[Piglit] [PATCH] add ARB_compute_variable_group_size tests
Samuel Pitoiset
samuel.pitoiset at gmail.com
Sat Sep 10 11:48:01 UTC 2016
On 09/09/2016 09:07 PM, Ian Romanick wrote:
> On 09/08/2016 12:00 PM, Samuel Pitoiset wrote:
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>> tests/all.py | 8 +
>> tests/spec/CMakeLists.txt | 1 +
>> .../CMakeLists.gl.txt | 16 ++
>> .../arb_compute_variable_group_size/CMakeLists.txt | 1 +
>> tests/spec/arb_compute_variable_group_size/basic.c | 168 ++++++++++++++
>> .../compiler/do_nothing.comp | 14 ++
>> .../compiler/gl_LocalGroupSizeARB_illegal_use.comp | 28 +++
>> .../compiler/gl_LocalGroupSizeARB_layout.comp | 27 +++
>> .../mixed_fixed_variable_local_work_size.comp | 23 ++
>> .../spec/arb_compute_variable_group_size/errors.c | 249 +++++++++++++++++++++
>> ...ixed_fixed_variable_local_work_size.shader_test | 36 +++
>> .../linker/no_local_size_specified.shader_test | 32 +++
>> .../spec/arb_compute_variable_group_size/minmax.c | 65 ++++++
>
> There is infrastructure for generating minmax tests. See commit
> 1373f58d for an example.
Yes, but this is only for built-in constants?
ARB_compute_variable_group_size doesn't introduce any new built-in
constants and gl_LocalGroupSizeARB is most likely a system value.
>
>> 13 files changed, 668 insertions(+)
>> create mode 100644 tests/spec/arb_compute_variable_group_size/CMakeLists.gl.txt
>> create mode 100644 tests/spec/arb_compute_variable_group_size/CMakeLists.txt
>> create mode 100644 tests/spec/arb_compute_variable_group_size/basic.c
>> create mode 100644 tests/spec/arb_compute_variable_group_size/compiler/do_nothing.comp
>> create mode 100644 tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_illegal_use.comp
>> create mode 100644 tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_layout.comp
>> create mode 100644 tests/spec/arb_compute_variable_group_size/compiler/mixed_fixed_variable_local_work_size.comp
>> create mode 100644 tests/spec/arb_compute_variable_group_size/errors.c
>> create mode 100644 tests/spec/arb_compute_variable_group_size/linker/mixed_fixed_variable_local_work_size.shader_test
>> create mode 100644 tests/spec/arb_compute_variable_group_size/linker/no_local_size_specified.shader_test
>> create mode 100644 tests/spec/arb_compute_variable_group_size/minmax.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index 3961656..961b36c 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -4797,5 +4797,13 @@ with profile.group_manager(
>> g(['ext_window_rectangles-errors_gles3'], 'errors_gles3')
>> g(['ext_window_rectangles-render_gles3'], 'render_gles3')
>>
>> +# Group ARB_compute_variable_group_size
>> +with profile.group_manager(
>> + PiglitGLTest,
>> + grouptools.join('spec', 'ARB_compute_variable_group_size')) as g:
>> + g(['arb_compute_variable_group_size-minmax'], 'minmax')
>> + g(['arb_compute_variable_group_size-basic'], 'basic')
>> + g(['arb_compute_variable_group_size-errors'], 'errors')
>> +
>> if platform.system() is 'Windows':
>> profile.filter_tests(lambda p, _: not p.startswith('glx'))
>> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
>> index 9b0f73e..3449a2b 100644
>> --- a/tests/spec/CMakeLists.txt
>> +++ b/tests/spec/CMakeLists.txt
>> @@ -9,6 +9,7 @@ add_subdirectory (arb_clip_control)
>> add_subdirectory (arb_color_buffer_float)
>> add_subdirectory (arb_copy_image)
>> add_subdirectory (arb_compute_shader)
>> +add_subdirectory (arb_compute_variable_group_size)
>> add_subdirectory (arb_cull_distance)
>> add_subdirectory (arb_debug_output)
>> add_subdirectory (khr_debug)
>> diff --git a/tests/spec/arb_compute_variable_group_size/CMakeLists.gl.txt b/tests/spec/arb_compute_variable_group_size/CMakeLists.gl.txt
>> new file mode 100644
>> index 0000000..e0ef913
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/CMakeLists.gl.txt
>> @@ -0,0 +1,16 @@
>> +include_directories(
>> + ${GLEXT_INCLUDE_DIR}
>> + ${OPENGL_INCLUDE_PATH}
>> + ${piglit_SOURCE_DIR}/tests/util
>> +)
>> +
>> +link_libraries (
>> + piglitutil_${piglit_target_api}
>> + ${OPENGL_gl_LIBRARY}
>> +)
>> +
>> +piglit_add_executable (arb_compute_variable_group_size-basic basic.c)
>> +piglit_add_executable (arb_compute_variable_group_size-errors errors.c)
>> +piglit_add_executable (arb_compute_variable_group_size-minmax minmax.c)
>> +
>> +# vim: ft=cmake:
>> diff --git a/tests/spec/arb_compute_variable_group_size/CMakeLists.txt b/tests/spec/arb_compute_variable_group_size/CMakeLists.txt
>> new file mode 100644
>> index 0000000..144a306
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/CMakeLists.txt
>> @@ -0,0 +1 @@
>> +piglit_include_target_api()
>> diff --git a/tests/spec/arb_compute_variable_group_size/basic.c b/tests/spec/arb_compute_variable_group_size/basic.c
>> new file mode 100644
>> index 0000000..b15e3cc
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/basic.c
>
>
> For this test, I think it would be much better to add
> glDispatchComputeGroupSizeARB support to shader_runner.
You are right, I will add it to shader_runner.
>
>> @@ -0,0 +1,168 @@
>> +/*
>> + * Copyright (c) 2016 Samuel Pitoiset
>> + *
>> + * 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
>> + *
>> + * Simple test for DispatchComputeGroupSizeARB().
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> + config.supports_gl_compat_version = 33;
>> + config.supports_gl_core_version = 33;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +static GLuint atomics_bo = 0;
>> +static uint32_t global_x = 1, global_y = 1, global_z = 1;
>> +
>> +static const char *cs_source =
>> + "#version 330\n"
>> + "#extension GL_ARB_compute_variable_group_size: enable\n"
>> + "#extension GL_ARB_shader_atomic_counters: require\n"
>> + "\n"
>> + "layout(binding = 0) uniform atomic_uint a;\n"
>> + "layout(local_size_variable) in;\n"
>> + "\n"
>> + "void main()\n"
>> + "{\n"
>> + " if (gl_LocalGroupSizeARB.x == 8u &&\n"
>> + " gl_LocalGroupSizeARB.y == 4u &&\n"
>> + " gl_LocalGroupSizeARB.z == 2u)\n"
>> + " atomicCounterIncrement(a);\n"
>> + "}\n";
>> +
>> +static GLuint
>> +generate_cs_prog(const char *source)
>> +{
>> + GLuint prog = glCreateProgram();
>> +
>> + GLuint shader =
>> + piglit_compile_shader_text_nothrow(GL_COMPUTE_SHADER, source);
>> +
>> + if (!shader) {
>> + glDeleteProgram(prog);
>> + return 0;
>> + }
>> +
>> + glAttachShader(prog, shader);
>> +
>> + glLinkProgram(prog);
>> +
>> + glDeleteShader(shader);
>> +
>> + if (!piglit_link_check_status(prog)) {
>> + glDeleteProgram(prog);
>> + return 0;
>> + }
>> +
>> + return prog;
>> +}
>> +
>> +static enum piglit_result
>> +check_result(uint32_t local_x, uint32_t local_y, uint32_t local_z)
>> +{
>> + uint32_t expected = local_x * local_y * local_z;
>> + bool pass = true;
>> + uint32_t *p;
>> +
>> + glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
>> + p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(uint32_t),
>> + GL_MAP_READ_BIT);
>> + if (!p) {
>> + printf("Couldn't map atomic counter to verify expected value.\n");
>> + return PIGLIT_FAIL;
>> + }
>> +
>> + if (p[0] != expected) {
>> + printf("Atomic counter test failed for (%d, %d, %d)\n",
>> + local_x, local_y, local_z);
>> + printf(" Reference: %u\n", expected);
>> + printf(" Observed: %u\n", p[0]);
>> + pass = false;
>> + }
>> +
>> + glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
>> +
>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +static enum piglit_result
>> +run_test(GLint prog)
>> +{
>> + enum piglit_result result;
>> + uint32_t atomics_init = 0;
>> + uint32_t local_x = 8, local_y = 4, local_z = 2;
>> +
>> + glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
>> + glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(uint32_t), &atomics_init,
>> + GL_STATIC_DRAW);
>> +
>> + glUseProgram(prog);
>> +
>> + glMemoryBarrier(GL_ALL_BARRIER_BITS);
>> + glDispatchComputeGroupSizeARB(global_x, global_y, global_z,
>> + local_x, local_y, local_z);
>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>> + return PIGLIT_FAIL;
>> + glMemoryBarrier(GL_ALL_BARRIER_BITS);
>> +
>> + result = check_result(local_x, local_y, local_z);
>> + if (result != PIGLIT_PASS)
>> + piglit_report_result(result);
>> +
>> + return result;
>> +}
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> + return PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + enum piglit_result result;
>> + GLint prog;
>> +
>> + piglit_require_extension("GL_ARB_compute_variable_group_size");
>> + piglit_require_extension("GL_ARB_shader_atomic_counters");
>> +
>> + glGenBuffers(1, &atomics_bo);
>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>> + piglit_report_result(PIGLIT_FAIL);
>> +
>> + prog = generate_cs_prog(cs_source);
>
> If you don't replace this test with shader_runner enhancements... why
> not use piglit_build_simple_program_multiple_shaders here?
I didn't know that helper actually... And it's the first time I write
piglit tests. :)
>
>> + if (!prog)
>> + piglit_report_result(PIGLIT_FAIL);
>> +
>> + result = run_test(prog);
>> +
>> + glDeleteProgram(prog);
>> + glDeleteBuffers(1, &atomics_bo);
>> +
>> + piglit_report_result(result);
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/compiler/do_nothing.comp b/tests/spec/arb_compute_variable_group_size/compiler/do_nothing.comp
>> new file mode 100644
>> index 0000000..95c061b
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/compiler/do_nothing.comp
>> @@ -0,0 +1,14 @@
>> +// [config]
>> +// expect_result: pass
>> +// glsl_version: 3.30
>> +// require_extensions: GL_ARB_compute_variable_group_size
>> +// [end config]
>> +
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +
>> +layout(local_size_variable) in;
>> +
>> +void main()
>> +{
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_illegal_use.comp b/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_illegal_use.comp
>> new file mode 100644
>> index 0000000..7ff4cc2
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_illegal_use.comp
>> @@ -0,0 +1,28 @@
>> +// [config]
>> +// expect_result: fail
>> +// glsl_version: 3.30
>> +// require_extensions: GL_ARB_compute_variable_group_size
>> +// [end config]
>> +//
>> +// From the ARB_compute_variable_group_size spec:
>> +//
>> +// However, the constant "gl_WorkGroupSize" would still be useful for
>> +// sizing built-in arrays for shaders with a fixed work group size. For
>> +// example, a shader might want to declare a shared variable with one
>> +// instance per work group invocation, such as:
>> +//
>> +// shared float shared_values[gl_WorkGroupSize.x *
>> +// gl_WorkGroupSize.y * gl_WorkGroupSize.z];
>> +//
>> +// Such declarations would be illegal using the input
>> +// "gl_LocalGroupSizeARB".
>> +
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +
>> +layout(local_size_variable) in;
>> +
>> +void main()
>> +{
>> + uint v[gl_LocalGroupSizeARB.x];
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_layout.comp b/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_layout.comp
>> new file mode 100644
>> index 0000000..8f2345f
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/compiler/gl_LocalGroupSizeARB_layout.comp
>> @@ -0,0 +1,27 @@
>> +// [config]
>> +// expect_result: pass
>> +// glsl_version: 3.30
>> +// require_extensions: GL_ARB_compute_variable_group_size
>> +// [end config]
>> +//
>> +// From the ARB_compute_variable_group_size spec:
>> +//
>> +// The built-in variable /gl_LocalGroupSizeARB/ is a compute-shader input
>> +// variable containing the local work group size for the current compute-
>> +// shader work group. For compute shaders with a fixed local group size
>> +// (using *local_size_x*, *local_size_y*, or *local_size_z* layout
>> +// qualifiers), its value will be the same as the constant
>> +// /gl_WorkGroupSize/. For compute shaders with a variable local group size
>> +// (using *local_size_variable*), the value of /gl_LocalGroupSizeARB/ will
>> +// be the work group size specified in the OpenGL API command dispatching
>> +// the current compute shader work.
>> +
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +
>> +layout(local_size_variable) in;
>> +
>> +void main()
>> +{
>> + uvec3 size = gl_LocalGroupSizeARB;
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/compiler/mixed_fixed_variable_local_work_size.comp b/tests/spec/arb_compute_variable_group_size/compiler/mixed_fixed_variable_local_work_size.comp
>> new file mode 100644
>> index 0000000..7bcfb4e
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/compiler/mixed_fixed_variable_local_work_size.comp
>> @@ -0,0 +1,23 @@
>> +// [config]
>> +// expect_result: fail
>> +// glsl_version: 3.30
>> +// require_extensions: GL_ARB_compute_variable_group_size
>> +// [end config]
>> +//
>> +// From the ARB_compute_variable_group_size spec:
>> +//
>> +// If a compute shader including a *local_size_variable* qualifier also
>> +// declares a fixed local group size using the *local_size_x*,
>> +// *local_size_y*, or *local_size_z* qualifiers, a compile-time error
>> +// results.
>> +
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +#extension GL_ARB_compute_shader: enable
>> +
>> +layout(local_size_x = 2) in;
>> +layout(local_size_variable) in;
>> +
>> +void main()
>> +{
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/errors.c b/tests/spec/arb_compute_variable_group_size/errors.c
>> new file mode 100644
>> index 0000000..c0c6d6e
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/errors.c
>> @@ -0,0 +1,249 @@
>> +/*
>> + * Copyright (C) 2016 Samuel Pitoiset
>> + *
>> + * 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
>> + *
>> + * Test cases in which the ARB_compute_variable_group_size API is expected to
>> + * generate an error.
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +#include "piglit-shader.h"
>> +
>> +static struct piglit_gl_test_config *piglit_config;
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> + piglit_config = &config;
>> + config.supports_gl_compat_version = 33;
>> + config.supports_gl_core_version = 33;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +static const char *variable_work_group_size_shader =
>> + "#version 330\n"
>> + "#extension GL_ARB_compute_variable_group_size: enable\n"
>> + "\n"
>> + "layout(local_size_variable) in;\n"
>> + "\n"
>> + "void main()\n"
>> + "{\n"
>> + "}\n";
>> +
>> +static const char *fixed_work_group_size_shader =
>> + "#version 330\n"
>> + "#extension GL_ARB_compute_shader: enable\n"
>> + "\n"
>> + "layout(local_size_x = 1) in;\n"
>> + "\n"
>> + "void main()\n"
>> + "{\n"
>> + "}\n";
>> +
>> +static enum piglit_result
>> +use_variable_work_group_size_normal()
>> +{
>> + /* From the ARB_compute_variable_group_size spec:
>> + *
>> + * An INVALID_OPERATION error is generated by DispatchCompute or
>> + * DispatchComputeIndirect if the active program for the compute
>> + * shader stage has a variable work group size.
>> + */
>> + GLint prog = piglit_build_simple_program_multiple_shaders(
>> + GL_COMPUTE_SHADER, variable_work_group_size_shader, 0);
>> + glUseProgram(prog);
>> + glDispatchCompute(1, 1, 1);
>> + if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>> + return PIGLIT_FAIL;
>> + return PIGLIT_PASS;
>> +}
>> +
>> +static enum piglit_result
>> +use_variable_work_group_size_indirect()
>> +{
>> + /* From the ARB_compute_variable_group_size spec:
>> + *
>> + * An INVALID_OPERATION error is generated by DispatchCompute or
>> + * DispatchComputeIndirect if the active program for the compute
>> + * shader stage has a variable work group size.
>> + */
>> + GLuint indirect_buf[3] = { 1, 1, 1 };
>> + GLuint indirect_bo = 0;
>> + GLint prog;
>> +
>> + glGenBuffers(1, &indirect_bo);
>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>> + return PIGLIT_FAIL;
>> +
>> + glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, indirect_bo);
>> + glBufferData(GL_DISPATCH_INDIRECT_BUFFER, sizeof(indirect_buf),
>> + indirect_buf, GL_STREAM_READ);
>> +
>> + prog = piglit_build_simple_program_multiple_shaders(
>> + GL_COMPUTE_SHADER, variable_work_group_size_shader, 0);
>> + glUseProgram(prog);
>> +
>> + glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, indirect_bo);
>> + glDispatchComputeIndirect(0);
>> + if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>> + return PIGLIT_FAIL;
>> +
>> + glDeleteBuffers(1, &indirect_bo);
>> + return PIGLIT_PASS;
>> +}
>> +
>> +static enum piglit_result
>> +use_fixed_work_group_size()
>> +{
>> + /* From the ARB_compute_variable_group_size spec:
>> + *
>> + * An INVALID_OPERATION error is generated by
>> + * DispatchComputeGroupSizeARB if the active program for the
>> + * compute shader stage has a fixed work group size.
>> + */
>> + GLint prog = piglit_build_simple_program_multiple_shaders(
>> + GL_COMPUTE_SHADER, fixed_work_group_size_shader, 0);
>> + glUseProgram(prog);
>> + glDispatchComputeGroupSizeARB(1, 1, 1, 1, 1, 1);
>> + if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>> + return PIGLIT_FAIL;
>> + return PIGLIT_PASS;
>> +}
>> +
>> +static enum piglit_result
>> +use_invalid_variable_work_group_size_values()
>> +{
>> + /* From the ARB_compute_variable_group_size spec:
>> + *
>> + * An INVALID_VALUE error is generated by
>> + * DispatchComputeGroupSizeARB if any of <group_size_x>,
>> + * <group_size_y>, or <group_size_z> is less than or equal to zero
>> + * or greater than the maximum local work group size for compute
>> + * shaders with variable group size
>> + * (MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB) in the corresponding
>> + * dimension.
>> + */
>> + GLint prog, v[3];
>> +
>> + prog = piglit_build_simple_program_multiple_shaders(
>> + GL_COMPUTE_SHADER, variable_work_group_size_shader, 0);
>> + glUseProgram(prog);
>> +
>> + /* Use values equal to zero (because "less than" is a spec bug). */
>
> That is true... have you submitted a bug to Khronos? That should get fixed.
Not yet, but I will do.
Thanks!
>
>> + glDispatchComputeGroupSizeARB(1, 1, 1, 0, 0, 0);
>> + if (!piglit_check_gl_error(GL_INVALID_VALUE))
>> + return PIGLIT_FAIL;
>> +
>> + /* Use values greater than the maximum local work group size. */
>> + glGetIntegeri_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 0, &v[0]);
>> + glGetIntegeri_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 1, &v[1]);
>> + glGetIntegeri_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 2, &v[2]);
>> + glDispatchComputeGroupSizeARB(1, 1, 1, v[0] + 1, v[1] + 1, v[0] + 1);
>> + if (!piglit_check_gl_error(GL_INVALID_VALUE))
>> + return PIGLIT_FAIL;
>> + return PIGLIT_PASS;
>> +}
>> +
>> +static enum piglit_result
>> +use_invalid_variable_group_invocations_values()
>> +{
>> + /* From the ARB_compute_variable_group_size spec:
>> + *
>> + * An INVALID_VALUE error is generated by
>> + * DispatchComputeGroupSizeARB if the product of <group_size_x>,
>> + * <group_size_y>, and <group_size_z> exceeds the
>> + * implementation-dependent maximum local work group invocation
>> + * count for compute shaders with variable group size
>> + * (MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB).
>> + */
>> + GLint prog, v;
>> +
>> + prog = piglit_build_simple_program_multiple_shaders(
>> + GL_COMPUTE_SHADER, variable_work_group_size_shader, 0);
>> + glUseProgram(prog);
>> +
>> + glGetIntegerv(GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB, &v);
>> + glDispatchComputeGroupSizeARB(1, 1, 1, v, v, v);
>> + if (!piglit_check_gl_error(GL_INVALID_VALUE))
>> + return PIGLIT_FAIL;
>> + return PIGLIT_PASS;
>> +}
>> +
>> +static const struct piglit_subtest subtests[] = {
>> + {
>> + "Use a variable work group size with DispatchCompute",
>> + "use_variable_work_group_size_normal",
>> + use_variable_work_group_size_normal,
>> + NULL
>> + },
>> + {
>> + "Use a variable work group size with DispatchComputeIndirect",
>> + "use_variable_work_group_size_indirect",
>> + use_variable_work_group_size_indirect,
>> + NULL
>> + },
>> +
>> + {
>> + "Use a fixed work group size with DispatchComputeGroupSizeARB",
>> + "use_fixed_work_group_size",
>> + use_fixed_work_group_size,
>> + NULL
>> + },
>> + {
>> + "Use invalid variable work group size values",
>> + "use_invalid_variable_work_group_size_values",
>> + use_invalid_variable_work_group_size_values,
>> + NULL
>> + },
>> + {
>> + "Use invalid variable group invocations values",
>> + "use_invalid_variable_group_invocations_values",
>> + use_invalid_variable_group_invocations_values,
>> + NULL
>> + },
>> + {
>> + NULL,
>> + NULL,
>> + NULL,
>> + NULL
>> + }
>> +};
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> + return PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + enum piglit_result result;
>> +
>> + piglit_require_extension("GL_ARB_compute_variable_group_size");
>> + result = piglit_run_selected_subtests(subtests,
>> + piglit_config->selected_subtests,
>> + piglit_config->num_selected_subtests,
>> + PIGLIT_SKIP);
>> + piglit_report_result(result);
>> +}
>> diff --git a/tests/spec/arb_compute_variable_group_size/linker/mixed_fixed_variable_local_work_size.shader_test b/tests/spec/arb_compute_variable_group_size/linker/mixed_fixed_variable_local_work_size.shader_test
>> new file mode 100644
>> index 0000000..718caba
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/linker/mixed_fixed_variable_local_work_size.shader_test
>> @@ -0,0 +1,36 @@
>> +# From the ARB_compute_variable_group_size spec:
>> +#
>> +# If one compute shader attached to a program declares a variable local
>> +# group size and a second compute shader attached to the same program
>> +# declares a fixed local group size, a link-time error results.
>> +
>> +[require]
>> +GL >= 3.3
>> +GLSL >= 3.30
>> +GL_ARB_compute_shader
>> +
>> +[compute shader]
>> +#version 330
>> +#extension GL_ARB_compute_shader: enable
>> +
>> +layout(local_size_x = 2) in;
>> +
>> +void foo();
>> +
>> +void main()
>> +{
>> + foo();
>> +}
>> +
>> +[compute shader]
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +
>> +layout(local_size_variable) in;
>> +
>> +void foo()
>> +{
>> +}
>> +
>> +[test]
>> +link error
>> diff --git a/tests/spec/arb_compute_variable_group_size/linker/no_local_size_specified.shader_test b/tests/spec/arb_compute_variable_group_size/linker/no_local_size_specified.shader_test
>> new file mode 100644
>> index 0000000..8011359
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/linker/no_local_size_specified.shader_test
>> @@ -0,0 +1,32 @@
>> +# From the ARB_compute_variable_group_size spec:
>> +#
>> +# Furthermore, if a program object contains any compute shaders, at least
>> +# one must contain an input layout qualifier specifying a fixed or variable
>> +# local group size for the program, or a link-time error will occur.
>> +
>> +[require]
>> +GL >= 3.3
>> +GLSL >= 3.30
>> +GL_ARB_compute_shader
>> +
>> +[compute shader]
>> +#version 330
>> +#extension GL_ARB_compute_shader: enable
>> +
>> +void foo();
>> +
>> +void main()
>> +{
>> + foo();
>> +}
>> +
>> +[compute shader]
>> +#version 330
>> +#extension GL_ARB_compute_variable_group_size: enable
>> +
>> +void foo()
>> +{
>> +}
>> +
>> +[test]
>> +link error
>> diff --git a/tests/spec/arb_compute_variable_group_size/minmax.c b/tests/spec/arb_compute_variable_group_size/minmax.c
>> new file mode 100644
>> index 0000000..cd8f1ea
>> --- /dev/null
>> +++ b/tests/spec/arb_compute_variable_group_size/minmax.c
>> @@ -0,0 +1,65 @@
>> +/*
>> + * Copyright © 2016 Samuel Pitoiset
>> + *
>> + * 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
>> + *
>> + * Test for the minimum maximum values specified in the
>> + * ARB_compute_variable_group_size extension.
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +#include "minmax-test.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> + config.supports_gl_compat_version = 33;
>> + config.supports_gl_core_version = 33;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> + /* UNREACHED */
>> + return PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + piglit_require_extension("GL_ARB_compute_variable_group_size");
>> + piglit_print_minmax_header();
>> +
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 0, 512);
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 1, 512);
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB, 2, 64);
>> + piglit_test_min_int(GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB, 512);
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB, 0, 1024);
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB, 1, 1024);
>> + piglit_test_min_int_v(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB, 2, 64);
>> + piglit_test_min_int(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, 1024);
>> +
>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>> + piglit_report_result(PIGLIT_FAIL);
>> + piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
>> +}
>>
>
More information about the Piglit
mailing list