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
View File
+16
View File
@@ -0,0 +1,16 @@
import Common;
import VertexData;
import MaterialParameter;
struct StaticMeshVertexData : IVertexData
{
VertexAttributes getAttributes(uint index)
{
VertexAttributes attributes;
attributes.position_MS = float3(positions[3 * index + 0], positions[3 * index + 1], positions[3 * index + 2]);
attributes.vertexColor = float3(color[3 * index + 0], color[3 * index + 1], color[3 * index + 2]);
return attributes;
}
StructuredBuffer<float> positions;
StructuredBuffer<float> color;
};
+116 -126
View File
@@ -16,129 +16,119 @@ void Seele::addDebugVertices(Array<DebugVertex> verts)
gDebugVertices.addAll(verts); gDebugVertices.addAll(verts);
} }
//DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene) DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene)
// : RenderPass(graphics, scene) : RenderPass(graphics, scene)
//{ {
//
//} }
//DebugPass::~DebugPass() DebugPass::~DebugPass()
//{ {
//
//} }
//
//void DebugPass::beginFrame(const Component::Camera& cam) void DebugPass::beginFrame(const Component::Camera& cam)
//{ {
// RenderPass::beginFrame(cam); RenderPass::beginFrame(cam);
// DataSource uniformUpdate;
// VertexBufferCreateInfo vertexBufferInfo = {
// viewParams.viewMatrix = cam.getViewMatrix(); .sourceData = {
// viewParams.projectionMatrix = viewport->getProjectionMatrix(); .size = sizeof(DebugVertex) * gDebugVertices.size(),
// viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 1); .data = (uint8*)gDebugVertices.data(),
// viewParams.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())); },
// uniformUpdate.size = sizeof(ViewParameter); .vertexSize = sizeof(DebugVertex),
// uniformUpdate.data = (uint8*)&viewParams; .numVertices = (uint32)gDebugVertices.size(),
// viewParamsBuffer->updateContents(uniformUpdate); };
// descriptorLayout->reset(); debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
// descriptorSet = descriptorLayout->allocateDescriptorSet();
// descriptorSet->updateBuffer(0, viewParamsBuffer); }
// descriptorSet->writeChanges();
// void DebugPass::render()
// VertexBufferCreateInfo vertexBufferInfo = { {
// .sourceData = { graphics->beginRenderPass(renderPass);
// .size = sizeof(DebugVertex) * passData.vertices.size(), Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
// .data = (uint8*)passData.vertices.data(), renderCommand->setViewport(viewport);
// }, renderCommand->bindPipeline(pipeline);
// .vertexSize = sizeof(DebugVertex), renderCommand->bindDescriptor(descriptorSet);
// .numVertices = (uint32)passData.vertices.size(), renderCommand->bindVertexBuffer({ debugVertices });
// }; renderCommand->draw((uint32)gDebugVertices.size(), 1, 0, 0);
// debugVertices = graphics->createVertexBuffer(vertexBufferInfo); graphics->executeCommands(Array{renderCommand});
// graphics->endRenderPass();
//} }
//
//void DebugPass::render() void DebugPass::endFrame()
//{ {
// graphics->beginRenderPass(renderPass);
// Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender"); }
// renderCommand->setViewport(viewport);
// renderCommand->bindPipeline(pipeline); void DebugPass::publishOutputs()
// renderCommand->bindDescriptor(descriptorSet); {
// renderCommand->bindVertexBuffer({VertexInputStream(0, 0, debugVertices)}); UniformBufferCreateInfo viewCreateInfo = {
// renderCommand->draw((uint32)passData.vertices.size(), 1, 0, 0); .sourceData = DataSource {
// graphics->executeCommands(Array{renderCommand}); .size = sizeof(ViewParameter),
// graphics->endRenderPass(); .data = nullptr,
//} },
// .dynamic = true
//void DebugPass::endFrame() };
//{ viewParamsBuffer = graphics->createUniformBuffer(viewCreateInfo);
//
//} descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout");
// descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
//void DebugPass::publishOutputs() descriptorLayout->create();
//{
// UniformBufferCreateInfo viewCreateInfo = { pipelineLayout = graphics->createPipelineLayout();
// .sourceData = DataSource { pipelineLayout->addDescriptorLayout(0, descriptorLayout);
// .size = sizeof(ViewParameter), pipelineLayout->create();
// .data = nullptr, }
// },
// .dynamic = true void DebugPass::createRenderPass()
// }; {
// viewParamsBuffer = graphics->createUniformBuffer(viewCreateInfo); Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
// baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
// descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout"); Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
// descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
// descriptorLayout->create(); Gfx::ORenderTargetLayout layout = new Gfx::RenderTargetLayout{
// .colorAttachments = {baseColorAttachment},
// pipelineLayout = graphics->createPipelineLayout(); .depthAttachment = depthAttachment,
// pipelineLayout->addDescriptorLayout(0, descriptorLayout); };
// pipelineLayout->create(); renderPass = graphics->createRenderPass(std::move(layout), viewport);
//}
// ShaderCreateInfo createInfo;
//void DebugPass::createRenderPass() createInfo.name = "DebugVertex";
//{ createInfo.mainModule = "Debug";
// Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR"); createInfo.entryPoint = "vertexMain";
// baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD; createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
// Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH"); Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo);
// depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
// Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(baseColorAttachment, depthAttachment); createInfo.name = "DebugFragment";
// renderPass = graphics->createRenderPass(layout, viewport);
// createInfo.entryPoint = "fragmentMain";
// ShaderCreateInfo createInfo; Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo);
// createInfo.name = "DebugVertex";
// createInfo.mainModule = "Debug"; Gfx::OVertexDeclaration vertexDecl = graphics->createVertexDeclaration({
// createInfo.entryPoint = "vertexMain"; Gfx::VertexElement {
// createInfo.defines["INDEX_VIEW_PARAMS"] = "0"; .streamIndex = 0,
// Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo); .offset = offsetof(DebugVertex, position),
// .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
// createInfo.name = "DebugFragment"; .attributeIndex = 0,
// .stride = sizeof(DebugVertex),
// createInfo.entryPoint = "fragmentMain"; },
// Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo); Gfx::VertexElement {
// .streamIndex = 0,
// Gfx::PVertexDeclaration vertexDecl = graphics->createVertexDeclaration({ .offset = offsetof(DebugVertex, color),
// Gfx::VertexElement { .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
// .streamIndex = 0, .attributeIndex = 1,
// .offset = offsetof(DebugVertex, position), .stride = sizeof(DebugVertex),
// .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT, }
// .attributeIndex = 0, });
// .stride = sizeof(DebugVertex),
// }, GraphicsPipelineCreateInfo gfxInfo;
// Gfx::VertexElement { gfxInfo.vertexDeclaration = vertexDecl;
// .streamIndex = 0, gfxInfo.vertexShader = vertexShader;
// .offset = offsetof(DebugVertex, color), gfxInfo.fragmentShader = fragmentShader;
// .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT, gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
// .attributeIndex = 1, gfxInfo.rasterizationState.lineWidth = 5.f;
// .stride = sizeof(DebugVertex), gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
// } gfxInfo.pipelineLayout = pipelineLayout;
// }); gfxInfo.renderPass = renderPass;
// pipeline = graphics->createGraphicsPipeline(gfxInfo);
// 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() void GameView::reloadGame()
{ {
gameInterface.reload(AssetRegistry::getInstance()); gameInterface.reload();
systemGraph = new SystemGraph(); systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph); gameInterface.getGame()->setupScene(scene, systemGraph);