File: glsl-predication-on-large-array.shader_test

package info (click to toggle)
piglit 0~git20220119-124bca3c9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 109,012 kB
  • sloc: ansic: 273,511; xml: 46,666; python: 33,098; lisp: 20,392; cpp: 12,480; sh: 22; makefile: 22; pascal: 5
file content (57 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[require]
GLSL >= 1.20

[vertex shader passthrough]

[fragment shader]
/*
Test predication on values from large array

Big local arrays may be handled differently than smaller ones, e.g. stored in
a global memory. However drivers may have a subtle error combining this
optimization with helper invocations of fragment shader.

Since all side-effects of helper invocations are being ignored - driver may
also erroneously ignore stores to a local array which was lowered to
a global memory.

This may cause an issue when a control flow in helper invocation depends
on the value written to such array.

To test this we make a loop which depends on a value written to a big local
array, so if stores are being ignored - the loop will become infinite,
causing a hang.
*/


#version 120

int map[2048];

uniform int indexInArray;

void main() {
  for (int i = 0; i < map.length(); i++) {
    map[i] = 0;
  }

  int i = min(indexInArray, map.length() - 1);

  do {
    if(map[i] == 1){
      break;
    }else{
      map[i] = 1;
    }
  }
  while (true);

  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}

[test]
uniform int indexInArray 500
clear color 0.0 0.0 0.0 0.0
clear
draw rect -1.0 -1.0 2.0 2.0
relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (0.0, 1.0, 0.0)