diff options
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/spec/ext_framebuffer_multisample/formats.cpp | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 27a59c97c..9ea22d73d 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1635,6 +1635,7 @@ add_texwrap_test2(ext_texture_shared_exponent, '2D', 'GL_RGB9_E5') ext_texture_snorm = Group() spec['EXT_texture_snorm'] = ext_texture_snorm add_fbo_formats_tests('spec/EXT_texture_snorm', 'GL_EXT_texture_snorm') +add_msaa_formats_tests(ext_texture_snorm, 'GL_EXT_texture_snorm') add_texwrap_test2(ext_texture_snorm, '2D', 'GL_R8_SNORM') add_texwrap_test2(ext_texture_snorm, '2D', 'GL_RG8_SNORM') add_texwrap_test2(ext_texture_snorm, '2D', 'GL_RGB8_SNORM') diff --git a/tests/spec/ext_framebuffer_multisample/formats.cpp b/tests/spec/ext_framebuffer_multisample/formats.cpp index 1d11024b6..960814d7f 100644 --- a/tests/spec/ext_framebuffer_multisample/formats.cpp +++ b/tests/spec/ext_framebuffer_multisample/formats.cpp @@ -73,6 +73,7 @@ class PatternRenderer public: bool try_setup(GLenum internalformat); void set_piglit_tolerance(); + void set_color_clamping_mode(); void draw(); float *read_image(GLenum base_format); @@ -110,6 +111,15 @@ public: */ float color_scale; + /** + * Color clamping setting that should be used for this test. + * Normally GL_FIXED_ONLY (the default setting) works fine, + * however the GL spec mandates that signed normalized formats + * be clamped to [0, 1] when in GL_FIXED_ONLY mode. So when + * testing signed normalized formats, this is GL_FALSE. + */ + GLenum color_clamping_mode; + Fbo fbo_msaa; Fbo fbo_downsampled; }; @@ -151,6 +161,7 @@ PatternRenderer::try_setup(GLenum internalformat) GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, (GLint *) &component_type); + color_clamping_mode = GL_FIXED_ONLY; switch (component_type) { case GL_INT: test_pattern = test_pattern_ivec4; @@ -184,6 +195,12 @@ PatternRenderer::try_setup(GLenum internalformat) color_scale = 20.0; } break; + case GL_SIGNED_NORMALIZED: + test_pattern = test_pattern_vec4; + color_offset = -1.0; + color_scale = 2.0; + color_clamping_mode = GL_FALSE; + break; default: printf("Unrecognized component type: %s\n", piglit_get_gl_enum_name(component_type)); @@ -260,6 +277,17 @@ void PatternRenderer::set_piglit_tolerance() /** + * Set up the appropriate color clamping mode for testing this format. + */ +void +PatternRenderer::set_color_clamping_mode() +{ + glClampColor(GL_CLAMP_FRAGMENT_COLOR, color_clamping_mode); + glClampColor(GL_CLAMP_READ_COLOR, color_clamping_mode); +} + + +/** * Draw the test pattern into the MSAA framebuffer, and then blit it * to the downsampled FBO to force an MSAA resolve. */ @@ -269,6 +297,7 @@ PatternRenderer::draw() /* Draw into the MSAA fbo */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_msaa.handle); fbo_msaa.set_viewport(); + set_color_clamping_mode(); test_pattern->draw_with_scale_and_offset(TestPattern::no_projection, color_scale, color_offset); @@ -323,6 +352,7 @@ PatternRenderer::read_image(GLenum base_format) unsigned array_size = components*pattern_width*pattern_height; float *image = (float *) malloc(sizeof(float)*array_size); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_downsampled.handle); + set_color_clamping_mode(); if (base_format == GL_INTENSITY) { /* GL_INTENSITY is not allowed for ReadPixels so * substitute GL_LUMINANCE. |