[Mesa-dev] [RFC PATCH 05/65] mesa: refuse to update sampler parameters when a handle is allocated

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed May 24 14:20:00 UTC 2017



On 05/24/2017 12:20 PM, Nicolai Hähnle wrote:
> On 19.05.2017 18:52, Samuel Pitoiset wrote:
>> 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 at gmail.com>
>> ---
>>   src/mesa/main/samplerobj.c | 42 
>> ++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 42 insertions(+)
>>
>> diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
>> index ee15c68b4f..cf4bcfce7c 100644
>> --- a/src/mesa/main/samplerobj.c
>> +++ b/src/mesa/main/samplerobj.c
>> @@ -801,6 +801,18 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum 
>> pname, GLint param)
>>      if (!sampObj)
>>         return;
>> +   if (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,
>> +                  "glSamplerParameteri(immutable sampler)");
>> +      return;
>> +   }
> 
> Maybe these could go into sampler_parameter_error_check?

Yes, I added a new boolean parameter to sampler_parameter_error_check() 
to differentiate set/get functions and moved the HandleAllocated check 
there.

> 
> Cheers,
> Nicolai
> 
> 
> 
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, param);
>> @@ -884,6 +896,12 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum 
>> pname, GLfloat param)
>>      if (!sampObj)
>>         return;
>> +   if (sampObj->HandleAllocated) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glSamplerParameterf(immutable sampler)");
>> +      return;
>> +   }
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, (GLint) param);
>> @@ -966,6 +984,12 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum 
>> pname, const GLint *params)
>>      if (!sampObj)
>>         return;
>> +   if (sampObj->HandleAllocated) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glSamplerParameteriv(immutable sampler)");
>> +      return;
>> +   }
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, params[0]);
>> @@ -1056,6 +1080,12 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum 
>> pname, const GLfloat *params)
>>      if (!sampObj)
>>         return;
>> +   if (sampObj->HandleAllocated) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glSamplerParameterfv(immutable sampler)");
>> +      return;
>> +   }
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]);
>> @@ -1139,6 +1169,12 @@ _mesa_SamplerParameterIiv(GLuint sampler, 
>> GLenum pname, const GLint *params)
>>      if (!sampObj)
>>         return;
>> +   if (sampObj->HandleAllocated) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glSamplerParameterIiv(immutable sampler)");
>> +      return;
>> +   }
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, params[0]);
>> @@ -1223,6 +1259,12 @@ _mesa_SamplerParameterIuiv(GLuint sampler, 
>> GLenum pname, const GLuint *params)
>>      if (!sampObj)
>>         return;
>> +   if (sampObj->HandleAllocated) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glSamplerParameterIuiv(immutable sampler)");
>> +      return;
>> +   }
>> +
>>      switch (pname) {
>>      case GL_TEXTURE_WRAP_S:
>>         res = set_sampler_wrap_s(ctx, sampObj, params[0]);
>>
> 
> 


More information about the mesa-dev mailing list