<div dir="ltr">On 22 August 2013 11:38, Steve Miller <span dir="ltr"><<a href="mailto:dervishx@gmail.com" target="_blank">dervishx@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><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">add new test to existing arb_seamless_cube_map group: sample three adjoining<br>
     faces and use average. if three faces are the same color, that color must<br>
     be used.<br>
add test to makelists and all.tests<br>
<br>
</div>V2 : test now uses contemporary pipeline<br>
<div class="im">---<br>
 tests/all.tests                                    |   1 +<br>
 tests/spec/arb_seamless_cube_map/CMakeLists.gl.txt |   1 +<br>
</div> .../arb_seamless_cube_map/three-faces-average.c    | 211 +++++++++++++++++++++<br>
 3 files changed, 213 insertions(+)<br>
<div class="im"> create mode 100644 tests/spec/arb_seamless_cube_map/three-faces-average.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
</div>index 6bf9f37..f6f8a50 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -2269,6 +2269,7 @@ arb_seamless_cube_map = Group()<br>
<div class="im"> spec['ARB_seamless_cube_map'] = arb_seamless_cube_map<br>
 add_plain_test(arb_seamless_cube_map, 'arb_seamless_cubemap')<br>
 add_plain_test(arb_seamless_cube_map, 'arb_seamless_cubemap-initially-disabled')<br>
+add_plain_test(arb_seamless_cube_map, 'arb_seamless_cubemap-three-faces-average')<br>
<br>
 amd_seamless_cubemap_per_texture = Group()<br>
 spec['AMD_seamless_cubemap_per_texture'] = amd_seamless_cubemap_per_texture<br>
diff --git a/tests/spec/arb_seamless_cube_map/CMakeLists.gl.txt b/tests/spec/arb_seamless_cube_map/CMakeLists.gl.txt<br>
index eac572a..e31759a 100644<br>
--- a/tests/spec/arb_seamless_cube_map/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_seamless_cube_map/CMakeLists.gl.txt<br>
@@ -11,5 +11,6 @@ link_libraries (<br>
<br>
 piglit_add_executable (arb_seamless_cubemap arb_seamless_cubemap.c)<br>
 piglit_add_executable (arb_seamless_cubemap-initially-disabled initially-disabled.c)<br>
+piglit_add_executable (arb_seamless_cubemap-three-faces-average three-faces-average.c)<br>
<br>
 # vim: ft=cmake:<br>
diff --git a/tests/spec/arb_seamless_cube_map/three-faces-average.c b/tests/spec/arb_seamless_cube_map/three-faces-average.c<br>
new file mode 100644<br>
</div>index 0000000..3d5f5c5<br>
--- /dev/null<br>
+++ b/tests/spec/arb_seamless_cube_map/three-faces-average.c<br>
@@ -0,0 +1,211 @@<br>
+/*<br>
+ * Copyright © 2013 Intel Corporation<br>
<div class="im">+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included<br>
+ * in all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN<br>
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br>
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
</div>+ * Test verifies that when sampling from three adjoining faces in a cube map,<br>
+ * samples will be averaged. If they share the same value, that value must be<br>
<div class="im">+ * guaranteed to be the result of the average. Resulting color should not<br>
</div>+ * include border color contamination.<br>
<div class="im">+ */<br>
+<br>
+/*<br>
+ * ARB_seamless_cube_map Section 3.8.7 says:<br>
+ *     "If LINEAR filtering is done within a miplevel, always apply wrap mode<br>
+ *     CLAMP_TO_BORDER. Then, ...<br>
+ *<br>
+ *     If a texture sample location would lie in the texture border in<br>
+ *     both u and v (in one of the corners of the cube), there is no<br>
+ *     unique neighboring face from which to extract one texel. The<br>
+ *     recommended method is to average the values of the three<br>
+ *     available samples. However, implementations are free to<br>
+ *     construct this fourth texel in another way, so long as, when the<br>
+ *     three available samples have the same value, this texel also has<br>
+ *     that value."<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_version = 10;<br>
</div>+       config.supports_gl_core_version = 31;<br>
<div class="im">+<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
</div>+const char *vs_text =<br>
+{<br>
+       "#version 130\n"<br>
+       "\n"<br>
+       "in vec2 vertex;\n"<br>
+       "\n"<br>
+       "void main() {\n"<br>
+       "       gl_Position = vec4( vertex.xy, 0, 1);\n"<br>
+       "}\n"<br></blockquote><div><br></div><div>You can make vertex a vec4 and then just do "gl_Position = vertex;".  OpenGL will automatically fill in z=0 and w=1 for you on the vertex input, since you specify size=2 in the call to glVertexAttribPointer.<br>
 <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+};<br>
+<br>
+const char *fs_text =<br>
+{<br>
+       "#version 130\n"<br>
+       "\n"<br>
+       "uniform samplerCube cubeTex;\n"<br>
+       "uniform vec3 cubeVec;\n"<br>
+       "\n"<br>
+       "void main() {\n"<br>
+       "       gl_FragColor = texture( cubeTex, cubeVec );\n"<br></blockquote><div><br></div><div>Style nit pick (both here and in the rest of the test): generally in Piglit we don't put spaces between the parens and the first/last argument, so this should be:<br>
<br></div><div>gl_FragColor = texture(cubeTex, cubeVec);<br><br></div><div>I realize that not all Piglit code follows that standard, so I can understand if you were cribbing from code that formatted things differently.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       "}\n"<br>
+};<br>
<div class="im">+<br>
+static const float red[3] = { 1., 0., 0. };<br>
+static const float blue[3] = { 0., 0., 1. };<br>
</div>+static const float green[3] = { 0., 1.0, 0. };<br>
+<br>
+static GLuint prog;<br>
+static GLuint vao;<br>
+static GLuint vbo;<br>
+static GLuint cubeMap;<br>
+<br>
+static GLint cubeVec_loc;<br>
+static GLfloat cubeVecPositive[3] = { 0.5, 0.5, 0.5 };<br>
+static GLfloat cubeVecNegative[3] = { -0.5, -0.5, -0.5 };<br>
<div class="im">+<br>
+static const GLenum targets[6] = {<br>
+   GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,<br>
+   GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,<br>
+   GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,<br>
+   GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,<br>
+   GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,<br>
+   GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB<br>
+};<br>
+<br>
</div>+static GLfloat quad_01[4][2] =<br>
+{<br>
+       { -1., -1. },<br>
+       { -1.,  0. },<br>
+       {  0.,  0. },<br>
+       {  0., -1. }<br>
+};<br>
+<br>
+static GLfloat quad_02[4][2] =<br>
+{<br>
+       { 0., 0. },<br>
+       { 0., 1. },<br>
+       { 1., 1. },<br>
+       { 1., 0. }<br>
+};<br>
<div class="im">+<br>
+void piglit_init( int argc, char **argv)<br>
+{<br>
+       GLint i;<br>
</div>+       GLuint vertex_index;<br>
+<br>+       if( piglit_get_gl_version() < 32 ) {<br>
<div class="im">+               piglit_require_extension("GL_ARB_seamless_cube_map");<br>
+       }<br>
+<br>
</div>+       /* create program */<br>
+       prog = piglit_build_simple_program( vs_text, fs_text );<br>
+       glUseProgram( prog );<br>
+<br>
+       /* create buffers */<br>
+       glGenBuffers( 1, &vbo );<br>
+       glBindBuffer( GL_ARRAY_BUFFER, vbo );<br>
+       glBufferData( GL_ARRAY_BUFFER, sizeof( quad_01 ) + sizeof( quad_02 ),<br>
+                     NULL, GL_STATIC_DRAW );<br>
+       glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof( quad_01 ),<br>
+                        &quad_01 );<br>
+       glBufferSubData( GL_ARRAY_BUFFER, sizeof( quad_01 ), sizeof( quad_02 ),<br>
+                        &quad_02 );<br>
+<br>
+       glGenVertexArrays( 1, &vao );<br>
+       glBindVertexArray( vao );<br>
+<br>
+       vertex_index = glGetAttribLocation( prog, "vertex" );<br>
+<br>
+       /* vertex attribs */<br>
+       glEnableVertexAttribArray( vertex_index );<br>
+<br>
+       glVertexAttribPointer( vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0 );<br>
+<br>
+       glGenTextures( 1, &cubeMap );<br>
+       glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, cubeMap );<br>
+<br>
+       /* set filter to linear, hardware should behave as if wrap modes are<br>
+        * set to CLAMP_TO_BORDER<br>
<div class="im">+        */<br>
+       glTexParameterfv( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_BORDER_COLOR,<br>
</div>+                         green );<br>
<div class="im">+       glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER,<br>
+                        GL_LINEAR );<br>
+       glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER,<br>
+                        GL_LINEAR );<br>
+<br>
+       /* texture positive axes/faces red */<br>
+       for( i = 0; i < 3; i++ ) {<br>
</div>+               glTexImage2D( targets[i], 0, GL_RGBA8, 1, 1, 0, GL_RGB,<br>
+                             GL_FLOAT, red );<br>
<div class="im">+       }<br>
+<br>
+       /* texuture negative axes/faces blue */<br>
+       for( i = 3; i < 6; i++ ) {<br>
</div>+               glTexImage2D( targets[i], 0, GL_RGBA8, 1, 1, 0, GL_RGB,<br>
+                             GL_FLOAT, blue );<br>
+       }<br>
+<br>
+       /* uniform texcoord input */<br>
+       cubeVec_loc = glGetUniformLocation( prog, "cubeVec" );<br>
<div class="im">+<br>
+       glClearColor( 0.0, 0.0, 0.0, 0.0 );<br></div></blockquote><div><br></div><div>Technically this call isn't needed, since this is the default clear color.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
+<br>
</div>+       if( !piglit_check_gl_error( GL_NO_ERROR ) )<br>
+               piglit_report_result( PIGLIT_FAIL );<br>
<div class="im">+<br>
+}<br>
+<br>
+enum piglit_result piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       glClear( GL_COLOR_BUFFER_BIT );<br>
+<br>
+               glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS );<br></div></blockquote><div><br></div><div>Spurious extra indentation.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
+<br>
+       /* texcoords should target vector to upper corner */<br>
</div>+       glUniform3fv( cubeVec_loc, 1, cubeVecPositive );<br>
+       glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );<br>
<div class="im">+<br>
+       /* expect red */<br>
</div>+       pass = piglit_probe_rect_rgb( 0, 0, 75, 75, red ) && pass;<br>
<div class="im">+<br>
+       /* texcoords should target vector to bottom corner */<br>
</div>+       glUniform3fv( cubeVec_loc, 1, cubeVecNegative );<br>
+       glDrawArrays( GL_TRIANGLE_FAN, 4, 4 );<br>
<div class="im">+<br>
+       /* expect blue */<br>
</div>+       pass = piglit_probe_rect_rgb( 75, 75, 75,75, blue ) && pass;<br>
<div class="HOEnZb"><div class="h5">+<br>
+       glDisable( GL_TEXTURE_CUBE_MAP_SEAMLESS );<br></div></div></blockquote><div><br></div><div>This call isn't necessary--we don't need to un-do GL state at the end of a piglit test.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
+<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
--<br>
1.8.3.1<br></div></div></blockquote><div><br></div><div>All of my comments are minor, so with or without the changes, this patch is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div></div></div></div>