Re: [Piglit] [PATCH 9/9 v2] ARB_viewport_array: Rendering test with multiple scissor rectangles/enables
Typos below. On 11/04/2013 08:15 AM, Jon Ashburn wrote: Tests rendering into a single framebuffer surface with multiple viewports via a geometry shader. Scissoring is used to restrict quads to a smaller area on the surface. Confirm that each area of the surface delineated by a scissor rectangle for viewport index renders the correct color. Both indexed scissor tests and indexed scissor enables are used. Geometry shader is used to expand a single rectangle primitve to N rectangles. Tested on Nvidia Quadro 600, test passes. Signed-off-by: Jon Ashburn --- tests/all.tests | 1 + tests/spec/arb_viewport_array/CMakeLists.gl.txt | 1 + tests/spec/arb_viewport_array/render_scissor.c | 249 3 files changed, 251 insertions(+) create mode 100644 tests/spec/arb_viewport_array/render_scissor.c diff --git a/tests/all.tests b/tests/all.tests index f20a58b..928bf33 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1750,6 +1750,7 @@ arb_viewport_array['queries'] = concurrent_test('arb_viewport_array-queries') arb_viewport_array['minmax'] = concurrent_test('arb_viewport_array-minmax') arb_viewport_array['render-viewport'] = concurrent_test('arb_viewport_array-render-viewport') arb_viewport_array['render-depthrange'] = concurrent_test('arb_viewport_array-render-depthrange') +arb_viewport_array['render-scissor'] = concurrent_test('arb_viewport_array-render-scissor') nv_vertex_program = Group() spec['NV_vertex_program'] = nv_vertex_program diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt index 418c1d1..3c217ad 100644 --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt @@ -17,5 +17,6 @@ piglit_add_executable(arb_viewport_array-queries queries.c) piglit_add_executable(arb_viewport_array-minmax minmax.c) piglit_add_executable(arb_viewport_array-render-viewport render_viewport.c) piglit_add_executable(arb_viewport_array-render-depthrange render_depthrange.c) +piglit_add_executable(arb_viewport_array-render-scissor render_scissor.c) # vim: ft=cmake: diff --git a/tests/spec/arb_viewport_array/render_scissor.c b/tests/spec/arb_viewport_array/render_scissor.c new file mode 100644 index 000..0f7e373 --- /dev/null +++ b/tests/spec/arb_viewport_array/render_scissor.c @@ -0,0 +1,249 @@ +/* + * Copyright © 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Author: Jon Ashburn + */ + +/** + * Tests rendering into a single framebuffer surface with multiple viewports + * via a geometry shader. Scissoring is used to restrict quads to a smaller + * area on the surface. Confirm that each area of the surface delineated by + * a scissor rectangle for viewport index renders the correct color. Both + * indexed scissor tests and indexed scissor enables are used. Geometry + * shader is used to expand a single rectangle to N rectangles. + * OpenGL 4.3 Core Profile spec section 13.7.2 covers this test: + *"The scissor test determines if (xw , yw ) lies within the scissor + *rectangle defined by four values for each viewport." + *"If left ≤ xw < left + width and bottom ≤ yw < bottom + height for the + *selected scissor rectangle, then the scissor test passes. Otherwise, the + *test fails and the fragment is discarded. For points, lines, and + *polygons, the scissor rectangle for a primitive is selected in the same + *manner as the viewport (see section 13.6.1)." + */ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/* number of viewport/scissor rectangle divisons in x and y */ +static con
Re: [Piglit] [PATCH 4/4] ARB_viewport_array: Test validity of bounds for viewport, depthRange, scissor
Minor formatting nits at the end. On 11/01/2013 04:51 PM, Jon Ashburn wrote: Tests for the validity of Viewport bounds, Depth Range bounds and Scissor Box bounds with viewport arrays (0 to GL_MAX_VIEWPORTS-1). "Bounds" refer to the bounding rectangle or range (eg x, y, width, height). Tested with Nvidia Quadro 600. All tests pass except Scissor Box with a negative height fails to return a gl error. Reviewed-by: Brian Paul Signed-off-by: Jon Ashburn --- tests/all.tests | 1 + tests/spec/arb_viewport_array/CMakeLists.gl.txt | 1 + tests/spec/arb_viewport_array/bounds.c | 270 3 files changed, 272 insertions(+) create mode 100644 tests/spec/arb_viewport_array/bounds.c diff --git a/tests/all.tests b/tests/all.tests index 78e1563..c40447c 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1745,6 +1745,7 @@ spec['ARB_viewport_array'] = arb_viewport_array arb_viewport_array['viewport-indices'] = concurrent_test('arb_viewport_array-viewport-indices') arb_viewport_array['depthrange-indices'] = concurrent_test('arb_viewport_array-depthrange-indices') arb_viewport_array['scissor-indices'] = concurrent_test('arb_viewport_array-scissor-indices') +arb_viewport_array['bounds'] = concurrent_test('arb_viewport_array-bounds') nv_vertex_program = Group() spec['NV_vertex_program'] = nv_vertex_program diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt index 35df5ea..e508102 100644 --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt @@ -12,5 +12,6 @@ link_libraries( piglit_add_executable(arb_viewport_array-viewport-indices viewport_indices.c) piglit_add_executable(arb_viewport_array-depthrange-indices depth_range_indices.c) piglit_add_executable(arb_viewport_array-scissor-indices scissor_indices.c) +piglit_add_executable(arb_viewport_array-bounds bounds.c) # vim: ft=cmake: diff --git a/tests/spec/arb_viewport_array/bounds.c b/tests/spec/arb_viewport_array/bounds.c new file mode 100644 index 000..3a58b92 --- /dev/null +++ b/tests/spec/arb_viewport_array/bounds.c @@ -0,0 +1,270 @@ +/* + * Copyright © 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Author: Jon Ashburn + */ + +/** + * Tests for the validity of Viewport bounds, Depth Range bounds and + * Scissor Box bounds with viewport arrays (0 to GL_MAX_VIEWPORTS-1). + * "Bounds" are the rectangle or range (eg x, y, width, height). + */ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/** + * Test clamping for viewport x,y, width, height. They should be clamped + * to VIEWPORT_BOUNDS_RANGE and MAX_VIEWPORT_DIMS. INVALID_VALUE for + * negative w,h. Test default values of x,y,w,h. + * OpenGL 4.3 Core section 13.6.1 ref: + *"The location of the viewport’s bottom-left corner, given by (x, y), + *are clamped to be within the implementation-dependent viewport bounds + *range. The viewport bounds range [min, max] tuple may be determined by + *calling GetFloatv with the symbolic constant VIEWPORT_BOUNDS_RANGE (see + *section 22)." + * + *"Viewport width and height are clamped to implementation-dependent + *maximums when specified. The maximum width and height may be found by + *calling GetFloatv with the symbolic constant MAX_VIEWPORT_DIMS." + * + *"An INVALID_VALUE error is generated if either w or h is negative." + * + *"In the initial state, w and h for each viewport are set to the width + *and height, respectively, of the window into which the GL is to do its + *rendering. If the defaul
Re: [Piglit] [PATCH 2/4] ARB_viewport_array: Validity test for depth range index/first/count params
Just some formatting issues on this one and the same for patch 3/4. On 11/01/2013 04:51 PM, Jon Ashburn wrote: Tests GL_ARB_viewport_array validity for indices. Use both valid and invalid parameters (index, first, count) for all these new API entry points: glDepthRangeArrayv, glDepthRangeIndexed, glGetDoublei_v. Tested on Nvidia Quadro 600 all tests pass. Signed-off-by: Jon Ashburn --- tests/all.tests| 1 + tests/spec/arb_viewport_array/CMakeLists.gl.txt| 1 + .../spec/arb_viewport_array/depth_range_indices.c | 151 + 3 files changed, 153 insertions(+) create mode 100644 tests/spec/arb_viewport_array/depth_range_indices.c diff --git a/tests/all.tests b/tests/all.tests index ea92448..de7a8bc 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1743,6 +1743,7 @@ add_plain_test(arb_vertex_program, 'vp-max-array') arb_viewport_array = Group() spec['ARB_viewport_array'] = arb_viewport_array arb_viewport_array['viewport-indices'] = concurrent_test('arb_viewport_array-viewport-indices') +arb_viewport_array['depthrange-indices'] = concurrent_test('arb_viewport_array-depthrange-indices') nv_vertex_program = Group() spec['NV_vertex_program'] = nv_vertex_program diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt index 56ec330..1a443a5 100644 --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt @@ -10,5 +10,6 @@ link_libraries( ) piglit_add_executable(arb_viewport_array-viewport-indices viewport_indices.c) +piglit_add_executable(arb_viewport_array-depthrange-indices depth_range_indices.c) # vim: ft=cmake: diff --git a/tests/spec/arb_viewport_array/depth_range_indices.c b/tests/spec/arb_viewport_array/depth_range_indices.c new file mode 100644 index 000..fe2eb79 --- /dev/null +++ b/tests/spec/arb_viewport_array/depth_range_indices.c @@ -0,0 +1,151 @@ +/* + * Copyright © 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Author: Jon Ashburn + */ + +/** + * Tests GL_ARB_viewport_array validity for indices. + * Use both valid and invalid parameters (index, first, count) + * for all these new API entry points: + * glDepthRangeArrayv, glDepthRangeIndexed, glGetDoublei_v + * + */ + +#include "piglit-util-gl-common.h" +#include + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/** + * Test that DepthRangeArrayv, DepthRangeIndexed, GetDoublei_v give the + * "expected_error" gl error. Given the values for "first" and "count" + * or "index" in range [first, first+count). + */ +static bool +check_dr_index(GLuint first, GLsizei count, GLenum expected_error) +{ + static const GLclampd dv[] = {0.213, 1.0}; + GLclampd *mv, dvGet[2]; + unsigned int i; + bool pass = true; + const unsigned int numIterate = (expected_error == GL_NO_ERROR) ? count : 1; + + mv = malloc(sizeof(GLclampd) * 2 * count); + if (mv == NULL) + return false; + for (i =0; i < count; i++) { "i = 0" + mv[i * 2] = dv[0]; + mv[i * 2 + 1] = dv[1]; + } + glDepthRangeArrayv(first, count, mv); + free( mv); free(mv); + pass = piglit_check_gl_error(expected_error) && pass; + + /* only iterate multiple indices for no error case */ + for (i = count; i > count - numIterate; i--) { + glDepthRangeIndexed(first + i - 1, dv[0], dv[1]); + pass = piglit_check_gl_error(expected_error) && pass; + glGetDoublei_v(GL_DEPTH_RANGE, first + i - 1, dvGet); + pass = piglit_check_gl_error(expected_error)
Re: [Piglit] [PATCH 2/2] arb_vertex_type_10f_10f_11f_rev: add test for draw-vertices
Chris Forbes writes: > diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c > b/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c > new file mode 100644 > index 000..1019777 > --- /dev/null > +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c > @@ -0,0 +1,252 @@ > +/** > + * \file api-errors.c filename > + * This tests a few error conditions from the > ARB_vertex_type_10f_11f_11f_rev extension. > + * > + * UF10/UF11 packing code based on The OpenGL Programming Guide / 7th > Edition, Appendix J, > + * with bugfix from gallium source. > + */ > + > +#include "piglit-util-gl-common.h" > + > +PIGLIT_GL_TEST_CONFIG_BEGIN > + config.supports_gl_compat_version = 30; > + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; > + config.window_width = 128; > + config.window_height = 128; > +PIGLIT_GL_TEST_CONFIG_END > + > + > +#define UF11(e, m) ((e << 6) | (m)) > +#define UF11_EXPONENT_BIAS 15 > +#define UF11_EXPONENT_BITS 0x1F > +#define UF11_EXPONENT_SHIFT 6 > +#define UF11_MANTISSA_BITS 0x3F > +#define UF11_MANTISSA_SHIFT (23 - UF11_EXPONENT_SHIFT) > +#define UF11_MAX_EXPONENT(UF11_EXPONENT_BITS << UF11_EXPONENT_SHIFT) > + > +#define UF10(e, m) ((e << 5) | (m)) > +#define UF10_EXPONENT_BIAS 15 > +#define UF10_EXPONENT_BITS 0x1F > +#define UF10_EXPONENT_SHIFT 5 > +#define UF10_MANTISSA_BITS 0x1F > +#define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT) > +#define UF10_MAX_EXPONENT(UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT) > + > +#define F32_INFINITY 0x7f80 > + > +static unsigned f32_to_uf11(float val) > +{ > + union { > + float f; > + uint32_t ui; > + } f32 = {val}; > + > + uint16_t uf11 = 0; > + > + /* Decode little-endian 32-bit floating-point value */ > + int sign = (f32.ui >> 16) & 0x8000; > + /* Map exponent to the range [-127,128] */ > + int exponent = ((f32.ui >> 23) & 0xff) - 127; > + int mantissa = f32.ui & 0x007f; > + > + if (exponent == 128) { /* Infinity or NaN */ > + /* From the GL_EXT_packed_float spec: > + * > + * "Additionally: negative infinity is converted to zero; positive > + * infinity is converted to positive infinity; and both positive > and > + * negative NaN are converted to positive NaN." > + */ > + uf11 = UF11_MAX_EXPONENT; > + if (mantissa) { > + uf11 |= 1; /* NaN */ > + } else { > + if (sign) > +uf11 = 0; /* 0.0 */ > + } > + } else if (sign) { > + return 0; > + } else if (val > 65024.0f) { > + /* From the GL_EXT_packed_float spec: > + * > + * "Likewise, finite positive values greater than 65024 (the > maximum > + * finite representable unsigned 11-bit floating-point value) are > + * converted to 65024." > + */ > + uf11 = UF11(30, 63); > + } > + else if (exponent > -15) { /* Representable value */ > + exponent += UF11_EXPONENT_BIAS; > + mantissa >>= UF11_MANTISSA_SHIFT; > + uf11 = exponent << UF11_EXPONENT_SHIFT | mantissa; > + } > + > + return uf11; > +} > + > +static unsigned f32_to_uf10(float val) > +{ > + union { > + float f; > + uint32_t ui; > + } f32 = {val}; > + > + uint16_t uf10 = 0; > + > + /* Decode little-endian 32-bit floating-point value */ > + int sign = (f32.ui >> 16) & 0x8000; > + /* Map exponent to the range [-127,128] */ > + int exponent = ((f32.ui >> 23) & 0xff) - 127; > + int mantissa = f32.ui & 0x007f; > + > + if (exponent == 128) { > + /* From the GL_EXT_packed_float spec: > + * > + * "Additionally: negative infinity is converted to zero; positive > + * infinity is converted to positive infinity; and both positive > and > + * negative NaN are converted to positive NaN." > + */ > + uf10 = UF10_MAX_EXPONENT; > + if (mantissa) { > + uf10 |= 1; /* NaN */ > + } else { > + if (sign) > +uf10 = 0; /* 0.0 */ > + } > + } else if (sign) { > + return 0; > + } else if (val > 64512.0f) { > + /* From the GL_EXT_packed_float spec: > + * > + * "Likewise, finite positive values greater than 64512 (the > maximum > + * finite representable unsigned 10-bit floating-point value) are > + * converted to 64512." > + */ > + uf10 = UF10(30, 31); > + } > + else if (exponent > -15) { /* Representable value */ > + exponent += UF10_EXPONENT_BIAS; > + mantissa >>= UF10_MANTISSA_SHIFT; > + uf10 = exponent << UF10_EXPONENT_SHIFT | mantissa; > + } > + > + return uf10; > +} > + > +static unsigned float3_to_r11g11b10f(const float rgb[3]) > +{ > + return ( f32_to_uf11(rgb[0]) & 0x7ff) | > + ((f32_to_uf11(rgb[1]) & 0x7ff) << 11) | > + ((f32_to_uf10(rgb[2]) & 0x3ff) << 22); > +} I'd rather see the f32_to_uf11 and frie
[Piglit] [PATCH 2/8] add new test for glDrawArraysIndirect
--- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + tests/spec/arb_draw_indirect/draw-arrays.c | 119 + 3 files changed, 121 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-arrays.c diff --git a/tests/all.tests b/tests/all.tests index 1ad230e..0e02729 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1219,6 +1219,7 @@ add_plain_test(arb_draw_instanced, 'draw-instanced-divisor') arb_draw_indirect = Group() spec['ARB_draw_indirect'] = arb_draw_indirect add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-api-errors') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 1447610..5400f03 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -10,5 +10,6 @@ link_libraries ( ) piglit_add_executable (arb_draw_indirect-api-errors api-errors.c) +piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-arrays.c b/tests/spec/arb_draw_indirect/draw-arrays.c new file mode 100644 index 000..3c03d75 --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-arrays.c @@ -0,0 +1,119 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawArraysIndirect */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float red[] = {1,0,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glUseProgram(prog); + + glDrawArraysIndirect(GL_TRIANGLES, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, red) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +}; + +GLuint indirect_data[] = { + 3, /* count */ + 1, /* primcount */ + 0, /* first vertex */ + 0, /* mbz */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); + + glGenBuffers(1, &indirect_bo); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirect_bo); + glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(indirect_data), indirect_data, GL_STATIC_DRAW); + + prog = piglit_build_simple_program( + "#version 130\n" + "#extension GL_ARB_explicit_attrib_location: require\n" + "\n" + "layout(location=0) in vec2 pos;\n" + "\n" + "void main() {\n" + " gl_Position = vec4(pos, 0, 1);\n" + "}\n", + + "#version 130\n" +
[Piglit] [PATCH 4/8] ARB_draw_indirect: add test for DrawArraysIndirect with base instance
Signed-off-by: Chris Forbes --- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + .../arb_draw_indirect/draw-arrays-base-instance.c | 142 + 3 files changed, 144 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-arrays-base-instance.c diff --git a/tests/all.tests b/tests/all.tests index d0e28d4..5213031 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1221,6 +1221,7 @@ spec['ARB_draw_indirect'] = arb_draw_indirect add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-api-errors') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-base-instance') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 388f1df..8395d7b 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -12,5 +12,6 @@ link_libraries ( piglit_add_executable (arb_draw_indirect-api-errors api-errors.c) piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c) piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c) +piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-base-instance.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-arrays-base-instance.c b/tests/spec/arb_draw_indirect/draw-arrays-base-instance.c new file mode 100644 index 000..b209509 --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-arrays-base-instance.c @@ -0,0 +1,142 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawArraysIndirect interaction with base instance */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float green[] = {0,1,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glUseProgram(prog); + + glDrawArraysIndirect(GL_TRIANGLES, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, green) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +}; + +int instance_data[] = { 0, 0, 0, 0, 42, 0, 0 }; + +GLuint indirect_data[] = { + 3, /* count */ + 1, /* primcount */ + 0, /* first vertex */ + 4, /* base instance */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint instance_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + piglit_require_extension("GL_ARB_base_instance"); + piglit_require_extension("GL_ARB_instanced_arrays"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); + + glGenBuffers(1, &instance_bo); + glBindBuffer(GL_ARRAY_BUFFER, instance_bo); + g
[Piglit] [PATCH 7/8] add ugly primitive restart case
--- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + .../draw-elements-prim-restart-ugly.c | 134 + 3 files changed, 136 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-elements-prim-restart-ugly.c diff --git a/tests/all.tests b/tests/all.tests index 049abaf..4eb 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1224,6 +1224,7 @@ add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-base-instance') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-base-instance') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-prim-restart') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-prim-restart-ugly') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 26aa410..1fa189c 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -15,5 +15,6 @@ piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c) piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-base-instance.c) piglit_add_executable (arb_draw_indirect-draw-elements-base-instance draw-elements-base-instance.c) piglit_add_executable (arb_draw_indirect-draw-elements-prim-restart draw-elements-prim-restart.c) +piglit_add_executable (arb_draw_indirect-draw-elements-prim-restart-ugly draw-elements-prim-restart-ugly.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-elements-prim-restart-ugly.c b/tests/spec/arb_draw_indirect/draw-elements-prim-restart-ugly.c new file mode 100644 index 000..5e348af --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-elements-prim-restart-ugly.c @@ -0,0 +1,134 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawElementsIndirect interaction with primitive restart, + * with a weird cut index. This requires a fallback on Ivybridge. */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float red[] = {1,0,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glPrimitiveRestartIndex(42); + glEnable(GL_PRIMITIVE_RESTART); + + glUseProgram(prog); + + glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, red) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +1, 1, +}; + +unsigned short indices_data[] = { + 3, 1, 42, 0, 1, 2, 0, 42, +}; + +GLuint indirect_data[] = { + 8, /* count */ + 1, /* primcount */ + 0, /* first index */ + 0, /* base vertex */ + 0, /* mbz */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint indices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vert
[Piglit] [PATCH 8/8] ARB_draw_indirect: add instances test
Signed-off-by: Chris Forbes --- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + .../spec/arb_draw_indirect/draw-arrays-instances.c | 123 + 3 files changed, 125 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-arrays-instances.c diff --git a/tests/all.tests b/tests/all.tests index 4eb..ed8f79f 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1225,6 +1225,7 @@ add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-base-insta add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-base-instance') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-prim-restart') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-prim-restart-ugly') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-instances') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 1fa189c..94735db 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -16,5 +16,6 @@ piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-b piglit_add_executable (arb_draw_indirect-draw-elements-base-instance draw-elements-base-instance.c) piglit_add_executable (arb_draw_indirect-draw-elements-prim-restart draw-elements-prim-restart.c) piglit_add_executable (arb_draw_indirect-draw-elements-prim-restart-ugly draw-elements-prim-restart-ugly.c) +piglit_add_executable (arb_draw_indirect-draw-arrays-instances draw-arrays-instances.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-arrays-instances.c b/tests/spec/arb_draw_indirect/draw-arrays-instances.c new file mode 100644 index 000..1d7c240 --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-arrays-instances.c @@ -0,0 +1,123 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawElementsIndirect */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float green[] = {0,1,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + int i; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glUseProgram(prog); + + glDrawArraysIndirect(GL_TRIANGLE_STRIP, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + for (i = 0; i < 8; i++) + pass = piglit_probe_pixel_rgb( 8 + 16 * i, 64, green) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +1, 1, +}; + +GLuint indirect_data[] = { + 4, /* count */ + 8, /* primcount */ + 0, /* first vertex */ + 0, /* mbz */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); + + glGenBuffers(1, &indirect_bo); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER,
[Piglit] [PATCH 5/8] ARB_draw_indirect: add test for DrawElementsIndirect with base instance
Signed-off-by: Chris Forbes --- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + .../draw-elements-base-instance.c | 152 + 3 files changed, 154 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-elements-base-instance.c diff --git a/tests/all.tests b/tests/all.tests index 5213031..d6b0704 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1222,6 +1222,7 @@ add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-api-errors') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-base-instance') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-base-instance') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 8395d7b..242647d 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -13,5 +13,6 @@ piglit_add_executable (arb_draw_indirect-api-errors api-errors.c) piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c) piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c) piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-base-instance.c) +piglit_add_executable (arb_draw_indirect-draw-elements-base-instance draw-elements-base-instance.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-elements-base-instance.c b/tests/spec/arb_draw_indirect/draw-elements-base-instance.c new file mode 100644 index 000..acd4a9e --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-elements-base-instance.c @@ -0,0 +1,152 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawElementsIndirect interaction with base instance */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float green[] = {0,1,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glUseProgram(prog); + + glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, green) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +}; + +int instance_data[] = { 0, 0, 0, 0, 42, 0, 0 }; + +unsigned short indices_data[] = { + 0, 1, 2, +}; + +GLuint indirect_data[] = { + 3, /* count */ + 1, /* primcount */ + 0, /* first index */ + 0, /* base vertex */ + 4, /* base instance */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint instance_bo; + GLuint indices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + piglit_require_extension("GL_ARB_base_instance"); + piglit_require_extension("GL_ARB_instanced_arrays"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + gl
[Piglit] [PATCH 6/8] ARB_draw_indirect: add test for glDrawElementsIndirect with primitive restart
--- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + .../arb_draw_indirect/draw-elements-prim-restart.c | 133 + 3 files changed, 135 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-elements-prim-restart.c diff --git a/tests/all.tests b/tests/all.tests index d6b0704..049abaf 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1223,6 +1223,7 @@ add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays-base-instance') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-base-instance') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements-prim-restart') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 242647d..26aa410 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -14,5 +14,6 @@ piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c) piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c) piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-base-instance.c) piglit_add_executable (arb_draw_indirect-draw-elements-base-instance draw-elements-base-instance.c) +piglit_add_executable (arb_draw_indirect-draw-elements-prim-restart draw-elements-prim-restart.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-elements-prim-restart.c b/tests/spec/arb_draw_indirect/draw-elements-prim-restart.c new file mode 100644 index 000..60c0465 --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-elements-prim-restart.c @@ -0,0 +1,133 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawElementsIndirect interaction with primitive restart */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float red[] = {1,0,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glPrimitiveRestartIndex(0x); + glEnable(GL_PRIMITIVE_RESTART); + + glUseProgram(prog); + + glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, red) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +1, 1, +}; + +unsigned short indices_data[] = { + 3, 1, 0x, 0, 1, 2, 0, 0x, +}; + +GLuint indirect_data[] = { + 8, /* count */ + 1, /* primcount */ + 0, /* first index */ + 0, /* base vertex */ + 0, /* mbz */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint indices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data,
[Piglit] [PATCH 1/8] arb_draw_indirect: add test for api errors
This initial test covers the new buffer binding point and expected API errors only; no successful Draw*Indirect calls are made. Future tests will exercise positive cases. Signed-off-by: Chris Forbes --- tests/all.tests| 5 + tests/spec/CMakeLists.txt | 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 14 ++ tests/spec/arb_draw_indirect/CMakeLists.txt| 1 + tests/spec/arb_draw_indirect/api-errors.c | 235 + 5 files changed, 256 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/CMakeLists.gl.txt create mode 100644 tests/spec/arb_draw_indirect/CMakeLists.txt create mode 100644 tests/spec/arb_draw_indirect/api-errors.c diff --git a/tests/all.tests b/tests/all.tests index 2e88de4..1ad230e 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1215,6 +1215,11 @@ arb_draw_instanced['negative-elements-type'] = concurrent_test('arb_draw_instanc add_plain_test(arb_draw_instanced, 'draw-instanced') add_plain_test(arb_draw_instanced, 'draw-instanced-divisor') +# Group ARB_draw_indirect +arb_draw_indirect = Group() +spec['ARB_draw_indirect'] = arb_draw_indirect +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-api-errors') + # Group ARB_fragment_program arb_fragment_program = Group() spec['ARB_fragment_program'] = arb_fragment_program diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 18b846d..07721b5 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory (arb_color_buffer_float) add_subdirectory (arb_debug_output) add_subdirectory (khr_debug) add_subdirectory (arb_depth_clamp) +add_subdirectory (arb_draw_indirect) add_subdirectory (arb_draw_instanced) add_subdirectory (arb_es2_compatibility) add_subdirectory (arb_framebuffer_object) diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt new file mode 100644 index 000..1447610 --- /dev/null +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -0,0 +1,14 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (arb_draw_indirect-api-errors api-errors.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/CMakeLists.txt b/tests/spec/arb_draw_indirect/CMakeLists.txt new file mode 100644 index 000..144a306 --- /dev/null +++ b/tests/spec/arb_draw_indirect/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_draw_indirect/api-errors.c b/tests/spec/arb_draw_indirect/api-errors.c new file mode 100644 index 000..acd7f6c --- /dev/null +++ b/tests/spec/arb_draw_indirect/api-errors.c @@ -0,0 +1,235 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Test error behavior for GL_ARB_draw_indirect */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + + +static bool +check_binding_point(void) +{ + /* Check that the binding point exists, and the default +* binding must be zero +*/ + + GLint obj; + glGetIntegerv(GL_DRAW_INDIRECT_BUFFER_BINDING, &obj); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + return false; + + if (obj != 0) + return false; + + return true; +} + + +static bool +check_can_bind(void) +{ + /* Check that a buffer can be bound to the binding point. +* Does not *use* the buffer for anything. +*/ + GLuint
[Piglit] [PATCH 3/8] add test for DrawElementsIndirect
--- tests/all.tests| 1 + tests/spec/arb_draw_indirect/CMakeLists.gl.txt | 1 + tests/spec/arb_draw_indirect/draw-elements.c | 129 + 3 files changed, 131 insertions(+) create mode 100644 tests/spec/arb_draw_indirect/draw-elements.c diff --git a/tests/all.tests b/tests/all.tests index 0e02729..d0e28d4 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1220,6 +1220,7 @@ arb_draw_indirect = Group() spec['ARB_draw_indirect'] = arb_draw_indirect add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-api-errors') add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-arrays') +add_concurrent_test(arb_draw_indirect, 'arb_draw_indirect-draw-elements') # Group ARB_fragment_program arb_fragment_program = Group() diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt index 5400f03..388f1df 100644 --- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt +++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt @@ -11,5 +11,6 @@ link_libraries ( piglit_add_executable (arb_draw_indirect-api-errors api-errors.c) piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c) +piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c) # vim: ft=cmake: diff --git a/tests/spec/arb_draw_indirect/draw-elements.c b/tests/spec/arb_draw_indirect/draw-elements.c new file mode 100644 index 000..26069a3 --- /dev/null +++ b/tests/spec/arb_draw_indirect/draw-elements.c @@ -0,0 +1,129 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* Basic test of glDrawElementsIndirect */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; +GLint prog; + +float red[] = {1,0,0}; +float blue[] = {0,0,1}; + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + glViewport(0, 0, 128, 128); + + glClearColor(0,0,1,1); + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + glUseProgram(prog); + + glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (GLvoid const *)0); + + glUseProgram(0); + + piglit_present_results(); + + pass = piglit_probe_pixel_rgb(32, 32, red) && pass; + pass = piglit_probe_pixel_rgb(96, 96, blue) && pass; + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +float vertices_data[] = { + -1, -1, +1, -1, + -1, 1, +}; + +unsigned short indices_data[] = { + 0, 1, 2, +}; + +GLuint indirect_data[] = { + 3, /* count */ + 1, /* primcount */ + 0, /* first index */ + 0, /* base vertex */ + 0, /* mbz */ +}; + +void +piglit_init(int argc, char **argv) +{ + GLuint vertices_bo; + GLuint indices_bo; + GLuint indirect_bo; + + piglit_require_extension("GL_ARB_draw_indirect"); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glGenBuffers(1, &vertices_bo); + glBindBuffer(GL_ARRAY_BUFFER, vertices_bo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); + + glGenBuffers(1, &indices_bo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_bo); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_data), indices_data, GL_STATIC_DRAW); + + glGenBuffers(1, &indirect_bo); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirect_bo); + glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(indirect_data), indirect_data, GL_STATIC_DRAW); + + prog = piglit_build_sim
Re: [Piglit] [PATCH 1/2] arb_vertex_type_10f_10f_11f_rev: add test for api-errors
Chris Forbes writes: > +static bool > +test_vertex_attribs() > +{ > + bool pass = true; > + GLuint data = 0; > + > + /* "The error INVALID_OPERATION is generated by ... , or > VertexAttribPointer > + * if is UNSIGNED_INT_10F_11F_11F_REV and is not 3. > + */ > + > + glVertexAttribPointer(0, 3, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, > 0, (GLvoid *)0); > + TEST("VertexAttribPointer-ok", GL_NO_ERROR); > + > + glVertexAttribPointer(0, 2, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, > 0, (GLvoid *)0); > + TEST("VertexAttribPointer-badsize", GL_INVALID_OPERATION); I think file could also use a test that a normalized == GL_TRUE doesn't spuriously throw an error, given how much spec text is devoted to that. > +void > +piglit_init(int argc, char **argv) > +{ > + bool pass = true; > + GLuint bo; > + > + piglit_require_extension("GL_ARB_vertex_type_2_10_10_10_rev"); > + piglit_require_extension("GL_ARB_vertex_type_10f_11f_11f_rev"); The 2_10_10_10 check seems gratuitous. In particular, if an implementation exposed 10f without the infrastructure from 2_10, you'd want this test to run and fail. Other than that, Reviewed-by: Eric Anholt pgppsPSVOgvWt.pgp Description: PGP signature ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
[Piglit] [PATCH 2/2] arb_vertex_type_10f_10f_11f_rev: add test for draw-vertices
--- tests/all.tests| 1 + .../CMakeLists.gl.txt | 1 + .../draw-vertices.c| 252 + 3 files changed, 254 insertions(+) create mode 100644 tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c diff --git a/tests/all.tests b/tests/all.tests index 2f102f4..c2c4d46 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -2599,6 +2599,7 @@ arb_vertex_type_2_10_10_10_rev['attribs'] = concurrent_test('attribs GL_ARB_vert arb_vertex_type_10f_11f_11f_rev = Group() spec['ARB_vertex_type_10f_11f_11f_rev'] = arb_vertex_type_10f_11f_11f_rev add_plain_test(arb_vertex_type_10f_11f_11f_rev, 'arb_vertex_type_10f_11f_11f_rev-api-errors') +add_concurrent_test(arb_vertex_type_10f_11f_11f_rev, 'arb_vertex_type_10f_11f_11f_rev-draw-vertices') arb_draw_buffers = Group() spec['ARB_draw_buffers'] = arb_draw_buffers diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt index 02d9314..1c751bf 100644 --- a/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt @@ -10,5 +10,6 @@ link_libraries ( ) piglit_add_executable (arb_vertex_type_10f_11f_11f_rev-api-errors api-errors.c) +piglit_add_executable (arb_vertex_type_10f_11f_11f_rev-draw-vertices draw-vertices.c) # vim: ft=cmake: diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c b/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c new file mode 100644 index 000..1019777 --- /dev/null +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/draw-vertices.c @@ -0,0 +1,252 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file api-errors.c + * + * This tests a few error conditions from the ARB_vertex_type_10f_11f_11f_rev extension. + * + * UF10/UF11 packing code based on The OpenGL Programming Guide / 7th Edition, Appendix J, + * with bugfix from gallium source. + */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + config.supports_gl_compat_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + config.window_width = 128; + config.window_height = 128; +PIGLIT_GL_TEST_CONFIG_END + + +#define UF11(e, m) ((e << 6) | (m)) +#define UF11_EXPONENT_BIAS 15 +#define UF11_EXPONENT_BITS 0x1F +#define UF11_EXPONENT_SHIFT 6 +#define UF11_MANTISSA_BITS 0x3F +#define UF11_MANTISSA_SHIFT (23 - UF11_EXPONENT_SHIFT) +#define UF11_MAX_EXPONENT(UF11_EXPONENT_BITS << UF11_EXPONENT_SHIFT) + +#define UF10(e, m) ((e << 5) | (m)) +#define UF10_EXPONENT_BIAS 15 +#define UF10_EXPONENT_BITS 0x1F +#define UF10_EXPONENT_SHIFT 5 +#define UF10_MANTISSA_BITS 0x1F +#define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT) +#define UF10_MAX_EXPONENT(UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT) + +#define F32_INFINITY 0x7f80 + +static unsigned f32_to_uf11(float val) +{ + union { + float f; + uint32_t ui; + } f32 = {val}; + + uint16_t uf11 = 0; + + /* Decode little-endian 32-bit floating-point value */ + int sign = (f32.ui >> 16) & 0x8000; + /* Map exponent to the range [-127,128] */ + int exponent = ((f32.ui >> 23) & 0xff) - 127; + int mantissa = f32.ui & 0x007f; + + if (exponent == 128) { /* Infinity or NaN */ + /* From the GL_EXT_packed_float spec: + * + * "Additionally: negative infinity is converted to zero; positive + * infinity is converted to positive infinity; and both positive and + * negative NaN are converted to positive NaN." + */ + uf11 = UF11_MAX_EXPONENT; + if (mantissa) { + uf11 |= 1; /* NaN */ + } else { + if (sign) +
[Piglit] [PATCH 1/2] arb_vertex_type_10f_10f_11f_rev: add test for api-errors
--- tests/all.tests| 4 + tests/spec/CMakeLists.txt | 1 + .../CMakeLists.gl.txt | 14 ++ .../arb_vertex_type_10f_11f_11f_rev/CMakeLists.txt | 1 + .../arb_vertex_type_10f_11f_11f_rev/api-errors.c | 213 + 5 files changed, 233 insertions(+) create mode 100644 tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt create mode 100644 tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.txt create mode 100644 tests/spec/arb_vertex_type_10f_11f_11f_rev/api-errors.c diff --git a/tests/all.tests b/tests/all.tests index f407adb..2f102f4 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -2596,6 +2596,10 @@ spec['ARB_vertex_type_2_10_10_10_rev'] = arb_vertex_type_2_10_10_10_rev add_plain_test(arb_vertex_type_2_10_10_10_rev, 'draw-vertices-2101010') arb_vertex_type_2_10_10_10_rev['attribs'] = concurrent_test('attribs GL_ARB_vertex_type_2_10_10_10_rev') +arb_vertex_type_10f_11f_11f_rev = Group() +spec['ARB_vertex_type_10f_11f_11f_rev'] = arb_vertex_type_10f_11f_11f_rev +add_plain_test(arb_vertex_type_10f_11f_11f_rev, 'arb_vertex_type_10f_11f_11f_rev-api-errors') + arb_draw_buffers = Group() spec['ARB_draw_buffers'] = arb_draw_buffers add_plain_test(arb_draw_buffers, 'arb_draw_buffers-state_change') diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 18b846d..3e48b86 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -78,6 +78,7 @@ add_subdirectory (gles-3.0) add_subdirectory (glx_arb_create_context) add_subdirectory (glx_ext_import_context) add_subdirectory (glx_oml_sync_control) +add_subdirectory (arb_vertex_type_10f_11f_11f_rev) add_subdirectory (arb_vertex_type_2_10_10_10_rev) add_subdirectory (ext_texture_array) add_subdirectory (ext_texture_integer) diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt new file mode 100644 index 000..02d9314 --- /dev/null +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.gl.txt @@ -0,0 +1,14 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (arb_vertex_type_10f_11f_11f_rev-api-errors api-errors.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.txt b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.txt new file mode 100644 index 000..144a306 --- /dev/null +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_vertex_type_10f_11f_11f_rev/api-errors.c b/tests/spec/arb_vertex_type_10f_11f_11f_rev/api-errors.c new file mode 100644 index 000..09ab431 --- /dev/null +++ b/tests/spec/arb_vertex_type_10f_11f_11f_rev/api-errors.c @@ -0,0 +1,213 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file api-errors.c + * + * This tests a few error conditions from the ARB_vertex_type_10f_11f_11f_rev extension. + */ + +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + config.supports_gl_compat_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; +PIGLIT_GL_TEST_CONFIG_END + + +enum piglit_result +piglit_display() +{ + return PIGLIT_FAIL; /* unreached */ +} + +#define TEST(name, err) \ + do { \ + if (!piglit_check_gl_error(err)) { \ + piglit_report_subtest_result(PIGLIT_FAIL, name); \ + pass = false; \ + } \ + else { \ + piglit_report_subtest_result(PIGLIT_PASS, name); \ + } \ +
Re: [Piglit] [PATCH 1/7] glsl-1.10: Delete bogus generated test.
Patches 1-3, 6-7 are Reviewed-by: Chad Versace Glad I wasn't the only one confused by the removal of glClear. By the way, I have some patches that do similar things for the python test generators. The patches make the tests run faster on simulation. I need to revive the patches and send them out. On 11/04/2013 10:27 PM, Matt Turner wrote: --- .../#fs-temp-array-mat2-index-col-wr.shader_test# | 97 -- 1 file changed, 97 deletions(-) delete mode 100644 tests/spec/glsl-1.10/execution/variable-indexing/#fs-temp-array-mat2-index-col-wr.shader_test# diff --git a/tests/spec/glsl-1.10/execution/variable-indexing/#fs-temp-array-mat2-index-col-wr.shader_test# b/tests/spec/glsl-1.10/execution/variable-indexing/#fs-temp-array-mat2-index-col-wr.shader_test# deleted file mode 100644 index a4571e4..000 --- a/tests/spec/glsl-1.10/execution/variable-indexing/#fs-temp-array-mat2-index-col-wr.shader_test# +++ /dev/null @@ -1,97 +0,0 @@ -# Test generated by: -# ../../../glsl-1.10/variable-index-write.sh 1.10 - -[require] -GLSL >= 1.10 - -[vertex shader] -void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } - -[fragment shader] -uniform mat2 src_matrix; -uniform vec2 v; -uniform vec2 expect; -uniform int index; -uniform int col; -uniform vec2 value; - -float distanceSqr(vec a, vec b) { vec diff = a - b; return dot(diff, diff); } - -void main() -{ -mat2 dst_matrix[3]; -dst_matrix[0] = mat2(0.0); -dst_matrix[1] = mat2(0.0); -dst_matrix[2] = mat2(0.0); - -/* Patch the supplied matrix with the supplied value. If the resulting - * matrix is correct, it will transform the input vector to the expected - * value. Verify that the distance between the result and the expected - * vector is less than epsilon. - * - * NOTE: This test assumes that reads of arrays using non-constant - * indicies works correctly. If reads and writes happen to fail in an - * identical manner, this test may give false positives. - */ -dst_matrix[index] = src_matrix; -dst_matrix[index][col] = value; -gl_FragColor = (distanceSqr(dst_matrix[index] * v, expect) < 4e-9) -? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); -} - -[test] -clear color 0.5 0.5 0.5 0.5 -clear -ortho - -uniform int index 0 -uniform int col 0 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 666.0 777.0 0.603473877011433 0.891622340451180 -uniform vec2 value 0.241498998195656 0.861223395812970 -draw rect 5 5 10 10 -probe rgb 10 10 0.0 1.0 0.0 - -uniform int col 1 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 0.241498998195656 0.861223395812970 666.0 777.0 -uniform vec2 value 0.603473877011433 0.891622340451180 -draw rect 20 5 10 10 -probe rgb 25 10 0.0 1.0 0.0 - -uniform int index 1 -uniform int col 0 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 666.0 777.0 0.603473877011433 0.891622340451180 -uniform vec2 value 0.241498998195656 0.861223395812970 -draw rect 45 5 10 10 -probe rgb 50 10 0.0 1.0 0.0 - -uniform int col 1 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 0.241498998195656 0.861223395812970 666.0 777.0 -uniform vec2 value 0.603473877011433 0.891622340451180 -draw rect 60 5 10 10 -probe rgb 65 10 0.0 1.0 0.0 - -uniform int index 2 -uniform int col 0 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 666.0 777.0 0.603473877011433 0.891622340451180 -uniform vec2 value 0.241498998195656 0.861223395812970 -draw rect 85 5 10 10 -probe rgb 90 10 0.0 1.0 0.0 - -uniform int col 1 -uniform vec2 v 0.803161418975390 0.852987140792140 -uniform vec2 expect 0.708718134966688 1.452243795483797 -uniform mat2x2 src_matrix 0.241498998195656 0.861223395812970 666.0 777.0 -uniform vec2 value 0.603473877011433 0.891622340451180 -draw rect 100 5 10 10 -probe rgb 105 10 0.0 1.0 0.0 - ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
[Piglit] [PATCH] fbo-drawbuffers-maxtargets: use different colors for different buffers
Before, the test always drew green rects for all the target buffers. Now we draw a different color into each buffer to be more thorough. Plus, replace 16 with MAX_TARGETS, add some comments, etc. Note: the test now fails with Mesa's swrast because swrast errantly writes the same color to all render targets. --- tests/fbo/fbo-drawbuffers-maxtargets.c | 63 ++-- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/tests/fbo/fbo-drawbuffers-maxtargets.c b/tests/fbo/fbo-drawbuffers-maxtargets.c index c7a8f7d..1efe819 100644 --- a/tests/fbo/fbo-drawbuffers-maxtargets.c +++ b/tests/fbo/fbo-drawbuffers-maxtargets.c @@ -44,6 +44,8 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END +#define MAX_TARGETS 16 + static GLint max_targets; static char *vs_source = @@ -53,13 +55,37 @@ static char *vs_source = "}\n"; static char *fs_source = + "uniform vec4 colors[16]; \n" "void main()\n" "{\n" " for (int i = 0; i < %d; i++) {\n" - " gl_FragData[i] = vec4(0.0, 1.0, 0.0, 0.0);\n" + " gl_FragData[i] = colors[i];\n" " }\n" "}\n"; +static const float colors[][4] = { + { 1.0, 0.0, 0.0, 0.0 }, /* red */ + { 0.0, 1.0, 0.0, 0.0 }, /* green */ + { 0.0, 0.0, 1.0, 0.0 }, /* blue */ + { 0.0, 1.0, 1.0, 0.0 }, /* cyan */ + + { 1.0, 0.0, 1.0, 0.0 }, /* purple */ + { 1.0, 1.0, 0.0, 0.0 }, /* green */ + { 0.5, 0.0, 0.0, 0.0 }, /* half red */ + { 0.0, 0.5, 0.0, 0.0 }, /* half green */ + + { 0.0, 0.0, 0.5, 0.0 }, /* half blue */ + { 0.0, 0.5, 0.5, 0.0 }, /* half cyan */ + { 0.5, 0.0, 0.5, 0.0 }, /* half purple */ + { 0.5, 0.5, 0.0, 0.0 }, /* half green */ + + { 1.0, 1.0, 1.0, 0.0 },/* white */ + { 0.75, 0.75, 0.75, 0.0 }, /* 75% gray */ + { 0.5, 0.5, 0.5, 0.0 },/* 50% gray */ + { 0.25, 0.25, 0.25, 0.0 } /* 25% gray */ +}; + + static GLuint attach_texture(int i) { @@ -87,10 +113,11 @@ attach_texture(int i) static void generate_and_display_drawbuffers(int count) { - GLuint tex[16], fb, fs, vs, prog; - GLenum attachments[16], status; + GLuint tex[MAX_TARGETS], fb, fs, vs, prog; + GLenum attachments[MAX_TARGETS], status; char *fs_count_source; int i; + int colors_uniform; glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); @@ -112,7 +139,7 @@ generate_and_display_drawbuffers(int count) glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); - /* Build the shader that spams green to all outputs. */ + /* Build the shader that writes different color to each buffer. */ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); fs_count_source = malloc(strlen(fs_source) + 5); @@ -126,6 +153,9 @@ generate_and_display_drawbuffers(int count) if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); + colors_uniform = glGetUniformLocation(prog, "colors"); + glUniform4fv(colors_uniform, MAX_TARGETS, (GLfloat *) colors); + /* Now render to all the color buffers. */ piglit_draw_rect(-1, -1, 2, 2); @@ -135,6 +165,7 @@ generate_and_display_drawbuffers(int count) piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); + /* draw row of boxes, each with the color from texture/target[i] */ for (i = 0; i < count; i++) { glBindTexture(GL_TEXTURE_2D, tex[i]); piglit_draw_rect_tex(16 * i, 16 * (count - 1), @@ -154,22 +185,24 @@ enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; - float green[] = {0, 1, 0, 0}; int count, i; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); + for (count = 1; count <= max_targets; count++) { generate_and_display_drawbuffers(count); } + /* walk over rows */ for (count = 1; count <= max_targets; count++) { + /* walk over columns */ for (i = 0; i < count; i++) { pass = pass && piglit_probe_pixel_rgb(16 * i + 8, 16 * (count - 1) + 8, - green); + colors[i]); } } @@ -183,9 +216,10 @@ piglit_init(int argc, char **argv) { GLint max_attachments; - printf("The result should be increasing lengths of rows of green\n" - "boxes as the test increases the number of drawbuffers \n" - "targets used.\n"); + assert(ARRAY_SIZE(colors) == MAX_TARGETS)