X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fmultisample.c;h=38d91f7204e2d27527006c5b45bcd9a5a5626c2a;hb=167f6a33fa7be914f4b5171eeeb82bc5e01255f9;hp=bd97c50960ef1b59c7ad9727a3269e1478280211;hpb=721f47227e2c5affded50ea41b33aa050ef6b5b6;p=mesa.git diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c index bd97c50960e..38d91f7204e 100644 --- a/src/mesa/main/multisample.c +++ b/src/mesa/main/multisample.c @@ -41,11 +41,16 @@ _mesa_SampleCoverage(GLclampf value, GLboolean invert) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); + value = CLAMP(value, 0.0f, 1.0f); - ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0); + if (ctx->Multisample.SampleCoverageInvert == invert && + ctx->Multisample.SampleCoverageValue == value) + return; + + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : _NEW_MULTISAMPLE); + ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask; + ctx->Multisample.SampleCoverageValue = value; ctx->Multisample.SampleCoverageInvert = invert; - ctx->NewState |= _NEW_MULTISAMPLE; } @@ -89,7 +94,7 @@ _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat * val) /* winsys FBOs are upside down */ if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) - val[1] = 1 - val[1]; + val[1] = 1.0f - val[1]; return; } @@ -115,10 +120,38 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask) return; } - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + if (ctx->Multisample.SampleMaskValue == mask) + return; + + 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); + + if (!_mesa_has_ARB_sample_shading(ctx) && + !_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, + 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 @@ -132,6 +165,20 @@ GLenum _mesa_check_sample_count(struct gl_context *ctx, GLenum target, GLenum internalFormat, GLsizei samples) { + /* Section 4.4 (Framebuffer objects), page 198 of the OpenGL ES 3.0.0 + * specification says: + * + * "If internalformat is a signed or unsigned integer format and samples + * is greater than zero, then the error INVALID_OPERATION is generated." + * + * This restriction is relaxed for OpenGL ES 3.1. + */ + if ((ctx->API == API_OPENGLES2 && ctx->Version == 30) && + _mesa_is_enum_format_integer(internalFormat) + && samples > 0) { + return GL_INVALID_OPERATION; + } + /* If ARB_internalformat_query is supported, then treat its highest * returned sample count as the absolute maximum for this format; it is * allowed to exceed MAX_SAMPLES. @@ -142,10 +189,15 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target, * for then the error INVALID_OPERATION is generated." */ if (ctx->Extensions.ARB_internalformat_query) { - GLint buffer[16]; - int count = ctx->Driver.QuerySamplesForFormat(ctx, target, - internalFormat, buffer); - int limit = count ? buffer[0] : -1; + GLint buffer[16] = {-1}; + GLint limit; + + ctx->Driver.QueryInternalFormat(ctx, target, internalFormat, + GL_SAMPLES, buffer); + /* since the query returns samples sorted in descending order, + * the first element is the greatest supported sample value. + */ + limit = buffer[0]; return samples > limit ? GL_INVALID_OPERATION : GL_NO_ERROR; }