diff options
author | Miklós Máté <mtmkls@gmail.com> | 2017-12-02 23:36:02 +0100 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2018-01-03 16:57:09 -0800 |
commit | 7961fd1c57664688be60175445de0f6b14711395 (patch) | |
tree | 17448377e7643a3a75ececa183a53db07eba74a3 /tests | |
parent | 740ef3f21b1a2598d840ac4b847fc3bafa79b2c8 (diff) |
ATI_fs: add api error tests
One for each paragraph in the Errors section of the spec.
v2: don't exit on first failure, improve some tests, move spec quotes
to top, add license headers, drop redundant error checks, add build
system integration, add tests to all.py
Signed-off-by: Miklós Máté <mtmkls@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'tests')
18 files changed, 1953 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 5a1368a8e..b87ed49c1 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1891,6 +1891,20 @@ with profile.test_list.group_manager( PiglitGLTest, grouptools.join('spec', 'ATI_fragment_shader')) as g: g(['ati-fs-bad-delete']) + g(['ati_fragment_shader-error01-genzero']) + g(['ati_fragment_shader-error02-inside']) + g(['ati_fragment_shader-error03-outside']) + g(['ati_fragment_shader-error04-endshader']) + g(['ati_fragment_shader-error05-passes']) + g(['ati_fragment_shader-error06-regswizzle']) + g(['ati_fragment_shader-error07-instcount']) + g(['ati_fragment_shader-error08-secondary']) + g(['ati_fragment_shader-error09-allconst']) + g(['ati_fragment_shader-error10-dotx']) + g(['ati_fragment_shader-error11-invaliddst']) + g(['ati_fragment_shader-error12-invalidsrc']) + g(['ati_fragment_shader-error13-invalidarg']) + g(['ati_fragment_shader-error14-invalidmod']) # Group ARB_framebuffer_object with profile.test_list.group_manager( diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 92b83518d..360d0157b 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -82,6 +82,7 @@ add_subdirectory (arb_transform_feedback3) add_subdirectory (arb_transform_feedback_overflow_query) add_subdirectory (arb_viewport_array) add_subdirectory (ati_envmap_bumpmap) +add_subdirectory (ati_fragment_shader) add_subdirectory (ext_depth_bounds_test) add_subdirectory (ext_frag_depth) add_subdirectory (ext_fog_coord) diff --git a/tests/spec/ati_fragment_shader/CMakeLists.gl.txt b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt new file mode 100644 index 000000000..f0d578157 --- /dev/null +++ b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt @@ -0,0 +1,26 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} +) + +piglit_add_executable (ati_fragment_shader-error01-genzero error01-genzero.c) +piglit_add_executable (ati_fragment_shader-error02-inside error02-inside.c) +piglit_add_executable (ati_fragment_shader-error03-outside error03-outside.c) +piglit_add_executable (ati_fragment_shader-error04-endshader error04-endshader.c) +piglit_add_executable (ati_fragment_shader-error05-passes error05-passes.c) +piglit_add_executable (ati_fragment_shader-error06-regswizzle error06-regswizzle.c) +piglit_add_executable (ati_fragment_shader-error07-instcount error07-instcount.c) +piglit_add_executable (ati_fragment_shader-error08-secondary error08-secondary.c) +piglit_add_executable (ati_fragment_shader-error09-allconst error09-allconst.c) +piglit_add_executable (ati_fragment_shader-error10-dotx error10-dotx.c) +piglit_add_executable (ati_fragment_shader-error11-invaliddst error11-invaliddst.c) +piglit_add_executable (ati_fragment_shader-error12-invalidsrc error12-invalidsrc.c) +piglit_add_executable (ati_fragment_shader-error13-invalidarg error13-invalidarg.c) +piglit_add_executable (ati_fragment_shader-error14-invalidmod error14-invalidmod.c) + +# vim: ft=cmake: diff --git a/tests/spec/ati_fragment_shader/CMakeLists.txt b/tests/spec/ati_fragment_shader/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/ati_fragment_shader/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/ati_fragment_shader/error01-genzero.c b/tests/spec/ati_fragment_shader/error01-genzero.c new file mode 100644 index 000000000..99638370e --- /dev/null +++ b/tests/spec/ati_fragment_shader/error01-genzero.c @@ -0,0 +1,66 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 1 of the Errors section: + * + * The error INVALID_VALUE is generated if GenFragmentShadersATI is + * called where <range> is zero. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + unsigned id; + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + id = glGenFragmentShadersATI(0); + pass &= piglit_check_gl_error(GL_INVALID_VALUE); + + /* The spec also says that 0 is returned */ + if (id != 0) + pass = false; + + /* Note that the spec also says that no shaders are generated, + * but there is no way of testing that + */ + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error02-inside.c b/tests/spec/ati_fragment_shader/error02-inside.c new file mode 100644 index 000000000..c1191de25 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error02-inside.c @@ -0,0 +1,71 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 2 of the Errors section: + * + * The error INVALID_OPERATION is generated if GenFragmentShadersATI, + * BindFragmentShaderATI, DeleteFragmentShaderATI, or + * BeginFragmentShaderATI are specified inside a + * Begin/EndFragmentShaderATI pair. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + glBeginFragmentShaderATI(); + + pass &= piglit_check_gl_error(GL_NO_ERROR); + glGenFragmentShadersATI(1); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBindFragmentShaderATI(2); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glDeleteFragmentShaderATI(3); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error03-outside.c b/tests/spec/ati_fragment_shader/error03-outside.c new file mode 100644 index 000000000..48e130f42 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error03-outside.c @@ -0,0 +1,95 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 3 of the Errors section: + * + * The error INVALID_OPERATION is generated if EndFragmentShaderATI, + * PassTexCoordATI, SampleMapATI, ColorFragmentOp[1..3]ATI, or + * AlphaFragmentOp[1..3]ATI is specified outside a + * Begin/EndFragmentShaderATI pair. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glColorFragmentOp3ATI(GL_MAD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_REG_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glAlphaFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glAlphaFragmentOp3ATI(GL_MAD_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_REG_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error04-endshader.c b/tests/spec/ati_fragment_shader/error04-endshader.c new file mode 100644 index 000000000..005a560a8 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error04-endshader.c @@ -0,0 +1,146 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 4 of the Errors section: + * + * The error INVALID_OPERATION is generated by EndFragmentShaderATI if + * <argN> passed to ColorFragmentOp[1..3]ATI or + * AlphaFragmentOp[1..3]ATI is PRIMARY_COLOR_ARB or + * SECONDARY_INTERPOLATOR_ATI on the first pass of a two-pass shader, + * or if the shader cannot be compiled due to some other + * implementation-dependent limitation. EndFragmentShaderATI will + * still have a side-effect if this error is encountered: the + * Begin/EndFragmentShaderATI pair will be closed, and the current + * shader will be undefined. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* use GL_PRIMARY_COLOR_ARB in the first pass */ + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* see if EndFragmentShaderATI really ended the shader */ + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* use GL_SECONDARY_INTERPOLATOR_ATI in the first pass */ + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* see if EndFragmentShaderATI really ended the shader */ + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* use them in a single-pass shader */ + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + /* use them in the second pass */ + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + /* use color in first pass, but the instruction is not added because + * the other argument is invalid, so EndFragmentShader should not + * complain about color in first pass */ + glBeginFragmentShaderATI(); + glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE, + GL_TEXTURE0_ARB, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_ENUM); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + /* use color, then start a second pass, but the PassTexCoord is + * invalid, so it should register as a valid single pass shader */ + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_TEXTURE0_ARB, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_ENUM); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + /* TODO what implementation-dependent limitation to check here? */ + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error05-passes.c b/tests/spec/ati_fragment_shader/error05-passes.c new file mode 100644 index 000000000..35ef65be4 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error05-passes.c @@ -0,0 +1,140 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 5 of the Errors section: + * + * The error INVALID_OPERATION is generated by PassTexCoordATI or + * SampleMapATI if two shader passes have already been specified, or if + * the same <dst> register is specified twice in the same pass. + */ + +#include "piglit-util-gl.h" + +static struct piglit_gl_test_config *piglit_config; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + piglit_config = &config; + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +static enum piglit_result +too_many_passes(void *data) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static enum piglit_result +same_reg_written_twice(void *data) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static const struct piglit_subtest subtests[] = { + { + "Too many passes", + "too-many-passes", + too_many_passes, + NULL + }, + { + "Same reg written twice", + "same-reg-written-twice", + same_reg_written_twice, + NULL + }, + { + NULL, + NULL, + NULL, + NULL + } +}; + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ATI_fragment_shader"); + + piglit_report_result(piglit_run_selected_subtests(subtests, + piglit_config->selected_subtests, + piglit_config->num_selected_subtests, + PIGLIT_SKIP)); +} diff --git a/tests/spec/ati_fragment_shader/error06-regswizzle.c b/tests/spec/ati_fragment_shader/error06-regswizzle.c new file mode 100644 index 000000000..978d3b6c8 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error06-regswizzle.c @@ -0,0 +1,322 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 6 of the Errors section: + * + * The error INVALID_OPERATION is generated by PassTexCoordATI or + * SampleMapATI if <coord> passed to PassTexCoordATI or <interp> passed + * to SampleMapATI is a register in the first pass, or a register with + * SWIZZLE_STQ_ATI or SWIZZLE_STQ_DQ_ATI <swizzle> in the second pass, + * or if different <swizzle> parameters are specified for the same + * <coord> or <interp> in the same pass. + */ + +/* Note that the spec is sloppy at the last part. Only STR and STQ are + * incompatible, but e.g. STR and STR_DR are not. This only applies to + * texture sources, but not to registers. And instead of "same pass" it + * should read "same shader". + * See r200_fragshader.c:333 + */ + +#include "piglit-util-gl.h" + +static struct piglit_gl_test_config *piglit_config; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + piglit_config = &config; + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +static enum piglit_result +reg_src_in_first_pass(void *data) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static enum piglit_result +stq_swizzle_on_reg(void *data) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_DQ_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_DQ_ATI); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static bool +check_swizzle_passtexcoord(unsigned src, unsigned swizzle1, unsigned swizzle2, unsigned error) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, src, swizzle1); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_1_ATI, src, swizzle2); + pass &= piglit_check_gl_error(error); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + return pass; +} + +static enum piglit_result +different_swizzle_on_same_tex_passtexcoord(void *data) +{ + bool pass = true; + + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR); + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STR_DR_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_NO_ERROR); + pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_DR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static bool +check_swizzle_samplemap(unsigned src, unsigned swizzle1, unsigned swizzle2, unsigned error) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glPassTexCoordATI(GL_REG_0_ATI, src, swizzle1); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glSampleMapATI(GL_REG_1_ATI, src, swizzle2); + pass &= piglit_check_gl_error(error); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + return pass; +} + +static enum piglit_result +different_swizzle_on_same_tex_samplemap(void *data) +{ + bool pass = true; + + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR); + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STR_DR_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_NO_ERROR); + pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_DR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static enum piglit_result +different_swizzle_on_same_reg(void *data) +{ + bool pass = true; + + pass &= check_swizzle_passtexcoord(GL_REG_0_ATI, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR); + pass &= check_swizzle_samplemap(GL_REG_0_ATI, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static bool check_swizzle_2pass(bool samplemap, unsigned swizzle1, unsigned swizzle2, unsigned error) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + if (samplemap) + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, swizzle1); + else + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, swizzle1); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + if (samplemap) + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, swizzle2); + else + glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, swizzle2); + pass &= piglit_check_gl_error(error); + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + return pass; +} + +static enum piglit_result +different_swizzle_in_different_pass(void *data) +{ + bool pass = true; + + pass &= check_swizzle_2pass(false, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION); + pass &= check_swizzle_2pass(true, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +static const struct piglit_subtest subtests[] = { + { + "REG source in first pass", + "reg-src-in-first-pass", + reg_src_in_first_pass, + NULL + }, + { + "STQ swizzle on REG", + "stq-swizzle-on-reg", + stq_swizzle_on_reg, + NULL + }, + { + "Different swizzle on the same TEX in PassTexCoord", + "different_swizzle_on_same_tex_passtexcoord", + different_swizzle_on_same_tex_passtexcoord, + NULL + }, + { + "Different swizzle on the same TEX in SampleMap", + "different_swizzle_on_same_tex_samplemap", + different_swizzle_on_same_tex_samplemap, + NULL + }, + { + "Different swizzle on the same REG", + "different_swizzle_on_same_reg", + different_swizzle_on_same_reg, + NULL + }, + { + "Different swizzle in different pass", + "different_swizzle_in_different_pass", + different_swizzle_in_different_pass, + NULL + }, + { + NULL, + NULL, + NULL, + NULL + } +}; + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ATI_fragment_shader"); + + piglit_report_result(piglit_run_selected_subtests(subtests, + piglit_config->selected_subtests, + piglit_config->num_selected_subtests, + PIGLIT_SKIP)); +} diff --git a/tests/spec/ati_fragment_shader/error07-instcount.c b/tests/spec/ati_fragment_shader/error07-instcount.c new file mode 100644 index 000000000..55f3f9915 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error07-instcount.c @@ -0,0 +1,104 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 7 of the Errors section: + * + * The error INVALID_OPERATION is generated by ColorFragmentOp[1..3]ATI + * or AlphaFragmentOp[1..3]ATI if more than 8 instructions have been + * specified for a shader pass. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +maxlength_pass(void) +{ + unsigned u; + + for (u=0; u<8; u++) { + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + } +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + glBeginFragmentShaderATI(); + maxlength_pass(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + maxlength_pass(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + maxlength_pass(); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + maxlength_pass(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + maxlength_pass(); + glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + maxlength_pass(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error08-secondary.c b/tests/spec/ati_fragment_shader/error08-secondary.c new file mode 100644 index 000000000..7e9d5c6fc --- /dev/null +++ b/tests/spec/ati_fragment_shader/error08-secondary.c @@ -0,0 +1,106 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 8 of the Errors section: + * + * The error INVALID_OPERATION is generated by ColorFragmentOp[1..3]ATI + * if <argN> is SECONDARY_INTERPOLATOR_ATI and <argNRep> is ALPHA, or + * by AlphaFragmentOp[1..3]ATI if <argN> is SECONDARY_INTERPOLATOR_ATI + * and <argNRep> is ALPHA or NONE, or by ColorFragmentOp2ATI if <op> is + * DOT4_ATI and <argN> is SECONDARY_INTERPOLATOR_ATI and <argNRep> is + * ALPHA or NONE. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* In all shaders all instructions are invalid, so the shader should + * be empty, which is invalid + */ + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* DOT4 */ + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE, + GL_REG_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error09-allconst.c b/tests/spec/ati_fragment_shader/error09-allconst.c new file mode 100644 index 000000000..ba5dbcfbf --- /dev/null +++ b/tests/spec/ati_fragment_shader/error09-allconst.c @@ -0,0 +1,100 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 9 of the Errors section: + * + * The error INVALID_OPERATION is generated by ColorFragmentOp3ATI or + * AlphaFragmentOp3ATI if all three <argN> parameters are constants, + * and all three are different. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* In these shaders all instructions are invalid, so the shader should + * be empty, which is invalid + */ + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* No error if some of them are the same (not exhaustive test) */ + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_CON_0_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error10-dotx.c b/tests/spec/ati_fragment_shader/error10-dotx.c new file mode 100644 index 000000000..c112e7eeb --- /dev/null +++ b/tests/spec/ati_fragment_shader/error10-dotx.c @@ -0,0 +1,136 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 10 of the Errors section: + * + * The error INVALID_OPERATION is generated by AlphaFragmentOp[2..3]ATI + * if <op> is DOT3_ATI, DOT4_ATI, or DOT2_ADD_ATI and there was no + * matching ColorFragmentOp[2..3]ATI immediately preceding, or if <op> + * is not DOT4_ATI and the immediately preceding ColorFragmentOp2ATI + * specifies an <op> of DOT4_ATI. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* nothing before it */ + + /* In these shaders all instructions are invalid, so the shader should + * be empty, which is invalid + */ + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* mismatching color op before it */ + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + glBeginFragmentShaderATI(); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + /* after color DOT4 the alpha is not DOT4 */ + + glBeginFragmentShaderATI(); + glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_CON_3_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glAlphaFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, + GL_CON_2_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + glEndFragmentShaderATI(); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error11-invaliddst.c b/tests/spec/ati_fragment_shader/error11-invaliddst.c new file mode 100644 index 000000000..11555e15c --- /dev/null +++ b/tests/spec/ati_fragment_shader/error11-invaliddst.c @@ -0,0 +1,175 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 11 of the Errors section: + * + * The error INVALID_ENUM is generated if <dst> passed to + * PassTexCoordATI, SampleMapATI, ColorFragmentOp[1..3]ATI, or + * AlphaFragmentOp[1..3]ATI is not a valid register or is greater than + * the number of texture units available on the implementation. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +#define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \ + { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; } + +bool +try_enum(unsigned e) +{ + bool pass = true; + + printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(e, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + check_enum_error(e); + + glSampleMapATI(e, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + check_enum_error(e); + + glColorFragmentOp1ATI(GL_MOV_ATI, e, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + check_enum_error(e); + + glAlphaFragmentOp1ATI(GL_MOV_ATI, e, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + check_enum_error(e); + glEndFragmentShaderATI(); + /* All instructions were invalid, so the shader should be empty, + * which is invalid + */ + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* TODO check fragment ops with more arguments? */ + + return pass; +} + +/* Trying all possible enum values is overkill, only try ones that are + * used in fragment shaders, thus being common user errors. + * Note that some of them have the same numeric value. + */ +static const unsigned enums[] = { + GL_CON_0_ATI, + GL_CON_1_ATI, + GL_CON_2_ATI, + GL_CON_3_ATI, + GL_CON_4_ATI, + GL_CON_5_ATI, + GL_CON_6_ATI, + GL_CON_7_ATI, + GL_MOV_ATI, + GL_ADD_ATI, + GL_MUL_ATI, + GL_SUB_ATI, + GL_DOT3_ATI, + GL_DOT4_ATI, + GL_MAD_ATI, + GL_LERP_ATI, + GL_CND_ATI, + GL_CND0_ATI, + GL_DOT2_ADD_ATI, + GL_SECONDARY_INTERPOLATOR_ATI, + GL_SWIZZLE_STR_ATI, + GL_SWIZZLE_STQ_ATI, + GL_SWIZZLE_STR_DR_ATI, + GL_SWIZZLE_STQ_DQ_ATI, + GL_SWIZZLE_STRQ_ATI, + GL_SWIZZLE_STRQ_DQ_ATI, + GL_RED_BIT_ATI, + GL_GREEN_BIT_ATI, + GL_BLUE_BIT_ATI, + GL_2X_BIT_ATI, + GL_4X_BIT_ATI, + GL_8X_BIT_ATI, + GL_HALF_BIT_ATI, + GL_QUARTER_BIT_ATI, + GL_EIGHTH_BIT_ATI, + GL_SATURATE_BIT_ATI, + GL_COMP_BIT_ATI, + GL_NEGATE_BIT_ATI, + GL_BIAS_BIT_ATI, + GL_TEXTURE0_ARB, + GL_TEXTURE1_ARB, + GL_TEXTURE2_ARB, + GL_TEXTURE3_ARB, + GL_TEXTURE4_ARB, + GL_TEXTURE5_ARB, + GL_TEXTURE6_ARB, + GL_TEXTURE7_ARB, + GL_PRIMARY_COLOR_ARB, + GL_NONE, + GL_RED, + GL_GREEN, + GL_BLUE, + GL_ALPHA, +}; + +void +piglit_init(int argc, char **argv) +{ + int num_tex_units; + unsigned i; + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* The spec defines the number of registers to be fixed at 6, even + * though the enum values are defined up to 31 in glext.h. According + * to the paragraph above, when an implementation has less than 6 + * texture units, glSampleMapATI(GL_REG_5_ATI, ...) is invalid. + * + * However, Doom3 uses 6 textures and 6 texcoords, so an implementation + * that supports less than 6 textures is not able to run it. Let's fail + * if it's less than 6. + */ + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &num_tex_units); + if (num_tex_units < 6) { + printf("Max texture units %d < 6 is not enough for ATI_fragment_shader\n", num_tex_units); + piglit_report_result(PIGLIT_FAIL); + } + + /* Try some invalid enums */ + + for (i=0; i<ARRAY_SIZE(enums); i++) + if (!try_enum(enums[i])) + pass = false; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error12-invalidsrc.c b/tests/spec/ati_fragment_shader/error12-invalidsrc.c new file mode 100644 index 000000000..5e2a64119 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error12-invalidsrc.c @@ -0,0 +1,163 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 12 of the Errors section: + * + * The error INVALID_ENUM is generated if <coord> passed to + * PassTexCoordATI or <interp> passed to SampleMapATI is not a valid + * register or texture unit, or the register or texture unit is greater + * than the number of texture units available on the implementation. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +#define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \ + { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; } + +bool +try_enum(unsigned e) +{ + bool pass = true; + + printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glPassTexCoordATI(GL_REG_0_ATI, e, GL_SWIZZLE_STR_ATI); + check_enum_error(e); + + glSampleMapATI(GL_REG_0_ATI, e, GL_SWIZZLE_STR_ATI); + check_enum_error(e); + + /* note: Mesa requires at least 1 arith instruction per pass, + * but this is not in the spec */ + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + pass &= piglit_check_gl_error(GL_NO_ERROR); + + return pass; +} + +/* Trying all possible enum values is overkill, only try ones that are + * used in fragment shaders, thus being common user errors. + * Note that some of them have the same numeric value. + */ +static const unsigned enums[] = { + GL_CON_0_ATI, + GL_CON_1_ATI, + GL_CON_2_ATI, + GL_CON_3_ATI, + GL_CON_4_ATI, + GL_CON_5_ATI, + GL_CON_6_ATI, + GL_CON_7_ATI, + GL_MOV_ATI, + GL_ADD_ATI, + GL_MUL_ATI, + GL_SUB_ATI, + GL_DOT3_ATI, + GL_DOT4_ATI, + GL_MAD_ATI, + GL_LERP_ATI, + GL_CND_ATI, + GL_CND0_ATI, + GL_DOT2_ADD_ATI, + GL_SECONDARY_INTERPOLATOR_ATI, + GL_SWIZZLE_STR_ATI, + GL_SWIZZLE_STQ_ATI, + GL_SWIZZLE_STR_DR_ATI, + GL_SWIZZLE_STQ_DQ_ATI, + GL_SWIZZLE_STRQ_ATI, + GL_SWIZZLE_STRQ_DQ_ATI, + GL_RED_BIT_ATI, + GL_GREEN_BIT_ATI, + GL_BLUE_BIT_ATI, + GL_2X_BIT_ATI, + GL_4X_BIT_ATI, + GL_8X_BIT_ATI, + GL_HALF_BIT_ATI, + GL_QUARTER_BIT_ATI, + GL_EIGHTH_BIT_ATI, + GL_SATURATE_BIT_ATI, + GL_COMP_BIT_ATI, + GL_NEGATE_BIT_ATI, + GL_BIAS_BIT_ATI, + GL_PRIMARY_COLOR_ARB, + GL_NONE, + GL_RED, + GL_GREEN, + GL_BLUE, + GL_ALPHA, +}; + +void +piglit_init(int argc, char **argv) +{ + int num_tex_coords; + unsigned i; + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + /* The spec lists texture coordinates up to GL_TEXTURE7_ARB. + * According to the above paragraph, when an implementation supports + * less than 8 texture coordinates + * glSampleMapATI(GL_REG_x_ATI, GL_TEXTURE7_ARB, ...) is invalid. + * + * Doom3 uses 6 textures and 6 texcoords, so an implementation + * that supports less than 6 texcoords is not able to run it. Let's + * fail if it's less than 6, and do some checks if it's less than 8. + */ + glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &num_tex_coords); + if (num_tex_coords < 6) { + printf("Max texture coordinate interpolators %d < 6 is not enough for ATI_fragment_shader\n", num_tex_coords); + piglit_report_result(PIGLIT_FAIL); + } else if (num_tex_coords < 8) { + if (!try_enum(GL_TEXTURE7_ARB)) + pass = false; + } + + /* Try some invalid enums */ + + for (i=0; i<ARRAY_SIZE(enums); i++) + if (!try_enum(enums[i])) + pass = false; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error13-invalidarg.c b/tests/spec/ati_fragment_shader/error13-invalidarg.c new file mode 100644 index 000000000..c787971d6 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error13-invalidarg.c @@ -0,0 +1,140 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 13 of the Errors section: + * + * The error INVALID_ENUM is generated if <argN> passed to + * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI is not a valid + * constant, interpolator, or register. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +#define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \ + { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; } + +bool +try_enum(unsigned e) +{ + bool pass = true; + + printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e); + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, + e, GL_NONE, GL_NONE); + check_enum_error(e); + + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, + e, GL_NONE, GL_NONE); + check_enum_error(e); + glEndFragmentShaderATI(); + /* All instructions were invalid, so the shader should be empty, + * which is invalid + */ + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* TODO check fragment ops with more arguments? */ + + return pass; +} + +/* Trying all possible enum values is overkill, only try ones that are + * used in fragment shaders, thus being common user errors. + * Note that some of them have the same numeric value. + */ +static const unsigned enums[] = { + GL_MOV_ATI, + GL_ADD_ATI, + GL_MUL_ATI, + GL_SUB_ATI, + GL_DOT3_ATI, + GL_DOT4_ATI, + GL_MAD_ATI, + GL_LERP_ATI, + GL_CND_ATI, + GL_CND0_ATI, + GL_DOT2_ADD_ATI, + GL_SWIZZLE_STR_ATI, + GL_SWIZZLE_STQ_ATI, + GL_SWIZZLE_STR_DR_ATI, + GL_SWIZZLE_STQ_DQ_ATI, + GL_SWIZZLE_STRQ_ATI, + GL_SWIZZLE_STRQ_DQ_ATI, + /*GL_RED_BIT_ATI,*/ + GL_GREEN_BIT_ATI, + GL_BLUE_BIT_ATI, + /*GL_2X_BIT_ATI,*/ + GL_4X_BIT_ATI, + GL_8X_BIT_ATI, + GL_HALF_BIT_ATI, + GL_QUARTER_BIT_ATI, + GL_EIGHTH_BIT_ATI, + GL_SATURATE_BIT_ATI, + GL_COMP_BIT_ATI, + GL_NEGATE_BIT_ATI, + GL_BIAS_BIT_ATI, + GL_TEXTURE0_ARB, + GL_TEXTURE1_ARB, + GL_TEXTURE2_ARB, + GL_TEXTURE3_ARB, + GL_TEXTURE4_ARB, + GL_TEXTURE5_ARB, + GL_TEXTURE6_ARB, + GL_TEXTURE7_ARB, + /*GL_NONE,*/ + GL_RED, + GL_GREEN, + GL_BLUE, + GL_ALPHA, +}; + +void +piglit_init(int argc, char **argv) +{ + unsigned i = 0; + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + for (i=0; i<ARRAY_SIZE(enums); i++) + if (!try_enum(enums[i])) + pass = false; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ati_fragment_shader/error14-invalidmod.c b/tests/spec/ati_fragment_shader/error14-invalidmod.c new file mode 100644 index 000000000..6b0899905 --- /dev/null +++ b/tests/spec/ati_fragment_shader/error14-invalidmod.c @@ -0,0 +1,147 @@ +/* + * Copyright © 2017 Miklós Máté + * + * 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. + */ + +/** Paragraph 14 of the Errors section: + * + * The error INVALID_ENUM is generated if <dstMod> passed to + * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI contains + * multiple mutually exclusive modifier bits, not counting + * SATURATE_BIT_ATI. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +#define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \ + { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; } +#define check_enum_good(en) if (!piglit_check_gl_error(GL_NO_ERROR)) \ + { printf("Enum %s 0x%x rejected\n", piglit_get_gl_enum_name(en), en); pass = false; } + +bool +try_enum(unsigned e) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e, + GL_REG_0_ATI, GL_NONE, GL_NONE); + check_enum_error(e); + + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e, + GL_REG_0_ATI, GL_NONE, GL_NONE); + check_enum_error(e); + glEndFragmentShaderATI(); + /* All instructions were invalid, so the shader should be empty, + * which is invalid + */ + pass &= piglit_check_gl_error(GL_INVALID_OPERATION); + + /* TODO check fragment ops with more arguments? */ + + return pass; +} + +static const unsigned enums[] = { + GL_2X_BIT_ATI | GL_4X_BIT_ATI, + GL_2X_BIT_ATI | GL_8X_BIT_ATI, + GL_2X_BIT_ATI | GL_HALF_BIT_ATI, + GL_2X_BIT_ATI | GL_QUARTER_BIT_ATI, + GL_2X_BIT_ATI | GL_EIGHTH_BIT_ATI, + GL_4X_BIT_ATI | GL_8X_BIT_ATI, + GL_4X_BIT_ATI | GL_HALF_BIT_ATI, + GL_4X_BIT_ATI | GL_QUARTER_BIT_ATI, + GL_4X_BIT_ATI | GL_EIGHTH_BIT_ATI, + GL_8X_BIT_ATI | GL_HALF_BIT_ATI, + GL_8X_BIT_ATI | GL_QUARTER_BIT_ATI, + GL_8X_BIT_ATI | GL_EIGHTH_BIT_ATI, + GL_HALF_BIT_ATI | GL_QUARTER_BIT_ATI, + GL_HALF_BIT_ATI | GL_EIGHTH_BIT_ATI, + GL_QUARTER_BIT_ATI | GL_EIGHTH_BIT_ATI, +}; + +bool try_compatible_enum(unsigned e) +{ + bool pass = true; + + glBeginFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e, + GL_REG_0_ATI, GL_NONE, GL_NONE); + check_enum_good(e); + + glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e, + GL_REG_0_ATI, GL_NONE, GL_NONE); + check_enum_good(e); + glEndFragmentShaderATI(); + pass &= piglit_check_gl_error(GL_NO_ERROR); + + /* TODO check fragment ops with more arguments? */ + + return pass; +} + +static const unsigned good_enums[] = { + GL_2X_BIT_ATI | GL_SATURATE_BIT_ATI, + GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI, + GL_8X_BIT_ATI | GL_SATURATE_BIT_ATI, + GL_HALF_BIT_ATI | GL_SATURATE_BIT_ATI, + GL_QUARTER_BIT_ATI | GL_SATURATE_BIT_ATI, + GL_EIGHTH_BIT_ATI | GL_SATURATE_BIT_ATI, +}; + +void +piglit_init(int argc, char **argv) +{ + unsigned i; + bool pass = true; + + piglit_require_extension("GL_ATI_fragment_shader"); + + for (i=0; i<ARRAY_SIZE(enums); i++) { + if (!try_enum(enums[i])) + pass = false; + if (!try_enum(enums[i] | GL_SATURATE_BIT_ATI)) + pass = false; + } + + /* test that all the mods are compatible with SATURATE */ + for (i=0; i<ARRAY_SIZE(good_enums); i++) + if (!try_compatible_enum(good_enums[i])) + pass = false; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} |