diff --git a/HPL2/include/gui/GuiSet.h b/HPL2/include/gui/GuiSet.h index 4b6c112d6..899ed7159 100644 --- a/HPL2/include/gui/GuiSet.h +++ b/HPL2/include/gui/GuiSet.h @@ -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(); } diff --git a/HPL2/sources/gui/GuiSet.cpp b/HPL2/sources/gui/GuiSet.cpp index af039f41b..5f7ee681c 100644 --- a/HPL2/sources/gui/GuiSet.cpp +++ b/HPL2/sources/gui/GuiSet.cpp @@ -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" @@ -109,16 +110,7 @@ namespace hpl { static std::array GuiUniformDescriptorSet{}; static std::array, 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; @@ -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"; @@ -269,8 +244,6 @@ namespace hpl { } } - - addUniformGPURingBuffer(pipeline.Rend(), sizeof(UniformBlock) * MAX_GUI_DRAW_CALLS, &GuiUniformRingBuffer, true); } void exitGui() { @@ -685,14 +658,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::Get(); + + GPURingBufferOffset vb = graphicsAllocator->allocTransientVertexBuffer(vertexBufferSize); + GPURingBufferOffset ib = graphicsAllocator->allocTransientIndexBuffer(indexBufferSize); cMatrixf projectionMtx(cMatrixf::Identity); cMatrixf viewMtx(cMatrixf::Identity); @@ -758,11 +728,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;