aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2016-03-24 08:30:09 -0600
committerBrian Paul <[email protected]>2016-03-24 08:36:43 -0600
commitf96309753b7f5f4ea5e1942778087b3ace8eda9b (patch)
tree468944dfe7dac7c04c956660c941bea2f2be26c3 /src/mesa/main
parent0bea0e7141a7698118bfd465fdb4adf8e0b21bc8 (diff)
mesa: replace gl_context->Multisample._Enabled with _mesa_is_multisample_enabled.
This removes any dependency on driver validation of the number of framebuffer samples. Signed-off-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Tested-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/framebuffer.c19
-rw-r--r--src/mesa/main/framebuffer.h3
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/state.c17
4 files changed, 22 insertions, 18 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index d18166d528e..f69dc6cb3e6 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -983,3 +983,22 @@ _mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb)
return (fb->_NumColorDrawBuffers >= 1 &&
fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
}
+
+static inline GLuint
+_mesa_geometric_nonvalidated_samples(const struct gl_framebuffer *buffer)
+{
+ return buffer->_HasAttachments ?
+ buffer->Visual.samples :
+ buffer->DefaultGeometry.NumSamples;
+}
+
+bool _mesa_is_multisample_enabled(const struct gl_context *ctx)
+{
+ /* The sample count may not be validated by the driver, but when it is set,
+ * we know that is in a valid range and no driver should ever validate a
+ * multisampled framebuffer to non-multisampled and vice-versa.
+ */
+ return ctx->Multisample.Enabled &&
+ ctx->DrawBuffer &&
+ _mesa_geometric_nonvalidated_samples(ctx->DrawBuffer) > 1;
+}
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index fa434d447ae..384f7498776 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -146,4 +146,7 @@ _mesa_is_front_buffer_reading(const struct gl_framebuffer *fb);
extern bool
_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb);
+extern bool
+_mesa_is_multisample_enabled(const struct gl_context *ctx);
+
#endif /* FRAMEBUFFER_H */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5d8bfe4bb09..399f4508415 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -667,7 +667,6 @@ struct gl_list_attrib
struct gl_multisample_attrib
{
GLboolean Enabled;
- GLboolean _Enabled; /**< true if Enabled and multisample buffer */
GLboolean SampleAlphaToCoverage;
GLboolean SampleAlphaToOne;
GLboolean SampleCoverage;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 57f13411fdf..917ae4da023 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -344,20 +344,6 @@ update_frontbit(struct gl_context *ctx)
/**
- * Update derived multisample state.
- */
-static void
-update_multisample(struct gl_context *ctx)
-{
- ctx->Multisample._Enabled = GL_FALSE;
- if (ctx->Multisample.Enabled &&
- ctx->DrawBuffer &&
- _mesa_geometric_samples(ctx->DrawBuffer) > 0)
- ctx->Multisample._Enabled = GL_TRUE;
-}
-
-
-/**
* Update the ctx->VertexProgram._TwoSideEnabled flag.
*/
static void
@@ -450,9 +436,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (new_state & _NEW_PIXEL)
_mesa_update_pixel( ctx, new_state );
- if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS))
- update_multisample( ctx );
-
/* ctx->_NeedEyeCoords is now up to date.
*
* If the truth value of this variable has changed, update for the