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
25 from textwrap
import dedent
27 from mako
.template
import Template
29 from modules
import utils
32 def product(ps
, *qss
):
34 Generate the cartesian product of a number of lists of dictionaries.
36 Generate a sequence with every possible combination of elements of
37 the specified lists of dictionaries. Each element of the result
38 will be the union of some combination of dictionaries from the
39 lists given as argument. The 'name' attribute of each dictionary
40 given as input is concatenated with the names of other
41 dictionaries part of the same combination to give the 'name'
42 attribute of the result.
44 for q
in (product(*qss
) if qss
else [{}]):
47 r
['name'] = ''.join(s
['name'] for s
in (p
, q
) if s
.get('name'))
53 Expand a source template for the provided list of test definitions.
55 Generate a test script for each element of the 'tests' iterable,
56 each of them should be a dictionary of definitions that will be
57 used as environment to render the source template.
59 The 'path' attribute of each dictionary gives the filename each
60 test will be written to.
62 template
= Template(dedent(src
))
66 utils
.safe_makedirs(os
.path
.dirname(t
['path']))
67 with
open(t
['path'], 'w') as f
:
68 f
.write(template
.render(**t
))
71 def gen_execution(src
, tests
):
73 Generate a shader runner test for each element of the 'tests'
77 (dict(t
, path
= os
.path
.join(
78 'spec', t
['extension'], 'execution', t
['api'],
79 t
['name'] + '.shader_test')) for t
in tests
))
82 def gen_compiler(src
, tests
):
84 Generate a GLSL parser test for each element of the 'tests'
88 (dict(t
, path
= os
.path
.join(
89 'spec', t
['extension'], 'compiler', t
['api'],
90 t
['name'] + '.' + t
['shader_stage'])) for t
in tests
))
94 # Common test definitions independent of the framebuffer fetch
97 common_defs
= [{# Allocate and bind a framebuffer object of the given
98 # format and number of samples.
99 'bind_fb': lambda fmt
, samples
= 0:
100 'fb ms {0} 250 250 {1}'.format(fmt
, samples
) if samples
> 0 else
101 ('texture storage 0 2D {0} (1 250 250)\n'
102 'fb tex 2d 0').format(fmt
) if fmt
[-1] == 'I' else
103 ('texture rgbw 0 (250, 250) {0}\n'
104 'fb tex 2d 0').format(fmt
),
106 # Resolve the contents of a framebuffer previously
107 # allocated with 'bind_fb' of the given format and
108 # samples into a newly allocated single-sample
110 'resolve_fb': lambda fmt
, samples
:
111 '' if samples
== 0 else
112 ('texture storage 0 2D {0} (1 250 250)\n'
114 'blit color nearest\n'
115 'fb read tex 2d 0\n').format(fmt
) if fmt
[-1] == 'I' else
116 ('texture rgbw 0 (250, 250) {0}\n'
118 'blit color linear\n'
119 'fb read tex 2d 0').format(fmt
),
121 # Blit the contents of the current read framebuffer
122 # into the window system framebuffer. XXX - Requires
123 # GL(ES) 3.0+ since glBlitFramebuffer doesn't exist on
124 # earlier API versions.
125 'display_fb': lambda api_version
:
126 '' if api_version
< 3.0 else
128 'blit color linear'),
130 # Declare a fragment color array set up for
131 # framebuffer fetch with the specified number of
132 # elements (n=0 indicates a single scalar output).
134 # The fragment color array can be accessed using the
135 # 'frag_data' and 'last_frag_data' macros defined
136 # below to make sure the generated test is valid
137 # irrespective of the GLSL version.
138 'decl_frag_data': lambda api_version
, layout
, n
= 0, \
139 t
= 'vec4', p
= 'mediump':
140 '' if api_version
< 3.0 and not layout
and t
== 'vec4' \
141 and p
== 'mediump' else
142 layout
+ ' ' + p
+ ' ' + t
+ ' gl_LastFragData[gl_MaxDrawBuffers];' \
143 if api_version
< 3.0 else
144 layout
+ ' inout ' + p
+ ' ' + t
+ ' fcolor;' if n
== 0 else
145 layout
+ ' inout ' + p
+ ' ' + t
+ ' fcolor[{0}];'.format(n
),
147 'frag_data': lambda api_version
, i
= -1:
148 'gl_FragData[{0}]'.format(max(0, i
)) if api_version
< 3.0 else
149 'fcolor[{0}]'.format(i
) if i
>= 0 else
152 'last_frag_data': lambda api_version
, i
= -1:
153 'gl_LastFragData[{0}]'.format(max(0, i
)) if api_version
< 3.0 else
154 'fcolor[{0}]'.format(i
) if i
>= 0 else
159 # Common test definitions for all supported extensions.
161 all_defs
= list(product(common_defs
,
162 [{'extension': 'EXT_shader_framebuffer_fetch',
165 {'extension': 'EXT_shader_framebuffer_fetch_non_coherent',
166 'layout': 'layout(noncoherent)',
167 'barrier': 'fbfetch barrier'}]))
174 # Test that the GL(ES) 2 gl_LastFragData built-in is not defined
175 # in more recent GLSL versions.
180 * expect_result: fail
181 * glsl_version: 3.0 es
182 * require_extensions: GL_${extension}
186 #extension GL_${extension} : enable
188 out highp vec4 color;
192 color = gl_LastFragData[0];
194 """, product(all_defs
,
195 [{'name': 'negative-gl_LastFragData',
197 'shader_stage': 'frag'}]))
200 # Test that the GL(ES) 2 gl_LastFragData built-in is read-only.
201 # From the EXT_shader_framebuffer_fetch extension: "[...] fragment
202 # shaders should use the read-only input array gl_LastFragData."
207 * expect_result: fail
208 * glsl_version: 1.0 es
209 * require_extensions: GL_${extension}
213 #extension GL_${extension} : enable
217 gl_LastFragData[0] = vec4(1.0);
219 """, product(all_defs
,
220 [{'name': 'negative-gl_LastFragData-write',
222 'shader_stage': 'frag'}]))
225 # Test framebuffer fetch output declarations with invalid layout
226 # qualifiers. From the EXT_shader_framebuffer_fetch extension:
228 # "It is an error to declare an inout fragment output not
229 # qualified with layout(noncoherent) if the
230 # GL_EXT_shader_framebuffer_fetch extension hasn't been enabled."
232 # "The ability to use the inout and layout(noncoherent) qualifiers
233 # at global scope in a fragment shader are optional and can be
235 # #extension GL_EXT_shader_framebuffer_fetch_non_coherent : <behavior>"
240 * expect_result: fail
241 * glsl_version: ${3.0 if api_version >= 3.0 else 1.0} es
242 * require_extensions: GL_${extension}
245 #version ${'300 es' if api_version >= 3.0 else '100'}
246 #extension GL_${extension} : enable
248 ${decl_frag_data(api_version, '' if layout else 'layout(noncoherent)')}
252 ${last_frag_data(api_version)};
254 """, product(all_defs
,
255 [{'name': 'negative-output-layout',
256 'shader_stage': 'frag'}],
257 [{'api': 'gles2', 'api_version': 2.0},
258 {'api': 'gles3', 'api_version': 3.0}]))
261 # Test that GL(ES) 3+ user-defined inout arrays are not accepted
262 # in earlier GLSL versions.
267 * expect_result: fail
268 * glsl_version: 1.0 es
269 * require_extensions: GL_${extension}
273 #extension GL_${extension} : enable
275 inout highp vec4 color;
281 """, product(all_defs
,
282 [{'name': 'negative-inout-fragment-output',
284 'shader_stage': 'frag'}]))
287 # Test that redeclaring an existing built-in fragment output as
288 # 'inout' leads to an error.
293 * expect_result: fail
294 * glsl_version: 3.0 es
295 * require_extensions: GL_${extension}
299 #extension GL_${extension} : enable
301 inout highp float gl_FragDepth;
307 """, product(all_defs
,
308 [{'name': 'negative-inout-gl_FragDepth',
310 'shader_stage': 'frag'}]))
313 # Test that vertex shader interface variables cannot be declared
319 * expect_result: fail
320 * glsl_version: 3.0 es
321 * require_extensions: GL_${extension}
325 #extension GL_${extension} : enable
327 inout highp vec4 vcolor;
332 """, product(all_defs
,
333 [{'name': 'negative-inout-vertex-output',
335 'shader_stage': 'vert'}]))
338 # Test basic framebuffer fetch functionality.
342 GL ES >= ${api_version}
343 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
345 INT GL_MAX_SAMPLES >= ${samples}
349 [vertex shader passthrough]
352 #version ${'300 es' if api_version >= 3.0 else '100'}
353 #extension GL_${extension} : enable
355 ${decl_frag_data(api_version, layout)}
359 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
360 vec4(0.5, 0.0, 0.0, 0.0);
364 ${bind_fb('GL_RGBA8', samples)}
366 clear color 0.0 0.0 1.0 0.0
373 ${resolve_fb('GL_RGBA8', samples)}
375 relative probe rect rgb (0, 0.0, 1.0, 1.0) (1.0, 0.0, 1.0)
377 ${display_fb(api_version)}
378 """, product(all_defs
,
379 [{'name': 'simple-'}],
380 [{'name': 'ss', 'api': 'gles2', 'api_version': 2.0, 'samples': 0},
381 {'name': 'ss', 'api': 'gles3', 'api_version': 3.0, 'samples': 0},
382 {'name': 'ms2', 'api': 'gles3', 'api_version': 3.0, 'samples': 2},
383 {'name': 'ms8', 'api': 'gles3', 'api_version': 3.0, 'samples': 8},
384 {'name': 'ms16', 'api': 'gles3', 'api_version': 3.0, 'samples': 16}]))
387 # Test read-back from a framebuffer with non-uniform contents
388 # rendered during a previous draw call.
392 GL ES >= ${api_version}
393 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
395 INT GL_MAX_SAMPLES >= ${samples}
400 #version ${'300 es' if api_version >= 3.0 else '100'}
402 ${'in' if api_version >= 3.0 else 'attribute'} highp vec4 vertex;
403 ${'out' if api_version >= 3.0 else 'varying'} highp vec4 vcolor;
407 gl_Position = vertex;
408 // Transform the vertex coordinates so that the R and G
409 // components of the vertex color range between 0.0 and 1.0.
410 vcolor = vec4((1.0 + vertex.x) / 2.0,
411 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
415 #version ${'300 es' if api_version >= 3.0 else '100'}
416 #extension GL_${extension} : enable
418 ${'in' if api_version >= 3.0 else 'varying'} highp vec4 vcolor;
419 ${decl_frag_data(api_version, layout, p=precision)}
423 // The condition makes sure that the else branch is
424 // taken for the top and right quadrants during the second
426 if (${last_frag_data(api_version)}.x <= 0.5 &&
427 ${last_frag_data(api_version)}.y <= 0.5) {
428 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
431 // Will give a solid color as result different for
432 // each quadrant, assuming that the first branch was
433 // taken during the first pass.
434 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
435 vec4((vcolor.x >= 0.5 ? 1.0 : 0.0) - vcolor.x,
436 (vcolor.y >= 0.5 ? 1.0 : 0.0) - vcolor.y,
442 ${bind_fb('GL_RGBA8', samples)}
444 clear color 0.0 0.0 1.0 0.0
451 ${resolve_fb('GL_RGBA8', samples)}
453 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (1.0, 0.0, 1.0)
454 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.0, 1.0, 1.0)
455 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
457 ${display_fb(api_version)}
458 """, product(all_defs
,
459 [{'name': 'nonuniform-'}],
460 [{'name': 'ss', 'api': 'gles2', 'api_version': 2.0,
461 'samples': 0, 'precision': 'mediump'},
462 {'name': 'ss-redecl-highp', 'api': 'gles2',
463 'api_version': 2.0, 'samples': 0, 'precision': 'highp'},
464 {'name': 'ss-redecl-lowp', 'api': 'gles2',
465 'api_version': 2.0, 'samples': 0, 'precision': 'lowp'},
466 {'name': 'ss', 'api': 'gles3', 'api_version': 3.0,
467 'samples': 0, 'precision': 'mediump'},
468 {'name': 'ms2', 'api': 'gles3', 'api_version': 3.0,
469 'samples': 2, 'precision': 'mediump'},
470 {'name': 'ms8', 'api': 'gles3', 'api_version': 3.0,
471 'samples': 8, 'precision': 'mediump'},
472 {'name': 'ms16', 'api': 'gles3', 'api_version': 3.0,
473 'samples': 16, 'precision': 'mediump'}]))
476 # Test basic framebuffer fetch functionality in combination with
481 GL ES >= ${api_version}
485 [vertex shader passthrough]
489 #extension GL_${extension} : enable
492 ${decl_frag_data(api_version, layout)}
496 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
497 texelFetch(s, ivec2(gl_FragCoord), 0) / 4.0;
501 ${bind_fb('GL_RGBA8')}
503 texture rgbw 1 (250, 250) GL_RGBA8
506 clear color 0.5 0.0 0.0 0.0
513 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (1.0, 0.0, 0.0)
514 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (0.5, 0.5, 0.0)
515 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.5, 0.0, 0.5)
516 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 0.5, 0.5)
518 ${display_fb(api_version)}
519 """, product(all_defs
,
522 'api_version': 3.0}]))
525 # Test non-uniform fragment discard dependent on the result read
526 # back from the framebuffer. The EXT_shader_framebuffer_fetch
527 # multisample test will be skipped if the implementation doesn't
528 # claim to support per-sample discard.
532 GL ES >= ${api_version}
536 INT GL_MAX_SAMPLES >= ${samples}
538 INT GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT >= ${1 if samples else 0}
543 in highp vec4 vertex;
544 out highp vec4 vcolor;
548 gl_Position = vertex;
549 // Transform the vertex coordinates so that the R and G
550 // components of the vertex color range between 0.0 and 1.0.
551 vcolor = vec4((1.0 + vertex.x) / 2.0,
552 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
557 #extension GL_${extension} : enable
559 in highp vec4 vcolor;
560 ${decl_frag_data(api_version, layout)}
564 // The condition makes sure that the discard branch is
565 // taken for the top and right quadrants during the second
567 if (${last_frag_data(api_version)}.x <= 0.45 &&
568 ${last_frag_data(api_version)}.y < 0.45)
569 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
570 vec4(vcolor.x >= 0.5 ? 0.5 : 0.1,
571 vcolor.y >= 0.5 ? 0.5 : 0.1,
578 ${bind_fb('GL_RGBA8', samples)}
580 clear color 0.0 0.0 1.0 0.0
587 ${resolve_fb('GL_RGBA8', samples)}
589 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (0.2, 0.2, 1.0)
590 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (0.5, 0.1, 1.0)
591 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (0.1, 0.5, 1.0)
592 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (0.5, 0.5, 1.0)
594 ${display_fb(api_version)}
595 """, product(all_defs
,
596 [{'name': 'discard-',
598 'api_version': 3.0}],
599 [{'name': 'ss', 'samples': 0},
600 {'name': 'ms8', 'samples': 8}]))
603 # Test read-back from an integer framebuffer with non-uniform
604 # contents rendered during a previous draw call. Similar to the
605 # "nonuniform" test above but using an integer framebuffer.
609 GL ES >= ${api_version}
613 INT GL_MAX_SAMPLES >= ${samples}
619 in highp vec4 vertex;
620 out highp vec4 vcolor;
624 gl_Position = vertex;
625 // Transform the vertex coordinates so that the R and G
626 // components of the vertex color range between 0.0 and 1.0.
627 vcolor = vec4((1.0 + vertex.x) / 2.0,
628 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
633 #extension GL_${extension} : enable
636 in highp vec4 vcolor;
637 ${decl_frag_data(api_version, layout, t='ivec4')}
641 if (${last_frag_data(api_version)}.x <= SCALE / 2 &&
642 ${last_frag_data(api_version)}.y <= SCALE / 2)
643 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
644 ivec4(vcolor * float(SCALE));
646 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
647 ivec4((vcolor.x >= 0.5 ? SCALE : 0)
648 - int(vcolor.x * float(SCALE)),
649 (vcolor.y >= 0.5 ? SCALE : 0)
650 - int(vcolor.y * float(SCALE)),
655 ${bind_fb('GL_RGBA8I', samples)}
664 ${resolve_fb('GL_RGBA8I', samples)}
666 relative probe rect rgba int (0.55, 0.0, 0.45, 0.45) (100, 0, 127, 100)
667 relative probe rect rgba int (0.0, 0.55, 0.45, 0.45) (0, 100, 127, 100)
668 relative probe rect rgba int (0.55, 0.55, 0.45, 0.45) (100, 100, 127, 100)
669 """, product(all_defs
,
670 [{'name': 'integer-', 'api': 'gles3'}],
671 [{'name': 'ss', 'samples': 0, 'api_version': 3.0},
672 {'name': 'ms2', 'samples': 2, 'api_version': 3.1},
673 {'name': 'ms8', 'samples': 8, 'api_version': 3.1}]))
676 # Test framebuffer fetch functionality in combination with
677 # multiple render targets.
681 GL ES >= ${api_version}
682 GLSL ES >= ${3.0 if api_version >= 3.0 else 1.0}
685 [vertex shader passthrough]
688 #version ${'300 es' if api_version >= 3.0 else '100'}
689 #extension GL_${extension} : enable
691 ${decl_frag_data(api_version, layout, 4)}
695 ${frag_data(api_version, 0)} = ${last_frag_data(api_version, 0)} +
696 vec4(0.5, 0.0, 0.0, 0.0);
697 ${frag_data(api_version, 1)} = ${last_frag_data(api_version, 1)} +
698 vec4(0.0, 0.5, 0.0, 0.0);
699 ${frag_data(api_version, 2)} = ${last_frag_data(api_version, 2)} +
700 vec4(0.5, 0.5, 0.0, 0.0);
701 ${frag_data(api_version, 3)} = ${last_frag_data(api_version, 3)} +
702 vec4(0.0, 0.0, 0.5, 0.0);
706 texture rgbw 0 (250, 250) GL_RGBA8
707 texture rgbw 1 (250, 250) GL_RGBA8
708 texture rgbw 2 (250, 250) GL_RGBA8
709 texture rgbw 3 (250, 250) GL_RGBA8
712 clear color 0.0 0.0 0.5 0.0
720 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0.0, 0.5)
723 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (0.0, 1.0, 0.5)
726 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 1.0, 0.5)
729 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (0.0, 0.0, 1.0)
731 ${display_fb(api_version)}
732 """, product(all_defs
,
734 [{'api': 'gles2', 'api_version': 2.0},
735 {'api': 'gles3', 'api_version': 3.0}]))
738 # Test framebuffer fetch functionality with multiple assignments
739 # of the fragment color input-output.
743 GL ES >= ${api_version}
755 gl_Position = vertex;
756 // Transform the vertex coordinates so that the R and G
757 // components of the vertex color range between 0.0 and 1.0.
758 vcolor = vec4((1.0 + vertex.x) / 2.0,
759 (1.0 + vertex.y) / 2.0, 0.0, 1.0);
764 #extension GL_${extension} : enable
766 in highp vec4 vcolor;
767 ${decl_frag_data(api_version, layout)}
771 // The conditional assignment will be executed for the top
772 // and right quadrants.
773 if (vcolor.x >= 0.5 || vcolor.y >= 0.5)
774 ${frag_data(api_version)} += vec4(0.5, 0, 0, 0);
776 ${frag_data(api_version)} += vec4(0.0, 0.5, 0, 0);
780 ${bind_fb('GL_RGBA8')}
782 clear color 0.0 0.0 1.0 0.0
789 relative probe rect rgb (0.0, 0.0, 0.45, 0.45) (0.0, 1.0, 1.0)
790 relative probe rect rgb (0.55, 0.0, 0.45, 0.45) (1.0, 1.0, 1.0)
791 relative probe rect rgb (0.0, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
792 relative probe rect rgb (0.55, 0.55, 0.45, 0.45) (1.0, 1.0, 1.0)
794 ${display_fb(api_version)}
795 """, product(all_defs
,
796 [{'name': 'overwrite',
798 'api_version': 3.0}]))
801 # Test framebuffer fetch functionality on individual slices of a
802 # texture render target with multiple layers or mipmap levels.
806 GL ES >= ${api_version}
810 [vertex shader passthrough]
814 #extension GL_${extension} : enable
816 ${decl_frag_data(api_version, layout)}
817 uniform highp vec4 ucolor;
821 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
826 %if target == 'Cube':
827 texture storage 0 ${target} GL_RGBA8 (${levels} 250 250)
829 texture storage 0 ${target} GL_RGBA8 (${levels} 250 250 ${layers})
832 <%! blend_colors = ['0.5 0.0 0.0 0.0',
835 '0.0 0.0 0.5 0.0'] %>
837 %for l in range(0, levels):
838 %for z in range(0, layers):
839 fb tex slice ${target} 0 ${l} ${z}
840 uniform vec4 ucolor ${blend_colors[(l + z) % 4]}
841 clear color 0.0 0.0 0.5 0.0
851 <%! expected_colors = ['(1.0, 0.0, 0.5)',
854 '(0.0, 0.0, 1.0)'] %>
856 %for l in range(0, levels):
857 %for z in range(0, layers):
858 fb tex slice ${target} 0 ${l} ${z}
859 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) ${expected_colors[(l + z) % 4]}
864 ${display_fb(api_version)}
865 """, product(all_defs
,
866 [{'name': 'single-slice-',
868 'api_version': 3.0}],
869 [{'name': '2darray', 'target': '2DArray',
870 'levels': 1, 'layers': 4},
871 {'name': '2darray-mipmap', 'target': '2DArray',
872 'levels': 4, 'layers': 1},
873 {'name': '3d', 'target': '3D',
874 'levels': 1, 'layers': 4},
875 {'name': 'cubemap', 'target': 'Cube',
876 'levels': 1, 'layers': 6}]))
879 # Test framebuffer fetch functionality on a 1D framebuffer.
885 GL_ARB_texture_storage
896 gl_Position = vertex;
897 // Transform the vertex coordinates so that the R
898 // component of the vertex color ranges between 0.0 and 1.0.
899 vcolor = vec4((1.0 + vertex.x) / 2.0, 0.7, 0.0, 1.0);
904 #extension GL_${extension} : enable
907 ${decl_frag_data(api_version, layout)}
911 // The else branch will be executed during the second
913 if (${last_frag_data(api_version)}.x <= 0.5 &&
914 ${last_frag_data(api_version)}.y <= 0.5) {
915 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
918 // Will give a solid color as result different for
919 // each half, assuming that the first branch was taken
920 // during the first pass.
921 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
922 vec4((vcolor.x >= 0.5 ? 1.0 : 0.0) - vcolor.x,
923 (vcolor.y >= 0.5 ? 1.0 : 0.0) - vcolor.y, 0, 0);
928 texture storage 0 1D GL_RGBA8 (1 250)
929 fb tex slice 1D 0 0 0
931 clear color 0.0 0.0 1.0 0.0
938 relative probe rect rgb (0.0, 0.0, 0.45, 1.0) (0.0, 1.0, 1.0)
939 relative probe rect rgb (0.55, 0.0, 0.45, 1.0) (1.0, 1.0, 1.0)
943 """, product(all_defs
,
946 'api_version': 3.2}]))
949 # Test framebuffer fetch functionality while rendering into
950 # multiple layers of an array or cubemap framebuffer
957 GL_ARB_texture_storage
960 [vertex shader passthrough]
964 layout(triangles) in;
965 layout(triangle_strip, max_vertices=18) out;
971 for (int layer = 0; layer < ${layers}; layer++) {
972 for (int i = 0; i < 3; i++) {
973 gl_Position = gl_in[i].gl_Position;
974 gl_Layer = glayer = layer;
983 #extension GL_${extension} : enable
986 ${decl_frag_data(api_version, layout)}
990 ${frag_data(api_version)} = ${last_frag_data(api_version)} +
991 (glayer == 5 ? vec4(0.0, 0.5, 0.5, 0.0) :
992 glayer == 4 ? vec4(0.5, 0.0, 0.5, 0.0) :
993 glayer == 3 ? vec4(0.0, 0.0, 0.5, 0.0) :
994 glayer == 2 ? vec4(0.5, 0.5, 0.0, 0.0) :
995 glayer == 1 ? vec4(0.0, 0.5, 0.0, 0.0) :
996 vec4(0.5, 0.0, 0.0, 0.0));
1000 texture storage 0 ${target} GL_RGBA8 (${dimensions})
1003 clear color 0.0 0.0 0.5 0.0
1010 <%! expected_colors = ['(1.0, 0.0, 0.5)',
1015 '(0.0, 1.0, 1.0)'] %>
1017 %for z in range(0, layers):
1018 fb tex slice ${target} 0 0 ${z}
1019 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) ${expected_colors[z]}
1024 """, product(all_defs
,
1025 [{'name': 'layered-',
1027 'api_version': 3.2}],
1028 [{'name': '1darray', 'target': '1DArray',
1029 'dimensions': '1 250 4', 'layers': 4},
1030 {'name': '2darray', 'target': '2DArray',
1031 'dimensions': '1 250 250 4', 'layers': 4},
1032 {'name': 'cubemap', 'target': 'Cube',
1033 'dimensions': '1 250 250', 'layers': 6}]))
1035 if __name__
== '__main__':