Fixed buffer staging
This commit is contained in:
@@ -45,11 +45,7 @@ CachedDepthPass::~CachedDepthPass() {}
|
||||
|
||||
void CachedDepthPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
||||
|
||||
uint64 numFragments = 0;
|
||||
|
||||
void CachedDepthPass::render() {
|
||||
occlusionQuery->resetQuery();
|
||||
occlusionQuery->beginQuery();
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
|
||||
@@ -145,14 +141,11 @@ void CachedDepthPass::render() {
|
||||
|
||||
graphics->executeCommands(std::move(commands));
|
||||
graphics->endRenderPass();
|
||||
occlusionQuery->endQuery();
|
||||
numFragments = occlusionQuery->getResults();
|
||||
}
|
||||
|
||||
void CachedDepthPass::endFrame() {}
|
||||
|
||||
void CachedDepthPass::publishOutputs() {
|
||||
occlusionQuery = graphics->createOcclusionQuery();
|
||||
// If we render to a part of an image, the depth buffer itself must
|
||||
// still match the size of the whole image or their coordinate systems go out of sync
|
||||
TextureCreateInfo depthBufferInfo = {
|
||||
|
||||
@@ -22,7 +22,6 @@ class CachedDepthPass : public RenderPass {
|
||||
Gfx::OTexture2D visibilityBuffer;
|
||||
Gfx::OPipelineLayout depthPrepassLayout;
|
||||
|
||||
Gfx::OOcclusionQuery occlusionQuery;
|
||||
Gfx::PShaderBuffer cullingBuffer;
|
||||
};
|
||||
DEFINE_REF(CachedDepthPass)
|
||||
|
||||
@@ -54,8 +54,6 @@ DepthCullingPass::~DepthCullingPass() {}
|
||||
|
||||
void DepthCullingPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
||||
|
||||
extern uint64 numFragments;
|
||||
|
||||
void DepthCullingPass::render() {
|
||||
depthAttachment.getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, Gfx::SE_ACCESS_TRANSFER_READ_BIT,
|
||||
@@ -78,8 +76,6 @@ void DepthCullingPass::render() {
|
||||
set->updateTexture(0, Gfx::PTexture2D(depthMipTexture));
|
||||
set->writeChanges();
|
||||
|
||||
occlusionQuery->resetQuery();
|
||||
occlusionQuery->beginQuery();
|
||||
graphics->beginRenderPass(renderPass);
|
||||
if (useDepthCulling) {
|
||||
|
||||
@@ -177,8 +173,6 @@ void DepthCullingPass::render() {
|
||||
graphics->executeCommands(std::move(commands));
|
||||
}
|
||||
graphics->endRenderPass();
|
||||
occlusionQuery->endQuery();
|
||||
std::cout << "Occlusion fragments: " << occlusionQuery->getResults() + numFragments << std::endl;
|
||||
// Sync depth read/write with compute read
|
||||
depthAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
@@ -192,8 +186,6 @@ void DepthCullingPass::render() {
|
||||
void DepthCullingPass::endFrame() {}
|
||||
|
||||
void DepthCullingPass::publishOutputs() {
|
||||
occlusionQuery = graphics->createOcclusionQuery();
|
||||
|
||||
uint32 width = viewport->getOwner()->getFramebufferWidth();
|
||||
uint32 height = viewport->getOwner()->getFramebufferHeight();
|
||||
uint32 mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
|
||||
|
||||
@@ -23,7 +23,6 @@ class DepthCullingPass : public RenderPass {
|
||||
Gfx::ODescriptorLayout depthTextureLayout;
|
||||
Gfx::OPipelineLayout depthPrepassLayout;
|
||||
|
||||
Gfx::OOcclusionQuery occlusionQuery;
|
||||
Gfx::PShaderBuffer cullingBuffer;
|
||||
};
|
||||
DEFINE_REF(DepthCullingPass)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "RenderGraph.h"
|
||||
#include "Scene/Scene.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
extern bool useLightCulling;
|
||||
@@ -184,10 +183,13 @@ void LightCullingPass::publishOutputs() {
|
||||
structInfo.name = "tLightIndexCounter";
|
||||
tLightIndexCounter = graphics->createShaderBuffer(structInfo);
|
||||
structInfo = {
|
||||
.sourceData = {.size = (uint32)sizeof(uint32) * dispatchParams.numThreadGroups.x * dispatchParams.numThreadGroups.y *
|
||||
dispatchParams.numThreadGroups.z * 8192,
|
||||
.data = nullptr,
|
||||
.owner = Gfx::QueueType::COMPUTE},
|
||||
.sourceData =
|
||||
{
|
||||
.size = (uint32)sizeof(uint32) * dispatchParams.numThreadGroups.x * dispatchParams.numThreadGroups.y *
|
||||
dispatchParams.numThreadGroups.z * 8192,
|
||||
.data = nullptr,
|
||||
.owner = Gfx::QueueType::COMPUTE,
|
||||
},
|
||||
.dynamic = false,
|
||||
.name = "oLightIndexList",
|
||||
};
|
||||
@@ -229,7 +231,10 @@ void LightCullingPass::setupFrustums() {
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
});
|
||||
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_ONLY_BIT});
|
||||
.binding = 1,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
.access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_ONLY_BIT,
|
||||
});
|
||||
frustumLayout = graphics->createPipelineLayout("FrustumLayout");
|
||||
frustumLayout->addDescriptorLayout(viewParamsLayout);
|
||||
frustumLayout->addDescriptorLayout(dispatchParamsLayout);
|
||||
@@ -251,17 +256,27 @@ void LightCullingPass::setupFrustums() {
|
||||
frustumPipeline = graphics->createComputePipeline(pipelineInfo);
|
||||
|
||||
Gfx::OUniformBuffer frustumDispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {.size = sizeof(DispatchParams), .data = (uint8*)&dispatchParams, .owner = Gfx::QueueType::COMPUTE},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(DispatchParams),
|
||||
.data = (uint8*)&dispatchParams,
|
||||
.owner = Gfx::QueueType::COMPUTE,
|
||||
},
|
||||
.dynamic = false,
|
||||
.name = "FrustumDispatch"});
|
||||
.name = "FrustumDispatch",
|
||||
});
|
||||
|
||||
frustumBuffer = graphics->createShaderBuffer(
|
||||
ShaderBufferCreateInfo{.sourceData = {.size = sizeof(Frustum) * numThreads.x * numThreads.y * numThreads.z,
|
||||
.data = nullptr,
|
||||
.owner = Gfx::QueueType::COMPUTE},
|
||||
.numElements = numThreads.x * numThreads.y * numThreads.z,
|
||||
.dynamic = false,
|
||||
.name = "FrustumBuffer"});
|
||||
frustumBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(Frustum) * numThreads.x * numThreads.y * numThreads.z,
|
||||
.data = nullptr,
|
||||
.owner = Gfx::QueueType::COMPUTE,
|
||||
},
|
||||
.numElements = numThreads.x * numThreads.y * numThreads.z,
|
||||
.dynamic = false,
|
||||
.name = "FrustumBuffer",
|
||||
});
|
||||
|
||||
Gfx::PDescriptorSet dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
||||
dispatchParamsSet->updateBuffer(0, frustumDispatchParamsBuffer);
|
||||
|
||||
@@ -34,7 +34,6 @@ void VisibilityPass::render() {
|
||||
Array<Gfx::OComputeCommand> commands;
|
||||
commands.add(std::move(command));
|
||||
graphics->executeCommands(std::move(commands));
|
||||
|
||||
cullingBuffer->pipelineBarrier(Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT);
|
||||
|
||||
Reference in New Issue
Block a user