3 # Copyright © 2014-2016 Intel Corporation
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice (including the next
13 # paragraph) shall be included in all copies or substantial portions of the
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 from textwrap
import dedent
28 from mako
.template
import Template
29 from mako
import exceptions
31 from modules
import utils
34 def product(ps
, *qss
):
36 Generate the cartesian product of a number of lists of dictionaries.
38 Generate a sequence with every possible combination of elements of
39 the specified lists of dictionaries. Each element of the result
40 will be the union of some combination of dictionaries from the
41 lists given as argument. The 'name' attribute of each dictionary
42 given as input is concatenated with the names of other
43 dictionaries part of the same combination to give the 'name'
44 attribute of the result.
46 for q
in (product(*qss
) if qss
else [{}]):
49 r
['name'] = ''.join(s
['name'] for s
in (p
, q
) if s
.get('name'))
55 Expand a source template for the provided list of test definitions.
57 Generate a test script for each element of the 'tests' iterable,
58 each of them should be a dictionary of definitions that will be
59 used as environment to render the source template.
61 The 'path' attribute of each dictionary gives the filename each
62 test will be written to.
64 template
= Template(dedent(src
))
68 utils
.safe_makedirs(os
.path
.dirname(t
['path']))
69 with
open(t
['path'], 'w') as f
:
71 f
.write(template
.render(**t
))
73 print(exceptions
.text_error_template().render(), file=sys
.stderr
)
77 def gen_execution(src
, tests
):
79 Generate a shader runner test for each element of the 'tests'
83 (dict(t
, path
= os
.path
.join(
84 'spec', t
['extension'], 'execution', t
['api'],
85 t
['name'] + '.shader_test')) for t
in tests
))
88 def gen_compiler(src
, tests
):
90 Generate a GLSL parser test for each element of the 'tests'
94 (dict(t
, path
= os
.path
.join(
95 'spec', t
['extension'], 'compiler', t
['api'],
96 t
['name'] + '.' + t
['shader_stage'])) for t
in tests
))
100 # Common test definitions independent of the framebuffer fetch
103 common_defs
= [{# Allocate and bind a framebuffer object of the given
104 # format and number of samples.
105 'bind_fb': lambda fmt
, samples
= 0:
106 'fb ms {0} 250 250 {1}'.format(fmt
, samples
) if samples
> 0 else
107 ('texture storage 0 2D {0} (1 250 250)\n'
108 'fb tex 2d 0').format(fmt
) if fmt
[-1] == 'I' else
109 ('texture rgbw 0 (250, 250) {0}\n'
110 'fb tex 2d 0').format(fmt
),
112 # Resolve the contents of a framebuffer previously
113 # allocated with 'bind_fb' of the given format and
114 # samples into a newly allocated single-sample
116 'resolve_fb': lambda fmt
, samples
:
117 '' if samples
== 0 else
118 ('texture storage 0 2D {0} (1 250 250)\n'
120 'blit color nearest\n'
121 'fb read tex 2d 0\n').format(fmt
) if fmt
[-1] == 'I' else
122 ('texture rgbw 0 (250, 250) {0}\n'
124 'blit color linear\n'
125 'fb read tex 2d 0').format(fmt
),
127 # Blit the contents of the current read framebuffer
128 # into the window system framebuffer. XXX - Requires
129 # GL(ES) 3.0+ since glBlitFramebuffer doesn't exist on
130 # earlier API versions.
131 'display_fb': lambda api_version
:
132 '' if api_version
< 3.0 else
134 'blit color linear'),
136 # Declare a fragment color array set up for
137 # framebuffer fetch with the specified number of
138 # elements (n=0 indicates a single scalar output).
140 # The fragment color array can be accessed using the
141 # 'frag_data' and 'last_frag_data' macros defined
142 # below to make sure the generated test is valid
143 # irrespective of the GLSL version.
144 'decl_frag_data': lambda api_version
, layout
, n
= 0, \
145 t
= 'vec4', p
= 'mediump':
146 '' if api_version
< 3.0 and not layout
and t
== 'vec4' \
147 and p
== 'mediump' else
148 layout
+ ' ' + p
+ ' ' + t
+ ' gl_LastFragData[gl_MaxDrawBuffers];' \
149 if api_version
< 3.0 else
150 layout
+ ' inout ' + p
+ ' ' + t
+ ' fcolor;' if n
== 0 else
151 layout
+ ' inout ' + p
+ ' ' + t
+ ' fcolor[{0}];'.format(n
),
153 'frag_data': lambda api_version
, i
= -1:
154 'gl_FragData[{0}]'.format(max(0, i
)) if api_version
< 3.0 else
155 'fcolor[{0}]'.format(i
) if i
>= 0 else
158 'last_frag_data': lambda api_version
, i
= -1:
159 'gl_LastFragData[{0}]'.format(max(0, i
)) if api_version
< 3.0 else
160 'fcolor[{0}]'.format(i
) if i
>= 0 else
165 # Common test definitions for all supported extensions.
167 all_defs
= list(product(common_defs
,
168 [{'extension': 'EXT_shader_framebuffer_fetch',
171 {'extension': 'EXT_shader_framebuffer_fetch_non_coherent',
172 'layout': 'layout(noncoherent)',
173 'barrier': 'fbfetch barrier'}]))
180 # Test that the GL(ES) 2 gl_LastFragData built-in is not defined
181 # in more recent GLSL versions.
186 * expect_result: fail
187 * glsl_version: 3.0 es
188 * require_extensions: GL_${extension}
192 #extension GL_${extension} : enable
194 out highp vec4 color;
198 color = gl_LastFragData[0];
200 """, product(all_defs
,
201 [{'name': 'negative-gl_LastFragData',
203 'shader_stage': 'frag'}]))
206 # Test that the GL(ES) 2 gl_LastFragData built-in is read-only.
207 # From the EXT_shader_framebuffer_fetch extension: "[...] fragment
208 # shaders should use the read-only input array gl_LastFragData."
213 * expect_result: fail
214 * glsl_version: 1.0 es
215 * require_extensions: GL_${extension}
219 #extension GL_${extension} : enable
223 gl_LastFragData[0] = vec4(1.0);
225 """, product(all_defs
,
226 [{'name': 'negative-gl_LastFragData-write',
228 'shader_stage': 'frag'}]))
231 # Test framebuffer fetch output declarations with invalid layout
232 # qualifiers. From the EXT_shader_framebuffer_fetch extension:
234 # "It is an error to declare an inout fragment output not
235 # qualified with layout(noncoherent) if the
236 # GL_EXT_shader_framebuffer_fetch extension hasn't been enabled."
238 # "The ability to use the inout and layout(noncoherent) qualifiers
239 # at global scope in a fragment shader are optional and can be
241 # #extension GL_EXT_shader_framebuffer_fetch_non_coherent : <behavior>"
246 * expect_result: fail
247 * glsl_version: ${3.0 if api_version >= 3.0 else 1.0} es
248 * require_extensions: GL_${extension}
251 #version ${'300 es' if api_version >= 3.0 else '100'}
252 #extension GL_${extension} : enable
254 ${decl_frag_data(api_version, '' if layout else 'layout(noncoherent)')}
258 ${last_frag_data(api_version)};
260 """, product(all_defs
,
261 [{'name': 'negative-output-layout',
262 'shader_stage': 'frag'}],
263 [{'api': 'gles2', 'api_version': 2.0},
264 {'api': 'gles3', 'api_version': 3.0}]))
267 # Test that GL(ES) 3+ user-defined inout arrays are not accepted
268 # in earlier GLSL versions.
273 * expect_result: fail
274 * glsl_version: 1.0 es
275 * require_extensions: GL_${extension}
279 #extension GL_${extension} : enable
281 inout highp vec4 color;
287 """, product(all_defs
,
288 [{'name': 'negative-inout-fragment-output',
290 'shader_stage': 'frag'}]))
293 # Test that redeclaring an existing built-in fragment output as
294 # 'inout' leads to an error.
299 * expect_result: fail
300 * glsl_version: 3.0 es
301 * require_extensions: GL_${extension}
305 #extension GL_${extension} : enable
307 inout highp float gl_FragDepth;
313 """, product(all_defs
,
314 [{'name': 'negative-inout-gl_FragDepth',
316 'shader_stage': 'frag'}]))
319 # Test that vertex shader interface variables cannot be declared
325 * expect_result: fail
326 * glsl_version: 3.0 es
327 * require_extensions: GL_${extension}
331 #extension GL_${extension} : enable
333 inout highp vec4 vcolor;
338 """, product(all_defs
,
339 [{'name': 'negative-inout-vertex-output',
341 'shader_stage': 'vert'}]))
344 # Test basic framebuffer fetch functionality.
348 GL ES >= ${api_version}
349 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
351 INT GL_MAX_SAMPLES >= ${samples}
355 [vertex shader passthrough]
358 #version ${'300 es' if api_version >= 3.0 else '100'}
359 #extension GL_${extension} : enable
361 ${decl_frag_data(api_version, layout)}
365 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
366 vec4(0.5, 0.0, 0.0, 0.0);
370 ${bind_fb('GL_RGBA8', samples)}
372 clear color 0.0 0.0 1.0 0.0
379 ${resolve_fb('GL_RGBA8', samples)}
381 relative probe rect rgb (0, 0.0, 1.0, 1.0) (1.0, 0.0, 1.0)
383 ${display_fb(api_version)}
384 """, product(all_defs
,
385 [{'name': 'simple-'}],
386 [{'name': 'ss', 'api': 'gles2', 'api_version': 2.0, 'samples': 0},
387 {'name': 'ss', 'api': 'gles3', 'api_version': 3.0, 'samples': 0},
388 {'name': 'ms2', 'api': 'gles3', 'api_version': 3.0, 'samples': 2},
389 {'name': 'ms8', 'api': 'gles3', 'api_version': 3.0, 'samples': 8},
390 {'name': 'ms16', 'api': 'gles3', 'api_version': 3.0, 'samples': 16}]))
393 # Test read-back from a framebuffer with non-uniform contents
394 # rendered during a previous draw call.
398 GL ES >= ${api_version}
399 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
401 INT GL_MAX_SAMPLES >= ${samples}
406 #version ${'300 es' if api_version >= 3.0 else '100'}
408 ${'in' if api_version >= 3.0 else 'attribute'} highp vec4 vertex;
409 ${'out' if api_version >= 3.0 else 'varying'} highp vec4 vcolor;
413 gl_Position = vertex;
414 // Transform the vertex coordinates so that the R and G
415 // components of the vertex color range between 0.0 and 1.0.
416 vcolor = vec4((1.0 + vertex.x) / 2.0,
417 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
421 #version ${'300 es' if api_version >= 3.0 else '100'}
422 #extension GL_${extension} : enable
424 ${'in' if api_version >= 3.0 else 'varying'} highp vec4 vcolor;
425 ${decl_frag_data(api_version, layout, p=precision)}
429 // The condition makes sure that the else branch is
430 // taken for the top and right quadrants during the second
432 if (${last_frag_data(api_version)}.x <= 0.5 &&
433 ${last_frag_data(api_version)}.y <= 0.5) {
434 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
437 // Will give a solid color as result different for
438 // each quadrant, assuming that the first branch was
439 // taken during the first pass.
440 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
441 vec4((vcolor.x >= 0.5 ? 1.0 : 0.0) - vcolor.x,
442 (vcolor.y >= 0.5 ? 1.0 : 0.0) - vcolor.y,
448 ${bind_fb('GL_RGBA8', samples)}
450 clear color 0.0 0.0 1.0 0.0
457 ${resolve_fb('GL_RGBA8', samples)}
459 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (1.0, 0.0, 1.0)
460 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.0, 1.0, 1.0)
461 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
463 ${display_fb(api_version)}
464 """, product(all_defs
,
465 [{'name': 'nonuniform-'}],
466 [{'name': 'ss', 'api': 'gles2', 'api_version': 2.0,
467 'samples': 0, 'precision': 'mediump'},
468 {'name': 'ss-redecl-highp', 'api': 'gles2',
469 'api_version': 2.0, 'samples': 0, 'precision': 'highp'},
470 {'name': 'ss-redecl-lowp', 'api': 'gles2',
471 'api_version': 2.0, 'samples': 0, 'precision': 'lowp'},
472 {'name': 'ss', 'api': 'gles3', 'api_version': 3.0,
473 'samples': 0, 'precision': 'mediump'},
474 {'name': 'ms2', 'api': 'gles3', 'api_version': 3.0,
475 'samples': 2, 'precision': 'mediump'},
476 {'name': 'ms8', 'api': 'gles3', 'api_version': 3.0,
477 'samples': 8, 'precision': 'mediump'},
478 {'name': 'ms16', 'api': 'gles3', 'api_version': 3.0,
479 'samples': 16, 'precision': 'mediump'}]))
482 # Test basic framebuffer fetch functionality in combination with
487 GL ES >= ${api_version}
491 [vertex shader passthrough]
495 #extension GL_${extension} : enable
498 ${decl_frag_data(api_version, layout)}
502 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
503 texelFetch(s, ivec2(gl_FragCoord), 0) / 4.0;
507 ${bind_fb('GL_RGBA8')}
509 texture rgbw 1 (250, 250) GL_RGBA8
512 clear color 0.5 0.0 0.0 0.0
519 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (1.0, 0.0, 0.0)
520 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (0.5, 0.5, 0.0)
521 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.5, 0.0, 0.5)
522 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 0.5, 0.5)
524 ${display_fb(api_version)}
525 """, product(all_defs
,
528 'api_version': 3.0}]))
531 # Test non-uniform fragment discard dependent on the result read
532 # back from the framebuffer. The EXT_shader_framebuffer_fetch
533 # multisample test will be skipped if the implementation doesn't
534 # claim to support per-sample discard.
538 GL ES >= ${api_version}
542 INT GL_MAX_SAMPLES >= ${samples}
544 INT GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT >= ${1 if samples else 0}
549 in highp vec4 vertex;
550 out highp vec4 vcolor;
554 gl_Position = vertex;
555 // Transform the vertex coordinates so that the R and G
556 // components of the vertex color range between 0.0 and 1.0.
557 vcolor = vec4((1.0 + vertex.x) / 2.0,
558 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
563 #extension GL_${extension} : enable
565 in highp vec4 vcolor;
566 ${decl_frag_data(api_version, layout)}
570 // The condition makes sure that the discard branch is
571 // taken for the top and right quadrants during the second
573 if (${last_frag_data(api_version)}.x <= 0.45 &&
574 ${last_frag_data(api_version)}.y < 0.45)
575 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
576 vec4(vcolor.x >= 0.5 ? 0.5 : 0.1,
577 vcolor.y >= 0.5 ? 0.5 : 0.1,
584 ${bind_fb('GL_RGBA8', samples)}
586 clear color 0.0 0.0 1.0 0.0
593 ${resolve_fb('GL_RGBA8', samples)}
595 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (0.2, 0.2, 1.0)
596 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (0.5, 0.1, 1.0)
597 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.1, 0.5, 1.0)
598 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (0.5, 0.5, 1.0)
600 ${display_fb(api_version)}
601 """, product(all_defs
,
602 [{'name': 'discard-',
604 'api_version': 3.0}],
605 [{'name': 'ss', 'samples': 0},
606 {'name': 'ms8', 'samples': 8}]))
609 # Test read-back from an integer framebuffer with non-uniform
610 # contents rendered during a previous draw call. Similar to the
611 # "nonuniform" test above but using an integer framebuffer.
615 GL ES >= ${api_version}
619 INT GL_MAX_SAMPLES >= ${samples}
625 in highp vec4 vertex;
626 out highp vec4 vcolor;
630 gl_Position = vertex;
631 // Transform the vertex coordinates so that the R and G
632 // components of the vertex color range between 0.0 and 1.0.
633 vcolor = vec4((1.0 + vertex.x) / 2.0,
634 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
639 #extension GL_${extension} : enable
642 in highp vec4 vcolor;
643 ${decl_frag_data(api_version, layout, t='ivec4')}
647 if (${last_frag_data(api_version)}.x <= SCALE / 2 &&
648 ${last_frag_data(api_version)}.y <= SCALE / 2)
649 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
650 ivec4(vcolor * float(SCALE));
652 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
653 ivec4((vcolor.x >= 0.5 ? SCALE : 0)
654 - int(vcolor.x * float(SCALE)),
655 (vcolor.y >= 0.5 ? SCALE : 0)
656 - int(vcolor.y * float(SCALE)),
661 ${bind_fb('GL_RGBA8I', samples)}
670 ${resolve_fb('GL_RGBA8I', samples)}
672 relative probe rect rgba int (0.55, 0.0, 0.45, 0.45) (100, 0, 127, 100)
673 relative probe rect rgba int (0.0, 0.55, 0.45, 0.45) (0, 100, 127, 100)
674 relative probe rect rgba int (0.55, 0.55, 0.45, 0.45) (100, 100, 127, 100)
675 """, product(all_defs
,
676 [{'name': 'integer-', 'api': 'gles3'}],
677 [{'name': 'ss', 'samples': 0, 'api_version': 3.0},
678 {'name': 'ms2', 'samples': 2, 'api_version': 3.1},
679 {'name': 'ms8', 'samples': 8, 'api_version': 3.1}]))
682 # Test framebuffer fetch functionality in combination with
683 # multiple render targets.
687 GL ES >= ${api_version}
688 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
691 [vertex shader passthrough]
694 #version ${'300 es' if api_version >= 3.0 else '100'}
695 #extension GL_${extension} : enable
697 ${decl_frag_data(api_version, layout, 4)}
701 ${frag_data(api_version, 0)} = ${last_frag_data(api_version, 0)} +
702 vec4(0.5, 0.0, 0.0, 0.0);
703 ${frag_data(api_version, 1)} = ${last_frag_data(api_version, 1)} +
704 vec4(0.0, 0.5, 0.0, 0.0);
705 ${frag_data(api_version, 2)} = ${last_frag_data(api_version, 2)} +
706 vec4(0.5, 0.5, 0.0, 0.0);
707 ${frag_data(api_version, 3)} = ${last_frag_data(api_version, 3)} +
708 vec4(0.0, 0.0, 0.5, 0.0);
712 texture rgbw 0 (250, 250) GL_RGBA8
713 texture rgbw 1 (250, 250) GL_RGBA8
714 texture rgbw 2 (250, 250) GL_RGBA8
715 texture rgbw 3 (250, 250) GL_RGBA8
718 clear color 0.0 0.0 0.5 0.0
726 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0.0, 0.5)
729 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (0.0, 1.0, 0.5)
732 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 1.0, 0.5)
735 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (0.0, 0.0, 1.0)
737 ${display_fb(api_version)}
738 """, product(all_defs
,
740 [{'api': 'gles2', 'api_version': 2.0},
741 {'api': 'gles3', 'api_version': 3.0}]))
744 # Test framebuffer fetch functionality with multiple assignments
745 # of the fragment color input-output.
749 GL ES >= ${api_version}
761 gl_Position = vertex;
762 // Transform the vertex coordinates so that the R and G
763 // components of the vertex color range between 0.0 and 1.0.
764 vcolor = vec4((1.0 + vertex.x) / 2.0,
765 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
770 #extension GL_${extension} : enable
772 in highp vec4 vcolor;
773 ${decl_frag_data(api_version, layout)}
777 // The conditional assignment will be executed for the top
778 // and right quadrants.
779 if (vcolor.x >= 0.5 || vcolor.y >= 0.5)
780 ${frag_data(api_version)} += vec4(0.5, 0, 0, 0);
782 ${frag_data(api_version)} += vec4(0.0, 0.5, 0, 0);
786 ${bind_fb('GL_RGBA8')}
788 clear color 0.0 0.0 1.0 0.0
795 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (0.0, 1.0, 1.0)
796 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (1.0, 1.0, 1.0)
797 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
798 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
800 ${display_fb(api_version)}
801 """, product(all_defs
,
802 [{'name': 'overwrite',
804 'api_version': 3.0}]))
807 # Test framebuffer fetch functionality on individual slices of a
808 # texture render target with multiple layers or mipmap levels.
812 GL ES >= ${api_version}
816 [vertex shader passthrough]
820 #extension GL_${extension} : enable
822 ${decl_frag_data(api_version, layout)}
823 uniform highp vec4 ucolor;
827 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
832 %if target == 'Cube':
833 texture storage 0 ${target} GL_RGBA8 (${levels} 250 250)
835 texture storage 0 ${target} GL_RGBA8 (${levels} 250 250 ${layers})
838 <%! blend_colors = ['0.5 0.0 0.0 0.0',
841 '0.0 0.0 0.5 0.0'] %>
843 %for l in range(0, levels):
844 %for z in range(0, layers):
845 fb tex slice ${target} 0 ${l} ${z}
846 uniform vec4 ucolor ${blend_colors[(l + z) % 4]}
847 clear color 0.0 0.0 0.5 0.0
857 <%! expected_colors = ['(1.0, 0.0, 0.5)',
860 '(0.0, 0.0, 1.0)'] %>
862 %for l in range(0, levels):
863 %for z in range(0, layers):
864 fb tex slice ${target} 0 ${l} ${z}
865 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) ${expected_colors[(l + z) % 4]}
870 ${display_fb(api_version)}
871 """, product(all_defs
,
872 [{'name': 'single-slice-',
874 'api_version': 3.0}],
875 [{'name': '2darray', 'target': '2DArray',
876 'levels': 1, 'layers': 4},
877 {'name': '2darray-mipmap', 'target': '2DArray',
878 'levels': 4, 'layers': 1},
879 {'name': '3d', 'target': '3D',
880 'levels': 1, 'layers': 4},
881 {'name': 'cubemap', 'target': 'Cube',
882 'levels': 1, 'layers': 6}]))
885 # Test framebuffer fetch functionality on a 1D framebuffer.
891 GL_ARB_texture_storage
902 gl_Position = vertex;
903 // Transform the vertex coordinates so that the R
904 // component of the vertex color ranges between 0.0 and 1.0.
905 vcolor = vec4((1.0 + vertex.x) / 2.0, 0.7, 0.0, 1.0);
910 #extension GL_${extension} : enable
913 ${decl_frag_data(api_version, layout)}
917 // The else branch will be executed during the second
919 if (${last_frag_data(api_version)}.x <= 0.5 &&
920 ${last_frag_data(api_version)}.y <= 0.5) {
921 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
924 // Will give a solid color as result different for
925 // each half, assuming that the first branch was taken
926 // during the first pass.
927 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
928 vec4((vcolor.x >= 0.5 ? 1.0 : 0.0) - vcolor.x,
929 (vcolor.y >= 0.5 ? 1.0 : 0.0) - vcolor.y, 0, 0);
934 texture storage 0 1D GL_RGBA8 (1 250)
935 fb tex slice 1D 0 0 0
937 clear color 0.0 0.0 1.0 0.0
944 relative probe rect rgb (0.0, 0.0, 0.45, 1.0) (0.0, 1.0, 1.0)
945 relative probe rect rgb (0.55, 0.0, 0.45, 1.0) (1.0, 1.0, 1.0)
949 """, product(all_defs
,
952 'api_version': 3.2}]))
955 # Test framebuffer fetch functionality while rendering into
956 # multiple layers of an array or cubemap framebuffer
963 GL_ARB_texture_storage
966 [vertex shader passthrough]
970 layout(triangles) in;
971 layout(triangle_strip, max_vertices=18) out;
977 for (int layer = 0; layer < ${layers}; layer++) {
978 for (int i = 0; i < 3; i++) {
979 gl_Position = gl_in[i].gl_Position;
980 gl_Layer = glayer = layer;
989 #extension GL_${extension} : enable
992 ${decl_frag_data(api_version, layout)}
996 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
997 (glayer == 5 ? vec4(0.0, 0.5, 0.5, 0.0) :
998 glayer == 4 ? vec4(0.5, 0.0, 0.5, 0.0) :
999 glayer == 3 ? vec4(0.0, 0.0, 0.5, 0.0) :
1000 glayer == 2 ? vec4(0.5, 0.5, 0.0, 0.0) :
1001 glayer == 1 ? vec4(0.0, 0.5, 0.0, 0.0) :
1002 vec4(0.5, 0.0, 0.0, 0.0));
1006 texture storage 0 ${target} GL_RGBA8 (${dimensions})
1009 clear color 0.0 0.0 0.5 0.0
1016 <%! expected_colors = ['(1.0, 0.0, 0.5)',
1021 '(0.0, 1.0, 1.0)'] %>
1023 %for z in range(0, layers):
1024 fb tex slice ${target} 0 0 ${z}
1025 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) ${expected_colors[z]}
1030 """, product(all_defs
,
1031 [{'name': 'layered-',
1033 'api_version': 3.2}],
1034 [{'name': '1darray', 'target': '1DArray',
1035 'dimensions': '1 250 4', 'layers': 4},
1036 {'name': '2darray', 'target': '2DArray',
1037 'dimensions': '1 250 250 4', 'layers': 4},
1038 {'name': 'cubemap', 'target': 'Cube',
1039 'dimensions': '1 250 250', 'layers': 6}]))
1041 if __name__
== '__main__':