Many stupid changes
This commit is contained in:
@@ -124,7 +124,7 @@ CPUMesh Seele::generateCPUMesh(uint32 cbtNumElements) {
|
||||
neighbours.x = halfedge.prevID != -1 ? cbtNumElements + halfedge.prevID : UINT32_MAX;
|
||||
neighbours.y = halfedge.nextID != -1 ? cbtNumElements + halfedge.nextID : UINT32_MAX;
|
||||
neighbours.z = halfedge.twinID != -1 ? cbtNumElements + halfedge.twinID : UINT32_MAX;
|
||||
result.neighborsArray[elementID] = UVector4(neighbours, 1);
|
||||
result.neighborsArray[elementID] = UVector4(neighbours, 0);
|
||||
|
||||
result.basePoints[3 * halfedgeIdx + 2] = basePoints[halfedge.vertexID];
|
||||
|
||||
@@ -404,6 +404,7 @@ void MeshUpdater::evaluateLeb(const BaseMesh& baseMesh, CBTMesh& mesh, Gfx::PDes
|
||||
Gfx::PUniformBuffer geometryBuffer, Gfx::PUniformBuffer updateBuffer, Gfx::PShaderBuffer lebMatrixCache,
|
||||
bool clear, bool complete) {
|
||||
if (clear) {
|
||||
graphics->beginDebugRegion("ClearLEB");
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryBuffer);
|
||||
set->updateBuffer(LEB_POSITION_BUFFER, 0, mesh.currentVertexBuffer);
|
||||
@@ -415,8 +416,10 @@ void MeshUpdater::evaluateLeb(const BaseMesh& baseMesh, CBTMesh& mesh, Gfx::PDes
|
||||
graphics->executeCommands(std::move(clearCmd));
|
||||
mesh.currentVertexBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
graphics->endDebugRegion();
|
||||
}
|
||||
graphics->waitDeviceIdle();
|
||||
graphics->beginDebugRegion("EvaluateLEB");
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryBuffer);
|
||||
set->updateBuffer(UPDATE_CB, 0, updateBuffer);
|
||||
@@ -436,6 +439,7 @@ void MeshUpdater::evaluateLeb(const BaseMesh& baseMesh, CBTMesh& mesh, Gfx::PDes
|
||||
graphics->executeCommands(std::move(evalCmd));
|
||||
mesh.lebVertexBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
graphics->endDebugRegion();
|
||||
}
|
||||
|
||||
void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::PUniformBuffer geometryCB, Gfx::PUniformBuffer updateCB) {
|
||||
@@ -444,8 +448,8 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
Gfx::PShaderBuffer nextNeighborsBuffer = mesh.neighborsBuffers[nextNeighborsBufferIdx];
|
||||
|
||||
resetBuffers(mesh);
|
||||
|
||||
// classify
|
||||
graphics->waitDeviceIdle();
|
||||
graphics->beginDebugRegion("Classify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -467,8 +471,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.updateBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// prepare indirect pass
|
||||
graphics->beginDebugRegion("PrepareIndirect");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.classificationBuffer);
|
||||
@@ -482,9 +488,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
indirectBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
|
||||
graphics->waitDeviceIdle();
|
||||
// split pass
|
||||
graphics->beginDebugRegion("Split");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -508,9 +515,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.allocateBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// prepare indirect pass
|
||||
graphics->beginDebugRegion("PrepareIndirect");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.allocateBuffer);
|
||||
@@ -524,9 +532,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
indirectBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Allocate Pass
|
||||
graphics->beginDebugRegion("Allocate");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -546,17 +555,19 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.updateBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// copy
|
||||
graphics->beginDebugRegion("Copy");
|
||||
currentNeighborsBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_TRANSFER_READ_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
graphics->copyBuffer(currentNeighborsBuffer, nextNeighborsBuffer);
|
||||
nextNeighborsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// bisect
|
||||
graphics->beginDebugRegion("Bisect");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -579,9 +590,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
nextNeighborsBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Prepare indirect pass
|
||||
graphics->beginDebugRegion("PrepareIndirect");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.propagateBuffer);
|
||||
@@ -595,9 +607,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
indirectBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// propagate split pass
|
||||
graphics->beginDebugRegion("PropagateBisect");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -615,9 +628,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.updateBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// prepare simplify
|
||||
graphics->beginDebugRegion("PrepareSimplify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -637,9 +651,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.simplificationBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Prepare Indirect Simplify
|
||||
graphics->beginDebugRegion("PrepareIndirectSimplify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.simplificationBuffer);
|
||||
@@ -653,9 +668,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
indirectBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Simplify Pass
|
||||
graphics->beginDebugRegion("Simplify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -677,9 +693,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
nextNeighborsBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Prepare Indirect Propagate Simplify
|
||||
graphics->beginDebugRegion("PrepareIndirectPropagateSimplify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.propagateBuffer);
|
||||
@@ -693,9 +710,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
indirectBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Propagate Simplify Pass
|
||||
graphics->beginDebugRegion("PropagateSimplify");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -714,9 +732,10 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
nextNeighborsBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
// Update Tree
|
||||
graphics->beginDebugRegion("Update Tree");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(CBT_BUFFER0, 0, mesh.gpuCBT.bufferArray[0]);
|
||||
@@ -747,6 +766,7 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
||||
mesh.gpuCBT.bufferArray[0]->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
|
||||
mesh.currentNeighborsBufferIdx = nextNeighborsBufferIdx;
|
||||
@@ -778,6 +798,7 @@ void MeshUpdater::validation(const CBTMesh& mesh, Gfx::PUniformBuffer geometryCB
|
||||
}
|
||||
|
||||
void MeshUpdater::resetBuffers(const CBTMesh& mesh) {
|
||||
graphics->beginDebugRegion("ResetBuffers");
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(CBT_BUFFER0, 0, mesh.gpuCBT.bufferArray[0]);
|
||||
set->updateBuffer(CBT_BUFFER1, 0, mesh.gpuCBT.bufferArray[1]);
|
||||
@@ -796,12 +817,14 @@ void MeshUpdater::resetBuffers(const CBTMesh& mesh) {
|
||||
graphics->executeCommands(std::move(resetCmd));
|
||||
memoryBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
graphics->endDebugRegion();
|
||||
}
|
||||
|
||||
void MeshUpdater::prepareIndirection(CBTMesh& mesh, Gfx::PUniformBuffer geometryCB) {
|
||||
uint32 numGroups = (mesh.totalNumElements + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE;
|
||||
|
||||
// Bitsector indexation
|
||||
graphics->waitDeviceIdle();
|
||||
graphics->beginDebugRegion("BisectorIndexation");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryCB);
|
||||
@@ -821,7 +844,9 @@ void MeshUpdater::prepareIndirection(CBTMesh& mesh, Gfx::PUniformBuffer geometry
|
||||
}
|
||||
mesh.indirectDrawBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
// Prepare bisector indirect dispatch
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
graphics->beginDebugRegion("PrepareBisectorIndirectDispatch");
|
||||
{
|
||||
Gfx::PDescriptorSet set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(INDIRECT_DRAW_BUFFER, 0, mesh.indirectDrawBuffer);
|
||||
@@ -836,6 +861,8 @@ void MeshUpdater::prepareIndirection(CBTMesh& mesh, Gfx::PUniformBuffer geometry
|
||||
mesh.indirectDispatchBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
graphics->endDebugRegion();
|
||||
graphics->waitDeviceIdle();
|
||||
}
|
||||
|
||||
bool MeshUpdater::checkIfValid() { return true; }
|
||||
|
||||
@@ -97,6 +97,9 @@ class Graphics {
|
||||
virtual Gfx::OPipelineStatisticsQuery createPipelineStatisticsQuery(const std::string& name = "") = 0;
|
||||
virtual Gfx::OTimestampQuery createTimestampQuery(uint64 numTimestamps, const std::string& name = "") = 0;
|
||||
|
||||
virtual void beginDebugRegion(const std::string& name) = 0;
|
||||
virtual void endDebugRegion() = 0;
|
||||
|
||||
virtual void resolveTexture(PTexture source, PTexture destination) = 0;
|
||||
virtual void copyTexture(PTexture src, PTexture dst) = 0;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ struct WindowCreateInfo {
|
||||
};
|
||||
struct ViewportCreateInfo {
|
||||
URect dimensions;
|
||||
float fieldOfView = 1.222f; // 70 deg
|
||||
float fieldOfView = glm::radians(70.0f);
|
||||
Gfx::SeSampleCountFlags numSamples;
|
||||
};
|
||||
// doesnt own the data, only proxy it
|
||||
|
||||
@@ -25,6 +25,28 @@ RenderPass::~RenderPass() {}
|
||||
void RenderPass::beginFrame(const Component::Camera& cam) {
|
||||
auto screenDim = Vector2(static_cast<float>(viewport->getWidth()), static_cast<float>(viewport->getHeight()));
|
||||
viewParams = {
|
||||
.viewFrustum =
|
||||
{
|
||||
.planes =
|
||||
{
|
||||
Plane{
|
||||
.n = Vector(-0.62628, 0, 0.7796),
|
||||
.d = 3.898,
|
||||
},
|
||||
Plane{
|
||||
.n = Vector(0.62628, 0, 0.7796),
|
||||
.d = 3.898,
|
||||
},
|
||||
Plane{
|
||||
.n = Vector(0, 0.81915, 0.57358),
|
||||
.d = 2.86788,
|
||||
},
|
||||
Plane{
|
||||
.n = Vector(0, -0.81915, 0.57358),
|
||||
.d = 2.86788,
|
||||
},
|
||||
},
|
||||
},
|
||||
.viewMatrix = cam.getViewMatrix(),
|
||||
.inverseViewMatrix = glm::inverse(cam.getViewMatrix()),
|
||||
.projectionMatrix = viewport->getProjectionMatrix(),
|
||||
|
||||
@@ -10,13 +10,13 @@ using namespace Seele;
|
||||
TerrainRenderer::TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescriptorLayout viewParamsLayout,
|
||||
Gfx::PDescriptorSet viewParamsSet)
|
||||
: graphics(graphics), scene(scene) {
|
||||
//Gfx::OPipelineLayout test = graphics->createPipelineLayout();
|
||||
//graphics->beginShaderCompilation(ShaderCompilationInfo{
|
||||
// .modules = {"CompileTest"},
|
||||
// .entryPoints = {{"Reset", "CompileTest"}},
|
||||
// .rootSignature = test,
|
||||
//});
|
||||
//graphics->createComputeShader({0});
|
||||
Gfx::OPipelineLayout test = graphics->createPipelineLayout();
|
||||
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
||||
.modules = {"CompileTest"},
|
||||
.entryPoints = {{"Split", "CompileTest"}},
|
||||
.rootSignature = test,
|
||||
});
|
||||
graphics->createComputeShader({0});
|
||||
meshUpdater.init(graphics, viewParamsLayout);
|
||||
lebCache.init(graphics, 5);
|
||||
CBT<18> cbt;
|
||||
@@ -223,9 +223,9 @@ TerrainRenderer::TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDe
|
||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
UpdateCB updateCB = {
|
||||
.viewProjectionMatrix = Matrix4(0),
|
||||
.triangleSize = 10.0f,
|
||||
.triangleSize = 60.0f,
|
||||
.maxSubdivisionDepth = 63,
|
||||
.fov = 70.0f,
|
||||
.fov = 1.22173f,
|
||||
.farPlaneDistance = 1000.0f,
|
||||
};
|
||||
updateBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
@@ -265,6 +265,8 @@ TerrainRenderer::TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDe
|
||||
graphics->waitDeviceIdle();
|
||||
applyDeformation(viewParamsSet);
|
||||
graphics->waitDeviceIdle();
|
||||
meshUpdater.validation(plainMesh, geometryBuffer);
|
||||
graphics->waitDeviceIdle();
|
||||
}
|
||||
|
||||
TerrainRenderer::~TerrainRenderer() {}
|
||||
@@ -274,9 +276,9 @@ static bool first = true;
|
||||
void TerrainRenderer::beginFrame(Gfx::PDescriptorSet viewParamsSet, const Component::Camera& cam) {
|
||||
UpdateCB updateCB = {
|
||||
.viewProjectionMatrix = viewport->getProjectionMatrix() * cam.getViewMatrix(),
|
||||
.triangleSize = 10.0f,
|
||||
.triangleSize = 60.0f,
|
||||
.maxSubdivisionDepth = 63,
|
||||
.fov = 70.0f,
|
||||
.fov = 1.22173f,
|
||||
.farPlaneDistance = 1000.0f,
|
||||
};
|
||||
updateBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
@@ -296,6 +298,8 @@ void TerrainRenderer::beginFrame(Gfx::PDescriptorSet viewParamsSet, const Compon
|
||||
graphics->waitDeviceIdle();
|
||||
applyDeformation(viewParamsSet);
|
||||
graphics->waitDeviceIdle();
|
||||
meshUpdater.validation(plainMesh, geometryBuffer);
|
||||
graphics->waitDeviceIdle();
|
||||
}
|
||||
|
||||
Gfx::ORenderCommand TerrainRenderer::render(Gfx::PDescriptorSet viewParamsSet) {
|
||||
@@ -344,6 +348,7 @@ void TerrainRenderer::setViewport(Gfx::PViewport _viewport, Gfx::PRenderPass ren
|
||||
}
|
||||
|
||||
void TerrainRenderer::applyDeformation(Gfx::PDescriptorSet viewParamsSet) {
|
||||
graphics->beginDebugRegion("ApplyDeformation");
|
||||
Gfx::PDescriptorSet set = meshUpdater.layout->allocateDescriptorSet();
|
||||
set->updateBuffer(GEOMETRY_CB, 0, geometryBuffer);
|
||||
set->updateBuffer(INDIRECT_DRAW_BUFFER, 0, plainMesh.indirectDrawBuffer);
|
||||
@@ -358,4 +363,5 @@ void TerrainRenderer::applyDeformation(Gfx::PDescriptorSet viewParamsSet) {
|
||||
graphics->executeCommands(std::move(command));
|
||||
plainMesh.currentVertexBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
|
||||
graphics->endDebugRegion();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ thread_local PCommandPool Seele::Vulkan::Graphics::transferCommands = nullptr;
|
||||
PFN_vkCmdDrawMeshTasksEXT cmdDrawMeshTasks;
|
||||
PFN_vkCmdDrawMeshTasksIndirectEXT cmdDrawMeshTasksIndirect;
|
||||
PFN_vkSetDebugUtilsObjectNameEXT setDebugUtilsObjectName;
|
||||
PFN_vkQueueBeginDebugUtilsLabelEXT queueBeginDebugUtilsLabelEXT;
|
||||
PFN_vkQueueEndDebugUtilsLabelEXT queueEndDebugUtilsLabelEXT;
|
||||
PFN_vkCreateAccelerationStructureKHR createAccelerationStructure;
|
||||
PFN_vkCmdBuildAccelerationStructuresKHR cmdBuildAccelerationStructures;
|
||||
PFN_vkGetAccelerationStructureBuildSizesKHR getAccelerationStructureBuildSize;
|
||||
@@ -57,6 +59,18 @@ VkResult vkSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectN
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void vkQueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo) {
|
||||
if (queueBeginDebugUtilsLabelEXT != nullptr) {
|
||||
queueBeginDebugUtilsLabelEXT(queue, pLabelInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void vkQueueEndDebugUtilsLabelEXT(VkQueue queue) {
|
||||
if (queueEndDebugUtilsLabelEXT != nullptr) {
|
||||
queueEndDebugUtilsLabelEXT(queue);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult vkCreateAccelerationStructureKHR(VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator, VkAccelerationStructureKHR* pAccelerationStructure) {
|
||||
return createAccelerationStructure(device, pCreateInfo, pAllocator, pAccelerationStructure);
|
||||
@@ -164,7 +178,7 @@ void Graphics::endRenderPass() { getGraphicsCommands()->getCommands()->endRender
|
||||
|
||||
void Graphics::waitDeviceIdle() {
|
||||
getGraphicsCommands()->submitCommands();
|
||||
vkDeviceWaitIdle(handle);
|
||||
vkDeviceWaitIdle(handle);
|
||||
getGraphicsCommands()->refreshCommands();
|
||||
}
|
||||
|
||||
@@ -288,6 +302,17 @@ Gfx::OTimestampQuery Graphics::createTimestampQuery(uint64 numTimestamps, const
|
||||
return new TimestampQuery(this, name);
|
||||
}
|
||||
|
||||
void Graphics::beginDebugRegion(const std::string& name) {
|
||||
VkDebugUtilsLabelEXT label = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
|
||||
.pNext = nullptr,
|
||||
.pLabelName = name.c_str(),
|
||||
};
|
||||
vkQueueBeginDebugUtilsLabelEXT(queues[graphicsQueue]->getHandle(), &label);
|
||||
}
|
||||
|
||||
void Graphics::endDebugRegion() { vkQueueEndDebugUtilsLabelEXT(queues[graphicsQueue]->getHandle()); }
|
||||
|
||||
void Graphics::resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) {
|
||||
PTextureBase sourceTex = source.cast<TextureBase>();
|
||||
PTextureBase destinationTex = destination.cast<TextureBase>();
|
||||
@@ -389,7 +414,6 @@ void Graphics::copyBuffer(Gfx::PShaderBuffer srcBuffer, Gfx::PShaderBuffer dstBu
|
||||
vkCmdCopyBuffer(getGraphicsCommands()->getCommands()->getHandle(), src->getHandle(), dst->getHandle(), 1, ®ion);
|
||||
}
|
||||
|
||||
|
||||
Gfx::OBottomLevelAS Graphics::createBottomLevelAccelerationStructure(const Gfx::BottomLevelASCreateInfo& createInfo) {
|
||||
return new BottomLevelAS(this, createInfo);
|
||||
}
|
||||
@@ -401,9 +425,9 @@ Gfx::OTopLevelAS Graphics::createTopLevelAccelerationStructure(const Gfx::TopLev
|
||||
void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS> data) {
|
||||
Gfx::PShaderBuffer verticesBuffer = StaticMeshVertexData::getInstance()->getPositionBuffer();
|
||||
Gfx::PIndexBuffer indexBuffer = StaticMeshVertexData::getInstance()->getIndexBuffer();
|
||||
|
||||
|
||||
// Setup vertices and indices for a single triangle
|
||||
|
||||
|
||||
// Create buffers for the bottom level geometry
|
||||
// For the sake of simplicity we won't stage the vertex data to the GPU memory
|
||||
|
||||
@@ -411,7 +435,6 @@ void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS>
|
||||
const VkBufferUsageFlags buffer_usage_flags = VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR |
|
||||
VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
|
||||
VkBufferCreateInfo transformBufferInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -437,9 +460,9 @@ void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS>
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT,
|
||||
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR | VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
verticesBuffer->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT,
|
||||
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR);
|
||||
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR);
|
||||
indexBuffer->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT,
|
||||
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR);
|
||||
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR);
|
||||
|
||||
Array<VkAccelerationStructureGeometryKHR> geometries(data.size());
|
||||
Array<VkAccelerationStructureBuildGeometryInfoKHR> buildGeometries(data.size());
|
||||
@@ -672,7 +695,7 @@ void Graphics::initInstance(GraphicsInitializer initInfo) {
|
||||
extensions.add("VK_KHR_portability_enumeration");
|
||||
#endif
|
||||
Array<const char*> layers = initInfo.layers;
|
||||
//layers.add("VK_LAYER_KHRONOS_validation");
|
||||
// layers.add("VK_LAYER_KHRONOS_validation");
|
||||
VkInstanceCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -885,9 +908,9 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
||||
#ifdef __APPLE__
|
||||
initializer.deviceExtensions.add("VK_KHR_portability_subset");
|
||||
#endif
|
||||
//initializer.deviceExtensions.add(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
|
||||
//initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
|
||||
//initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
|
||||
// initializer.deviceExtensions.add(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
|
||||
// initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
|
||||
// initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
|
||||
VkDeviceCreateInfo deviceInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.pNext = &features,
|
||||
@@ -920,6 +943,8 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
||||
cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT");
|
||||
cmdDrawMeshTasksIndirect = (PFN_vkCmdDrawMeshTasksIndirectEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksIndirectEXT");
|
||||
setDebugUtilsObjectName = (PFN_vkSetDebugUtilsObjectNameEXT)vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT");
|
||||
queueBeginDebugUtilsLabelEXT = (PFN_vkQueueBeginDebugUtilsLabelEXT)vkGetInstanceProcAddr(instance, "vkQueueBeginDebugUtilsLabelEXT");
|
||||
queueEndDebugUtilsLabelEXT = (PFN_vkQueueEndDebugUtilsLabelEXT)vkGetInstanceProcAddr(instance, "vkQueueEndDebugUtilsLabelEXT");
|
||||
|
||||
createAccelerationStructure = (PFN_vkCreateAccelerationStructureKHR)vkGetDeviceProcAddr(handle, "vkCreateAccelerationStructureKHR");
|
||||
cmdBuildAccelerationStructures =
|
||||
|
||||
@@ -76,6 +76,9 @@ class Graphics : public Gfx::Graphics {
|
||||
virtual Gfx::OPipelineStatisticsQuery createPipelineStatisticsQuery(const std::string& name = "") override;
|
||||
virtual Gfx::OTimestampQuery createTimestampQuery(uint64 numTimestamps, const std::string& name = "") override;
|
||||
|
||||
virtual void beginDebugRegion(const std::string& name) override;
|
||||
virtual void endDebugRegion() override;
|
||||
|
||||
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) override;
|
||||
virtual void copyTexture(Gfx::PTexture src, Gfx::PTexture dst) override;
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
||||
slang::SessionDesc sessionDesc;
|
||||
sessionDesc.flags = 0;
|
||||
Array<slang::CompilerOptionEntry> option = {
|
||||
{
|
||||
.name = slang::CompilerOptionName::Capability,
|
||||
.value =
|
||||
{
|
||||
.kind = slang::CompilerOptionValueKind::Int,
|
||||
.intValue0 = globalSession->findCapability("GLSL_450"),
|
||||
},
|
||||
},
|
||||
//{
|
||||
// .name = slang::CompilerOptionName::Capability,
|
||||
// .value =
|
||||
// {
|
||||
// .kind = slang::CompilerOptionValueKind::Int,
|
||||
// .intValue0 = globalSession->findCapability("GLSL_450"),
|
||||
// },
|
||||
//},
|
||||
{
|
||||
.name = slang::CompilerOptionName::EmitSpirvDirectly,
|
||||
.value =
|
||||
@@ -88,7 +88,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
||||
sessionDesc.preprocessorMacroCount = macros.size();
|
||||
sessionDesc.preprocessorMacros = macros.data();
|
||||
slang::TargetDesc targetDesc;
|
||||
targetDesc.profile = globalSession->findProfile("glsl_450");
|
||||
targetDesc.profile = globalSession->findProfile("spirv_1_6");
|
||||
targetDesc.format = target;
|
||||
sessionDesc.targetCount = 1;
|
||||
sessionDesc.targets = &targetDesc;
|
||||
|
||||
Reference in New Issue
Block a user