Starting to readd Debug renderpass

This commit is contained in:
Dynamitos
2024-01-11 21:40:46 +01:00
parent f17f05433f
commit c0da7d77a1
4 changed files with 133 additions and 127 deletions
+116 -126
View File
@@ -16,129 +16,119 @@ void Seele::addDebugVertices(Array<DebugVertex> verts)
gDebugVertices.addAll(verts);
}
//DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene)
// : RenderPass(graphics, scene)
//{
//
//}
//DebugPass::~DebugPass()
//{
//
//}
//
//void DebugPass::beginFrame(const Component::Camera& cam)
//{
// RenderPass::beginFrame(cam);
// DataSource uniformUpdate;
//
// viewParams.viewMatrix = cam.getViewMatrix();
// viewParams.projectionMatrix = viewport->getProjectionMatrix();
// viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 1);
// viewParams.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
// uniformUpdate.size = sizeof(ViewParameter);
// uniformUpdate.data = (uint8*)&viewParams;
// viewParamsBuffer->updateContents(uniformUpdate);
// descriptorLayout->reset();
// descriptorSet = descriptorLayout->allocateDescriptorSet();
// descriptorSet->updateBuffer(0, viewParamsBuffer);
// descriptorSet->writeChanges();
//
// VertexBufferCreateInfo vertexBufferInfo = {
// .sourceData = {
// .size = sizeof(DebugVertex) * passData.vertices.size(),
// .data = (uint8*)passData.vertices.data(),
// },
// .vertexSize = sizeof(DebugVertex),
// .numVertices = (uint32)passData.vertices.size(),
// };
// debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
//
//}
//
//void DebugPass::render()
//{
// graphics->beginRenderPass(renderPass);
// Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
// renderCommand->setViewport(viewport);
// renderCommand->bindPipeline(pipeline);
// renderCommand->bindDescriptor(descriptorSet);
// renderCommand->bindVertexBuffer({VertexInputStream(0, 0, debugVertices)});
// renderCommand->draw((uint32)passData.vertices.size(), 1, 0, 0);
// graphics->executeCommands(Array{renderCommand});
// graphics->endRenderPass();
//}
//
//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();
//
// pipelineLayout = graphics->createPipelineLayout();
// pipelineLayout->addDescriptorLayout(0, descriptorLayout);
// pipelineLayout->create();
//}
//
//void DebugPass::createRenderPass()
//{
// Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
// baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
// Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
// depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
// Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(baseColorAttachment, depthAttachment);
// renderPass = graphics->createRenderPass(layout, viewport);
//
// ShaderCreateInfo createInfo;
// createInfo.name = "DebugVertex";
// createInfo.mainModule = "Debug";
// createInfo.entryPoint = "vertexMain";
// createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
// Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo);
//
// createInfo.name = "DebugFragment";
//
// createInfo.entryPoint = "fragmentMain";
// Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo);
//
// Gfx::PVertexDeclaration vertexDecl = graphics->createVertexDeclaration({
// Gfx::VertexElement {
// .streamIndex = 0,
// .offset = offsetof(DebugVertex, position),
// .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
// .attributeIndex = 0,
// .stride = sizeof(DebugVertex),
// },
// Gfx::VertexElement {
// .streamIndex = 0,
// .offset = offsetof(DebugVertex, color),
// .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
// .attributeIndex = 1,
// .stride = sizeof(DebugVertex),
// }
// });
//
// GraphicsPipelineCreateInfo gfxInfo;
// gfxInfo.vertexDeclaration = vertexDecl;
// gfxInfo.vertexShader = vertexShader;
// gfxInfo.fragmentShader = fragmentShader;
// gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
// gfxInfo.rasterizationState.lineWidth = 5.f;
// gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
// gfxInfo.pipelineLayout = pipelineLayout;
// gfxInfo.renderPass = renderPass;
// pipeline = graphics->createGraphicsPipeline(gfxInfo);
//}
DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
{
}
DebugPass::~DebugPass()
{
}
void DebugPass::beginFrame(const Component::Camera& cam)
{
RenderPass::beginFrame(cam);
VertexBufferCreateInfo vertexBufferInfo = {
.sourceData = {
.size = sizeof(DebugVertex) * gDebugVertices.size(),
.data = (uint8*)gDebugVertices.data(),
},
.vertexSize = sizeof(DebugVertex),
.numVertices = (uint32)gDebugVertices.size(),
};
debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
}
void DebugPass::render()
{
graphics->beginRenderPass(renderPass);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
renderCommand->setViewport(viewport);
renderCommand->bindPipeline(pipeline);
renderCommand->bindDescriptor(descriptorSet);
renderCommand->bindVertexBuffer({ debugVertices });
renderCommand->draw((uint32)gDebugVertices.size(), 1, 0, 0);
graphics->executeCommands(Array{renderCommand});
graphics->endRenderPass();
}
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();
pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
}
void DebugPass::createRenderPass()
{
Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
Gfx::ORenderTargetLayout layout = new Gfx::RenderTargetLayout{
.colorAttachments = {baseColorAttachment},
.depthAttachment = depthAttachment,
};
renderPass = graphics->createRenderPass(std::move(layout), viewport);
ShaderCreateInfo createInfo;
createInfo.name = "DebugVertex";
createInfo.mainModule = "Debug";
createInfo.entryPoint = "vertexMain";
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo);
createInfo.name = "DebugFragment";
createInfo.entryPoint = "fragmentMain";
Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo);
Gfx::OVertexDeclaration vertexDecl = graphics->createVertexDeclaration({
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, position),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 0,
.stride = sizeof(DebugVertex),
},
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, color),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 1,
.stride = sizeof(DebugVertex),
}
});
GraphicsPipelineCreateInfo gfxInfo;
gfxInfo.vertexDeclaration = vertexDecl;
gfxInfo.vertexShader = vertexShader;
gfxInfo.fragmentShader = fragmentShader;
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
gfxInfo.rasterizationState.lineWidth = 5.f;
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
gfxInfo.pipelineLayout = pipelineLayout;
gfxInfo.renderPass = renderPass;
pipeline = graphics->createGraphicsPipeline(gfxInfo);
}
+1 -1
View File
@@ -81,7 +81,7 @@ void GameView::applyArea(URect rect)
void GameView::reloadGame()
{
gameInterface.reload(AssetRegistry::getInstance());
gameInterface.reload();
systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph);