summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2022-06-07 18:24:36 -0400
committerMarge Bot <emma+marge@anholt.net>2022-06-09 12:17:45 +0000
commitb818c0862bc3c78f0e028292349824aedd675e9c (patch)
tree6d26e3b86544421163165d5cfdf4841f7537ae87
parentbcc22b9e4d8767e1b8660eeca4a7b6ad13eb3dbc (diff)
zink: simplify some compiler bo code
this is a bit easier to read Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16927>
-rw-r--r--src/gallium/drivers/zink/zink_compiler.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 21923ed0190..2b579cff5bc 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -962,7 +962,8 @@ rewrite_bo_access(nir_shader *shader, struct zink_screen *screen)
}
struct bo_vars {
- nir_variable *ubo[2][5];
+ nir_variable *uniforms[5];
+ nir_variable *ubo[5];
nir_variable *ssbo[5];
uint32_t first_ubo;
uint32_t first_ssbo;
@@ -972,19 +973,26 @@ static nir_variable *
get_bo_var(nir_shader *shader, struct bo_vars *bo, bool ssbo, nir_src *src, unsigned bit_size)
{
nir_variable *var, **ptr;
- nir_variable **arr = (nir_variable**)bo->ubo;
unsigned idx = ssbo || (nir_src_is_const(*src) && !nir_src_as_uint(*src)) ? 0 : 1;
if (ssbo)
ptr = &bo->ssbo[bit_size >> 4];
- else
- ptr = &arr[idx * 5 + (bit_size >> 4)];
+ else {
+ if (!idx) {
+ ptr = &bo->uniforms[bit_size >> 4];
+ } else
+ ptr = &bo->ubo[bit_size >> 4];
+ }
var = *ptr;
if (!var) {
if (ssbo)
var = bo->ssbo[32 >> 4];
- else
- var = arr[idx * 5 + (32 >> 4)];
+ else {
+ if (!idx)
+ var = bo->uniforms[32 >> 4];
+ else
+ var = bo->ubo[32 >> 4];
+ }
var = nir_variable_clone(var, shader);
*ptr = var;
nir_shader_add_variable(shader, var);
@@ -1105,8 +1113,13 @@ remove_bo_access(nir_shader *shader, struct zink_shader *zs)
assert(!bo.ssbo[32 >> 4]);
bo.ssbo[32 >> 4] = var;
} else {
- assert(!bo.ubo[!!var->data.driver_location][32 >> 4]);
- bo.ubo[!!var->data.driver_location][32 >> 4] = var;
+ if (var->data.driver_location) {
+ assert(!bo.ubo[32 >> 4]);
+ bo.ubo[32 >> 4] = var;
+ } else {
+ assert(!bo.uniforms[32 >> 4]);
+ bo.uniforms[32 >> 4] = var;
+ }
}
}
return nir_shader_instructions_pass(shader, remove_bo_access_instr, nir_metadata_dominance, &bo);