Fix samplerParameter validation
Refactor the validation out from the API and into a separate Validate
function. Also check the sampler parameter first to match dEQP
expectations.
BUG=angleproject:1101
TEST=dEQP-GLES3.functional.negative_api.shader.sampler* (all pass)
Change-Id: I5f4072d9e52d37f741bd4c90f1bffe13371af3f5
Reviewed-on: https://chromium-review.googlesource.com/336162
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 24ab91a..fe5d009 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -1970,4 +1970,37 @@
return true;
}
+bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param)
+{
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
+ return false;
+ }
+
+ if (!context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return false;
+ }
+
+ if (!ValidateSamplerObjectParameter(context, pname))
+ {
+ return false;
+ }
+
+ if (!ValidateTexParamParameters(context, pname, param))
+ {
+ return false;
+ }
+ return true;
+}
+
+bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param)
+{
+ // The only float parameters are MIN_LOD and MAX_LOD. For these any value is permissible, so
+ // ValidateSamplerParameteri can be used for validation here.
+ return ValidateSamplerParameteri(context, sampler, pname, static_cast<GLint>(param));
+}
+
} // namespace gl