From 5de33f3d3e155283ab72b6acccaee8eeeab4b710 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sun, 14 Jul 2024 08:44:00 -0700 Subject: [PATCH] freedreno: Implement stencil blit fallback Now that there is a util_blitter_clear_depth_stencil() helper, we can use that to implement stencil blits in the fallback path. Signed-off-by: Rob Clark Part-of: --- src/freedreno/ci/freedreno-a530-fails.txt | 12 ---- src/freedreno/ci/freedreno-a618-fails.txt | 2 - src/freedreno/ci/freedreno-a630-fails.txt | 2 - .../drivers/freedreno/freedreno_blitter.c | 56 ++++++++++++++++--- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/freedreno/ci/freedreno-a530-fails.txt b/src/freedreno/ci/freedreno-a530-fails.txt index e9f9c327261..dc9bef826a1 100644 --- a/src/freedreno/ci/freedreno-a530-fails.txt +++ b/src/freedreno/ci/freedreno-a530-fails.txt @@ -10,10 +10,7 @@ dEQP-GLES3.functional.clipping.point.wide_point_clip,Fail dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_center,Fail dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_corner,Fail dEQP-GLES3.functional.fbo.blit.depth_stencil.depth24_stencil8_basic,Fail -dEQP-GLES3.functional.fbo.blit.depth_stencil.depth24_stencil8_scale,Fail -dEQP-GLES3.functional.fbo.blit.depth_stencil.depth24_stencil8_stencil_only,Fail dEQP-GLES3.functional.fbo.blit.depth_stencil.depth32f_stencil8_basic,Fail -dEQP-GLES3.functional.fbo.blit.depth_stencil.depth32f_stencil8_scale,Fail dEQP-GLES3.functional.fbo.blit.depth_stencil.depth32f_stencil8_stencil_only,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag_reverse_dst_x,Fail @@ -29,20 +26,13 @@ dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_dst_x,Fa dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_dst_y,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_x,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_y,Fail -dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_color,Fail dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_depth,Fail -dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_msaa_color,Fail dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_msaa_depth,Fail dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_color,Fail dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_depth,Fail -dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_msaa_color,Fail -dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_msaa_depth,Fail -dEQP-GLES3.functional.fbo.msaa.2_samples.depth24_stencil8,Fail dEQP-GLES3.functional.fbo.msaa.2_samples.depth32f_stencil8,Fail dEQP-GLES3.functional.fbo.msaa.2_samples.stencil_index8,Fail -dEQP-GLES3.functional.fbo.msaa.4_samples.depth24_stencil8,Fail dEQP-GLES3.functional.fbo.msaa.4_samples.depth32f_stencil8,Fail -dEQP-GLES3.functional.fbo.msaa.4_samples.stencil_index8,Fail dEQP-GLES3.functional.polygon_offset.float32_displacement_with_units,Fail dEQP-GLES3.functional.shaders.texture_functions.textureprojgradoffset.sampler3d_float_vertex,Fail dEQP-GLES3.functional.texture.specification.texstorage3d.size.3d_2x2x2_2_levels,Fail @@ -73,8 +63,6 @@ KHR-GLES3.copy_tex_image_conversions.required.texture2d_texture2d,Fail KHR-GLES3.copy_tex_image_conversions.required.texture3d_cubemap_posx,Fail KHR-GLES3.copy_tex_image_conversions.required.texture3d_texture2d,Fail -KHR-GLES3.packed_depth_stencil.blit.depth32f_stencil8,Fail - # "Non-integer comparison: 1, 0, 18, 1e-05: 0.142857 == 0: not equal. # Copy stage: Gradient comparison failed during ReadPixels for input = [GL_RG, GL_FLOAT] output = [GL_RED, GL_FLOAT]" KHR-GLES3.packed_pixels.pbo_rectangle.rg32f,Fail diff --git a/src/freedreno/ci/freedreno-a618-fails.txt b/src/freedreno/ci/freedreno-a618-fails.txt index a9b04fd890c..ae0518ecb2f 100644 --- a/src/freedreno/ci/freedreno-a618-fails.txt +++ b/src/freedreno/ci/freedreno-a618-fails.txt @@ -46,8 +46,6 @@ glx@glx-swap-pixmap-bad,Fail # "../src/freedreno/ir3/ir3_shader.h:968:ir3_link_add: Assertion `i < ARRAY_SIZE(l->var)' failed." shaders@glsl-max-varyings >max_varying_components,Crash -spec@arb_depth_buffer_float@fbo-clear-formats stencil,Fail -spec@arb_depth_buffer_float@fbo-clear-formats stencil@GL_DEPTH32F_STENCIL8,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT32F,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT32F NPOT,Fail diff --git a/src/freedreno/ci/freedreno-a630-fails.txt b/src/freedreno/ci/freedreno-a630-fails.txt index 4d408bc895d..88e83605448 100644 --- a/src/freedreno/ci/freedreno-a630-fails.txt +++ b/src/freedreno/ci/freedreno-a630-fails.txt @@ -53,8 +53,6 @@ glx@glx-swap-pixmap-bad,Fail # "../src/freedreno/ir3/ir3_shader.h:968:ir3_link_add: Assertion `i < ARRAY_SIZE(l->var)' failed." shaders@glsl-max-varyings >max_varying_components,Crash -spec@arb_depth_buffer_float@fbo-clear-formats stencil,Fail -spec@arb_depth_buffer_float@fbo-clear-formats stencil@GL_DEPTH32F_STENCIL8,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT32F,Fail spec@arb_depth_buffer_float@fbo-generatemipmap-formats@GL_DEPTH_COMPONENT32F NPOT,Fail diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.c b/src/gallium/drivers/freedreno/freedreno_blitter.c index f19736a3ab7..6119babecda 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.c +++ b/src/gallium/drivers/freedreno/freedreno_blitter.c @@ -104,6 +104,8 @@ fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond) assert_dt util_blitter_save_fragment_sampler_views( ctx->blitter, ctx->tex[PIPE_SHADER_FRAGMENT].num_textures, ctx->tex[PIPE_SHADER_FRAGMENT].textures); + util_blitter_save_fragment_constant_buffer_slot(ctx->blitter, + ctx->constbuf[PIPE_SHADER_FRAGMENT].cb); if (!render_cond) util_blitter_save_render_condition(ctx->blitter, ctx->cond_query, ctx->cond_cond, ctx->cond_mode); @@ -117,22 +119,20 @@ fd_blitter_pipe_end(struct fd_context *ctx) assert_dt { } -bool -fd_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info) +static void +fd_blitter_prep(struct fd_context *ctx, const struct pipe_blit_info *info) + assert_dt { - struct pipe_context *pctx = &ctx->base; struct pipe_resource *dst = info->dst.resource; struct pipe_resource *src = info->src.resource; struct pipe_context *pipe = &ctx->base; - struct pipe_surface *dst_view, dst_templ; - struct pipe_sampler_view src_templ, *src_view; /* If the blit is updating the whole contents of the resource, * invalidate it so we don't trigger any unnecessary tile loads in the 3D * path. */ if (util_blit_covers_whole_resource(info)) - pctx->invalidate_resource(pctx, info->dst.resource); + pipe->invalidate_resource(pipe, info->dst.resource); /* The blit format may not match the resource format in this path, so * we need to validate that we can use the src/dst resource with the @@ -153,6 +153,18 @@ fd_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info) DBG_BLIT(info, NULL); fd_blitter_pipe_begin(ctx, info->render_condition_enable); +} + +bool +fd_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info) +{ + struct pipe_resource *dst = info->dst.resource; + struct pipe_resource *src = info->src.resource; + struct pipe_context *pipe = &ctx->base; + struct pipe_surface *dst_view, dst_templ; + struct pipe_sampler_view src_templ, *src_view; + + fd_blitter_prep(ctx, info); /* Initialize the surface. */ default_dst_texture(&dst_templ, dst, info->dst.level, info->dst.box.z); @@ -311,6 +323,34 @@ fd_blitter_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *p fd_blitter_pipe_end(ctx); } +static void +fd_blit_stencil_fallback(struct fd_context *ctx, const struct pipe_blit_info *info) + assert_dt +{ + struct pipe_context *pctx = &ctx->base; + struct pipe_surface *dst_view, dst_templ; + + util_blitter_default_dst_texture(&dst_templ, info->dst.resource, + info->dst.level, info->dst.box.z); + + dst_view = pctx->create_surface(pctx, info->dst.resource, &dst_templ); + + fd_blitter_prep(ctx, info); + + util_blitter_clear_depth_stencil(ctx->blitter, dst_view, PIPE_CLEAR_STENCIL, + 0, 0, info->dst.box.x, info->dst.box.y, + info->dst.box.width, info->dst.box.height); + + fd_blitter_prep(ctx, info); + + util_blitter_stencil_fallback( + ctx->blitter, info->dst.resource, info->dst.level, &info->dst.box, + info->src.resource, info->src.level, &info->src.box, + info->scissor_enable ? &info->scissor : NULL); + + pipe_surface_release(pctx, &dst_view); +} + /** * Optimal hardware path for blitting pixels. * Scaling, format conversion, up- and downsampling (resolve) are allowed. @@ -328,8 +368,10 @@ fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info) return true; if (info.mask & PIPE_MASK_S) { - DBG("cannot blit stencil, skipping"); + fd_blit_stencil_fallback(ctx, &info); info.mask &= ~PIPE_MASK_S; + if (!info.mask) + return true; } if (!util_blitter_is_blit_supported(ctx->blitter, &info)) {