summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/attrib.c
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2018-04-27 11:35:00 -0600
committerBrian Paul <[email protected]>2018-04-30 21:13:53 -0600
commit4580617509d1ba48a7806227533a07e1c495ca81 (patch)
tree99d00ab799e56500ba754fa02bb50464731945ce /src/mesa/main/attrib.c
parent31ab0427a767c6c8377c00203e87bf0a03ac3247 (diff)
mesa: add support for nvidia conservative rasterization extensions
Although the specs are written against compatibility GL 4.3 and allows core profile and GLES2+, it is exposed for GL 1.0+ and GLES1 and GLES2+. Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/attrib.c')
-rw-r--r--src/mesa/main/attrib.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 9f0e7161f3e..6127a556d73 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -137,6 +137,9 @@ struct gl_enable_attrib
/* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */
GLboolean sRGBEnabled;
+
+ /* GL_NV_conservative_raster */
+ GLboolean ConservativeRasterization;
};
@@ -177,6 +180,13 @@ struct texture_state
};
+struct viewport_state
+{
+ struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS];
+ GLuint SubpixelPrecisionBias[2];
+};
+
+
/** An unused GL_*_BIT value */
#define DUMMY_BIT 0x10000000
@@ -393,6 +403,9 @@ _mesa_PushAttrib(GLbitfield mask)
/* GL_ARB_framebuffer_sRGB / GL_EXT_framebuffer_sRGB */
attr->sRGBEnabled = ctx->Color.sRGBEnabled;
+
+ /* GL_NV_conservative_raster */
+ attr->ConservativeRasterization = ctx->ConservativeRasterization;
}
if (mask & GL_EVAL_BIT) {
@@ -544,11 +557,23 @@ _mesa_PushAttrib(GLbitfield mask)
}
if (mask & GL_VIEWPORT_BIT) {
- if (!push_attrib(ctx, &head, GL_VIEWPORT_BIT,
- sizeof(struct gl_viewport_attrib)
- * ctx->Const.MaxViewports,
- (void*)&ctx->ViewportArray))
+ struct viewport_state *viewstate = CALLOC_STRUCT(viewport_state);
+ if (!viewstate) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_VIEWPORT_BIT)");
+ goto end;
+ }
+
+ if (!save_attrib_data(&head, GL_VIEWPORT_BIT, viewstate)) {
+ free(viewstate);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_VIEWPORT_BIT)");
goto end;
+ }
+
+ memcpy(&viewstate->ViewportArray, &ctx->ViewportArray,
+ sizeof(struct gl_viewport_attrib)*ctx->Const.MaxViewports);
+
+ viewstate->SubpixelPrecisionBias[0] = ctx->SubpixelPrecisionBias[0];
+ viewstate->SubpixelPrecisionBias[1] = ctx->SubpixelPrecisionBias[1];
}
/* GL_ARB_multisample */
@@ -713,6 +738,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
TEST_AND_UPDATE(ctx->Color.sRGBEnabled, enable->sRGBEnabled,
GL_FRAMEBUFFER_SRGB);
+ /* GL_NV_conservative_raster */
+ if (ctx->Extensions.NV_conservative_raster) {
+ TEST_AND_UPDATE(ctx->ConservativeRasterization,
+ enable->ConservativeRasterization,
+ GL_CONSERVATIVE_RASTERIZATION_NV);
+ }
+
/* texture unit enables */
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
const GLbitfield enabled = enable->Texture[i];
@@ -1126,7 +1158,8 @@ _mesa_PopAttrib(void)
ctx->DriverFlags.NewSampleAlphaToXEnable |
ctx->DriverFlags.NewSampleMask |
ctx->DriverFlags.NewScissorTest |
- ctx->DriverFlags.NewStencil;
+ ctx->DriverFlags.NewStencil |
+ ctx->DriverFlags.NewNvConservativeRasterization;
}
break;
case GL_EVAL_BIT:
@@ -1418,13 +1451,20 @@ _mesa_PopAttrib(void)
case GL_VIEWPORT_BIT:
{
unsigned i;
- const struct gl_viewport_attrib *vp;
- vp = (const struct gl_viewport_attrib *) attr->data;
+ const struct viewport_state *viewstate;
+ viewstate = (const struct viewport_state *) attr->data;
for (i = 0; i < ctx->Const.MaxViewports; i++) {
- _mesa_set_viewport(ctx, i, vp[i].X, vp[i].Y, vp[i].Width,
- vp[i].Height);
- _mesa_set_depth_range(ctx, i, vp[i].Near, vp[i].Far);
+ const struct gl_viewport_attrib *vp = &viewstate->ViewportArray[i];
+ _mesa_set_viewport(ctx, i, vp->X, vp->Y, vp->Width,
+ vp->Height);
+ _mesa_set_depth_range(ctx, i, vp->Near, vp->Far);
+ }
+
+ if (ctx->Extensions.NV_conservative_raster) {
+ GLuint biasx = viewstate->SubpixelPrecisionBias[0];
+ GLuint biasy = viewstate->SubpixelPrecisionBias[1];
+ _mesa_SubpixelPrecisionBiasNV(biasx, biasy);
}
}
break;