diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-06-22 17:49:04 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-08-03 13:04:19 -0700 |
commit | 33e51571e481aa123232bc96488b029aea988180 (patch) | |
tree | 79371d55fa42b4df83d5e14e37c44a02d13d99a2 /generated_tests | |
parent | 4e06c74956d8a77bbb0da4da1cf71e98682a3ec1 (diff) |
generators: use main function in gen_shader_image_load_store_tests
This is a) good practice, b) fixes potential issues on windows, and c)
makes testing easier.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'generated_tests')
-rw-r--r-- | generated_tests/gen_shader_image_load_store_tests.py | 1076 |
1 files changed, 541 insertions, 535 deletions
diff --git a/generated_tests/gen_shader_image_load_store_tests.py b/generated_tests/gen_shader_image_load_store_tests.py index 8d6be9cd7..c30dac164 100644 --- a/generated_tests/gen_shader_image_load_store_tests.py +++ b/generated_tests/gen_shader_image_load_store_tests.py @@ -278,552 +278,558 @@ image_types = [ ] -# -# Test the preprocessor defines. -# -gen('preprocessor', """\ - ${header('pass')} +def main(): + """Main function.""" + # + # Test the preprocessor defines. + # + gen('preprocessor', """\ + ${header('pass')} + + #if !defined GL_ARB_shader_image_load_store + # error GL_ARB_shader_image_load_store is not defined + #elif GL_ARB_shader_image_load_store != 1 + # error GL_ARB_shader_image_load_store is not equal to 1 + #endif + + void main() + { + } + """, shader_stages) + + # + # Test the early_fragment_tests layout qualifier. + # + gen('early-fragment-tests', """\ + ${header('pass' if shader_stage == 'frag' and hunk == 'in' else 'fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Fragment shaders also allow the following layout qualifier on 'in' + * only (not with variable declarations): + * + * layout-qualifier-id + * early_fragment_tests" + */ + layout(early_fragment_tests) ${hunk}; + + void main() + { + } + """, product(shader_stages, [ + {'name': 'in', 'hunk': 'in'}, + {'name': 'out', 'hunk': 'out'}, + {'name': 'uniform', 'hunk': 'uniform uint u'}, + {'name': 'in-var', 'hunk': 'in float f'}, + {'name': 'uniform-buffer', 'hunk': 'uniform b { image2D img; }'} + ])) + + # + # Test image declarations. + # + gen('declaration-allowed', """\ + ${header('pass')} + /* + * From the ARB_shader_image_load_store spec: + * + * "[Images] can only be declared as function parameters or uniform + * variables." + */ + layout(rgba32f) uniform ${image_type} img; + layout(rgba32ui) uniform u${image_type} uimg; + layout(rgba32i) uniform i${image_type} iimg; + + void f(${image_type} arg, + u${image_type} uarg, + i${image_type} iarg) + { + } + + void main() + { + } + """, product(image_types, shader_stages)) + + gen('declaration-global', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "[Images] can only be declared as function parameters or uniform + * variables." + */ + layout(rgba32f) ${qualifier} image2D img; + + void main() + { + } + """, product(shader_stages, [ + {'name': 'const', 'qualifier': 'const'}, + {'name': 'in', 'qualifier': 'in'}, + {'name': 'out', 'qualifier': 'out'} + ])) + + gen('declaration-local', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "[Images] can only be declared as function parameters or uniform + * variables." + */ + void main() + { + layout(rgba32f) image2D img; + } + """, shader_stages) + + gen('declaration-uniform-block', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Sets of uniforms, except for samplers and images, can be grouped + * into uniform blocks." + */ + uniform b { + layout(rgba32f) image2D img; + }; - #if !defined GL_ARB_shader_image_load_store - # error GL_ARB_shader_image_load_store is not defined - #elif GL_ARB_shader_image_load_store != 1 - # error GL_ARB_shader_image_load_store is not equal to 1 - #endif + void main() + { + } + """, shader_stages) - void main() - { - } -""", shader_stages) + gen('declaration-argument', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Images cannot be treated as l-values; hence, they cannot be used + * as out or inout function parameters, nor can they be assigned + * into." + */ + void f(${qualifier} image2D y) + { + } + + void main() + { + } + """, product(shader_stages, [ + {'name': 'inout', 'qualifier': 'inout'}, + {'name': 'out', 'qualifier': 'out'} + ])) + + gen('declaration-initializer', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "[Images] cannot be declared with an initializer in a shader." + */ + layout(rgba32f) uniform image2D img = 0; -# -# Test the early_fragment_tests layout qualifier. -# -gen('early-fragment-tests', """\ - ${header('pass' if shader_stage == 'frag' and hunk == 'in' else 'fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Fragment shaders also allow the following layout qualifier on 'in' - * only (not with variable declarations): - * - * layout-qualifier-id - * early_fragment_tests" - */ - layout(early_fragment_tests) ${hunk}; - - void main() - { - } -""", product(shader_stages, [ - {'name': 'in', 'hunk': 'in'}, - {'name': 'out', 'hunk': 'out'}, - {'name': 'uniform', 'hunk': 'uniform uint u'}, - {'name': 'in-var', 'hunk': 'in float f'}, - {'name': 'uniform-buffer', 'hunk': 'uniform b { image2D img; }'} -])) + void main() + { + } + """, shader_stages) -# -# Test image declarations. -# -gen('declaration-allowed', """\ - ${header('pass')} - /* - * From the ARB_shader_image_load_store spec: - * - * "[Images] can only be declared as function parameters or uniform - * variables." - */ - layout(rgba32f) uniform ${image_type} img; - layout(rgba32ui) uniform u${image_type} uimg; - layout(rgba32i) uniform i${image_type} iimg; - - void f(${image_type} arg, - u${image_type} uarg, - i${image_type} iarg) - { - } + gen('declaration-format-qualifier', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "It is an error to declare an image variable where the format + * qualifier does not match the image variable type." + */ + layout(${format}) uniform ${prefix}${image_type} img; + + void main() + { + } + """, product(image_types, shader_stages, [ + {'name': 'float', + 'format': 'rgba32f', + 'prefix': 'i'}, + {'name': 'int', + 'format': 'rgba32i', + 'prefix': 'u'}, + {'name': 'uint', + 'format': 'rgba32ui', + 'prefix': ''} + ])) + + gen('declaration-format-qualifier-duplicate', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Only one format qualifier may be specified for any image variable + * declaration." + */ + layout(rgba32f) layout(rgba32f) uniform image2D img; - void main() - { - } -""", product(image_types, shader_stages)) - -gen('declaration-global', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "[Images] can only be declared as function parameters or uniform - * variables." - */ - layout(rgba32f) ${qualifier} image2D img; - - void main() - { - } -""", product(shader_stages, [ - {'name': 'const', 'qualifier': 'const'}, - {'name': 'in', 'qualifier': 'in'}, - {'name': 'out', 'qualifier': 'out'} -])) - -gen('declaration-local', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "[Images] can only be declared as function parameters or uniform - * variables." - */ - void main() - { - layout(rgba32f) image2D img; - } -""", shader_stages) - -gen('declaration-uniform-block', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Sets of uniforms, except for samplers and images, can be grouped - * into uniform blocks." - */ - uniform b { - layout(rgba32f) image2D img; - }; - - void main() - { - } -""", shader_stages) - -gen('declaration-argument', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Images cannot be treated as l-values; hence, they cannot be used - * as out or inout function parameters, nor can they be assigned - * into." - */ - void f(${qualifier} image2D y) - { - } + void main() + { + } + """, shader_stages) - void main() - { - } -""", product(shader_stages, [ - {'name': 'inout', 'qualifier': 'inout'}, - {'name': 'out', 'qualifier': 'out'} -])) - -gen('declaration-initializer', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "[Images] cannot be declared with an initializer in a shader." - */ - layout(rgba32f) uniform image2D img = 0; - - void main() - { - } -""", shader_stages) - -gen('declaration-format-qualifier', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "It is an error to declare an image variable where the format - * qualifier does not match the image variable type." - */ - layout(${format}) uniform ${prefix}${image_type} img; - - void main() - { - } -""", product(image_types, shader_stages, [ - {'name': 'float', - 'format': 'rgba32f', - 'prefix': 'i'}, - {'name': 'int', - 'format': 'rgba32i', - 'prefix': 'u'}, - {'name': 'uint', - 'format': 'rgba32ui', - 'prefix': ''} -])) - -gen('declaration-format-qualifier-duplicate', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Only one format qualifier may be specified for any image variable - * declaration." - */ - layout(rgba32f) layout(rgba32f) uniform image2D img; - - void main() - { - } -""", shader_stages) - -gen('declaration-format-qualifier-missing', """\ - ${header(status)} - /* - * From the ARB_shader_image_load_store spec: - * - * "Uniforms not qualified with "writeonly" must have a format - * layout qualifier." - */ - ${qualifier} uniform image2D img; - - void main() - { - } -""", product(shader_stages, [ - {'name': 'writeonly', - 'qualifier': 'writeonly', - 'status': 'pass'}, - {'name': 'readonly', - 'qualifier': 'readonly', - 'status': 'fail'}, - {'name': 'readwrite', - 'qualifier': '', - 'status': 'fail'} -])) - -gen('declaration-memory-qualifier-sampler', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Only variables declared as image types [...] can be qualified - * with a memory qualifier. " - */ - ${qualifier} uniform sampler2D s; - - void main() - { - } -""", product(shader_stages, [ - {'name': 'readonly', 'qualifier': 'readonly'}, - {'name': 'writeonly', 'qualifier': 'writeonly'}, - {'name': 'coherent', 'qualifier': 'coherent'}, - {'name': 'volatile', 'qualifier': 'volatile'}, - {'name': 'restrict', 'qualifier': 'restrict'} -])) + gen('declaration-format-qualifier-missing', """\ + ${header(status)} + /* + * From the ARB_shader_image_load_store spec: + * + * "Uniforms not qualified with "writeonly" must have a format + * layout qualifier." + */ + ${qualifier} uniform image2D img; + + void main() + { + } + """, product(shader_stages, [ + {'name': 'writeonly', + 'qualifier': 'writeonly', + 'status': 'pass'}, + {'name': 'readonly', + 'qualifier': 'readonly', + 'status': 'fail'}, + {'name': 'readwrite', + 'qualifier': '', + 'status': 'fail'} + ])) + + gen('declaration-memory-qualifier-sampler', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Only variables declared as image types [...] can be qualified + * with a memory qualifier. " + */ + ${qualifier} uniform sampler2D s; + + void main() + { + } + """, product(shader_stages, [ + {'name': 'readonly', 'qualifier': 'readonly'}, + {'name': 'writeonly', 'qualifier': 'writeonly'}, + {'name': 'coherent', 'qualifier': 'coherent'}, + {'name': 'volatile', 'qualifier': 'volatile'}, + {'name': 'restrict', 'qualifier': 'restrict'} + ])) + + # + # Test expressions involving images. + # + gen('expression-allowed', """\ + ${header('pass')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Except for array indexing, structure field selection, and + * parentheses, images are not allowed to be operands in + * expressions." + */ + layout(rgba32f) uniform ${image_type} imgs[2]; + uniform vec4 y; -# -# Test expressions involving images. -# -gen('expression-allowed', """\ - ${header('pass')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Except for array indexing, structure field selection, and - * parentheses, images are not allowed to be operands in - * expressions." - */ - layout(rgba32f) uniform ${image_type} imgs[2]; - uniform vec4 y; - - out vec4 color; - - void main() - { - color = y + imageLoad((imgs[1]) ${image_addr()}); - } -""", product(image_types[:1], shader_stages)) - -gen('expression', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Except for array indexing, structure field selection, and - * parentheses, images are not allowed to be operands in - * expressions." - */ - layout(rgba32f) uniform image2D img; - - void main() - { - ${expression}; - } -""", product(shader_stages, [ - {'name': 'arithmetic-1', 'expression': '-img'}, - {'name': 'arithmetic-2', 'expression': 'img + img'}, - {'name': 'arithmetic-3', 'expression': 'img - img'}, - {'name': 'arithmetic-4', 'expression': 'img * img'}, - {'name': 'arithmetic-5', 'expression': 'img / img'}, - {'name': 'arithmetic-6', 'expression': '++img'}, - {'name': 'arithmetic-7', 'expression': '--img'}, - {'name': 'arithmetic-8', 'expression': 'img++'}, - {'name': 'arithmetic-9', 'expression': 'img--'}, - {'name': 'assignment-1', 'expression': 'img ^= img'}, - {'name': 'assignment-2', 'expression': 'img |= img'}, - {'name': 'assignment-3', 'expression': 'img = img'}, - {'name': 'assignment-4', 'expression': 'img += img'}, - {'name': 'assignment-5', 'expression': 'img -= img'}, - {'name': 'assignment-6', 'expression': 'img *= img'}, - {'name': 'assignment-7', 'expression': 'img /= img'}, - {'name': 'assignment-8', 'expression': 'img %= img'}, - {'name': 'assignment-9', 'expression': 'img <<= img'}, - {'name': 'assignment-10', 'expression': 'img >>= img'}, - {'name': 'assignment-11', 'expression': 'img &= img'}, - {'name': 'binary-1', 'expression': '~img'}, - {'name': 'binary-2', 'expression': 'img << img'}, - {'name': 'binary-3', 'expression': 'img >> img'}, - {'name': 'binary-4', 'expression': 'img & img'}, - {'name': 'binary-5', 'expression': 'img | img'}, - {'name': 'binary-6', 'expression': 'img ^ img'}, - {'name': 'conversion-1', 'expression': 'float(img)'}, - {'name': 'conversion-2', 'expression': 'uint(img)'}, - {'name': 'conversion-3', 'expression': 'bool(img)'}, - {'name': 'conversion-4', 'expression': 'image1D(img)'}, - {'name': 'field-selection', 'expression': 'img.x'}, - {'name': 'function-call', 'expression': 'img()'}, - {'name': 'logical-1', 'expression': '!img'}, - {'name': 'logical-2', 'expression': 'img && img'}, - {'name': 'logical-3', 'expression': 'img || img'}, - {'name': 'logical-4', 'expression': 'img ^^ img'}, - {'name': 'relational-1', 'expression': 'img == img'}, - {'name': 'relational-2', 'expression': 'img != img'}, - {'name': 'relational-3', 'expression': 'img < img'}, - {'name': 'relational-4', 'expression': 'img > img'}, - {'name': 'relational-5', 'expression': 'img <= img'}, - {'name': 'relational-6', 'expression': 'img >= img'}, - {'name': 'selection', 'expression': 'true ? img : img'}, - {'name': 'subscript', 'expression': 'img[0]'} -])) + out vec4 color; -# -# Test passing of image variables in function calls. -# -gen('call-argument-qualifiers', """\ - ${header(status)} - /* - * From the ARB_shader_image_load_store spec: - * - * "The values of image variables qualified with 'coherent', - * 'volatile', 'restrict', 'readonly', or 'writeonly' may not be - * passed to functions whose formal parameters lack such - * qualifiers. [...] It is legal to have additional qualifiers on a - * formal parameter, but not to have fewer." - */ - layout(rgba32f) ${actual_qualifier} uniform image2D x; - - void f(${formal_qualifier} image2D y) - { - } + void main() + { + color = y + imageLoad((imgs[1]) ${image_addr()}); + } + """, product(image_types[:1], shader_stages)) - void main() - { - f(x); - } -""", product(shader_stages, [ - {'name': 'allowed-volatile', - 'actual_qualifier': 'volatile', - 'formal_qualifier': 'volatile coherent', - 'status': 'pass'}, - {'name': 'allowed-coherent', - 'actual_qualifier': 'coherent', - 'formal_qualifier': 'volatile coherent', - 'status': 'pass'}, - {'name': 'allowed-restrict', - 'actual_qualifier': 'restrict', - 'formal_qualifier': 'volatile restrict', - 'status': 'pass'}, - {'name': 'allowed-readonly', - 'actual_qualifier': 'readonly', - 'formal_qualifier': 'restrict readonly', - 'status': 'pass'}, - {'name': 'allowed-writeonly', - 'actual_qualifier': 'writeonly', - 'formal_qualifier': 'volatile writeonly', - 'status': 'pass'}, - {'name': 'disallowed-volatile', - 'actual_qualifier': 'volatile', - 'formal_qualifier': '', - 'status': 'fail'}, - {'name': 'disallowed-coherent', - 'actual_qualifier': 'coherent', - 'formal_qualifier': 'restrict', - 'status': 'fail'}, - {'name': 'disallowed-restrict', - 'actual_qualifier': 'restrict', - 'formal_qualifier': '', - 'status': 'fail'}, - {'name': 'disallowed-readonly', - 'actual_qualifier': 'readonly', - 'formal_qualifier': 'restrict writeonly', - 'status': 'fail'}, - {'name': 'disallowed-writeonly', - 'actual_qualifier': 'writeonly', - 'formal_qualifier': 'volatile readonly', - 'status': 'fail'} -])) - -gen('call-argument-type', """\ - ${header('pass' if image_type == 'image2D' else 'fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "As function parameters, images may only be passed to [arguments] - * of matching type." - */ - layout(rgba32f) uniform image2D x; - - void f(${image_type} y) - { - } + gen('expression', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Except for array indexing, structure field selection, and + * parentheses, images are not allowed to be operands in + * expressions." + */ + layout(rgba32f) uniform image2D img; + + void main() + { + ${expression}; + } + """, product(shader_stages, [ + {'name': 'arithmetic-1', 'expression': '-img'}, + {'name': 'arithmetic-2', 'expression': 'img + img'}, + {'name': 'arithmetic-3', 'expression': 'img - img'}, + {'name': 'arithmetic-4', 'expression': 'img * img'}, + {'name': 'arithmetic-5', 'expression': 'img / img'}, + {'name': 'arithmetic-6', 'expression': '++img'}, + {'name': 'arithmetic-7', 'expression': '--img'}, + {'name': 'arithmetic-8', 'expression': 'img++'}, + {'name': 'arithmetic-9', 'expression': 'img--'}, + {'name': 'assignment-1', 'expression': 'img ^= img'}, + {'name': 'assignment-2', 'expression': 'img |= img'}, + {'name': 'assignment-3', 'expression': 'img = img'}, + {'name': 'assignment-4', 'expression': 'img += img'}, + {'name': 'assignment-5', 'expression': 'img -= img'}, + {'name': 'assignment-6', 'expression': 'img *= img'}, + {'name': 'assignment-7', 'expression': 'img /= img'}, + {'name': 'assignment-8', 'expression': 'img %= img'}, + {'name': 'assignment-9', 'expression': 'img <<= img'}, + {'name': 'assignment-10', 'expression': 'img >>= img'}, + {'name': 'assignment-11', 'expression': 'img &= img'}, + {'name': 'binary-1', 'expression': '~img'}, + {'name': 'binary-2', 'expression': 'img << img'}, + {'name': 'binary-3', 'expression': 'img >> img'}, + {'name': 'binary-4', 'expression': 'img & img'}, + {'name': 'binary-5', 'expression': 'img | img'}, + {'name': 'binary-6', 'expression': 'img ^ img'}, + {'name': 'conversion-1', 'expression': 'float(img)'}, + {'name': 'conversion-2', 'expression': 'uint(img)'}, + {'name': 'conversion-3', 'expression': 'bool(img)'}, + {'name': 'conversion-4', 'expression': 'image1D(img)'}, + {'name': 'field-selection', 'expression': 'img.x'}, + {'name': 'function-call', 'expression': 'img()'}, + {'name': 'logical-1', 'expression': '!img'}, + {'name': 'logical-2', 'expression': 'img && img'}, + {'name': 'logical-3', 'expression': 'img || img'}, + {'name': 'logical-4', 'expression': 'img ^^ img'}, + {'name': 'relational-1', 'expression': 'img == img'}, + {'name': 'relational-2', 'expression': 'img != img'}, + {'name': 'relational-3', 'expression': 'img < img'}, + {'name': 'relational-4', 'expression': 'img > img'}, + {'name': 'relational-5', 'expression': 'img <= img'}, + {'name': 'relational-6', 'expression': 'img >= img'}, + {'name': 'selection', 'expression': 'true ? img : img'}, + {'name': 'subscript', 'expression': 'img[0]'} + ])) + + # + # Test passing of image variables in function calls. + # + gen('call-argument-qualifiers', """\ + ${header(status)} + /* + * From the ARB_shader_image_load_store spec: + * + * "The values of image variables qualified with 'coherent', + * 'volatile', 'restrict', 'readonly', or 'writeonly' may not be + * passed to functions whose formal parameters lack such + * qualifiers. [...] It is legal to have additional qualifiers on a + * formal parameter, but not to have fewer." + */ + layout(rgba32f) ${actual_qualifier} uniform image2D x; + + void f(${formal_qualifier} image2D y) + { + } + + void main() + { + f(x); + } + """, product(shader_stages, [ + {'name': 'allowed-volatile', + 'actual_qualifier': 'volatile', + 'formal_qualifier': 'volatile coherent', + 'status': 'pass'}, + {'name': 'allowed-coherent', + 'actual_qualifier': 'coherent', + 'formal_qualifier': 'volatile coherent', + 'status': 'pass'}, + {'name': 'allowed-restrict', + 'actual_qualifier': 'restrict', + 'formal_qualifier': 'volatile restrict', + 'status': 'pass'}, + {'name': 'allowed-readonly', + 'actual_qualifier': 'readonly', + 'formal_qualifier': 'restrict readonly', + 'status': 'pass'}, + {'name': 'allowed-writeonly', + 'actual_qualifier': 'writeonly', + 'formal_qualifier': 'volatile writeonly', + 'status': 'pass'}, + {'name': 'disallowed-volatile', + 'actual_qualifier': 'volatile', + 'formal_qualifier': '', + 'status': 'fail'}, + {'name': 'disallowed-coherent', + 'actual_qualifier': 'coherent', + 'formal_qualifier': 'restrict', + 'status': 'fail'}, + {'name': 'disallowed-restrict', + 'actual_qualifier': 'restrict', + 'formal_qualifier': '', + 'status': 'fail'}, + {'name': 'disallowed-readonly', + 'actual_qualifier': 'readonly', + 'formal_qualifier': 'restrict writeonly', + 'status': 'fail'}, + {'name': 'disallowed-writeonly', + 'actual_qualifier': 'writeonly', + 'formal_qualifier': 'volatile readonly', + 'status': 'fail'} + ])) + + gen('call-argument-type', """\ + ${header('pass' if image_type == 'image2D' else 'fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "As function parameters, images may only be passed to [arguments] + * of matching type." + */ + layout(rgba32f) uniform image2D x; + + void f(${image_type} y) + { + } + + void main() + { + f(x); + } + """, product(image_types, shader_stages)) + + # + # Test the language built-in constants and functions. + # + gen('builtin-constants', """\ + ${header('pass')} + /* + * Check that the builtin constants defined by the extension + * are present. + */ + out ivec4 color; + + void main() + { + color.x = gl_MaxImageUnits + + gl_MaxCombinedImageUnitsAndFragmentOutputs + + gl_MaxImageSamples + + gl_MaxVertexImageUniforms + + gl_MaxGeometryImageUniforms + + gl_MaxFragmentImageUniforms + + gl_MaxCombinedImageUniforms; + } + """, shader_stages) + + gen('builtin-image-argument-mismatch', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "Atomic memory operations are supported on only [...]: an image + * variable with signed integer components (iimage*) format qualifier + * of 'r32i', or an image variable with unsigned integer components + * (uimage*) and format qualifier of 'r32ui'." + * + * Call an atomic built-in with a floating point image data type. + */ + layout(r32f) uniform ${image_type} img; - void main() - { - f(x); - } -""", product(image_types, shader_stages)) + void main() + { + ${image_builtin}(img ${image_addr()} ${image_args('float')}); + } + """, product(image_atomic_builtins, image_types[:1], shader_stages)) -# -# Test the language built-in constants and functions. -# -gen('builtin-constants', """\ - ${header('pass')} - /* - * Check that the builtin constants defined by the extension - * are present. - */ - out ivec4 color; - - void main() - { - color.x = gl_MaxImageUnits + - gl_MaxCombinedImageUnitsAndFragmentOutputs + - gl_MaxImageSamples + - gl_MaxVertexImageUniforms + - gl_MaxGeometryImageUniforms + - gl_MaxFragmentImageUniforms + - gl_MaxCombinedImageUniforms; - } -""", shader_stages) - -gen('builtin-image-argument-mismatch', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "Atomic memory operations are supported on only [...]: an image - * variable with signed integer components (iimage*) format qualifier - * of 'r32i', or an image variable with unsigned integer components - * (uimage*) and format qualifier of 'r32ui'." - * - * Call an atomic built-in with a floating point image data type. - */ - layout(r32f) uniform ${image_type} img; - - void main() - { - ${image_builtin}(img ${image_addr()} ${image_args('float')}); - } -""", product(image_atomic_builtins, image_types[:1], shader_stages)) + gen('builtin-data-argument-mismatch', """\ + ${header('fail')} + /* + * Call a signed integer atomic built-in with a mismatching + * argument data type. + */ + layout(r32i) uniform i${image_type} img; -gen('builtin-data-argument-mismatch', """\ - ${header('fail')} - /* - * Call a signed integer atomic built-in with a mismatching - * argument data type. - */ - layout(r32i) uniform i${image_type} img; + void main() + { + ${image_builtin}(img ${image_addr()} ${image_args('uint')}); + } + """, product(image_store_builtin + image_atomic_builtins, + image_types[:1], shader_stages)) - void main() - { - ${image_builtin}(img ${image_addr()} ${image_args('uint')}); - } -""", product(image_store_builtin + image_atomic_builtins, - image_types[:1], shader_stages)) - -gen('builtin-address-argument-mismatch', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "The 'IMAGE_INFO' placeholder is replaced by one of the following - * parameter lists: - * gimage1D image, int coord - * gimage2D image, ivec2 coord - * gimage3D image, ivec3 coord - * gimage2DRect image, ivec2 coord - * gimageCube image, ivec3 coord - * gimageBuffer image, int coord - * gimage1DArray image, ivec2 coord - * gimage2DArray image, ivec3 coord - * gimageCubeArray image, ivec3 coord - * gimage2DMS image, ivec2 coord, int sample - * gimage2DMSArray image, ivec3 coord, int sample" - * - * Pass an argument as address coordinate that doesn't match the - * dimensionality of the specified image. - */ - layout(r32i) uniform i${image_type} img; - - void main() - { - ${image_builtin}(img ${image_addr(fail = True)} ${image_args('int')}); - } -""", product(image_load_builtin + image_store_builtin + image_atomic_builtins, - image_types, shader_stages)) - -gen('builtin-qualifier-mismatch-readonly', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "It is an error to pass an image variable qualified with 'readonly' - * to imageStore() or other built-in functions that modify image - * memory." - * - * Call a built-in function on a readonly qualified image. - */ - layout(r32i) readonly uniform i${image_type} img; - - void main() - { - ${image_builtin}(img ${image_addr()} ${image_args('int')}); - } -""", product(image_store_builtin + image_atomic_builtins, - image_types[:1], shader_stages)) - -gen('builtin-qualifier-mismatch-writeonly', """\ - ${header('fail')} - /* - * From the ARB_shader_image_load_store spec: - * - * "It is an error to pass an image variable qualified with 'writeonly' - * to imageLoad() or other built-in functions that read image - * memory." - * - * Call a built-in function on a writeonly qualified image. - */ - layout(r32i) writeonly uniform i${image_type} img; - - void main() - { - ${image_builtin}(img ${image_addr()} ${image_args('int')}); - } -""", product(image_load_builtin + image_atomic_builtins, - image_types[:1], shader_stages)) + gen('builtin-address-argument-mismatch', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "The 'IMAGE_INFO' placeholder is replaced by one of the following + * parameter lists: + * gimage1D image, int coord + * gimage2D image, ivec2 coord + * gimage3D image, ivec3 coord + * gimage2DRect image, ivec2 coord + * gimageCube image, ivec3 coord + * gimageBuffer image, int coord + * gimage1DArray image, ivec2 coord + * gimage2DArray image, ivec3 coord + * gimageCubeArray image, ivec3 coord + * gimage2DMS image, ivec2 coord, int sample + * gimage2DMSArray image, ivec3 coord, int sample" + * + * Pass an argument as address coordinate that doesn't match the + * dimensionality of the specified image. + */ + layout(r32i) uniform i${image_type} img; -gen('builtin-memory-barrier', """\ - ${header('pass')} - void main() - { - memoryBarrier(); - } -""", shader_stages) + void main() + { + ${image_builtin}(img ${image_addr(fail = True)} ${image_args('int')}); + } + """, product(image_load_builtin + image_store_builtin + image_atomic_builtins, + image_types, shader_stages)) + + gen('builtin-qualifier-mismatch-readonly', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "It is an error to pass an image variable qualified with 'readonly' + * to imageStore() or other built-in functions that modify image + * memory." + * + * Call a built-in function on a readonly qualified image. + */ + layout(r32i) readonly uniform i${image_type} img; + + void main() + { + ${image_builtin}(img ${image_addr()} ${image_args('int')}); + } + """, product(image_store_builtin + image_atomic_builtins, + image_types[:1], shader_stages)) + + gen('builtin-qualifier-mismatch-writeonly', """\ + ${header('fail')} + /* + * From the ARB_shader_image_load_store spec: + * + * "It is an error to pass an image variable qualified with 'writeonly' + * to imageLoad() or other built-in functions that read image + * memory." + * + * Call a built-in function on a writeonly qualified image. + */ + layout(r32i) writeonly uniform i${image_type} img; + + void main() + { + ${image_builtin}(img ${image_addr()} ${image_args('int')}); + } + """, product(image_load_builtin + image_atomic_builtins, + image_types[:1], shader_stages)) + + gen('builtin-memory-barrier', """\ + ${header('pass')} + void main() + { + memoryBarrier(); + } + """, shader_stages) + + +if __name__ == '__main__': + main() |