From d9baadcfb5b70db909b415b1939a5351b7c8ab6e Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 4 Jul 2025 14:46:13 +0200 Subject: [PATCH] r600: set never as the depth compare function when depth compare is disabled This is the backport of 0c0b9789380 "radeonsi: set NEVER as the depth compare func if depth compare is disabled". The function r600_tex_compare arguments are updated with the "const" keyword. This change fixes the test below which was broken after 0c6e56c391a: khr-gl4[5-6]/incomplete_texture_access/sampler: fail pass Fixes: 0c6e56c391a ("mesa: (more) correctly handle incomplete depth textures") Signed-off-by: Patrick Lerda Acked-by: Vitaliy Triang3l Kuzmin Reviewed-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/evergreen_state.c | 2 +- src/gallium/drivers/r600/r600_pipe.h | 3 ++- src/gallium/drivers/r600/r600_state.c | 2 +- src/gallium/drivers/r600/r600_state_common.c | 6 +++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index a8c3f0c21cc..d30ed227d28 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -616,7 +616,7 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx, S_03C000_XY_MIN_FILTER(eg_tex_filter(state->min_img_filter, max_aniso)) | S_03C000_MIP_FILTER(r600_tex_mipfilter(state->min_mip_filter)) | S_03C000_MAX_ANISO_RATIO(max_aniso_ratio) | - S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_func)) | + S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_mode, state->compare_func)) | S_03C000_BORDER_COLOR_TYPE(ss->border_color_use ? V_03C000_SQ_TEX_BORDER_COLOR_REGISTER : 0); /* R_03C004_SQ_TEX_SAMPLER_WORD1_0 */ ss->tex_sampler_words[1] = diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 764e39f423e..86f32800b99 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -848,7 +848,8 @@ uint32_t r600_translate_stencil_op(int s_op); uint32_t r600_translate_fill(uint32_t func); unsigned r600_tex_wrap(unsigned wrap); unsigned r600_tex_mipfilter(unsigned filter); -unsigned r600_tex_compare(unsigned compare); +unsigned r600_tex_compare(const unsigned mode, + const unsigned compare); bool sampler_state_needs_border_color(const struct pipe_sampler_state *state); unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format, const unsigned char *swizzle_view, diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index f78d54cf483..854de515610 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -598,7 +598,7 @@ static void *r600_create_sampler_state(struct pipe_context *ctx, S_03C000_XY_MIN_FILTER(r600_tex_filter(state->min_img_filter, max_aniso)) | S_03C000_MIP_FILTER(r600_tex_mipfilter(state->min_mip_filter)) | S_03C000_MAX_ANISO_RATIO(max_aniso_ratio) | - S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_func)) | + S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_mode, state->compare_func)) | S_03C000_BORDER_COLOR_TYPE(ss->border_color_use ? V_03C000_SQ_TEX_BORDER_COLOR_REGISTER : 0); /* R_03C004_SQ_TEX_SAMPLER_WORD1_0 */ ss->tex_sampler_words[1] = diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 94bb71d4d13..f926b7c13da 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -3107,8 +3107,12 @@ unsigned r600_tex_mipfilter(unsigned filter) } } -unsigned r600_tex_compare(unsigned compare) +unsigned r600_tex_compare(const unsigned mode, + const unsigned compare) { + if (unlikely(mode == PIPE_TEX_COMPARE_NONE)) + return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER; + switch (compare) { default: case PIPE_FUNC_NEVER: