diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-07-12 17:02:32 -0700 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2012-07-17 12:49:14 -0700 |
commit | c23eb2cb51196ab137e043ae21c7b817844255bf (patch) | |
tree | 68846b14de2626d74c9d24a9dae4e606ea9a6216 | |
parent | 79fefb56133e012a9567e6698918364be721f27d (diff) |
msaa: Add the ability to run msaa tests without color/depth/stencil buffers.
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.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r-- | tests/spec/ext_framebuffer_multisample/common.cpp | 104 | ||||
-rw-r--r-- | 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 e1f6127fc..12c9c8221 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 d941e96c6..3caccaaba 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; }; /** |