From 4c72bb4a960e7362e7cf4cd6e3159af85c967614 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 24 Mar 2020 16:18:46 +1000 Subject: [PATCH] llvmpipe: handle multisample render target clears Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_surface.c | 92 ++++++++++++++--------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index e8e06821149..cfeb1da67f1 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -238,43 +238,6 @@ llvmpipe_surface_destroy(struct pipe_context *pipe, } -static void -llvmpipe_clear_render_target(struct pipe_context *pipe, - struct pipe_surface *dst, - const union pipe_color_union *color, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - bool render_condition_enabled) -{ - struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); - - if (render_condition_enabled && !llvmpipe_check_render_cond(llvmpipe)) - return; - - util_clear_render_target(pipe, dst, color, - dstx, dsty, width, height); -} - - -static void -llvmpipe_clear_depth_stencil(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned clear_flags, - double depth, - unsigned stencil, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - bool render_condition_enabled) -{ - struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); - - if (render_condition_enabled && !llvmpipe_check_render_cond(llvmpipe)) - return; - - util_clear_depth_stencil(pipe, dst, clear_flags, - depth, stencil, - dstx, dsty, width, height); -} static void llvmpipe_get_sample_position(struct pipe_context *pipe, @@ -333,6 +296,32 @@ lp_clear_color_texture_msaa(struct pipe_context *pipe, pipe->transfer_unmap(pipe, dst_trans); } +static void +llvmpipe_clear_render_target(struct pipe_context *pipe, + struct pipe_surface *dst, + const union pipe_color_union *color, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, + bool render_condition_enabled) +{ + struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + + if (render_condition_enabled && !llvmpipe_check_render_cond(llvmpipe)) + return; + + if (dst->texture->nr_samples > 1) { + struct pipe_box box; + u_box_2d(dstx, dsty, width, height, &box); + for (unsigned s = 0; s < util_res_sample_count(dst->texture); s++) { + lp_clear_color_texture_msaa(pipe, dst->texture, dst->format, + color, s, &box); + } + } else + util_clear_render_target(pipe, dst, color, + dstx, dsty, width, height); +} + + static void lp_clear_depth_stencil_texture_msaa(struct pipe_context *pipe, struct pipe_resource *texture, @@ -369,6 +358,35 @@ lp_clear_depth_stencil_texture_msaa(struct pipe_context *pipe, pipe->transfer_unmap(pipe, dst_trans); } +static void +llvmpipe_clear_depth_stencil(struct pipe_context *pipe, + struct pipe_surface *dst, + unsigned clear_flags, + double depth, + unsigned stencil, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, + bool render_condition_enabled) +{ + struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + + if (render_condition_enabled && !llvmpipe_check_render_cond(llvmpipe)) + return; + + if (dst->texture->nr_samples > 1) { + uint64_t zstencil = util_pack64_z_stencil(dst->format, depth, stencil); + struct pipe_box box; + u_box_2d(dstx, dsty, width, height, &box); + for (unsigned s = 0; s < util_res_sample_count(dst->texture); s++) + lp_clear_depth_stencil_texture_msaa(pipe, dst->texture, + dst->format, clear_flags, + zstencil, s, &box); + } else + util_clear_depth_stencil(pipe, dst, clear_flags, + depth, stencil, + dstx, dsty, width, height); +} + static void llvmpipe_clear_texture(struct pipe_context *pipe, struct pipe_resource *tex, -- 2.30.2