[Mesa-dev] [PATCH v2 06/64] mesa: refuse to update sampler parameters when a handle is allocated
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue May 30 20:35:37 UTC 2017
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."
v2: - add new 'get' param to sampler_parameter_error_check()
- move the HandleAllocated check to sampler_parameter_error_check()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/mesa/main/samplerobj.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index ee15c68b4f..d3ed4da393 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -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;
--
2.13.0
More information about the mesa-dev
mailing list