diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index 2d50ec2e34e..88cfdb08a8c 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -1385,10 +1385,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 *old_sampler = NULL; @@ -1411,7 +1411,6 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) } assert(old_sampler); - nir_variable *bare_sampler = NULL; /* If it is already bare, we just need to fix the shadow information */ if (glsl_type_is_bare_sampler(glsl_without_array(old_sampler->type))) @@ -1442,11 +1441,10 @@ 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 { + uint64_t var_key = ((uint64_t)old_var->data.descriptor_set << 32) | + old_var->data.binding; + nir_variable *new_var = _mesa_hash_table_u64_search(data, var_key); + if (!new_var) { if (glsl_type_is_bare_sampler(glsl_without_array(old_var->type))) new_var = old_var; else { @@ -1455,7 +1453,7 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) } new_var->type = get_bare_samplers_for_type(old_var->type, tex->is_shadow); - _mesa_hash_table_u64_insert(data, old_var->data.binding, new_var); + _mesa_hash_table_u64_insert(data, var_key, new_var); } b->cursor = nir_after_instr(&old_tail->instr); @@ -1485,10 +1483,10 @@ redirect_texture_derefs(struct nir_builder *b, nir_instr *instr, void *data) int texture_idx = nir_tex_instr_src_index(tex, nir_tex_src_texture_deref); if (texture_idx == -1) { /* No derefs, must be using indices */ - struct hash_entry *hash_entry = _mesa_hash_table_u64_search(data, tex->texture_index); + nir_variable *bare_sampler = _mesa_hash_table_u64_search(data, tex->texture_index); /* Already have a texture here */ - if (hash_entry) + if (bare_sampler) return false; nir_variable *typed_sampler = NULL; @@ -1509,7 +1507,7 @@ redirect_texture_derefs(struct nir_builder *b, nir_instr *instr, void *data) /* Clone the typed sampler to a texture 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_textures_for_sampler_type(typed_sampler->type); nir_shader_add_variable(b->shader, bare_sampler); _mesa_hash_table_u64_insert(data, tex->texture_index, bare_sampler); @@ -1529,15 +1527,14 @@ redirect_texture_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 { + uint64_t var_key = ((uint64_t)old_var->data.descriptor_set << 32) | + old_var->data.binding; + nir_variable *new_var = _mesa_hash_table_u64_search(data, var_key); + if (!new_var) { new_var = nir_variable_clone(old_var, b->shader); new_var->type = get_textures_for_sampler_type(old_var->type); nir_shader_add_variable(b->shader, new_var); - _mesa_hash_table_u64_insert(data, old_var->data.binding, new_var); + _mesa_hash_table_u64_insert(data, var_key, new_var); } b->cursor = nir_after_instr(&old_tail->instr);