On 07/12/2012 05:53 PM, Paul Berry wrote:
This patch modifies the common code for MSAA tests, so that we can
easily configure framebuffers that lack a color, depth, and/or stencil
buffer.

For the series,

Reviewed-by: Ian Romanick <[email protected]>

---
  tests/spec/ext_framebuffer_multisample/common.cpp |  104 +++++++++++---------
  tests/spec/ext_framebuffer_multisample/common.h   |   21 ++++-
  2 files changed, 76 insertions(+), 49 deletions(-)

diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp 
b/tests/spec/ext_framebuffer_multisample/common.cpp
index e1f6127..12c9c82 100644
--- a/tests/spec/ext_framebuffer_multisample/common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp
@@ -116,7 +116,9 @@ FboConfig::FboConfig(int num_samples, int width, int height)
          height(height),
          combine_depth_stencil(true),
          attach_texture(false),
-         color_internalformat(GL_RGBA)
+         color_internalformat(GL_RGBA),
+         depth_internalformat(GL_DEPTH_COMPONENT24),
+         stencil_internalformat(GL_STENCIL_INDEX8)
  {
  }

@@ -186,36 +188,38 @@ Fbo::try_setup(const FboConfig &new_config)
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, handle);

        /* Color buffer */
-       if (!config.attach_texture) {
-               glBindRenderbuffer(GL_RENDERBUFFER, color_rb);
-               glRenderbufferStorageMultisample(GL_RENDERBUFFER,
-                                                config.num_samples,
-                                                config.color_internalformat,
-                                                config.width,
-                                                config.height);
-               glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
-                                         GL_COLOR_ATTACHMENT0,
-                                         GL_RENDERBUFFER, color_rb);
-       } else {
-               glBindTexture(GL_TEXTURE_2D, color_tex);
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-                               GL_NEAREST);
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
-                               GL_NEAREST);
-               glTexImage2D(GL_TEXTURE_2D,
-                            0 /* level */,
-                            config.color_internalformat,
-                            config.width,
-                            config.height,
-                            0 /* border */,
-                            GL_RGBA /* format */,
-                            GL_BYTE /* type */,
-                            NULL /* data */);
-               glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
-                                      GL_COLOR_ATTACHMENT0,
-                                      GL_TEXTURE_2D,
-                                      color_tex,
-                                      0 /* level */);
+       if (config.color_internalformat != GL_NONE) {
+               if (!config.attach_texture) {
+                       glBindRenderbuffer(GL_RENDERBUFFER, color_rb);
+                       glRenderbufferStorageMultisample(GL_RENDERBUFFER,
+                                                        config.num_samples,
+                                                        
config.color_internalformat,
+                                                        config.width,
+                                                        config.height);
+                       glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
+                                                 GL_COLOR_ATTACHMENT0,
+                                                 GL_RENDERBUFFER, color_rb);
+               } else {
+                       glBindTexture(GL_TEXTURE_2D, color_tex);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+                                       GL_NEAREST);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+                                       GL_NEAREST);
+                       glTexImage2D(GL_TEXTURE_2D,
+                                    0 /* level */,
+                                    config.color_internalformat,
+                                    config.width,
+                                    config.height,
+                                    0 /* border */,
+                                    GL_RGBA /* format */,
+                                    GL_BYTE /* type */,
+                                    NULL /* data */);
+                       glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
+                                              GL_COLOR_ATTACHMENT0,
+                                              GL_TEXTURE_2D,
+                                              color_tex,
+                                              0 /* level */);
+               }
        }

        /* Depth/stencil buffer(s) */
@@ -230,23 +234,29 @@ Fbo::try_setup(const FboConfig &new_config)
                                          GL_DEPTH_STENCIL_ATTACHMENT,
                                          GL_RENDERBUFFER, depth_rb);
        } else {
-               glBindRenderbuffer(GL_RENDERBUFFER, stencil_rb);
-               glRenderbufferStorageMultisample(GL_RENDERBUFFER,
-                                                config.num_samples,
-                                                GL_STENCIL_INDEX8,
-                                                config.width, config.height);
-               glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
-                                         GL_STENCIL_ATTACHMENT,
-                                         GL_RENDERBUFFER, stencil_rb);
+               if (config.stencil_internalformat != GL_NONE) {
+                       glBindRenderbuffer(GL_RENDERBUFFER, stencil_rb);
+                       glRenderbufferStorageMultisample(GL_RENDERBUFFER,
+                                                        config.num_samples,
+                                                        
config.stencil_internalformat,
+                                                        config.width,
+                                                        config.height);
+                       glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
+                                                 GL_STENCIL_ATTACHMENT,
+                                                 GL_RENDERBUFFER, stencil_rb);
+               }

-               glBindRenderbuffer(GL_RENDERBUFFER, depth_rb);
-               glRenderbufferStorageMultisample(GL_RENDERBUFFER,
-                                                config.num_samples,
-                                                GL_DEPTH_COMPONENT24,
-                                                config.width, config.height);
-               glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
-                                         GL_DEPTH_ATTACHMENT,
-                                         GL_RENDERBUFFER, depth_rb);
+               if (config.depth_internalformat != GL_NONE) {
+                       glBindRenderbuffer(GL_RENDERBUFFER, depth_rb);
+                       glRenderbufferStorageMultisample(GL_RENDERBUFFER,
+                                                        config.num_samples,
+                                                        
config.depth_internalformat,
+                                                        config.width,
+                                                        config.height);
+                       glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
+                                                 GL_DEPTH_ATTACHMENT,
+                                                 GL_RENDERBUFFER, depth_rb);
+               }
        }

        bool success = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
diff --git a/tests/spec/ext_framebuffer_multisample/common.h 
b/tests/spec/ext_framebuffer_multisample/common.h
index d941e96..3caccaa 100644
--- a/tests/spec/ext_framebuffer_multisample/common.h
+++ b/tests/spec/ext_framebuffer_multisample/common.h
@@ -66,10 +66,27 @@ public:
        bool attach_texture;

        /**
-        * Internalformat that should be used for the color buffer.
-        * Defaults to GL_RGBA.
+        * Internalformat that should be used for the color buffer, or
+        * GL_NONE if no color buffer should be used.  Defaults to
+        * GL_RGBA.
         */
        GLenum color_internalformat;
+
+       /**
+        * Internalformat that should be used for the depth buffer, or
+        * GL_NONE if no depth buffer should be used.  Ignored if
+        * combine_depth_stencil is true.  Defaults to
+        * GL_DEPTH_COMPONENT24.
+        */
+       GLenum depth_internalformat;
+
+       /**
+        * Internalformat that should be used for the stencil buffer,
+        * or GL_NONE if no stencil buffer should be used.  Ignored if
+        * combine_depth_stencil is true.  Defaults to
+        * GL_STENCIL_INDEX8.
+        */
+       GLenum stencil_internalformat;
  };

  /**



_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to