This is similar to what we do in the texture error codepath. While we are at it, update the specification comment with latest GL 4.5 spec.
Signed-off-by: Samuel Pitoiset <[email protected]> --- src/mesa/main/samplerobj.c | 139 +++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 87 deletions(-) diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index 9326956e2f..19ee44b562 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -799,26 +799,40 @@ set_sampler_srgb_decode(struct gl_context *ctx, return GL_TRUE; } -void GLAPIENTRY -_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) +static struct gl_sampler_object * +sampler_parameter_error_check(struct gl_context *ctx, GLuint sampler, + const char *name) { struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); sampObj = _mesa_lookup_samplerobj(ctx, sampler); if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." + /* OpenGL 4.5 spec, section "8.2 Sampler Objects", page 176 of the PDF + * states: * + * "An INVALID_OPERATION error is generated if sampler is not the name + * of a sampler object previously returned from a call to + * GenSamplers." */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameteri(sampler %u)", sampler); - return; + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid sampler)", name); + return NULL; } + return sampObj; +} + +void GLAPIENTRY +_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameteri"); + if (!sampObj) + return; + switch (pname) { case GL_TEXTURE_WRAP_S: res = set_sampler_wrap_s(ctx, sampObj, param); @@ -897,18 +911,10 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) GLuint res; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." - * - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameterf(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameterf"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -987,17 +993,10 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) GLuint res; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameteriv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameteriv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1084,18 +1083,10 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) GLuint res; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." - * - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameterfv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameterfv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1175,12 +1166,10 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) GLuint res; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameterIiv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameterIiv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1261,12 +1250,10 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) GLuint res; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSamplerParameterIuiv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glSamplerParameterIuiv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1346,18 +1333,10 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) struct gl_sampler_object *sampObj; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." - * - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSamplerParameteriv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glGetSamplerParameteriv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1438,18 +1417,10 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) struct gl_sampler_object *sampObj; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - /* '3.8.2 Sampler Objects' section of the GL-ES 3.0 specification states: - * - * "An INVALID_OPERATION error is generated if sampler is not the name - * of a sampler object previously returned from a call to GenSamplers." - * - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSamplerParameterfv(sampler %u)", sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glGetSamplerParameterfv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1518,13 +1489,10 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) struct gl_sampler_object *sampObj; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSamplerParameterIiv(sampler %u)", - sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glGetSamplerParameterIiv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: @@ -1593,13 +1561,10 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) struct gl_sampler_object *sampObj; GET_CURRENT_CONTEXT(ctx); - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSamplerParameterIuiv(sampler %u)", - sampler); + sampObj = sampler_parameter_error_check(ctx, sampler, + "glGetSamplerParameterIuiv"); + if (!sampObj) return; - } switch (pname) { case GL_TEXTURE_WRAP_S: -- 2.11.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
