Graphics/SpriteChainRenderer: Improve copy
This commit is contained in:
parent
db85372778
commit
7f6b61df53
|
|
@ -35,6 +35,13 @@ namespace Nz
|
||||||
void Reset(ElementRendererData& rendererData, RenderFrame& currentFrame);
|
void Reset(ElementRendererData& rendererData, RenderFrame& currentFrame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct BufferCopy
|
||||||
|
{
|
||||||
|
AbstractBuffer* targetBuffer;
|
||||||
|
UploadPool::Allocation* allocation;
|
||||||
|
std::size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
struct VertexBufferPool
|
struct VertexBufferPool
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<AbstractBuffer>> vertexBuffers;
|
std::vector<std::shared_ptr<AbstractBuffer>> vertexBuffers;
|
||||||
|
|
@ -44,7 +51,7 @@ namespace Nz
|
||||||
std::shared_ptr<VertexBufferPool> m_vertexBufferPool;
|
std::shared_ptr<VertexBufferPool> m_vertexBufferPool;
|
||||||
std::size_t m_maxVertexBufferSize;
|
std::size_t m_maxVertexBufferSize;
|
||||||
std::size_t m_maxVertexCount;
|
std::size_t m_maxVertexCount;
|
||||||
std::vector<std::pair<UploadPool::Allocation*, AbstractBuffer*>> m_pendingCopies;
|
std::vector<BufferCopy> m_pendingCopies;
|
||||||
RenderDevice& m_device;
|
RenderDevice& m_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,13 @@ namespace Nz
|
||||||
|
|
||||||
if (currentAllocation)
|
if (currentAllocation)
|
||||||
{
|
{
|
||||||
m_pendingCopies.emplace_back(currentAllocation, currentVertexBuffer);
|
std::size_t size = currentAllocationMemPtr - static_cast<UInt8*>(currentAllocation->mappedPtr);
|
||||||
|
|
||||||
|
m_pendingCopies.emplace_back(BufferCopy{
|
||||||
|
currentVertexBuffer,
|
||||||
|
currentAllocation,
|
||||||
|
size
|
||||||
|
});
|
||||||
|
|
||||||
firstQuadIndex = 0;
|
firstQuadIndex = 0;
|
||||||
currentAllocation = nullptr;
|
currentAllocation = nullptr;
|
||||||
|
|
@ -237,8 +243,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
currentFrame.Execute([&](CommandBufferBuilder& builder)
|
currentFrame.Execute([&](CommandBufferBuilder& builder)
|
||||||
{
|
{
|
||||||
for (auto&& [allocation, buffer] : m_pendingCopies)
|
for (auto& copy : m_pendingCopies)
|
||||||
builder.CopyBuffer(*allocation, buffer);
|
builder.CopyBuffer(*copy.allocation, copy.targetBuffer, copy.size);
|
||||||
|
|
||||||
builder.PostTransferBarrier();
|
builder.PostTransferBarrier();
|
||||||
}, Nz::QueueType::Transfer);
|
}, Nz::QueueType::Transfer);
|
||||||
|
|
@ -247,7 +253,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteChainRenderer::Render(ElementRendererData& rendererData, CommandBufferBuilder& commandBuffer, const Pointer<const RenderElement>* elements, std::size_t elementCount)
|
void SpriteChainRenderer::Render(ElementRendererData& rendererData, CommandBufferBuilder& commandBuffer, const Pointer<const RenderElement>* elements, std::size_t /*elementCount*/)
|
||||||
{
|
{
|
||||||
auto& data = static_cast<SpriteChainRendererData&>(rendererData);
|
auto& data = static_cast<SpriteChainRendererData&>(rendererData);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue