Vulkan: Move texture upload buffer to ObjectCache

This commit is contained in:
Stenzek 2019-01-19 00:27:09 +10:00
parent 36ce47635b
commit e03b8e899e
5 changed files with 12 additions and 18 deletions

View File

@ -54,6 +54,15 @@ bool ObjectCache::Initialize()
if (!CreateStaticSamplers())
return false;
m_texture_upload_buffer =
StreamBuffer::Create(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, INITIAL_TEXTURE_UPLOAD_BUFFER_SIZE,
MAXIMUM_TEXTURE_UPLOAD_BUFFER_SIZE);
if (!m_texture_upload_buffer)
{
PanicAlert("Failed to create texture upload buffer");
return false;
}
m_utility_shader_vertex_buffer =
StreamBuffer::Create(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, 1024 * 1024, 4 * 1024 * 1024);
m_utility_shader_uniform_buffer =

View File

@ -58,6 +58,7 @@ public:
{
return m_utility_shader_uniform_buffer.get();
}
StreamBuffer* GetTextureUploadBuffer() const { return m_texture_upload_buffer.get(); }
// Static samplers
VkSampler GetPointSampler() const { return m_point_sampler; }
@ -94,6 +95,7 @@ private:
std::unique_ptr<VertexFormat> m_utility_shader_vertex_format;
std::unique_ptr<StreamBuffer> m_utility_shader_vertex_buffer;
std::unique_ptr<StreamBuffer> m_utility_shader_uniform_buffer;
std::unique_ptr<StreamBuffer> m_texture_upload_buffer;
VkSampler m_point_sampler = VK_NULL_HANDLE;
VkSampler m_linear_sampler = VK_NULL_HANDLE;

View File

@ -45,11 +45,6 @@ VkShaderModule TextureCache::GetCopyShader() const
return m_copy_shader;
}
StreamBuffer* TextureCache::GetTextureUploadBuffer() const
{
return m_texture_upload_buffer.get();
}
TextureCache* TextureCache::GetInstance()
{
return static_cast<TextureCache*>(g_texture_cache.get());
@ -57,15 +52,6 @@ TextureCache* TextureCache::GetInstance()
bool TextureCache::Initialize()
{
m_texture_upload_buffer =
StreamBuffer::Create(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, INITIAL_TEXTURE_UPLOAD_BUFFER_SIZE,
MAXIMUM_TEXTURE_UPLOAD_BUFFER_SIZE);
if (!m_texture_upload_buffer)
{
PanicAlert("Failed to create texture upload buffer");
return false;
}
m_texture_converter = std::make_unique<TextureConverter>();
if (!m_texture_converter->Initialize())
{

View File

@ -49,7 +49,6 @@ public:
TLUTFormat palette_format) override;
VkShaderModule GetCopyShader() const;
StreamBuffer* GetTextureUploadBuffer() const;
private:
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
@ -57,8 +56,6 @@ private:
float gamma, bool clamp_top, bool clamp_bottom,
const CopyFilterCoefficientArray& filter_coefficients) override;
std::unique_ptr<StreamBuffer> m_texture_upload_buffer;
std::unique_ptr<TextureConverter> m_texture_converter;
VkShaderModule m_copy_shader = VK_NULL_HANDLE;

View File

@ -290,7 +290,7 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
if (upload_size <= STAGING_TEXTURE_UPLOAD_THRESHOLD &&
upload_size <= MAXIMUM_TEXTURE_UPLOAD_BUFFER_SIZE)
{
StreamBuffer* stream_buffer = TextureCache::GetInstance()->GetTextureUploadBuffer();
StreamBuffer* stream_buffer = g_object_cache->GetTextureUploadBuffer();
if (!stream_buffer->ReserveMemory(upload_size, upload_alignment))
{
// Execute the command buffer first.