Skip to content

Commit

Permalink
Merge pull request #113 from OSS-Cosmic/feature/simplify-gui-set
Browse files Browse the repository at this point in the history
feat: simplify guiset global
  • Loading branch information
pollend authored Jan 5, 2024
2 parents f1a0ee3 + a7d80c7 commit 17c2db6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 48 deletions.
4 changes: 2 additions & 2 deletions HPL2/include/graphics/GraphicsAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace hpl {
static constexpr uint32_t ParticleVertexBufferSize = 0xf << 12;
static constexpr uint32_t ParticleIndexBufferSize = 0xf << 12;

static constexpr uint32_t ImmediateVertexBufferSize = 1;
static constexpr uint32_t ImmediateIndexBufferSize = 1;
static constexpr uint32_t ImmediateVertexBufferSize = 0xf << 14;
static constexpr uint32_t ImmediateIndexBufferSize = 0xf << 14;

GPURingBufferOffset allocTransientVertexBuffer(uint32_t size);
GPURingBufferOffset allocTransientIndexBuffer(uint32_t size);
Expand Down
6 changes: 1 addition & 5 deletions HPL2/include/gui/GuiSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
namespace hpl {

namespace gui {
static constexpr size_t GUI_STREAM_BUFFER_VB_SIZE = 32768;
static constexpr size_t GUI_STREAM_BUFFER_IB_SIZE = 32768;
static constexpr size_t GUI_MAX_BATCHES = 1024;
static constexpr uint32_t MAX_GUI_DRAW_CALLS = 1024;



void InitializeGui(ForgeRenderer& pipeline);
void exitGui();
}
Expand Down
49 changes: 8 additions & 41 deletions HPL2/sources/gui/GuiSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Common_3/Graphics/Interfaces/IGraphics.h"
#include "graphics/Color.h"
#include "graphics/Enum.h"
#include "graphics/GraphicsAllocator.h"
#include "graphics/RenderTarget.h"
#include "gui/GuiTypes.h"
#include "math/Math.h"
Expand Down Expand Up @@ -109,16 +110,7 @@ namespace hpl {
static std::array<DescriptorSet*, ForgeRenderer::SwapChainLength> GuiUniformDescriptorSet{};
static std::array<std::array<SharedTexture, MAX_GUI_DRAW_CALLS>, ForgeRenderer::SwapChainLength> GuiTextures{};
static RootSignature* GuiRootSignatnre = nullptr;

#ifdef USE_THE_FORGE_LEGACY
static GPURingBuffer* GuiUniformRingBuffer = nullptr;
static GPURingBuffer* GuiVertexRingBuffer = nullptr;
static GPURingBuffer* GuiIndexRingBuffer = nullptr;
#else
static GPURingBuffer GuiUniformRingBuffer {};
static GPURingBuffer GuiVertexRingBuffer{};
static GPURingBuffer GuiIndexRingBuffer{};
#endif
static GPURingBuffer GuiUniformRingBuffer {};
static Sampler* GuiSampler = nullptr;

static uint32_t descriptorIndex = 0;
Expand All @@ -139,23 +131,6 @@ namespace hpl {
samplerDesc.mAddressW = ADDRESS_MODE_CLAMP_TO_EDGE;
addSampler(pipeline.Rend(), &samplerDesc, &GuiSampler);
}
{
BufferDesc desc = {};
desc.mDescriptors = DESCRIPTOR_TYPE_VERTEX_BUFFER;
desc.mMemoryUsage = RESOURCE_MEMORY_USAGE_CPU_TO_GPU;
desc.mSize = GUI_STREAM_BUFFER_VB_SIZE * sizeof(PositionTexColor);
desc.pName = "GUI Vertex Buffer";

addGPURingBuffer(pipeline.Rend(), &desc, &GuiVertexRingBuffer);
}
{
BufferDesc desc = {};
desc.mDescriptors = DESCRIPTOR_TYPE_INDEX_BUFFER;
desc.mMemoryUsage = RESOURCE_MEMORY_USAGE_CPU_TO_GPU;
desc.mSize = GUI_STREAM_BUFFER_IB_SIZE * sizeof(uint32_t);
desc.pName = "GUI Index Buffer";
addGPURingBuffer(pipeline.Rend(), &desc, &GuiIndexRingBuffer);
}

ShaderLoadDesc loadDesc = {};
loadDesc.mStages[0].pFileName = "gui.vert";
Expand Down Expand Up @@ -269,8 +244,7 @@ namespace hpl {
}

}

addUniformGPURingBuffer(pipeline.Rend(), sizeof(UniformBlock) * MAX_GUI_DRAW_CALLS, &GuiUniformRingBuffer, true);
addUniformGPURingBuffer(pipeline.Rend(), sizeof(UniformBlock) * MAX_GUI_DRAW_CALLS, &GuiUniformRingBuffer, true);
}

void exitGui() {
Expand Down Expand Up @@ -685,14 +659,11 @@ namespace hpl {

size_t vertexBufferSize = m_setRenderObjects.size() * sizeof(gui::PositionTexColor) * 4;
size_t indexBufferSize = m_setRenderObjects.size() * sizeof(uint32_t) * 6;
#ifdef USE_THE_FORGE_LEGACY
GPURingBufferOffset vb = getGPURingBufferOffset(gui::GuiVertexRingBuffer, vertexBufferSize);
GPURingBufferOffset ib = getGPURingBufferOffset(gui::GuiIndexRingBuffer, indexBufferSize);
#else
GPURingBufferOffset vb = getGPURingBufferOffset(&gui::GuiVertexRingBuffer, vertexBufferSize);
GPURingBufferOffset ib = getGPURingBufferOffset(&gui::GuiIndexRingBuffer, indexBufferSize);
#endif
GraphicsAllocator* graphicsAllocator = Interface<GraphicsAllocator>::Get();


GPURingBufferOffset vb = graphicsAllocator->allocTransientVertexBuffer(vertexBufferSize);
GPURingBufferOffset ib = graphicsAllocator->allocTransientIndexBuffer(indexBufferSize);

cMatrixf projectionMtx(cMatrixf::Identity);
cMatrixf viewMtx(cMatrixf::Identity);
Expand Down Expand Up @@ -758,11 +729,7 @@ namespace hpl {
size_t indexBufferIndex = 0;

uint32_t requestSize = round_up(sizeof(gui::UniformBlock), 256);
#ifdef USE_THE_FORGE_LEGACY
GPURingBufferOffset uniformBlockOffset = getGPURingBufferOffset(gui::GuiUniformRingBuffer, requestSize);
#else
GPURingBufferOffset uniformBlockOffset = getGPURingBufferOffset(&gui::GuiUniformRingBuffer, requestSize);
#endif
GPURingBufferOffset uniformBlockOffset = getGPURingBufferOffset(&gui::GuiUniformRingBuffer, requestSize);

DescriptorData params[10]{};
uint32_t paramCount = 0;
Expand Down

0 comments on commit 17c2db6

Please sign in to comment.