Skip to content

Commit 1cbd558

Browse files
committed
[gfx] Make sure that all UBOs have variable names to avoid problems on metal
1 parent cfaf286 commit 1cbd558

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

Threedim/ModelDisplay/ModelDisplayNode.cpp

+25-39
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ layout(location = 2) out vec2 v_texcoord;
2525
2626
layout(std140, binding = 0) uniform renderer_t {
2727
mat4 clipSpaceCorrMatrix;
28-
vec2 texcoordAdjust;
2928
vec2 renderSize;
30-
};
29+
} renderer;
3130
3231
layout(std140, binding = 2) uniform material_t {
3332
mat4 matrixModelViewProjection;
@@ -47,16 +46,15 @@ void main()
4746
esVertex = position;
4847
esNormal = normal;
4948
v_texcoord = texcoord;
50-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
49+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
5150
}
5251
)_";
5352

5453
static const constexpr auto model_display_fragment_shader_phong = R"_(#version 450
5554
layout(std140, binding = 0) uniform renderer_t {
5655
mat4 clipSpaceCorrMatrix;
57-
vec2 texcoordAdjust;
5856
vec2 renderSize;
59-
};
57+
} renderer;
6058
6159
layout(std140, binding = 1) uniform process_t {
6260
float time;
@@ -71,7 +69,7 @@ layout(std140, binding = 1) uniform process_t {
7169
vec4 channelTime;
7270
7371
float sampleRate;
74-
};
72+
} process;
7573
7674
layout(std140, binding = 2) uniform material_t {
7775
mat4 matrixModelViewProjection;
@@ -102,8 +100,8 @@ void main ()
102100
{
103101
vec3 normal = normalize(esNormal);
104102
vec3 light;
105-
lightPosition.y = sin(time) * 20.;
106-
lightPosition.z = cos(time) * 50.;
103+
lightPosition.y = sin(process.time) * 20.;
104+
lightPosition.z = cos(process.time) * 50.;
107105
if(lightPosition.w == 0.0)
108106
{
109107
light = normalize(lightPosition.xyz);
@@ -136,9 +134,8 @@ layout(location = 0) out vec2 v_texcoord;
136134
137135
layout(std140, binding = 0) uniform renderer_t {
138136
mat4 clipSpaceCorrMatrix;
139-
vec2 texcoordAdjust;
140137
vec2 renderSize;
141-
};
138+
} renderer;
142139
143140
layout(std140, binding = 2) uniform material_t {
144141
mat4 matrixModelViewProjection;
@@ -156,16 +153,15 @@ out gl_PerVertex { vec4 gl_Position; };
156153
void main()
157154
{
158155
v_texcoord = texcoord;
159-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
156+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
160157
}
161158
)_";
162159

163160
static const constexpr auto model_display_fragment_shader_texcoord = R"_(#version 450
164161
layout(std140, binding = 0) uniform renderer_t {
165162
mat4 clipSpaceCorrMatrix;
166-
vec2 texcoordAdjust;
167163
vec2 renderSize;
168-
};
164+
} renderer;
169165
170166
layout(std140, binding = 2) uniform material_t {
171167
mat4 matrixModelViewProjection;
@@ -200,9 +196,8 @@ layout(location = 1) out vec3 v_coords;
200196
201197
layout(std140, binding = 0) uniform renderer_t {
202198
mat4 clipSpaceCorrMatrix;
203-
vec2 texcoordAdjust;
204199
vec2 renderSize;
205-
};
200+
} renderer;
206201
207202
layout(std140, binding = 2) uniform material_t {
208203
mat4 matrixModelViewProjection;
@@ -221,16 +216,15 @@ void main()
221216
{
222217
v_normal = normal;
223218
v_coords = (mat.matrixModel * vec4(position.xyz, 1.0)).xyz;
224-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
219+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
225220
}
226221
)_";
227222

228223
static const constexpr auto model_display_fragment_shader_triplanar = R"_(#version 450
229224
layout(std140, binding = 0) uniform renderer_t {
230225
mat4 clipSpaceCorrMatrix;
231-
vec2 texcoordAdjust;
232226
vec2 renderSize;
233-
};
227+
} renderer;
234228
235229
layout(std140, binding = 2) uniform material_t {
236230
mat4 matrixModelViewProjection;
@@ -274,9 +268,8 @@ layout(location = 1) out vec3 v_n;
274268
275269
layout(std140, binding = 0) uniform renderer_t {
276270
mat4 clipSpaceCorrMatrix;
277-
vec2 texcoordAdjust;
278271
vec2 renderSize;
279-
};
272+
} renderer;
280273
281274
layout(std140, binding = 2) uniform material_t {
282275
mat4 matrixModelViewProjection;
@@ -296,15 +289,14 @@ void main()
296289
vec4 p = vec4( position, 1. );
297290
v_e = normalize( vec3( mat.matrixModelView * p ) );
298291
v_n = normal; //normalize( mat.matrixNormal * normal );
299-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
292+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
300293
}
301294
)_";
302295
static const constexpr auto model_display_fragment_shader_spherical = R"_(#version 450
303296
layout(std140, binding = 0) uniform renderer_t {
304297
mat4 clipSpaceCorrMatrix;
305-
vec2 texcoordAdjust;
306298
vec2 renderSize;
307-
};
299+
} renderer;
308300
309301
layout(std140, binding = 2) uniform material_t {
310302
mat4 matrixModelViewProjection;
@@ -345,9 +337,8 @@ layout(location = 1) out vec3 v_n;
345337
346338
layout(std140, binding = 0) uniform renderer_t {
347339
mat4 clipSpaceCorrMatrix;
348-
vec2 texcoordAdjust;
349340
vec2 renderSize;
350-
};
341+
} renderer;
351342
352343
layout(std140, binding = 2) uniform material_t {
353344
mat4 matrixModelViewProjection;
@@ -372,15 +363,14 @@ void main()
372363
vec4 p = vec4( position, 1. );
373364
v_e = normalize( vec3( mat.matrixModelView * p ) );
374365
v_n = normalize( mat.matrixNormal * normal );
375-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
366+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
376367
}
377368
)_";
378369
static const constexpr auto model_display_fragment_shader_spherical2 = R"_(#version 450
379370
layout(std140, binding = 0) uniform renderer_t {
380371
mat4 clipSpaceCorrMatrix;
381-
vec2 texcoordAdjust;
382372
vec2 renderSize;
383-
};
373+
} renderer;
384374
385375
layout(std140, binding = 2) uniform material_t {
386376
mat4 matrixModelViewProjection;
@@ -412,9 +402,8 @@ layout(location = 0) in vec3 position;
412402
413403
layout(std140, binding = 0) uniform renderer_t {
414404
mat4 clipSpaceCorrMatrix;
415-
vec2 texcoordAdjust;
416405
vec2 renderSize;
417-
};
406+
} renderer;
418407
419408
layout(std140, binding = 2) uniform material_t {
420409
mat4 matrixModelViewProjection;
@@ -431,16 +420,15 @@ out gl_PerVertex { vec4 gl_Position; };
431420
432421
void main()
433422
{
434-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
423+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
435424
}
436425
)_";
437426

438427
static const constexpr auto model_display_fragment_shader_viewspace = R"_(#version 450
439428
layout(std140, binding = 0) uniform renderer_t {
440429
mat4 clipSpaceCorrMatrix;
441-
vec2 texcoordAdjust;
442430
vec2 renderSize;
443-
};
431+
} renderer;
444432
445433
layout(std140, binding = 2) uniform material_t {
446434
mat4 matrixModelViewProjection;
@@ -457,7 +445,7 @@ layout(location = 0) out vec4 fragColor;
457445
458446
void main ()
459447
{
460-
fragColor = texture(y_tex, gl_FragCoord.xy / renderSize.xy);
448+
fragColor = texture(y_tex, gl_FragCoord.xy / renderer.renderSize.xy);
461449
}
462450
)_";
463451

@@ -468,9 +456,8 @@ layout(location = 1) out vec2 v_bary;
468456
469457
layout(std140, binding = 0) uniform renderer_t {
470458
mat4 clipSpaceCorrMatrix;
471-
vec2 texcoordAdjust;
472459
vec2 renderSize;
473-
};
460+
} renderer;
474461
475462
layout(std140, binding = 2) uniform material_t {
476463
mat4 matrixModelViewProjection;
@@ -491,16 +478,15 @@ void main()
491478
else if(gl_VertexIndex % 3 == 1) v_bary = vec2(0, 1);
492479
else if(gl_VertexIndex % 3 == 2) v_bary = vec2(1, 0);
493480
494-
gl_Position = clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
481+
gl_Position = renderer.clipSpaceCorrMatrix * mat.matrixModelViewProjection * vec4(position.xyz, 1.0);
495482
}
496483
)_";
497484

498485
static const constexpr auto model_display_fragment_shader_barycentric = R"_(#version 450
499486
layout(std140, binding = 0) uniform renderer_t {
500487
mat4 clipSpaceCorrMatrix;
501-
vec2 texcoordAdjust;
502488
vec2 renderSize;
503-
};
489+
} renderer;
504490
505491
layout(std140, binding = 2) uniform material_t {
506492
mat4 matrixModelViewProjection;

0 commit comments

Comments
 (0)