summaryrefslogtreecommitdiff
path: root/tests/spec/ext_framebuffer_multisample/common.cpp
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2012-06-08 12:15:25 -0700
committerPaul Berry <stereotype441@gmail.com>2012-06-25 10:46:00 -0700
commit0079e1dd112a83d53a80f1e79b9bbc0a14b52cf5 (patch)
tree18b3d810ac864c55dca987c14d474914fa36990a /tests/spec/ext_framebuffer_multisample/common.cpp
parent132c8a104ff7c03702b2c4d160d4a15cbceb9bfa (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>
Diffstat (limited to 'tests/spec/ext_framebuffer_multisample/common.cpp')
-rw-r--r--tests/spec/ext_framebuffer_multisample/common.cpp47
1 files changed, 45 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])
{