Mesa (main): gallium/draw: Properly handle nr_samplers != nr_sampler_views in keys
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 12 02:03:44 UTC 2022
Module: Mesa
Branch: main
Commit: bbd5883c87e149417e3be53490296edbbe72ed8f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbd5883c87e149417e3be53490296edbbe72ed8f
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Tue May 10 15:58:36 2022 -0500
gallium/draw: Properly handle nr_samplers != nr_sampler_views in keys
First, make all key_size functions take nr_samplers and nr_sampler_views
separately so we ensure both get passed in. Second, rework the offset
helpers to take MAX(nr_samplers, nr_sampler_views) so we get the image
param offset correct if nr_samplers < nr_sampler_views. While we're
here, also re-order the size calculations to be in the same order as the
things land in memory.
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16435>
---
src/gallium/auxiliary/draw/draw_gs.c | 4 +--
src/gallium/auxiliary/draw/draw_llvm.h | 46 +++++++++++++++++++------------
src/gallium/auxiliary/draw/draw_tess.c | 8 +++---
src/gallium/auxiliary/draw/draw_vs_llvm.c | 4 +--
4 files changed, 37 insertions(+), 25 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 66e10b077d2..61cf47aa596 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -888,8 +888,8 @@ draw_create_geometry_shader(struct draw_context *draw,
llvm_gs->variant_key_size =
draw_gs_llvm_variant_key_size(
- MAX2(gs->info.file_max[TGSI_FILE_SAMPLER]+1,
- gs->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
+ gs->info.file_max[TGSI_FILE_SAMPLER]+1,
+ gs->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1,
gs->info.file_max[TGSI_FILE_IMAGE]+1);
} else
#endif
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h
index 4e118bef091..50525cbd25b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -577,37 +577,49 @@ struct draw_tes_llvm_variant_key
static inline size_t
draw_llvm_variant_key_size(unsigned nr_vertex_elements,
- unsigned nr_samplers, unsigned nr_images)
+ unsigned nr_samplers,
+ unsigned nr_sampler_views,
+ unsigned nr_images)
{
return (sizeof(struct draw_llvm_variant_key) +
- nr_samplers * sizeof(struct draw_sampler_static_state) +
- nr_images * sizeof(struct draw_image_static_state) +
- (nr_vertex_elements - 1) * sizeof(struct pipe_vertex_element));
+ (nr_vertex_elements - 1) * sizeof(struct pipe_vertex_element) +
+ MAX2(nr_samplers, nr_sampler_views) *
+ sizeof(struct draw_sampler_static_state) +
+ nr_images * sizeof(struct draw_image_static_state));
}
static inline size_t
-draw_gs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
+draw_gs_llvm_variant_key_size(unsigned nr_samplers,
+ unsigned nr_sampler_views,
+ unsigned nr_images)
{
return (sizeof(struct draw_gs_llvm_variant_key) +
- (nr_images) * sizeof(struct draw_sampler_static_state) +
- (nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
+ (MAX2(nr_samplers, nr_sampler_views) - 1) *
+ sizeof(struct draw_sampler_static_state) +
+ nr_images * sizeof(struct draw_sampler_static_state));
}
static inline size_t
-draw_tcs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
+draw_tcs_llvm_variant_key_size(unsigned nr_samplers,
+ unsigned nr_sampler_views,
+ unsigned nr_images)
{
return (sizeof(struct draw_tcs_llvm_variant_key) +
- (nr_images) * sizeof(struct draw_sampler_static_state) +
- (nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
+ (MAX2(nr_samplers, nr_sampler_views) - 1) *
+ sizeof(struct draw_sampler_static_state) +
+ nr_images * sizeof(struct draw_sampler_static_state));
}
static inline size_t
-draw_tes_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
+draw_tes_llvm_variant_key_size(unsigned nr_samplers,
+ unsigned nr_sampler_views,
+ unsigned nr_images)
{
return (sizeof(struct draw_tes_llvm_variant_key) +
- (nr_images) * sizeof(struct draw_sampler_static_state) +
- (nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
+ (MAX2(nr_samplers, nr_sampler_views) - 1) *
+ sizeof(struct draw_sampler_static_state) +
+ nr_images * sizeof(struct draw_sampler_static_state));
}
static inline struct draw_sampler_static_state *
@@ -623,28 +635,28 @@ draw_llvm_variant_key_images(struct draw_llvm_variant_key *key)
struct draw_sampler_static_state *samplers = (struct draw_sampler_static_state *)
(&key->vertex_element[key->nr_vertex_elements]);
return (struct draw_image_static_state *)
- &samplers[key->nr_samplers];
+ &samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
static inline struct draw_image_static_state *
draw_gs_llvm_variant_key_images(struct draw_gs_llvm_variant_key *key)
{
return (struct draw_image_static_state *)
- &key->samplers[key->nr_samplers];
+ &key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
static inline struct draw_image_static_state *
draw_tcs_llvm_variant_key_images(struct draw_tcs_llvm_variant_key *key)
{
return (struct draw_image_static_state *)
- &key->samplers[key->nr_samplers];
+ &key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
static inline struct draw_image_static_state *
draw_tes_llvm_variant_key_images(struct draw_tes_llvm_variant_key *key)
{
return (struct draw_image_static_state *)
- &key->samplers[key->nr_samplers];
+ &key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
struct draw_llvm_variant_list_item
diff --git a/src/gallium/auxiliary/draw/draw_tess.c b/src/gallium/auxiliary/draw/draw_tess.c
index f42cd5799ce..313996ef6db 100644
--- a/src/gallium/auxiliary/draw/draw_tess.c
+++ b/src/gallium/auxiliary/draw/draw_tess.c
@@ -460,8 +460,8 @@ draw_create_tess_ctrl_shader(struct draw_context *draw,
tcs->jit_context = &draw->llvm->tcs_jit_context;
llvm_tcs->variant_key_size =
draw_tcs_llvm_variant_key_size(
- MAX2(tcs->info.file_max[TGSI_FILE_SAMPLER]+1,
- tcs->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
+ tcs->info.file_max[TGSI_FILE_SAMPLER]+1,
+ tcs->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1,
tcs->info.file_max[TGSI_FILE_IMAGE]+1);
}
#endif
@@ -585,8 +585,8 @@ draw_create_tess_eval_shader(struct draw_context *draw,
tes->jit_context = &draw->llvm->tes_jit_context;
llvm_tes->variant_key_size =
draw_tes_llvm_variant_key_size(
- MAX2(tes->info.file_max[TGSI_FILE_SAMPLER]+1,
- tes->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
+ tes->info.file_max[TGSI_FILE_SAMPLER]+1,
+ tes->info.file_max[TGSI_FILE_SAMPLER_VIEW]+1,
tes->info.file_max[TGSI_FILE_IMAGE]+1);
}
#endif
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index d71dd177411..5e09f6ab727 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -111,8 +111,8 @@ draw_create_vs_llvm(struct draw_context *draw,
vs->variant_key_size =
draw_llvm_variant_key_size(
vs->base.info.file_max[TGSI_FILE_INPUT]+1,
- MAX2(vs->base.info.file_max[TGSI_FILE_SAMPLER]+1,
- vs->base.info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
+ vs->base.info.file_max[TGSI_FILE_SAMPLER]+1,
+ vs->base.info.file_max[TGSI_FILE_SAMPLER_VIEW]+1,
vs->base.info.file_max[TGSI_FILE_IMAGE]+1);
vs->base.state.type = state->type;
More information about the mesa-commit
mailing list