diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-06-08 12:15:25 -0700 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2012-06-25 10:46:00 -0700 |
commit | 0079e1dd112a83d53a80f1e79b9bbc0a14b52cf5 (patch) | |
tree | 18b3d810ac864c55dca987c14d474914fa36990a | |
parent | 132c8a104ff7c03702b2c4d160d4a15cbceb9bfa (diff) |
msaa: Make it possible to scale and offset ColorGradientSunburst.
In order to test that MSAA works properly for integer framebuffers, we
will need to be able to adjust the outputs of the
ColorGradientSunburst program to cover the range of signed or unsigned
integers, rather than the range [0, 1] that is appropriate for testing
normalized color framebuffers.
This patch makes that possible by adding "scale" and "offset"
parameters to the ColorGradientSunburst program.
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r-- | tests/spec/ext_framebuffer_multisample/common.cpp | 47 | ||||
-rw-r--r-- | tests/spec/ext_framebuffer_multisample/common.h | 3 |
2 files changed, 48 insertions, 2 deletions
diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp index ff1ca7fee..e1060a862 100644 --- a/tests/spec/ext_framebuffer_multisample/common.cpp +++ b/tests/spec/ext_framebuffer_multisample/common.cpp @@ -1009,15 +1009,50 @@ ColorGradientSunburst::ColorGradientSunburst(GLenum out_type) } +/** + * Draw the color gradient sunburst, but instead of using color + * components that range from 0.0 to 1.0, apply the given scaling + * factor and offset to each color component. + * + * The offset is also applied when clearing the color buffer. + */ void -ColorGradientSunburst::draw(const float (*proj)[4]) +ColorGradientSunburst::draw_with_scale_and_offset(const float (*proj)[4], + float scale, float offset) { - glClear(GL_COLOR_BUFFER_BIT); + switch (out_type) { + case GL_INT: { + int clear_color[4] = { offset, offset, offset, offset }; + glClearBufferiv(GL_COLOR, 0, clear_color); + break; + } + case GL_UNSIGNED_INT: { + unsigned clear_color[4] = { offset, offset, offset, offset }; + glClearBufferuiv(GL_COLOR, 0, clear_color); + break; + } + case GL_UNSIGNED_NORMALIZED: + case GL_FLOAT: { + float clear_color[4] = { offset, offset, offset, offset }; + glClearBufferfv(GL_COLOR, 0, clear_color); + break; + } + default: + printf("Unrecognized out_type: %s\n", + piglit_get_gl_enum_name(out_type)); + piglit_report_result(PIGLIT_FAIL); + break; + } glUseProgram(prog); glUniformMatrix4fv(proj_loc, 1, GL_TRUE, &proj[0][0]); float draw_colors[3][4] = { { 1, 0, 0, 1.0 }, { 0, 1, 0, 0.5 }, { 0, 0, 1, 1.0 } }; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + draw_colors[i][j] = scale * draw_colors[i][j] + offset; + } + } glUniformMatrix3x4fv(draw_colors_loc, 1, GL_FALSE, &draw_colors[0][0]); glBindVertexArray(vao); @@ -1027,6 +1062,14 @@ ColorGradientSunburst::draw(const float (*proj)[4]) } } + +void +ColorGradientSunburst::draw(const float (*proj)[4]) +{ + draw_with_scale_and_offset(proj, 1.0, 0.0); +} + + void StencilSunburst::draw(const float (*proj)[4]) { diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h index b432f8617..e7cc9b76a 100644 --- a/tests/spec/ext_framebuffer_multisample/common.h +++ b/tests/spec/ext_framebuffer_multisample/common.h @@ -355,6 +355,9 @@ public: explicit ColorGradientSunburst(GLenum out_type); virtual void draw(const float (*proj)[4]); + + void draw_with_scale_and_offset(const float (*proj)[4], + float scale, float offset); }; /** |