mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-30 16:01:49 +00:00
Limit texture upload transfer buffers to roughly 64 MB
This commit is contained in:
parent
9aeb78ae97
commit
796890bb98
3 changed files with 38 additions and 19 deletions
|
@ -209,8 +209,13 @@ void VulkanFrameBuffer::Update()
|
||||||
Super::Update();
|
Super::Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::DeleteFrameObjects()
|
void VulkanFrameBuffer::DeleteFrameObjects(bool uploadOnly)
|
||||||
{
|
{
|
||||||
|
FrameTextureUpload.Buffers.clear();
|
||||||
|
FrameTextureUpload.TotalSize = 0;
|
||||||
|
|
||||||
|
if (!uploadOnly)
|
||||||
|
{
|
||||||
FrameDeleteList.Images.clear();
|
FrameDeleteList.Images.clear();
|
||||||
FrameDeleteList.ImageViews.clear();
|
FrameDeleteList.ImageViews.clear();
|
||||||
FrameDeleteList.Framebuffers.clear();
|
FrameDeleteList.Framebuffers.clear();
|
||||||
|
@ -218,6 +223,7 @@ void VulkanFrameBuffer::DeleteFrameObjects()
|
||||||
FrameDeleteList.Descriptors.clear();
|
FrameDeleteList.Descriptors.clear();
|
||||||
FrameDeleteList.DescriptorPools.clear();
|
FrameDeleteList.DescriptorPools.clear();
|
||||||
FrameDeleteList.CommandBuffers.clear();
|
FrameDeleteList.CommandBuffers.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit)
|
void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit)
|
||||||
|
@ -251,11 +257,12 @@ void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t cou
|
||||||
mNextSubmit++;
|
mNextSubmit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit)
|
void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit, bool uploadOnly)
|
||||||
{
|
{
|
||||||
|
if (!uploadOnly)
|
||||||
mRenderState->EndRenderPass();
|
mRenderState->EndRenderPass();
|
||||||
|
|
||||||
if (mDrawCommands || mTransferCommands)
|
if ((!uploadOnly && mDrawCommands) || mTransferCommands)
|
||||||
{
|
{
|
||||||
VulkanCommandBuffer *commands[2];
|
VulkanCommandBuffer *commands[2];
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
@ -267,7 +274,7 @@ void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit)
|
||||||
FrameDeleteList.CommandBuffers.push_back(std::move(mTransferCommands));
|
FrameDeleteList.CommandBuffers.push_back(std::move(mTransferCommands));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDrawCommands)
|
if (!uploadOnly && mDrawCommands)
|
||||||
{
|
{
|
||||||
mDrawCommands->end();
|
mDrawCommands->end();
|
||||||
commands[count++] = mDrawCommands.get();
|
commands[count++] = mDrawCommands.get();
|
||||||
|
@ -280,7 +287,7 @@ void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::WaitForCommands(bool finish)
|
void VulkanFrameBuffer::WaitForCommands(bool finish, bool uploadOnly)
|
||||||
{
|
{
|
||||||
if (finish)
|
if (finish)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +299,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
||||||
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, false);
|
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlushCommands(finish, true);
|
FlushCommands(finish, true, uploadOnly);
|
||||||
|
|
||||||
if (finish)
|
if (finish)
|
||||||
{
|
{
|
||||||
|
@ -310,7 +317,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
||||||
vkResetFences(device->device, numWaitFences, mSubmitWaitFences);
|
vkResetFences(device->device, numWaitFences, mSubmitWaitFences);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteFrameObjects();
|
DeleteFrameObjects(uploadOnly);
|
||||||
mNextSubmit = 0;
|
mNextSubmit = 0;
|
||||||
|
|
||||||
if (finish)
|
if (finish)
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
|
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
|
||||||
FRenderState* RenderState() override;
|
FRenderState* RenderState() override;
|
||||||
|
|
||||||
void FlushCommands(bool finish, bool lastsubmit = false);
|
void FlushCommands(bool finish, bool lastsubmit = false, bool uploadOnly = false);
|
||||||
|
|
||||||
unsigned int GetLightBufferBlockSize() const;
|
unsigned int GetLightBufferBlockSize() const;
|
||||||
|
|
||||||
|
@ -64,6 +64,12 @@ public:
|
||||||
std::vector<std::unique_ptr<VulkanCommandBuffer>> CommandBuffers;
|
std::vector<std::unique_ptr<VulkanCommandBuffer>> CommandBuffers;
|
||||||
} FrameDeleteList;
|
} FrameDeleteList;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
std::vector<std::unique_ptr<VulkanBuffer>> Buffers;
|
||||||
|
size_t TotalSize = 0;
|
||||||
|
} FrameTextureUpload;
|
||||||
|
|
||||||
VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevice *dev);
|
VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevice *dev);
|
||||||
~VulkanFrameBuffer();
|
~VulkanFrameBuffer();
|
||||||
bool IsVulkan() override { return true; }
|
bool IsVulkan() override { return true; }
|
||||||
|
@ -103,7 +109,8 @@ public:
|
||||||
|
|
||||||
void Draw2D() override;
|
void Draw2D() override;
|
||||||
|
|
||||||
void WaitForCommands(bool finish) override;
|
void WaitForCommands(bool finish) override { WaitForCommands(finish, false); }
|
||||||
|
void WaitForCommands(bool finish, bool uploadOnly);
|
||||||
|
|
||||||
void PushGroup(const FString &name);
|
void PushGroup(const FString &name);
|
||||||
void PopGroup();
|
void PopGroup();
|
||||||
|
@ -116,7 +123,7 @@ private:
|
||||||
void PrintStartupLog();
|
void PrintStartupLog();
|
||||||
void CreateFanToTrisIndexBuffer();
|
void CreateFanToTrisIndexBuffer();
|
||||||
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
|
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
|
||||||
void DeleteFrameObjects();
|
void DeleteFrameObjects(bool uploadOnly = false);
|
||||||
void FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit);
|
void FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit);
|
||||||
|
|
||||||
std::unique_ptr<VkShaderManager> mShaderManager;
|
std::unique_ptr<VkShaderManager> mShaderManager;
|
||||||
|
|
|
@ -203,9 +203,14 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
|
||||||
region.imageExtent.height = h;
|
region.imageExtent.height = h;
|
||||||
cmdbuffer->copyBufferToImage(stagingBuffer->buffer, mImage.Image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
cmdbuffer->copyBufferToImage(stagingBuffer->buffer, mImage.Image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||||
|
|
||||||
fb->FrameDeleteList.Buffers.push_back(std::move(stagingBuffer));
|
fb->FrameTextureUpload.Buffers.push_back(std::move(stagingBuffer));
|
||||||
|
|
||||||
if (mipmap) mImage.GenerateMipmaps(cmdbuffer);
|
if (mipmap) mImage.GenerateMipmaps(cmdbuffer);
|
||||||
|
|
||||||
|
// If we queued more than 64 MB of data already: wait until the uploads finish before continuing
|
||||||
|
fb->FrameTextureUpload.TotalSize += totalSize;
|
||||||
|
if (fb->FrameTextureUpload.TotalSize > 64 * 1024 * 1024)
|
||||||
|
fb->WaitForCommands(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VkHardwareTexture::GetMipLevels(int w, int h)
|
int VkHardwareTexture::GetMipLevels(int w, int h)
|
||||||
|
|
Loading…
Reference in a new issue