Skip to content

Commit

Permalink
feat: add uniform ring buffer for viewport
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Jan 5, 2024
1 parent a7d80c7 commit fd98e2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions HPL2/include/graphics/RendererDeferred2.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ namespace hpl {
static constexpr uint32_t LightClusterSlices = 24;
static constexpr uint32_t TransientImagePoolCount = 256;

static constexpr uint32_t ViewportRingBufferSize = 2048;

static constexpr uint32_t IndirectArgumentSize = 8 * sizeof(uint32_t);

struct RootConstantDrawIndexArguments {
Expand Down Expand Up @@ -225,6 +227,8 @@ namespace hpl {

cRenderList m_rendererList;

GPURingBuffer m_viewPortUniformBuffer{};

SharedRootSignature m_lightClusterRootSignature;
std::array<SharedDescriptorSet, ForgeRenderer::SwapChainLength> m_lightDescriptorPerFrameSet;
SharedShader m_lightClusterShader;
Expand Down Expand Up @@ -312,6 +316,7 @@ namespace hpl {
uint32_t m_objectIndex = 0;
uint32_t m_indirectIndex = 0;
uint32_t m_particleIndex = 0;
uint32_t m_viewportIndex = 0;
};
ResetFrameHandler m_resetHandler;
TransientFrameVariable<TransientFrameVars> m_variables;
Expand Down
4 changes: 4 additions & 0 deletions HPL2/resource/scene_resource.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ CBUFFER(sceneInfo, UPDATE_FREQ_PER_FRAME, b1, binding = 4) {
DATA(ViewportInfo, viewports[64], None);
};

CBUFFER(viewportBlock, UPDATE_FREQ_PER_BATCH, b2, binding = 5) {
DATA(ViewportInfo, viewport, None);
};

RES(Buffer(UniformObject), sceneObjects, UPDATE_FREQ_PER_FRAME, t0, binding = 5);
RES(Buffer(Light), lights, UPDATE_FREQ_PER_FRAME, t1, binding = 6);
RES(Buffer(Particle), particles, UPDATE_FREQ_PER_FRAME, t2, binding = 7);
Expand Down
7 changes: 7 additions & 0 deletions HPL2/sources/graphics/RendererDeferred2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,9 @@ namespace hpl {
m_diffuseIndexPool = IndexPool(resource::MaxSolidDiffuseMaterials);
m_translucencyIndexPool = IndexPool(resource::MaxTranslucenctMaterials);
m_waterIndexPool = IndexPool(resource::MaxWaterMaterials);

addUniformGPURingBuffer(forgeRenderer->Rend(), ViewportRingBufferSize, &m_viewPortUniformBuffer);


// create Descriptor sets
m_sceneDescriptorConstSet.Load(forgeRenderer->Rend(), [&](DescriptorSet** descSet) {
Expand Down Expand Up @@ -1481,6 +1484,7 @@ namespace hpl {
vars.m_objectIndex = 0;
vars.m_indirectIndex = 0;
vars.m_particleIndex = 0;
vars.m_viewportIndex = 0;
vars.m_objectSlotIndex.clear();
});

Expand Down Expand Up @@ -1618,6 +1622,9 @@ namespace hpl {
updateDescriptorSet(
forgeRenderer->Rend(), 0, m_sceneDescriptorPerFrameSet[frame.m_frameIndex].m_handle, params.size(), params.data());
}



{
BufferUpdateDesc updateDesc = { m_perSceneInfoBuffer[frame.m_frameIndex].m_handle, 0, sizeof(resource::SceneInfoResource) };
beginUpdateResource(&updateDesc);
Expand Down

0 comments on commit fd98e2b

Please sign in to comment.