Added pipeline statistics query example
This commit is contained in:
parent
f62115ffca
commit
a17e3924b3
13 changed files with 660 additions and 0 deletions
19
data/shaders/pipelinestatistics/scene.frag
Normal file
19
data/shaders/pipelinestatistics/scene.frag
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec3 inViewVec;
|
||||
layout (location = 3) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
vec3 V = normalize(inViewVec);
|
||||
vec3 R = reflect(-L, N);
|
||||
vec3 diffuse = max(dot(N, L), 0.0) * inColor;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 8.0) * vec3(0.75);
|
||||
outFragColor = vec4(diffuse + specular, 0.5);
|
||||
}
|
||||
BIN
data/shaders/pipelinestatistics/scene.frag.spv
Normal file
BIN
data/shaders/pipelinestatistics/scene.frag.spv
Normal file
Binary file not shown.
30
data/shaders/pipelinestatistics/scene.tesc
Normal file
30
data/shaders/pipelinestatistics/scene.tesc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#version 450
|
||||
|
||||
layout (vertices = 3) out;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec3 inColor[];
|
||||
layout (location = 2) in vec3 inViewVec[];
|
||||
layout (location = 3) in vec3 inLightVec[];
|
||||
|
||||
layout (location = 0) out vec3 outNormal[3];
|
||||
layout (location = 1) out vec3 outColor[3];
|
||||
layout (location = 2) out vec3 outViewVec[3];
|
||||
layout (location = 3) out vec3 outLightVec[3];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = 2.0;
|
||||
gl_TessLevelOuter[0] = 1.0;
|
||||
gl_TessLevelOuter[1] = 1.0;
|
||||
gl_TessLevelOuter[2] = 1.0;
|
||||
}
|
||||
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
outColor[gl_InvocationID] = inColor[gl_InvocationID];
|
||||
outViewVec[gl_InvocationID] = inViewVec[gl_InvocationID];
|
||||
outLightVec[gl_InvocationID] = inLightVec[gl_InvocationID];
|
||||
}
|
||||
BIN
data/shaders/pipelinestatistics/scene.tesc.spv
Normal file
BIN
data/shaders/pipelinestatistics/scene.tesc.spv
Normal file
Binary file not shown.
24
data/shaders/pipelinestatistics/scene.tese
Normal file
24
data/shaders/pipelinestatistics/scene.tese
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#version 450
|
||||
|
||||
layout (triangles) in;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec3 inColor[];
|
||||
layout (location = 2) in vec3 inViewVec[];
|
||||
layout (location = 3) in vec3 inLightVec[];
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec3 outViewVec;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = (gl_TessCoord.x * gl_in[2].gl_Position) +
|
||||
(gl_TessCoord.y * gl_in[1].gl_Position) +
|
||||
(gl_TessCoord.z * gl_in[0].gl_Position);
|
||||
outNormal = gl_TessCoord.x*inNormal[2] + gl_TessCoord.y*inNormal[1] + gl_TessCoord.z*inNormal[0];
|
||||
outViewVec = gl_TessCoord.x*inViewVec[2] + gl_TessCoord.y*inViewVec[1] + gl_TessCoord.z*inViewVec[0];
|
||||
outLightVec = gl_TessCoord.x*inLightVec[2] + gl_TessCoord.y*inLightVec[1] + gl_TessCoord.z*inLightVec[0];
|
||||
outColor = inColor[0];
|
||||
}
|
||||
BIN
data/shaders/pipelinestatistics/scene.tese.spv
Normal file
BIN
data/shaders/pipelinestatistics/scene.tese.spv
Normal file
Binary file not shown.
41
data/shaders/pipelinestatistics/scene.vert
Normal file
41
data/shaders/pipelinestatistics/scene.vert
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec3 inColor;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
vec4 lightPos;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec3 outViewVec;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
layout(push_constant) uniform PushConsts {
|
||||
vec3 objPos;
|
||||
} pushConsts;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
|
||||
vec3 locPos = vec3(ubo.modelview * vec4(inPos, 1.0));
|
||||
vec3 worldPos = vec3(ubo.modelview * vec4(inPos + pushConsts.objPos, 1.0));
|
||||
gl_Position = ubo.projection /* ubo.modelview */ * vec4(worldPos, 1.0);
|
||||
|
||||
vec4 pos = ubo.modelview * vec4(worldPos, 1.0);
|
||||
outNormal = mat3(ubo.modelview) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
}
|
||||
BIN
data/shaders/pipelinestatistics/scene.vert.spv
Normal file
BIN
data/shaders/pipelinestatistics/scene.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue