Adding basic timestamps

This commit is contained in:
Dynamitos
2024-07-01 12:17:04 +02:00
parent 966c64ca27
commit 8418cdbd11
21 changed files with 220 additions and 63 deletions
+5 -1
View File
@@ -92,6 +92,7 @@ void BasePass::render() {
transparentCulling->writeChanges();
query->beginQuery();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "BASEPASS");
graphics->beginRenderPass(renderPass);
Array<Gfx::ORenderCommand> commands;
@@ -294,6 +295,8 @@ void BasePass::render() {
graphics->endRenderPass();
query->endQuery();
timestamps->write(Gfx::SE_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, "END");
timestamps->end();
}
void BasePass::endFrame() {}
@@ -316,11 +319,12 @@ void BasePass::publishOutputs() {
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
resources->registerRenderPassOutput("BASEPASS_DEPTH", depthAttachment);
query = graphics->createPipelineStatisticsQuery();
query = graphics->createPipelineStatisticsQuery("BasePassPipelineStatistics");
resources->registerQueryOutput("BASEPASS_QUERY", query);
}
void BasePass::createRenderPass() {
timestamps = resources->requestTimestampQuery("TIMESTAMP");
cullingBuffer = resources->requestBuffer("CULLINGBUFFER");
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
@@ -40,6 +40,7 @@ class BasePass : public RenderPass {
Gfx::ODescriptorLayout lightCullingLayout;
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
Gfx::PShaderBuffer cullingBuffer;
};
@@ -47,6 +47,8 @@ void CachedDepthPass::beginFrame(const Component::Camera& cam) { RenderPass::beg
void CachedDepthPass::render() {
query->beginQuery();
timestamps->begin();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "CACHED");
graphics->beginRenderPass(renderPass);
Array<Gfx::ORenderCommand> commands;
@@ -165,8 +167,11 @@ void CachedDepthPass::publishOutputs() {
Gfx::RenderTargetAttachment(visibilityBuffer, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
resources->registerRenderPassOutput("VISIBILITY", visibilityAttachment);
query = graphics->createPipelineStatisticsQuery();
query = graphics->createPipelineStatisticsQuery("CachedPipelineStatistics");
resources->registerQueryOutput("CACHED_QUERY", query);
timestamps = graphics->createTimestampQuery(7, "Timestamps");
resources->registerTimestampQueryOutput("TIMESTAMP", timestamps);
}
void CachedDepthPass::createRenderPass() {
@@ -22,6 +22,7 @@ class CachedDepthPass : public RenderPass {
Gfx::OTexture2D visibilityBuffer;
Gfx::OPipelineLayout depthPrepassLayout;
Gfx::OPipelineStatisticsQuery query;
Gfx::OTimestampQuery timestamps;
Gfx::PShaderBuffer cullingBuffer;
};
@@ -71,6 +71,7 @@ DepthCullingPass::~DepthCullingPass() {}
void DepthCullingPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
void DepthCullingPass::render() {
query->beginQuery();
depthAttachment.getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, Gfx::SE_ACCESS_TRANSFER_READ_BIT,
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
@@ -80,6 +81,7 @@ void DepthCullingPass::render() {
set->updateBuffer(1, depthMipBuffer);
set->writeChanges();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "DEPTHMIP");
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("DepthMipGenCommand");
computeCommand->bindPipeline(depthInitialReduce);
computeCommand->bindDescriptor({viewParamsSet, set});
@@ -116,7 +118,7 @@ void DepthCullingPass::render() {
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
query->beginQuery();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "DEPTHCULL");
graphics->beginRenderPass(renderPass);
Array<Gfx::ORenderCommand> commands;
@@ -262,11 +264,12 @@ void DepthCullingPass::publishOutputs() {
depthMipGen = graphics->createComputePipeline(pipelineCreateInfo);
query = graphics->createPipelineStatisticsQuery();
query = graphics->createPipelineStatisticsQuery("DepthPipelineStatistics");
resources->registerQueryOutput("DEPTH_QUERY", query);
}
void DepthCullingPass::createRenderPass() {
timestamps = resources->requestTimestampQuery("TIMESTAMP");
cullingBuffer = resources->requestBuffer("CULLINGBUFFER");
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
@@ -33,6 +33,7 @@ class DepthCullingPass : public RenderPass {
Gfx::ODescriptorLayout depthAttachmentLayout;
Gfx::OPipelineLayout depthCullingLayout;
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
Gfx::OPipelineLayout depthComputeLayout;
Gfx::OComputeShader depthInitialReduceShader;
@@ -41,6 +41,7 @@ void LightCullingPass::beginFrame(const Component::Camera& cam) {
void LightCullingPass::render() {
query->beginQuery();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "LIGHTCULL");
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
cullingDescriptorSet->updateTexture(0, depthAttachment);
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
@@ -211,12 +212,14 @@ void LightCullingPass::publishOutputs() {
resources->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", Gfx::PTexture2D(oLightGrid));
resources->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", Gfx::PTexture2D(tLightGrid));
query = graphics->createPipelineStatisticsQuery("LightCullPipelineStatistics");
resources->registerQueryOutput("LIGHTCULL_QUERY", query);
}
void LightCullingPass::createRenderPass() {
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH").getTexture();
query = graphics->createPipelineStatisticsQuery();
resources->registerQueryOutput("LIGHTCULL_QUERY", query);
timestamps = resources->requestTimestampQuery("TIMESTAMP");
}
void LightCullingPass::setupFrustums() {
@@ -65,6 +65,7 @@ class LightCullingPass : public RenderPass {
Gfx::PComputePipeline cullingPipeline;
Gfx::PComputePipeline cullingEnabledPipeline;
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
};
DEFINE_REF(LightCullingPass)
} // namespace Seele
@@ -21,6 +21,8 @@ Gfx::PUniformBuffer RenderGraphResources::requestUniform(const std::string& outp
Gfx::PPipelineStatisticsQuery RenderGraphResources::requestQuery(const std::string& outputName) { return registeredQueries.at(outputName); }
Gfx::PTimestampQuery Seele::RenderGraphResources::requestTimestampQuery(const std::string& outputName) { return registeredTimestamps.at(outputName); }
void RenderGraphResources::registerRenderPassOutput(const std::string& outputName, Gfx::RenderTargetAttachment attachment) {
registeredAttachments[outputName] = attachment;
}
@@ -38,4 +40,8 @@ void RenderGraphResources::registerUniformOutput(const std::string& outputName,
void RenderGraphResources::registerQueryOutput(const std::string& outputName, Gfx::PPipelineStatisticsQuery query) {
registeredQueries[outputName] = query;
}
}
void Seele::RenderGraphResources::registerTimestampQueryOutput(const std::string& outputName, Gfx::PTimestampQuery query) {
registeredTimestamps[outputName] = query;
}
@@ -18,11 +18,13 @@ class RenderGraphResources {
Gfx::PShaderBuffer requestBuffer(const std::string& outputName);
Gfx::PUniformBuffer requestUniform(const std::string& outputName);
Gfx::PPipelineStatisticsQuery requestQuery(const std::string& outputName);
Gfx::PTimestampQuery requestTimestampQuery(const std::string& outputName);
void registerRenderPassOutput(const std::string& outputName, Gfx::RenderTargetAttachment attachment);
void registerTextureOutput(const std::string& outputName, Gfx::PTexture buffer);
void registerBufferOutput(const std::string& outputName, Gfx::PShaderBuffer buffer);
void registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer);
void registerQueryOutput(const std::string& outputName, Gfx::PPipelineStatisticsQuery query);
void registerTimestampQueryOutput(const std::string& outputName, Gfx::PTimestampQuery query);
protected:
Map<std::string, Gfx::RenderTargetAttachment> registeredAttachments;
@@ -30,6 +32,7 @@ class RenderGraphResources {
Map<std::string, Gfx::PShaderBuffer> registeredBuffers;
Map<std::string, Gfx::PUniformBuffer> registeredUniforms;
Map<std::string, Gfx::PPipelineStatisticsQuery> registeredQueries;
Map<std::string, Gfx::PTimestampQuery> registeredTimestamps;
};
DEFINE_REF(RenderGraphResources)
} // namespace Seele
@@ -28,6 +28,7 @@ void VisibilityPass::render() {
visibilitySet->writeChanges();
query->beginQuery();
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "VISIBILITY");
Gfx::OComputeCommand command = graphics->createComputeCommand("VisibilityCommand");
command->bindPipeline(visibilityPipeline);
command->bindDescriptor({viewParamsSet, visibilitySet});
@@ -85,7 +86,8 @@ void VisibilityPass::publishOutputs() {
});
resources->registerBufferOutput("CULLINGBUFFER", cullingBuffer);
query = graphics->createPipelineStatisticsQuery();
query = graphics->createPipelineStatisticsQuery("VisibilityPipelineStatistics");
timestamps = resources->requestTimestampQuery("TIMESTAMP");
resources->registerQueryOutput("VISIBILITY_QUERY", query);
}
@@ -24,6 +24,7 @@ class VisibilityPass : public RenderPass {
Gfx::OComputeShader visibilityShader;
Gfx::PComputePipeline visibilityPipeline;
Gfx::OPipelineStatisticsQuery query;
Gfx::PTimestampQuery timestamps;
// Holds culling information for every meshlet for each instance
Gfx::OShaderBuffer cullingBuffer;