[macOS] Cannot compile GSK shaders: syntax error: Array size must appear after variable name
Some GSK shaders do not compile.
Here's the terminal output:
FF094:lib user931145$ gtk4-demo
** Message: 14:12:41.318: For syntax highlighting, install the “highlight” program
Gsk-Message: 14:12:51.397: Failed to realize renderer of type 'GskGLRenderer' for surface 'GdkMacosToplevelSurface': Compilation failure in shader.
Source Code: 1| #version 110
2| #define GSK_LEGACY 1
3| #define NO_CLIP 1
4| #ifndef GSK_LEGACY
5| precision highp float;
6| #endif
7|
8| #if defined(GSK_GLES) || defined(GSK_LEGACY)
9| #define _OUT_ varying
10| #define _IN_ varying
11| #define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
12| #else
13| #define _OUT_ out
14| #define _IN_ in
15| #define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
16| #endif
17|
18|
19| struct GskRoundedRect
20| {
21| vec4 bounds; // Top left and bottom right
22| // Look, arrays can't be in structs if you want to return the struct
23| // from a function in gles or whatever. Just kill me.
24| vec4 corner_points1; // xy = top left, zw = top right
25| vec4 corner_points2; // xy = bottom right, zw = bottom left
26| };
27|
28| void gsk_rounded_rect_normalize(inout GskRoundedRect r)
29| {
30| if (r.bounds.x > r.bounds.z)
31| {
32| float t = r.bounds.x;
33| r.bounds.x = r.bounds.z;
34| r.bounds.z = t;
35|
36| vec2 c = r.corner_points1.xy;
37| r.corner_points1.xy = r.corner_points1.zw;
38| r.corner_points1.zw = c;
39|
40| c = r.corner_points2.xy;
41| r.corner_points2.xy = r.corner_points2.zw;
42| r.corner_points2.zw = c;
43| }
44|
45| if (r.bounds.y > r.bounds.w)
46| {
47| float t = r.bounds.y;
48| r.bounds.y = r.bounds.w;
49| r.bounds.w = t;
50|
51| vec2 c = r.corner_points1.xy;
52| r.corner_points1.xy = r.corner_points2.xy;
53| r.corner_points2.xy = c;
54|
55| c = r.corner_points1.zw;
56| r.corner_points1.zw = r.corner_points2.zw;
57| r.corner_points2.zw = c;
58| }
59| }
60|
61| void gsk_bounds_normalize (inout vec4 bounds)
62| {
63| if (bounds.x > bounds.z)
64| {
65| float t = bounds.x;
66| bounds.x = bounds.z;
67| bounds.z = t;
68| }
69| if (bounds.y > bounds.w)
70| {
71| float t = bounds.y;
72| bounds.y = bounds.w;
73| bounds.w = t;
74| }
75| }
76|
77| // Transform from a C GskRoundedRect to what we need.
78| GskRoundedRect
79| gsk_create_rect(vec4[3] data)
80| {
81| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
82|
83| vec4 corner_points1 = vec4(bounds.xy + data[1].xy,
84| bounds.zy + vec2(data[1].zw * vec2(-1, 1)));
85| vec4 corner_points2 = vec4(bounds.zw + (data[2].xy * vec2(-1, -1)),
86| bounds.xw + vec2(data[2].zw * vec2(1, -1)));
87|
88| GskRoundedRect rect = GskRoundedRect(bounds, corner_points1, corner_points2);
89|
90| gsk_rounded_rect_normalize (rect);
91|
92| return rect;
93| }
94|
95| vec4
96| gsk_get_bounds(vec4[3] data)
97| {
98| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
99|
100| gsk_bounds_normalize (bounds);
101|
102| return bounds;
103| }
104|
105| vec4 gsk_premultiply(vec4 c) {
106| return vec4(c.rgb * c.a, c.a);
107| }
108|
109| vec4 gsk_scaled_premultiply(vec4 c, float s) {
110| // Fast version of gsk_premultiply(c) * s
111| // 4 muls instead of 7
112| float a = s * c.a;
113|
114| return vec4(c.rgb * a, a);
115| }
116| uniform mat4 u_projection;
117| uniform mat4 u_modelview;
118| uniform float u_alpha;
119|
120| #if defined(GSK_GLES) || defined(GSK_LEGACY)
121| attribute vec2 aPosition;
122| attribute vec2 aUv;
123| attribute vec4 aColor;
124| attribute vec4 aColor2;
125| _OUT_ vec2 vUv;
126| #else
127| _IN_ vec2 aPosition;
128| _IN_ vec2 aUv;
129| _IN_ vec4 aColor;
130| _IN_ vec4 aColor2;
131| _OUT_ vec2 vUv;
132| #endif
133|
134| // amount is: top, right, bottom, left
135| GskRoundedRect
136| gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
137| {
138| vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
139| vec4 new_corner_points1 = r.corner_points1;
140| vec4 new_corner_points2 = r.corner_points2;
141|
142| if (r.corner_points1.xy == r.bounds.xy) new_corner_points1.xy = new_bounds.xy;
143| if (r.corner_points1.zw == r.bounds.zy) new_corner_points1.zw = new_bounds.zy;
144| if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
145| if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
146|
147| return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
148| }
149|
150| void
151| gsk_rounded_rect_offset(inout GskRoundedRect r, vec2 offset)
152| {
153| r.bounds.xy += offset;
154| r.bounds.zw += offset;
155| r.corner_points1.xy += offset;
156| r.corner_points1.zw += offset;
157| r.corner_points2.xy += offset;
158| r.corner_points2.zw += offset;
159| }
160|
161| void gsk_rounded_rect_transform(inout GskRoundedRect r, mat4 mat)
162| {
163| r.bounds.xy = (mat * vec4(r.bounds.xy, 0.0, 1.0)).xy;
164| r.bounds.zw = (mat * vec4(r.bounds.zw, 0.0, 1.0)).xy;
165|
166| r.corner_points1.xy = (mat * vec4(r.corner_points1.xy, 0.0, 1.0)).xy;
167| r.corner_points1.zw = (mat * vec4(r.corner_points1.zw, 0.0, 1.0)).xy;
168|
169| r.corner_points2.xy = (mat * vec4(r.corner_points2.xy, 0.0, 1.0)).xy;
170| r.corner_points2.zw = (mat * vec4(r.corner_points2.zw, 0.0, 1.0)).xy;
171| }
172|
173| #if defined(GSK_LEGACY)
174| // Can't have out or inout array parameters...
175| #define gsk_rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] = r.corner_points2;
176| #else
177| void gsk_rounded_rect_encode(GskRoundedRect r, out _GSK_ROUNDED_RECT_UNIFORM_ out_r)
178| {
179| #if defined(GSK_GLES)
180| out_r[0] = r.bounds;
181| out_r[1] = r.corner_points1;
182| out_r[2] = r.corner_points2;
183| #else
184| out_r = r;
185| #endif
186| }
187|
188| #endif
189|
190| // blend.glsl
191|
192| void main() {
193| gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
194|
195| vUv = vec2(aUv.x, aUv.y);
196| }
197|
198| // FRAGMENT_SHADER:
Error Message:
ERROR: 0:79: 'data' : syntax error: Array size must appear after variable name
Gsk-Message: 14:13:00.462: Failed to realize renderer of type 'GskGLRenderer' for surface 'GdkMacosPopupSurface': Compilation failure in shader.
Source Code: 1| #version 110
2| #define GSK_LEGACY 1
3| #define NO_CLIP 1
4| #ifndef GSK_LEGACY
5| precision highp float;
6| #endif
7|
8| #if defined(GSK_GLES) || defined(GSK_LEGACY)
9| #define _OUT_ varying
10| #define _IN_ varying
11| #define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
12| #else
13| #define _OUT_ out
14| #define _IN_ in
15| #define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
16| #endif
17|
18|
19| struct GskRoundedRect
20| {
21| vec4 bounds; // Top left and bottom right
22| // Look, arrays can't be in structs if you want to return the struct
23| // from a function in gles or whatever. Just kill me.
24| vec4 corner_points1; // xy = top left, zw = top right
25| vec4 corner_points2; // xy = bottom right, zw = bottom left
26| };
27|
28| void gsk_rounded_rect_normalize(inout GskRoundedRect r)
29| {
30| if (r.bounds.x > r.bounds.z)
31| {
32| float t = r.bounds.x;
33| r.bounds.x = r.bounds.z;
34| r.bounds.z = t;
35|
36| vec2 c = r.corner_points1.xy;
37| r.corner_points1.xy = r.corner_points1.zw;
38| r.corner_points1.zw = c;
39|
40| c = r.corner_points2.xy;
41| r.corner_points2.xy = r.corner_points2.zw;
42| r.corner_points2.zw = c;
43| }
44|
45| if (r.bounds.y > r.bounds.w)
46| {
47| float t = r.bounds.y;
48| r.bounds.y = r.bounds.w;
49| r.bounds.w = t;
50|
51| vec2 c = r.corner_points1.xy;
52| r.corner_points1.xy = r.corner_points2.xy;
53| r.corner_points2.xy = c;
54|
55| c = r.corner_points1.zw;
56| r.corner_points1.zw = r.corner_points2.zw;
57| r.corner_points2.zw = c;
58| }
59| }
60|
61| void gsk_bounds_normalize (inout vec4 bounds)
62| {
63| if (bounds.x > bounds.z)
64| {
65| float t = bounds.x;
66| bounds.x = bounds.z;
67| bounds.z = t;
68| }
69| if (bounds.y > bounds.w)
70| {
71| float t = bounds.y;
72| bounds.y = bounds.w;
73| bounds.w = t;
74| }
75| }
76|
77| // Transform from a C GskRoundedRect to what we need.
78| GskRoundedRect
79| gsk_create_rect(vec4[3] data)
80| {
81| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
82|
83| vec4 corner_points1 = vec4(bounds.xy + data[1].xy,
84| bounds.zy + vec2(data[1].zw * vec2(-1, 1)));
85| vec4 corner_points2 = vec4(bounds.zw + (data[2].xy * vec2(-1, -1)),
86| bounds.xw + vec2(data[2].zw * vec2(1, -1)));
87|
88| GskRoundedRect rect = GskRoundedRect(bounds, corner_points1, corner_points2);
89|
90| gsk_rounded_rect_normalize (rect);
91|
92| return rect;
93| }
94|
95| vec4
96| gsk_get_bounds(vec4[3] data)
97| {
98| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
99|
100| gsk_bounds_normalize (bounds);
101|
102| return bounds;
103| }
104|
105| vec4 gsk_premultiply(vec4 c) {
106| return vec4(c.rgb * c.a, c.a);
107| }
108|
109| vec4 gsk_scaled_premultiply(vec4 c, float s) {
110| // Fast version of gsk_premultiply(c) * s
111| // 4 muls instead of 7
112| float a = s * c.a;
113|
114| return vec4(c.rgb * a, a);
115| }
116| uniform mat4 u_projection;
117| uniform mat4 u_modelview;
118| uniform float u_alpha;
119|
120| #if defined(GSK_GLES) || defined(GSK_LEGACY)
121| attribute vec2 aPosition;
122| attribute vec2 aUv;
123| attribute vec4 aColor;
124| attribute vec4 aColor2;
125| _OUT_ vec2 vUv;
126| #else
127| _IN_ vec2 aPosition;
128| _IN_ vec2 aUv;
129| _IN_ vec4 aColor;
130| _IN_ vec4 aColor2;
131| _OUT_ vec2 vUv;
132| #endif
133|
134| // amount is: top, right, bottom, left
135| GskRoundedRect
136| gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
137| {
138| vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
139| vec4 new_corner_points1 = r.corner_points1;
140| vec4 new_corner_points2 = r.corner_points2;
141|
142| if (r.corner_points1.xy == r.bounds.xy) new_corner_points1.xy = new_bounds.xy;
143| if (r.corner_points1.zw == r.bounds.zy) new_corner_points1.zw = new_bounds.zy;
144| if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
145| if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
146|
147| return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
148| }
149|
150| void
151| gsk_rounded_rect_offset(inout GskRoundedRect r, vec2 offset)
152| {
153| r.bounds.xy += offset;
154| r.bounds.zw += offset;
155| r.corner_points1.xy += offset;
156| r.corner_points1.zw += offset;
157| r.corner_points2.xy += offset;
158| r.corner_points2.zw += offset;
159| }
160|
161| void gsk_rounded_rect_transform(inout GskRoundedRect r, mat4 mat)
162| {
163| r.bounds.xy = (mat * vec4(r.bounds.xy, 0.0, 1.0)).xy;
164| r.bounds.zw = (mat * vec4(r.bounds.zw, 0.0, 1.0)).xy;
165|
166| r.corner_points1.xy = (mat * vec4(r.corner_points1.xy, 0.0, 1.0)).xy;
167| r.corner_points1.zw = (mat * vec4(r.corner_points1.zw, 0.0, 1.0)).xy;
168|
169| r.corner_points2.xy = (mat * vec4(r.corner_points2.xy, 0.0, 1.0)).xy;
170| r.corner_points2.zw = (mat * vec4(r.corner_points2.zw, 0.0, 1.0)).xy;
171| }
172|
173| #if defined(GSK_LEGACY)
174| // Can't have out or inout array parameters...
175| #define gsk_rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] = r.corner_points2;
176| #else
177| void gsk_rounded_rect_encode(GskRoundedRect r, out _GSK_ROUNDED_RECT_UNIFORM_ out_r)
178| {
179| #if defined(GSK_GLES)
180| out_r[0] = r.bounds;
181| out_r[1] = r.corner_points1;
182| out_r[2] = r.corner_points2;
183| #else
184| out_r = r;
185| #endif
186| }
187|
188| #endif
189|
190| // blend.glsl
191|
192| void main() {
193| gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
194|
195| vUv = vec2(aUv.x, aUv.y);
196| }
197|
198| // FRAGMENT_SHADER:
Error Message:
ERROR: 0:79: 'data' : syntax error: Array size must appear after variable name
Gsk-Message: 14:13:01.984: Failed to realize renderer of type 'GskGLRenderer' for surface 'GdkMacosToplevelSurface': Compilation failure in shader.
Source Code: 1| #version 110
2| #define GSK_LEGACY 1
3| #define NO_CLIP 1
4| #ifndef GSK_LEGACY
5| precision highp float;
6| #endif
7|
8| #if defined(GSK_GLES) || defined(GSK_LEGACY)
9| #define _OUT_ varying
10| #define _IN_ varying
11| #define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
12| #else
13| #define _OUT_ out
14| #define _IN_ in
15| #define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
16| #endif
17|
18|
19| struct GskRoundedRect
20| {
21| vec4 bounds; // Top left and bottom right
22| // Look, arrays can't be in structs if you want to return the struct
23| // from a function in gles or whatever. Just kill me.
24| vec4 corner_points1; // xy = top left, zw = top right
25| vec4 corner_points2; // xy = bottom right, zw = bottom left
26| };
27|
28| void gsk_rounded_rect_normalize(inout GskRoundedRect r)
29| {
30| if (r.bounds.x > r.bounds.z)
31| {
32| float t = r.bounds.x;
33| r.bounds.x = r.bounds.z;
34| r.bounds.z = t;
35|
36| vec2 c = r.corner_points1.xy;
37| r.corner_points1.xy = r.corner_points1.zw;
38| r.corner_points1.zw = c;
39|
40| c = r.corner_points2.xy;
41| r.corner_points2.xy = r.corner_points2.zw;
42| r.corner_points2.zw = c;
43| }
44|
45| if (r.bounds.y > r.bounds.w)
46| {
47| float t = r.bounds.y;
48| r.bounds.y = r.bounds.w;
49| r.bounds.w = t;
50|
51| vec2 c = r.corner_points1.xy;
52| r.corner_points1.xy = r.corner_points2.xy;
53| r.corner_points2.xy = c;
54|
55| c = r.corner_points1.zw;
56| r.corner_points1.zw = r.corner_points2.zw;
57| r.corner_points2.zw = c;
58| }
59| }
60|
61| void gsk_bounds_normalize (inout vec4 bounds)
62| {
63| if (bounds.x > bounds.z)
64| {
65| float t = bounds.x;
66| bounds.x = bounds.z;
67| bounds.z = t;
68| }
69| if (bounds.y > bounds.w)
70| {
71| float t = bounds.y;
72| bounds.y = bounds.w;
73| bounds.w = t;
74| }
75| }
76|
77| // Transform from a C GskRoundedRect to what we need.
78| GskRoundedRect
79| gsk_create_rect(vec4[3] data)
80| {
81| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
82|
83| vec4 corner_points1 = vec4(bounds.xy + data[1].xy,
84| bounds.zy + vec2(data[1].zw * vec2(-1, 1)));
85| vec4 corner_points2 = vec4(bounds.zw + (data[2].xy * vec2(-1, -1)),
86| bounds.xw + vec2(data[2].zw * vec2(1, -1)));
87|
88| GskRoundedRect rect = GskRoundedRect(bounds, corner_points1, corner_points2);
89|
90| gsk_rounded_rect_normalize (rect);
91|
92| return rect;
93| }
94|
95| vec4
96| gsk_get_bounds(vec4[3] data)
97| {
98| vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
99|
100| gsk_bounds_normalize (bounds);
101|
102| return bounds;
103| }
104|
105| vec4 gsk_premultiply(vec4 c) {
106| return vec4(c.rgb * c.a, c.a);
107| }
108|
109| vec4 gsk_scaled_premultiply(vec4 c, float s) {
110| // Fast version of gsk_premultiply(c) * s
111| // 4 muls instead of 7
112| float a = s * c.a;
113|
114| return vec4(c.rgb * a, a);
115| }
116| uniform mat4 u_projection;
117| uniform mat4 u_modelview;
118| uniform float u_alpha;
119|
120| #if defined(GSK_GLES) || defined(GSK_LEGACY)
121| attribute vec2 aPosition;
122| attribute vec2 aUv;
123| attribute vec4 aColor;
124| attribute vec4 aColor2;
125| _OUT_ vec2 vUv;
126| #else
127| _IN_ vec2 aPosition;
128| _IN_ vec2 aUv;
129| _IN_ vec4 aColor;
130| _IN_ vec4 aColor2;
131| _OUT_ vec2 vUv;
132| #endif
133|
134| // amount is: top, right, bottom, left
135| GskRoundedRect
136| gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
137| {
138| vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
139| vec4 new_corner_points1 = r.corner_points1;
140| vec4 new_corner_points2 = r.corner_points2;
141|
142| if (r.corner_points1.xy == r.bounds.xy) new_corner_points1.xy = new_bounds.xy;
143| if (r.corner_points1.zw == r.bounds.zy) new_corner_points1.zw = new_bounds.zy;
144| if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
145| if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
146|
147| return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
148| }
149|
150| void
151| gsk_rounded_rect_offset(inout GskRoundedRect r, vec2 offset)
152| {
153| r.bounds.xy += offset;
154| r.bounds.zw += offset;
155| r.corner_points1.xy += offset;
156| r.corner_points1.zw += offset;
157| r.corner_points2.xy += offset;
158| r.corner_points2.zw += offset;
159| }
160|
161| void gsk_rounded_rect_transform(inout GskRoundedRect r, mat4 mat)
162| {
163| r.bounds.xy = (mat * vec4(r.bounds.xy, 0.0, 1.0)).xy;
164| r.bounds.zw = (mat * vec4(r.bounds.zw, 0.0, 1.0)).xy;
165|
166| r.corner_points1.xy = (mat * vec4(r.corner_points1.xy, 0.0, 1.0)).xy;
167| r.corner_points1.zw = (mat * vec4(r.corner_points1.zw, 0.0, 1.0)).xy;
168|
169| r.corner_points2.xy = (mat * vec4(r.corner_points2.xy, 0.0, 1.0)).xy;
170| r.corner_points2.zw = (mat * vec4(r.corner_points2.zw, 0.0, 1.0)).xy;
171| }
172|
173| #if defined(GSK_LEGACY)
174| // Can't have out or inout array parameters...
175| #define gsk_rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] = r.corner_points2;
176| #else
177| void gsk_rounded_rect_encode(GskRoundedRect r, out _GSK_ROUNDED_RECT_UNIFORM_ out_r)
178| {
179| #if defined(GSK_GLES)
180| out_r[0] = r.bounds;
181| out_r[1] = r.corner_points1;
182| out_r[2] = r.corner_points2;
183| #else
184| out_r = r;
185| #endif
186| }
187|
188| #endif
189|
190| // blend.glsl
191|
192| void main() {
193| gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
194|
195| vUv = vec2(aUv.x, aUv.y);
196| }
197|
198| // FRAGMENT_SHADER:
Error Message:
ERROR: 0:79: 'data' : syntax error: Array size must appear after variable name
Edited by Luca Bacci