Minor changes

- Render Node Compute now has access to camera to send camera data to shaders
- Fonts now have functions to bind descriptor set
This commit is contained in:
Brandon Mak 2022-12-28 12:43:40 +08:00
parent 4210f5c533
commit b84364ffe9
7 changed files with 38 additions and 9 deletions

View File

@ -265,6 +265,7 @@ namespace SHADE
auto viewSamplerLayout = ssaoStorage->GetViewSamplerLayout();
ssaoPass->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_IMAGE_BINDING, { &viewSamplerLayout, 1 });
ssaoPass->SetRenderer (worldRenderer);
// Add another pass to blur SSAO
Handle<SHRenderGraphNodeCompute> ssaoBlurPass = gBufferNode->AddNodeCompute("SSAO Blur Step", ssaoBlurShader, { "SSAO", "SSAO Blur" });

View File

@ -132,6 +132,11 @@ namespace SHADE
}
void SHFont::BindDescriptorSet(Handle<SHVkCommandBuffer> commandBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept
{
commandBuffer->BindDescriptorSet(descSet, SH_PIPELINE_TYPE::GRAPHICS, setIndex, {});
}
std::unordered_map<msdfgen::unicode_t, uint32_t> SHFont::GetUnicodeIndexing(void) const noexcept
{
return unicodeIndexing;

View File

@ -57,6 +57,7 @@ namespace SHADE
SHFont (Handle<SHVkLogicalDevice> inLogicalDeviceHdl, SHFontAsset const& asset) noexcept;
void TransferToGPU (Handle<SHVkCommandBuffer> commandBuffer) noexcept;
void DoPostTransfer (Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> layout) noexcept;
void BindDescriptorSet (Handle<SHVkCommandBuffer> commandBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept;
/*-----------------------------------------------------------------------*/

View File

@ -199,7 +199,7 @@ namespace SHADE
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
// bind descriptors for font (matrices)
cmdBuffer->BindDescriptorSet(fontHandle->GetDescriptorSet(), SH_PIPELINE_TYPE::GRAPHICS, fontSetIndex, {});
fontHandle->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, fontSetIndex);
// bind VBO (position and indices)
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);

View File

@ -353,14 +353,19 @@ namespace SHADE
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings;
// Execute all subpass computes
for (auto& sbCompute : nodeComputes)
// We bind these 2 descriptor sets here because they apply to all node computes
if (!nodeComputes.empty())
{
// bind static global data
SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA));
// bind lighting data
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex);
sbCompute->Execute(commandBuffer, frameIndex);
}
// Execute all subpass computes
for (auto& sbCompute : nodeComputes)
sbCompute->Execute(commandBuffer, frameIndex);
}
Handle<SHVkPipeline> SHRenderGraphNode::GetOrCreatePipeline(std::pair<Handle<SHVkShaderModule>, Handle<SHVkShaderModule>> const& vsFsPair, Handle<SHSubpass> subpass) noexcept

View File

@ -10,6 +10,7 @@
#include "SHRenderGraphStorage.h"
#include "SHRenderGraphResource.h"
#include "Graphics/Commands/SHVkCommandBuffer.h"
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
namespace SHADE
{
@ -23,6 +24,7 @@ namespace SHADE
, numWorkGroupScale {std::clamp(inNumWorkGroupScale, 0.0f, 1.0f)}
, computeResource{}
, name { std::move(nodeName) }
, renderer{ }
{
SHPipelineLayoutParams pipelineLayoutParams
{
@ -94,14 +96,20 @@ namespace SHADE
auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings;
// bind descriptor sets
// bind render graph resource
cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {});
// bind compute resource
if (computeResource)
{
cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]);
}
// bind camera data
if (renderer)
renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex);
// dispatch compute
cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1);
@ -187,6 +195,11 @@ namespace SHADE
}
}
void SHRenderGraphNodeCompute::SetRenderer(Handle<SHRenderer> inRenderer) noexcept
{
renderer = inRenderer;
}
void SHRenderGraphNodeCompute::ModifyWriteDescBufferComputeResource(uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept
{
computeResource->descSet->ModifyWriteDescBuffer(set, binding, buffers, offset, range);

View File

@ -7,6 +7,7 @@
#include <initializer_list>
#include <string>
#include <unordered_set>
#include "Resource/SHHandle.h"
namespace SHADE
{
@ -19,6 +20,7 @@ namespace SHADE
class SHVkShaderModule;
class SHVkCommandBuffer;
class SHVkBuffer;
class SHRenderer;
class SHRenderGraphNodeCompute
@ -50,11 +52,12 @@ namespace SHADE
//! Compute resources
Handle<ComputeResource> computeResource;
//!
//! vector of resources needed by the subpass compute
std::vector<Handle<SHRenderGraphResource>> resources;
//! For binding optional camera data to the post compute
Handle<SHRenderer> renderer;
//! X dimension work group size. Should scale with resource size.
uint32_t groupSizeX;
@ -77,6 +80,7 @@ namespace SHADE
void HandleResize (void) noexcept;
void SetDynamicOffsets (std::span<uint32_t> perFrameSizes) noexcept;
void SetRenderer (Handle<SHRenderer> inRenderer) noexcept;
void ModifyWriteDescBufferComputeResource (uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept;
void ModifyWriteDescImageComputeResource(uint32_t set, uint32_t binding, std::span<SHVkDescriptorSetGroup::viewSamplerLayout> const& viewSamplerLayouts) noexcept;