mesa/es: Validate FBO attachment enum in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Sun, 2 Oct 2011 21:50:21 +0000 (14:50 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 4 Oct 2011 19:25:56 +0000 (12:25 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/APIspec.xml
src/mesa/main/fbobject.c

index 0f82d0a38e16d70e2dfd96d8013759d3f17a90f1..2b277a081b9177a747e86002246ddfa00040960f 100644 (file)
                <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
        </desc>
 
-       <desc name="attachment">
-               <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
-               <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
-               <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
-               <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
-       </desc>
-
        <desc name="renderbuffertarget">
                <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
                <value name="GL_RENDERBUFFER" category="GLES2.0"/>
                <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
        </desc>
 
-       <desc name="attachment">
-               <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
-               <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
-               <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
-               <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
-       </desc>
-
        <desc name="textarget" error="GL_INVALID_OPERATION">
                <value name="GL_TEXTURE_2D"/>
                <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
                <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
        </desc>
 
-       <desc name="attachment">
-               <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
-               <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
-               <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
-               <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
-               <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
-       </desc>
-
        <desc name="textarget" error="GL_INVALID_OPERATION">
                <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
        </desc>
index 139ff03da063817320bb98481e3d9f6423683b83..2e0af97f4d373172d166a979d6e249ae78dd73f2 100644 (file)
@@ -239,17 +239,22 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
    case GL_COLOR_ATTACHMENT14_EXT:
    case GL_COLOR_ATTACHMENT15_EXT:
       i = attachment - GL_COLOR_ATTACHMENT0_EXT;
-      if (i >= ctx->Const.MaxColorAttachments) {
+      if (i >= ctx->Const.MaxColorAttachments
+         || (i > 0 && ctx->API != API_OPENGL)) {
         return NULL;
       }
       return &fb->Attachment[BUFFER_COLOR0 + i];
    case GL_DEPTH_STENCIL_ATTACHMENT:
+      if (ctx->API != API_OPENGL)
+        return NULL;
       /* fall-through */
    case GL_DEPTH_BUFFER:
       /* fall-through / new in GL 3.0 */
    case GL_DEPTH_ATTACHMENT_EXT:
       return &fb->Attachment[BUFFER_DEPTH];
    case GL_STENCIL_BUFFER:
+      if (ctx->API != API_OPENGL)
+        return NULL;
       /* fall-through / new in GL 3.0 */
    case GL_STENCIL_ATTACHMENT_EXT:
       return &fb->Attachment[BUFFER_STENCIL];