Add code to support proper errror reporting:
GL_FRAMEBUFFER_UNSUPPORTED
when an internal texture image format isn't suitable for render-to-texture,
and the texture image has been attached to a framebuffer.

The driver should set
gl_texture_image::IsDepthStencil
and
gl_texture_image::IsColorRT

to indicate whether the internal texture image format is suitable as
a depth / stencil or color render target respective.

Note: For backwards compatibility, these default to GL_TRUE.

Signed-off-by: Thomas Hellstrom <[email protected]>
---
 src/mesa/main/fbobject.c |   14 ++++++++++++++
 src/mesa/main/mtypes.h   |    4 ++++
 src/mesa/main/teximage.c |    5 +++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 83301f1..274958c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -549,9 +549,23 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct 
gl_framebuffer *fb)
 
       /* get width, height, format of the renderbuffer/texture
        */
+
       if (att->Type == GL_TEXTURE) {
          const struct gl_texture_image *texImg
             = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+
+        /**
+         * Internal format may be unsupported as a render target
+         */
+
+        if ((i < 0 && !texImg->IsDepthStencil) ||
+            (i >= 0 && !texImg->IsColorRT)) {
+           att->Complete = GL_FALSE;
+           fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+           fbo_incomplete("internal format unsupported", i);
+           return;
+        }
+
          minWidth = MIN2(minWidth, texImg->Width);
          maxWidth = MAX2(maxWidth, texImg->Width);
          minHeight = MIN2(minHeight, texImg->Height);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d0309f5..b76f2b1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1259,6 +1259,10 @@ struct gl_texture_image
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
    GLvoid *Data;               /**< Image data, accessed via FetchTexel() */
+   GLboolean IsDepthStencil;    /**< Format can be attached as a Depth
+                                    Stencil renderbuffer >**/
+   GLboolean IsColorRT;         /**< Format can be attached as a Color
+                                    rendertarget>**/
 
    /**
     * \name For device driver:
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6e21066..b4b6fa4 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1269,6 +1269,11 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
       img->HeightScale = (GLfloat) img->Height;
       img->DepthScale = (GLfloat) img->Depth;
    }
+
+   /* Initialize these to true for backwards compatibility. */
+
+   img->IsDepthStencil = GL_TRUE;
+   img->IsColorRT = GL_TRUE;
 }
 
 
-- 
1.6.0.2


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to