[Mesa-dev] multisample clears
Roland Scheidegger
sroland at vmware.com
Mon Mar 4 03:22:09 PST 2013
Am 04.03.2013 04:54, schrieb Dave Airlie:
> I've been playing with softpipe msaa on and off, but I hit a problem
> with the clears and am just wondering if the state tracker should be
> doing something like this.
>
> Or maybe only if any bound buffer has nr_samples > 1, or fallback to
> the non-quad draw method.
>
> I can't see how else the driver could distinguish a multisample clear.
>
> The other problem I have and not figuring out is if rendering to a
> buffer with multisample off, then turning it on is meant to be
> meaningful, if you have to clear
> the buffer in between, then with this fixed it should be cool.
>
> Dave.
>
> From e1ee59d87ba42d8a58be640ee1fd2b952414f45e Mon Sep 17 00:00:00 2001
> From: Dave Airlie <airlied at redhat.com>
> Date: Mon, 4 Mar 2013 13:39:17 +1000
> Subject: [PATCH] st/mesa: enable multisample in clear quad code
>
> Not sure if this is correct at all
> ---
> src/mesa/state_tracker/st_cb_clear.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_clear.c
> b/src/mesa/state_tracker/st_cb_clear.c
> index 4aa0bc1..649d7bd 100644
> --- a/src/mesa/state_tracker/st_cb_clear.c
> +++ b/src/mesa/state_tracker/st_cb_clear.c
> @@ -282,7 +282,14 @@ clear_with_quad(struct gl_context *ctx,
> cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw);
> cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
> cso_set_sample_mask(st->cso_context, ~0);
> - cso_set_rasterizer(st->cso_context, &st->clear.raster);
> +
> + {
> + struct pipe_rasterizer_state rs = st->clear.raster;
> +
> + if (st->ctx->Multisample.Enabled)
> + rs.multisample = 1;
> + cso_set_rasterizer(st->cso_context, &rs);
> + }
>
> /* viewport state: viewport matching window dims */
> {
>
Hmm I don't think this should be necessary (but it should be ok), since
it is perfectly legal to do non-multisampled rendering into a
multisampled buffer. The semantics of this are somewhat loose (you are
for instance allowed to perform depth test against a "centermost" sample
or do the test depth against individual samples, but in any case
rasterization will only have produced one depth value, and that depth
value is written to all samples if the depth test passes (but don't ask
me when the depth test is considered "passed" when you test against each
sample but still only can write the same value for all samples, I guess
it's easier to simply pick one sample)). Likewise all color samples are
set to the same value.
So as far as I can tell a clear should work with the same result,
regardless if you have multisampling enabled or not.
So yes it is indeed somewhat meaningful to render to a multisampled
buffer with multisampling off and on (though I'm quite sure some hw and
drivers don't quite support it correctly, it is probably not something
apps would do).
Roland
More information about the mesa-dev
mailing list