Fixing a refactor error

This commit is contained in:
Dynamitos
2024-04-23 17:08:39 +02:00
parent 89571e5298
commit 80963edfd4
11 changed files with 83 additions and 38 deletions
+4 -4
View File
@@ -151,7 +151,7 @@ install(
EXPORT EXPORT
EngineTargets EngineTargets
FILE_SET HEADERS FILE_SET HEADERS
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Seele) DESTINATION include/Seele)
export(EXPORT EngineTargets export(EXPORT EngineTargets
FILE "${CMAKE_BINARY_DIR}/EngineTargets.cmake" FILE "${CMAKE_BINARY_DIR}/EngineTargets.cmake"
@@ -169,14 +169,14 @@ install(EXPORT EngineTargets
NAMESPACE NAMESPACE
Seele:: Seele::
DESTINATION DESTINATION
${CMAKE_INSTALL_PREFIX}/lib/cmake/Seele lib/cmake/Seele
) )
install( install(
FILES FILES
${CMAKE_BINARY_DIR}/SeeleConfig.cmake ${CMAKE_BINARY_DIR}/SeeleConfig.cmake
DESTINATION DESTINATION
${CMAKE_INSTALL_PREFIX}/lib/cmake/Seele lib/cmake/Seele
) )
install( install(
@@ -186,5 +186,5 @@ install(
${CMAKE_SOURCE_DIR}/res/shaders ${CMAKE_SOURCE_DIR}/res/shaders
${CMAKE_SOURCE_DIR}/res/textures ${CMAKE_SOURCE_DIR}/res/textures
DESTINATION DESTINATION
${CMAKE_INSTALL_PREFIX}/bin bin
) )
+4 -4
View File
@@ -9,14 +9,14 @@
"intelliSenseMode": "windows-msvc-x64", "intelliSenseMode": "windows-msvc-x64",
"inheritEnvironments": [ "msvc_x64" ], "inheritEnvironments": [ "msvc_x64" ],
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64", "cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
"buildRoot": "C:/Users/Dynamitos/Seele/bin/", "buildRoot": "C:/Users/Dynamitos/Seele/build",
"installRoot": "C:/Program Files/Seele" "installRoot": "C:/Program Files/Seele"
}, },
{ {
"name": "Release", "name": "Release",
"generator": "Visual Studio 17 2022 Win64", "generator": "Visual Studio 17 2022 Win64",
"configurationType": "Release", "configurationType": "Release",
"buildRoot": "C:/Users/Dynamitos/Seele/bin/", "buildRoot": "C:/Users/Dynamitos/Seele/build/",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64", "cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
"buildCommandArgs": "", "buildCommandArgs": "",
"ctestCommandArgs": "", "ctestCommandArgs": "",
@@ -28,7 +28,7 @@
"name": "RelWithDebInfo", "name": "RelWithDebInfo",
"generator": "Visual Studio 17 2022 Win64", "generator": "Visual Studio 17 2022 Win64",
"configurationType": "RelWithDebInfo", "configurationType": "RelWithDebInfo",
"buildRoot": "C:/Users/Dynamitos/Seele/bin/", "buildRoot": "C:/Users/Dynamitos/Seele/build/",
"installRoot": "C:/Program Files/Seele", "installRoot": "C:/Program Files/Seele",
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64", "cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
"buildCommandArgs": "", "buildCommandArgs": "",
@@ -45,7 +45,7 @@
"intelliSenseMode": "windows-msvc-x64", "intelliSenseMode": "windows-msvc-x64",
"inheritEnvironments": [ "msvc_x64" ], "inheritEnvironments": [ "msvc_x64" ],
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64", "cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
"buildRoot": "C:/Users/Dynamitos/Seele/bin/", "buildRoot": "C:/Users/Dynamitos/Seele/build/",
"installRoot": "C:/Program Files/Seele", "installRoot": "C:/Program Files/Seele",
"addressSanitizerEnabled": true "addressSanitizerEnabled": true
} }
+29
View File
@@ -0,0 +1,29 @@
# Mesh Shading for Visibility Culling
## Generelle TODO
- Bounding Box/Sphere intersection fix
- ~~Meshlet generation effizienter machen~~ (Index Buffer mit Tipsy optimiert)
- Vertex Attribute compression
## Culling Ablauf
- Erstes Frame: Alle Meshlets Drawcall
- Immer: View Frustum Culling (fertig, wenn Bounding intersection gefixt ist)
- Meshlet ID in separaten Buffer rendern
- Compute Shader über ID Buffer sammelt die Meshlets, die sichtbar waren
- Diese Meshlets wieder rendern
- Aus Depth Buffer eine Mipmap Pyramide generieren
- Im nächsten Frame: Meshlets aus ID Buffer Drawcall
- Für alle anderen Meshlets: Bounding Box/Sphere minimum Depth berechnen und mit Depth Pyramide vergleichen
- Wenn berechnete Depth < Previous, also potentiell visible: Draw call (Indirect mesh invocation aus compute shader?)
## Evaluierung
Vergleich mit Traditioneller Vertex Pipeline
### Demo Szene
Viel Overdraw, Camera Movement was die Occlusion stark verändert (Work in Progress)
- Ich hätte mir überlegt eine Art Arena mit Säulen vorgestellt, wo die Kamera hinter den Säulen fliegt die immer wieder die Szene verdecken
- Vielleicht verändert sich die Szene nach jeder Säule für pseudo "Animationen", vielleicht nicht sinnvoll und wichtig
### Scripted Benchmark Run
Fixierter Kameraflug durch die Demo Szene, sammelt Timings und andere Statistiken und schreibt sie in eine Datei
### Platformen(optional)
Ich hätte Zugriff auf sowohl Nvidia, AMD und Apple Hardware mit Mesh Shading, und es würde Sinn machen den Unterschied Mesh-Traditionell auf allen Platformed zu vergleichen. Um Apple zu benchmarken, müsste ich ein Metal-Backend implementieren.
+2 -2
View File
@@ -78,8 +78,8 @@ void meshMain(
in uint threadID: SV_GroupIndex, in uint threadID: SV_GroupIndex,
in uint groupID: SV_GroupID, in uint groupID: SV_GroupID,
in payload MeshPayload meshPayload, in payload MeshPayload meshPayload,
OutputVertices<FragmentParameter, MAX_VERTICES> vertices, out vertices FragmentParameter vertices[MAX_VERTICES],
OutputIndices<uint3, MAX_PRIMITIVES> indices out indices uint3 indices[MAX_PRIMITIVES]
){ ){
InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]]; InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]];
MeshData md = pScene.meshData[meshPayload.instanceId[groupID]]; MeshData md = pScene.meshData[meshPayload.instanceId[groupID]];
+32 -5
View File
@@ -194,7 +194,16 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
.filePath = meshDirectory / outMatFilename, .filePath = meshDirectory / outMatFilename,
.importPath = importPath, .importPath = importPath,
}); });
PMaterialAsset baseMat = AssetRegistry::findMaterial(matCode["name"].get<std::string>()); std::string materialAsset;
if (importPath.empty())
{
materialAsset = matCode["name"].get<std::string>();
}
else
{
materialAsset = fmt::format("{0}/{1}", importPath, matCode["name"].get<std::string>());
}
PMaterialAsset baseMat = AssetRegistry::findMaterial(materialAsset);
globalMaterials[i] = baseMat->instantiate(InstantiationParameter{ globalMaterials[i] = baseMat->instantiate(InstantiationParameter{
.name = fmt::format("{0}_Inst_0", baseMat->getName()), .name = fmt::format("{0}_Inst_0", baseMat->getName()),
.folderPath = baseMat->getFolderPath(), .folderPath = baseMat->getFolderPath(),
@@ -220,6 +229,8 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
for (uint32 meshIndex = 0; meshIndex < scene->mNumMeshes; ++meshIndex) for (uint32 meshIndex = 0; meshIndex < scene->mNumMeshes; ++meshIndex)
{ {
aiMesh* mesh = scene->mMeshes[meshIndex]; aiMesh* mesh = scene->mMeshes[meshIndex];
if (!(mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE))
continue;
collider.boundingbox.adjust(Vector(mesh->mAABB.mMin.x, mesh->mAABB.mMin.y, mesh->mAABB.mMin.z)); collider.boundingbox.adjust(Vector(mesh->mAABB.mMin.x, mesh->mAABB.mMin.y, mesh->mAABB.mMin.z));
collider.boundingbox.adjust(Vector(mesh->mAABB.mMax.x, mesh->mAABB.mMax.y, mesh->mAABB.mMax.z)); collider.boundingbox.adjust(Vector(mesh->mAABB.mMax.x, mesh->mAABB.mMax.y, mesh->mAABB.mMax.z));
@@ -236,10 +247,25 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
for (uint32 i = 0; i < mesh->mNumVertices; ++i) for (uint32 i = 0; i < mesh->mNumVertices; ++i)
{ {
positions[i] = Vector(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z); positions[i] = Vector(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z);
texCoords[i] = Vector2(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y); if (mesh->HasTextureCoords(0))
{
texCoords[i] = Vector2(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y);
}
else
{
texCoords[i] = Vector2(0, 0);
}
normals[i] = Vector(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z); normals[i] = Vector(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z);
tangents[i] = Vector(mesh->mTangents[i].x, mesh->mTangents[i].y, mesh->mTangents[i].z); if (mesh->HasTangentsAndBitangents())
biTangents[i] = Vector(mesh->mBitangents[i].x, mesh->mBitangents[i].y, mesh->mBitangents[i].z); {
tangents[i] = Vector(mesh->mTangents[i].x, mesh->mTangents[i].y, mesh->mTangents[i].z);
biTangents[i] = Vector(mesh->mBitangents[i].x, mesh->mBitangents[i].y, mesh->mBitangents[i].z);
}
else
{
tangents[i] = Vector(0, 0, 1);
biTangents[i] = Vector(1, 0, 0);
}
if(mesh->HasVertexColors(0)) if(mesh->HasVertexColors(0))
{ {
colors[i] = Vector(mesh->mColors[0][i].r, mesh->mColors[0][i].g, mesh->mColors[0][i].b); colors[i] = Vector(mesh->mColors[0][i].r, mesh->mColors[0][i].g, mesh->mColors[0][i].b);
@@ -336,8 +362,9 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
aiProcess_GenBoundingBoxes | aiProcess_GenBoundingBoxes |
aiProcess_GenSmoothNormals | aiProcess_GenSmoothNormals |
aiProcess_GenUVCoords | aiProcess_GenUVCoords |
aiProcess_SortByPType |
aiProcess_FindDegenerates)); aiProcess_FindDegenerates));
const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace | aiProcess_ImproveCacheLocality); const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
Array<PMaterialInstanceAsset> globalMaterials(scene->mNumMaterials); Array<PMaterialInstanceAsset> globalMaterials(scene->mNumMaterials);
loadTextures(scene, args.filePath.parent_path(), args.importPath); loadTextures(scene, args.filePath.parent_path(), args.importPath);
+4 -3
View File
@@ -57,9 +57,10 @@ int main() {
AssetImporter::importMesh(MeshImportArgs{ AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import/models/cube.fbx", .filePath = sourcePath / "import/models/cube.fbx",
}); });
AssetImporter::importMesh(MeshImportArgs{ //AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.blend" // .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.blend",
}); // .importPath = "Whitechapel"
// });
WindowCreateInfo mainWindowInfo; WindowCreateInfo mainWindowInfo;
mainWindowInfo.title = "SeeleEngine"; mainWindowInfo.title = "SeeleEngine";
mainWindowInfo.width = 1920; mainWindowInfo.width = 1920;
+1 -4
View File
@@ -209,9 +209,6 @@ void AssetRegistry::peekAsset(ArchiveBuffer& buffer)
std::string folderPath; std::string folderPath;
Serialization::load(buffer, folderPath); Serialization::load(buffer, folderPath);
uint64 assetSize;
Serialization::load(buffer, assetSize);
AssetFolder* folder = getOrCreateFolder(folderPath); AssetFolder* folder = getOrCreateFolder(folderPath);
OAsset asset; OAsset asset;
@@ -332,7 +329,7 @@ void AssetRegistry::saveAsset(PAsset asset, uint64 identifier, const std::filesy
Serialization::save(buffer, folderPath.string()); Serialization::save(buffer, folderPath.string());
// write asset data // write asset data
asset->save(buffer); asset->save(buffer);
assetBuffer.writeToStream(assetStream); buffer.writeToStream(assetStream);
} }
std::filesystem::path AssetRegistry::getRootFolder() std::filesystem::path AssetRegistry::getRootFolder()
-1
View File
@@ -74,7 +74,6 @@ private:
std::filesystem::path rootFolder; std::filesystem::path rootFolder;
AssetFolder* assetRoot; AssetFolder* assetRoot;
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
ArchiveBuffer assetBuffer;
bool release = false; bool release = false;
friend class MaterialAsset; friend class MaterialAsset;
friend class TextureLoader; friend class TextureLoader;
+6 -12
View File
@@ -18,16 +18,11 @@ static Map<Vulkan::Buffer*, PendingBuffer> pendingBuffers;
Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType& queueType, bool dynamic, Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType& queueType, bool dynamic,
std::string name) std::string name)
: graphics(graphics), currentBuffer(0), size(size), owner(queueType), usage(usage), name(name) { : graphics(graphics), currentBuffer(0), size(size), owner(queueType), usage(usage), name(name) {
if (dynamic) {
numBuffers = Gfx::numFramesBuffered;
} else {
numBuffers = 1;
}
createBuffer(); createBuffer();
} }
Buffer::~Buffer() { Buffer::~Buffer() {
for (uint32 i = 0; i < numBuffers; ++i) { for (uint32 i = 0; i < buffers.size(); ++i) {
graphics->getDestructionManager()->queueBuffer(graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer, graphics->getDestructionManager()->queueBuffer(graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer,
buffers[i].allocation); buffers[i].allocation);
} }
@@ -74,12 +69,12 @@ void Buffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
VkCommandBuffer srcCommand = sourcePool->getCommands()->getHandle(); VkCommandBuffer srcCommand = sourcePool->getCommands()->getHandle();
VkCommandBuffer dstCommand = dstPool->getCommands()->getHandle(); VkCommandBuffer dstCommand = dstPool->getCommands()->getHandle();
VkBufferMemoryBarrier dynamicBarriers[Gfx::numFramesBuffered]; VkBufferMemoryBarrier dynamicBarriers[Gfx::numFramesBuffered];
for (uint32 i = 0; i < numBuffers; ++i) { for (uint32 i = 0; i < buffers.size(); ++i) {
dynamicBarriers[i] = barrier; dynamicBarriers[i] = barrier;
dynamicBarriers[i].buffer = buffers[i].buffer; dynamicBarriers[i].buffer = buffers[i].buffer;
} }
vkCmdPipelineBarrier(srcCommand, srcStage, srcStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr); vkCmdPipelineBarrier(srcCommand, srcStage, srcStage, 0, 0, nullptr, buffers.size(), dynamicBarriers, 0, nullptr);
vkCmdPipelineBarrier(dstCommand, dstStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr); vkCmdPipelineBarrier(dstCommand, dstStage, dstStage, 0, 0, nullptr, buffers.size(), dynamicBarriers, 0, nullptr);
sourcePool->submitCommands(); sourcePool->submitCommands();
} }
@@ -97,15 +92,14 @@ void Buffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlag
.size = size, .size = size,
}; };
VkBufferMemoryBarrier dynamicBarriers[Gfx::numFramesBuffered]; VkBufferMemoryBarrier dynamicBarriers[Gfx::numFramesBuffered];
for (uint32 i = 0; i < numBuffers; ++i) { for (uint32 i = 0; i < buffers.size(); ++i) {
dynamicBarriers[i] = barrier; dynamicBarriers[i] = barrier;
dynamicBarriers[i].buffer = buffers[i].buffer; dynamicBarriers[i].buffer = buffers[i].buffer;
} }
vkCmdPipelineBarrier(commandBuffer->getHandle(), srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, vkCmdPipelineBarrier(commandBuffer->getHandle(), srcStage, dstStage, 0, 0, nullptr, buffers.size(), dynamicBarriers, 0,
nullptr); nullptr);
} }
void* Buffer::map(bool writeOnly) { return mapRegion(0, size, writeOnly); } void* Buffer::map(bool writeOnly) { return mapRegion(0, size, writeOnly); }
void* Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly) { void* Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly) {
-1
View File
@@ -31,7 +31,6 @@ protected:
Gfx::QueueType &owner; Gfx::QueueType &owner;
Array<BufferAllocation> buffers; Array<BufferAllocation> buffers;
VkBufferUsageFlags usage; VkBufferUsageFlags usage;
uint32 numBuffers;
std::string name; std::string name;
void createBuffer(); void createBuffer();
+1 -2
View File
@@ -11,7 +11,6 @@
"nlohmann-json", "nlohmann-json",
"fmt", "fmt",
"gtest", "gtest",
"vulkan-memory-allocator", "vulkan-memory-allocator"
"shader-slang"
] ]
} }