Fixed validation errors due to debug draw
This commit is contained in:
parent
82e0e4df5c
commit
f0ef9fc0cf
|
@ -95,18 +95,26 @@ namespace SHADE
|
||||||
// Get Current frame index
|
// Get Current frame index
|
||||||
const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex();
|
const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex();
|
||||||
|
|
||||||
// Set Pipelin
|
|
||||||
cmdBuffer->BindPipeline(GFX_SYSTEM->GetDebugDrawPipeline());
|
|
||||||
cmdBuffer->SetLineWidth(LineWidth);
|
|
||||||
|
|
||||||
// Don't draw if no points
|
// Don't draw if no points
|
||||||
if (numPoints[FRAME_IDX] > 0)
|
if (numPoints[FRAME_IDX] > 0)
|
||||||
{
|
{
|
||||||
|
cmdBuffer->BindPipeline(GFX_SYSTEM->GetDebugDrawPipeline());
|
||||||
|
cmdBuffer->SetLineWidth(LineWidth);
|
||||||
cmdBuffer->BindVertexBuffer(0, vertexBuffers[FRAME_IDX], 0);
|
cmdBuffer->BindVertexBuffer(0, vertexBuffers[FRAME_IDX], 0);
|
||||||
cmdBuffer->DrawArrays(numPoints[FRAME_IDX], 1, 0, 0);
|
cmdBuffer->DrawArrays(numPoints[FRAME_IDX], 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
auto subPassWithDepth = renderGraph->GetNode("Debug Draw with Depth")->GetSubpass("Debug Draw with Depth");
|
||||||
|
subPassWithDepth->AddExteriorDrawCalls([this, GFX_SYSTEM](Handle<SHVkCommandBuffer>& cmdBuffer)
|
||||||
|
{
|
||||||
|
// Get Current frame index
|
||||||
|
const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex();
|
||||||
|
|
||||||
|
// Don't draw if no points
|
||||||
if (numPersistentPoints[FRAME_IDX] > 0)
|
if (numPersistentPoints[FRAME_IDX] > 0)
|
||||||
{
|
{
|
||||||
|
cmdBuffer->BindPipeline(GFX_SYSTEM->GetDebugDrawDepthPipeline());
|
||||||
|
cmdBuffer->SetLineWidth(LineWidth);
|
||||||
cmdBuffer->BindVertexBuffer(0, persistentVertexBuffers[FRAME_IDX], 0);
|
cmdBuffer->BindVertexBuffer(0, persistentVertexBuffers[FRAME_IDX], 0);
|
||||||
cmdBuffer->DrawArrays(numPersistentPoints[FRAME_IDX], 1, 0, 0);
|
cmdBuffer->DrawArrays(numPersistentPoints[FRAME_IDX], 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a line between two points in world space that will persist until
|
/// Renders a line between two points in world space that will persist until
|
||||||
/// ClearPersistentDraws() is called.
|
/// ClearPersistentDraws() is called. These lines are depth tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the line.</param>
|
/// <param name="color">Colour of the line.</param>
|
||||||
/// <param name="startPt">First point of the line.</param>
|
/// <param name="startPt">First point of the line.</param>
|
||||||
|
@ -139,7 +139,7 @@ namespace SHADE
|
||||||
void DrawPersistentLine(const SHVec4& color, const SHVec3& startPt, const SHVec3& endPt);
|
void DrawPersistentLine(const SHVec4& color, const SHVec3& startPt, const SHVec3& endPt);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a triangle indicated by three points in world space that will persist
|
/// Renders a triangle indicated by three points in world space that will persist
|
||||||
/// until ClearPersistentDraws() is called.
|
/// until ClearPersistentDraws() is called. These lines are depth tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the triangle.</param>
|
/// <param name="color">Colour of the triangle.</param>
|
||||||
/// <param name="pt1">First point of the triangle.</param>
|
/// <param name="pt1">First point of the triangle.</param>
|
||||||
|
@ -148,7 +148,7 @@ namespace SHADE
|
||||||
void DrawPersistentTri(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3);
|
void DrawPersistentTri(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a quadrilateral indicated by four points in world space that will persist
|
/// Renders a quadrilateral indicated by four points in world space that will persist
|
||||||
/// until ClearPersistentDraws() is called.
|
/// until ClearPersistentDraws() is called. These lines are depth tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the quadrilateral.</param>
|
/// <param name="color">Colour of the quadrilateral.</param>
|
||||||
/// <param name="pt1">First point of the triangle.</param>
|
/// <param name="pt1">First point of the triangle.</param>
|
||||||
|
@ -158,14 +158,16 @@ namespace SHADE
|
||||||
void DrawPersistentQuad(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3, const SHVec3& pt4);
|
void DrawPersistentQuad(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3, const SHVec3& pt4);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a polygon indicated by the specified set of points in world space that
|
/// Renders a polygon indicated by the specified set of points in world space that
|
||||||
/// will persist until ClearPersistentDraws() is called.
|
/// will persist until ClearPersistentDraws() is called. These lines are depth
|
||||||
|
/// tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the polygon.</param>
|
/// <param name="color">Colour of the polygon.</param>
|
||||||
/// <param name="pointList">List of points for the polygon.</param>
|
/// <param name="pointList">List of points for the polygon.</param>
|
||||||
void DrawPersistentPoly(const SHVec4& color, std::initializer_list<SHVec3> pointList);
|
void DrawPersistentPoly(const SHVec4& color, std::initializer_list<SHVec3> pointList);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a polygon indicated by the specified set of points in world space that
|
/// Renders a polygon indicated by the specified set of points in world space that
|
||||||
/// will persist until ClearPersistentDraws() is called.
|
/// will persist until ClearPersistentDraws() is called. These lines are depth
|
||||||
|
/// tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="IterType">Iterator for a STL-like container.</typeparam>
|
/// <typeparam name="IterType">Iterator for a STL-like container.</typeparam>
|
||||||
/// <param name="color">Colour of the polygon.</param>
|
/// <param name="color">Colour of the polygon.</param>
|
||||||
|
@ -179,7 +181,8 @@ namespace SHADE
|
||||||
void DrawPersistentPoly(const SHVec4& color, IterType pointListBegin, IterType pointListEnd);
|
void DrawPersistentPoly(const SHVec4& color, IterType pointListBegin, IterType pointListEnd);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a wireframe cube centered around the position specified in world space
|
/// Renders a wireframe cube centered around the position specified in world space
|
||||||
/// that will persist until ClearPersistentDraws() is called.
|
/// that will persist until ClearPersistentDraws() is called. These lines are depth
|
||||||
|
/// tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the cube.</param>
|
/// <param name="color">Colour of the cube.</param>
|
||||||
/// <param name="pos">Position where the cube wil be centered at.</param>
|
/// <param name="pos">Position where the cube wil be centered at.</param>
|
||||||
|
@ -187,7 +190,8 @@ namespace SHADE
|
||||||
void DrawPersistentCube(const SHVec4& color, const SHVec3& pos, const SHVec3& size);
|
void DrawPersistentCube(const SHVec4& color, const SHVec3& pos, const SHVec3& size);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders a wireframe sphere centered around the position specified in world space
|
/// Renders a wireframe sphere centered around the position specified in world space
|
||||||
/// that will persist until ClearPersistentDraws() is called.
|
/// that will persist until ClearPersistentDraws() is called. These lines are depth
|
||||||
|
/// tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Colour of the sphere.</param>
|
/// <param name="color">Colour of the sphere.</param>
|
||||||
/// <param name="pos">Position where the sphere wil be centered at.</param>
|
/// <param name="pos">Position where the sphere wil be centered at.</param>
|
||||||
|
@ -241,13 +245,6 @@ namespace SHADE
|
||||||
void drawCube(std::vector<PointVertex>& storage, const SHVec4& color, const SHVec3& pos, const SHVec3& size);
|
void drawCube(std::vector<PointVertex>& storage, const SHVec4& color, const SHVec3& pos, const SHVec3& size);
|
||||||
void drawSphere(std::vector<PointVertex>& storage, const SHVec4& color, const SHVec3& pos, double radius);
|
void drawSphere(std::vector<PointVertex>& storage, const SHVec4& color, const SHVec3& pos, double radius);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename IterType>
|
|
||||||
void SHADE::SHDebugDrawSystem::DrawPersistentPoly(const SHVec4& color, IterType pointListBegin, IterType pointListEnd)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "SHDebugDrawSystem.hpp"
|
#include "SHDebugDrawSystem.hpp"
|
|
@ -186,8 +186,14 @@ namespace SHADE
|
||||||
// deferred composite
|
// deferred composite
|
||||||
gBufferNode->AddNodeCompute(deferredCompositeShader, { "Position", "Normals", "Albedo", "Light Layer Indices", "Scene" });
|
gBufferNode->AddNodeCompute(deferredCompositeShader, { "Position", "Normals", "Albedo", "Light Layer Indices", "Scene" });
|
||||||
|
|
||||||
// Set up Debug Draw Pass
|
// Set up Debug Draw Passes
|
||||||
auto debugDrawNode = worldRenderGraph->AddNode("Debug Draw", { "Scene" }, {"G-Buffer"});
|
// - Depth Tested
|
||||||
|
auto debugDrawNodeDepth = worldRenderGraph->AddNode("Debug Draw with Depth", { "Scene", "Depth Buffer" }, {"G-Buffer"});
|
||||||
|
auto debugDrawDepthSubpass = debugDrawNodeDepth->AddSubpass("Debug Draw with Depth");
|
||||||
|
debugDrawDepthSubpass->AddColorOutput("Scene");
|
||||||
|
debugDrawDepthSubpass->AddDepthOutput("Depth Buffer");
|
||||||
|
// - No Depth Test
|
||||||
|
auto debugDrawNode = worldRenderGraph->AddNode("Debug Draw", { "Scene" }, { "Debug Draw with Depth" });
|
||||||
auto debugDrawSubpass = debugDrawNode->AddSubpass("Debug Draw");
|
auto debugDrawSubpass = debugDrawNode->AddSubpass("Debug Draw");
|
||||||
debugDrawSubpass->AddColorOutput("Scene");
|
debugDrawSubpass->AddColorOutput("Scene");
|
||||||
|
|
||||||
|
@ -209,53 +215,8 @@ namespace SHADE
|
||||||
defaultMaterial = AddMaterial(defaultVertShader, defaultFragShader, gBufferSubpass);
|
defaultMaterial = AddMaterial(defaultVertShader, defaultFragShader, gBufferSubpass);
|
||||||
|
|
||||||
// Create debug draw pipeline
|
// Create debug draw pipeline
|
||||||
auto debugDrawPipelineLayout = resourceManager.Create<SHVkPipelineLayout>
|
debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass);
|
||||||
(
|
debugDrawDepthPipeline = createDebugDrawPipeline(debugDrawNodeDepth->GetRenderpass(), debugDrawDepthSubpass);
|
||||||
device, SHPipelineLayoutParams
|
|
||||||
{
|
|
||||||
.shaderModules = { debugVertShader, debugFragShader },
|
|
||||||
.globalDescSetLayouts = SHGraphicsGlobalData::GetDescSetLayouts()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
debugDrawPipeline = resourceManager.Create<SHVkPipeline>(device, debugDrawPipelineLayout, nullptr, debugDrawNode->GetRenderpass(), debugDrawSubpass);
|
|
||||||
debugDrawPipeline->GetPipelineState().SetRasterizationState(SHRasterizationState
|
|
||||||
{
|
|
||||||
.polygonMode = vk::PolygonMode::eLine,
|
|
||||||
.cull_mode = vk::CullModeFlagBits::eNone
|
|
||||||
});
|
|
||||||
debugDrawPipeline->GetPipelineState().SetInputAssemblyState(SHInputAssemblyState
|
|
||||||
{
|
|
||||||
.topology = vk::PrimitiveTopology::eLineList
|
|
||||||
});
|
|
||||||
|
|
||||||
SHVertexInputState debugDrawVertexInputState;
|
|
||||||
debugDrawVertexInputState.AddBinding(false, true, { SHVertexAttribute(SHAttribFormat::FLOAT_4D), SHVertexAttribute(SHAttribFormat::FLOAT_4D) });
|
|
||||||
debugDrawPipeline->GetPipelineState().SetVertexInputState(debugDrawVertexInputState);
|
|
||||||
SHColorBlendState colorBlendState{};
|
|
||||||
colorBlendState.logic_op_enable = VK_FALSE;
|
|
||||||
colorBlendState.logic_op = vk::LogicOp::eCopy;
|
|
||||||
|
|
||||||
auto const& subpassColorReferences = debugDrawSubpass->GetColorAttachmentReferences();
|
|
||||||
colorBlendState.attachments.reserve(subpassColorReferences.size());
|
|
||||||
|
|
||||||
for (auto& att : subpassColorReferences)
|
|
||||||
{
|
|
||||||
colorBlendState.attachments.push_back(vk::PipelineColorBlendAttachmentState
|
|
||||||
{
|
|
||||||
.blendEnable = SHVkUtil::IsBlendCompatible(debugDrawSubpass->GetFormatFromAttachmentReference(att.attachment)),
|
|
||||||
.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha,
|
|
||||||
.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha,
|
|
||||||
.colorBlendOp = vk::BlendOp::eAdd,
|
|
||||||
.srcAlphaBlendFactor = vk::BlendFactor::eOne,
|
|
||||||
.dstAlphaBlendFactor = vk::BlendFactor::eZero,
|
|
||||||
.alphaBlendOp = vk::BlendOp::eAdd,
|
|
||||||
.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
debugDrawPipeline->GetPipelineState().SetColorBlenState(colorBlendState);
|
|
||||||
debugDrawPipeline->ConstructPipeline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGraphicsSystem::InitMiddleEnd(void) noexcept
|
void SHGraphicsSystem::InitMiddleEnd(void) noexcept
|
||||||
|
@ -867,5 +828,57 @@ namespace SHADE
|
||||||
return worldRenderGraph->GetNode(G_BUFFER_RENDER_GRAPH_NODE_NAME.data());
|
return worldRenderGraph->GetNode(G_BUFFER_RENDER_GRAPH_NODE_NAME.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<SHVkPipeline> SHGraphicsSystem::createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass)
|
||||||
|
{
|
||||||
|
auto pipelineLayout = resourceManager.Create<SHVkPipelineLayout>
|
||||||
|
(
|
||||||
|
device, SHPipelineLayoutParams
|
||||||
|
{
|
||||||
|
.shaderModules = { debugVertShader, debugFragShader },
|
||||||
|
.globalDescSetLayouts = SHGraphicsGlobalData::GetDescSetLayouts()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auto pipeline = resourceManager.Create<SHVkPipeline>(device, pipelineLayout, nullptr, renderPass, subpass);
|
||||||
|
pipeline->GetPipelineState().SetRasterizationState(SHRasterizationState
|
||||||
|
{
|
||||||
|
.polygonMode = vk::PolygonMode::eLine,
|
||||||
|
.cull_mode = vk::CullModeFlagBits::eNone
|
||||||
|
});
|
||||||
|
pipeline->GetPipelineState().SetInputAssemblyState(SHInputAssemblyState
|
||||||
|
{
|
||||||
|
.topology = vk::PrimitiveTopology::eLineList
|
||||||
|
});
|
||||||
|
|
||||||
|
SHVertexInputState debugDrawVertexInputState;
|
||||||
|
debugDrawVertexInputState.AddBinding(false, true, { SHVertexAttribute(SHAttribFormat::FLOAT_4D), SHVertexAttribute(SHAttribFormat::FLOAT_4D) });
|
||||||
|
pipeline->GetPipelineState().SetVertexInputState(debugDrawVertexInputState);
|
||||||
|
SHColorBlendState colorBlendState{};
|
||||||
|
colorBlendState.logic_op_enable = VK_FALSE;
|
||||||
|
colorBlendState.logic_op = vk::LogicOp::eCopy;
|
||||||
|
|
||||||
|
auto const& subpassColorReferences = subpass->GetColorAttachmentReferences();
|
||||||
|
colorBlendState.attachments.reserve(subpassColorReferences.size());
|
||||||
|
|
||||||
|
for (auto& att : subpassColorReferences)
|
||||||
|
{
|
||||||
|
colorBlendState.attachments.push_back(vk::PipelineColorBlendAttachmentState
|
||||||
|
{
|
||||||
|
.blendEnable = SHVkUtil::IsBlendCompatible(subpass->GetFormatFromAttachmentReference(att.attachment)),
|
||||||
|
.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha,
|
||||||
|
.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha,
|
||||||
|
.colorBlendOp = vk::BlendOp::eAdd,
|
||||||
|
.srcAlphaBlendFactor = vk::BlendFactor::eOne,
|
||||||
|
.dstAlphaBlendFactor = vk::BlendFactor::eZero,
|
||||||
|
.alphaBlendOp = vk::BlendOp::eAdd,
|
||||||
|
.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pipeline->GetPipelineState().SetColorBlenState(colorBlendState);
|
||||||
|
pipeline->ConstructPipeline();
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma endregion MISC
|
#pragma endregion MISC
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,6 +289,7 @@ namespace SHADE
|
||||||
Handle<SHPostOffscreenRenderSystem> GetPostOffscreenRenderSystem(void) const noexcept {return postOffscreenRender;};
|
Handle<SHPostOffscreenRenderSystem> GetPostOffscreenRenderSystem(void) const noexcept {return postOffscreenRender;};
|
||||||
Handle<SHRenderGraphNode> GetPrimaryRenderpass() const noexcept;
|
Handle<SHRenderGraphNode> GetPrimaryRenderpass() const noexcept;
|
||||||
Handle<SHVkPipeline> GetDebugDrawPipeline(void) const noexcept { return debugDrawPipeline; }
|
Handle<SHVkPipeline> GetDebugDrawPipeline(void) const noexcept { return debugDrawPipeline; }
|
||||||
|
Handle<SHVkPipeline> GetDebugDrawDepthPipeline(void) const noexcept { return debugDrawDepthPipeline; }
|
||||||
uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); }
|
uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); }
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -355,6 +356,7 @@ namespace SHADE
|
||||||
// Built-In Materials
|
// Built-In Materials
|
||||||
Handle<SHMaterial> defaultMaterial;
|
Handle<SHMaterial> defaultMaterial;
|
||||||
Handle<SHVkPipeline> debugDrawPipeline;
|
Handle<SHVkPipeline> debugDrawPipeline;
|
||||||
|
Handle<SHVkPipeline> debugDrawDepthPipeline;
|
||||||
|
|
||||||
Handle<SHRenderGraph> worldRenderGraph;
|
Handle<SHRenderGraph> worldRenderGraph;
|
||||||
|
|
||||||
|
@ -367,5 +369,9 @@ namespace SHADE
|
||||||
uint32_t resizeHeight;
|
uint32_t resizeHeight;
|
||||||
bool restoredFromMinimize = false;
|
bool restoredFromMinimize = false;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Helper Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
Handle<SHVkPipeline> createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass);
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue