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 <bas@basnieuwenhuizen.nl> Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Brian Paul <brianp@vmware.com>
This commit is contained in:

committed by
Brian Paul

parent
0bea0e7141
commit
f96309753b
@@ -34,6 +34,7 @@
|
|||||||
#define BRW_UTIL_H
|
#define BRW_UTIL_H
|
||||||
|
|
||||||
#include "brw_context.h"
|
#include "brw_context.h"
|
||||||
|
#include "main/framebuffer.h"
|
||||||
|
|
||||||
extern GLuint brw_translate_blend_factor( GLenum factor );
|
extern GLuint brw_translate_blend_factor( GLenum factor );
|
||||||
extern GLuint brw_translate_blend_equation( GLenum mode );
|
extern GLuint brw_translate_blend_equation( GLenum mode );
|
||||||
@@ -49,13 +50,13 @@ brw_get_line_width(struct brw_context *brw)
|
|||||||
* implementation-dependent maximum non-antialiased line width."
|
* implementation-dependent maximum non-antialiased line width."
|
||||||
*/
|
*/
|
||||||
float line_width =
|
float line_width =
|
||||||
CLAMP(!brw->ctx.Multisample._Enabled && !brw->ctx.Line.SmoothFlag
|
CLAMP(!_mesa_is_multisample_enabled(&brw->ctx) && !brw->ctx.Line.SmoothFlag
|
||||||
? roundf(brw->ctx.Line.Width) : brw->ctx.Line.Width,
|
? roundf(brw->ctx.Line.Width) : brw->ctx.Line.Width,
|
||||||
0.0f, brw->ctx.Const.MaxLineWidth);
|
0.0f, brw->ctx.Const.MaxLineWidth);
|
||||||
uint32_t line_width_u3_7 = U_FIXED(line_width, 7);
|
uint32_t line_width_u3_7 = U_FIXED(line_width, 7);
|
||||||
|
|
||||||
/* Line width of 0 is not allowed when MSAA enabled */
|
/* Line width of 0 is not allowed when MSAA enabled */
|
||||||
if (brw->ctx.Multisample._Enabled) {
|
if (_mesa_is_multisample_enabled(&brw->ctx)) {
|
||||||
if (line_width_u3_7 == 0)
|
if (line_width_u3_7 == 0)
|
||||||
line_width_u3_7 = 1;
|
line_width_u3_7 = 1;
|
||||||
} else if (brw->ctx.Line.SmoothFlag && line_width < 1.5f) {
|
} else if (brw->ctx.Line.SmoothFlag && line_width < 1.5f) {
|
||||||
|
@@ -198,14 +198,14 @@ gen6_upload_blend_state(struct brw_context *brw)
|
|||||||
if(!is_buffer_zero_integer_format) {
|
if(!is_buffer_zero_integer_format) {
|
||||||
/* _NEW_MULTISAMPLE */
|
/* _NEW_MULTISAMPLE */
|
||||||
blend[b].blend1.alpha_to_coverage =
|
blend[b].blend1.alpha_to_coverage =
|
||||||
ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToCoverage;
|
_mesa_is_multisample_enabled(ctx) && ctx->Multisample.SampleAlphaToCoverage;
|
||||||
|
|
||||||
/* From SandyBridge PRM, volume 2 Part 1, section 8.2.3, BLEND_STATE:
|
/* From SandyBridge PRM, volume 2 Part 1, section 8.2.3, BLEND_STATE:
|
||||||
* DWord 1, Bit 30 (AlphaToOne Enable):
|
* DWord 1, Bit 30 (AlphaToOne Enable):
|
||||||
* "If Dual Source Blending is enabled, this bit must be disabled"
|
* "If Dual Source Blending is enabled, this bit must be disabled"
|
||||||
*/
|
*/
|
||||||
WARN_ONCE(ctx->Color.Blend[b]._UsesDualSrc &&
|
WARN_ONCE(ctx->Color.Blend[b]._UsesDualSrc &&
|
||||||
ctx->Multisample._Enabled &&
|
_mesa_is_multisample_enabled(ctx) &&
|
||||||
ctx->Multisample.SampleAlphaToOne,
|
ctx->Multisample.SampleAlphaToOne,
|
||||||
"HW workaround: disabling alpha to one with dual src "
|
"HW workaround: disabling alpha to one with dual src "
|
||||||
"blending\n");
|
"blending\n");
|
||||||
@@ -213,7 +213,7 @@ gen6_upload_blend_state(struct brw_context *brw)
|
|||||||
blend[b].blend1.alpha_to_one = false;
|
blend[b].blend1.alpha_to_one = false;
|
||||||
else
|
else
|
||||||
blend[b].blend1.alpha_to_one =
|
blend[b].blend1.alpha_to_one =
|
||||||
ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToOne;
|
_mesa_is_multisample_enabled(ctx) && ctx->Multisample.SampleAlphaToOne;
|
||||||
|
|
||||||
blend[b].blend1.alpha_to_coverage_dither = (brw->gen >= 7);
|
blend[b].blend1.alpha_to_coverage_dither = (brw->gen >= 7);
|
||||||
}
|
}
|
||||||
|
@@ -171,7 +171,7 @@ gen6_determine_sample_mask(struct brw_context *brw)
|
|||||||
/* BRW_NEW_NUM_SAMPLES */
|
/* BRW_NEW_NUM_SAMPLES */
|
||||||
unsigned num_samples = brw->num_samples;
|
unsigned num_samples = brw->num_samples;
|
||||||
|
|
||||||
if (ctx->Multisample._Enabled) {
|
if (_mesa_is_multisample_enabled(ctx)) {
|
||||||
if (ctx->Multisample.SampleCoverage) {
|
if (ctx->Multisample.SampleCoverage) {
|
||||||
coverage = ctx->Multisample.SampleCoverageValue;
|
coverage = ctx->Multisample.SampleCoverageValue;
|
||||||
coverage_invert = ctx->Multisample.SampleCoverageInvert;
|
coverage_invert = ctx->Multisample.SampleCoverageInvert;
|
||||||
|
@@ -65,7 +65,7 @@ gen8_upload_blend_state(struct brw_context *brw)
|
|||||||
|
|
||||||
if (rb_zero_type != GL_INT && rb_zero_type != GL_UNSIGNED_INT) {
|
if (rb_zero_type != GL_INT && rb_zero_type != GL_UNSIGNED_INT) {
|
||||||
/* _NEW_MULTISAMPLE */
|
/* _NEW_MULTISAMPLE */
|
||||||
if (ctx->Multisample._Enabled) {
|
if (_mesa_is_multisample_enabled(ctx)) {
|
||||||
if (ctx->Multisample.SampleAlphaToCoverage) {
|
if (ctx->Multisample.SampleAlphaToCoverage) {
|
||||||
blend[0] |= GEN8_BLEND_ALPHA_TO_COVERAGE_ENABLE;
|
blend[0] |= GEN8_BLEND_ALPHA_TO_COVERAGE_ENABLE;
|
||||||
blend[0] |= GEN8_BLEND_ALPHA_TO_COVERAGE_DITHER_ENABLE;
|
blend[0] |= GEN8_BLEND_ALPHA_TO_COVERAGE_DITHER_ENABLE;
|
||||||
@@ -183,7 +183,7 @@ gen8_upload_blend_state(struct brw_context *brw)
|
|||||||
* "If Dual Source Blending is enabled, this bit must be disabled."
|
* "If Dual Source Blending is enabled, this bit must be disabled."
|
||||||
*/
|
*/
|
||||||
WARN_ONCE(ctx->Color.Blend[i]._UsesDualSrc &&
|
WARN_ONCE(ctx->Color.Blend[i]._UsesDualSrc &&
|
||||||
ctx->Multisample._Enabled &&
|
_mesa_is_multisample_enabled(ctx) &&
|
||||||
ctx->Multisample.SampleAlphaToOne,
|
ctx->Multisample.SampleAlphaToOne,
|
||||||
"HW workaround: disabling alpha to one with dual src "
|
"HW workaround: disabling alpha to one with dual src "
|
||||||
"blending\n");
|
"blending\n");
|
||||||
@@ -226,7 +226,7 @@ gen8_upload_ps_blend(struct brw_context *brw)
|
|||||||
dw1 |= GEN8_PS_BLEND_ALPHA_TEST_ENABLE;
|
dw1 |= GEN8_PS_BLEND_ALPHA_TEST_ENABLE;
|
||||||
|
|
||||||
/* _NEW_MULTISAMPLE */
|
/* _NEW_MULTISAMPLE */
|
||||||
if (ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToCoverage)
|
if (_mesa_is_multisample_enabled(ctx) && ctx->Multisample.SampleAlphaToCoverage)
|
||||||
dw1 |= GEN8_PS_BLEND_ALPHA_TO_COVERAGE_ENABLE;
|
dw1 |= GEN8_PS_BLEND_ALPHA_TO_COVERAGE_ENABLE;
|
||||||
|
|
||||||
/* Used for implementing the following bit of GL_EXT_texture_integer:
|
/* Used for implementing the following bit of GL_EXT_texture_integer:
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "brw_state.h"
|
#include "brw_state.h"
|
||||||
#include "brw_defines.h"
|
#include "brw_defines.h"
|
||||||
#include "brw_wm.h"
|
#include "brw_wm.h"
|
||||||
|
#include "main/framebuffer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to emit depth related command packets.
|
* Helper function to emit depth related command packets.
|
||||||
@@ -303,7 +304,7 @@ pma_fix_enable(const struct brw_context *brw)
|
|||||||
const bool kill_pixel =
|
const bool kill_pixel =
|
||||||
brw->wm.prog_data->uses_kill ||
|
brw->wm.prog_data->uses_kill ||
|
||||||
brw->wm.prog_data->uses_omask ||
|
brw->wm.prog_data->uses_omask ||
|
||||||
(ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToCoverage) ||
|
(_mesa_is_multisample_enabled(ctx) && ctx->Multisample.SampleAlphaToCoverage) ||
|
||||||
ctx->Color.AlphaEnabled;
|
ctx->Color.AlphaEnabled;
|
||||||
|
|
||||||
/* The big formula in CACHE_MODE_1::NP PMA FIX ENABLE. */
|
/* The big formula in CACHE_MODE_1::NP PMA FIX ENABLE. */
|
||||||
|
@@ -178,7 +178,7 @@ upload_sf(struct brw_context *brw)
|
|||||||
dw3 |= GEN6_SF_USE_STATE_POINT_WIDTH;
|
dw3 |= GEN6_SF_USE_STATE_POINT_WIDTH;
|
||||||
|
|
||||||
/* _NEW_POINT | _NEW_MULTISAMPLE */
|
/* _NEW_POINT | _NEW_MULTISAMPLE */
|
||||||
if ((ctx->Point.SmoothFlag || ctx->Multisample._Enabled) &&
|
if ((ctx->Point.SmoothFlag || _mesa_is_multisample_enabled(ctx)) &&
|
||||||
!ctx->Point.PointSprite) {
|
!ctx->Point.PointSprite) {
|
||||||
dw3 |= GEN8_SF_SMOOTH_POINT_ENABLE;
|
dw3 |= GEN8_SF_SMOOTH_POINT_ENABLE;
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ upload_raster(struct brw_context *brw)
|
|||||||
if (ctx->Point.SmoothFlag)
|
if (ctx->Point.SmoothFlag)
|
||||||
dw1 |= GEN8_RASTER_SMOOTH_POINT_ENABLE;
|
dw1 |= GEN8_RASTER_SMOOTH_POINT_ENABLE;
|
||||||
|
|
||||||
if (ctx->Multisample._Enabled)
|
if (_mesa_is_multisample_enabled(ctx))
|
||||||
dw1 |= GEN8_RASTER_API_MULTISAMPLE_ENABLE;
|
dw1 |= GEN8_RASTER_API_MULTISAMPLE_ENABLE;
|
||||||
|
|
||||||
if (ctx->Polygon.OffsetFill)
|
if (ctx->Polygon.OffsetFill)
|
||||||
|
@@ -983,3 +983,22 @@ _mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb)
|
|||||||
return (fb->_NumColorDrawBuffers >= 1 &&
|
return (fb->_NumColorDrawBuffers >= 1 &&
|
||||||
fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
|
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;
|
||||||
|
}
|
||||||
|
@@ -146,4 +146,7 @@ _mesa_is_front_buffer_reading(const struct gl_framebuffer *fb);
|
|||||||
extern bool
|
extern bool
|
||||||
_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb);
|
_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb);
|
||||||
|
|
||||||
|
extern bool
|
||||||
|
_mesa_is_multisample_enabled(const struct gl_context *ctx);
|
||||||
|
|
||||||
#endif /* FRAMEBUFFER_H */
|
#endif /* FRAMEBUFFER_H */
|
||||||
|
@@ -667,7 +667,6 @@ struct gl_list_attrib
|
|||||||
struct gl_multisample_attrib
|
struct gl_multisample_attrib
|
||||||
{
|
{
|
||||||
GLboolean Enabled;
|
GLboolean Enabled;
|
||||||
GLboolean _Enabled; /**< true if Enabled and multisample buffer */
|
|
||||||
GLboolean SampleAlphaToCoverage;
|
GLboolean SampleAlphaToCoverage;
|
||||||
GLboolean SampleAlphaToOne;
|
GLboolean SampleAlphaToOne;
|
||||||
GLboolean SampleCoverage;
|
GLboolean SampleCoverage;
|
||||||
|
@@ -343,20 +343,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.
|
* Update the ctx->VertexProgram._TwoSideEnabled flag.
|
||||||
*/
|
*/
|
||||||
@@ -450,9 +436,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
|
|||||||
if (new_state & _NEW_PIXEL)
|
if (new_state & _NEW_PIXEL)
|
||||||
_mesa_update_pixel( ctx, new_state );
|
_mesa_update_pixel( ctx, new_state );
|
||||||
|
|
||||||
if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS))
|
|
||||||
update_multisample( ctx );
|
|
||||||
|
|
||||||
/* ctx->_NeedEyeCoords is now up to date.
|
/* ctx->_NeedEyeCoords is now up to date.
|
||||||
*
|
*
|
||||||
* If the truth value of this variable has changed, update for the
|
* If the truth value of this variable has changed, update for the
|
||||||
|
@@ -502,7 +502,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
|
|||||||
minImplSize = ctx->Const.MinPointSizeAA;
|
minImplSize = ctx->Const.MinPointSizeAA;
|
||||||
maxImplSize = ctx->Const.MaxPointSize;
|
maxImplSize = ctx->Const.MaxPointSize;
|
||||||
}
|
}
|
||||||
else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) {
|
else if (ctx->Point.SmoothFlag || _mesa_is_multisample_enabled(ctx)) {
|
||||||
minImplSize = ctx->Const.MinPointSizeAA;
|
minImplSize = ctx->Const.MinPointSizeAA;
|
||||||
maxImplSize = ctx->Const.MaxPointSizeAA;
|
maxImplSize = ctx->Const.MaxPointSizeAA;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/framebuffer.h"
|
||||||
#include "st_context.h"
|
#include "st_context.h"
|
||||||
#include "st_atom.h"
|
#include "st_atom.h"
|
||||||
#include "st_debug.h"
|
#include "st_debug.h"
|
||||||
@@ -235,12 +236,12 @@ static void update_raster_state( struct st_context *st )
|
|||||||
raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
|
raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
|
||||||
|
|
||||||
/* _NEW_MULTISAMPLE */
|
/* _NEW_MULTISAMPLE */
|
||||||
raster->multisample = ctx->Multisample._Enabled;
|
raster->multisample = _mesa_is_multisample_enabled(ctx);
|
||||||
|
|
||||||
/* _NEW_MULTISAMPLE | _NEW_BUFFERS */
|
/* _NEW_MULTISAMPLE | _NEW_BUFFERS */
|
||||||
raster->force_persample_interp =
|
raster->force_persample_interp =
|
||||||
!st->force_persample_in_shader &&
|
!st->force_persample_in_shader &&
|
||||||
ctx->Multisample._Enabled &&
|
_mesa_is_multisample_enabled(ctx) &&
|
||||||
ctx->Multisample.SampleShading &&
|
ctx->Multisample.SampleShading &&
|
||||||
ctx->Multisample.MinSampleShadingValue *
|
ctx->Multisample.MinSampleShadingValue *
|
||||||
ctx->DrawBuffer->Visual.samples > 1;
|
ctx->DrawBuffer->Visual.samples > 1;
|
||||||
|
@@ -74,7 +74,7 @@ update_fp( struct st_context *st )
|
|||||||
/* _NEW_MULTISAMPLE | _NEW_BUFFERS */
|
/* _NEW_MULTISAMPLE | _NEW_BUFFERS */
|
||||||
key.persample_shading =
|
key.persample_shading =
|
||||||
st->force_persample_in_shader &&
|
st->force_persample_in_shader &&
|
||||||
st->ctx->Multisample._Enabled &&
|
_mesa_is_multisample_enabled(st->ctx) &&
|
||||||
st->ctx->Multisample.SampleShading &&
|
st->ctx->Multisample.SampleShading &&
|
||||||
st->ctx->Multisample.MinSampleShadingValue *
|
st->ctx->Multisample.MinSampleShadingValue *
|
||||||
_mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
|
_mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "main/framebuffer.h"
|
||||||
#include "main/glheader.h"
|
#include "main/glheader.h"
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
#include "s_context.h"
|
#include "s_context.h"
|
||||||
@@ -257,7 +257,7 @@ smooth_point(struct gl_context *ctx, const SWvertex *vert)
|
|||||||
size = get_size(ctx, vert, GL_TRUE);
|
size = get_size(ctx, vert, GL_TRUE);
|
||||||
|
|
||||||
/* alpha attenuation / fade factor */
|
/* alpha attenuation / fade factor */
|
||||||
if (ctx->Multisample._Enabled) {
|
if (_mesa_is_multisample_enabled(ctx)) {
|
||||||
if (vert->pointSize >= ctx->Point.Threshold) {
|
if (vert->pointSize >= ctx->Point.Threshold) {
|
||||||
alphaAtten = 1.0F;
|
alphaAtten = 1.0F;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user