<div dir="ltr">On 5 January 2013 01:07, Chris Forbes <span dir="ltr"><<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
This tests FBO setup with various combinations of multisample textures<br>
and `classic` multisample renderbuffers, and for each, checks:<br>
<br>
- That the renderbuffers or textures can be created<br>
- Completeness status<br>
<br>
If the configuration is expected to work, additionally:<br>
- Actual sample count >= requested sample count<br>
- Sample positions meet spec requirements (all obtainable, and in [0,1]<br>
<br>
Covers the fixedsamplelocations and sample count consistency<br>
requirements in the spec.<br>
<br>
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>><br></blockquote><div><br></div><div>I'm not really comfortable with the fact that this test only covers 4x MSAA. We need to test a variety of sample counts since the sample positions are going to be different for different sample counts. I would recommend modeling this on the tests in ext_framebuffer_multisample--these tests take a sample count as an argment, and skip if the requested sample count is larger than the implementation's value of GL_MAX_SAMPLES. In all.tests, we generate an instance of each of these tests for all power-of-two sample counts from 2 to 32. (Note: Marek's patch "all.tests: test 6x MSAA" also adds the non-power of two sample count of 6).<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
tests/all.tests | 1 +<br>
.../spec/arb_texture_multisample/CMakeLists.gl.txt | 1 +<br>
.../spec/arb_texture_multisample/fb-completeness.c | 242 +++++++++++++++++++++<br>
3 files changed, 244 insertions(+)<br>
create mode 100644 tests/spec/arb_texture_multisample/fb-completeness.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index acaf1ad..379964f 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -844,6 +844,7 @@ add_plain_test(arb_point_sprite, 'point-sprite')<br>
arb_texture_multisample = Group()<br>
spec['ARB_texture_multisample'] = arb_texture_multisample<br>
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-minmax')<br>
+add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-fb-completeness')<br>
<br>
# Group AMD_shader_stencil_export<br>
spec['AMD_shader_stencil_export'] = Group()<br>
diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt<br>
index 90dae9e..d793256 100644<br>
--- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt<br>
@@ -11,5 +11,6 @@ link_libraries (<br>
)<br>
<br>
piglit_add_executable (arb_texture_multisample-minmax minmax.c)<br>
+piglit_add_executable (arb_texture_multisample-fb-completeness fb-completeness.c)<br>
<br>
# vim: ft=cmake:<br>
diff --git a/tests/spec/arb_texture_multisample/fb-completeness.c b/tests/spec/arb_texture_multisample/fb-completeness.c<br>
new file mode 100644<br>
index 0000000..44f9786<br>
--- /dev/null<br>
+++ b/tests/spec/arb_texture_multisample/fb-completeness.c<br>
@@ -0,0 +1,242 @@<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 30;<br>
+<br>
+ config.window_width = 10;<br>
+ config.window_height = 10;<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ return PIGLIT_FAIL;<br>
+}<br>
+<br>
+struct attachment_info<br>
+{<br>
+ GLenum target;<br>
+ GLenum attachment;<br>
+ int samples;<br>
+ int width;<br>
+ int height;<br></blockquote><div><br></div><div>It looks liike width and height are 64 in all test variants. I would recommend putting them in a single place rather than in every single attachment_info struct.<br></div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ bool fixedsamplelocations;<br>
+ GLuint format;<br></blockquote><div><br></div><div>It would be nice to have a comment here explaining that if format is 0, it will be automatically chosen based on attachment. That was a stumbling block for me in understanding this code.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+};<br>
+<br>
+struct test_info<br>
+{<br>
+ char const *name;<br>
+ int expected;<br>
+ struct attachment_info attachments[4];<br>
+};<br>
+<br>
+struct test_info tests[] = {<br>
+ { "single_msaa_color", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_mrt_color", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_mixed_texture_and_renderbuffer", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "mixed_msaa_and_plain", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT1, 0, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_mrt_color_nofixed", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_FALSE },<br>
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_FALSE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "mix_fixedmode", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_FALSE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "mix_fixedmode_with_renderbuffer", GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_FALSE },<br>
+ { GL_RENDERBUFFER, GL_COLOR_ATTACHMENT1, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_depth", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_DEPTH_ATTACHMENT, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_depth_stencil", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_DEPTH_ATTACHMENT, 4, 64, 64, GL_TRUE,<br>
+ GL_DEPTH_STENCIL<br>
+ },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_classic_stencil", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_RENDERBUFFER, GL_STENCIL_ATTACHMENT, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { "msaa_stencil", GL_FRAMEBUFFER_COMPLETE,<br>
+ { { GL_TEXTURE_2D_MULTISAMPLE, GL_COLOR_ATTACHMENT0, 4, 64, 64, GL_TRUE },<br>
+ { GL_TEXTURE_2D_MULTISAMPLE, GL_STENCIL_ATTACHMENT, 4, 64, 64, GL_TRUE },<br>
+ { 0 },<br>
+ }<br>
+ },<br>
+ { 0 },<br>
+};<br></blockquote><div><br></div><div>Our preferred way of handling situations like this, where a test has multiple variants, is to select the variant using a command line argument, and then have all.tests invoke the test separately using each possible variant. That way, the piglit framework can track failures at the granularity of the variants, rather than just considering the entire test to pass or fail. See for example b/tests/spec/ext_transform_feedback/change-size.c.<br>
<br></div><div>I'm not comfortable with the fact that this test only tests a sample count of 4 (and occasionally 0). At least one piece of hardware I know of (Ivy Bridge)<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+static GLuint<br>
+choose_format(struct attachment_info *att)<br>
+{<br>
+ if (att->format)<br>
+ return att->format;<br>
+<br>
+ switch(att->attachment) {<br>
+ case GL_DEPTH_ATTACHMENT:<br>
+ return GL_DEPTH_COMPONENT;<br>
+ case GL_STENCIL_ATTACHMENT:<br>
+ return GL_STENCIL_INDEX;<br>
+ default:<br>
+ return GL_RGBA;<br>
+ }<br>
+}<br>
+<br>
+static enum piglit_result<br>
+check_sample_positions(int expected_sample_count)<br>
+{<br>
+ GLint samples;<br>
+ int i;<br>
+<br>
+ glGetIntegerv(GL_SAMPLES, &samples);<br>
+ if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+ return PIGLIT_FAIL;<br>
+<br>
+ if (samples < expected_sample_count) {<br>
+ printf("Expected sample count at least %d, got %d\n",<br>
+ expected_sample_count, samples);<br>
+ return PIGLIT_FAIL;<br>
+ }<br>
+<br>
+ for (i = 0; i < samples; i++) {<br>
+ float sample_pos[2];<br>
+<br>
+ glGetMultisamplefv(GL_SAMPLE_POSITION, i, sample_pos);<br>
+<br>
+ if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+ return PIGLIT_FAIL;<br>
+<br>
+ printf("Sample %d position %2.2f %2.2f\n",<br>
+ i, sample_pos[0], sample_pos[1] );<br>
+<br>
+ if (sample_pos[0] < 0 || sample_pos[0] > 1 ||<br>
+ sample_pos[1] < 0 || sample_pos[1] > 1) {<br>
+ printf("Sample %d out of range\n", i );<br>
+ return PIGLIT_FAIL;<br>
+ }<br>
+ }<br>
+<br>
+ return PIGLIT_PASS;<br>
+}<br>
+<br>
+static enum piglit_result<br>
+exec_test(struct test_info *info)<br>
+{<br>
+ GLuint fb, tex, rb;<br>
+ GLint result;<br>
+ struct attachment_info *att;<br>
+<br>
+ glGenFramebuffers(1, &fb);<br>
+ glBindFramebuffer(GL_FRAMEBUFFER, fb);<br>
+<br>
+ printf("Testing fbo completeness for config '%s'\n", info->name);<br>
+<br>
+ for (att=info->attachments; att->target; att++) {<br>
+ printf(" Att target=%x att=%x samples=%d dims=%d,%d fixed=%d\n",<br>
+ att->target, att->attachment, att->samples,<br>
+ att->width, att->height, att->fixedsamplelocations);<br>
+<br>
+ switch (att->target) {<br>
+ case GL_TEXTURE_2D_MULTISAMPLE:<br>
+ glGenTextures(1, &tex);<br>
+ glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);<br>
+ glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,<br>
+ att->samples, choose_format(att),<br>
+ att->width, att->height,<br>
+ att->fixedsamplelocations);<br>
+<br>
+ if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+ return PIGLIT_FAIL;<br>
+<br>
+ glFramebufferTexture2D(GL_FRAMEBUFFER, att->attachment,<br>
+ att->target, tex, 0);<br>
+ break;<br>
+<br>
+ case GL_RENDERBUFFER:<br>
+ /* RENDERBUFFER has fixedsamplelocations implicitly */<br>
+ assert(att->fixedsamplelocations);<br>
+ glGenRenderbuffers(1, &rb);<br>
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);<br>
+ if (att->samples == 0) {<br>
+ /* non-MSAA renderbuffer */<br>
+ glRenderbufferStorage(GL_RENDERBUFFER, choose_format(att),<br>
+ att->width, att->height);<br>
+ }<br>
+ else {<br>
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER,<br>
+ att->samples, choose_format(att),<br>
+ att->width, att->height);<br>
+ }<br>
+<br>
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER,<br>
+ att->attachment, att->target, rb);<br>
+<br>
+ if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+ return PIGLIT_FAIL;<br>
+ break;<br>
+<br>
+ default:<br>
+ assert(!"Unsupported target");<br>
+ }<br>
+ }<br>
+<br>
+ result = glCheckFramebufferStatus(GL_FRAMEBUFFER);<br>
+ printf("glCheckFramebufferStatus: expected %d, got %d\n",<br>
+ info->expected, result);<br>
+ if (result != info->expected)<br>
+ return PIGLIT_FAIL;<br>
+<br>
+ if (result == GL_FRAMEBUFFER_COMPLETE)<br>
+ return check_sample_positions(info->attachments->samples);<br>
+<br>
+ return PIGLIT_PASS;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ struct test_info *info;<br>
+ enum piglit_result result = PIGLIT_PASS;<br>
+<br>
+ for (info = tests; info->name; info++)<br>
+ piglit_merge_result(&result, exec_test(info));<br>
+<br>
+ piglit_report_result(result);<br>
+}<br>
<span><font color="#888888">--<br>
1.8.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>