Text Rendering works
This commit is contained in:
Vendored
+1
-1
@@ -135,5 +135,5 @@
|
|||||||
},
|
},
|
||||||
"git.ignoreSubmodules": true,
|
"git.ignoreSubmodules": true,
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.configureOnOpen": true,
|
||||||
"cmake.parallelJobs": 15
|
"cmake.parallelJobs": 0
|
||||||
}
|
}
|
||||||
@@ -19,24 +19,25 @@ cbuffer DispatchParams
|
|||||||
|
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 2)
|
layout(set = INDEX_VIEW_PARAMS, binding = 2)
|
||||||
Texture2D depthTextureVS;
|
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;
|
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 5)
|
layout(set = INDEX_VIEW_PARAMS, binding = 4)
|
||||||
globallycoherent RWStructuredBuffer<uint> tLightIndexCounter;
|
globallycoherent RWStructuredBuffer<uint> tLightIndexCounter;
|
||||||
|
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 6)
|
layout(set = INDEX_VIEW_PARAMS, binding = 5)
|
||||||
RWStructuredBuffer<uint> oLightIndexList;
|
RWStructuredBuffer<uint> oLightIndexList;
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 7)
|
layout(set = INDEX_VIEW_PARAMS, binding = 6)
|
||||||
RWStructuredBuffer<uint> tLightIndexList;
|
RWStructuredBuffer<uint> tLightIndexList;
|
||||||
|
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 8)
|
layout(set = INDEX_VIEW_PARAMS, binding = 7)
|
||||||
RWTexture2D<uint2> oLightGrid;
|
RWTexture2D<uint2> oLightGrid;
|
||||||
layout(set = INDEX_VIEW_PARAMS, binding = 9)
|
layout(set = INDEX_VIEW_PARAMS, binding = 8)
|
||||||
RWTexture2D<uint2> tLightGrid;
|
RWTexture2D<uint2> tLightGrid;
|
||||||
|
|
||||||
|
layout(set = INDEX_VIEW_PARAMS, binding = 9)
|
||||||
|
StructuredBuffer<Frustum> frustums;
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
//layout(set = INDEX_VIEW_PARAMS, binding = 10)
|
//layout(set = INDEX_VIEW_PARAMS, binding = 10)
|
||||||
//Texture2D lightCountHeatMap;
|
//Texture2D lightCountHeatMap;
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ layout(set = 0, binding = 0)
|
|||||||
ConstantBuffer<ViewData> viewData;
|
ConstantBuffer<ViewData> viewData;
|
||||||
layout(set = 0, binding = 1)
|
layout(set = 0, binding = 1)
|
||||||
SamplerState glyphSampler;
|
SamplerState glyphSampler;
|
||||||
layout(set = 0, binding = 2)
|
|
||||||
StructuredBuffer<GlyphData> glyphData;
|
|
||||||
layout(set = 1)
|
layout(set = 1)
|
||||||
Texture2D glyphTextures[];
|
RWStructuredBuffer<GlyphData> glyphData;
|
||||||
|
layout(set = 2)
|
||||||
|
Texture2D<uint> glyphTextures[];
|
||||||
layout(push_constant)
|
layout(push_constant)
|
||||||
float scale;
|
ConstantBuffer<float> scale;
|
||||||
|
|
||||||
struct VertexStageInput
|
struct VertexStageInput
|
||||||
{
|
{
|
||||||
@@ -45,10 +45,10 @@ VertexStageOutput vertexMain(VertexStageInput input)
|
|||||||
float h = glyph.size.y * scale;
|
float h = glyph.size.y * scale;
|
||||||
|
|
||||||
float4 coordinates[4] = {
|
float4 coordinates[4] = {
|
||||||
float4(xpos, ypos + h, 0, 0),
|
|
||||||
float4(xpos, ypos, 0, 1),
|
float4(xpos, ypos, 0, 1),
|
||||||
float4(xpos + w, ypos, 1, 0),
|
float4(xpos, ypos + h, 0, 0),
|
||||||
float4(xpos + w, ypos + h, 1, 1)
|
float4(xpos + w, ypos, 1, 1),
|
||||||
|
float4(xpos + w, ypos + h, 1, 0)
|
||||||
};
|
};
|
||||||
float4 vertex = coordinates[input.vertexId];
|
float4 vertex = coordinates[input.vertexId];
|
||||||
VertexStageOutput output;
|
VertexStageOutput output;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,20 +1,44 @@
|
|||||||
#version 450
|
#version 450
|
||||||
|
#extension GL_EXT_nonuniform_qualifier : require
|
||||||
layout(row_major) uniform;
|
layout(row_major) uniform;
|
||||||
layout(row_major) buffer;
|
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)
|
layout(location = 0)
|
||||||
out vec4 _S1;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
#line 61
|
#line 68
|
||||||
_S1 = vec4(float(0), float(1), float(0), float(1));
|
vec4 _S4 = (texture(sampler2D(glyphTextures_0[_S3],glyphSampler_0), (_S2)));
|
||||||
|
|
||||||
#line 61
|
#line 68
|
||||||
|
_S1 = _S4;
|
||||||
|
|
||||||
|
#line 68
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -2,7 +2,7 @@
|
|||||||
layout(row_major) uniform;
|
layout(row_major) uniform;
|
||||||
layout(row_major) buffer;
|
layout(row_major) buffer;
|
||||||
|
|
||||||
#line 7 0
|
#line 2 0
|
||||||
struct GlyphData_0
|
struct GlyphData_0
|
||||||
{
|
{
|
||||||
vec2 bearing_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 _data[];
|
||||||
} glyphData_0;
|
} glyphData_0;
|
||||||
|
|
||||||
#line 1
|
layout(push_constant)
|
||||||
struct ViewParameter_0
|
layout(std140) uniform _S2
|
||||||
|
{
|
||||||
|
float _data;
|
||||||
|
} scale_0;
|
||||||
|
|
||||||
|
#line 7
|
||||||
|
struct ViewData_0
|
||||||
{
|
{
|
||||||
mat4x4 projectionMatrix_0;
|
mat4x4 projectionMatrix_0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#line 5
|
|
||||||
layout(binding = 0)
|
layout(binding = 0)
|
||||||
layout(std140) uniform _S2
|
layout(std140) uniform _S3
|
||||||
{
|
{
|
||||||
ViewParameter_0 _data;
|
ViewData_0 _data;
|
||||||
} gViewParams_0;
|
} viewData_0;
|
||||||
|
|
||||||
#line 5
|
#line 12
|
||||||
layout(location = 0)
|
layout(location = 0)
|
||||||
out vec2 _S3;
|
out vec2 _S4;
|
||||||
|
|
||||||
|
|
||||||
#line 5
|
#line 12
|
||||||
layout(location = 1)
|
layout(location = 1)
|
||||||
out uint _S4;
|
out uint _S5;
|
||||||
|
|
||||||
|
|
||||||
#line 5
|
#line 12
|
||||||
layout(location = 0)
|
layout(location = 0)
|
||||||
in uint _S5;
|
in uint _S6;
|
||||||
|
|
||||||
|
|
||||||
#line 5
|
#line 12
|
||||||
layout(location = 1)
|
layout(location = 1)
|
||||||
in vec2 _S6;
|
in vec2 _S7;
|
||||||
|
|
||||||
|
|
||||||
#line 5
|
#line 22
|
||||||
layout(location = 2)
|
|
||||||
in float _S7;
|
|
||||||
|
|
||||||
|
|
||||||
#line 20
|
|
||||||
struct VertexStageInput_0
|
struct VertexStageInput_0
|
||||||
{
|
{
|
||||||
uint glyphIndex_0;
|
uint glyphIndex_0;
|
||||||
vec2 position_0;
|
vec2 position_0;
|
||||||
float scale_0;
|
|
||||||
uint vertexId_0;
|
uint vertexId_0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,42 +72,42 @@ struct VertexStageOutput_0
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
#line 36
|
#line 37
|
||||||
VertexStageInput_0 _S8 = VertexStageInput_0(_S5, _S6, _S7, uint(gl_VertexIndex));
|
VertexStageInput_0 _S8 = VertexStageInput_0(_S6, _S7, uint(gl_VertexIndex));
|
||||||
|
|
||||||
GlyphData_0 glyph_0 = ((glyphData_0)._data[(_S8.glyphIndex_0)]);
|
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 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) * _S8.scale_0;
|
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 47
|
||||||
|
|
||||||
#line 46
|
|
||||||
vec4 vertex_0 = coordinates_0[_S8.vertexId_0];
|
vec4 vertex_0 = coordinates_0[_S8.vertexId_0];
|
||||||
|
|
||||||
#line 53
|
#line 54
|
||||||
VertexStageOutput_0 output_0;
|
VertexStageOutput_0 output_0;
|
||||||
output_0.uvCoords_0 = vertex_0.zw;
|
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.position_1 = _S9;
|
||||||
output_0.glyphIndex_1 = _S8.glyphIndex_0;
|
output_0.glyphIndex_1 = _S8.glyphIndex_0;
|
||||||
VertexStageOutput_0 _S10 = output_0;
|
VertexStageOutput_0 _S10 = output_0;
|
||||||
|
|
||||||
#line 57
|
#line 58
|
||||||
gl_Position = _S10.position_1;
|
gl_Position = _S10.position_1;
|
||||||
|
|
||||||
#line 57
|
#line 58
|
||||||
_S3 = _S10.uvCoords_0;
|
_S4 = _S10.uvCoords_0;
|
||||||
|
|
||||||
#line 57
|
#line 58
|
||||||
_S4 = _S10.glyphIndex_1;
|
_S5 = _S10.glyphIndex_1;
|
||||||
|
|
||||||
#line 57
|
#line 58
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ void FontAsset::save()
|
|||||||
assert(false && "Cannot save font files");
|
assert(false && "Cannot save font files");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in case of the space character there is no bitmap
|
||||||
|
// so we create a single pixel empty texture
|
||||||
|
uint8 transparentPixel = 0;
|
||||||
|
|
||||||
void FontAsset::load()
|
void FontAsset::load()
|
||||||
{
|
{
|
||||||
FT_Library ft;
|
FT_Library ft;
|
||||||
@@ -43,18 +47,26 @@ void FontAsset::load()
|
|||||||
if(FT_Load_Char(face, c, FT_LOAD_RENDER))
|
if(FT_Load_Char(face, c, FT_LOAD_RENDER))
|
||||||
{
|
{
|
||||||
std::cout << "error loading " << (char)c << std::endl;
|
std::cout << "error loading " << (char)c << std::endl;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
Glyph& glyph = glyphs[c];
|
||||||
|
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
|
||||||
|
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
|
||||||
|
glyph.advance = face->glyph->advance.x;
|
||||||
TextureCreateInfo imageData;
|
TextureCreateInfo imageData;
|
||||||
imageData.format = Gfx::SE_FORMAT_R8_UINT;
|
imageData.format = Gfx::SE_FORMAT_R8_UINT;
|
||||||
imageData.width = face->glyph->bitmap.width;
|
imageData.width = face->glyph->bitmap.width;
|
||||||
imageData.height = face->glyph->bitmap.rows;
|
imageData.height = face->glyph->bitmap.rows;
|
||||||
imageData.resourceData.data = face->glyph->bitmap.buffer;
|
imageData.resourceData.data = face->glyph->bitmap.buffer;
|
||||||
imageData.resourceData.size = imageData.width * imageData.height;
|
imageData.resourceData.size = imageData.width * imageData.height;
|
||||||
Glyph& glyph = glyphs[c];
|
if(imageData.width == 0 || imageData.width == 0)
|
||||||
|
{
|
||||||
|
imageData.width = 1;
|
||||||
|
imageData.height = 1;
|
||||||
|
imageData.resourceData.size = sizeof(uint8);
|
||||||
|
imageData.resourceData.data = &transparentPixel;
|
||||||
|
}
|
||||||
glyph.texture = graphics->createTexture2D(imageData);
|
glyph.texture = graphics->createTexture2D(imageData);
|
||||||
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
|
|
||||||
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
|
|
||||||
glyph.advance = face->glyph->advance.x;
|
|
||||||
}
|
}
|
||||||
FT_Done_Face(face);
|
FT_Done_Face(face);
|
||||||
FT_Done_FreeType(ft);
|
FT_Done_FreeType(ft);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void MaterialLoader::import(std::filesystem::path, PMaterialAsset asset)
|
|||||||
asset->load();
|
asset->load();
|
||||||
graphics->getShaderCompiler()->registerMaterial(asset);
|
graphics->getShaderCompiler()->registerMaterial(asset);
|
||||||
AssetRegistry::get().registerMaterial(asset);
|
AssetRegistry::get().registerMaterial(asset);
|
||||||
//co_return;
|
////co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PMaterialAsset MaterialLoader::getPlaceHolderMaterial()
|
PMaterialAsset MaterialLoader::getPlaceHolderMaterial()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
|
|||||||
@@ -71,5 +71,5 @@ void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsse
|
|||||||
|
|
||||||
textureAsset->load();
|
textureAsset->load();
|
||||||
textureAsset->setStatus(Asset::Status::Ready);
|
textureAsset->setStatus(Asset::Status::Ready);
|
||||||
//co_return;
|
////co_return;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ target_sources(Engine
|
|||||||
EngineTypes.h
|
EngineTypes.h
|
||||||
MinimalEngine.h
|
MinimalEngine.h
|
||||||
MinimalEngine.cpp
|
MinimalEngine.cpp
|
||||||
ThreadPool.h
|
|
||||||
ThreadPool.cpp
|
|
||||||
main.cpp)
|
main.cpp)
|
||||||
|
|
||||||
add_subdirectory(Asset/)
|
add_subdirectory(Asset/)
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ public:
|
|||||||
}
|
}
|
||||||
return endIt;
|
return endIt;
|
||||||
}
|
}
|
||||||
//template<class F, class... Args, std::predicate<F, Args...> Pred>
|
|
||||||
template<class Pred>
|
template<class Pred>
|
||||||
|
requires std::predicate<Pred, value_type>
|
||||||
constexpr iterator find(Pred pred) const noexcept
|
constexpr iterator find(Pred pred) const noexcept
|
||||||
{
|
{
|
||||||
for (size_type i = 0; i < arraySize; ++i)
|
for (size_type i = 0; i < arraySize; ++i)
|
||||||
@@ -337,9 +337,9 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr void remove(iterator it, bool keepOrder = true)
|
constexpr void remove(iterator it, bool keepOrder = true)
|
||||||
{
|
{
|
||||||
remove(it - beginIt, keepOrder);
|
removeAt(it - beginIt, keepOrder);
|
||||||
}
|
}
|
||||||
constexpr void remove(size_type index, bool keepOrder = true)
|
constexpr void removeAt(size_type index, bool keepOrder = true)
|
||||||
{
|
{
|
||||||
if (keepOrder)
|
if (keepOrder)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -232,16 +232,16 @@ public:
|
|||||||
, root(other.root)
|
, root(other.root)
|
||||||
, _size(other._size)
|
, _size(other._size)
|
||||||
, comp(other.comp)
|
, comp(other.comp)
|
||||||
|
, iteratorsDirty(true)
|
||||||
{
|
{
|
||||||
markIteratorsDirty();
|
|
||||||
}
|
}
|
||||||
constexpr Map(Map&& other) noexcept
|
constexpr Map(Map&& other) noexcept
|
||||||
: nodeContainer(std::move(other.nodeContainer))
|
: nodeContainer(std::move(other.nodeContainer))
|
||||||
, root(std::move(other.root))
|
, root(std::move(other.root))
|
||||||
, _size(std::move(other._size))
|
, _size(std::move(other._size))
|
||||||
, comp(std::move(other.comp))
|
, comp(std::move(other.comp))
|
||||||
|
, iteratorsDirty(true)
|
||||||
{
|
{
|
||||||
markIteratorsDirty();
|
|
||||||
}
|
}
|
||||||
constexpr ~Map() noexcept
|
constexpr ~Map() noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "GraphicsEnums.h"
|
#include "GraphicsEnums.h"
|
||||||
|
|
||||||
using namespace Gfx;
|
using namespace Seele;
|
||||||
|
|
||||||
uint32 Gfx::currentFrameIndex = 0;
|
uint32 Gfx::currentFrameIndex = 0;
|
||||||
double Gfx::currentFrameDelta = 0;
|
double Gfx::currentFrameDelta = 0;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class KeyCode
|
enum class KeyCode
|
||||||
{
|
{
|
||||||
/* Printable keys */
|
/* Printable keys */
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct GraphicsInitializer
|
|||||||
: applicationName("SeeleEngine")
|
: applicationName("SeeleEngine")
|
||||||
, engineName("SeeleEngine")
|
, engineName("SeeleEngine")
|
||||||
, windowLayoutFile(nullptr)
|
, windowLayoutFile(nullptr)
|
||||||
, layers{}
|
, layers{"VK_LAYER_KHRONOS_validation"}
|
||||||
, instanceExtensions{}
|
, instanceExtensions{}
|
||||||
, deviceExtensions{"VK_KHR_swapchain"}
|
, deviceExtensions{"VK_KHR_swapchain"}
|
||||||
, windowHandle(nullptr)
|
, windowHandle(nullptr)
|
||||||
@@ -101,12 +101,13 @@ struct IndexBufferCreateInfo
|
|||||||
struct UniformBufferCreateInfo
|
struct UniformBufferCreateInfo
|
||||||
{
|
{
|
||||||
BulkResourceData resourceData = BulkResourceData();
|
BulkResourceData resourceData = BulkResourceData();
|
||||||
uint8 bDynamic : 1 = 0;
|
uint8 bDynamic = 0;
|
||||||
};
|
};
|
||||||
struct StructuredBufferCreateInfo
|
struct StructuredBufferCreateInfo
|
||||||
{
|
{
|
||||||
BulkResourceData resourceData;
|
BulkResourceData resourceData;
|
||||||
uint8 bDynamic: 1;
|
uint32 stride;
|
||||||
|
uint8 bDynamic = 0;
|
||||||
};
|
};
|
||||||
struct ShaderCreateInfo
|
struct ShaderCreateInfo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -194,9 +194,10 @@ bool UniformBuffer::updateContents(const BulkResourceData& resourceData)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StructuredBuffer::StructuredBuffer(QueueFamilyMapping mapping, const BulkResourceData& resourceData)
|
StructuredBuffer::StructuredBuffer(QueueFamilyMapping mapping, uint32 stride, const BulkResourceData& resourceData)
|
||||||
: Buffer(mapping, resourceData.owner)
|
: Buffer(mapping, resourceData.owner)
|
||||||
, contents(resourceData.size)
|
, contents(resourceData.size)
|
||||||
|
, stride(stride)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
StructuredBuffer::~StructuredBuffer()
|
StructuredBuffer::~StructuredBuffer()
|
||||||
@@ -366,12 +367,7 @@ RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttac
|
|||||||
}
|
}
|
||||||
|
|
||||||
Window::Window(const WindowCreateInfo &createInfo)
|
Window::Window(const WindowCreateInfo &createInfo)
|
||||||
: sizeX(createInfo.width)
|
: windowState(createInfo)
|
||||||
, sizeY(createInfo.height)
|
|
||||||
, bFullscreen(createInfo.bFullscreen)
|
|
||||||
, title(createInfo.title)
|
|
||||||
, pixelFormat(createInfo.pixelFormat)
|
|
||||||
, samples(createInfo.numSamples)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -387,11 +387,11 @@ class IndexBuffer : public Buffer
|
|||||||
public:
|
public:
|
||||||
IndexBuffer(QueueFamilyMapping mapping, uint32 size, Gfx::SeIndexType index, QueueType startQueueType);
|
IndexBuffer(QueueFamilyMapping mapping, uint32 size, Gfx::SeIndexType index, QueueType startQueueType);
|
||||||
virtual ~IndexBuffer();
|
virtual ~IndexBuffer();
|
||||||
inline uint32 getNumIndices() const
|
constexpr uint32 getNumIndices() const
|
||||||
{
|
{
|
||||||
return numIndices;
|
return numIndices;
|
||||||
}
|
}
|
||||||
inline Gfx::SeIndexType getIndexType() const
|
constexpr Gfx::SeIndexType getIndexType() const
|
||||||
{
|
{
|
||||||
return indexType;
|
return indexType;
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,7 @@ DEFINE_REF(IndexBuffer)
|
|||||||
class StructuredBuffer : public Buffer
|
class StructuredBuffer : public Buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StructuredBuffer(QueueFamilyMapping mapping, const BulkResourceData& bulkResourceData);
|
StructuredBuffer(QueueFamilyMapping mapping, uint32 stride, const BulkResourceData& bulkResourceData);
|
||||||
virtual ~StructuredBuffer();
|
virtual ~StructuredBuffer();
|
||||||
virtual bool updateContents(const BulkResourceData& resourceData);
|
virtual bool updateContents(const BulkResourceData& resourceData);
|
||||||
bool isDataEquals(StructuredBuffer* other)
|
bool isDataEquals(StructuredBuffer* other)
|
||||||
@@ -428,12 +428,18 @@ public:
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
constexpr uint32 getStride() const
|
||||||
|
{
|
||||||
|
return stride;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
Array<uint8> contents;
|
|
||||||
// Inherited via QueueOwnedResource
|
// Inherited via QueueOwnedResource
|
||||||
virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
|
virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
|
||||||
virtual void executePipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage,
|
virtual void executePipelineBarrier(SeAccessFlags srcAccess, SePipelineStageFlags srcStage,
|
||||||
SeAccessFlags dstAccess, SePipelineStageFlags dstStage) = 0;
|
SeAccessFlags dstAccess, SePipelineStageFlags dstStage) = 0;
|
||||||
|
|
||||||
|
Array<uint8> contents;
|
||||||
|
uint32 stride;
|
||||||
};
|
};
|
||||||
DEFINE_REF(StructuredBuffer)
|
DEFINE_REF(StructuredBuffer)
|
||||||
|
|
||||||
@@ -590,28 +596,23 @@ public:
|
|||||||
virtual void setCloseCallback(std::function<void()> callback) = 0;
|
virtual void setCloseCallback(std::function<void()> callback) = 0;
|
||||||
SeFormat getSwapchainFormat() const
|
SeFormat getSwapchainFormat() const
|
||||||
{
|
{
|
||||||
return pixelFormat;
|
return windowState.pixelFormat;
|
||||||
}
|
}
|
||||||
SeSampleCountFlags getNumSamples() const
|
SeSampleCountFlags getNumSamples() const
|
||||||
{
|
{
|
||||||
return samples;
|
return windowState.numSamples;
|
||||||
}
|
}
|
||||||
uint32 getSizeX() const
|
uint32 getSizeX() const
|
||||||
{
|
{
|
||||||
return sizeX;
|
return windowState.width;
|
||||||
}
|
}
|
||||||
uint32 getSizeY() const
|
uint32 getSizeY() const
|
||||||
{
|
{
|
||||||
return sizeY;
|
return windowState.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 sizeX;
|
WindowCreateInfo windowState;
|
||||||
uint32 sizeY;
|
|
||||||
bool bFullscreen;
|
|
||||||
const char *title;
|
|
||||||
SeFormat pixelFormat;
|
|
||||||
uint32 samples;
|
|
||||||
};
|
};
|
||||||
DEFINE_REF(Window)
|
DEFINE_REF(Window)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ BasePassMeshProcessor::~BasePassMeshProcessor()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob BasePassMeshProcessor::processMeshBatch(
|
void BasePassMeshProcessor::processMeshBatch(
|
||||||
const MeshBatch& batch,
|
const MeshBatch& batch,
|
||||||
// const PPrimitiveComponent primitiveComponent,
|
// const PPrimitiveComponent primitiveComponent,
|
||||||
const Gfx::PRenderPass& renderPass,
|
const Gfx::PRenderPass& renderPass,
|
||||||
@@ -66,7 +66,7 @@ MainJob BasePassMeshProcessor::processMeshBatch(
|
|||||||
}
|
}
|
||||||
std::scoped_lock lock(commandLock);
|
std::scoped_lock lock(commandLock);
|
||||||
renderCommands.add(renderCommand);
|
renderCommands.add(renderCommand);
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||||
@@ -114,7 +114,7 @@ BasePass::~BasePass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob BasePass::beginFrame()
|
void BasePass::beginFrame()
|
||||||
{
|
{
|
||||||
processor->clearCommands();
|
processor->clearCommands();
|
||||||
primitiveLayout->reset();
|
primitiveLayout->reset();
|
||||||
@@ -135,10 +135,10 @@ MainJob BasePass::beginFrame()
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
//std::cout << "BasePass beginFrame()" << std::endl;
|
//std::cout << "BasePass beginFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob BasePass::render()
|
void BasePass::render()
|
||||||
{
|
{
|
||||||
oLightIndexList->pipelineBarrier(
|
oLightIndexList->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
@@ -155,23 +155,20 @@ MainJob BasePass::render()
|
|||||||
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
||||||
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
List<Job> jobs;
|
|
||||||
for (auto &&meshBatch : passData.staticDrawList)
|
for (auto &&meshBatch : passData.staticDrawList)
|
||||||
{
|
{
|
||||||
//jobs.add(
|
processor->processMeshBatch(meshBatch, renderPass, basePassLayout, primitiveLayout, descriptorSets);
|
||||||
co_await processor->processMeshBatch(meshBatch, renderPass, basePassLayout, primitiveLayout, descriptorSets);
|
|
||||||
}
|
}
|
||||||
//co_await Job::all(jobs);
|
|
||||||
graphics->executeCommands(processor->getRenderCommands());
|
graphics->executeCommands(processor->getRenderCommands());
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
//std::cout << "BasePass render()" << std::endl;
|
//std::cout << "BasePass render()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob BasePass::endFrame()
|
void BasePass::endFrame()
|
||||||
{
|
{
|
||||||
//std::cout << "BasePass endFrame()" << std::endl;
|
//std::cout << "BasePass endFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::publishOutputs()
|
void BasePass::publishOutputs()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public:
|
|||||||
BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass);
|
BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass);
|
||||||
virtual ~BasePassMeshProcessor();
|
virtual ~BasePassMeshProcessor();
|
||||||
|
|
||||||
virtual MainJob processMeshBatch(
|
virtual void processMeshBatch(
|
||||||
const MeshBatch& batch,
|
const MeshBatch& batch,
|
||||||
// const PPrimitiveComponent primitiveComponent,
|
// const PPrimitiveComponent primitiveComponent,
|
||||||
const Gfx::PRenderPass& renderPass,
|
const Gfx::PRenderPass& renderPass,
|
||||||
@@ -37,9 +37,9 @@ class BasePass : public RenderPass<BasePassData>
|
|||||||
public:
|
public:
|
||||||
BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
||||||
virtual ~BasePass();
|
virtual ~BasePass();
|
||||||
virtual MainJob beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
virtual MainJob endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ DepthPrepassMeshProcessor::~DepthPrepassMeshProcessor()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob DepthPrepassMeshProcessor::processMeshBatch(
|
void DepthPrepassMeshProcessor::processMeshBatch(
|
||||||
const MeshBatch& batch,
|
const MeshBatch& batch,
|
||||||
// const PPrimitiveComponent primitiveComponent,
|
// const PPrimitiveComponent primitiveComponent,
|
||||||
const Gfx::PRenderPass& renderPass,
|
const Gfx::PRenderPass& renderPass,
|
||||||
@@ -27,7 +27,7 @@ MainJob DepthPrepassMeshProcessor::processMeshBatch(
|
|||||||
Array<Gfx::PDescriptorSet> descriptorSets,
|
Array<Gfx::PDescriptorSet> descriptorSets,
|
||||||
int32 /*staticMeshId*/)
|
int32 /*staticMeshId*/)
|
||||||
{
|
{
|
||||||
//std::cout << "Depth job started" << std::endl;
|
//std::cout << "Depth void started" << std::endl;
|
||||||
PMaterialAsset material = batch.material;
|
PMaterialAsset material = batch.material;
|
||||||
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
|
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ MainJob DepthPrepassMeshProcessor::processMeshBatch(
|
|||||||
std::scoped_lock lock(commandLock);
|
std::scoped_lock lock(commandLock);
|
||||||
renderCommands.add(renderCommand);
|
renderCommands.add(renderCommand);
|
||||||
//std::cout << "Finished depth job" << std::endl;
|
//std::cout << "Finished depth job" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||||
@@ -97,7 +97,7 @@ DepthPrepass::~DepthPrepass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob DepthPrepass::beginFrame()
|
void DepthPrepass::beginFrame()
|
||||||
{
|
{
|
||||||
processor->clearCommands();
|
processor->clearCommands();
|
||||||
primitiveLayout->reset();
|
primitiveLayout->reset();
|
||||||
@@ -116,33 +116,30 @@ MainJob DepthPrepass::beginFrame()
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
//std::cout << "DepthPrepass beginFrame()" << std::endl;
|
//std::cout << "DepthPrepass beginFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob DepthPrepass::render()
|
void DepthPrepass::render()
|
||||||
{
|
{
|
||||||
depthAttachment->getTexture()->pipelineBarrier(
|
depthAttachment->getTexture()->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||||
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
|
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
List<Job> jobs;
|
|
||||||
for (auto &&meshBatch : passData.staticDrawList)
|
for (auto &&meshBatch : passData.staticDrawList)
|
||||||
{
|
{
|
||||||
//jobs.add(
|
processor->processMeshBatch(meshBatch, renderPass, depthPrepassLayout, primitiveLayout, descriptorSets);
|
||||||
co_await processor->processMeshBatch(meshBatch, renderPass, depthPrepassLayout, primitiveLayout, descriptorSets);
|
|
||||||
}
|
}
|
||||||
//co_await Job::all(jobs);
|
|
||||||
graphics->executeCommands(processor->getRenderCommands());
|
graphics->executeCommands(processor->getRenderCommands());
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
//std::cout << "DepthPrepass render()" << std::endl;
|
//std::cout << "DepthPrepass render()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob DepthPrepass::endFrame()
|
void DepthPrepass::endFrame()
|
||||||
{
|
{
|
||||||
//std::cout << "DepthPrepass endFrame()" << std::endl;
|
//std::cout << "DepthPrepass endFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::publishOutputs()
|
void DepthPrepass::publishOutputs()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public:
|
|||||||
DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics);
|
DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics);
|
||||||
virtual ~DepthPrepassMeshProcessor();
|
virtual ~DepthPrepassMeshProcessor();
|
||||||
|
|
||||||
virtual MainJob processMeshBatch(
|
virtual void processMeshBatch(
|
||||||
const MeshBatch& batch,
|
const MeshBatch& batch,
|
||||||
const Gfx::PRenderPass& renderPass,
|
const Gfx::PRenderPass& renderPass,
|
||||||
Gfx::PPipelineLayout pipelineLayout,
|
Gfx::PPipelineLayout pipelineLayout,
|
||||||
@@ -34,9 +34,9 @@ class DepthPrepass : public RenderPass<DepthPrepassData>
|
|||||||
public:
|
public:
|
||||||
DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
||||||
~DepthPrepass();
|
~DepthPrepass();
|
||||||
virtual MainJob beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
virtual MainJob endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ LightCullingPass::~LightCullingPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob LightCullingPass::beginFrame()
|
void LightCullingPass::beginFrame()
|
||||||
{
|
{
|
||||||
uint32_t viewportWidth = viewport->getSizeX();
|
uint32_t viewportWidth = viewport->getSizeX();
|
||||||
uint32_t viewportHeight = viewport->getSizeY();
|
uint32_t viewportHeight = viewport->getSizeY();
|
||||||
@@ -61,13 +61,13 @@ MainJob LightCullingPass::beginFrame()
|
|||||||
|
|
||||||
cullingDescriptorSet->updateBuffer(0, viewParamsBuffer);
|
cullingDescriptorSet->updateBuffer(0, viewParamsBuffer);
|
||||||
cullingDescriptorSet->updateBuffer(1, dispatchParamsBuffer);
|
cullingDescriptorSet->updateBuffer(1, dispatchParamsBuffer);
|
||||||
cullingDescriptorSet->updateBuffer(3, frustumBuffer);
|
cullingDescriptorSet->updateBuffer(3, oLightIndexCounter);
|
||||||
cullingDescriptorSet->updateBuffer(4, oLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(4, tLightIndexCounter);
|
||||||
cullingDescriptorSet->updateBuffer(5, tLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(5, oLightIndexList);
|
||||||
cullingDescriptorSet->updateBuffer(6, oLightIndexList);
|
cullingDescriptorSet->updateBuffer(6, tLightIndexList);
|
||||||
cullingDescriptorSet->updateBuffer(7, tLightIndexList);
|
cullingDescriptorSet->updateTexture(7, oLightGrid);
|
||||||
cullingDescriptorSet->updateTexture(8, oLightGrid);
|
cullingDescriptorSet->updateTexture(8, tLightGrid);
|
||||||
cullingDescriptorSet->updateTexture(9, tLightGrid);
|
cullingDescriptorSet->updateBuffer(9, frustumBuffer);
|
||||||
|
|
||||||
|
|
||||||
lightEnvDescriptorSet->updateBuffer(0, directLightBuffer);
|
lightEnvDescriptorSet->updateBuffer(0, directLightBuffer);
|
||||||
@@ -76,10 +76,10 @@ MainJob LightCullingPass::beginFrame()
|
|||||||
lightEnvDescriptorSet->updateBuffer(3, numPointLightBuffer);
|
lightEnvDescriptorSet->updateBuffer(3, numPointLightBuffer);
|
||||||
lightEnvDescriptorSet->writeChanges();
|
lightEnvDescriptorSet->writeChanges();
|
||||||
//std::cout << "LightCulling beginFrame()" << std::endl;
|
//std::cout << "LightCulling beginFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob LightCullingPass::render()
|
void LightCullingPass::render()
|
||||||
{
|
{
|
||||||
oLightIndexList->pipelineBarrier(
|
oLightIndexList->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
@@ -104,13 +104,13 @@ MainJob LightCullingPass::render()
|
|||||||
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
//std::cout << "LightCulling render()" << std::endl;
|
//std::cout << "LightCulling render()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob LightCullingPass::endFrame()
|
void LightCullingPass::endFrame()
|
||||||
{
|
{
|
||||||
//std::cout << "LightCulling endFrame()" << std::endl;
|
//std::cout << "LightCulling endFrame()" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::publishOutputs()
|
void LightCullingPass::publishOutputs()
|
||||||
@@ -122,65 +122,6 @@ void LightCullingPass::publishOutputs()
|
|||||||
dispatchParams.numThreadGroups = numThreadGroups;
|
dispatchParams.numThreadGroups = numThreadGroups;
|
||||||
dispatchParams.numThreads = numThreadGroups * glm::uvec3(BLOCK_SIZE, BLOCK_SIZE, 1);
|
dispatchParams.numThreads = numThreadGroups * glm::uvec3(BLOCK_SIZE, BLOCK_SIZE, 1);
|
||||||
|
|
||||||
BulkResourceData resourceData;
|
|
||||||
StructuredBufferCreateInfo structInfo;
|
|
||||||
uint32 counterReset = 0;
|
|
||||||
resourceData.size = sizeof(uint32);
|
|
||||||
resourceData.data = (uint8*)&counterReset;
|
|
||||||
resourceData.owner = Gfx::QueueType::COMPUTE;
|
|
||||||
structInfo.bDynamic = true;
|
|
||||||
structInfo.resourceData = resourceData;
|
|
||||||
oLightIndexCounter = graphics->createStructuredBuffer(structInfo);
|
|
||||||
tLightIndexCounter = graphics->createStructuredBuffer(structInfo);
|
|
||||||
resourceData.data = nullptr;
|
|
||||||
resourceData.size = sizeof(uint32_t)
|
|
||||||
* dispatchParams.numThreadGroups.x
|
|
||||||
* dispatchParams.numThreadGroups.y
|
|
||||||
* dispatchParams.numThreadGroups.z * 200;
|
|
||||||
structInfo.resourceData = resourceData;
|
|
||||||
structInfo.bDynamic = false;
|
|
||||||
oLightIndexList = graphics->createStructuredBuffer(structInfo);
|
|
||||||
tLightIndexList = graphics->createStructuredBuffer(structInfo);
|
|
||||||
resources->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
|
||||||
resources->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
|
||||||
|
|
||||||
resourceData.size = sizeof(DirectionalLight) * MAX_DIRECTIONAL_LIGHTS;
|
|
||||||
structInfo.resourceData = resourceData;
|
|
||||||
structInfo.bDynamic = true;
|
|
||||||
directLightBuffer = graphics->createStructuredBuffer(structInfo);
|
|
||||||
resourceData.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
|
||||||
structInfo.resourceData = resourceData;
|
|
||||||
pointLightBuffer = graphics->createStructuredBuffer(structInfo);
|
|
||||||
|
|
||||||
UniformBufferCreateInfo uniformInfo;
|
|
||||||
resourceData.size = sizeof(uint32);
|
|
||||||
uniformInfo.resourceData = resourceData;
|
|
||||||
uniformInfo.bDynamic = true;
|
|
||||||
numDirLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
|
||||||
uniformInfo.resourceData = resourceData;
|
|
||||||
uniformInfo.bDynamic = true;
|
|
||||||
numPointLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
|
||||||
|
|
||||||
resources->registerBufferOutput("DIRECTIONAL_LIGHTS", directLightBuffer);
|
|
||||||
resources->registerUniformOutput("NUM_DIRECTIONAL_LIGHTS", numDirLightBuffer);
|
|
||||||
resources->registerBufferOutput("POINT_LIGHTS", pointLightBuffer);
|
|
||||||
resources->registerUniformOutput("NUM_POINT_LIGHTS", numPointLightBuffer);
|
|
||||||
|
|
||||||
TextureCreateInfo textureInfo;
|
|
||||||
textureInfo.width = dispatchParams.numThreadGroups.x;
|
|
||||||
textureInfo.height = dispatchParams.numThreadGroups.y;
|
|
||||||
textureInfo.format = Gfx::SE_FORMAT_R32G32_UINT;
|
|
||||||
textureInfo.usage = Gfx::SE_IMAGE_USAGE_STORAGE_BIT;
|
|
||||||
oLightGrid = graphics->createTexture2D(textureInfo);
|
|
||||||
tLightGrid = graphics->createTexture2D(textureInfo);
|
|
||||||
|
|
||||||
resources->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", oLightGrid);
|
|
||||||
resources->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", tLightGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LightCullingPass::createRenderPass()
|
|
||||||
{
|
|
||||||
cullingDescriptorLayout = graphics->createDescriptorLayout("CullingLayout");
|
cullingDescriptorLayout = graphics->createDescriptorLayout("CullingLayout");
|
||||||
|
|
||||||
//ViewParams
|
//ViewParams
|
||||||
@@ -189,28 +130,28 @@ void LightCullingPass::createRenderPass()
|
|||||||
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
//DepthTexture
|
//DepthTexture
|
||||||
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||||
//Frustums
|
|
||||||
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
|
||||||
//o_lightIndexCounter
|
//o_lightIndexCounter
|
||||||
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
//t_lightIndexCounter
|
//t_lightIndexCounter
|
||||||
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
//o_lightIndexList
|
//o_lightIndexList
|
||||||
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
//t_lightIndexList
|
//t_lightIndexList
|
||||||
cullingDescriptorLayout->addDescriptorBinding(7, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
//o_lightGrid
|
//o_lightGrid
|
||||||
cullingDescriptorLayout->addDescriptorBinding(8, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
cullingDescriptorLayout->addDescriptorBinding(7, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||||
//t_lightGrid
|
//t_lightGrid
|
||||||
cullingDescriptorLayout->addDescriptorBinding(9, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
cullingDescriptorLayout->addDescriptorBinding(8, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||||
|
//Frustums
|
||||||
|
cullingDescriptorLayout->addDescriptorBinding(9, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, viewportWidth * viewportHeight);
|
||||||
|
|
||||||
|
|
||||||
lightEnvDescriptorLayout = graphics->createDescriptorLayout("LightEnv");
|
lightEnvDescriptorLayout = graphics->createDescriptorLayout("LightEnv");
|
||||||
// Directional Lights
|
// Directional Lights
|
||||||
lightEnvDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
lightEnvDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_DIRECTIONAL_LIGHTS);
|
||||||
lightEnvDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
lightEnvDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
// Point Lights
|
// Point Lights
|
||||||
lightEnvDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
lightEnvDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_POINT_LIGHTS);
|
||||||
lightEnvDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
lightEnvDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
|
|
||||||
cullingLayout = graphics->createPipelineLayout();
|
cullingLayout = graphics->createPipelineLayout();
|
||||||
@@ -238,7 +179,80 @@ void LightCullingPass::createRenderPass()
|
|||||||
pipelineInfo.computeShader = cullingShader;
|
pipelineInfo.computeShader = cullingShader;
|
||||||
pipelineInfo.pipelineLayout = cullingLayout;
|
pipelineInfo.pipelineLayout = cullingLayout;
|
||||||
cullingPipeline = graphics->createComputePipeline(pipelineInfo);
|
cullingPipeline = graphics->createComputePipeline(pipelineInfo);
|
||||||
|
|
||||||
|
uint32 counterReset = 0;
|
||||||
|
StructuredBufferCreateInfo structInfo =
|
||||||
|
{
|
||||||
|
.resourceData = {
|
||||||
|
.size = sizeof(uint32),
|
||||||
|
.data = (uint8*)&counterReset,
|
||||||
|
.owner = Gfx::QueueType::COMPUTE,
|
||||||
|
},
|
||||||
|
.stride = sizeof(uint32),
|
||||||
|
.bDynamic = true,
|
||||||
|
};
|
||||||
|
oLightIndexCounter = graphics->createStructuredBuffer(structInfo);
|
||||||
|
tLightIndexCounter = graphics->createStructuredBuffer(structInfo);
|
||||||
|
structInfo = {
|
||||||
|
.resourceData = {
|
||||||
|
.size = (uint32)sizeof(uint32)
|
||||||
|
* dispatchParams.numThreadGroups.x
|
||||||
|
* dispatchParams.numThreadGroups.y
|
||||||
|
* dispatchParams.numThreadGroups.z * 200,
|
||||||
|
.data = nullptr,
|
||||||
|
.owner = Gfx::QueueType::COMPUTE
|
||||||
|
},
|
||||||
|
.stride = sizeof(uint32),
|
||||||
|
.bDynamic = false,
|
||||||
|
};
|
||||||
|
oLightIndexList = graphics->createStructuredBuffer(structInfo);
|
||||||
|
tLightIndexList = graphics->createStructuredBuffer(structInfo);
|
||||||
|
resources->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
||||||
|
resources->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
||||||
|
|
||||||
|
structInfo = {
|
||||||
|
.resourceData = {
|
||||||
|
.size = sizeof(DirectionalLight) * MAX_DIRECTIONAL_LIGHTS,
|
||||||
|
.data = nullptr,
|
||||||
|
},
|
||||||
|
.stride = sizeof(DirectionalLight),
|
||||||
|
.bDynamic = true,
|
||||||
|
};
|
||||||
|
directLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||||
|
structInfo.resourceData.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||||
|
pointLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||||
|
|
||||||
|
UniformBufferCreateInfo uniformInfo = {
|
||||||
|
.resourceData = {
|
||||||
|
.size = sizeof(uint32),
|
||||||
|
.data = nullptr
|
||||||
|
},
|
||||||
|
.bDynamic = true
|
||||||
|
};
|
||||||
|
numDirLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||||
|
numPointLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||||
|
|
||||||
|
resources->registerBufferOutput("DIRECTIONAL_LIGHTS", directLightBuffer);
|
||||||
|
resources->registerUniformOutput("NUM_DIRECTIONAL_LIGHTS", numDirLightBuffer);
|
||||||
|
resources->registerBufferOutput("POINT_LIGHTS", pointLightBuffer);
|
||||||
|
resources->registerUniformOutput("NUM_POINT_LIGHTS", numPointLightBuffer);
|
||||||
|
|
||||||
|
TextureCreateInfo textureInfo = {
|
||||||
|
.width = dispatchParams.numThreadGroups.x,
|
||||||
|
.height = dispatchParams.numThreadGroups.y,
|
||||||
|
.format = Gfx::SE_FORMAT_R32G32_UINT,
|
||||||
|
.usage = Gfx::SE_IMAGE_USAGE_STORAGE_BIT,
|
||||||
|
};
|
||||||
|
oLightGrid = graphics->createTexture2D(textureInfo);
|
||||||
|
tLightGrid = graphics->createTexture2D(textureInfo);
|
||||||
|
|
||||||
|
resources->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", oLightGrid);
|
||||||
|
resources->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", tLightGrid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LightCullingPass::createRenderPass()
|
||||||
|
{
|
||||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH")->getTexture();
|
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH")->getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,11 +268,13 @@ void LightCullingPass::setupFrustums()
|
|||||||
glm::uvec3 numThreads = glm::ceil(glm::vec3(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1));
|
glm::uvec3 numThreads = glm::ceil(glm::vec3(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1));
|
||||||
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1));
|
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1));
|
||||||
|
|
||||||
viewParams.viewMatrix = source->getViewMatrix();
|
viewParams = {
|
||||||
viewParams.projectionMatrix = source->getProjectionMatrix();
|
.viewMatrix = source->getViewMatrix(),
|
||||||
viewParams.inverseProjectionMatrix = glm::inverse(source->getProjectionMatrix());
|
.projectionMatrix = source->getProjectionMatrix(),
|
||||||
viewParams.screenDimensions = glm::vec2(viewportWidth, viewportHeight);
|
.inverseProjectionMatrix = glm::inverse(source->getProjectionMatrix()),
|
||||||
viewParams.cameraPosition = Vector4(source->getCameraPosition(), 0);
|
.cameraPosition = Vector4(source->getCameraPosition(), 0),
|
||||||
|
.screenDimensions = glm::vec2(viewportWidth, viewportHeight),
|
||||||
|
};
|
||||||
dispatchParams.numThreads = numThreads;
|
dispatchParams.numThreads = numThreads;
|
||||||
dispatchParams.numThreadGroups = numThreadGroups;
|
dispatchParams.numThreadGroups = numThreadGroups;
|
||||||
|
|
||||||
@@ -283,7 +299,6 @@ void LightCullingPass::setupFrustums()
|
|||||||
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
|
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
|
||||||
frustumShader = graphics->createComputeShader(createInfo);
|
frustumShader = graphics->createComputeShader(createInfo);
|
||||||
|
|
||||||
|
|
||||||
ComputePipelineCreateInfo pipelineInfo;
|
ComputePipelineCreateInfo pipelineInfo;
|
||||||
pipelineInfo.computeShader = frustumShader;
|
pipelineInfo.computeShader = frustumShader;
|
||||||
pipelineInfo.pipelineLayout = frustumLayout;
|
pipelineInfo.pipelineLayout = frustumLayout;
|
||||||
@@ -304,11 +319,14 @@ void LightCullingPass::setupFrustums()
|
|||||||
uniformInfo.bDynamic = false;
|
uniformInfo.bDynamic = false;
|
||||||
dispatchParamsBuffer = graphics->createUniformBuffer(uniformInfo);
|
dispatchParamsBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||||
|
|
||||||
StructuredBufferCreateInfo structuredInfo;
|
StructuredBufferCreateInfo structuredInfo = {
|
||||||
resourceInfo.size = sizeof(Frustum) * numThreads.x * numThreads.y * numThreads.z;
|
.resourceData = {
|
||||||
resourceInfo.data = nullptr;
|
.size = sizeof(Frustum) * numThreads.x * numThreads.y * numThreads.z,
|
||||||
structuredInfo.resourceData = resourceInfo;
|
.data = nullptr,
|
||||||
structuredInfo.bDynamic = false;
|
},
|
||||||
|
.stride = sizeof(Frustum),
|
||||||
|
.bDynamic = false,
|
||||||
|
};
|
||||||
frustumBuffer = graphics->createStructuredBuffer(structuredInfo);
|
frustumBuffer = graphics->createStructuredBuffer(structuredInfo);
|
||||||
|
|
||||||
frustumDescriptorSet = frustumDescriptorLayout->allocateDescriptorSet();
|
frustumDescriptorSet = frustumDescriptorLayout->allocateDescriptorSet();
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class LightCullingPass : public RenderPass<LightCullingPassData>
|
|||||||
public:
|
public:
|
||||||
LightCullingPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
|
LightCullingPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
|
||||||
virtual ~LightCullingPass();
|
virtual ~LightCullingPass();
|
||||||
virtual MainJob beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
virtual MainJob endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "Scene/Scene.h"
|
#include "Scene/Scene.h"
|
||||||
#include "Graphics/GraphicsResources.h"
|
#include "Graphics/GraphicsResources.h"
|
||||||
#include "Graphics/MeshBatch.h"
|
#include "Graphics/MeshBatch.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
PScene scene;
|
PScene scene;
|
||||||
Gfx::PGraphics graphics;
|
Gfx::PGraphics graphics;
|
||||||
virtual MainJob processMeshBatch(
|
virtual void processMeshBatch(
|
||||||
const MeshBatch& batch,
|
const MeshBatch& batch,
|
||||||
// const PPrimitiveComponent primitiveComponent,
|
// const PPrimitiveComponent primitiveComponent,
|
||||||
const Gfx::PRenderPass& renderPass,
|
const Gfx::PRenderPass& renderPass,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Math/Math.h"
|
#include "Math/Math.h"
|
||||||
#include "RenderGraph.h"
|
#include "RenderGraph.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -22,9 +21,9 @@ public:
|
|||||||
void updateViewFrame(RenderPassDataType viewFrame) {
|
void updateViewFrame(RenderPassDataType viewFrame) {
|
||||||
passData = std::move(viewFrame);
|
passData = std::move(viewFrame);
|
||||||
}
|
}
|
||||||
virtual MainJob beginFrame() = 0;
|
virtual void beginFrame() = 0;
|
||||||
virtual MainJob render() = 0;
|
virtual void render() = 0;
|
||||||
virtual MainJob endFrame() = 0;
|
virtual void endFrame() = 0;
|
||||||
virtual void publishOutputs() = 0;
|
virtual void publishOutputs() = 0;
|
||||||
virtual void createRenderPass() = 0;
|
virtual void createRenderPass() = 0;
|
||||||
void setResources(PRenderGraphResources resources) { this->resources = resources; }
|
void setResources(PRenderGraphResources resources) { this->resources = resources; }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ TextPass::~TextPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob TextPass::beginFrame()
|
void TextPass::beginFrame()
|
||||||
{
|
{
|
||||||
for(TextRender& render : passData.texts)
|
for(TextRender& render : passData.texts)
|
||||||
{
|
{
|
||||||
@@ -37,25 +37,18 @@ MainJob TextPass::beginFrame()
|
|||||||
vbInfo.numVertices = static_cast<uint32>(instanceData.size());
|
vbInfo.numVertices = static_cast<uint32>(instanceData.size());
|
||||||
vbInfo.vertexSize = sizeof(GlyphInstanceData);
|
vbInfo.vertexSize = sizeof(GlyphInstanceData);
|
||||||
vbInfo.resourceData.data = reinterpret_cast<uint8*>(instanceData.data());
|
vbInfo.resourceData.data = reinterpret_cast<uint8*>(instanceData.data());
|
||||||
vbInfo.resourceData.size = static_cast<uint32>(instanceData.size());
|
vbInfo.resourceData.size = static_cast<uint32>(instanceData.size() * sizeof(GlyphInstanceData));
|
||||||
resources.vertexBuffer = graphics->createVertexBuffer(vbInfo);
|
resources.vertexBuffer = graphics->createVertexBuffer(vbInfo);
|
||||||
|
|
||||||
resources.descriptorSet = descriptorLayout->allocateDescriptorSet();
|
resources.glyphDataSet = fontData.glyphDataSet;
|
||||||
resources.descriptorSet->updateBuffer(0, projectionBuffer);
|
resources.textureArraySet = fontData.textureArraySet;
|
||||||
resources.descriptorSet->updateSampler(1, glyphSampler);
|
|
||||||
resources.descriptorSet->updateBuffer(2, fontData.structuredBuffer);
|
|
||||||
resources.descriptorSet->writeChanges();
|
|
||||||
|
|
||||||
resources.textureArraySet = descriptorLayout->allocateDescriptorSet();
|
|
||||||
resources.textureArraySet->updateTextureArray(0, fontData.textures);
|
|
||||||
|
|
||||||
resources.textureArraySet->writeChanges();
|
|
||||||
resources.scale = render.scale;
|
resources.scale = render.scale;
|
||||||
}
|
}
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob TextPass::render()
|
void TextPass::render()
|
||||||
{
|
{
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
Array<Gfx::PRenderCommand> commands;
|
Array<Gfx::PRenderCommand> commands;
|
||||||
@@ -64,7 +57,7 @@ MainJob TextPass::render()
|
|||||||
Gfx::PRenderCommand command = graphics->createRenderCommand("TextPassCommand");
|
Gfx::PRenderCommand command = graphics->createRenderCommand("TextPassCommand");
|
||||||
command->setViewport(viewport);
|
command->setViewport(viewport);
|
||||||
command->bindPipeline(pipeline);
|
command->bindPipeline(pipeline);
|
||||||
|
command->bindDescriptor({generalSet, resources.glyphDataSet, resources.textureArraySet});
|
||||||
command->bindVertexBuffer({VertexInputStream(0, 0, resources.vertexBuffer)});
|
command->bindVertexBuffer({VertexInputStream(0, 0, resources.vertexBuffer)});
|
||||||
|
|
||||||
command->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float), &resources.scale);
|
command->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float), &resources.scale);
|
||||||
@@ -73,12 +66,13 @@ MainJob TextPass::render()
|
|||||||
}
|
}
|
||||||
graphics->executeCommands(commands);
|
graphics->executeCommands(commands);
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
co_return;
|
textResources.clear();
|
||||||
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob TextPass::endFrame()
|
void TextPass::endFrame()
|
||||||
{
|
{
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextPass::publishOutputs()
|
void TextPass::publishOutputs()
|
||||||
@@ -123,16 +117,20 @@ void TextPass::createRenderPass()
|
|||||||
});
|
});
|
||||||
declaration = graphics->createVertexDeclaration(elements);
|
declaration = graphics->createVertexDeclaration(elements);
|
||||||
|
|
||||||
descriptorLayout = graphics->createDescriptorLayout("TextDescriptor");
|
generalLayout = graphics->createDescriptorLayout("TextGeneral");
|
||||||
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
generalLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
generalLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||||
descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, 128, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
|
generalLayout->create();
|
||||||
descriptorLayout->create();
|
|
||||||
|
glyphDataLayout = graphics->createDescriptorLayout("TextGlyphData");
|
||||||
|
glyphDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
|
glyphDataLayout->create();
|
||||||
|
|
||||||
textureArrayLayout = graphics->createDescriptorLayout("TextureArray");
|
textureArrayLayout = graphics->createDescriptorLayout("TextTextureArray");
|
||||||
textureArrayLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 128, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
|
textureArrayLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 128, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
|
||||||
textureArrayLayout->create();
|
textureArrayLayout->create();
|
||||||
|
|
||||||
|
|
||||||
Matrix4 projectionMatrix = glm::ortho(0.f, (float)viewport->getSizeX(), 0.f, (float)viewport->getSizeY());
|
Matrix4 projectionMatrix = glm::ortho(0.f, (float)viewport->getSizeX(), 0.f, (float)viewport->getSizeY());
|
||||||
projectionBuffer = graphics->createUniformBuffer({
|
projectionBuffer = graphics->createUniformBuffer({
|
||||||
.resourceData = {
|
.resourceData = {
|
||||||
@@ -146,12 +144,18 @@ void TextPass::createRenderPass()
|
|||||||
.magFilter = Gfx::SE_FILTER_LINEAR,
|
.magFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
.minFilter = Gfx::SE_FILTER_LINEAR,
|
.minFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
.addressModeU = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
.addressModeU = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
|
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
generalSet = generalLayout->allocateDescriptorSet();
|
||||||
|
generalSet->updateBuffer(0, projectionBuffer);
|
||||||
|
generalSet->updateSampler(1, glyphSampler);
|
||||||
|
generalSet->writeChanges();
|
||||||
|
|
||||||
pipelineLayout = graphics->createPipelineLayout();
|
pipelineLayout = graphics->createPipelineLayout();
|
||||||
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
|
pipelineLayout->addDescriptorLayout(0, generalLayout);
|
||||||
pipelineLayout->addDescriptorLayout(1, textureArrayLayout);
|
pipelineLayout->addDescriptorLayout(1, glyphDataLayout);
|
||||||
|
pipelineLayout->addDescriptorLayout(2, textureArrayLayout);
|
||||||
pipelineLayout->addPushConstants({
|
pipelineLayout->addPushConstants({
|
||||||
.stageFlags = Gfx::SE_SHADER_STAGE_VERTEX_BIT,
|
.stageFlags = Gfx::SE_SHADER_STAGE_VERTEX_BIT,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
@@ -168,6 +172,15 @@ void TextPass::createRenderPass()
|
|||||||
pipelineInfo.renderPass = renderPass;
|
pipelineInfo.renderPass = renderPass;
|
||||||
pipelineInfo.pipelineLayout = pipelineLayout;
|
pipelineInfo.pipelineLayout = pipelineLayout;
|
||||||
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
|
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
|
||||||
|
pipelineInfo.colorBlend.attachmentCount = 1;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].blendEnable = true;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].colorWriteMask = Gfx::SE_COLOR_COMPONENT_R_BIT | Gfx::SE_COLOR_COMPONENT_G_BIT | Gfx::SE_COLOR_COMPONENT_B_BIT | Gfx::SE_COLOR_COMPONENT_A_BIT;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].srcColorBlendFactor = Gfx::SE_BLEND_FACTOR_SRC_ALPHA;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].dstColorBlendFactor = Gfx::SE_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].alphaBlendOp = Gfx::SE_BLEND_OP_ADD;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].srcAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].dstAlphaBlendFactor = Gfx::SE_BLEND_FACTOR_ZERO;
|
||||||
|
pipelineInfo.colorBlend.blendAttachments[0].alphaBlendOp = Gfx::SE_BLEND_OP_ADD;
|
||||||
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
||||||
|
|
||||||
pipeline = graphics->createGraphicsPipeline(pipelineInfo);
|
pipeline = graphics->createGraphicsPipeline(pipelineInfo);
|
||||||
@@ -181,20 +194,33 @@ TextPass::FontData& TextPass::getFontData(PFontAsset font)
|
|||||||
const Map<uint32, FontAsset::Glyph>& fontGlyphs = font->getGlyphData();
|
const Map<uint32, FontAsset::Glyph>& fontGlyphs = font->getGlyphData();
|
||||||
FontData& fd = fontData[font];
|
FontData& fd = fontData[font];
|
||||||
Array<GlyphData> buffer;
|
Array<GlyphData> buffer;
|
||||||
|
Array<Gfx::PTexture> textures;
|
||||||
buffer.reserve(fontGlyphs.size());
|
buffer.reserve(fontGlyphs.size());
|
||||||
for(const auto& [key, value] : fontGlyphs)
|
for(const auto& [key, value] : fontGlyphs)
|
||||||
{
|
{
|
||||||
fd.characterToGlyphIndex[key] = static_cast<uint32>(buffer.size());
|
fd.characterToGlyphIndex[key] = static_cast<uint32>(buffer.size());
|
||||||
fd.characterAdvance[key] = value.advance;
|
fd.characterAdvance[key] = value.advance;
|
||||||
fd.textures.add(value.texture);
|
|
||||||
GlyphData& gd = buffer.add();
|
GlyphData& gd = buffer.add();
|
||||||
gd.bearing = value.bearing;
|
gd.bearing = value.bearing;
|
||||||
gd.size = value.size;
|
gd.size = value.size;
|
||||||
|
textures.add(value.texture);
|
||||||
}
|
}
|
||||||
StructuredBufferCreateInfo bufferInfo;
|
StructuredBufferCreateInfo bufferInfo = {
|
||||||
bufferInfo.bDynamic = false;
|
.resourceData = {
|
||||||
bufferInfo.resourceData.data = reinterpret_cast<uint8*>(buffer.data());
|
.size = static_cast<uint32>(buffer.size() * sizeof(GlyphData)),
|
||||||
bufferInfo.resourceData.size = static_cast<uint32>(buffer.size());
|
.data = reinterpret_cast<uint8*>(buffer.data()),
|
||||||
fd.structuredBuffer = graphics->createStructuredBuffer(bufferInfo);
|
},
|
||||||
|
.stride = sizeof(GlyphData),
|
||||||
|
.bDynamic = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
Gfx::PStructuredBuffer glyphBuffer = graphics->createStructuredBuffer(bufferInfo);
|
||||||
|
fd.glyphDataSet = glyphDataLayout->allocateDescriptorSet();
|
||||||
|
fd.glyphDataSet->updateBuffer(0, glyphBuffer);
|
||||||
|
fd.glyphDataSet->writeChanges();
|
||||||
|
|
||||||
|
fd.textureArraySet = textureArrayLayout->allocateDescriptorSet();
|
||||||
|
fd.textureArraySet->updateTextureArray(0, textures);
|
||||||
|
fd.textureArraySet->writeChanges();
|
||||||
return fontData[font];
|
return fontData[font];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ class TextPass : public RenderPass<TextPassData>
|
|||||||
public:
|
public:
|
||||||
TextPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
TextPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
||||||
virtual ~TextPass();
|
virtual ~TextPass();
|
||||||
virtual MainJob beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
virtual MainJob endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
private:
|
private:
|
||||||
@@ -45,8 +45,8 @@ private:
|
|||||||
};
|
};
|
||||||
struct FontData
|
struct FontData
|
||||||
{
|
{
|
||||||
Gfx::PStructuredBuffer structuredBuffer;
|
Gfx::PDescriptorSet glyphDataSet;
|
||||||
Array<Gfx::PTexture> textures;
|
Gfx::PDescriptorSet textureArraySet;
|
||||||
Map<uint32, uint32> characterToGlyphIndex;
|
Map<uint32, uint32> characterToGlyphIndex;
|
||||||
// Logically this should be part of GlyphData,
|
// Logically this should be part of GlyphData,
|
||||||
// but because GlyphData mirrors shader data and we need
|
// but because GlyphData mirrors shader data and we need
|
||||||
@@ -58,9 +58,9 @@ private:
|
|||||||
|
|
||||||
struct TextResources
|
struct TextResources
|
||||||
{
|
{
|
||||||
Gfx::PDescriptorSet descriptorSet;
|
|
||||||
Gfx::PDescriptorSet textureArraySet;
|
|
||||||
Gfx::PVertexBuffer vertexBuffer;
|
Gfx::PVertexBuffer vertexBuffer;
|
||||||
|
Gfx::PDescriptorSet glyphDataSet;
|
||||||
|
Gfx::PDescriptorSet textureArraySet;
|
||||||
float scale;
|
float scale;
|
||||||
};
|
};
|
||||||
Array<TextResources> textResources;
|
Array<TextResources> textResources;
|
||||||
@@ -69,9 +69,12 @@ private:
|
|||||||
Gfx::PRenderTargetAttachment depthAttachment;
|
Gfx::PRenderTargetAttachment depthAttachment;
|
||||||
Gfx::PTexture2D depthBuffer;
|
Gfx::PTexture2D depthBuffer;
|
||||||
|
|
||||||
Gfx::PDescriptorLayout descriptorLayout;
|
Gfx::PDescriptorLayout generalLayout;
|
||||||
|
Gfx::PDescriptorLayout glyphDataLayout;
|
||||||
Gfx::PDescriptorLayout textureArrayLayout;
|
Gfx::PDescriptorLayout textureArrayLayout;
|
||||||
|
|
||||||
|
Gfx::PDescriptorSet generalSet;
|
||||||
|
|
||||||
Gfx::PUniformBuffer projectionBuffer;
|
Gfx::PUniformBuffer projectionBuffer;
|
||||||
Gfx::PSamplerState glyphSampler;
|
Gfx::PSamplerState glyphSampler;
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ UIPass::~UIPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob UIPass::beginFrame()
|
void UIPass::beginFrame()
|
||||||
{
|
{
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob UIPass::render()
|
void UIPass::render()
|
||||||
{
|
{
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
||||||
@@ -29,12 +29,12 @@ MainJob UIPass::render()
|
|||||||
command->draw(4, 1, 0, 0);
|
command->draw(4, 1, 0, 0);
|
||||||
graphics->executeCommands(Array<Gfx::PRenderCommand>({command}));
|
graphics->executeCommands(Array<Gfx::PRenderCommand>({command}));
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob UIPass::endFrame()
|
void UIPass::endFrame()
|
||||||
{
|
{
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPass::publishOutputs()
|
void UIPass::publishOutputs()
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ class UIPass : public RenderPass<UIPassData>
|
|||||||
public:
|
public:
|
||||||
UIPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
UIPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
||||||
virtual ~UIPass();
|
virtual ~UIPass();
|
||||||
virtual MainJob beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
virtual MainJob endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -90,10 +90,9 @@ PSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDevice
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto it : freeRanges)
|
for (auto& [allocatedOffset, freeAllocation] : freeRanges)
|
||||||
{
|
{
|
||||||
PSubAllocation freeAllocation = it.value;
|
assert(allocatedOffset == freeAllocation->allocatedOffset);
|
||||||
VkDeviceSize allocatedOffset = freeAllocation->allocatedOffset;
|
|
||||||
VkDeviceSize alignedOffset = align(allocatedOffset, alignment);
|
VkDeviceSize alignedOffset = align(allocatedOffset, alignment);
|
||||||
VkDeviceSize alignmentAdjustment = alignedOffset - allocatedOffset;
|
VkDeviceSize alignmentAdjustment = alignedOffset - allocatedOffset;
|
||||||
VkDeviceSize size = alignmentAdjustment + requestedSize;
|
VkDeviceSize size = alignmentAdjustment + requestedSize;
|
||||||
@@ -112,8 +111,8 @@ PSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDevice
|
|||||||
freeAllocation->alignedOffset += size;
|
freeAllocation->alignedOffset += size;
|
||||||
PSubAllocation subAlloc = new SubAllocation(this, allocatedOffset, size, alignedOffset, size);
|
PSubAllocation subAlloc = new SubAllocation(this, allocatedOffset, size, alignedOffset, size);
|
||||||
activeAllocations[allocatedOffset] = subAlloc.getHandle();
|
activeAllocations[allocatedOffset] = subAlloc.getHandle();
|
||||||
freeRanges.erase(allocatedOffset);
|
|
||||||
freeRanges[freeAllocation->allocatedOffset] = freeAllocation;
|
freeRanges[freeAllocation->allocatedOffset] = freeAllocation;
|
||||||
|
freeRanges.erase(allocatedOffset);
|
||||||
bytesUsed += size;
|
bytesUsed += size;
|
||||||
return subAlloc;
|
return subAlloc;
|
||||||
}
|
}
|
||||||
@@ -136,9 +135,8 @@ void Allocation::markFree(SubAllocation *allocation)
|
|||||||
{
|
{
|
||||||
std::scoped_lock lck(lock);
|
std::scoped_lock lck(lock);
|
||||||
//Join lower bound
|
//Join lower bound
|
||||||
for (auto freeRange : freeRanges)
|
for (auto& [allocatedOffset, freeAlloc] : freeRanges)
|
||||||
{
|
{
|
||||||
PSubAllocation freeAlloc = freeRange.value;
|
|
||||||
if (freeAlloc->allocatedOffset <= lowerBound
|
if (freeAlloc->allocatedOffset <= lowerBound
|
||||||
&& freeAlloc->allocatedOffset + freeAlloc->allocatedSize >= upperBound)
|
&& freeAlloc->allocatedOffset + freeAlloc->allocatedSize >= upperBound)
|
||||||
{
|
{
|
||||||
@@ -157,24 +155,24 @@ void Allocation::markFree(SubAllocation *allocation)
|
|||||||
auto foundAlloc = freeRanges.find(upperBound);
|
auto foundAlloc = freeRanges.find(upperBound);
|
||||||
if (foundAlloc != freeRanges.end())
|
if (foundAlloc != freeRanges.end())
|
||||||
{
|
{
|
||||||
freeRangeToDelete = foundAlloc->value;
|
freeRangeToDelete = foundAlloc->second;
|
||||||
// There is a free allocation ending where the new free one ends
|
// There is a free allocation ending where the new free one ends
|
||||||
if (allocHandle != nullptr)
|
if (allocHandle != nullptr)
|
||||||
{
|
{
|
||||||
// extend allocHandle by another foundAlloc->allocatedSize bytes
|
// extend allocHandle by another foundAlloc->allocatedSize bytes
|
||||||
allocHandle->allocatedSize += foundAlloc->value->allocatedSize;
|
allocHandle->allocatedSize += foundAlloc->second->allocatedSize;
|
||||||
freeRanges.erase(foundAlloc->key);
|
freeRanges.erase(foundAlloc->first);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set foundAlloc back by size amount
|
// set foundAlloc back by size amount
|
||||||
allocHandle = foundAlloc->value;
|
allocHandle = foundAlloc->second;
|
||||||
allocHandle->allocatedOffset -= allocation->allocatedSize;
|
allocHandle->allocatedOffset -= allocation->allocatedSize;
|
||||||
allocHandle->alignedOffset -= allocation->allocatedSize;
|
allocHandle->alignedOffset -= allocation->allocatedSize;
|
||||||
// place back at correct offset
|
// place back at correct offset
|
||||||
freeRanges[allocHandle->allocatedOffset] = allocHandle;
|
freeRanges[allocHandle->allocatedOffset] = allocHandle;
|
||||||
// remove from offset map since key changes
|
// remove from offset map since key changes
|
||||||
freeRanges.erase(foundAlloc->key);
|
freeRanges.erase(foundAlloc->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +257,7 @@ void Allocator::free(Allocation *allocation)
|
|||||||
{
|
{
|
||||||
if (heap.allocations[i] == allocation)
|
if (heap.allocations[i] == allocation)
|
||||||
{
|
{
|
||||||
heap.allocations.remove(i, false);
|
heap.allocations.removeAt(i, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ private:
|
|||||||
VkDeviceSize bytesAllocated;
|
VkDeviceSize bytesAllocated;
|
||||||
VkDeviceSize bytesUsed;
|
VkDeviceSize bytesUsed;
|
||||||
VkDeviceMemory allocatedMemory;
|
VkDeviceMemory allocatedMemory;
|
||||||
Map<VkDeviceSize, SubAllocation *> activeAllocations;
|
std::map<VkDeviceSize, SubAllocation *> activeAllocations;
|
||||||
Map<VkDeviceSize, PSubAllocation> freeRanges;
|
std::map<VkDeviceSize, PSubAllocation> freeRanges;
|
||||||
std::mutex lock;
|
std::mutex lock;
|
||||||
void *mappedPointer;
|
void *mappedPointer;
|
||||||
uint8 isDedicated : 1;
|
uint8 isDedicated : 1;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "VulkanGraphics.h"
|
#include "VulkanGraphics.h"
|
||||||
#include "VulkanCommandBuffer.h"
|
#include "VulkanCommandBuffer.h"
|
||||||
#include "VulkanAllocator.h"
|
#include "VulkanAllocator.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
@@ -65,11 +64,11 @@ ShaderBuffer::~ShaderBuffer()
|
|||||||
{
|
{
|
||||||
PCmdBuffer cmdBuffer = graphics->getQueueCommands(owner)->getCommands();
|
PCmdBuffer cmdBuffer = graphics->getQueueCommands(owner)->getCommands();
|
||||||
VkDevice device = graphics->getDevice();
|
VkDevice device = graphics->getDevice();
|
||||||
auto deletionLambda = [cmdBuffer, device](VkBuffer buffer) -> Job
|
auto deletionLambda = [cmdBuffer, device](VkBuffer buffer) -> void
|
||||||
{
|
{
|
||||||
//co_await cmdBuffer->asyncWait();
|
//co_await cmdBuffer->asyncWait();
|
||||||
//vkDestroyBuffer(device, buffer, nullptr);
|
//vkDestroyBuffer(device, buffer, nullptr);
|
||||||
co_return;
|
//co_return;
|
||||||
};
|
};
|
||||||
for (uint32 i = 0; i < numBuffers; ++i)
|
for (uint32 i = 0; i < numBuffers; ++i)
|
||||||
{
|
{
|
||||||
@@ -355,7 +354,7 @@ VkAccessFlags UniformBuffer::getDestAccessMask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
StructuredBuffer::StructuredBuffer(PGraphics graphics, const StructuredBufferCreateInfo &resourceData)
|
StructuredBuffer::StructuredBuffer(PGraphics graphics, const StructuredBufferCreateInfo &resourceData)
|
||||||
: Gfx::StructuredBuffer(graphics->getFamilyMapping(), resourceData.resourceData)
|
: Gfx::StructuredBuffer(graphics->getFamilyMapping(), resourceData.stride, resourceData.resourceData)
|
||||||
, Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner, resourceData.bDynamic)
|
, Vulkan::ShaderBuffer(graphics, resourceData.resourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner, resourceData.bDynamic)
|
||||||
{
|
{
|
||||||
if (resourceData.resourceData.data != nullptr)
|
if (resourceData.resourceData.data != nullptr)
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
|
|||||||
{
|
{
|
||||||
assert(threadId == std::this_thread::get_id());
|
assert(threadId == std::this_thread::get_id());
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||||
|
assert(descriptor->writeDescriptors.size() == 0);
|
||||||
boundDescriptors.add(descriptor.getHandle());
|
boundDescriptors.add(descriptor.getHandle());
|
||||||
descriptor->bind();
|
descriptor->bind();
|
||||||
|
|
||||||
@@ -263,6 +264,7 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
|||||||
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
||||||
{
|
{
|
||||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||||
|
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||||
descriptorSet->bind();
|
descriptorSet->bind();
|
||||||
|
|
||||||
boundDescriptors.add(descriptorSet.getHandle());
|
boundDescriptors.add(descriptorSet.getHandle());
|
||||||
@@ -370,6 +372,7 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
|
|||||||
{
|
{
|
||||||
assert(threadId == std::this_thread::get_id());
|
assert(threadId == std::this_thread::get_id());
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||||
|
assert(descriptor->writeDescriptors.size() == 0);
|
||||||
boundDescriptors.add(descriptor.getHandle());
|
boundDescriptors.add(descriptor.getHandle());
|
||||||
descriptor->bind();
|
descriptor->bind();
|
||||||
|
|
||||||
@@ -384,9 +387,11 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
|||||||
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
||||||
{
|
{
|
||||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||||
boundDescriptors.add(descriptorSet.getHandle());
|
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||||
descriptorSet->bind();
|
descriptorSet->bind();
|
||||||
|
|
||||||
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
||||||
|
boundDescriptors.add(descriptorSet.getHandle());
|
||||||
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
||||||
}
|
}
|
||||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr);
|
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr);
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBu
|
|||||||
cachedData[binding] = new UniformBuffer(*vulkanBuffer.getHandle());
|
cachedData[binding] = new UniformBuffer(*vulkanBuffer.getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer)
|
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PStructuredBuffer structuredBuffer)
|
||||||
{
|
{
|
||||||
PStructuredBuffer vulkanBuffer = uniformBuffer.cast<StructuredBuffer>();
|
PStructuredBuffer vulkanBuffer = structuredBuffer.cast<StructuredBuffer>();
|
||||||
StructuredBuffer* cachedBuffer = reinterpret_cast<StructuredBuffer*>(cachedData[binding]);
|
StructuredBuffer* cachedBuffer = reinterpret_cast<StructuredBuffer*>(cachedData[binding]);
|
||||||
if(vulkanBuffer.getHandle() == cachedBuffer)
|
if(vulkanBuffer.getHandle() == cachedBuffer)
|
||||||
{
|
{
|
||||||
@@ -330,7 +330,7 @@ void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet &descriptorS
|
|||||||
uint32 counts = 0;
|
uint32 counts = 0;
|
||||||
for(const auto& binding : layout.bindings)
|
for(const auto& binding : layout.bindings)
|
||||||
{
|
{
|
||||||
if(binding.binding & Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT)
|
if(binding.descriptorCount > 0)
|
||||||
{
|
{
|
||||||
counts = binding.descriptorCount;
|
counts = binding.descriptorCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ private:
|
|||||||
bool currentlyInUse;
|
bool currentlyInUse;
|
||||||
friend class DescriptorAllocator;
|
friend class DescriptorAllocator;
|
||||||
friend class CmdBuffer;
|
friend class CmdBuffer;
|
||||||
|
friend class RenderCommand;
|
||||||
|
friend class ComputeCommand;
|
||||||
};
|
};
|
||||||
DEFINE_REF(DescriptorSet)
|
DEFINE_REF(DescriptorSet)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "Graphics/GraphicsResources.h"
|
#include "Graphics/GraphicsResources.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|
||||||
thread_local PCommandBufferManager Seele::Vulkan::Graphics::graphicsCommands = nullptr;
|
thread_local PCommandBufferManager Seele::Vulkan::Graphics::graphicsCommands = nullptr;
|
||||||
@@ -570,7 +571,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV |
|
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV |
|
||||||
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV |
|
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV |
|
||||||
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV;
|
VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV;
|
||||||
deviceInfo.pNext = &crashDiagInfo;
|
descriptorIndexing.pNext = &crashDiagInfo;
|
||||||
#endif
|
#endif
|
||||||
deviceInfo.enabledExtensionCount = (uint32)initializer.deviceExtensions.size();
|
deviceInfo.enabledExtensionCount = (uint32)initializer.deviceExtensions.size();
|
||||||
deviceInfo.ppEnabledExtensionNames = initializer.deviceExtensions.data();
|
deviceInfo.ppEnabledExtensionNames = initializer.deviceExtensions.data();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "VulkanGraphicsEnums.h"
|
#include "VulkanGraphicsEnums.h"
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
using namespace Seele::Gfx;
|
using namespace Seele::Gfx;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Semaphore::~Semaphore()
|
|||||||
|
|
||||||
Fence::Fence(PGraphics graphics)
|
Fence::Fence(PGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
, signaled("Fence")
|
, signaled(false)
|
||||||
{
|
{
|
||||||
VkFenceCreateInfo info =
|
VkFenceCreateInfo info =
|
||||||
init::FenceCreateInfo(0);
|
init::FenceCreateInfo(0);
|
||||||
@@ -45,8 +45,8 @@ bool Fence::isSignaled()
|
|||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case VK_SUCCESS:
|
case VK_SUCCESS:
|
||||||
signaled.raise();
|
signaled = true;
|
||||||
return true;
|
return signaled;
|
||||||
case VK_NOT_READY:
|
case VK_NOT_READY:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -60,7 +60,7 @@ void Fence::reset()
|
|||||||
if (signaled)
|
if (signaled)
|
||||||
{
|
{
|
||||||
vkResetFences(graphics->getDevice(), 1, &fence);
|
vkResetFences(graphics->getDevice(), 1, &fence);
|
||||||
signaled.reset();
|
signaled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ void Fence::wait(uint32 timeout)
|
|||||||
switch (r)
|
switch (r)
|
||||||
{
|
{
|
||||||
case VK_SUCCESS:
|
case VK_SUCCESS:
|
||||||
signaled.raise();
|
signaled = true;
|
||||||
break;
|
break;
|
||||||
case VK_TIMEOUT:
|
case VK_TIMEOUT:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Graphics/GraphicsResources.h"
|
#include "Graphics/GraphicsResources.h"
|
||||||
#include "VulkanAllocator.h"
|
#include "VulkanAllocator.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -43,10 +42,10 @@ public:
|
|||||||
return fence;
|
return fence;
|
||||||
}
|
}
|
||||||
void wait(uint32 timeout);
|
void wait(uint32 timeout);
|
||||||
Event& operator co_await()
|
/*Event& operator co_await()
|
||||||
{
|
{
|
||||||
return signaled;
|
return signaled;
|
||||||
}
|
}*/
|
||||||
bool operator<(const Fence &other) const
|
bool operator<(const Fence &other) const
|
||||||
{
|
{
|
||||||
return fence < other.fence;
|
return fence < other.fence;
|
||||||
@@ -54,7 +53,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
Event signaled;
|
bool signaled;
|
||||||
VkFence fence;
|
VkFence fence;
|
||||||
};
|
};
|
||||||
DEFINE_REF(Fence)
|
DEFINE_REF(Fence)
|
||||||
@@ -357,6 +356,11 @@ public:
|
|||||||
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
|
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
|
||||||
virtual void setCloseCallback(std::function<void()> callback);
|
virtual void setCloseCallback(std::function<void()> callback);
|
||||||
|
|
||||||
|
VkFormat getPixelFormat() const
|
||||||
|
{
|
||||||
|
return cast(windowState.pixelFormat);
|
||||||
|
}
|
||||||
|
|
||||||
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
||||||
std::function<void(double, double)> mouseMoveCallback;
|
std::function<void(double, double)> mouseMoveCallback;
|
||||||
std::function<void(MouseButton, InputAction, KeyModifier)> mouseButtonCallback;
|
std::function<void(MouseButton, InputAction, KeyModifier)> mouseButtonCallback;
|
||||||
@@ -381,7 +385,6 @@ protected:
|
|||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkSwapchainKHR swapchain;
|
VkSwapchainKHR swapchain;
|
||||||
VkSampleCountFlags numSamples;
|
VkSampleCountFlags numSamples;
|
||||||
VkFormat pixelFormat;
|
|
||||||
VkPresentModeKHR presentMode;
|
VkPresentModeKHR presentMode;
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
VkSurfaceFormatKHR surfaceFormat;
|
VkSurfaceFormatKHR surfaceFormat;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "VulkanGraphicsEnums.h"
|
#include "VulkanGraphicsEnums.h"
|
||||||
#include "VulkanAllocator.h"
|
#include "VulkanAllocator.h"
|
||||||
#include "VulkanCommandBuffer.h"
|
#include "VulkanCommandBuffer.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
@@ -162,21 +161,21 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType,
|
|||||||
|
|
||||||
TextureHandle::~TextureHandle()
|
TextureHandle::~TextureHandle()
|
||||||
{
|
{
|
||||||
auto cmdBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
//auto cmdBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
||||||
VkDevice device = graphics->getDevice();
|
//VkDevice device = graphics->getDevice();
|
||||||
VkImageView view = defaultView;
|
//VkImageView view = defaultView;
|
||||||
VkImage img = image;
|
//VkImage img = image;
|
||||||
auto deletionLambda = [cmdBuffer, device, view, img]() -> Job
|
//vkDestroyImageView(device, view, nullptr);
|
||||||
{
|
//vkDestroyImage(device, img, nullptr);
|
||||||
//vkDestroyImageView(device, view, nullptr);
|
//co_return;
|
||||||
//vkDestroyImage(device, img, nullptr);
|
|
||||||
co_return;
|
|
||||||
};
|
|
||||||
deletionLambda();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureHandle* TextureBase::cast(Gfx::PTexture texture)
|
TextureHandle* TextureBase::cast(Gfx::PTexture texture)
|
||||||
{
|
{
|
||||||
|
if(texture == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if(texture->getTexture2D() != nullptr)
|
if(texture->getTexture2D() != nullptr)
|
||||||
{
|
{
|
||||||
PTexture2D texture2D = texture.cast<Texture2D>();
|
PTexture2D texture2D = texture.cast<Texture2D>();
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
|
|||||||
, instance(graphics->getInstance())
|
, instance(graphics->getInstance())
|
||||||
, swapchain(VK_NULL_HANDLE)
|
, swapchain(VK_NULL_HANDLE)
|
||||||
, numSamples(createInfo.numSamples)
|
, numSamples(createInfo.numSamples)
|
||||||
, pixelFormat(cast(createInfo.pixelFormat))
|
|
||||||
{
|
{
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
|
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
|
||||||
@@ -194,11 +193,7 @@ void Window::advanceBackBuffer()
|
|||||||
void Window::recreateSwapchain(const WindowCreateInfo &windowInfo)
|
void Window::recreateSwapchain(const WindowCreateInfo &windowInfo)
|
||||||
{
|
{
|
||||||
destroySwapchain();
|
destroySwapchain();
|
||||||
sizeX = windowInfo.width;
|
windowState = windowInfo;
|
||||||
sizeY = windowInfo.height;
|
|
||||||
pixelFormat = cast(windowInfo.pixelFormat);
|
|
||||||
bFullscreen = windowInfo.bFullscreen;
|
|
||||||
|
|
||||||
uint32_t numFormats;
|
uint32_t numFormats;
|
||||||
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, nullptr));
|
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, nullptr));
|
||||||
Array<VkSurfaceFormatKHR> formats(numFormats);
|
Array<VkSurfaceFormatKHR> formats(numFormats);
|
||||||
@@ -234,6 +229,10 @@ void Window::present()
|
|||||||
while (presentResult != VK_SUCCESS)
|
while (presentResult != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
presentResult = vkQueuePresentKHR(graphics->getGraphicsCommands()->getQueue()->getHandle(), &info);
|
presentResult = vkQueuePresentKHR(graphics->getGraphicsCommands()->getQueue()->getHandle(), &info);
|
||||||
|
if(presentResult == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
recreateSwapchain(windowState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Gfx::currentFrameIndex = (Gfx::currentFrameIndex + 1)%Gfx::numFramesBuffered;
|
Gfx::currentFrameIndex = (Gfx::currentFrameIndex + 1)%Gfx::numFramesBuffered;
|
||||||
static double lastFrameTime = 0.f;
|
static double lastFrameTime = 0.f;
|
||||||
@@ -259,8 +258,8 @@ void Window::createSwapchain()
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D extent;
|
VkExtent2D extent;
|
||||||
extent.width = sizeX;
|
extent.width = getSizeX();
|
||||||
extent.height = sizeY;
|
extent.height = getSizeY();
|
||||||
VkSwapchainCreateInfoKHR swapchainInfo =
|
VkSwapchainCreateInfoKHR swapchainInfo =
|
||||||
init::SwapchainCreateInfo(
|
init::SwapchainCreateInfo(
|
||||||
surface,
|
surface,
|
||||||
@@ -283,8 +282,8 @@ void Window::createSwapchain()
|
|||||||
|
|
||||||
|
|
||||||
TextureCreateInfo backBufferCreateInfo;
|
TextureCreateInfo backBufferCreateInfo;
|
||||||
backBufferCreateInfo.width = sizeX;
|
backBufferCreateInfo.width = getSizeX();
|
||||||
backBufferCreateInfo.height = sizeY;
|
backBufferCreateInfo.height = getSizeY();
|
||||||
backBufferCreateInfo.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
backBufferCreateInfo.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
backBufferCreateInfo.resourceData.owner = Gfx::QueueType::GRAPHICS;
|
backBufferCreateInfo.resourceData.owner = Gfx::QueueType::GRAPHICS;
|
||||||
backBufferCreateInfo.format = cast(surfaceFormat.format);
|
backBufferCreateInfo.format = cast(surfaceFormat.format);
|
||||||
|
|||||||
@@ -7,10 +7,11 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Gfx::ShaderMap MaterialAsset::shaderMap;
|
using namespace Seele;
|
||||||
|
|
||||||
|
Seele::Gfx::ShaderMap MaterialAsset::shaderMap;
|
||||||
std::mutex MaterialAsset::shaderMapLock;
|
std::mutex MaterialAsset::shaderMapLock;
|
||||||
|
|
||||||
using namespace Seele;
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|||||||
@@ -154,6 +154,10 @@ public:
|
|||||||
template <typename F>
|
template <typename F>
|
||||||
constexpr RefPtr(const RefPtr<F> &other)
|
constexpr RefPtr(const RefPtr<F> &other)
|
||||||
{
|
{
|
||||||
|
if(other == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
F *f = other.getObject()->getHandle();
|
F *f = other.getObject()->getHandle();
|
||||||
assert(static_cast<T *>(f));
|
assert(static_cast<T *>(f));
|
||||||
object = (RefObject<T, Deleter> *)other.getObject();
|
object = (RefObject<T, Deleter> *)other.getObject();
|
||||||
@@ -357,5 +361,3 @@ private:
|
|||||||
RefPtr<T> pointer;
|
RefPtr<T> pointer;
|
||||||
};
|
};
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|
||||||
using namespace Seele;
|
|
||||||
@@ -22,26 +22,24 @@ void Actor::launchStart()
|
|||||||
}
|
}
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
Array<Job> Actor::launchTick(float deltaTime) const
|
void Actor::launchTick(float deltaTime) const
|
||||||
{
|
{
|
||||||
Array<Job> result = rootComponent->launchTick(deltaTime);
|
rootComponent->launchTick(deltaTime);
|
||||||
for(auto child : children)
|
for(auto child : children)
|
||||||
{
|
{
|
||||||
result.addAll(child->launchTick(deltaTime));
|
child->launchTick(deltaTime);
|
||||||
}
|
}
|
||||||
result.add(tick(deltaTime));
|
tick(deltaTime);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<Job> Actor::launchUpdate()
|
void Actor::launchUpdate()
|
||||||
{
|
{
|
||||||
Array<Job> result = rootComponent->launchUpdate();
|
rootComponent->launchUpdate();
|
||||||
for(auto child : children)
|
for(auto child : children)
|
||||||
{
|
{
|
||||||
result.addAll(child->launchUpdate());
|
child->launchUpdate();
|
||||||
}
|
}
|
||||||
result.add(update());
|
update();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
void Actor::notifySceneAttach(PScene scene)
|
void Actor::notifySceneAttach(PScene scene)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Math/Transform.h"
|
#include "Math/Transform.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -15,10 +14,10 @@ public:
|
|||||||
virtual ~Actor();
|
virtual ~Actor();
|
||||||
virtual void launchStart();
|
virtual void launchStart();
|
||||||
virtual void start() {}
|
virtual void start() {}
|
||||||
Array<Job> launchTick(float deltaTime) const;
|
void launchTick(float deltaTime) const;
|
||||||
virtual Job tick(float) const { co_return; }
|
virtual void tick(float) const { }//co_return; }
|
||||||
Array<Job> launchUpdate();
|
void launchUpdate();
|
||||||
virtual Job update() { co_return; }
|
virtual void update() { }//co_return; }
|
||||||
void notifySceneAttach(PScene scene);
|
void notifySceneAttach(PScene scene);
|
||||||
PScene getScene();
|
PScene getScene();
|
||||||
|
|
||||||
|
|||||||
@@ -20,26 +20,22 @@ void Component::launchStart()
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<Job> Component::launchTick(float deltaTime) const
|
void Component::launchTick(float deltaTime) const
|
||||||
{
|
{
|
||||||
Array<Job> result;
|
|
||||||
for(auto child : children)
|
for(auto child : children)
|
||||||
{
|
{
|
||||||
result.addAll(child->launchTick(deltaTime));
|
child->launchTick(deltaTime);
|
||||||
}
|
}
|
||||||
result.add(tick(deltaTime));
|
tick(deltaTime);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<Job> Component::launchUpdate()
|
void Component::launchUpdate()
|
||||||
{
|
{
|
||||||
Array<Job> result;
|
|
||||||
for(auto child : children)
|
for(auto child : children)
|
||||||
{
|
{
|
||||||
result.addAll(child->launchUpdate());
|
child->launchUpdate();
|
||||||
}
|
}
|
||||||
result.add(update());
|
update();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PComponent Component::getParent()
|
PComponent Component::getParent()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "Math/Transform.h"
|
#include "Math/Transform.h"
|
||||||
#include "Scene/Util.h"
|
#include "Scene/Util.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -16,10 +15,10 @@ public:
|
|||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
void launchStart();
|
void launchStart();
|
||||||
virtual void start() {};
|
virtual void start() {};
|
||||||
Array<Job> launchTick(float deltaTime) const;
|
void launchTick(float deltaTime) const;
|
||||||
virtual Job tick(float) const { co_return; }
|
virtual void tick(float) const { }//co_return; }
|
||||||
Array<Job> launchUpdate();
|
void launchUpdate();
|
||||||
virtual Job update() { co_return; }
|
virtual void update() { }//co_return; }
|
||||||
PComponent getParent();
|
PComponent getParent();
|
||||||
PActor getOwner();
|
PActor getOwner();
|
||||||
const Array<PComponent>& getChildComponents();
|
const Array<PComponent>& getChildComponents();
|
||||||
|
|||||||
@@ -12,19 +12,19 @@ void MyComponent::start()
|
|||||||
otherComp.update();
|
otherComp.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Job MyComponent::tick(float) const
|
void MyComponent::tick(float) const
|
||||||
{
|
{
|
||||||
//std::cout << "MyComponent::tick" << std::endl;
|
//std::cout << "MyComponent::tick" << std::endl;
|
||||||
++writable;
|
++writable;
|
||||||
//std::cout << "MyComponent::tick finished" << std::endl;
|
//std::cout << "MyComponent::tick finished" << std::endl;
|
||||||
otherComp->data = *writable;
|
otherComp->data = *writable;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job MyComponent::update()
|
void MyComponent::update()
|
||||||
{
|
{
|
||||||
//std::cout << "MyComponent::update" << std::endl;
|
//std::cout << "MyComponent::update" << std::endl;
|
||||||
writable.update();
|
writable.update();
|
||||||
//std::cout << "MyComponent::update finished" << std::endl;
|
//std::cout << "MyComponent::update finished" << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ class MyComponent : public Component
|
|||||||
public:
|
public:
|
||||||
MyComponent();
|
MyComponent();
|
||||||
virtual void start();
|
virtual void start();
|
||||||
virtual Job tick(float deltatime) const;
|
virtual void tick(float deltatime) const;
|
||||||
virtual Job update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
Writable<PMyOtherComponent> otherComp;
|
Writable<PMyOtherComponent> otherComp;
|
||||||
Writable<uint32> writable = 0;
|
Writable<uint32> writable = 0;
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
Job MyOtherComponent::tick(float) const
|
void MyOtherComponent::tick(float) const
|
||||||
{
|
{
|
||||||
//std::cout << *data << std::endl;
|
//std::cout << *data << std::endl;
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job MyOtherComponent::update()
|
void MyOtherComponent::update()
|
||||||
{
|
{
|
||||||
data.update();
|
data.update();
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace Seele
|
|||||||
class MyOtherComponent : public Component
|
class MyOtherComponent : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Job tick(float deltaTime) const;
|
virtual void tick(float deltaTime) const;
|
||||||
virtual Job update();
|
virtual void update();
|
||||||
Writable<uint32> data = Writable<uint32>(0);
|
Writable<uint32> data = Writable<uint32>(0);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,37 +44,33 @@ void Scene::start()
|
|||||||
static int64 lastUpdate;
|
static int64 lastUpdate;
|
||||||
static uint64 numUpdates;
|
static uint64 numUpdates;
|
||||||
|
|
||||||
Job Scene::beginUpdate(double deltaTime)
|
void Scene::beginUpdate(double deltaTime)
|
||||||
{
|
{
|
||||||
//std::cout << "Scene::beginUpdate" << std::endl;
|
//std::cout << "Scene::beginUpdate" << std::endl;
|
||||||
auto startTime = std::chrono::high_resolution_clock::now();
|
auto startTime = std::chrono::high_resolution_clock::now();
|
||||||
//Array<Job> jobs;
|
|
||||||
for(auto actor : rootActors)
|
for(auto actor : rootActors)
|
||||||
{
|
{
|
||||||
co_await Job::all(actor->launchTick(static_cast<float>(deltaTime)));
|
actor->launchTick(static_cast<float>(deltaTime));
|
||||||
}
|
}
|
||||||
//co_await Job::all(std::move(jobs));
|
|
||||||
auto endTime = std::chrono::high_resolution_clock::now();
|
auto endTime = std::chrono::high_resolution_clock::now();
|
||||||
int64 delta = (endTime - startTime).count();
|
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
|
||||||
lastUpdate += delta;
|
lastUpdate += delta;
|
||||||
numUpdates++;
|
numUpdates++;
|
||||||
if(lastUpdate > 1000)
|
if(lastUpdate > 1000000)
|
||||||
{
|
{
|
||||||
lastUpdate -= 1000;
|
lastUpdate -= 1000000;
|
||||||
std::cout << numUpdates << " updates per second" << std::endl;
|
std::cout << numUpdates << " updates per second" << std::endl;
|
||||||
numUpdates = 0;
|
numUpdates = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Job Scene::commitUpdate()
|
void Scene::commitUpdate()
|
||||||
{
|
{
|
||||||
//std::cout << "Scene::commitUpdate" << std::endl;
|
//std::cout << "Scene::commitUpdate" << std::endl;
|
||||||
//std::vector<Job> jobs;
|
|
||||||
for(auto actor : rootActors)
|
for(auto actor : rootActors)
|
||||||
{
|
{
|
||||||
co_await Job::all(actor->launchUpdate());
|
actor->launchUpdate();
|
||||||
}
|
}
|
||||||
//co_await Job::all(std::move(jobs));
|
|
||||||
//std::cout << "Scene::commitUpdate finished waiting" << std::endl;
|
//std::cout << "Scene::commitUpdate finished waiting" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public:
|
|||||||
Scene(Gfx::PGraphics graphics);
|
Scene(Gfx::PGraphics graphics);
|
||||||
~Scene();
|
~Scene();
|
||||||
void start();
|
void start();
|
||||||
Job beginUpdate(double deltaTime);
|
void beginUpdate(double deltaTime);
|
||||||
Job commitUpdate();
|
void commitUpdate();
|
||||||
void addActor(PActor actor);
|
void addActor(PActor actor);
|
||||||
void addPrimitiveComponent(PPrimitiveComponent comp);
|
void addPrimitiveComponent(PPrimitiveComponent comp);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const View
|
|||||||
TextRender& render = textPassData.texts.add();
|
TextRender& render = textPassData.texts.add();
|
||||||
render.font = AssetRegistry::findFont("Calibri");
|
render.font = AssetRegistry::findFont("Calibri");
|
||||||
render.text = "Seele Engine";
|
render.text = "Seele Engine";
|
||||||
render.position = Vector2(0.5f, 0.5f);
|
render.position = Vector2(200.f, 300.f);
|
||||||
render.scale = 1.0f;
|
render.scale = 1.0f;
|
||||||
render.textColor = Vector4(1, 1, 1, 1);
|
render.textColor = Vector4(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,14 @@ InspectorView::~InspectorView()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Job InspectorView::beginUpdate()
|
void InspectorView::beginUpdate()
|
||||||
{
|
{
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job InspectorView::update()
|
void InspectorView::update()
|
||||||
{
|
{
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorView::commitUpdate()
|
void InspectorView::commitUpdate()
|
||||||
@@ -50,14 +50,14 @@ void InspectorView::prepareRender()
|
|||||||
textPass.updateViewFrame(textPassData);
|
textPass.updateViewFrame(textPassData);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob InspectorView::render()
|
void InspectorView::render()
|
||||||
{
|
{
|
||||||
return uiPass.beginFrame()
|
uiPass.beginFrame();
|
||||||
.then(textPass.beginFrame())
|
textPass.beginFrame();
|
||||||
.then(uiPass.render())
|
uiPass.render();
|
||||||
.then(textPass.render())
|
textPass.render();
|
||||||
.then(uiPass.endFrame())
|
uiPass.endFrame();
|
||||||
.then(textPass.endFrame());
|
textPass.endFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorView::keyCallback(KeyCode, InputAction, KeyModifier)
|
void InspectorView::keyCallback(KeyCode, InputAction, KeyModifier)
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ public:
|
|||||||
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||||
virtual ~InspectorView();
|
virtual ~InspectorView();
|
||||||
|
|
||||||
virtual Job beginUpdate() override;
|
virtual void beginUpdate() override;
|
||||||
virtual Job update() override;
|
virtual void update() override;
|
||||||
virtual void commitUpdate() override;
|
virtual void commitUpdate() override;
|
||||||
|
|
||||||
virtual void prepareRender() override;
|
virtual void prepareRender() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
void selectActor();
|
void selectActor();
|
||||||
protected:
|
protected:
|
||||||
UIPass uiPass;
|
UIPass uiPass;
|
||||||
|
|||||||
@@ -68,16 +68,16 @@ Seele::SceneView::~SceneView()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Job SceneView::beginUpdate()
|
void SceneView::beginUpdate()
|
||||||
{
|
{
|
||||||
co_await scene->beginUpdate(Gfx::currentFrameDelta);
|
scene->beginUpdate(Gfx::currentFrameDelta);
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job SceneView::update()
|
void SceneView::update()
|
||||||
{
|
{
|
||||||
co_await scene->commitUpdate();
|
scene->commitUpdate();
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneView::commitUpdate()
|
void SceneView::commitUpdate()
|
||||||
@@ -94,17 +94,17 @@ void SceneView::prepareRender()
|
|||||||
basePass.updateViewFrame(basePassData);
|
basePass.updateViewFrame(basePassData);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob SceneView::render()
|
void SceneView::render()
|
||||||
{
|
{
|
||||||
return depthPrepass.beginFrame()
|
depthPrepass.beginFrame();
|
||||||
.then(lightCullingPass.beginFrame())
|
lightCullingPass.beginFrame();
|
||||||
.then(basePass.beginFrame())
|
basePass.beginFrame();
|
||||||
.then(depthPrepass.render())
|
depthPrepass.render();
|
||||||
.then(lightCullingPass.render())
|
lightCullingPass.render();
|
||||||
.then(basePass.render())
|
basePass.render();
|
||||||
.then(depthPrepass.endFrame())
|
depthPrepass.endFrame();
|
||||||
.then(lightCullingPass.endFrame())
|
lightCullingPass.endFrame();
|
||||||
.then(basePass.endFrame());
|
basePass.endFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
static float cameraSpeed = 1;
|
static float cameraSpeed = 1;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ class SceneView : public View
|
|||||||
public:
|
public:
|
||||||
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
||||||
~SceneView();
|
~SceneView();
|
||||||
virtual Job beginUpdate() override;
|
virtual void beginUpdate() override;
|
||||||
virtual Job update() override;
|
virtual void update() override;
|
||||||
virtual void commitUpdate() override;
|
virtual void commitUpdate() override;
|
||||||
|
|
||||||
virtual void prepareRender() override;
|
virtual void prepareRender() override;
|
||||||
virtual MainJob render() override;
|
virtual void render() override;
|
||||||
|
|
||||||
PScene getScene() const { return scene; }
|
PScene getScene() const { return scene; }
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Graphics/RenderPass/RenderGraph.h"
|
#include "Graphics/RenderPass/RenderGraph.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -13,15 +12,15 @@ public:
|
|||||||
virtual ~View();
|
virtual ~View();
|
||||||
|
|
||||||
// These are called from the view thread, and handle updating game data
|
// These are called from the view thread, and handle updating game data
|
||||||
virtual Job beginUpdate() = 0;
|
virtual void beginUpdate() = 0;
|
||||||
virtual Job update() = 0;
|
virtual void update() = 0;
|
||||||
// End frame is called with a lock, so it is safe to write to shared memory
|
// End frame is called with a lock, so it is safe to write to shared memory
|
||||||
virtual void commitUpdate() = 0;
|
virtual void commitUpdate() = 0;
|
||||||
|
|
||||||
// These are called from the render thread
|
// These are called from the render thread
|
||||||
// prepare render is also locked, so reading from shared memory is also safe
|
// prepare render is also locked, so reading from shared memory is also safe
|
||||||
virtual void prepareRender() = 0;
|
virtual void prepareRender() = 0;
|
||||||
virtual MainJob render() = 0;
|
virtual void render() = 0;
|
||||||
void applyArea(URect area);
|
void applyArea(URect area);
|
||||||
void setFocused();
|
void setFocused();
|
||||||
|
|
||||||
|
|||||||
@@ -16,29 +16,32 @@ Window::~Window()
|
|||||||
|
|
||||||
void Window::addView(PView view)
|
void Window::addView(PView view)
|
||||||
{
|
{
|
||||||
WindowView* windowView = new WindowView(view);
|
//WindowView* windowView = new WindowView(view);
|
||||||
//windowView->worker = std::thread(&Window::viewWorker, this, windowView);
|
//windowView->worker = std::thread(&Window::viewWorker, this, windowView);
|
||||||
views.add(windowView);
|
views.add(view);
|
||||||
viewWorker(views.size() - 1);
|
//viewWorker(views.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainJob Window::render()
|
void Window::render()
|
||||||
{
|
{
|
||||||
gfxHandle->beginFrame();
|
while(owner->isActive())
|
||||||
for(auto& windowView : views)
|
|
||||||
{
|
{
|
||||||
|
gfxHandle->beginFrame();
|
||||||
|
for(auto& view : views)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(windowView->workerMutex);
|
view->beginUpdate();
|
||||||
windowView->view->prepareRender();
|
view->update();
|
||||||
|
view->commitUpdate();
|
||||||
|
view->prepareRender();
|
||||||
|
view->render();
|
||||||
|
}
|
||||||
|
gfxHandle->endFrame();
|
||||||
|
if(owner->isActive())
|
||||||
|
{
|
||||||
|
render();
|
||||||
}
|
}
|
||||||
co_await windowView->view->render();
|
|
||||||
}
|
}
|
||||||
gfxHandle->endFrame();
|
//co_return;
|
||||||
if(owner->isActive())
|
|
||||||
{
|
|
||||||
render();
|
|
||||||
}
|
|
||||||
co_return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::PWindow Window::getGfxHandle()
|
Gfx::PWindow Window::getGfxHandle()
|
||||||
@@ -63,7 +66,7 @@ void Window::setFocused(PView view)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Job Window::viewWorker(size_t viewIndex)
|
/*void Window::viewWorker(size_t viewIndex)
|
||||||
{
|
{
|
||||||
WindowView* windowView = views[viewIndex];
|
WindowView* windowView = views[viewIndex];
|
||||||
co_await windowView->view->beginUpdate();
|
co_await windowView->view->beginUpdate();
|
||||||
@@ -79,5 +82,5 @@ Job Window::viewWorker(size_t viewIndex)
|
|||||||
{
|
{
|
||||||
viewWorker(viewIndex);
|
viewWorker(viewIndex);
|
||||||
}
|
}
|
||||||
co_return;
|
//co_return;
|
||||||
}
|
}*/
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Graphics/GraphicsResources.h"
|
#include "Graphics/GraphicsResources.h"
|
||||||
#include "View.h"
|
#include "View.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
struct WindowView
|
/*struct WindowView
|
||||||
{
|
{
|
||||||
PView view;
|
PView view;
|
||||||
Event updateFinished;
|
Event updateFinished;
|
||||||
@@ -14,8 +13,8 @@ struct WindowView
|
|||||||
: view(view)
|
: view(view)
|
||||||
, updateFinished(view->getName())
|
, updateFinished(view->getName())
|
||||||
{}
|
{}
|
||||||
};
|
};*/
|
||||||
DEFINE_REF(WindowView)
|
//DEFINE_REF(WindowView)
|
||||||
DECLARE_REF(WindowManager)
|
DECLARE_REF(WindowManager)
|
||||||
// The logical window, with the graphics proxy
|
// The logical window, with the graphics proxy
|
||||||
class Window
|
class Window
|
||||||
@@ -24,16 +23,16 @@ public:
|
|||||||
Window(PWindowManager owner, Gfx::PWindow handle);
|
Window(PWindowManager owner, Gfx::PWindow handle);
|
||||||
~Window();
|
~Window();
|
||||||
void addView(PView view);
|
void addView(PView view);
|
||||||
MainJob render();
|
void render();
|
||||||
Gfx::PWindow getGfxHandle();
|
Gfx::PWindow getGfxHandle();
|
||||||
void setFocused(PView view);
|
void setFocused(PView view);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PWindowManager owner;
|
PWindowManager owner;
|
||||||
Array<WindowView*> views;
|
Array<PView> views;
|
||||||
Gfx::PWindow gfxHandle;
|
Gfx::PWindow gfxHandle;
|
||||||
|
|
||||||
Job viewWorker(size_t viewIndex);
|
//void viewWorker(size_t viewIndex);
|
||||||
};
|
};
|
||||||
DEFINE_REF(Window)
|
DEFINE_REF(Window)
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -36,7 +36,5 @@ int main()
|
|||||||
sceneView->setFocused();
|
sceneView->setFocused();
|
||||||
|
|
||||||
window->render();
|
window->render();
|
||||||
|
|
||||||
getGlobalThreadPool().mainLoop();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+10
-3
@@ -1,12 +1,19 @@
|
|||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
|
||||||
|
|
||||||
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
|
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
|
||||||
|
find_package(Aftermath REQUIRED)
|
||||||
include_directories(${ENGINE_ROOT})
|
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
add_subdirectory(Engine/)
|
add_subdirectory(Engine/)
|
||||||
|
|
||||||
|
target_include_directories(Seele_unit_tests PRIVATE ${ENGINE_ROOT})
|
||||||
|
target_include_directories(Seele_unit_tests PRIVATE ${Boost_INCLUDE_DIRS})
|
||||||
|
target_include_directories(Seele_unit_tests PRIVATE ${GLM_INCLUDE_DIRS})
|
||||||
|
target_include_directories(Seele_unit_tests PRIVATE ${Vulkan_INCLUDE_DIR})
|
||||||
|
target_include_directories(Seele_unit_tests PRIVATE ${NSAM_INCLUDE_DIRS})
|
||||||
|
|
||||||
target_link_libraries(Seele_unit_tests ${Boost_LIBRARIES})
|
target_link_libraries(Seele_unit_tests ${Boost_LIBRARIES})
|
||||||
|
target_link_libraries(Seele_unit_tests ${Vulkan_LIBRARY})
|
||||||
|
target_link_libraries(Seele_unit_tests ${NSAM_LIBRARIES})
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_compile_definitions(Seele_unit_tests PRIVATE -DBOOST_TEST_DYN_LINK)
|
target_compile_definitions(Seele_unit_tests PRIVATE -DBOOST_TEST_DYN_LINK)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ target_sources(Seele_unit_tests
|
|||||||
../../src/Engine/MinimalEngine.cpp
|
../../src/Engine/MinimalEngine.cpp
|
||||||
../../src/Engine/ThreadPool.cpp
|
../../src/Engine/ThreadPool.cpp
|
||||||
EngineTest.h
|
EngineTest.h
|
||||||
EngineTest.cpp
|
EngineTest.cpp)
|
||||||
ThreadPool.cpp)
|
#ThreadPool.cpp)
|
||||||
target_include_directories(Seele_unit_tests PUBLIC ./)
|
target_include_directories(Seele_unit_tests PUBLIC ./)
|
||||||
add_subdirectory(Containers/)
|
add_subdirectory(Containers/)
|
||||||
add_subdirectory(Graphics/)
|
add_subdirectory(Graphics/)
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ BOOST_AUTO_TEST_CASE(remove_keeporder)
|
|||||||
BOOST_CHECK_EQUAL(array.size(), 4);
|
BOOST_CHECK_EQUAL(array.size(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(find)
|
||||||
|
{
|
||||||
|
Array<uint8> array;
|
||||||
|
for(uint32 i = 0; i < 100; ++i)
|
||||||
|
{
|
||||||
|
array.add(i);
|
||||||
|
}
|
||||||
|
auto it = array.find([](uint8 elem){ return elem / 9 == 9; });
|
||||||
|
BOOST_CHECK_EQUAL(*it, 81);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(remove_swap)
|
BOOST_AUTO_TEST_CASE(remove_swap)
|
||||||
{
|
{
|
||||||
Array<uint8> array;
|
Array<uint8> array;
|
||||||
@@ -65,7 +76,7 @@ BOOST_AUTO_TEST_CASE(remove_swap)
|
|||||||
array.add(3);
|
array.add(3);
|
||||||
array.add(4);
|
array.add(4);
|
||||||
array.add(5);
|
array.add(5);
|
||||||
array.remove(1, false);
|
array.removeAt(1, false);
|
||||||
BOOST_CHECK_EQUAL(array[1], 5);
|
BOOST_CHECK_EQUAL(array[1], 5);
|
||||||
BOOST_CHECK_EQUAL(array[2], 3);
|
BOOST_CHECK_EQUAL(array[2], 3);
|
||||||
BOOST_CHECK_EQUAL(array[3], 4);
|
BOOST_CHECK_EQUAL(array[3], 4);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "EngineTest.h"
|
#include "EngineTest.h"
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
#include "ThreadPool.h"
|
|
||||||
#define BOOST_TEST_MODULE SeeleEngine
|
#define BOOST_TEST_MODULE SeeleEngine
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
//#include <vld.h>
|
//#include <vld.h>
|
||||||
@@ -9,7 +8,7 @@ using namespace Seele;
|
|||||||
|
|
||||||
Seele::GlobalFixture::~GlobalFixture()
|
Seele::GlobalFixture::~GlobalFixture()
|
||||||
{
|
{
|
||||||
getGlobalThreadPool().waitIdle();
|
//getGlobalThreadPool().waitIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST_GLOBAL_FIXTURE(GlobalFixture);
|
BOOST_TEST_GLOBAL_FIXTURE(GlobalFixture);
|
||||||
|
|||||||
Reference in New Issue
Block a user