[Mesa-dev] [PATCH 2/2] gallium/u_blitter: enable MSAA when blitting to MSAA surfaces
Brian Paul
brianp at vmware.com
Wed Dec 13 20:06:04 UTC 2017
I'm actually going to drop these patches for now. It seems that
implicitly enabling MSAA when the sample mask != ~0 is expected behavior
with D3D and some (most?) hardware, including our virtual GPU (I'm
fixing a bug there).
-Brian
On 12/13/2017 12:35 PM, Marek Olšák wrote:
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
>
> Marek
>
> On Mon, Dec 11, 2017 at 9:09 PM, Brian Paul <brianp at vmware.com> wrote:
>> If we're doing a Z -> Z MSAA blit (for example) we need to enable
>> msaa rasterization when drawing the quads so that we can properly
>> write the per-sample values.
>>
>> This fixes a number of Piglit ext_framebuffer_multisample blit tests
>> such as ext_framebuffer_multisample/no-color 2 depth combined with
>> the VMware driver.
>>
>> v2: This depends on the previous patch to save/set/restore the
>> min_samples state.
>> ---
>> src/gallium/auxiliary/util/u_blitter.c | 54 +++++++++++++++++++++-------------
>> 1 file changed, 33 insertions(+), 21 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
>> index 371daf1..acb9fcf 100644
>> --- a/src/gallium/auxiliary/util/u_blitter.c
>> +++ b/src/gallium/auxiliary/util/u_blitter.c
>> @@ -123,7 +123,8 @@ struct blitter_context_priv
>> void *sampler_state_rect_linear;
>>
>> /* Rasterizer state. */
>> - void *rs_state, *rs_state_scissor, *rs_discard_state;
>> + void *rs_state[2][2]; /**< [scissor][msaa] */
>> + void *rs_discard_state;
>>
>> /* Destination surface dimensions. */
>> unsigned dst_width;
>> @@ -275,13 +276,19 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
>> rs_state.bottom_edge_rule = 1;
>> rs_state.flatshade = 1;
>> rs_state.depth_clip = 1;
>> - ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
>>
>> - rs_state.scissor = 1;
>> - ctx->rs_state_scissor = pipe->create_rasterizer_state(pipe, &rs_state);
>> + unsigned scissor, msaa;
>> + for (scissor = 0; scissor < 2; scissor++) {
>> + for (msaa = 0; msaa < 2; msaa++) {
>> + rs_state.scissor = scissor;
>> + rs_state.multisample = msaa;
>> + ctx->rs_state[scissor][msaa] =
>> + pipe->create_rasterizer_state(pipe, &rs_state);
>> + }
>> + }
>>
>> if (ctx->has_stream_out) {
>> - rs_state.scissor = 0;
>> + rs_state.scissor = rs_state.multisample = 0;
>> rs_state.rasterizer_discard = 1;
>> ctx->rs_discard_state = pipe->create_rasterizer_state(pipe, &rs_state);
>> }
>> @@ -454,8 +461,13 @@ void util_blitter_destroy(struct blitter_context *blitter)
>> pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil);
>> pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_write_stencil);
>>
>> - pipe->delete_rasterizer_state(pipe, ctx->rs_state);
>> - pipe->delete_rasterizer_state(pipe, ctx->rs_state_scissor);
>> + unsigned scissor, msaa;
>> + for (scissor = 0; scissor < 2; scissor++) {
>> + for (msaa = 0; msaa < 2; msaa++) {
>> + pipe->delete_rasterizer_state(pipe, ctx->rs_state[scissor][msaa]);
>> + }
>> + }
>> +
>> if (ctx->rs_discard_state)
>> pipe->delete_rasterizer_state(pipe, ctx->rs_discard_state);
>> if (ctx->vs)
>> @@ -1222,12 +1234,12 @@ void util_blitter_cache_all_shaders(struct blitter_context *blitter)
>> }
>>
>> static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
>> - bool scissor)
>> + bool scissor, bool msaa)
>> {
>> struct pipe_context *pipe = ctx->base.pipe;
>>
>> - pipe->bind_rasterizer_state(pipe, scissor ? ctx->rs_state_scissor
>> - : ctx->rs_state);
>> + pipe->bind_rasterizer_state(pipe, ctx->rs_state[scissor][msaa]);
>> +
>> if (ctx->has_geometry_shader)
>> pipe->bind_gs_state(pipe, NULL);
>> if (ctx->has_tessellation) {
>> @@ -1401,7 +1413,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
>> if (num_layers > 1 && ctx->has_layered) {
>> blitter_get_vs_func get_vs = get_vs_layered;
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs,
>> 0, 0, width, height,
>> (float) depth, num_layers, type, &attrib);
>> @@ -1413,7 +1425,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
>> else
>> get_vs = get_vs_passthrough_pos;
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs,
>> 0, 0, width, height,
>> (float) depth, 1, type, &attrib);
>> @@ -1966,7 +1978,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
>> pipe->set_scissor_states(pipe, 0, 1, scissor);
>> }
>>
>> - blitter_set_common_draw_rect_state(ctx, scissor != NULL);
>> + blitter_set_common_draw_rect_state(ctx, scissor != NULL, dst_samples > 1);
>>
>> do_blits(ctx, dst, dstbox, src, src_width0, src_height0,
>> srcbox, blit_depth || blit_stencil, use_txf);
>> @@ -2072,7 +2084,7 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
>> pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
>> 0, 1, &sampler_state);
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>>
>> for (src_level = base_level; src_level < last_level; src_level++) {
>> struct pipe_box dstbox = {0}, srcbox = {0};
>> @@ -2164,12 +2176,12 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
>>
>> num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1;
>> if (num_layers > 1 && ctx->has_layered) {
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_layered,
>> dstx, dsty, dstx+width, dsty+height, 0,
>> num_layers, UTIL_BLITTER_ATTRIB_COLOR, &attrib);
>> } else {
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state,
>> get_vs_passthrough_pos_generic,
>> dstx, dsty, dstx+width, dsty+height, 0,
>> @@ -2243,12 +2255,12 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
>>
>> num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1;
>> if (num_layers > 1 && ctx->has_layered) {
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_layered,
>> dstx, dsty, dstx+width, dsty+height, depth,
>> num_layers, UTIL_BLITTER_ATTRIB_NONE, NULL);
>> } else {
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter->draw_rectangle(blitter, ctx->velem_state,
>> get_vs_passthrough_pos,
>> dstx, dsty, dstx+width, dsty+height, depth, 1,
>> @@ -2308,7 +2320,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
>> pipe->set_framebuffer_state(pipe, &fb_state);
>> pipe->set_sample_mask(pipe, sample_mask);
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
>> 0, 0, zsurf->width, zsurf->height, depth,
>> @@ -2508,7 +2520,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
>> fb_state.zsbuf = NULL;
>> pipe->set_framebuffer_state(pipe, &fb_state);
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter_set_dst_dimensions(ctx, src->width0, src->height0);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
>> 0, 0, src->width0, src->height0,
>> @@ -2558,7 +2570,7 @@ void util_blitter_custom_color(struct blitter_context *blitter,
>> pipe->set_framebuffer_state(pipe, &fb_state);
>> pipe->set_sample_mask(pipe, ~0);
>>
>> - blitter_set_common_draw_rect_state(ctx, false);
>> + blitter_set_common_draw_rect_state(ctx, false, false);
>> blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
>> blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
>> 0, 0, dstsurf->width, dstsurf->height,
>> --
>> 1.9.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=snyd-__-374Ylq_3lTXfigrADFm_lI2gYEqzNnaKOp4&s=RF8qyjCltu0LbAmHlicTM6DgAAiS5FBvGub8ZlnKeBM&e=
More information about the mesa-dev
mailing list