mesa/es: Validate glGetFramebufferAttachmentParameter pname in Mesa code rather than the ES wrapper

v2: Add proper core-profile, GLES1, and GLES3 filtering.

v3: Fix the GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME query when the
attachment type is GL_NONE on GLES3.  Other cleanups.  Based on review
feedback from Eric Anholt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Ian Romanick
2012-07-27 07:47:28 -07:00
parent 5b44a77428
commit 0cdaa471ec
2 changed files with 29 additions and 42 deletions

View File

@@ -2194,21 +2194,6 @@
<param name="pname" type="GLenum"/> <param name="pname" type="GLenum"/>
<vector name="params" type="GLtype *" size="dynamic"/> <vector name="params" type="GLtype *" size="dynamic"/>
</proto> </proto>
<desc name="pname">
<value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES" category="OES_framebuffer_object"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES" category="OES_framebuffer_object"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES" category="OES_framebuffer_object"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES" category="OES_framebuffer_object"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE" category="GLES2.0"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME" category="GLES2.0"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL" category="GLES2.0"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE" category="GLES2.0"/>
<value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES" category="OES_texture_3D"/>
<desc name="params" vector_size="1" convert="false"/>
</desc>
</template> </template>
<template name="GetRenderbufferParameter" direction="get"> <template name="GetRenderbufferParameter" direction="get">

View File

@@ -2362,11 +2362,10 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
} }
else { else {
assert(att->Type == GL_NONE); assert(att->Type == GL_NONE);
if (_mesa_is_desktop_gl(ctx)) { if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
*params = 0; *params = 0;
} else { } else {
_mesa_error(ctx, GL_INVALID_ENUM, goto invalid_pname_enum;
"glGetFramebufferAttachmentParameterivEXT(pname)");
} }
} }
return; return;
@@ -2379,8 +2378,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
"glGetFramebufferAttachmentParameterivEXT(pname)"); "glGetFramebufferAttachmentParameterivEXT(pname)");
} }
else { else {
_mesa_error(ctx, GL_INVALID_ENUM, goto invalid_pname_enum;
"glGetFramebufferAttachmentParameterivEXT(pname)");
} }
return; return;
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT:
@@ -2397,12 +2395,16 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
"glGetFramebufferAttachmentParameterivEXT(pname)"); "glGetFramebufferAttachmentParameterivEXT(pname)");
} }
else { else {
_mesa_error(ctx, GL_INVALID_ENUM, goto invalid_pname_enum;
"glGetFramebufferAttachmentParameterivEXT(pname)");
} }
return; return;
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT:
if (att->Type == GL_TEXTURE) { if (ctx->API == API_OPENGLES) {
goto invalid_pname_enum;
} else if (att->Type == GL_NONE) {
_mesa_error(ctx, err,
"glGetFramebufferAttachmentParameterivEXT(pname)");
} else if (att->Type == GL_TEXTURE) {
if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) {
*params = att->Zoffset; *params = att->Zoffset;
} }
@@ -2410,19 +2412,14 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
*params = 0; *params = 0;
} }
} }
else if (att->Type == GL_NONE) {
_mesa_error(ctx, err,
"glGetFramebufferAttachmentParameterivEXT(pname)");
}
else { else {
_mesa_error(ctx, GL_INVALID_ENUM, goto invalid_pname_enum;
"glGetFramebufferAttachmentParameterivEXT(pname)");
} }
return; return;
case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
if (!ctx->Extensions.ARB_framebuffer_object) { if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object)
_mesa_error(ctx, GL_INVALID_ENUM, && !_mesa_is_gles3(ctx)) {
"glGetFramebufferAttachmentParameterivEXT(pname)"); goto invalid_pname_enum;
} }
else if (att->Type == GL_NONE) { else if (att->Type == GL_NONE) {
_mesa_error(ctx, err, _mesa_error(ctx, err,
@@ -2440,10 +2437,10 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
} }
return; return;
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
if (!ctx->Extensions.ARB_framebuffer_object) { if ((ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object)
_mesa_error(ctx, GL_INVALID_ENUM, && ctx->API != API_OPENGL_CORE
"glGetFramebufferAttachmentParameterivEXT(pname)"); && !_mesa_is_gles3(ctx)) {
return; goto invalid_pname_enum;
} }
else if (att->Type == GL_NONE) { else if (att->Type == GL_NONE) {
_mesa_error(ctx, err, _mesa_error(ctx, err,
@@ -2475,9 +2472,9 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
if (!ctx->Extensions.ARB_framebuffer_object) { if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object)
_mesa_error(ctx, GL_INVALID_ENUM, && !_mesa_is_gles3(ctx)) {
"glGetFramebufferAttachmentParameterivEXT(pname)"); goto invalid_pname_enum;
} }
else if (att->Type == GL_NONE) { else if (att->Type == GL_NONE) {
_mesa_error(ctx, err, _mesa_error(ctx, err,
@@ -2505,10 +2502,15 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
} }
return; return;
default: default:
_mesa_error(ctx, GL_INVALID_ENUM, goto invalid_pname_enum;
"glGetFramebufferAttachmentParameterivEXT(pname)");
return;
} }
return;
invalid_pname_enum:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetFramebufferAttachmentParameteriv(pname)");
return;
} }