aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/cso_cache
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-01-20 22:59:49 -0500
committerMarge Bot <[email protected]>2020-02-28 00:53:45 +0000
commitc9e4dc8d5e8f5e860f93eb3555a507402506b59a (patch)
tree60fe237f31934f94d67728e7d2940221b514faef /src/gallium/auxiliary/cso_cache
parent6c90e39a5b854595e3bbbf30f01aaf7dc798158e (diff)
gallium: pass cso_velems_state into cso_context instead of pipe_vertex_element
This removes one memcpy from the CSO hashing code. Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3990>
Diffstat (limited to 'src/gallium/auxiliary/cso_cache')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c33
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h7
2 files changed, 17 insertions, 23 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index d7c017a91f2..ff40f19e685 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1061,34 +1061,31 @@ void cso_delete_compute_shader(struct cso_context *ctx, void *handle)
static void
cso_set_vertex_elements_direct(struct cso_context *ctx,
- unsigned count,
- const struct pipe_vertex_element *states)
+ const struct cso_velems_state *velems)
{
unsigned key_size, hash_key;
struct cso_hash_iter iter;
void *handle;
- struct cso_velems_state velems_state;
/* Need to include the count into the stored state data too.
* Otherwise first few count pipe_vertex_elements could be identical
* even if count is different, and there's no guarantee the hash would
* be different in that case neither.
*/
- key_size = sizeof(struct pipe_vertex_element) * count + sizeof(unsigned);
- velems_state.count = count;
- memcpy(velems_state.velems, states,
- sizeof(struct pipe_vertex_element) * count);
- hash_key = cso_construct_key((void*)&velems_state, key_size);
+ key_size = sizeof(struct pipe_vertex_element) * velems->count +
+ sizeof(unsigned);
+ hash_key = cso_construct_key((void*)velems, key_size);
iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS,
- (void*)&velems_state, key_size);
+ (void*)velems, key_size);
if (cso_hash_iter_is_null(iter)) {
struct cso_velements *cso = MALLOC(sizeof(struct cso_velements));
if (!cso)
return;
- memcpy(&cso->state, &velems_state, key_size);
- cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, count,
+ memcpy(&cso->state, velems, key_size);
+ cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe,
+ velems->count,
&cso->state.velems[0]);
cso->delete_state =
(cso_state_callback) ctx->pipe->delete_vertex_elements_state;
@@ -1114,17 +1111,16 @@ cso_set_vertex_elements_direct(struct cso_context *ctx,
enum pipe_error
cso_set_vertex_elements(struct cso_context *ctx,
- unsigned count,
- const struct pipe_vertex_element *states)
+ const struct cso_velems_state *velems)
{
struct u_vbuf *vbuf = ctx->vbuf_current;
if (vbuf) {
- u_vbuf_set_vertex_elements(vbuf, count, states);
+ u_vbuf_set_vertex_elements(vbuf, velems);
return PIPE_OK;
}
- cso_set_vertex_elements_direct(ctx, count, states);
+ cso_set_vertex_elements_direct(ctx, velems);
return PIPE_OK;
}
@@ -1241,8 +1237,7 @@ cso_restore_vertex_buffer0(struct cso_context *ctx)
*/
void
cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
- unsigned velem_count,
- const struct pipe_vertex_element *velems,
+ const struct cso_velems_state *velems,
unsigned vb_count,
unsigned unbind_trailing_vb_count,
const struct pipe_vertex_buffer *vbuffers,
@@ -1267,7 +1262,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
if (vb_count)
u_vbuf_set_vertex_buffers(vbuf, 0, vb_count, vbuffers);
- u_vbuf_set_vertex_elements(vbuf, velem_count, velems);
+ u_vbuf_set_vertex_elements(vbuf, velems);
return;
}
@@ -1287,7 +1282,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
if (vb_count)
cso_set_vertex_buffers_direct(ctx, 0, vb_count, vbuffers);
- cso_set_vertex_elements_direct(ctx, velem_count, velems);
+ cso_set_vertex_elements_direct(ctx, velems);
}
void
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index 0204ace34b7..447630943f5 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -32,6 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "cso_cache.h"
#ifdef __cplusplus
@@ -82,8 +83,7 @@ cso_single_sampler_done(struct cso_context *cso,
enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
- unsigned count,
- const struct pipe_vertex_element *states);
+ const struct cso_velems_state *velems);
void cso_set_vertex_buffers(struct cso_context *ctx,
unsigned start_slot, unsigned count,
@@ -222,8 +222,7 @@ void cso_restore_constant_buffer_slot0(struct cso_context *cso,
/* Optimized version. */
void
cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
- unsigned velem_count,
- const struct pipe_vertex_element *velems,
+ const struct cso_velems_state *velems,
unsigned vb_count,
unsigned unbind_trailing_vb_count,
const struct pipe_vertex_buffer *vbuffers,