Mesa (master): mesa/st: Set _NumSamples in update_framebuffer_state()
Dave Airlie
airlied at kemper.freedesktop.org
Thu Apr 7 02:05:34 UTC 2016
Module: Mesa
Branch: master
Commit: b512b5fd3664781d1f9ada1c784353b85bbe0e5b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b512b5fd3664781d1f9ada1c784353b85bbe0e5b
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date: Wed Feb 17 10:27:41 2016 +1100
mesa/st: Set _NumSamples in update_framebuffer_state()
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.
V.3:
Move comment to right place after loop was rewritten.
V.4: [airlied]
remove unneeded variable, and assert, and unneeded pipe assignment
Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/state_tracker/st_atom_framebuffer.c | 46 ++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index ae883a2..5c23735 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -64,6 +64,41 @@ 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_screen *screen = st->pipe->screen;
+ int quantized_samples = 0;
+ unsigned msaa_mode;
+
+ if (!num_samples)
+ return 0;
+
+ /* 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 */
+
+ /**
+ * Check if the MSAA mode that is higher than the requested
+ * num_samples is supported, and if so returning it.
+ */
+ 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.
+ */
+ if (screen->is_format_supported(screen, PIPE_FORMAT_NONE,
+ PIPE_TEXTURE_2D, msaa_mode,
+ PIPE_BIND_RENDER_TARGET))
+ quantized_samples = msaa_mode;
+ }
+ return quantized_samples;
+}
/**
* Update framebuffer state (color, depth, stencil, etc. buffers)
@@ -82,6 +117,17 @@ update_framebuffer_state( struct st_context *st )
framebuffer->width = UINT_MAX;
framebuffer->height = UINT_MAX;
+ /**
+ * Quantize the derived default number of samples:
+ *
+ * A query to the driver of supported MSAA values the
+ * hardware supports is done as to legalize the number
+ * of application requested samples, NumSamples.
+ * See commit eb9cf3c for more information.
+ */
+ fb->DefaultGeometry._NumSamples =
+ framebuffer_quantize_num_samples(st, fb->DefaultGeometry.NumSamples);
+
/*printf("------ fb size %d x %d\n", fb->Width, fb->Height);*/
/* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state
More information about the mesa-commit
mailing list