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
+1 -1
View File
@@ -10,7 +10,7 @@
"inheritEnvironments": [ "msvc_x64" ],
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
"buildRoot": "C:/Users/Dynamitos/Seele/bin/",
"installRoot": "C:/Program Files/Seele",
"installRoot": "C:/Program Files/Seele"
},
{
"name": "Release",
+28
View File
@@ -0,0 +1,28 @@
import Common;
struct DebugVertex
{
float3 position;
float3 color;
}
struct VertexOutput
{
float4 clipPosition : SV_Position;
float3 color : COLOR0;
};
[shader("vertex")]
VertexOutput vertexMain(DebugVertex input)
{
VertexOutput output;
output.clipPosition = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, float4(input.position, 1.0f)));
output.color = input.color;
return output;
}
[shader("pixel")]
float4 fragmentMain(VertexOutput input)
{
return float4(input.color, 1.0f);
}
+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);
}
+1 -5
View File
@@ -19,9 +19,7 @@ public:
void update(float deltaTime);
entt::entity createEntity()
{
auto result = registry.create();
std::cout << "Created " << (uint64_t)result << " at " << this << std::endl;
return result;
return registry.create();
}
void destroyEntity(entt::entity identifier)
{
@@ -30,8 +28,6 @@ public:
template<typename Component, typename... Args>
Component& attachComponent(entt::entity entity, Args&&... args)
{
std::cout << "Emplace " << (uint64_t)entity << std::endl;
std::cout << "Exists " << registry.valid(entity) << std::endl;
return registry.emplace<Component>(entity, std::forward<Args>(args)...);
}
template<typename Component>
+1
View File
@@ -20,6 +20,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
DepthPrepass(graphics, scene),
LightCullingPass(graphics, scene),
BasePass(graphics, scene),
DebugPass(graphics, scene),
SkyboxRenderPass(graphics, scene)
))
{
+2
View File
@@ -5,6 +5,7 @@
#include "Graphics/RenderPass/LightCullingPass.h"
#include "Graphics/RenderPass/BasePass.h"
#include "Graphics/RenderPass/SkyboxRenderPass.h"
#include "Graphics/RenderPass/DebugPass.h"
#include "System/KeyboardInput.h"
#ifdef WIN32
#include "Platform/Windows/GameInterface.h" // TODO
@@ -35,6 +36,7 @@ protected:
DepthPrepass,
LightCullingPass,
BasePass,
DebugPass,
SkyboxRenderPass
> renderGraph;