Light Culling still doesn't work properly
This commit is contained in:
Vendored
+3
-3
@@ -8,7 +8,7 @@
|
||||
"name": "Engine Debug (Linux)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/Debug/SeeleEngine",
|
||||
"program": "${workspaceRoot}/bin/Debug/Engine",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/bin/Debug",
|
||||
@@ -27,7 +27,7 @@
|
||||
"name": "Engine Debug",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/Debug/SeeleEngine.exe",
|
||||
"program": "${workspaceRoot}/bin/Debug/Engine.exe",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/bin/Debug",
|
||||
@@ -47,7 +47,7 @@
|
||||
"name": "Engine Release",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/Release/SeeleEngine.exe",
|
||||
"program": "${workspaceRoot}/bin/Release/Engine.exe",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/bin/Release",
|
||||
|
||||
Vendored
+1
@@ -134,5 +134,6 @@
|
||||
},
|
||||
"git.ignoreSubmodules": true,
|
||||
"cmake.configureOnOpen": true,
|
||||
"cmake.parallelJobs": 0,
|
||||
"C_Cpp.intelliSenseEngineFallback": "Enabled"
|
||||
}
|
||||
+23
-23
@@ -77,19 +77,19 @@ if(CMAKE_DEBUG_POSTFIX)
|
||||
add_compile_definitions(ENABLE_VALIDATION)
|
||||
add_compile_definitions(SEELE_DEBUG)
|
||||
endif()
|
||||
add_executable(SeeleEngine "")
|
||||
target_link_libraries(SeeleEngine ${Vulkan_LIBRARY})
|
||||
target_link_libraries(SeeleEngine ${Boost_LIBRARIES})
|
||||
target_link_libraries(SeeleEngine ${GLFW_LIBRARIES})
|
||||
target_link_libraries(SeeleEngine ${SLANG_LIBRARIES})
|
||||
target_link_libraries(SeeleEngine ${ASSIMP_LIBRARIES})
|
||||
target_link_libraries(SeeleEngine ${NSAM_LIBRARIES})
|
||||
target_link_libraries(SeeleEngine ${KTX_LIBRARIES})
|
||||
add_executable(Engine "")
|
||||
target_link_libraries(Engine ${Vulkan_LIBRARY})
|
||||
target_link_libraries(Engine ${Boost_LIBRARIES})
|
||||
target_link_libraries(Engine ${GLFW_LIBRARIES})
|
||||
target_link_libraries(Engine ${SLANG_LIBRARIES})
|
||||
target_link_libraries(Engine ${ASSIMP_LIBRARIES})
|
||||
target_link_libraries(Engine ${NSAM_LIBRARIES})
|
||||
target_link_libraries(Engine ${KTX_LIBRARIES})
|
||||
if(UNIX)
|
||||
target_link_libraries(SeeleEngine Threads::Threads)
|
||||
target_link_libraries(SeeleEngine dl)
|
||||
target_link_libraries(Engine Threads::Threads)
|
||||
target_link_libraries(Engine dl)
|
||||
endif()
|
||||
target_precompile_headers(SeeleEngine
|
||||
target_precompile_headers(Engine
|
||||
PRIVATE
|
||||
<assert.h>
|
||||
<atomic>
|
||||
@@ -111,9 +111,9 @@ add_subdirectory(src/)
|
||||
|
||||
if(MSVC)
|
||||
set(_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_options(SeeleEngine PRIVATE /Zi)
|
||||
target_compile_options(Engine PRIVATE /Zi /MP)
|
||||
else()
|
||||
target_compile_options(SeeleEngine PRIVATE -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
||||
target_compile_options(Engine PRIVATE -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
||||
endif()
|
||||
|
||||
add_executable(Seele_unit_tests "")
|
||||
@@ -121,19 +121,19 @@ add_subdirectory(test/)
|
||||
|
||||
if(WIN32)
|
||||
add_custom_target(copy-binaries ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_GLSLANG} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASSIMP_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_LLVM} $<TARGET_FILE_DIR:SeeleEngine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${KTX_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARIES} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_GLSLANG} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_BINARY} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASSIMP_BINARY} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_BINARIES} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_LLVM} $<TARGET_FILE_DIR:Engine>
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${KTX_BINARIES} $<TARGET_FILE_DIR:Engine>)
|
||||
else()
|
||||
add_custom_target(copy-binaries ALL COMMAND "")
|
||||
endif()
|
||||
|
||||
add_custom_target(copy-runtime-files ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:SeeleEngine>
|
||||
DEPENDS SeeleEngine copy-binaries)
|
||||
add_custom_target(SeeleEngine ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:Engine>
|
||||
DEPENDS Engine copy-binaries)
|
||||
|
||||
|
||||
+23
-2
@@ -23,21 +23,42 @@
|
||||
</LinkedListItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="Seele::Pair<*,*>">
|
||||
<DisplayString>[{key}, {value}]</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[key]">key</Item>
|
||||
<Item Name="[value]">value</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="Seele::Map<*>">
|
||||
<DisplayString>{{size={_size}}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[size]">_size</Item>
|
||||
<Item Name="[comp]">comp</Item>
|
||||
<ArrayItems>
|
||||
<Size>nodeContainer.arraySize</Size>
|
||||
<Size>_size</Size>
|
||||
<ValuePointer>nodeContainer._data</ValuePointer>
|
||||
</ArrayItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="Seele::Map<*>::IteratorBase<*>">
|
||||
<DisplayString Condition="nodeContainer.arraySize==0">empty</DisplayString>
|
||||
<DisplayString>[{nodeContainer._data[node].pair}]</DisplayString>
|
||||
<Expand>
|
||||
<ExpandedItem>nodeContainer._data[node].pair</ExpandedItem>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="Seele::RefPtr<*>">
|
||||
<DisplayString>RefPtr {*object->handle} {object->refCount.load()} references</DisplayString>
|
||||
<DisplayString Condition="object == nullptr">empty</DisplayString>
|
||||
<DisplayString>RefPtr {*object->handle} {object->refCount} references</DisplayString>
|
||||
<Expand>
|
||||
<ExpandedItem>object->handle</ExpandedItem>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="Seele::UniquePtr<*>">
|
||||
<DisplayString>UniquePtr {*handle}</DisplayString>
|
||||
<Expand>
|
||||
<ExpandedItem>handle</ExpandedItem>
|
||||
</Expand>
|
||||
</Type>
|
||||
</AutoVisualizer>
|
||||
|
||||
@@ -23,19 +23,26 @@ layout(set = INDEX_VIEW_PARAMS, binding = 3)
|
||||
StructuredBuffer<Frustum> frustums;
|
||||
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 4)
|
||||
RWStructuredBuffer<uint> oLightIndexCounter;
|
||||
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 5)
|
||||
RWStructuredBuffer<uint> tLightIndexCounter;
|
||||
globallycoherent RWStructuredBuffer<uint> tLightIndexCounter;
|
||||
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 6)
|
||||
RWStructuredBuffer<uint> oLightIndexList;
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 7)
|
||||
RWStructuredBuffer<uint> tLightIndexList;
|
||||
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 8)
|
||||
RWTexture2D<uint2> oLightGrid;
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 9)
|
||||
RWTexture2D<uint2> tLightGrid;
|
||||
|
||||
// Debug
|
||||
//layout(set = INDEX_VIEW_PARAMS, binding = 10)
|
||||
//Texture2D lightCountHeatMap;
|
||||
//layout(set = INDEX_VIEW_PARAMS, binding = 11)
|
||||
//RWTexture2D<float4> debugTexture;
|
||||
|
||||
groupshared uint uMinDepth;
|
||||
groupshared uint uMaxDepth;
|
||||
|
||||
@@ -74,8 +81,8 @@ void tAppendLight(uint lightIndex)
|
||||
[shader("compute")]
|
||||
void cullLights(ComputeShaderInput in)
|
||||
{
|
||||
int3 texCoord = int3(in.dispatchThreadID.xy, 0);
|
||||
float fDepth = depthTextureVS.Load(texCoord).r;
|
||||
int2 texCoord = in.dispatchThreadID.xy;
|
||||
float fDepth = depthTextureVS.Load(int3(texCoord, 0)).r;
|
||||
|
||||
uint uDepth = asuint(fDepth);
|
||||
if(in.groupIndex == 0)
|
||||
@@ -88,6 +95,7 @@ void cullLights(ComputeShaderInput in)
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
InterlockedMin(uMinDepth, uDepth);
|
||||
InterlockedMax(uMaxDepth, uDepth);
|
||||
|
||||
@@ -120,22 +128,24 @@ void cullLights(ComputeShaderInput in)
|
||||
|
||||
if(in.groupIndex == 0)
|
||||
{
|
||||
InterlockedAdd(oLightIndexCounter[0], (uint)oLightCount, oLightIndexStartOffset);
|
||||
InterlockedAdd(oLightIndexCounter[0], oLightCount, oLightIndexStartOffset);
|
||||
oLightGrid[in.groupID.xy] = uint2(oLightIndexStartOffset, oLightCount);
|
||||
|
||||
InterlockedAdd(tLightIndexCounter[0], (uint)tLightCount, tLightIndexStartOffset);
|
||||
InterlockedAdd(tLightIndexCounter[0], tLightCount, tLightIndexStartOffset);
|
||||
tLightGrid[in.groupID.xy] = uint2(tLightIndexStartOffset, tLightCount);
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
for (uint j = in.groupIndex; j < (uint)oLightCount; j += BLOCK_SIZE * BLOCK_SIZE)
|
||||
for (uint j = in.groupIndex; j < oLightCount; j += BLOCK_SIZE * BLOCK_SIZE)
|
||||
{
|
||||
oLightIndexList[oLightIndexStartOffset + j] = oLightList[j];
|
||||
}
|
||||
|
||||
// For transparent geometry.
|
||||
for ( uint k = in.groupIndex; k < (uint)tLightCount; k += BLOCK_SIZE * BLOCK_SIZE )
|
||||
for ( uint k = in.groupIndex; k < tLightCount; k += BLOCK_SIZE * BLOCK_SIZE )
|
||||
{
|
||||
tLightIndexList[tLightIndexStartOffset + k] = tLightList[k];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const static float PI = 3.1415926535897932f;
|
||||
const static uint MAX_PARTICLES = 65536;
|
||||
const static uint BLOCK_SIZE = 8;
|
||||
const static uint BLOCK_SIZE = 32;
|
||||
|
||||
struct ViewParameter
|
||||
{
|
||||
float4x4 viewMatrix;
|
||||
float4x4 projectionMatrix;
|
||||
float4x4 inverseProjection;
|
||||
float4x4 inverseProjection;
|
||||
float4 cameraPos_WS;
|
||||
float2 screenDimensions;
|
||||
float2 screenDimensions;
|
||||
}
|
||||
layout(set = INDEX_VIEW_PARAMS, binding = 0, std430)
|
||||
ConstantBuffer<ViewParameter> gViewParams;
|
||||
@@ -31,37 +31,31 @@ float4 screenToView( float4 screen )
|
||||
float2 texCoord = screen.xy / gViewParams.screenDimensions;
|
||||
|
||||
// Convert to clip space
|
||||
float4 clip = float4( float2( texCoord.x, -texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
|
||||
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
|
||||
|
||||
return clipToView( clip );
|
||||
}
|
||||
|
||||
struct Plane
|
||||
{
|
||||
float3 n;
|
||||
float d;
|
||||
float3 p0;
|
||||
float3 p1;
|
||||
float3 p2;
|
||||
float3 n;
|
||||
float d;
|
||||
};
|
||||
|
||||
struct Frustum
|
||||
{
|
||||
Plane planes[4];
|
||||
Plane planes[4];
|
||||
};
|
||||
Plane computePlane(float3 p0, float3 p1, float3 p2)
|
||||
{
|
||||
Plane plane;
|
||||
Plane plane;
|
||||
|
||||
float3 v0 = p2 - p0;
|
||||
float3 v2 = p1 - p0;
|
||||
float3 v0 = p1 - p0;
|
||||
float3 v2 = p2 - p0;
|
||||
|
||||
plane.n = normalize(cross(v0, v2));
|
||||
plane.n = normalize(cross(v0, v2));
|
||||
|
||||
plane.d = dot(plane.n, p0);
|
||||
plane.p0 = p0;
|
||||
plane.p1 = p1;
|
||||
plane.p2 = p2;
|
||||
plane.d = dot(plane.n, p0);
|
||||
|
||||
return plane;
|
||||
return plane;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ struct DirectionalLight : ILightEnv
|
||||
struct PointLight : ILightEnv
|
||||
{
|
||||
float4 positionWS;
|
||||
float4 positionVS;
|
||||
float4 colorRange;
|
||||
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf, float3 viewDir)
|
||||
@@ -36,14 +35,14 @@ struct PointLight : ILightEnv
|
||||
|
||||
bool insidePlane(Plane plane)
|
||||
{
|
||||
return dot(plane.n, positionVS.xyz) - plane.d < -colorRange.w;
|
||||
return dot(plane.n, getViewPos().xyz) - plane.d < -colorRange.w;
|
||||
}
|
||||
|
||||
bool insideFrustum(Frustum frustum, float zNear, float zFar)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if(positionVS.z - colorRange.w > zNear || positionVS.z + colorRange.w < zFar)
|
||||
if(getViewPos().z - colorRange.w > zNear || getViewPos().z + colorRange.w < zFar)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -56,6 +55,10 @@ struct PointLight : ILightEnv
|
||||
}
|
||||
return result;
|
||||
}
|
||||
float3 getViewPos()
|
||||
{
|
||||
return mul(gViewParams.viewMatrix, positionWS).xyz;
|
||||
}
|
||||
};
|
||||
|
||||
layout(set = INDEX_LIGHT_ENV, binding = 0, std430)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Asset.h
|
||||
Asset.cpp
|
||||
|
||||
@@ -27,12 +27,12 @@ void MaterialLoader::importAsset(const std::filesystem::path& name)
|
||||
import(name, asset);
|
||||
}
|
||||
|
||||
Job MaterialLoader::import(std::filesystem::path, PMaterialAsset asset)
|
||||
void MaterialLoader::import(std::filesystem::path, PMaterialAsset asset)
|
||||
{
|
||||
asset->load();
|
||||
graphics->getShaderCompiler()->registerMaterial(asset);
|
||||
AssetRegistry::get().registerMaterial(asset);
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
|
||||
PMaterialAsset MaterialLoader::getPlaceHolderMaterial()
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void importAsset(const std::filesystem::path& name);
|
||||
PMaterialAsset getPlaceHolderMaterial();
|
||||
private:
|
||||
Job import(std::filesystem::path filePath, PMaterialAsset asset);
|
||||
void import(std::filesystem::path filePath, PMaterialAsset asset);
|
||||
Gfx::PGraphics graphics;
|
||||
List<std::future<void>> futures;
|
||||
PMaterialAsset placeholderMaterial;
|
||||
|
||||
@@ -38,7 +38,7 @@ PTextureAsset TextureLoader::getPlaceholderTexture()
|
||||
return placeholderAsset;
|
||||
}
|
||||
|
||||
Job TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsset)
|
||||
void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsset)
|
||||
{
|
||||
int x, y, n;
|
||||
unsigned char* data = stbi_load(path.string().c_str(), &x, &y, &n, 4);
|
||||
@@ -70,5 +70,5 @@ Job TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsset
|
||||
|
||||
textureAsset->load();
|
||||
textureAsset->setStatus(Asset::Status::Ready);
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
void importAsset(const std::filesystem::path& filePath);
|
||||
PTextureAsset getPlaceholderTexture();
|
||||
private:
|
||||
Job import(std::filesystem::path path, PTextureAsset asset);
|
||||
void import(std::filesystem::path path, PTextureAsset asset);
|
||||
Gfx::PGraphics graphics;
|
||||
List<std::future<void>> futures;
|
||||
PTextureAsset placeholderAsset;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
EngineTypes.h
|
||||
MinimalEngine.h
|
||||
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
{
|
||||
remove(it - beginIt, keepOrder);
|
||||
}
|
||||
constexpr void remove(int index, bool keepOrder = true)
|
||||
constexpr void remove(size_type index, bool keepOrder = true)
|
||||
{
|
||||
if (keepOrder)
|
||||
{
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
{
|
||||
_data[index] = std::move(_data[arraySize - 1]);
|
||||
}
|
||||
arraySize--;
|
||||
std::allocator_traits<allocator_type>::destroy(allocator, &_data[--arraySize]);
|
||||
markIteratorDirty();
|
||||
}
|
||||
constexpr void resize(size_type newSize)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Array.h
|
||||
Map.h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
GraphicsResources.h
|
||||
GraphicsResources.cpp
|
||||
|
||||
@@ -134,6 +134,7 @@ MainJob BasePass::beginFrame()
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||
//std::cout << "BasePass beginFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -163,11 +164,13 @@ MainJob BasePass::render()
|
||||
//co_await Job::all(jobs);
|
||||
graphics->executeCommands(processor->getRenderCommands());
|
||||
graphics->endRenderPass();
|
||||
//std::cout << "BasePass render()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
MainJob BasePass::endFrame()
|
||||
{
|
||||
//std::cout << "BasePass endFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
BasePass.h
|
||||
BasePass.cpp
|
||||
|
||||
@@ -115,6 +115,7 @@ MainJob DepthPrepass::beginFrame()
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||
//std::cout << "DepthPrepass beginFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -134,11 +135,13 @@ MainJob DepthPrepass::render()
|
||||
//co_await Job::all(jobs);
|
||||
graphics->executeCommands(processor->getRenderCommands());
|
||||
graphics->endRenderPass();
|
||||
//std::cout << "DepthPrepass render()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
MainJob DepthPrepass::endFrame()
|
||||
{
|
||||
//std::cout << "DepthPrepass endFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ MainJob LightCullingPass::beginFrame()
|
||||
lightEnvDescriptorSet->updateBuffer(2, pointLightBuffer);
|
||||
lightEnvDescriptorSet->updateBuffer(3, numPointLightBuffer);
|
||||
lightEnvDescriptorSet->writeChanges();
|
||||
//std::cout << "Finished light culling beginFrame()" << std::endl;
|
||||
//std::cout << "LightCulling beginFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -103,11 +103,13 @@ MainJob LightCullingPass::render()
|
||||
graphics->executeCommands(commands);
|
||||
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
//std::cout << "LightCulling render()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
MainJob LightCullingPass::endFrame()
|
||||
{
|
||||
//std::cout << "LightCulling endFrame()" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
||||
private:
|
||||
void setupFrustums();
|
||||
static constexpr uint32 BLOCK_SIZE = 8;
|
||||
static constexpr uint32 BLOCK_SIZE = 32;
|
||||
static constexpr uint32 INDEX_LIGHT_ENV = 1;
|
||||
struct DispatchParams
|
||||
{
|
||||
@@ -39,9 +39,6 @@ private:
|
||||
{
|
||||
Vector n;
|
||||
float d;
|
||||
Vector p0;
|
||||
Vector p1;
|
||||
Vector p2;
|
||||
};
|
||||
struct Frustum
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
NsightAftermathGpuCrashTracker.h
|
||||
NsightAftermathGpuCrashTracker.cpp
|
||||
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
private:
|
||||
enum
|
||||
{
|
||||
MemoryBlockSize = 64 * 1024 * 1024 // 64MB
|
||||
MemoryBlockSize = 16 * 1024 * 1024 // 16MB
|
||||
};
|
||||
struct HeapInfo
|
||||
{
|
||||
|
||||
@@ -332,7 +332,7 @@ PCommandBufferManager Graphics::getTransferCommands()
|
||||
}
|
||||
PCommandBufferManager Graphics::getDedicatedTransferCommands()
|
||||
{
|
||||
if(dedicatedTransferCommands == dedicatedTransferCommands)
|
||||
if(dedicatedTransferCommands == nullptr)
|
||||
{
|
||||
dedicatedTransferCommands = new CommandBufferManager(this, dedicatedTransferQueue);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
BRDF.h
|
||||
BRDF.cpp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Math.h
|
||||
Matrix.h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Actor.cpp
|
||||
Actor.h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Util.h
|
||||
Scene.cpp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
CameraComponent.h
|
||||
CameraComponent.cpp
|
||||
|
||||
@@ -4,7 +4,7 @@ using namespace Seele;
|
||||
|
||||
Job MyOtherComponent::tick(float deltaTime) const
|
||||
{
|
||||
std::cout << *data << std::endl;
|
||||
//std::cout << *data << std::endl;
|
||||
co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ Scene::Scene(Gfx::PGraphics graphics)
|
||||
lightEnv.directionalLights[0].intensity = Vector4(1, 1, 1, 1);
|
||||
lightEnv.numDirectionalLights = 1;
|
||||
srand((unsigned int)time(NULL));
|
||||
for(uint32 i = 0; i < 16; ++i)
|
||||
for(uint32 i = 0; i < 256; ++i)
|
||||
{
|
||||
lightEnv.pointLights[i].colorRange = Vector4(frand(), frand(), frand(), frand() * 30);
|
||||
lightEnv.pointLights[i].colorRange = Vector4(frand(), frand(), frand(), frand() * 300);
|
||||
lightEnv.pointLights[i].positionWS = Vector4(frand() * 100-50, frand(), frand() * 100-50, 1);
|
||||
}
|
||||
lightEnv.numPointLights = 16;
|
||||
lightEnv.pointLights[0].colorRange = Vector4(1, 1, 1, 1000);
|
||||
lightEnv.numPointLights = 256;
|
||||
lightEnv.pointLights[0].colorRange = Vector4(1, 0, 1, 1000);
|
||||
lightEnv.pointLights[0].positionWS = Vector4(0, 10, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ struct DirectionalLight
|
||||
struct PointLight
|
||||
{
|
||||
Vector4 positionWS;
|
||||
Vector4 positionVS;
|
||||
Vector4 colorRange;
|
||||
};
|
||||
|
||||
@@ -46,7 +45,7 @@ public:
|
||||
|
||||
const std::vector<PPrimitiveComponent>& getPrimitives() const { return primitives; }
|
||||
const std::vector<StaticMeshBatch>& getStaticMeshes() const { return staticMeshes; }
|
||||
const LightEnv& getLightBuffer() const { return lightEnv; }
|
||||
LightEnv& getLightBuffer() { return lightEnv; }
|
||||
private:
|
||||
std::vector<StaticMeshBatch> staticMeshes;
|
||||
std::vector<PActor> rootActors;
|
||||
|
||||
+10
-13
@@ -4,6 +4,7 @@
|
||||
#include "MinimalEngine.h"
|
||||
#include "Containers/List.h"
|
||||
#include "Concepts.h"
|
||||
#include <source_location>
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
@@ -66,11 +67,11 @@ struct JobPromiseBase
|
||||
EXECUTING,
|
||||
DONE
|
||||
};
|
||||
JobPromiseBase()
|
||||
JobPromiseBase(const std::source_location& location = std::source_location::current())
|
||||
{
|
||||
handle = std::coroutine_handle<JobPromiseBase<MainJob>>::from_promise(*this);
|
||||
id = globalCounter++;
|
||||
finishedEvent = Event(std::format("Job {}", id));
|
||||
finishedEvent = Event(std::string(location.file_name()).append(": ").append(location.function_name()));
|
||||
}
|
||||
~JobPromiseBase()
|
||||
{}
|
||||
@@ -101,6 +102,7 @@ struct JobPromiseBase
|
||||
finishedEvent.raise();
|
||||
if(continuation)
|
||||
{
|
||||
std::scoped_lock lock(continuation->promiseLock);
|
||||
getGlobalThreadPool().scheduleJob(continuation);
|
||||
continuation->removeRef();
|
||||
}
|
||||
@@ -108,6 +110,7 @@ struct JobPromiseBase
|
||||
void setContinuation(JobPromiseBase* cont)
|
||||
{
|
||||
std::scoped_lock lock(promiseLock, cont->promiseLock);
|
||||
assert(cont->ready());
|
||||
continuation = cont;
|
||||
cont->state = State::SCHEDULED;
|
||||
cont->addRef();
|
||||
@@ -148,12 +151,12 @@ struct JobPromiseBase
|
||||
}
|
||||
void schedule()
|
||||
{
|
||||
//dont lock here, as it is already locked from outside
|
||||
std::scoped_lock lock(promiseLock);
|
||||
if(!handle || done() || !ready())
|
||||
{
|
||||
return;
|
||||
}
|
||||
state = State::SCHEDULED;
|
||||
getGlobalThreadPool().scheduleJob(this);
|
||||
}
|
||||
void addRef()
|
||||
@@ -243,6 +246,7 @@ public:
|
||||
JobBase&& then(JobBase&& continuation)
|
||||
{
|
||||
promise->setContinuation(continuation.promise);
|
||||
promise->schedule();
|
||||
return std::move(continuation);
|
||||
}
|
||||
bool done()
|
||||
@@ -253,19 +257,12 @@ public:
|
||||
{
|
||||
promise->finalize();
|
||||
}
|
||||
Event operator co_await()
|
||||
Event operator co_await() const
|
||||
{
|
||||
Event result = promise->finishedEvent;
|
||||
// if we schedule the promise now, it might finish and self destruct
|
||||
// but there is no way for us to know that
|
||||
// but as the co_await operator keeps a reference to this, we it won't
|
||||
// the co_await operator keeps a reference to this, we it won't
|
||||
// be scheduled from the destructor
|
||||
promise->schedule();
|
||||
// so we reset the promise so we don't schedule it when this destructs
|
||||
promise->removeRef();
|
||||
promise = nullptr;
|
||||
// but we still have to provide with the event, so we get that first
|
||||
return result;
|
||||
return promise->finishedEvent;
|
||||
}
|
||||
static JobBase all() = delete;
|
||||
template<iterable Iterable>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
HorizontalLayout.h
|
||||
HorizontalLayout.cpp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
Element.h
|
||||
Element.cpp)
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(SeeleEngine
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
InspectorView.h
|
||||
InspectorView.cpp
|
||||
|
||||
@@ -41,11 +41,9 @@ void InspectorView::prepareRender()
|
||||
|
||||
MainJob InspectorView::render()
|
||||
{
|
||||
co_await uiPass.beginFrame();
|
||||
co_await uiPass.render();
|
||||
co_await uiPass.endFrame();
|
||||
renderFinishedEvent.raise();
|
||||
co_return;
|
||||
return uiPass.beginFrame()
|
||||
.then(uiPass.render())
|
||||
.then(uiPass.endFrame());
|
||||
}
|
||||
|
||||
void InspectorView::keyCallback(KeyCode, InputAction, KeyModifier)
|
||||
|
||||
@@ -34,7 +34,7 @@ Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const Viewpo
|
||||
PPrimitiveComponent ayaka = new PrimitiveComponent(AssetRegistry::findMesh("Ayaka"));
|
||||
ayaka->addWorldTranslation(Vector(0, 0, 0));
|
||||
ayaka->setWorldScale(Vector(10, 10, 10));
|
||||
scene->addPrimitiveComponent(ayaka);
|
||||
//scene->addPrimitiveComponent(ayaka);
|
||||
|
||||
PPrimitiveComponent plane = new PrimitiveComponent(AssetRegistry::findMesh("plane"));
|
||||
plane->setWorldScale(Vector(100, 100, 100));
|
||||
@@ -97,17 +97,19 @@ void SceneView::prepareRender()
|
||||
|
||||
MainJob SceneView::render()
|
||||
{
|
||||
co_await depthPrepass.beginFrame();
|
||||
co_await lightCullingPass.beginFrame();
|
||||
co_await basePass.beginFrame();
|
||||
co_await depthPrepass.render();
|
||||
co_await lightCullingPass.render();
|
||||
co_await basePass.render();
|
||||
co_await depthPrepass.endFrame();
|
||||
co_await lightCullingPass.endFrame();
|
||||
co_await basePass.endFrame();
|
||||
renderFinishedEvent.raise();
|
||||
co_return;
|
||||
return MainJob::all(
|
||||
depthPrepass.beginFrame(),
|
||||
lightCullingPass.beginFrame(),
|
||||
basePass.beginFrame())
|
||||
.then(depthPrepass.render())
|
||||
.then(lightCullingPass.render())
|
||||
.then(basePass.render())
|
||||
.then(
|
||||
MainJob::all(
|
||||
depthPrepass.endFrame(),
|
||||
lightCullingPass.endFrame(),
|
||||
basePass.endFrame())
|
||||
);
|
||||
}
|
||||
|
||||
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||
|
||||
@@ -8,7 +8,6 @@ View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &vi
|
||||
: graphics(graphics)
|
||||
, owner(window)
|
||||
, name(name)
|
||||
, renderFinishedEvent(std::format("{}RenderFinished", name))
|
||||
{
|
||||
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,12 @@ public:
|
||||
virtual MainJob render() = 0;
|
||||
void applyArea(URect area);
|
||||
void setFocused();
|
||||
Event renderFinished() { return renderFinishedEvent; }
|
||||
void resetRender() { renderFinishedEvent.reset(); }
|
||||
|
||||
protected:
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::PViewport viewport;
|
||||
PWindow owner;
|
||||
std::string name;
|
||||
Event renderFinishedEvent;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) = 0;
|
||||
|
||||
@@ -27,21 +27,16 @@ void Window::addView(PView view)
|
||||
MainJob Window::render()
|
||||
{
|
||||
gfxHandle->beginFrame();
|
||||
Array<MainJob> jobs;
|
||||
for(auto& windowView : views)
|
||||
{
|
||||
co_await windowView->updateFinished;
|
||||
windowView->updateFinished.reset();
|
||||
{
|
||||
std::scoped_lock lock(windowView->workerMutex);
|
||||
windowView->view->prepareRender();
|
||||
}
|
||||
windowView->view->render();
|
||||
}
|
||||
for(auto& windowView : views)
|
||||
{
|
||||
co_await windowView->view->renderFinished();
|
||||
windowView->view->resetRender();
|
||||
jobs.add(windowView->view->render());
|
||||
}
|
||||
co_await MainJob::all(jobs);
|
||||
gfxHandle->endFrame();
|
||||
if(owner->isActive())
|
||||
{
|
||||
@@ -82,8 +77,11 @@ Job Window::viewWorker(size_t viewIndex)
|
||||
windowView->view->commitUpdate();
|
||||
}
|
||||
//std::cout << "Update completed" << std::endl;
|
||||
windowView->updateFinished.raise();
|
||||
//windowView->updateFinished.raise();
|
||||
// enqueue next frame update
|
||||
viewWorker(viewIndex);
|
||||
if(owner->isActive())
|
||||
{
|
||||
viewWorker(viewIndex);
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ void WindowManager::notifyWindowClosed(PWindow window)
|
||||
windows.remove(windows.find(window));
|
||||
if(windows.empty())
|
||||
{
|
||||
std::scoped_lock lock(windowsLock);
|
||||
windowsCV.notify_all();
|
||||
getGlobalThreadPool().cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,9 @@ public:
|
||||
{
|
||||
return windows.size();
|
||||
}
|
||||
void waitForCompletion()
|
||||
{
|
||||
std::unique_lock lock(windowsLock);
|
||||
windowsCV.wait(lock);
|
||||
}
|
||||
|
||||
private:
|
||||
Array<PWindow> windows;
|
||||
std::mutex windowsLock;
|
||||
std::condition_variable windowsCV;
|
||||
static Gfx::PGraphics graphics;
|
||||
};
|
||||
DEFINE_REF(WindowManager)
|
||||
|
||||
@@ -93,18 +93,15 @@ uint64 basicAllState2 = 0;
|
||||
Job basicAllFirst()
|
||||
{
|
||||
basicAllState1 = 10;
|
||||
std::cout << "AllFirst" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
Job basicAllSecond()
|
||||
{
|
||||
basicAllState2 = 10;
|
||||
std::cout << "AllSecond" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
Job basicAllThen()
|
||||
{
|
||||
std::cout << "AllThen" << std::endl;
|
||||
BOOST_REQUIRE_EQUAL(basicAllState1, 10);
|
||||
BOOST_REQUIRE_EQUAL(basicAllState2, 10);
|
||||
co_return;
|
||||
@@ -129,7 +126,6 @@ BOOST_AUTO_TEST_CASE(basic_callable)
|
||||
.then([=]() -> Job
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(basicCallable, 10);
|
||||
std::cout << "callable" << std::endl;
|
||||
co_return;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user