[Mesa-dev] [PATCH 03/14] mesa/st: Set _NumSamples in update_framebuffer_state()
Marek Olšák
maraeo at gmail.com
Sun Mar 27 16:54:05 UTC 2016
On Sun, Mar 27, 2016 at 4:38 AM, Edward O'Callaghan
<eocallaghan at alterapraxis.com> wrote:
> Using PIPE_FORMAT_NONE to indicate what MSAA modes are supported
> with a framebuffer using no attachment.
>
> V.2:
> Rewrite MSAA mode loop to be more general.
>
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
> ---
> src/mesa/state_tracker/st_atom_framebuffer.c | 52 ++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
> index ae883a2..14ff16d 100644
> --- a/src/mesa/state_tracker/st_atom_framebuffer.c
> +++ b/src/mesa/state_tracker/st_atom_framebuffer.c
> @@ -64,6 +64,47 @@ update_framebuffer_size(struct pipe_framebuffer_state *framebuffer,
> framebuffer->height = MIN2(framebuffer->height, surface->height);
> }
>
> +/**
> + * Round up the requested multisample count to the next supported sample size.
> + */
> +static unsigned
> +framebuffer_quantize_num_samples(struct st_context *st, unsigned num_samples)
> +{
> + struct pipe_context *pipe = st->pipe;
> + struct pipe_screen *screen = pipe->screen;
> + int quantized_samples = 0;
> + bool msaa_mode_supported;
> + unsigned msaa_mode;
> +
> + if (!num_samples)
> + return 0;
> +
> + assert(screen);
> +
> + /* Assumes the highest supported MSAA is a power of 2 */
> + msaa_mode = util_next_power_of_two(st->ctx->Const.MaxFramebufferSamples);
> + assert(!(num_samples > msaa_mode)); /* be safe from infinite loops */
> +
> + for (; msaa_mode >= num_samples; msaa_mode = msaa_mode/2) {
> + /**
> + * For ARB_framebuffer_no_attachment, A format of
> + * PIPE_FORMAT_NONE implies what number of samples is
> + * supported for a framebuffer with no attachment. Thus the
> + * drivers callback must be adjusted for this.
> + */
> + msaa_mode_supported = screen->is_format_supported(screen,
> + PIPE_FORMAT_NONE, PIPE_TEXTURE_2D,
> + msaa_mode, PIPE_BIND_RENDER_TARGET);
> + /**
> + * Check if the MSAA mode that is higher than the requested
> + * num_samples is supported, and if so returning it.
> + */
This comment doesn't make any sense with the code that follows it.
Also, you could just do:
if (!screen->is_format_supported(...))
continue;
quantized_samples = msaa_mode;
.. to make it shorter.
Marek
More information about the mesa-dev
mailing list