Module: Mesa Branch: main Commit: 224735abaf9352249df0902c442115ead304921d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=224735abaf9352249df0902c442115ead304921d
Author: Marek Olšák <[email protected]> Date: Sat Aug 6 17:28:34 2022 -0400 cso: constify some parameters to remove typecasts Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19129> --- src/gallium/auxiliary/cso_cache/cso_cache.c | 2 +- src/gallium/auxiliary/cso_cache/cso_cache.h | 7 ++++--- src/gallium/auxiliary/cso_cache/cso_context.c | 20 ++++++++++---------- src/gallium/auxiliary/util/u_vbuf.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c index d0a97fbc30d..c40fd1bf7fb 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.c +++ b/src/gallium/auxiliary/cso_cache/cso_cache.c @@ -151,7 +151,7 @@ cso_hash_find_data_from_template(struct cso_hash *hash, struct cso_hash_iter cso_find_state_template(struct cso_cache *sc, unsigned hash_key, enum cso_cache_type type, - void *templ, unsigned size) + const void *templ, unsigned size) { struct cso_hash_iter iter = cso_find_state(sc, hash_key, type); while (!cso_hash_iter_is_null(iter)) { diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h index 20f2e0ad76d..7adbdadd6d5 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.h +++ b/src/gallium/auxiliary/cso_cache/cso_cache.h @@ -174,7 +174,7 @@ cso_find_state(struct cso_cache *sc, struct cso_hash_iter cso_find_state_template(struct cso_cache *sc, unsigned hash_key, enum cso_cache_type type, - void *templ, unsigned size); + const void *templ, unsigned size); void cso_set_maximum_cache_size(struct cso_cache *sc, int number); @@ -185,9 +185,10 @@ cso_delete_state(struct pipe_context *pipe, void *state, static inline unsigned -cso_construct_key(void *key, int key_size) +cso_construct_key(const void *key, int key_size) { - unsigned hash = 0, *ikey = (unsigned *)key; + unsigned hash = 0; + const unsigned *ikey = (const unsigned *)key; unsigned num_elements = key_size / 4; assert(key_size % 4 == 0); diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 23ab26473d6..0d276fb033d 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -456,10 +456,10 @@ cso_set_blend(struct cso_context *ctx, const unsigned key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) : (char *)&(templ->rt[1]) - (char *)templ; - const unsigned hash_key = cso_construct_key((void*)templ, key_size); + const unsigned hash_key = cso_construct_key(templ, key_size); struct cso_hash_iter iter = - cso_find_state_template(&ctx->cache, hash_key, CSO_BLEND, - (void*)templ, key_size); + cso_find_state_template(&ctx->cache, hash_key, CSO_BLEND, templ, + key_size); void *handle; if (cso_hash_iter_is_null(iter)) { @@ -514,11 +514,11 @@ cso_set_depth_stencil_alpha(struct cso_context *ctx, const struct pipe_depth_stencil_alpha_state *templ) { const unsigned key_size = sizeof(struct pipe_depth_stencil_alpha_state); - const unsigned hash_key = cso_construct_key((void*)templ, key_size); + const unsigned hash_key = cso_construct_key(templ, key_size); struct cso_hash_iter iter = cso_find_state_template(&ctx->cache, hash_key, CSO_DEPTH_STENCIL_ALPHA, - (void*)templ, key_size); + templ, key_size); void *handle; if (cso_hash_iter_is_null(iter)) { @@ -577,11 +577,11 @@ cso_set_rasterizer(struct cso_context *ctx, const struct pipe_rasterizer_state *templ) { const unsigned key_size = sizeof(struct pipe_rasterizer_state); - const unsigned hash_key = cso_construct_key((void*)templ, key_size); + const unsigned hash_key = cso_construct_key(templ, key_size); struct cso_hash_iter iter = cso_find_state_template(&ctx->cache, hash_key, CSO_RASTERIZER, - (void*)templ, key_size); + templ, key_size); void *handle = NULL; /* We can't have both point_quad_rasterization (sprites) and point_smooth @@ -1097,7 +1097,7 @@ cso_set_vertex_elements_direct(struct cso_context *ctx, const unsigned hash_key = cso_construct_key((void*)velems, key_size); struct cso_hash_iter iter = cso_find_state_template(&ctx->cache, hash_key, CSO_VELEMENTS, - (void*)velems, key_size); + velems, key_size); void *handle; if (cso_hash_iter_is_null(iter)) { @@ -1279,12 +1279,12 @@ set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage, unsigned idx, const struct pipe_sampler_state *templ, size_t key_size) { - unsigned hash_key = cso_construct_key((void*)templ, key_size); + unsigned hash_key = cso_construct_key(templ, key_size); struct cso_sampler *cso; struct cso_hash_iter iter = cso_find_state_template(&ctx->cache, hash_key, CSO_SAMPLER, - (void *) templ, key_size); + templ, key_size); if (cso_hash_iter_is_null(iter)) { cso = MALLOC(sizeof(struct cso_sampler)); diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 4a8f6cd284a..357dc3e93e4 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -393,9 +393,9 @@ u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, /* need to include the count into the stored state data too. */ key_size = sizeof(struct pipe_vertex_element) * velems->count + sizeof(unsigned); - hash_key = cso_construct_key((void*)velems, key_size); + hash_key = cso_construct_key(velems, key_size); iter = cso_find_state_template(&mgr->cso_cache, hash_key, CSO_VELEMENTS, - (void*)velems, key_size); + velems, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_velements *cso = MALLOC_STRUCT(cso_velements);
