Trying to fix fluid pass

This commit is contained in:
2026-04-12 21:39:31 +02:00
parent ac317a3829
commit 495e683522
7 changed files with 18 additions and 30 deletions
-4
View File
@@ -36,10 +36,6 @@
"name": "ASAN_OPTIONS", "name": "ASAN_OPTIONS",
"value": "detect_leaks=0", "value": "detect_leaks=0",
}, },
{
"name": "VK_INSTANCE_LAYERS",
"value": "VK_LAYER_KHRONOS_validation",
},
{ {
"name": "DISABLE_VK_LAYER_VALVE_steam_overlay_1", "name": "DISABLE_VK_LAYER_VALVE_steam_overlay_1",
"value": "1", "value": "1",
@@ -73,22 +73,15 @@ void FluidRenderPass::render() {
void FluidRenderPass::endFrame() {} void FluidRenderPass::endFrame() {}
void FluidRenderPass::publishOutputs() { void FluidRenderPass::publishOutputs() {
depthTexture = graphics->createTexture2D(TextureCreateInfo{
.format = Gfx::SE_FORMAT_D32_SFLOAT,
.width = viewport->getWidth(),
.height = viewport->getHeight(),
.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
.name = "FluidDepth",
});
} }
void FluidRenderPass::createRenderPass() { void FluidRenderPass::createRenderPass() {
colorAttachment = Gfx::RenderTargetAttachment(viewport, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_PRESENT_SRC_KHR, colorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE); colorAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
depthAttachment = Gfx::RenderTargetAttachment(depthTexture->getDefaultView(), Gfx::SE_IMAGE_LAYOUT_UNDEFINED, colorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, depthAttachment = resources->requestRenderTarget("BASEPASS_DEPTH");
Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE); depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
depthAttachment.clear.depthStencil.depth = 0.0f; depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{ Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
.colorAttachments = {colorAttachment}, .colorAttachments = {colorAttachment},
.depthAttachment = depthAttachment, .depthAttachment = depthAttachment,
@@ -22,7 +22,6 @@ class FluidRenderPass : public RenderPass {
private: private:
Gfx::RenderTargetAttachment colorAttachment; Gfx::RenderTargetAttachment colorAttachment;
Gfx::RenderTargetAttachment depthAttachment; Gfx::RenderTargetAttachment depthAttachment;
Gfx::OTexture2D depthTexture;
Gfx::ODescriptorSet viewParamsSet; Gfx::ODescriptorSet viewParamsSet;
@@ -73,7 +73,6 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa
.mainFile = "ClosestHit", .mainFile = "ClosestHit",
.useMaterial = true, .useMaterial = true,
.rayTracing = true, .rayTracing = true,
.dumpIntermediates = true,
}); });
skyBox = AssetRegistry::findEnvironmentMap("", "newport_loft")->getSkybox(); skyBox = AssetRegistry::findEnvironmentMap("", "newport_loft")->getSkybox();
skyBoxSampler = graphics->createSampler({}); skyBoxSampler = graphics->createSampler({});
@@ -48,6 +48,7 @@ SurfaceExtractPass::SurfaceExtractPass(Gfx::PGraphics graphics, PScene scene) :
.modules = {"MarchingCubes"}, .modules = {"MarchingCubes"},
.entryPoints = {{"marchingCubes", "MarchingCubes"}}, .entryPoints = {{"marchingCubes", "MarchingCubes"}},
.rootSignature = pipelineLayout, .rootSignature = pipelineLayout,
.dumpIntermediate = true,
}); });
pipelineLayout->create(); pipelineLayout->create();
computeShader = graphics->createComputeShader({0}); computeShader = graphics->createComputeShader({0});
@@ -69,7 +70,7 @@ void SurfaceExtractPass::render() {
uint32 surfaceCountData[4] = {0, 1, 0, 0}; uint32 surfaceCountData[4] = {0, 1, 0, 0};
data.surfaceCountBuffer->updateContents(0, sizeof(surfaceCountData), surfaceCountData); data.surfaceCountBuffer->updateContents(0, sizeof(surfaceCountData), surfaceCountData);
data.surfaceCountBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, data.surfaceCountBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
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);
descriptorSet = descriptorLayout->allocateDescriptorSet(); descriptorSet = descriptorLayout->allocateDescriptorSet();
descriptorSet->updateBuffer("vertexBuffer", 0, data.vertexBuffer); descriptorSet->updateBuffer("vertexBuffer", 0, data.vertexBuffer);
@@ -86,13 +87,13 @@ void SurfaceExtractPass::render() {
graphics->executeCommands(std::move(cmd)); graphics->executeCommands(std::move(cmd));
data.vertexBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, data.vertexBuffer->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); Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
data.normalBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, data.normalBuffer->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); Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
data.indexBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, data.indexBuffer->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); Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
data.surfaceCountBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, data.surfaceCountBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_INDIRECT_COMMAND_READ_BIT, Gfx::SE_PIPELINE_STAGE_DRAW_INDIRECT_BIT); Gfx::SE_ACCESS_INDIRECT_COMMAND_READ_BIT, Gfx::SE_PIPELINE_STAGE_DRAW_INDIRECT_BIT);
} }
} }
@@ -100,4 +101,4 @@ void SurfaceExtractPass::endFrame() {}
void SurfaceExtractPass::publishOutputs() {} void SurfaceExtractPass::publishOutputs() {}
void SurfaceExtractPass::createRenderPass() { } void SurfaceExtractPass::createRenderPass() {}
+2 -2
View File
@@ -268,7 +268,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
} }
} }
if (descriptorSet->setHandle->constantsBuffer != nullptr) { if (descriptorSet->setHandle->constantsBuffer != nullptr) {
descriptorSet->setHandle->bind(); descriptorSet->setHandle->constantsBuffer->bind();
boundResources.add(PBufferAllocation(descriptorSet->setHandle->constantsBuffer)); boundResources.add(PBufferAllocation(descriptorSet->setHandle->constantsBuffer));
} }
@@ -299,7 +299,7 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
} }
} }
if (descriptorSet->setHandle->constantsBuffer != nullptr) { if (descriptorSet->setHandle->constantsBuffer != nullptr) {
descriptorSet->setHandle->bind(); descriptorSet->setHandle->constantsBuffer->bind();
boundResources.add(PBufferAllocation(descriptorSet->setHandle->constantsBuffer)); boundResources.add(PBufferAllocation(descriptorSet->setHandle->constantsBuffer));
} }
sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle(); sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
+3 -3
View File
@@ -29,9 +29,9 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
renderGraph.addPass(new LightCullingPass(graphics, scene)); renderGraph.addPass(new LightCullingPass(graphics, scene));
renderGraph.addPass(new ShadowPass(graphics, scene)); renderGraph.addPass(new ShadowPass(graphics, scene));
renderGraph.addPass(new BasePass(graphics, scene)); renderGraph.addPass(new BasePass(graphics, scene));
// renderGraph.addPass(new SimulationComputePass(graphics, scene)); renderGraph.addPass(new SimulationComputePass(graphics, scene));
// renderGraph.addPass(new SurfaceExtractPass(graphics, scene)); renderGraph.addPass(new SurfaceExtractPass(graphics, scene));
// renderGraph.addPass(new FluidRenderPass(graphics, scene)); renderGraph.addPass(new FluidRenderPass(graphics, scene));
renderGraph.addPass(new ToneMappingPass(graphics)); renderGraph.addPass(new ToneMappingPass(graphics));
renderGraph.setViewport(viewport); renderGraph.setViewport(viewport);
renderGraph.createRenderPass(); renderGraph.createRenderPass();