[Mesa-dev] [PATCH 2/4] mesa: validate size parameters for glTexStorage*Multisample
Anuj Phogat
anuj.phogat at gmail.com
Fri Aug 14 10:43:19 PDT 2015
On Fri, Aug 14, 2015 at 10:30 AM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> On Mon, Aug 10, 2015 at 1:06 AM, Tapani Pälli <tapani.palli at intel.com> wrote:
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>> src/mesa/main/teximage.c | 28 ++++++++++++++++++++++++++++
>> 1 file changed, 28 insertions(+)
>>
>> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> index fc69387..3ea7b2a 100644
>> --- a/src/mesa/main/teximage.c
>> +++ b/src/mesa/main/teximage.c
>> @@ -5782,6 +5782,18 @@ _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
>> "glTexImage3DMultisample");
>> }
>>
>> +static bool
>> +valid_texstorage_ms_parameters(GLsizei width, GLsizei height, GLsizei depth,
>> + GLsizei samples, const char *func)
>> +{
>> + GET_CURRENT_CONTEXT(ctx);
>> +
>> + if (_mesa_tex_storage_invalid_dim(width, height, depth) || samples < 1) {
>> + _mesa_error(ctx, GL_INVALID_VALUE, "%s()", func);
>> + return false;
>> + }
>> + return true;
>> +}
>>
> I think samples = 0 is acceptable by the spec. samples < 0 or samples
>> max_samples is what generate GL_INVALID_VALUE error. samples
> count check is anyway taken care of by _mesa_check_sample_count()
> in _mesa_texture_image_multisample(). So, no need of a helper function
> here. Just do _mesa_valid_tex_storage_dim() checks.
>
Now I noticed that samples = 0 is not acceptable in GLES 3.1 but don't see
it in GL. Add an ES 3.1 check here.
>> void GLAPIENTRY
>> _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
>> @@ -5795,6 +5807,10 @@ _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
>> if (!texObj)
>> return;
>>
>> + if (!valid_texstorage_ms_parameters(width, height, 1, samples,
>> + "glTexStorage2DMultisample"))
>> + return;
>> +
>> _mesa_texture_image_multisample(ctx, 2, texObj, target, samples,
>> internalformat, width, height, 1,
>> fixedsamplelocations, GL_TRUE,
>> @@ -5814,6 +5830,10 @@ _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
>> if (!texObj)
>> return;
>>
>> + if (!valid_texstorage_ms_parameters(width, height, depth, samples,
>> + "glTexStorage3DMultisample"))
>> + return;
>> +
>> _mesa_texture_image_multisample(ctx, 3, texObj, target, samples,
>> internalformat, width, height, depth,
>> fixedsamplelocations, GL_TRUE,
>> @@ -5834,6 +5854,10 @@ _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
>> if (!texObj)
>> return;
>>
>> + if (!valid_texstorage_ms_parameters(width, height, 1, samples,
>> + "glTextureStorage2DMultisample"))
>> + return;
>> +
>> _mesa_texture_image_multisample(ctx, 2, texObj, texObj->Target, samples,
>> internalformat, width, height, 1,
>> fixedsamplelocations, GL_TRUE,
>> @@ -5855,6 +5879,10 @@ _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
>> if (!texObj)
>> return;
>>
>> + if (!valid_texstorage_ms_parameters(width, height, depth, samples,
>> + "glTextureStorage3DMultisample"))
>> + return;
>> +
>> _mesa_texture_image_multisample(ctx, 3, texObj, texObj->Target, samples,
>> internalformat, width, height, depth,
>> fixedsamplelocations, GL_TRUE,
>> --
>> 2.1.0
>>
More information about the mesa-dev
mailing list