Skip to content

Commit

Permalink
- don't map the frame buffer memory every frame when doing software r…
Browse files Browse the repository at this point in the history
…endering
  • Loading branch information
dpjudas committed Nov 23, 2019
1 parent 8abbd63 commit bff22bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/rendering/vulkan/textures/vk_hwtexture.cpp
Expand Up @@ -69,6 +69,12 @@ void VkHardwareTexture::Reset()
{
ResetDescriptors();

if (mappedSWFB)
{
mImage.Image->Unmap();
mappedSWFB = nullptr;
}

auto &deleteList = fb->FrameDeleteList;
if (mImage.Image) deleteList.Images.push_back(std::move(mImage.Image));
if (mImage.View) deleteList.ImageViews.push_back(std::move(mImage.View));
Expand Down Expand Up @@ -348,12 +354,13 @@ void VkHardwareTexture::AllocateBuffer(int w, int h, int texelsize)

uint8_t *VkHardwareTexture::MapBuffer()
{
return (uint8_t*)mImage.Image->Map(0, mImage.Image->width * mImage.Image->height * mTexelsize);
if (!mappedSWFB)
mappedSWFB = (uint8_t*)mImage.Image->Map(0, mImage.Image->width * mImage.Image->height * mTexelsize);
return mappedSWFB;
}

unsigned int VkHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name)
{
mImage.Image->Unmap();
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/rendering/vulkan/textures/vk_hwtexture.h
Expand Up @@ -77,4 +77,6 @@ class VkHardwareTexture : public IHardwareTexture
int mTexelsize = 4;

VkTextureImage mDepthStencil;

uint8_t* mappedSWFB = nullptr;
};

0 comments on commit bff22bb

Please sign in to comment.