[Mesa-dev] [PATCH 1/1] main: validate the type correctly against the OpenGL ES spec.
Brian Paul
brianp at vmware.com
Tue Sep 11 10:15:18 PDT 2012
On 09/11/2012 10:21 AM, Oliver McFadden wrote:
> On Tue, Sep 11, 2012 at 07:54:36AM -0600, Brian Paul wrote:
>> On 09/11/2012 06:09 AM, Oliver McFadden wrote:
>>> Previously Mesa would validate UNSIGNED_INT successfully in violation of
>>> the OpenGL(R) ES 1.0 and 2.0 Specification.
>>>
>>> http://www.khronos.org/registry/gles/specs/1.1/es_full_spec_1.1.12.pdf
>>> http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf
>>> http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf
>>>
>>> Signed-off-by: Oliver McFadden<oliver.mcfadden at linux.intel.com>
>>> ---
>>> src/mesa/main/api_validate.c | 22 ++++++++++++++++++++++
>>> 1 files changed, 22 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
>>> index d0d2ca4..698394c 100644
>>> --- a/src/mesa/main/api_validate.c
>>> +++ b/src/mesa/main/api_validate.c
>>> @@ -296,10 +296,32 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
>>> static bool
>>> valid_elements_type(struct gl_context *ctx, GLenum type, const char *name)
>>> {
>>> + /*
>>> + * Page 22 of the OpenGL(R) ES Version 1.0 Specification (PDF)
>>> + * and
>>> + * Page 21 of the OpenGL(R) ES Version 2.0 Specification (PDF) says:
>>> + *
>>> + * `type' must be one of UNSIGNED_BYTE or UNSIGNED_SHORT, indicating that the
>>> + * values in indices are indices of GL type ubyte or ushort, respectively.
>>> + *
>>> + * Page 29 of the OpenGL(R) ES Version 3.0 Specification (PDF) says:
>>> + *
>>> + * `type' must be one of UNSIGNED_BYTE, UNSIGNED_SHORT, or UNSIGNED_INT,
>>> + * indicating that the index values are of GL type ubyte, ushort, or uint
>>> + * respectively.
>>> + *
>>> + */
>>> switch (type) {
>>> case GL_UNSIGNED_BYTE:
>>> case GL_UNSIGNED_SHORT:
>>> + return true;
>>> case GL_UNSIGNED_INT:
>>> + if (ctx->API == API_OPENGLES ||
>>> + (ctx->API == API_OPENGLES2&& ctx->Version< 30)) {
>>> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", name,
>>> + _mesa_lookup_enum_by_nr(type));
>>> + return false;
>>> + }
>>> return true;
>>>
>>> default:
>>
>> I suspect Ian's covered this in his ES overhaul work, but it looks
>> good to me.
>
> You're giving the OK to push to master? I don't want to conflict with
> existing work...
Ian hasn't posted all his ES-cleanup patches yet (though maybe they're
in a public tree of his) so I don't know if there's a conflict.
If you can hold off for a bit, maybe Ian can review and comment.
-Brian
More information about the mesa-dev
mailing list