On 22 May 2012 19:21, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">This patch adds following new classes to common.cpp file:<br>
- Points: Draws a sequence of points with varied sizes in<br>
color buffer.<br>
- Spiral: Draws points with varied sizes in spiral pattern.<br>
- StencilSpiral: Draws spiral pattern in stencil buffer.<br>
- DepthSpiral: Draws spiral pattern in depth buffer.<br>
- Lines: Draws a sequence of lines with varied width in<br>
color buffer<br>
- Star: Draws lines in a star like pattern.<br>
- StencilStar: Draws star pattern in stencil buffer.<br>
- DepthStar: Draws star pattern in depth buffer.<br>
<br>
All above mentioned classes are used to verify drawing multisample<br>
points and lines in color, depth and sencil buffers.<br>
<br>
</div>V2: Testing smooth lines and points on depth and stencil buffers<br>
seems redundant. So, trimmed down the patch to just add Points<br>
and Lines classes. Also made changes to draw points and lines<br>
with floating point sizes and sizes < 1.0.<br></blockquote><div><br>Looks reasonable. We should probably trim down the commit message so that it only mentions Points and Lines. With that changed, this patch is:<br>
<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
---<br>
</div> tests/spec/ext_framebuffer_multisample/common.cpp | 198 +++++++++++++++++++++<br>
tests/spec/ext_framebuffer_multisample/common.h | 43 +++++<br>
2 files changed, 241 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp<br>
index d1e6bcd..ac23683 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/common.cpp<br>
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp<br>
@@ -639,6 +639,204 @@ void Triangles::draw(float (*proj)[4])<br>
<div><div class="h5"> }<br>
}<br>
<br>
+void Lines::compile()<br>
+{<br>
+ /* Line coords within (-1,-1) to (1,1) rect */<br>
+ static const float pos_line[][2] = {<br>
+ { -0.8, -0.5 },<br>
+ { 0.8, -0.5 }<br>
+ };<br>
+<br>
+ /* Number of line instances across (and down) */<br>
+ int lines_across = 4;<br>
+<br>
+ /* Total number of lines drawn */<br>
+ num_lines = lines_across * lines_across;<br>
+<br>
+ /* Amount each line should be rotated compared to prev */<br>
+ float rotation_delta = M_PI * 2.0 / num_lines;<br>
+<br>
+ /* Scaling factor uniformly applied to line coords */<br>
+ float line_scale = 0.8 / lines_across;<br>
+<br>
+ /* Final scaling factor */<br>
+ float final_scale = 0.95;<br>
+<br>
+ static const char *vert =<br>
+ "#version 130\n"<br>
+ "in vec2 pos_line;\n"<br>
+ "uniform float line_scale;\n"<br>
+ "uniform float rotation_delta;\n"<br>
+ "uniform int lines_across;\n"<br>
+ "uniform float final_scale;\n"<br>
+ "uniform mat4 proj;\n"<br>
+ "uniform int line_num;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " vec2 pos = line_scale * pos_line;\n"<br>
+ " float rotation = rotation_delta * line_num;\n"<br>
+ " pos = mat2(cos(rotation), sin(rotation),\n"<br>
+ " -sin(rotation), cos(rotation)) * pos;\n"<br>
+ " int i = line_num % lines_across;\n"<br>
+ " int j = lines_across - 1 - line_num / lines_across;\n"<br>
+ " pos += (vec2(i, j) * 2.0 + 1.0) / lines_across - 1.0;\n"<br>
+ " pos *= final_scale;\n"<br>
+ " gl_Position = proj * vec4(pos, 0.0, 1.0);\n"<br>
+ "}\n";<br>
+<br>
+ static const char *frag =<br>
+ "#version 130\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_FragColor = vec4(1.0);\n"<br>
+ "}\n";<br>
+<br>
+ /* Compile program */<br>
+ prog = glCreateProgram();<br>
+ GLint vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert);<br>
+ glAttachShader(prog, vs);<br>
+ GLint fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag);<br>
+ glAttachShader(prog, fs);<br>
+ glBindAttribLocation(prog, 0, "pos_line");<br>
+ glLinkProgram(prog);<br>
+ if (!piglit_link_check_status(prog)) {<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+<br>
+ /* Set up uniforms */<br>
+ glUseProgram(prog);<br>
+ glUniform1f(glGetUniformLocation(prog, "line_scale"), line_scale);<br>
+ glUniform1f(glGetUniformLocation(prog, "rotation_delta"),<br>
+ rotation_delta);<br>
+ glUniform1i(glGetUniformLocation(prog, "lines_across"), lines_across);<br>
+ glUniform1f(glGetUniformLocation(prog, "final_scale"), final_scale);<br>
+ proj_loc = glGetUniformLocation(prog, "proj");<br>
+ line_num_loc = glGetUniformLocation(prog, "line_num");<br>
+<br>
+ /* Set up vertex array object */<br>
+ glGenVertexArrays(1, &vao);<br>
+ glBindVertexArray(vao);<br>
+<br>
+ /* Set up vertex input buffer */<br>
+ glGenBuffers(1, &vertex_buf);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, vertex_buf);<br>
+ glBufferData(GL_ARRAY_BUFFER, sizeof(pos_line), pos_line,<br>
+ GL_STATIC_DRAW);<br>
+ glEnableVertexAttribArray(0);<br>
+ glVertexAttribPointer(0, ARRAY_SIZE(pos_line[0]), GL_FLOAT,<br>
+ GL_FALSE, sizeof(pos_line[0]), (void *) 0);<br>
+}<br>
+<br>
+void Lines::draw(float (*proj)[4])<br>
+{<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+ glUseProgram(prog);<br>
+ glUniformMatrix4fv(proj_loc, 1, GL_TRUE, &proj[0][0]);<br>
+ glBindVertexArray(vao);<br>
+ for (int line_num = 0; line_num < num_lines; ++line_num) {<br>
</div></div>+ /* Draws with line width = 0.25, 0.75, 1.25,<br>
+ * 1.75, 2.25, 2.75, 3.25, 3.75<br>
+ */<br>
+ glLineWidth((1 + 2 * line_num) / 4.0);<br>
<div><div class="h5">+ glUniform1i(line_num_loc, line_num);<br>
+ glDrawArrays(GL_LINES, 0, 2);<br>
+ }<br>
+}<br>
+<br>
+void Points::compile()<br>
+{<br>
+ /* Point coords within (-1,-1) to (1,1) rect */<br>
+ static const float pos_point[2] = { -0.5, -0.5 };<br>
+<br>
+ /* Number of point instances across (and down) */<br>
+ int points_across = 4;<br>
+<br>
+ /* Total number of points drawn */<br>
+ num_points = points_across * points_across;<br>
+<br>
+ /* Scaling factor uniformly applied to point coords */<br>
+ float point_scale = 0.8 / points_across;<br>
+<br>
+ /* Final scaling factor */<br>
+ float final_scale = 0.95;<br>
+<br>
+ static const char *vert =<br>
+ "#version 130\n"<br>
+ "in vec2 pos_point;\n"<br>
+ "uniform float point_scale;\n"<br>
+ "uniform int points_across;\n"<br>
+ "uniform float final_scale;\n"<br>
+ "uniform mat4 proj;\n"<br>
+ "uniform int point_num;\n"<br>
+ "uniform float depth;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " vec2 pos = point_scale * pos_point;\n"<br>
+ " int i = point_num % points_across;\n"<br>
+ " int j = points_across - 1 - point_num / points_across;\n"<br>
+ " pos += (vec2(i, j) * 2.0 + 1.0) / points_across - 1.0;\n"<br>
+ " pos *= final_scale;\n"<br>
+ " gl_Position = proj * vec4(pos, depth, 1.0);\n"<br>
+ "}\n";<br>
+<br>
+ static const char *frag =<br>
+ "#version 130\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_FragColor = vec4(1.0);\n"<br>
+ "}\n";<br>
+<br>
+ /* Compile program */<br>
+ prog = glCreateProgram();<br>
+ GLint vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert);<br>
+ glAttachShader(prog, vs);<br>
+ GLint fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag);<br>
+ glAttachShader(prog, fs);<br>
+ glBindAttribLocation(prog, 0, "pos_point");<br>
+ glLinkProgram(prog);<br>
+ if (!piglit_link_check_status(prog)) {<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+<br>
+ /* Set up uniforms */<br>
+ glUseProgram(prog);<br>
+ glUniform1f(glGetUniformLocation(prog, "point_scale"), point_scale);<br>
+ glUniform1i(glGetUniformLocation(prog, "points_across"), points_across);<br>
+ glUniform1f(glGetUniformLocation(prog, "final_scale"), final_scale);<br>
+ proj_loc = glGetUniformLocation(prog, "proj");<br>
+ point_num_loc = glGetUniformLocation(prog, "point_num");<br>
+ depth_loc = glGetUniformLocation(prog, "depth");<br>
+<br>
+ /* Set up vertex array object */<br>
+ glGenVertexArrays(1, &vao);<br>
+ glBindVertexArray(vao);<br>
+<br>
+ /* Set up vertex input buffer */<br>
+ glGenBuffers(1, &vertex_buf);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, vertex_buf);<br>
+ glBufferData(GL_ARRAY_BUFFER, sizeof(pos_point), pos_point,<br>
+ GL_STATIC_DRAW);<br>
+ glEnableVertexAttribArray(0);<br>
+ glVertexAttribPointer(0, ARRAY_SIZE(pos_point), GL_FLOAT,<br>
+ GL_FALSE, 0, (void *) 0);<br>
+}<br>
+<br>
+void Points::draw(float (*proj)[4])<br>
+{<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+ glUseProgram(prog);<br>
+ glUniformMatrix4fv(proj_loc, 1, GL_TRUE, &proj[0][0]);<br>
+ glBindVertexArray(vao);<br>
+ glUniform1f(depth_loc, 0.0);<br>
+ for (int point_num = 0; point_num < num_points; ++point_num) {<br>
</div></div>+ glPointSize((1.0 + 4 * point_num) / 4.0);<br>
<div class="im">+ glUniform1i(point_num_loc, point_num);<br>
+ glDrawArrays(GL_POINTS, 0, 1);<br>
+ }<br>
+}<br>
+<br>
</div><div class="im"> void Sunburst::compile()<br>
{<br>
/* Triangle coords within (-1,-1) to (1,1) rect */<br>
diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h<br>
</div>index d86cb95..2ea3b42 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/common.h<br>
+++ b/tests/spec/ext_framebuffer_multisample/common.h<br>
@@ -187,6 +187,49 @@ private:<br>
<div class="im HOEnZb"> };<br>
<br>
/**<br>
+ * Program we use to draw a test pattern into the color buffer.<br>
+ *<br>
+ * This program draws a sequence of points with varied sizes. This ensures<br>
+ * antialiasing works well with all point sizes.<br>
+ */<br>
+class Points : public TestPattern<br>
+{<br>
+public:<br>
+ virtual void compile();<br>
+ virtual void draw(float (*proj)[4]);<br>
+<br>
+private:<br>
+ GLint prog;<br>
+ GLuint vao;<br>
+ GLint proj_loc;<br>
+ GLint depth_loc;<br>
+ GLint point_num_loc;<br>
+ GLuint vertex_buf;<br>
+ int num_points;<br>
+};<br>
+<br>
+/**<br>
</div><div class="im HOEnZb">+ * Program we use to draw a test pattern into the color buffer.<br>
+ *<br>
+ * This program draws a sequence of lines with varied width. This ensures<br>
+ * antialiasing works well with all line widths.<br>
+ */<br>
+class Lines : public TestPattern<br>
+{<br>
+public:<br>
+ virtual void compile();<br>
+ virtual void draw(float (*proj)[4]);<br>
+<br>
+private:<br>
+ GLint prog;<br>
+ GLuint vao;<br>
+ GLint proj_loc;<br>
+ GLint line_num_loc;<br>
+ GLuint vertex_buf;<br>
+ int num_lines;<br>
+};<br>
+<br>
+/**<br>
</div><div class="HOEnZb"><div class="h5"> * Program we use to draw a test pattern into the depth and stencil<br>
* buffers.<br>
*<br>
--<br>
1.7.7.6<br>
<br>
</div></div></blockquote></div><br>