mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-23 12:42:15 +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,15 +209,21 @@ void VulkanFrameBuffer::Update()
|
|||
Super::Update();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::DeleteFrameObjects()
|
||||
void VulkanFrameBuffer::DeleteFrameObjects(bool uploadOnly)
|
||||
{
|
||||
FrameDeleteList.Images.clear();
|
||||
FrameDeleteList.ImageViews.clear();
|
||||
FrameDeleteList.Framebuffers.clear();
|
||||
FrameDeleteList.Buffers.clear();
|
||||
FrameDeleteList.Descriptors.clear();
|
||||
FrameDeleteList.DescriptorPools.clear();
|
||||
FrameDeleteList.CommandBuffers.clear();
|
||||
FrameTextureUpload.Buffers.clear();
|
||||
FrameTextureUpload.TotalSize = 0;
|
||||
|
||||
if (!uploadOnly)
|
||||
{
|
||||
FrameDeleteList.Images.clear();
|
||||
FrameDeleteList.ImageViews.clear();
|
||||
FrameDeleteList.Framebuffers.clear();
|
||||
FrameDeleteList.Buffers.clear();
|
||||
FrameDeleteList.Descriptors.clear();
|
||||
FrameDeleteList.DescriptorPools.clear();
|
||||
FrameDeleteList.CommandBuffers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit)
|
||||
void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit, bool uploadOnly)
|
||||
{
|
||||
mRenderState->EndRenderPass();
|
||||
if (!uploadOnly)
|
||||
mRenderState->EndRenderPass();
|
||||
|
||||
if (mDrawCommands || mTransferCommands)
|
||||
if ((!uploadOnly && mDrawCommands) || mTransferCommands)
|
||||
{
|
||||
VulkanCommandBuffer *commands[2];
|
||||
size_t count = 0;
|
||||
|
@ -267,7 +274,7 @@ void VulkanFrameBuffer::FlushCommands(bool finish, bool lastsubmit)
|
|||
FrameDeleteList.CommandBuffers.push_back(std::move(mTransferCommands));
|
||||
}
|
||||
|
||||
if (mDrawCommands)
|
||||
if (!uploadOnly && mDrawCommands)
|
||||
{
|
||||
mDrawCommands->end();
|
||||
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)
|
||||
{
|
||||
|
@ -292,7 +299,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
|||
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, false);
|
||||
}
|
||||
|
||||
FlushCommands(finish, true);
|
||||
FlushCommands(finish, true, uploadOnly);
|
||||
|
||||
if (finish)
|
||||
{
|
||||
|
@ -310,7 +317,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
|||
vkResetFences(device->device, numWaitFences, mSubmitWaitFences);
|
||||
}
|
||||
|
||||
DeleteFrameObjects();
|
||||
DeleteFrameObjects(uploadOnly);
|
||||
mNextSubmit = 0;
|
||||
|
||||
if (finish)
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
|
||||
FRenderState* RenderState() override;
|
||||
|
||||
void FlushCommands(bool finish, bool lastsubmit = false);
|
||||
void FlushCommands(bool finish, bool lastsubmit = false, bool uploadOnly = false);
|
||||
|
||||
unsigned int GetLightBufferBlockSize() const;
|
||||
|
||||
|
@ -64,6 +64,12 @@ public:
|
|||
std::vector<std::unique_ptr<VulkanCommandBuffer>> CommandBuffers;
|
||||
} FrameDeleteList;
|
||||
|
||||
struct
|
||||
{
|
||||
std::vector<std::unique_ptr<VulkanBuffer>> Buffers;
|
||||
size_t TotalSize = 0;
|
||||
} FrameTextureUpload;
|
||||
|
||||
VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevice *dev);
|
||||
~VulkanFrameBuffer();
|
||||
bool IsVulkan() override { return true; }
|
||||
|
@ -103,7 +109,8 @@ public:
|
|||
|
||||
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 PopGroup();
|
||||
|
@ -116,7 +123,7 @@ private:
|
|||
void PrintStartupLog();
|
||||
void CreateFanToTrisIndexBuffer();
|
||||
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);
|
||||
|
||||
std::unique_ptr<VkShaderManager> mShaderManager;
|
||||
|
|
|
@ -203,9 +203,14 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
|
|||
region.imageExtent.height = h;
|
||||
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 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)
|
||||
|
|
Loading…
Reference in a new issue