Add support for zero size buffers as the hwrenderer uses that!

Also add a sanity check on zero size textures just in case that ever happens!
This commit is contained in:
Magnus Norddahl 2021-02-12 12:17:01 +01:00 committed by Rachael Alexanderson
parent f2469c6dcf
commit 7e68223794
2 changed files with 11 additions and 0 deletions

View file

@ -68,6 +68,8 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
{
auto fb = GetVulkanFrameBuffer();
size = std::max(size, (size_t)16); // For supporting zero byte buffers
if (staticdata)
{
mPersistent = false;
@ -122,6 +124,8 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
{
size = std::max(size, (size_t)16); // For supporting zero byte buffers
auto fb = GetVulkanFrameBuffer();
if (mStaging)
{
@ -141,6 +145,8 @@ void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
void VKBuffer::Resize(size_t newsize)
{
newsize = std::max(newsize, (size_t)16); // For supporting zero byte buffers
auto fb = GetVulkanFrameBuffer();
// Grab old buffer
@ -187,6 +193,8 @@ void VKBuffer::Unmap()
void *VKBuffer::Lock(unsigned int size)
{
size = std::max(size, (unsigned int)16); // For supporting zero byte buffers
if (!mBuffer)
{
// The model mesh loaders lock multiple non-persistent buffers at the same time. This is not allowed in vulkan.

View file

@ -158,6 +158,9 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels)
{
if (w <= 0 || h <= 0)
throw CVulkanError("Trying to create zero size texture");
auto fb = GetVulkanFrameBuffer();
int totalSize = w * h * pixelsize;