aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c22
-rw-r--r--src/mesa/main/enable.c29
-rw-r--r--src/mesa/main/framebuffer.c19
-rw-r--r--src/mesa/main/get.c12
-rw-r--r--src/mesa/main/get_hash_params.py2
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/scissor.c26
7 files changed, 78 insertions, 40 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 30c815d67f0..f571f9fc7f0 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -112,7 +112,7 @@ struct gl_enable_attrib
GLboolean PolygonSmooth;
GLboolean PolygonStipple;
GLboolean RescaleNormals;
- GLboolean Scissor;
+ GLbitfield Scissor;
GLboolean Stencil;
GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
GLboolean MultisampleEnabled; /* GL_ARB_multisample */
@@ -354,7 +354,7 @@ _mesa_PushAttrib(GLbitfield mask)
attr->PolygonSmooth = ctx->Polygon.SmoothFlag;
attr->PolygonStipple = ctx->Polygon.StippleFlag;
attr->RescaleNormals = ctx->Transform.RescaleNormals;
- attr->Scissor = ctx->Scissor.Enabled;
+ attr->Scissor = ctx->Scissor.EnableFlags;
attr->Stencil = ctx->Stencil.Enabled;
attr->StencilTwoSide = ctx->Stencil.TestTwoSide;
attr->MultisampleEnabled = ctx->Multisample.Enabled;
@@ -658,7 +658,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
GL_POLYGON_SMOOTH);
TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple,
GL_POLYGON_STIPPLE);
- TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
+ if (ctx->Scissor.EnableFlags != enable->Scissor) {
+ unsigned i;
+
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i, (enable->Scissor >> i) & 1);
+ }
+ }
TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
if (ctx->Extensions.EXT_stencil_two_side) {
TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT);
@@ -1264,9 +1270,13 @@ _mesa_PopAttrib(void)
{
const struct gl_scissor_attrib *scissor;
scissor = (const struct gl_scissor_attrib *) attr->data;
- _mesa_Scissor(scissor->X, scissor->Y,
- scissor->Width, scissor->Height);
- _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled);
+ _mesa_set_scissor(ctx,
+ scissor->ScissorArray[0].X,
+ scissor->ScissorArray[0].Y,
+ scissor->ScissorArray[0].Width,
+ scissor->ScissorArray[0].Height);
+ _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->EnableFlags & 1);
+
}
break;
case GL_STENCIL_BUFFER_BIT:
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index fca306890e5..a6246905e51 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -659,10 +659,15 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
ctx->Transform.RescaleNormals = state;
break;
case GL_SCISSOR_TEST:
- if (ctx->Scissor.Enabled == state)
- return;
- FLUSH_VERTICES(ctx, _NEW_SCISSOR);
- ctx->Scissor.Enabled = state;
+ {
+ /* Must expand glEnable to all scissors */
+ GLbitfield newEnabled =
+ state * ((1 << ctx->Const.MaxViewports) - 1);
+ if (newEnabled != ctx->Scissor.EnableFlags) {
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ ctx->Scissor.EnableFlags = newEnabled;
+ }
+ }
break;
case GL_STENCIL_TEST:
if (ctx->Stencil.Enabled == state)
@@ -1076,6 +1081,20 @@ _mesa_set_enablei(struct gl_context *ctx, GLenum cap,
ctx->Color.BlendEnabled &= ~(1 << index);
}
break;
+ case GL_SCISSOR_TEST:
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
+ state ? "glEnablei" : "glDisablei", index);
+ return;
+ }
+ if (((ctx->Scissor.EnableFlags >> index) & 1) != state) {
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ if (state)
+ ctx->Scissor.EnableFlags |= (1 << index);
+ else
+ ctx->Scissor.EnableFlags &= ~(1 << index);
+ }
+ break;
default:
goto invalid_enum_error;
}
@@ -1349,7 +1368,7 @@ _mesa_IsEnabled( GLenum cap )
goto invalid_enum_error;
return ctx->Transform.RescaleNormals;
case GL_SCISSOR_TEST:
- return ctx->Scissor.Enabled;
+ return ctx->Scissor.EnableFlags & 1; /* return state for index 0 */
case GL_STENCIL_TEST:
return ctx->Stencil.Enabled;
case GL_TEXTURE_1D:
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 2fad4588066..f14f7a4877e 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -380,18 +380,19 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx)
buffer->_Xmax = buffer->Width;
buffer->_Ymax = buffer->Height;
- if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > buffer->_Xmin) {
- buffer->_Xmin = ctx->Scissor.X;
+ /* Default to the first scissor as that's always valid */
+ if (ctx->Scissor.EnableFlags & 1) {
+ if (ctx->Scissor.ScissorArray[0].X > buffer->_Xmin) {
+ buffer->_Xmin = ctx->Scissor.ScissorArray[0].X;
}
- if (ctx->Scissor.Y > buffer->_Ymin) {
- buffer->_Ymin = ctx->Scissor.Y;
+ if (ctx->Scissor.ScissorArray[0].Y > buffer->_Ymin) {
+ buffer->_Ymin = ctx->Scissor.ScissorArray[0].Y;
}
- if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
- buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
+ if (ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width < buffer->_Xmax) {
+ buffer->_Xmax = ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width;
}
- if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
- buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+ if (ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height < buffer->_Ymax) {
+ buffer->_Ymax = ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height;
}
/* finally, check for empty region */
if (buffer->_Xmin > buffer->_Xmax) {
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index b13f9a3dba6..dd6ac311674 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -665,10 +665,14 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_SCISSOR_BOX:
- v->value_int_4[0] = ctx->Scissor.X;
- v->value_int_4[1] = ctx->Scissor.Y;
- v->value_int_4[2] = ctx->Scissor.Width;
- v->value_int_4[3] = ctx->Scissor.Height;
+ v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X;
+ v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y;
+ v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width;
+ v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height;
+ break;
+
+ case GL_SCISSOR_TEST:
+ v->value_bool = ctx->Scissor.EnableFlags & 1;
break;
case GL_LIST_INDEX:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index bc2bbafa8c3..6fcd4f622cd 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -30,7 +30,7 @@ descriptor=[
[ "POLYGON_OFFSET_FILL", "CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA" ],
[ "RED_BITS", "BUFFER_INT(Visual.redBits), extra_new_buffers" ],
[ "SCISSOR_BOX", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ],
- [ "SCISSOR_TEST", "CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA" ],
+ [ "SCISSOR_TEST", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
[ "STENCIL_BITS", "BUFFER_INT(Visual.stencilBits), extra_new_buffers" ],
[ "STENCIL_CLEAR_VALUE", "CONTEXT_INT(Stencil.Clear), NO_EXTRA" ],
[ "STENCIL_FAIL", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a939d9c9f62..9dbfa6bfbc6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1009,12 +1009,16 @@ struct gl_polygon_attrib
/**
* Scissor attributes (GL_SCISSOR_BIT).
*/
-struct gl_scissor_attrib
+struct gl_scissor_rect
{
- GLboolean Enabled; /**< Scissor test enabled? */
GLint X, Y; /**< Lower left corner of box */
GLsizei Width, Height; /**< Size of box */
};
+struct gl_scissor_attrib
+{
+ GLbitfield EnableFlags; /**< Scissor test enabled? */
+ struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
+};
/**
diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index ac86bd59138..7ec927ecd8b 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -66,17 +66,17 @@ void
_mesa_set_scissor(struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height)
{
- if (x == ctx->Scissor.X &&
- y == ctx->Scissor.Y &&
- width == ctx->Scissor.Width &&
- height == ctx->Scissor.Height)
+ if (x == ctx->Scissor.ScissorArray[0].X &&
+ y == ctx->Scissor.ScissorArray[0].Y &&
+ width == ctx->Scissor.ScissorArray[0].Width &&
+ height == ctx->Scissor.ScissorArray[0].Height)
return;
FLUSH_VERTICES(ctx, _NEW_SCISSOR);
- ctx->Scissor.X = x;
- ctx->Scissor.Y = y;
- ctx->Scissor.Width = width;
- ctx->Scissor.Height = height;
+ ctx->Scissor.ScissorArray[0].X = x;
+ ctx->Scissor.ScissorArray[0].Y = y;
+ ctx->Scissor.ScissorArray[0].Width = width;
+ ctx->Scissor.ScissorArray[0].Height = height;
if (ctx->Driver.Scissor)
ctx->Driver.Scissor(ctx);
@@ -91,9 +91,9 @@ void
_mesa_init_scissor(struct gl_context *ctx)
{
/* Scissor group */
- ctx->Scissor.Enabled = GL_FALSE;
- ctx->Scissor.X = 0;
- ctx->Scissor.Y = 0;
- ctx->Scissor.Width = 0;
- ctx->Scissor.Height = 0;
+ ctx->Scissor.EnableFlags = GL_FALSE;
+ ctx->Scissor.ScissorArray[0].X = 0;
+ ctx->Scissor.ScissorArray[0].Y = 0;
+ ctx->Scissor.ScissorArray[0].Width = 0;
+ ctx->Scissor.ScissorArray[0].Height = 0;
}