r300: make occlusion queries work without a bound depth buffer

Reviewed-by: Filip Gawin <filip@gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39880>
This commit is contained in:
Pavel Ondračka 2026-02-12 09:42:27 +01:00 committed by Marge Bot
parent 4e461d1569
commit 20c2dad006
6 changed files with 62 additions and 32 deletions

View file

@ -565,7 +565,6 @@ spec@!opengl 1.4@triangle-rasterization,Fail
spec@!opengl 1.4@triangle-rasterization-fbo,Fail
spec@!opengl 2.0@gl-2.0-two-sided-stencil,Fail
spec@!opengl 2.0@occlusion-query-discard,Fail
spec@!opengl 2.1@pbo,Fail
spec@!opengl 2.1@pbo@test_polygon_stip,Fail
@ -727,8 +726,6 @@ spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
spec@ext_occlusion_query_boolean@any-samples,Fail
spec@ext_texture_format_bgra8888@api-errors,Fail
spec@ext_texture_snorm@fbo-alphatest-formats,Fail
@ -1161,13 +1158,6 @@ spec@khr_texture_compression_astc@miptree-gl srgb-fp@sRGB decode full precision,
spec@khr_texture_compression_astc@miptree-gles srgb,Fail
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
spec@nv_conditional_render@bitmap,Fail
spec@nv_conditional_render@clear,Fail
spec@nv_conditional_render@copypixels,Fail
spec@nv_conditional_render@dlist,Fail
spec@nv_conditional_render@drawpixels,Fail
spec@nv_conditional_render@vertex_array,Fail
spec@nv_primitive_restart@primitive-restart-draw-mode-lines,Fail
spec@nv_primitive_restart@primitive-restart-draw-mode-quad_strip,Fail
spec@nv_primitive_restart@primitive-restart-draw-mode-quads,Fail

View file

@ -564,7 +564,6 @@ spec@!opengl 1.4@triangle-rasterization-fbo,Fail
spec@!opengl 2.0@gl-2.0-edgeflag,Fail
spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
spec@!opengl 2.0@gl-2.0-two-sided-stencil,Fail
spec@!opengl 2.0@occlusion-query-discard,Fail
spec@!opengl 2.0@tex3d-npot,Fail
spec@!opengl 2.1@pbo,Fail
@ -725,8 +724,6 @@ spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
spec@ext_occlusion_query_boolean@any-samples,Fail
spec@ext_texture_format_bgra8888@api-errors,Fail
spec@ext_texture_snorm@fbo-alphatest-formats,Fail
@ -1211,13 +1208,6 @@ spec@khr_texture_compression_astc@miptree-gl srgb-fp@sRGB decode full precision,
spec@khr_texture_compression_astc@miptree-gles srgb,Fail
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
spec@nv_conditional_render@bitmap,Fail
spec@nv_conditional_render@clear,Fail
spec@nv_conditional_render@copypixels,Fail
spec@nv_conditional_render@dlist,Fail
spec@nv_conditional_render@drawpixels,Fail
spec@nv_conditional_render@vertex_array,Fail
# uprev Piglit in Mesa
spec@glsl-1.10@execution@glsl-fs-texture2d-mipmap-const-bias-01,Fail
spec@glsl-1.10@execution@glsl-fs-texture2d-mipmap-const-bias-04,Fail

View file

@ -405,7 +405,6 @@ spec@!opengl 1.4@triangle-rasterization-fbo,Fail
spec@!opengl 2.0@gl-2.0-edgeflag,Fail
spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
spec@!opengl 2.0@occlusion-query-discard,Fail
spec@!opengl 2.0@tex3d-npot,Fail
spec@!opengl 2.1@pbo,Fail
@ -549,8 +548,6 @@ spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
spec@ext_occlusion_query_boolean@any-samples,Fail
spec@ext_texture_compression_rgtc@rgtc-teximage-01,Fail
spec@ext_texture_compression_rgtc@rgtc-teximage-02,Fail
@ -694,13 +691,6 @@ spec@khr_texture_compression_astc@miptree-gl srgb-fp@sRGB decode full precision,
spec@khr_texture_compression_astc@miptree-gles srgb,Fail
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
spec@nv_conditional_render@bitmap,Fail
spec@nv_conditional_render@clear,Fail
spec@nv_conditional_render@copypixels,Fail
spec@nv_conditional_render@dlist,Fail
spec@nv_conditional_render@drawpixels,Fail
spec@nv_conditional_render@vertex_array,Fail
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/10557
dEQP-GLES2.functional.texture.mipmap.2d.projected.nearest_nearest_mirror,Fail
dEQP-GLES2.functional.texture.mipmap.2d.projected.nearest_nearest_repeat,Fail

View file

@ -208,7 +208,7 @@ static bool r300_setup_atoms(struct r300_context* r300)
R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 4 : 0);
R300_INIT_ATOM(cmask_clear, 4);
/* ZB (unpipelined), SU. */
R300_INIT_ATOM(query_start, 4);
R300_INIT_ATOM(query_start, 14);
/* Replace emission functions for r500. */
if (is_r500) {

View file

@ -69,6 +69,9 @@ void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state)
bool is_r500 = r300->screen->caps.is_r500;
CS_LOCALS(r300);
uint32_t alpha_func = dsa->alpha_function;
bool force_query_z =
r300->query_current &&
(!fb->zsbuf.texture || !dsa->dsa.depth_enabled);
/* Choose the alpha ref value between 8-bit (FG_ALPHA_FUNC.AM_VAL) and
* 16-bit (FG_ALPHA_VALUE). */
@ -91,6 +94,27 @@ void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state)
R300_FG_ALPHA_FUNC_CFG_3_OF_6;
}
if (force_query_z) {
uint32_t z_buffer_control = dsa->z_buffer_control | R300_Z_ENABLE;
uint32_t z_stencil_control = dsa->z_stencil_control;
z_stencil_control &= ~(R300_ZS_MASK << R300_Z_FUNC_SHIFT);
z_stencil_control |= R300_ZS_ALWAYS << R300_Z_FUNC_SHIFT;
BEGIN_CS(size);
OUT_CS_REG(R300_FG_ALPHA_FUNC, alpha_func);
OUT_CS_REG_SEQ(R300_ZB_CNTL, 3);
OUT_CS(z_buffer_control);
OUT_CS(z_stencil_control);
OUT_CS(dsa->stencil_ref_mask);
if (is_r500) {
OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf);
OUT_CS_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
}
END_CS;
return;
}
BEGIN_CS(size);
OUT_CS_REG(R300_FG_ALPHA_FUNC, alpha_func);
OUT_CS_TABLE(fb->zsbuf.texture ? &dsa->cb_begin : dsa->cb_zb_no_readwrite, size-2);
@ -639,17 +663,49 @@ void r300_emit_fb_state_pipelined(struct r300_context *r300,
void r300_emit_query_start(struct r300_context *r300, unsigned size, void*state)
{
struct r300_query *query = r300->query_current;
struct pipe_framebuffer_state *fb =
(struct pipe_framebuffer_state *)r300->fb_state.state;
struct r300_surface *surf = NULL;
bool use_dummy_z = false;
unsigned dwords = 4;
CS_LOCALS(r300);
if (!query)
return;
BEGIN_CS(size);
/* If there is no depth buffer, bind a temporary dummy one to satisfy
* ZPASS accounting and the CS checker.
*/
if (fb && !fb->zsbuf.texture && fb->nr_cbufs) {
struct pipe_surface *cb = r300_get_nonnull_cb(r300, fb, 0);
if (cb) {
surf = r300_surface(cb);
use_dummy_z = true;
}
}
if (use_dummy_z) {
dwords += 10;
}
BEGIN_CS(dwords);
if (r300->screen->caps.family == CHIP_RV530) {
OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
} else {
OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL);
}
if (use_dummy_z) {
OUT_CS_REG(R300_ZB_FORMAT, R300_DEPTHFORMAT_16BIT_INT_Z);
OUT_CS_REG(R300_ZB_DEPTHOFFSET, 0);
OUT_CS_RELOC(surf);
OUT_CS_REG(R300_ZB_DEPTHPITCH, 4 | R300_DEPTHMICROTILE_TILED_SQUARE);
OUT_CS_RELOC(surf);
}
OUT_CS_REG(R300_ZB_ZPASS_DATA, 0);
END_CS;
query->begin_emitted = true;

View file

@ -980,6 +980,10 @@ void r300_mark_fb_state_dirty(struct r300_context *r300,
r300_mark_atom_dirty(r300, &r300->fb_state_pipelined);
}
if (r300->query_current) {
r300_mark_atom_dirty(r300, &r300->query_start);
}
/* Now compute the fb_state atom size. */
r300->fb_state.size = 2 + (8 * state->nr_cbufs);