From cb96dab5c8fb8cc7e8b927349b6b076600c470c9 Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Thu, 8 Jun 2023 00:57:15 +0200 Subject: [PATCH] vc4: mark buffers as initialized at vc4_texture_subdata This fixes several tests when the initially uploaded buffer from CPU was being ignored because vc4_texture_subdata was not marking the resource as written/initialized. The usage flags management available at vc4_resource_transfer_map is generalized into vc4_map_usage_prep and reused at vc4_resource_transfer_map. This makes vc4 implementation more similar to v3d. This fixes 7 text in the following subgroups: -dEQP-GLES2.functional.fbo.render.texsubimage.* -dEQP-GLES2.functional.texture.specification.basic_copytexsubimage2d.* -spec@arb_clear_texture@arb_clear_texture-* Cc: mesa-stable Reviewed-by: Juan A. Suarez Reviewed-by: Emma Anholt Part-of: --- src/broadcom/ci/broadcom-rpi3-fails.txt | 14 ----- src/gallium/drivers/vc4/vc4_resource.c | 75 +++++++++++++++---------- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi3-fails.txt b/src/broadcom/ci/broadcom-rpi3-fails.txt index 0f91d158c0a..b14f49d7beb 100644 --- a/src/broadcom/ci/broadcom-rpi3-fails.txt +++ b/src/broadcom/ci/broadcom-rpi3-fails.txt @@ -18,11 +18,6 @@ dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES2.functional.depth_stencil_clear.depth_stencil_masked,Fail -# A glTexImage, glDraw, glTexSubImage sequence into a texture is missing what looks like the drawing. -dEQP-GLES2.functional.fbo.render.texsubimage.after_render_tex2d_rgba,Fail -# A glTexImage, glDraw, glTexSubImage, glDraw sequence into a texture is missing what looks like the first drawing. -dEQP-GLES2.functional.fbo.render.texsubimage.between_render_tex2d_rgba,Fail - # Sampling grid slightly off in test 2? dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_linear_linear_mirror_rgba8888,Fail dEQP-GLES2.functional.texture.filtering.2d.nearest_mipmap_linear_linear_repeat_rgba8888,Fail @@ -38,12 +33,6 @@ dEQP-GLES2.functional.texture.mipmap.2d.basic.nearest_linear_clamp_non_square,Fa dEQP-GLES2.functional.texture.mipmap.2d.basic.nearest_linear_mirror_non_square,Fail dEQP-GLES2.functional.texture.mipmap.2d.basic.nearest_linear_repeat_non_square,Fail -# Sequence of glTexImage, glDraw, glCopyTexSubImage. -# background red/green checkerboard on the left side is incorrectly white. -dEQP-GLES2.functional.texture.specification.basic_copytexsubimage2d.2d_rgba,Fail -# Maybe it was copied as RGB instead of RGBA? -dEQP-GLES2.functional.texture.specification.basic_copytexsubimage2d.cube_rgba,Fail - # One of the pixels on the left edge near the bottom is wrong for both min and # mag. Also a line of pixels through the image in minification. dEQP-GLES2.functional.texture.wrap.clamp_clamp_nearest_npot_etc1,Fail @@ -784,11 +773,8 @@ spec@!opengl 1.1@clipflat@glDrawElements(GL_TRIANGLE_STRIP)- glFrontFace(GL_CW)- spec@!opengl 1.1@clipflat@glDrawElements(GL_TRIANGLE_STRIP)- glFrontFace(GL_CW)- glPolygonMode(GL_LINE)- quadrant: right middle PV: FIRST,Fail spec@!opengl 1.1@clipflat@glDrawElements(GL_TRIANGLE_STRIP)- glFrontFace(GL_CW)- glPolygonMode(GL_LINE)- quadrant: right top PV: FIRST,Fail spec@arb_clear_texture@arb_clear_texture-3d,Fail -spec@arb_clear_texture@arb_clear_texture-base-formats,Fail spec@arb_clear_texture@arb_clear_texture-depth,Fail -spec@arb_clear_texture@arb_clear_texture-depth-stencil,Fail spec@arb_clear_texture@arb_clear_texture-sized-formats,Fail -spec@arb_clear_texture@arb_clear_texture-srgb,Fail spec@arb_clear_texture@arb_clear_texture-supported-formats,Fail spec@glsl-1.10@execution@glsl-fs-inline-explosion,Crash spec@glsl-1.10@execution@glsl-vs-inline-explosion,Crash diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index ad2791aa972..0a3a435a46c 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -95,6 +95,46 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx, slab_free(&vc4->transfer_pool, ptrans); } +static void +vc4_map_usage_prep(struct pipe_context *pctx, + struct pipe_resource *prsc, + unsigned usage) +{ + struct vc4_context *vc4 = vc4_context(pctx); + struct vc4_resource *rsc = vc4_resource(prsc); + + if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) { + if (vc4_resource_bo_alloc(rsc)) { + /* If it might be bound as one of our vertex buffers, + * make sure we re-emit vertex buffer state. + */ + if (prsc->bind & PIPE_BIND_VERTEX_BUFFER) + vc4->dirty |= VC4_DIRTY_VTXBUF; + if (prsc->bind & PIPE_BIND_CONSTANT_BUFFER) + vc4->dirty |= VC4_DIRTY_CONSTBUF; + } else { + /* If we failed to reallocate, flush users so that we + * don't violate any syncing requirements. + */ + vc4_flush_jobs_reading_resource(vc4, prsc); + } + } else if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) { + /* If we're writing and the buffer is being used by the CL, we + * have to flush the CL first. If we're only reading, we need + * to flush if the CL has written our buffer. + */ + if (usage & PIPE_MAP_WRITE) + vc4_flush_jobs_reading_resource(vc4, prsc); + else + vc4_flush_jobs_writing_resource(vc4, prsc); + } + + if (usage & PIPE_MAP_WRITE) { + rsc->writes++; + rsc->initialized_buffers = ~0; + } +} + static void * vc4_resource_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, @@ -124,34 +164,7 @@ vc4_resource_transfer_map(struct pipe_context *pctx, usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE; } - if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) { - if (vc4_resource_bo_alloc(rsc)) { - /* If it might be bound as one of our vertex buffers, - * make sure we re-emit vertex buffer state. - */ - if (prsc->bind & PIPE_BIND_VERTEX_BUFFER) - vc4->dirty |= VC4_DIRTY_VTXBUF; - } else { - /* If we failed to reallocate, flush users so that we - * don't violate any syncing requirements. - */ - vc4_flush_jobs_reading_resource(vc4, prsc); - } - } else if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) { - /* If we're writing and the buffer is being used by the CL, we - * have to flush the CL first. If we're only reading, we need - * to flush if the CL has written our buffer. - */ - if (usage & PIPE_MAP_WRITE) - vc4_flush_jobs_reading_resource(vc4, prsc); - else - vc4_flush_jobs_writing_resource(vc4, prsc); - } - - if (usage & PIPE_MAP_WRITE) { - rsc->writes++; - rsc->initialized_buffers = ~0; - } + vc4_map_usage_prep(pctx, prsc, usage); trans = slab_zalloc(&vc4->transfer_pool); if (!trans) @@ -240,8 +253,12 @@ vc4_texture_subdata(struct pipe_context *pctx, } /* Otherwise, map and store the texture data directly into the tiled - * texture. + * texture. Note that gallium's texture_subdata may be called with + * obvious usage flags missing! */ + vc4_map_usage_prep(pctx, prsc, usage | (PIPE_MAP_WRITE | + PIPE_MAP_DISCARD_RANGE)); + void *buf; if (usage & PIPE_MAP_UNSYNCHRONIZED) buf = vc4_bo_map_unsynchronized(rsc->bo);