[Mesa-dev] [PATCH 17/31] mesa: don't flag _NEW_MULTISAMPLE for st/mesa
Marek Olšák
maraeo at gmail.com
Mon Jun 12 16:55:42 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
There are several new driver flags here so that it maps nicely to gallium.
---
src/mesa/main/enable.c | 37 ++++++++++++++++++++++++++++++-------
src/mesa/main/mtypes.h | 12 ++++++++++++
src/mesa/main/multisample.c | 10 +++++++---
src/mesa/state_tracker/st_context.c | 36 +++++++++++++++++++-----------------
4 files changed, 68 insertions(+), 27 deletions(-)
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 66160a4..401ef62 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -232,21 +232,32 @@ enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
/**
* Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
* whether the API supports it (GLES doesn't).
*/
void
_mesa_set_multisample(struct gl_context *ctx, GLboolean state)
{
if (ctx->Multisample.Enabled == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+
+ /* GL compatibility needs Multisample.Enable to determine program state
+ * constants.
+ */
+ if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES ||
+ !ctx->DriverFlags.NewMultisampleEnable) {
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ } else {
+ FLUSH_VERTICES(ctx, 0);
+ }
+
+ ctx->NewDriverState |= ctx->DriverFlags.NewMultisampleEnable;
ctx->Multisample.Enabled = state;
if (ctx->Driver.Enable) {
ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state);
}
}
/**
* Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
* check for whether the API supports it (GLES doesn't).
@@ -801,54 +812,64 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
/* GL_ARB_multisample */
case GL_MULTISAMPLE_ARB:
if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
goto invalid_enum_error;
_mesa_set_multisample(ctx, state);
return;
case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
if (ctx->Multisample.SampleAlphaToCoverage == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
ctx->Multisample.SampleAlphaToCoverage = state;
break;
case GL_SAMPLE_ALPHA_TO_ONE_ARB:
if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
goto invalid_enum_error;
if (ctx->Multisample.SampleAlphaToOne == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
ctx->Multisample.SampleAlphaToOne = state;
break;
case GL_SAMPLE_COVERAGE_ARB:
if (ctx->Multisample.SampleCoverage == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
ctx->Multisample.SampleCoverage = state;
break;
case GL_SAMPLE_COVERAGE_INVERT_ARB:
if (!_mesa_is_desktop_gl(ctx))
goto invalid_enum_error;
if (ctx->Multisample.SampleCoverageInvert == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
ctx->Multisample.SampleCoverageInvert = state;
break;
/* GL_ARB_sample_shading */
case GL_SAMPLE_SHADING:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_enum_error;
CHECK_EXTENSION(ARB_sample_shading, cap);
if (ctx->Multisample.SampleShading == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleShading ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleShading;
ctx->Multisample.SampleShading = state;
break;
/* GL_IBM_rasterpos_clip */
case GL_RASTER_POSITION_UNCLIPPED_IBM:
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
if (ctx->Transform.RasterPositionUnclipped == state)
return;
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
@@ -1029,21 +1050,23 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
}
break;
/* ARB_texture_multisample */
case GL_SAMPLE_MASK:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
goto invalid_enum_error;
CHECK_EXTENSION(ARB_texture_multisample, cap);
if (ctx->Multisample.SampleMask == state)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+ _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
ctx->Multisample.SampleMask = state;
break;
case GL_BLEND_ADVANCED_COHERENT_KHR:
CHECK_EXTENSION(KHR_blend_equation_advanced_coherent, cap);
if (ctx->Color.BlendCoherent == state)
return;
FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR);
ctx->NewDriverState |= ctx->DriverFlags.NewBlend;
ctx->Color.BlendCoherent = state;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 17b5543..6fdd0fd 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4414,20 +4414,32 @@ struct gl_driver_flags
/** gl_context::Color::Color/Index */
uint64_t NewColorMask;
/** gl_context::Depth */
uint64_t NewDepth;
/** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
uint64_t NewLogicOp;
+ /** gl_context::Multisample::Enabled */
+ uint64_t NewMultisampleEnable;
+
+ /** gl_context::Multisample::SampleAlphaTo* */
+ uint64_t NewSampleAlphaToXEnable;
+
+ /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
+ uint64_t NewSampleMask;
+
+ /** gl_context::Multisample::(Min)SampleShading */
+ uint64_t NewSampleShading;
+
/** gl_context::Stencil */
uint64_t NewStencil;
};
struct gl_uniform_buffer_binding
{
struct gl_buffer_object *BufferObject;
/** Start of uniform block data in the buffer */
GLintptr Offset;
/** Size of data allowed to be referenced from the buffer (in bytes) */
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index 0778613..38d91f7 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -40,21 +40,22 @@ void GLAPIENTRY
_mesa_SampleCoverage(GLclampf value, GLboolean invert)
{
GET_CURRENT_CONTEXT(ctx);
value = CLAMP(value, 0.0f, 1.0f);
if (ctx->Multisample.SampleCoverageInvert == invert &&
ctx->Multisample.SampleCoverageValue == value)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
ctx->Multisample.SampleCoverageValue = value;
ctx->Multisample.SampleCoverageInvert = invert;
}
/**
* Initialize the context's multisample state.
* \param ctx the GL context.
*/
void
@@ -115,21 +116,22 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask)
}
if (index != 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)");
return;
}
if (ctx->Multisample.SampleMaskValue == mask)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
ctx->Multisample.SampleMaskValue = mask;
}
/**
* Called via glMinSampleShadingARB
*/
void GLAPIENTRY
_mesa_MinSampleShading(GLclampf value)
{
GET_CURRENT_CONTEXT(ctx);
@@ -138,21 +140,23 @@ _mesa_MinSampleShading(GLclampf value)
!_mesa_has_OES_sample_shading(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glMinSampleShading");
return;
}
value = CLAMP(value, 0.0f, 1.0f);
if (ctx->Multisample.MinSampleShadingValue == value)
return;
- FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ FLUSH_VERTICES(ctx,
+ ctx->DriverFlags.NewSampleShading ? 0 : _NEW_MULTISAMPLE);
+ ctx->NewDriverState |= ctx->DriverFlags.NewSampleShading;
ctx->Multisample.MinSampleShadingValue = value;
}
/**
* Helper for checking a requested sample count against the limit
* for a particular (target, internalFormat) pair. The limit imposed,
* and the error generated, both depend on which extensions are supported.
*
* Returns a GL error enum, or GL_NO_ERROR if the requested sample count is
* acceptable.
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 6dc3f35..bb06853 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -206,37 +206,26 @@ st_invalidate_state(struct gl_context * ctx)
st->dirty |= ST_NEW_VIEWPORT;
if (new_state & _NEW_FRAG_CLAMP) {
if (st->clamp_frag_color_in_shader)
st->dirty |= ST_NEW_FS_STATE;
else
st->dirty |= ST_NEW_RASTERIZER;
}
}
- if (new_state & _NEW_MULTISAMPLE) {
- st->dirty |= ST_NEW_BLEND |
- ST_NEW_SAMPLE_MASK |
- ST_NEW_SAMPLE_SHADING |
- ST_NEW_RASTERIZER |
- ST_NEW_FS_STATE;
- } else {
- /* These set a subset of flags set by _NEW_MULTISAMPLE, so we only
- * have to check them when _NEW_MULTISAMPLE isn't set.
- */
- if (new_state & (_NEW_LIGHT |
- _NEW_LINE |
- _NEW_POINT |
- _NEW_POLYGON |
- _NEW_TRANSFORM))
- st->dirty |= ST_NEW_RASTERIZER;
- }
+ if (new_state & (_NEW_LIGHT |
+ _NEW_LINE |
+ _NEW_POINT |
+ _NEW_POLYGON |
+ _NEW_TRANSFORM))
+ st->dirty |= ST_NEW_RASTERIZER;
if (new_state & (_NEW_PROJECTION |
_NEW_TRANSFORM) &&
st_user_clip_planes_enabled(ctx))
st->dirty |= ST_NEW_CLIP_STATE;
if (new_state & _NEW_PIXEL)
st->dirty |= ST_NEW_PIXEL_TRANSFER;
if (new_state & _NEW_CURRENT_ATTRIB)
@@ -513,20 +502,33 @@ static void st_init_driver_flags(struct st_context *st)
f->NewFramebufferSRGB = ST_NEW_FRAMEBUFFER;
f->NewScissorRect = ST_NEW_SCISSOR;
f->NewScissorTest = ST_NEW_SCISSOR | ST_NEW_RASTERIZER;
f->NewAlphaTest = ST_NEW_DSA;
f->NewBlend = ST_NEW_BLEND;
f->NewBlendColor = ST_NEW_BLEND; /* TODO: add an atom for blend color */
f->NewColorMask = ST_NEW_BLEND;
f->NewDepth = ST_NEW_DSA;
f->NewLogicOp = ST_NEW_BLEND;
f->NewStencil = ST_NEW_DSA;
+ f->NewMultisampleEnable = ST_NEW_BLEND | ST_NEW_RASTERIZER |
+ ST_NEW_SAMPLE_MASK | ST_NEW_SAMPLE_SHADING;
+ f->NewSampleAlphaToXEnable = ST_NEW_BLEND;
+ f->NewSampleMask = ST_NEW_SAMPLE_MASK;
+ f->NewSampleShading = ST_NEW_SAMPLE_SHADING;
+
+ /* This depends on what the gallium driver wants. */
+ if (st->force_persample_in_shader) {
+ f->NewMultisampleEnable |= ST_NEW_FS_STATE;
+ f->NewSampleShading |= ST_NEW_FS_STATE;
+ } else {
+ f->NewSampleShading |= ST_NEW_RASTERIZER;
+ }
}
struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
const struct gl_config *visual,
struct st_context *share,
const struct st_config_options *options)
{
struct gl_context *ctx;
struct gl_context *shareCtx = share ? share->ctx : NULL;
struct dd_function_table funcs;
--
2.7.4
More information about the mesa-dev
mailing list