[Mesa-dev] [PATCH] i965: Let driconf clamp_max_samples affect context version
Chad Versace
chad.versace at linux.intel.com
Mon Nov 4 17:06:14 PST 2013
Commit 2f89662 added the driconf option 'clamp_max_samples'. In that
commit, the option did not alter the context version.
Specifically, Mesa constructed a GL 3.0 context for Baytrail even if
clamp_max_samples=0, which clamps GL_MAX_SAMPLES to 0. This violates the
GL 3.0 spec, which requires GL_MAX_SAMPLES >= 4.
The spec violation causes WebGL fail on Chromium because it correctly
assumes that a GL 3.0 context supports at least 4 samples.
This patch fixes calculation of the context version to respect the
post-clamped value of GL_MAX_SAMPLES. This in turn fixes WebGL on
Chromium when clamp_max_samples=0.
CC: Eric Anholt <eric at anholt.org>
CC: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
src/mesa/drivers/dri/i965/brw_context.c | 66 ++++++++++++---------------------
1 file changed, 24 insertions(+), 42 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 95b602f..66ce93e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -287,37 +287,6 @@ brw_supported_msaa_modes(const struct brw_context *brw)
}
}
-/**
- * Override GL_MAX_SAMPLES and related constants according to value of driconf
- * option 'clamp_max_samples'.
- */
-static void
-brw_override_max_samples(struct brw_context *brw)
-{
- const int clamp_max_samples = driQueryOptioni(&brw->optionCache,
- "clamp_max_samples");
- if (clamp_max_samples < 0)
- return;
-
- const int *supported_msaa_modes = brw_supported_msaa_modes(brw);
- int max_samples = 0;
-
- /* Select the largest supported MSAA mode that does not exceed
- * clamp_max_samples.
- */
- for (int i = 0; supported_msaa_modes[i] != 0; ++i) {
- if (supported_msaa_modes[i] <= clamp_max_samples) {
- max_samples = supported_msaa_modes[i];
- break;
- }
- }
-
- brw->ctx.Const.MaxSamples = max_samples;
- brw->ctx.Const.MaxColorTextureSamples = max_samples;
- brw->ctx.Const.MaxDepthTextureSamples = max_samples;
- brw->ctx.Const.MaxIntegerSamples = max_samples;
-}
-
static void
brw_initialize_context_constants(struct brw_context *brw)
{
@@ -383,11 +352,30 @@ brw_initialize_context_constants(struct brw_context *brw)
ctx->Const.AlwaysUseGetTransformFeedbackVertexCount = true;
- const int max_samples = brw_supported_msaa_modes(brw)[0];
- ctx->Const.MaxSamples = max_samples;
- ctx->Const.MaxColorTextureSamples = max_samples;
- ctx->Const.MaxDepthTextureSamples = max_samples;
- ctx->Const.MaxIntegerSamples = max_samples;
+ const int *supported_msaa_modes = brw_supported_msaa_modes(brw);
+ const int clamp_max_samples =
+ driQueryOptioni(&brw->optionCache, "clamp_max_samples");
+ int max_samples;
+
+ if (clamp_max_samples >= 0) {
+ /* Select the largest supported MSAA mode that does not exceed
+ * clamp_max_samples.
+ */
+ max_samples = 0;
+ for (int i = 0; supported_msaa_modes[i] != 0; ++i) {
+ if (supported_msaa_modes[i] <= clamp_max_samples) {
+ max_samples = supported_msaa_modes[i];
+ break;
+ }
+ }
+ } else {
+ max_samples = supported_msaa_modes[0];
+ }
+
+ brw->ctx.Const.MaxSamples = max_samples;
+ brw->ctx.Const.MaxColorTextureSamples = max_samples;
+ brw->ctx.Const.MaxDepthTextureSamples = max_samples;
+ brw->ctx.Const.MaxIntegerSamples = max_samples;
if (brw->gen >= 7)
ctx->Const.MaxProgramTextureGatherComponents = 4;
@@ -742,12 +730,6 @@ brwCreateContext(gl_api api,
_mesa_compute_version(ctx);
- /* Here we override context constants. We apply the overrides after
- * calculation of the context version because we do not want the overridden
- * constants to change the version.
- */
- brw_override_max_samples(brw);
-
_mesa_initialize_dispatch_tables(ctx);
_mesa_initialize_vbo_vtxfmt(ctx);
--
1.8.3.1
More information about the mesa-dev
mailing list