From a1c1a606307d8a8c8cb5cd53ca94257a3dfe0146 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 22 Nov 2021 07:31:00 -0800 Subject: [PATCH] microsoft/compiler: Fix dxil_nir_create_bare_samplers() _mesa_hash_table_u64_search() returns the data directly, not an hash_entry object. Fixes: 46bc7cf6783 ("microsoft/compiler: Rewrite sampler splitting pass to be smarter and handle derefs") Signed-off-by: Boris Brezillon Reviewed-by: Jesse Natalie (cherry picked from commit 83280b8e23e721cb39f66a4d7cad4fd2d7143045) Part-of: --- .pick_status.json | 2 +- src/microsoft/compiler/dxil_nir.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e6859957e0a..738dea8918d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -10678,7 +10678,7 @@ "description": "microsoft/compiler: Fix dxil_nir_create_bare_samplers()", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "46bc7cf6783f184073a123add854c82cc7140d27" }, diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index d968d98b46b..baff2c7c83e 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -1386,10 +1386,10 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) int sampler_idx = nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref); if (sampler_idx == -1) { /* No derefs, must be using indices */ - struct hash_entry *hash_entry = _mesa_hash_table_u64_search(data, tex->sampler_index); + nir_variable *bare_sampler = _mesa_hash_table_u64_search(data, tex->sampler_index); /* Already have a bare sampler here */ - if (hash_entry) + if (bare_sampler) return false; nir_variable *typed_sampler = NULL; @@ -1408,7 +1408,7 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) /* Clone the typed sampler to a bare sampler and we're done */ assert(typed_sampler); - nir_variable *bare_sampler = nir_variable_clone(typed_sampler, b->shader); + bare_sampler = nir_variable_clone(typed_sampler, b->shader); bare_sampler->type = get_bare_samplers_for_type(typed_sampler->type); nir_shader_add_variable(b->shader, bare_sampler); _mesa_hash_table_u64_insert(data, tex->sampler_index, bare_sampler); @@ -1428,11 +1428,8 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) return false; } - struct hash_entry *hash_entry = _mesa_hash_table_u64_search(data, old_var->data.binding); - nir_variable *new_var; - if (hash_entry) { - new_var = hash_entry->data; - } else { + nir_variable *new_var = _mesa_hash_table_u64_search(data, old_var->data.binding); + if (!new_var) { new_var = nir_variable_clone(old_var, b->shader); new_var->type = get_bare_samplers_for_type(old_var->type); nir_shader_add_variable(b->shader, new_var);