Merge pull request #3031 from rg3igalia/sub-group-size-arb-flat-fix
[platform/upstream/glslang.git] / Test / spv.debuginfo.glsl.tese
1 /*
2 The MIT License (MIT)
3
4 Copyright (c) 2022 Sascha Willems
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15
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 THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24
25 #version 450
26
27 layout (set = 0, binding = 0) uniform UBO
28 {
29         mat4 projection;
30         mat4 modelview;
31         vec4 lightPos;
32         vec4 frustumPlanes[6];
33         float displacementFactor;
34         float tessellationFactor;
35         vec2 viewportDim;
36         float tessellatedEdgeSize;
37 } ubo;
38
39 layout (set = 0, binding = 1) uniform sampler2D displacementMap;
40
41 layout(quads, equal_spacing, cw) in;
42
43 layout (location = 0) in vec3 inNormal[];
44 layout (location = 1) in vec2 inUV[];
45
46 layout (location = 0) out vec3 outNormal;
47 layout (location = 1) out vec2 outUV;
48 layout (location = 2) out vec3 outViewVec;
49 layout (location = 3) out vec3 outLightVec;
50 layout (location = 4) out vec3 outEyePos;
51 layout (location = 5) out vec3 outWorldPos;
52
53 void main()
54 {
55         // Interpolate UV coordinates
56         vec2 uv1 = mix(inUV[0], inUV[1], gl_TessCoord.x);
57         vec2 uv2 = mix(inUV[3], inUV[2], gl_TessCoord.x);
58         outUV = mix(uv1, uv2, gl_TessCoord.y);
59
60         vec3 n1 = mix(inNormal[0], inNormal[1], gl_TessCoord.x);
61         vec3 n2 = mix(inNormal[3], inNormal[2], gl_TessCoord.x);
62         outNormal = mix(n1, n2, gl_TessCoord.y);
63
64         // Interpolate positions
65         vec4 pos1 = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);
66         vec4 pos2 = mix(gl_in[3].gl_Position, gl_in[2].gl_Position, gl_TessCoord.x);
67         vec4 pos = mix(pos1, pos2, gl_TessCoord.y);
68         // Displace
69         pos.y -= textureLod(displacementMap, outUV, 0.0).r * ubo.displacementFactor;
70         // Perspective projection
71         gl_Position = ubo.projection * ubo.modelview * pos;
72
73         // Calculate vectors for lighting based on tessellated position
74         outViewVec = -pos.xyz;
75         outLightVec = normalize(ubo.lightPos.xyz + outViewVec);
76         outWorldPos = pos.xyz;
77         outEyePos = vec3(ubo.modelview * pos);
78 }