diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e507ec6aa8c..813e6bd8e6f 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6472,7 +6472,8 @@ bool nir_lower_tex_shadow(nir_shader *s, unsigned n_states, enum compare_func *compare_func, - nir_lower_tex_shadow_swizzle *tex_swizzles); + nir_lower_tex_shadow_swizzle *tex_swizzles, + bool is_fixed_point_format); typedef struct nir_lower_image_options { /** diff --git a/src/compiler/nir/nir_lower_tex_shadow.c b/src/compiler/nir/nir_lower_tex_shadow.c index ec077a60d97..7e772f5570c 100644 --- a/src/compiler/nir/nir_lower_tex_shadow.c +++ b/src/compiler/nir/nir_lower_tex_shadow.c @@ -69,6 +69,7 @@ typedef struct { unsigned n_states; enum compare_func *compare_func; nir_lower_tex_shadow_swizzle *tex_swizzles; + bool is_fixed_point_format; } sampler_state; static nir_def * @@ -106,6 +107,9 @@ nir_lower_tex_shadow_impl(nir_builder *b, nir_instr *instr, void *options) if (proj_index >= 0) cmp = nir_fmul(b, cmp, nir_frcp(b, tex->src[proj_index].src.ssa)); + if (state->is_fixed_point_format) + cmp = nir_fsat(b, cmp); + nir_def *result = nir_compare_func(b, sampler_binding < state->n_states ? state->compare_func[sampler_binding] : COMPARE_FUNC_ALWAYS, @@ -142,9 +146,10 @@ bool nir_lower_tex_shadow(nir_shader *s, unsigned n_states, enum compare_func *compare_func, - nir_lower_tex_shadow_swizzle *tex_swizzles) + nir_lower_tex_shadow_swizzle *tex_swizzles, + bool is_fixed_point_format) { - sampler_state state = { n_states, compare_func, tex_swizzles }; + sampler_state state = { n_states, compare_func, tex_swizzles, is_fixed_point_format }; bool result = nir_shader_lower_instructions(s, diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp index 02b7859c805..0b0bfdfca47 100644 --- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp +++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp @@ -1125,8 +1125,12 @@ select_shader_variant(struct d3d12_selection_context *sel_ctx, d3d12_shader_sele STATIC_ASSERT(sizeof(dxil_texture_swizzle_state) == sizeof(nir_lower_tex_shadow_swizzle)); - NIR_PASS_V(new_nir_variant, nir_lower_tex_shadow, key.n_texture_states, - key.sampler_compare_funcs, (nir_lower_tex_shadow_swizzle *)key.swizzle_state); + NIR_PASS_V(new_nir_variant, + nir_lower_tex_shadow, + key.n_texture_states, + key.sampler_compare_funcs, + (nir_lower_tex_shadow_swizzle *) key.swizzle_state, + false); } if (key.stage == PIPE_SHADER_FRAGMENT) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c b/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c index 692bfff6d49..1d03c2a1c35 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c +++ b/src/gallium/drivers/etnaviv/etnaviv_nir_lower_texture.c @@ -42,7 +42,8 @@ etna_nir_lower_texture(nir_shader *s, struct etna_shader_key *key) if (key->has_sample_tex_compare) NIR_PASS(progress, s, nir_lower_tex_shadow, key->num_texture_states, key->tex_compare_func, - key->tex_swizzle); + key->tex_swizzle, + false); NIR_PASS(progress, s, nir_shader_instructions_pass, lower_txs, nir_metadata_control_flow, NULL);