|
|
@@ -50,53 +50,48 @@ Error VolumetricFog::init(const ConfigSet& config)
|
|
|
return Error::NONE;
|
|
|
}
|
|
|
|
|
|
-void VolumetricFog::run(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx)
|
|
|
+void VolumetricFog::populateRenderGraph(RenderingContext& ctx)
|
|
|
{
|
|
|
- CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
|
|
|
+ RenderGraphDescription& rgraph = ctx.m_renderGraphDescr;
|
|
|
|
|
|
- cmdb->bindShaderProgram(m_grProg);
|
|
|
+ m_runCtx.m_rt = rgraph.newRenderTarget(m_rtDescr);
|
|
|
|
|
|
- cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
|
|
|
- rgraphCtx.bindColorTexture(0, 1, m_r->getVolumetricLightingAccumulation().getRt());
|
|
|
+ ComputeRenderPassDescription& pass = rgraph.newComputeRenderPass("Vol fog");
|
|
|
|
|
|
- rgraphCtx.bindImage(0, 2, m_runCtx.m_rt, TextureSubresourceInfo());
|
|
|
+ pass.newDependency({m_runCtx.m_rt, TextureUsageBit::IMAGE_COMPUTE_WRITE});
|
|
|
+ pass.newDependency({m_r->getVolumetricLightingAccumulation().getRt(), TextureUsageBit::SAMPLED_COMPUTE});
|
|
|
|
|
|
- struct PushConsts
|
|
|
- {
|
|
|
- F32 m_fogScatteringCoeff;
|
|
|
- F32 m_fogAbsorptionCoeff;
|
|
|
- F32 m_density;
|
|
|
- F32 m_near;
|
|
|
- Vec3 m_fogDiffuse;
|
|
|
- F32 m_far;
|
|
|
- } regs;
|
|
|
+ pass.setWork([this, &ctx](RenderPassWorkContext& rgraphCtx) -> void {
|
|
|
+ CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
|
|
|
|
|
|
- regs.m_fogScatteringCoeff = m_fogScatteringCoeff;
|
|
|
- regs.m_fogAbsorptionCoeff = m_fogAbsorptionCoeff;
|
|
|
- regs.m_density = m_fogDensity;
|
|
|
- regs.m_fogDiffuse = m_fogDiffuseColor;
|
|
|
- regs.m_near = ctx.m_renderQueue->m_cameraNear;
|
|
|
- regs.m_far = ctx.m_renderQueue->m_cameraFar;
|
|
|
+ cmdb->bindShaderProgram(m_grProg);
|
|
|
|
|
|
- cmdb->setPushConstants(®s, sizeof(regs));
|
|
|
+ cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
|
|
|
+ rgraphCtx.bindColorTexture(0, 1, m_r->getVolumetricLightingAccumulation().getRt());
|
|
|
|
|
|
- dispatchPPCompute(cmdb, m_workgroupSize[0], m_workgroupSize[1], m_volumeSize[0], m_volumeSize[1]);
|
|
|
-}
|
|
|
+ rgraphCtx.bindImage(0, 2, m_runCtx.m_rt, TextureSubresourceInfo());
|
|
|
|
|
|
-void VolumetricFog::populateRenderGraph(RenderingContext& ctx)
|
|
|
-{
|
|
|
- RenderGraphDescription& rgraph = ctx.m_renderGraphDescr;
|
|
|
+ struct PushConsts
|
|
|
+ {
|
|
|
+ F32 m_fogScatteringCoeff;
|
|
|
+ F32 m_fogAbsorptionCoeff;
|
|
|
+ F32 m_density;
|
|
|
+ F32 m_near;
|
|
|
+ Vec3 m_fogDiffuse;
|
|
|
+ F32 m_far;
|
|
|
+ } regs;
|
|
|
|
|
|
- m_runCtx.m_rt = rgraph.newRenderTarget(m_rtDescr);
|
|
|
+ regs.m_fogScatteringCoeff = m_fogScatteringCoeff;
|
|
|
+ regs.m_fogAbsorptionCoeff = m_fogAbsorptionCoeff;
|
|
|
+ regs.m_density = m_fogDensity;
|
|
|
+ regs.m_fogDiffuse = m_fogDiffuseColor;
|
|
|
+ regs.m_near = ctx.m_renderQueue->m_cameraNear;
|
|
|
+ regs.m_far = ctx.m_renderQueue->m_cameraFar;
|
|
|
|
|
|
- ComputeRenderPassDescription& pass = rgraph.newComputeRenderPass("Vol fog");
|
|
|
+ cmdb->setPushConstants(®s, sizeof(regs));
|
|
|
|
|
|
- pass.setWork([this, &ctx](RenderPassWorkContext& rgraphCtx) -> void {
|
|
|
- run(ctx, rgraphCtx);
|
|
|
+ dispatchPPCompute(cmdb, m_workgroupSize[0], m_workgroupSize[1], m_volumeSize[0], m_volumeSize[1]);
|
|
|
});
|
|
|
-
|
|
|
- pass.newDependency({m_runCtx.m_rt, TextureUsageBit::IMAGE_COMPUTE_WRITE});
|
|
|
- pass.newDependency({m_r->getVolumetricLightingAccumulation().getRt(), TextureUsageBit::SAMPLED_COMPUTE});
|
|
|
}
|
|
|
|
|
|
} // end namespace anki
|