Module: Mesa
Branch: master
Commit: 5da8288911bfd104756dfe6dc02be998208dd4cb
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5da8288911bfd104756dfe6dc02be998208dd4cb

Author: Jordan Justen <[email protected]>
Date:   Thu Apr 18 10:20:05 2013 -0700

mesa: add Layered field to framebuffers

When checking framebuffer completeness, we test each attachment.
We verify that all attachments are consistent in terms of layers.

1. They must all be layered, or all non-layered
2. If they are layered, they must match in depth

Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Brian Paul <[email protected]>

---

 src/mesa/main/fbobject.c |   20 ++++++++++++++++++++
 src/mesa/main/mtypes.h   |    2 ++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 7984661..de0c08f 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -777,6 +777,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
    GLint fixedSampleLocations = -1;
    GLint i;
    GLuint j;
+   bool layer_count_valid = false;
+   GLuint layer_count = 0, att_layer_count;
 
    assert(_mesa_is_user_fbo(fb));
 
@@ -949,8 +951,26 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          fbo_incomplete("unsupported renderbuffer format", i);
          return;
       }
+
+      /* Check that layered rendering is consistent. */
+      att_layer_count = att->Layered ? att->Renderbuffer->Depth : 0;
+      if (!layer_count_valid) {
+         layer_count = att_layer_count;
+         layer_count_valid = true;
+      } else if (layer_count != att_layer_count) {
+         if (layer_count == 0 || att_layer_count == 0) {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
+            fbo_incomplete("framebuffer attachment layer mode is 
inconsistent", i);
+         } else {
+            fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB;
+            fbo_incomplete("framebuffer attachment layer count is 
inconsistent", i);
+         }
+         return;
+      }
    }
 
+   fb->Layered = layer_count > 0;
+
    if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
       /* Check that all DrawBuffers are present */
       for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8dda8e2..89e00e3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2683,6 +2683,8 @@ struct gl_framebuffer
    struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
+   GLboolean Layered;
+
    /** Delete this framebuffer */
    void (*Delete)(struct gl_framebuffer *fb);
 };

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to