mesa: refuse to update sampler parameters when a handle is allocated
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 22 Feb 2017 22:20:03 +0000 (23:20 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Jun 2017 08:04:36 +0000 (10:04 +0200)
The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by SamplerParameter* if
    <sampler> identifies a sampler object referenced by one or more
    texture handles."

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/main/samplerobj.c

index ee15c68b4ff6639c0c284fcb0fedd85904e94f67..d3ed4da39324914139a8583b14f9f5341155a853 100644 (file)
@@ -769,7 +769,7 @@ set_sampler_srgb_decode(struct gl_context *ctx,
 
 static struct gl_sampler_object *
 sampler_parameter_error_check(struct gl_context *ctx, GLuint sampler,
-                              const char *name)
+                              bool get, const char *name)
 {
    struct gl_sampler_object *sampObj;
 
@@ -786,6 +786,17 @@ sampler_parameter_error_check(struct gl_context *ctx, GLuint sampler,
       return NULL;
    }
 
+   if (!get && sampObj->HandleAllocated) {
+      /* The ARB_bindless_texture spec says:
+       *
+       * "The error INVALID_OPERATION is generated by SamplerParameter* if
+       *  <sampler> identifies a sampler object referenced by one or more
+       *  texture handles."
+       */
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable sampler)", name);
+      return NULL;
+   }
+
    return sampObj;
 }
 
@@ -796,7 +807,7 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameteri");
    if (!sampObj)
       return;
@@ -879,7 +890,7 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameterf");
    if (!sampObj)
       return;
@@ -961,7 +972,7 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameteriv");
    if (!sampObj)
       return;
@@ -1051,7 +1062,7 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameterfv");
    if (!sampObj)
       return;
@@ -1134,7 +1145,7 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameterIiv");
    if (!sampObj)
       return;
@@ -1218,7 +1229,7 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
    GLuint res;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, false,
                                            "glSamplerParameterIuiv");
    if (!sampObj)
       return;
@@ -1301,7 +1312,7 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
    struct gl_sampler_object *sampObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, true,
                                            "glGetSamplerParameteriv");
    if (!sampObj)
       return;
@@ -1385,7 +1396,7 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
    struct gl_sampler_object *sampObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, true,
                                            "glGetSamplerParameterfv");
    if (!sampObj)
       return;
@@ -1457,7 +1468,7 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
    struct gl_sampler_object *sampObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, true,
                                            "glGetSamplerParameterIiv");
    if (!sampObj)
       return;
@@ -1529,7 +1540,7 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
    struct gl_sampler_object *sampObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   sampObj = sampler_parameter_error_check(ctx, sampler,
+   sampObj = sampler_parameter_error_check(ctx, sampler, true,
                                            "glGetSamplerParameterIuiv");
    if (!sampObj)
       return;