Fixing debug pass

This commit is contained in:
Dynamitos
2024-01-26 09:58:01 +01:00
parent 87417f483c
commit f1e1ce0541
12 changed files with 77 additions and 37 deletions
+6 -1
View File
@@ -71,6 +71,11 @@ void BasePass::render()
tLightGrid->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
depthAttachment->getTexture()->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
depthAttachment->getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
descriptorSets[INDEX_VIEW_PARAMS] = viewParamsSet;
descriptorSets[INDEX_LIGHT_ENV] = scene->getLightEnvironment()->getDescriptorSet();
@@ -191,7 +196,7 @@ void BasePass::publishOutputs()
void BasePass::createRenderPass()
{
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
Gfx::ORenderTargetLayout layout = new Gfx::RenderTargetLayout{
.colorAttachments = { colorAttachment },
+1 -1
View File
@@ -20,7 +20,7 @@ public:
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
private:
Gfx::ORenderTargetAttachment colorAttachment;
Gfx::PTexture2D depthBuffer;
Gfx::PRenderTargetAttachment depthAttachment;
Gfx::PShaderBuffer oLightIndexList;
Gfx::PShaderBuffer tLightIndexList;
Gfx::PTexture2D oLightGrid;
+34 -20
View File
@@ -23,6 +23,7 @@ DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene)
{
}
DebugPass::~DebugPass()
{
@@ -50,7 +51,7 @@ void DebugPass::render()
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
renderCommand->setViewport(viewport);
renderCommand->bindPipeline(pipeline);
renderCommand->bindDescriptor(descriptorSet);
renderCommand->bindDescriptor(viewParamsSet);
renderCommand->bindVertexBuffer({ debugVertices });
renderCommand->draw((uint32)gDebugVertices.size(), 1, 0, 0);
graphics->executeCommands(Array{renderCommand});
@@ -64,18 +65,6 @@ void DebugPass::endFrame()
void DebugPass::publishOutputs()
{
UniformBufferCreateInfo viewCreateInfo = {
.sourceData = DataSource {
.size = sizeof(ViewParameter),
.data = nullptr,
},
.dynamic = true
};
viewParamsBuffer = graphics->createUniformBuffer(viewCreateInfo);
descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout");
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
descriptorLayout->create();
}
void DebugPass::createRenderPass()
@@ -91,22 +80,47 @@ void DebugPass::createRenderPass()
renderPass = graphics->createRenderPass(std::move(layout), viewport);
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->addDescriptorLayout(0, viewParamsLayout);
pipelineLayout->create();
ShaderCreateInfo createInfo;
createInfo.name = "DebugVertex";
createInfo.mainModule = "Debug";
createInfo.entryPoint = "vertexMain";
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
ShaderCreateInfo createInfo = {
.mainModule = "Debug",
.additionalModules = { "Debug" },
.name = "DebugVertex",
.entryPoint = "vertexMain",
};
vertexShader = graphics->createVertexShader(createInfo);
createInfo.name = "DebugFragment";
createInfo.entryPoint = "fragmentMain";
fragmentShader = graphics->createFragmentShader(createInfo);
VertexInputStateCreateInfo inputCreate = {
.bindings = {
VertexInputBinding {
.binding = 0,
.stride = sizeof(DebugVertex),
.inputRate = Gfx::SE_VERTEX_INPUT_RATE_VERTEX,
},
},
.attributes = {
VertexInputAttribute {
.location = 0,
.binding = 0,
.format = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.offset = 0,
},
VertexInputAttribute {
.location = 1,
.binding = 0,
.format = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.offset = sizeof(Vector)
}
},
};
vertexInput = graphics->createVertexInput(inputCreate);
Gfx::LegacyPipelineCreateInfo gfxInfo;
gfxInfo.vertexInput = vertexInput;
gfxInfo.vertexShader = vertexShader;
gfxInfo.fragmentShader = fragmentShader;
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
+2 -3
View File
@@ -2,6 +2,7 @@
#include "RenderPass.h"
#include "Scene/Scene.h"
#include "Graphics/DebugVertex.h"
#include "Graphics/Pipeline.h"
namespace Seele
{
@@ -21,10 +22,8 @@ public:
virtual void publishOutputs() override;
virtual void createRenderPass() override;
private:
Gfx::OVertexInput vertexInput;
Gfx::OVertexBuffer debugVertices;
Gfx::OUniformBuffer viewParamsBuffer;
Gfx::ODescriptorLayout descriptorLayout;
Gfx::PDescriptorSet descriptorSet;
Gfx::OVertexShader vertexShader;
Gfx::OFragmentShader fragmentShader;
Gfx::PGraphicsPipeline pipeline;
@@ -40,10 +40,6 @@ void DepthPrepass::beginFrame(const Component::Camera& cam)
void DepthPrepass::render()
{
depthAttachment->getTexture()->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
Gfx::ShaderPermutation permutation;
if(graphics->supportMeshShading())
{
@@ -64,8 +64,6 @@ void LightCullingPass::render()
//computeCommand->dispatch(dispatchParams.numThreadGroups.x, dispatchParams.numThreadGroups.y, dispatchParams.numThreadGroups.z);
Array<Gfx::PComputeCommand> commands = {computeCommand};
graphics->executeCommands(commands);
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
//std::cout << "LightCulling render()" << std::endl;
//co_return;
}
+1
View File
@@ -37,6 +37,7 @@ Fence::Fence(PGraphics graphics)
Fence::~Fence()
{
vkWaitForFences(graphics->getDevice(), 1, &fence, true, 100000);
vkDestroyFence(graphics->getDevice(), fence, nullptr);
}