The open source OpenXR runtime
1// Copyright 2023, Collabora Ltd.
2// Author: Jakob Bornecrantz <jakob@collabora.com>
3// SPDX-License-Identifier: BSL-1.0
4
5#version 460
6
7
8layout (binding = 0, std140) uniform Config
9{
10 vec4 post_transform;
11 mat4 mvp;
12} ubo;
13
14layout (location = 0) out vec2 out_uv;
15
16out gl_PerVertex
17{
18 vec4 gl_Position;
19};
20
21vec2 pos[4] = {
22 vec2(0, 0),
23 vec2(0, 1),
24 vec2(1, 0),
25 vec2(1, 1),
26};
27
28void main()
29{
30 // We now get a unmodified UV position.
31 vec2 in_uv = pos[gl_VertexIndex % 4];
32
33 // Center the quad at origin.
34 vec2 pos = in_uv - 0.5;
35
36 // Flip to OpenXR coordinate system.
37 pos.y = -pos.y;
38
39 // Place quad in the center of the mvp, it will scale it.
40 vec4 position = ubo.mvp * vec4(pos, 0.0f, 1.0f);
41
42 // To deal with OpenGL flip and sub image view.
43 vec2 uv = fma(in_uv, ubo.post_transform.zw, ubo.post_transform.xy);
44
45 gl_Position = position;
46 out_uv = uv;
47}