Text Rendering works

This commit is contained in:
Dynamitos
2022-04-15 23:45:44 +02:00
parent eb23264c40
commit 03e1a5784d
70 changed files with 1178 additions and 476 deletions
+9 -8
View File
@@ -19,24 +19,25 @@ cbuffer DispatchParams
layout(set = INDEX_VIEW_PARAMS, binding = 2)
Texture2D depthTextureVS;
layout(set = INDEX_VIEW_PARAMS, binding = 3)
StructuredBuffer<Frustum> frustums;
layout(set = INDEX_VIEW_PARAMS, binding = 4)
layout(set = INDEX_VIEW_PARAMS, binding = 3)
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
layout(set = INDEX_VIEW_PARAMS, binding = 5)
layout(set = INDEX_VIEW_PARAMS, binding = 4)
globallycoherent RWStructuredBuffer<uint> tLightIndexCounter;
layout(set = INDEX_VIEW_PARAMS, binding = 6)
layout(set = INDEX_VIEW_PARAMS, binding = 5)
RWStructuredBuffer<uint> oLightIndexList;
layout(set = INDEX_VIEW_PARAMS, binding = 7)
layout(set = INDEX_VIEW_PARAMS, binding = 6)
RWStructuredBuffer<uint> tLightIndexList;
layout(set = INDEX_VIEW_PARAMS, binding = 8)
layout(set = INDEX_VIEW_PARAMS, binding = 7)
RWTexture2D<uint2> oLightGrid;
layout(set = INDEX_VIEW_PARAMS, binding = 9)
layout(set = INDEX_VIEW_PARAMS, binding = 8)
RWTexture2D<uint2> tLightGrid;
layout(set = INDEX_VIEW_PARAMS, binding = 9)
StructuredBuffer<Frustum> frustums;
// Debug
//layout(set = INDEX_VIEW_PARAMS, binding = 10)
//Texture2D lightCountHeatMap;
+7 -7
View File
@@ -12,12 +12,12 @@ layout(set = 0, binding = 0)
ConstantBuffer<ViewData> viewData;
layout(set = 0, binding = 1)
SamplerState glyphSampler;
layout(set = 0, binding = 2)
StructuredBuffer<GlyphData> glyphData;
layout(set = 1)
Texture2D glyphTextures[];
RWStructuredBuffer<GlyphData> glyphData;
layout(set = 2)
Texture2D<uint> glyphTextures[];
layout(push_constant)
float scale;
ConstantBuffer<float> scale;
struct VertexStageInput
{
@@ -45,10 +45,10 @@ VertexStageOutput vertexMain(VertexStageInput input)
float h = glyph.size.y * scale;
float4 coordinates[4] = {
float4(xpos, ypos + h, 0, 0),
float4(xpos, ypos, 0, 1),
float4(xpos + w, ypos, 1, 0),
float4(xpos + w, ypos + h, 1, 1)
float4(xpos, ypos + h, 0, 0),
float4(xpos + w, ypos, 1, 1),
float4(xpos + w, ypos + h, 1, 0)
};
float4 vertex = coordinates[input.vertexId];
VertexStageOutput output;
+424
View File
@@ -0,0 +1,424 @@
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 21 0
layout(binding = 2)
uniform texture2D depthTextureVS_0;
#line 46
shared uint uMinDepth_0;
#line 47
shared uint uMaxDepth_0;
shared uint oLightCount_0;
shared uint tLightCount_0;
#line 12
struct SLANG_ParameterGroup_DispatchParams_0
{
uvec3 numThreadGroups_0;
uint pad0_0;
uvec3 numThreads_0;
uint pad1_0;
};
#line 12
layout(binding = 1)
layout(std140) uniform _S1
{
SLANG_ParameterGroup_DispatchParams_0 _data;
} DispatchParams_0;
#line 39 1
struct Plane_0
{
vec3 n_0;
float d_0;
};
struct Frustum_0
{
Plane_0 planes_0[4];
};
#line 23 0
layout(std430, binding = 3) readonly buffer _S2 {
Frustum_0 _data[];
} frustums_0;
#line 49
shared Frustum_0 groupFrustum_0;
#line 5 1
struct ViewParameter_0
{
mat4x4 viewMatrix_0;
mat4x4 projectionMatrix_0;
mat4x4 inverseProjection_0;
vec4 cameraPos_WS_0;
vec2 screenDimensions_0;
};
layout(binding = 0)
layout(std140) uniform _S3
{
ViewParameter_0 _data;
} gViewParams_0;
#line 17
vec4 clipToView_0(vec4 clip_0)
{
vec4 view_0 = (((clip_0) * (gViewParams_0._data.inverseProjection_0)));
vec4 view_1 = view_0 / view_0.w;
return view_1;
}
#line 71 2
layout(binding = 3, set = 1)
layout(std140) uniform _S4
{
uint _data;
} numPointLights_0;
#line 22
struct PointLight_0
{
vec4 positionWS_0;
vec4 colorRange_0;
};
#line 69
layout(std430, binding = 2, set = 1) readonly buffer _S5 {
PointLight_0 _data[];
} pointLights_0;
#line 57 0
shared uint tLightList_0[1024];
#line 70
void tAppendLight_0(uint lightIndex_0)
{
uint index_0;
((index_0) = atomicAdd((tLightCount_0), (uint(1))));
if(index_0 < uint(1024))
{
tLightList_0[index_0] = lightIndex_0;
#line 74
}
else
{
#line 74
}
return;
}
#line 58 2
vec3 PointLight_getViewPos_0(PointLight_0 this_0)
{
vec4 _S6 = (((this_0.positionWS_0) * (gViewParams_0._data.viewMatrix_0)));
#line 60
return _S6.xyz;
}
#line 36
bool PointLight_insidePlane_0(PointLight_0 this_1, Plane_0 plane_0)
{
#line 36
vec3 _S7 = plane_0.n_0;
vec3 _S8 = PointLight_getViewPos_0(this_1);
#line 38
float _S9 = dot(_S7, _S8.xyz);
#line 38
return _S9 - plane_0.d_0 < - this_1.colorRange_0.w;
}
#line 53 0
shared uint oLightList_0[1024];
#line 60
void oAppendLight_0(uint lightIndex_1)
{
uint index_1;
((index_1) = atomicAdd((oLightCount_0), (uint(1))));
if(index_1 < uint(1024))
{
oLightList_0[index_1] = lightIndex_1;
#line 64
}
else
{
#line 64
}
return;
}
#line 26
layout(std430, binding = 4) buffer _S10 {
uint _data[];
} oLightIndexCounter_0;
#line 52
shared uint oLightIndexStartOffset_0;
#line 36
layout(rg32ui)
layout(binding = 8)
uniform uimage2D oLightGrid_0;
#line 28
layout(std430, binding = 5) buffer _S11 {
uint _data[];
} tLightIndexCounter_0;
#line 56
shared uint tLightIndexStartOffset_0;
#line 38
layout(rg32ui)
layout(binding = 9)
uniform uimage2D tLightGrid_0;
#line 31
layout(std430, binding = 6) buffer _S12 {
uint _data[];
} oLightIndexList_0;
#line 33
layout(std430, binding = 7) buffer _S13 {
uint _data[];
} tLightIndexList_0;
#line 4
struct ComputeShaderInput_0
{
uvec3 groupID_0;
uvec3 groupThreadID_0;
uvec3 dispatchThreadID_0;
uint groupIndex_0;
};
#line 82
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
void main()
{
uint i_0;
uint j_0;
uint k_0;
#line 82
ComputeShaderInput_0 _S14 = ComputeShaderInput_0(gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex);
ivec3 _S15 = ivec3(ivec2(_S14.dispatchThreadID_0.xy), 0);
#line 85
vec4 _S16 = (texelFetch((depthTextureVS_0), ((_S15)).xy, ((_S15)).z));
uint uDepth_0 = floatBitsToUint(_S16.x);
if(_S14.groupIndex_0 == uint(0))
{
uMinDepth_0 = uint(-1);
uMaxDepth_0 = uint(0);
oLightCount_0 = uint(0);
tLightCount_0 = uint(0);
Frustum_0 _S17 = ((frustums_0)._data[(_S14.groupID_0.x + _S14.groupID_0.y * DispatchParams_0._data.numThreadGroups_0.x)]);
#line 94
groupFrustum_0 = _S17;
#line 88
}
else
{
#line 88
}
#line 97
groupMemoryBarrier(), barrier();
atomicMin((uMinDepth_0), (uDepth_0));
atomicMax((uMaxDepth_0), (uDepth_0));
groupMemoryBarrier(), barrier();
float fMinDepth_0 = uintBitsToFloat(uMinDepth_0);
float fMaxDepth_0 = uintBitsToFloat(uMaxDepth_0);
vec4 _S18 = clipToView_0(vec4(float(0), float(0), fMinDepth_0, float(1)));
#line 107
float minDepthVS_0 = _S18.z;
vec4 _S19 = clipToView_0(vec4(float(0), float(0), fMaxDepth_0, float(1)));
vec4 _S20 = clipToView_0(vec4(float(0), float(0), float(0), 1.00000000000000000000));
Plane_0 _S21 = { vec3(float(0), float(0), float(-1)), - minDepthVS_0 };
#line 111
uint _S22 = _S14.groupIndex_0;
i_0 = _S22;
for(;;)
{
#line 113
if(i_0 < numPointLights_0._data)
{
}
else
{
break;
}
#line 115
PointLight_0 light_0 = ((pointLights_0)._data[(i_0)]);
tAppendLight_0(i_0);
bool _S23 = PointLight_insidePlane_0(light_0, _S21);
#line 120
if(!_S23)
{
oAppendLight_0(i_0);
#line 120
}
else
{
#line 120
}
#line 113
uint i_1 = i_0 + uint(32) * uint(32);
#line 113
i_0 = i_1;
}
#line 127
groupMemoryBarrier(), barrier();
if(_S14.groupIndex_0 == uint(0))
{
((oLightIndexStartOffset_0) = atomicAdd((((oLightIndexCounter_0)._data[(uint(0))])), (oLightCount_0)));
imageStore((oLightGrid_0), ivec2((_S14.groupID_0.xy)), uvec4(uvec2(oLightIndexStartOffset_0, oLightCount_0), uint(0), uint(0)));
((tLightIndexStartOffset_0) = atomicAdd((((tLightIndexCounter_0)._data[(uint(0))])), (tLightCount_0)));
imageStore((tLightGrid_0), ivec2((_S14.groupID_0.xy)), uvec4(uvec2(tLightIndexStartOffset_0, tLightCount_0), uint(0), uint(0)));
#line 129
}
else
{
#line 129
}
#line 137
groupMemoryBarrier(), barrier();
#line 137
uint _S24 = _S14.groupIndex_0;
j_0 = _S24;
for(;;)
{
#line 139
if(j_0 < oLightCount_0)
{
}
else
{
break;
}
#line 141
((oLightIndexList_0)._data[(oLightIndexStartOffset_0 + j_0)]) = oLightList_0[j_0];
#line 139
uint j_1 = j_0 + uint(32) * uint(32);
#line 139
j_0 = j_1;
}
#line 139
uint _S25 = _S14.groupIndex_0;
#line 145
k_0 = _S25;
for(;;)
{
#line 145
if(k_0 < tLightCount_0)
{
}
else
{
break;
}
#line 147
((tLightIndexList_0)._data[(tLightIndexStartOffset_0 + k_0)]) = tLightList_0[k_0];
#line 145
uint k_1 = k_0 + uint(32) * uint(32);
#line 145
k_0 = k_1;
}
#line 151
return;
}
+29 -5
View File
@@ -1,20 +1,44 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 61 0
#line 18 0
layout(binding = 1, set = 1)
uniform texture2D glyphTextures_0[];
#line 14
layout(binding = 1)
uniform sampler glyphSampler_0;
#line 14
layout(location = 0)
out vec4 _S1;
#line 61
#line 62
layout(location = 0)
in vec2 _S2;
#line 62
flat layout(location = 1)
in uint _S3;
#line 62
void main()
{
#line 61
_S1 = vec4(float(0), float(1), float(0), float(1));
#line 68
vec4 _S4 = (texture(sampler2D(glyphTextures_0[_S3],glyphSampler_0), (_S2)));
#line 61
#line 68
_S1 = _S4;
#line 68
return;
}
+197
View File
@@ -0,0 +1,197 @@
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
#line 5 0
struct ViewParameter_0
{
mat4x4 viewMatrix_0;
mat4x4 projectionMatrix_0;
mat4x4 inverseProjection_0;
vec4 cameraPos_WS_0;
vec2 screenDimensions_0;
};
layout(binding = 0)
layout(std140) uniform _S1
{
ViewParameter_0 _data;
} gViewParams_0;
#line 17
vec4 clipToView_0(vec4 clip_0)
{
vec4 view_0 = (((clip_0) * (gViewParams_0._data.inverseProjection_0)));
vec4 view_1 = view_0 / view_0.w;
return view_1;
}
vec4 screenToView_0(vec4 screen_0)
{
vec2 texCoord_0 = screen_0.xy / gViewParams_0._data.screenDimensions_0;
#line 36
vec4 _S2 = clipToView_0(vec4(vec2(texCoord_0.x, 1.00000000000000000000 - texCoord_0.y) * 2.00000000000000000000 - 1.00000000000000000000, screen_0.z, screen_0.w));
#line 36
return _S2;
}
struct Plane_0
{
vec3 n_0;
float d_0;
};
#line 49
Plane_0 computePlane_0(vec3 p0_0, vec3 p1_0, vec3 p2_0)
{
Plane_0 plane_0;
#line 56
vec3 _S3 = cross(p1_0 - p0_0, p2_0 - p0_0);
#line 56
vec3 _S4 = normalize(_S3);
#line 56
plane_0.n_0 = _S4;
float _S5 = dot(plane_0.n_0, p0_0);
#line 58
plane_0.d_0 = _S5;
return plane_0;
}
#line 12 1
struct SLANG_ParameterGroup_DispatchParams_0
{
uvec3 numThreadGroups_0;
uint pad0_0;
uvec3 numThreads_0;
uint pad1_0;
};
#line 12
layout(binding = 1)
layout(std140) uniform _S6
{
SLANG_ParameterGroup_DispatchParams_0 _data;
} DispatchParams_0;
#line 45 0
struct Frustum_0
{
Plane_0 planes_0[4];
};
#line 20 1
layout(std430, binding = 2) buffer _S7 {
Frustum_0 _data[];
} out_Frustums_0;
#line 3
struct ComputeShaderInput_0
{
uvec3 groupID_0;
uvec3 groupThreadID_0;
uvec3 dispatchThreadID_0;
uint groupIndex_0;
};
#line 25
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
void main()
{
int i_0;
#line 25
ComputeShaderInput_0 _S8 = ComputeShaderInput_0(gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex);
const vec3 eyePos_0 = vec3(float(0), float(0), float(0));
vec4 screenSpace_0[4];
screenSpace_0[0] = vec4(vec2(_S8.dispatchThreadID_0.xy * uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[1] = vec4(vec2(float(_S8.dispatchThreadID_0.x + uint(1)), float(_S8.dispatchThreadID_0.y)) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[2] = vec4(vec2(float(_S8.dispatchThreadID_0.x), float(_S8.dispatchThreadID_0.y + uint(1))) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[3] = vec4(vec2(float(_S8.dispatchThreadID_0.x + uint(1)), float(_S8.dispatchThreadID_0.y + uint(1))) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
vec3 viewSpace_0[4];
i_0 = 0;
for(;;)
{
#line 39
if(i_0 < 4)
{
}
else
{
break;
}
#line 41
vec4 _S9 = screenToView_0(screenSpace_0[i_0]);
#line 41
viewSpace_0[i_0] = _S9.xyz;
#line 39
int _S10 = i_0 + int(1);
#line 39
i_0 = _S10;
}
#line 45
Frustum_0 frustum_0;
Plane_0 _S11 = computePlane_0(eyePos_0, viewSpace_0[2], viewSpace_0[0]);
#line 47
frustum_0.planes_0[0] = _S11;
Plane_0 _S12 = computePlane_0(eyePos_0, viewSpace_0[1], viewSpace_0[3]);
#line 48
frustum_0.planes_0[1] = _S12;
Plane_0 _S13 = computePlane_0(eyePos_0, viewSpace_0[0], viewSpace_0[1]);
#line 49
frustum_0.planes_0[2] = _S13;
Plane_0 _S14 = computePlane_0(eyePos_0, viewSpace_0[3], viewSpace_0[2]);
#line 50
frustum_0.planes_0[3] = _S14;
if(_S8.dispatchThreadID_0.x < DispatchParams_0._data.numThreads_0.x && _S8.dispatchThreadID_0.y < DispatchParams_0._data.numThreads_0.y)
{
((out_Frustums_0)._data[(_S8.dispatchThreadID_0.x + _S8.dispatchThreadID_0.y * DispatchParams_0._data.numThreads_0.x)]) = frustum_0;
#line 52
}
else
{
#line 52
}
#line 57
return;
}
+40 -41
View File
@@ -2,7 +2,7 @@
layout(row_major) uniform;
layout(row_major) buffer;
#line 7 0
#line 2 0
struct GlyphData_0
{
vec2 bearing_0;
@@ -10,55 +10,54 @@ struct GlyphData_0
};
layout(std430, binding = 1) readonly buffer _S1 {
#line 16
layout(std430, binding = 0, set = 1) readonly buffer _S1 {
GlyphData_0 _data[];
} glyphData_0;
#line 1
struct ViewParameter_0
layout(push_constant)
layout(std140) uniform _S2
{
float _data;
} scale_0;
#line 7
struct ViewData_0
{
mat4x4 projectionMatrix_0;
};
#line 5
layout(binding = 0)
layout(std140) uniform _S2
layout(std140) uniform _S3
{
ViewParameter_0 _data;
} gViewParams_0;
ViewData_0 _data;
} viewData_0;
#line 5
#line 12
layout(location = 0)
out vec2 _S3;
out vec2 _S4;
#line 5
#line 12
layout(location = 1)
out uint _S4;
out uint _S5;
#line 5
#line 12
layout(location = 0)
in uint _S5;
in uint _S6;
#line 5
#line 12
layout(location = 1)
in vec2 _S6;
in vec2 _S7;
#line 5
layout(location = 2)
in float _S7;
#line 20
#line 22
struct VertexStageInput_0
{
uint glyphIndex_0;
vec2 position_0;
float scale_0;
uint vertexId_0;
};
@@ -73,42 +72,42 @@ struct VertexStageOutput_0
void main()
{
#line 36
VertexStageInput_0 _S8 = VertexStageInput_0(_S5, _S6, _S7, uint(gl_VertexIndex));
#line 37
VertexStageInput_0 _S8 = VertexStageInput_0(_S6, _S7, uint(gl_VertexIndex));
GlyphData_0 glyph_0 = ((glyphData_0)._data[(_S8.glyphIndex_0)]);
float xpos_0 = _S8.position_0.x + glyph_0.bearing_0.x * _S8.scale_0;
float ypos_0 = _S8.position_0.y - (glyph_0.size_0.y - glyph_0.bearing_0.y) * _S8.scale_0;
float xpos_0 = _S8.position_0.x + glyph_0.bearing_0.x * scale_0._data;
float ypos_0 = _S8.position_0.y - (glyph_0.size_0.y - glyph_0.bearing_0.y) * scale_0._data;
float w_0 = glyph_0.size_0.x * _S8.scale_0;
float w_0 = glyph_0.size_0.x * scale_0._data;
float h_0 = glyph_0.size_0.y * scale_0._data;
vec4 coordinates_0[4] = { vec4(xpos_0, ypos_0 + h_0, float(0), float(0)), vec4(xpos_0, ypos_0, float(0), float(1)), vec4(xpos_0 + w_0, ypos_0, float(1), float(0)), vec4(xpos_0 + w_0, ypos_0 + h_0, float(1), float(1)) };
vec4 coordinates_0[4] = { vec4(xpos_0, ypos_0 + glyph_0.size_0.y * _S8.scale_0, float(0), float(0)), vec4(xpos_0, ypos_0, float(0), float(1)), vec4(xpos_0 + w_0, ypos_0, float(1), float(0)), vec4(xpos_0 + w_0, ypos_0 + w_0, float(1), float(1)) };
#line 46
#line 47
vec4 vertex_0 = coordinates_0[_S8.vertexId_0];
#line 53
#line 54
VertexStageOutput_0 output_0;
output_0.uvCoords_0 = vertex_0.zw;
vec4 _S9 = (((vec4(vertex_0.xy, float(0), float(1))) * (gViewParams_0._data.projectionMatrix_0)));
vec4 _S9 = (((vec4(vertex_0.xy, float(0), float(1))) * (viewData_0._data.projectionMatrix_0)));
#line 55
#line 56
output_0.position_1 = _S9;
output_0.glyphIndex_1 = _S8.glyphIndex_0;
VertexStageOutput_0 _S10 = output_0;
#line 57
#line 58
gl_Position = _S10.position_1;
#line 57
_S3 = _S10.uvCoords_0;
#line 58
_S4 = _S10.uvCoords_0;
#line 57
_S4 = _S10.glyphIndex_1;
#line 58
_S5 = _S10.glyphIndex_1;
#line 57
#line 58
return;
}