Skip to content
Permalink
Browse files

Vulkan: Move texture upload buffer to ObjectCache

  • Loading branch information...
stenzek committed Jan 18, 2019
1 parent 36ce476 commit e03b8e899e14a2a57bf32ad539f7f987edc5b24c
@@ -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 =
@@ -58,6 +58,7 @@ class ObjectCache
{
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 @@ class ObjectCache
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;
@@ -45,27 +45,13 @@ 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());
}

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())
{
@@ -49,16 +49,13 @@ class TextureCache : public TextureCacheBase
TLUTFormat palette_format) override;

VkShaderModule GetCopyShader() const;
StreamBuffer* GetTextureUploadBuffer() const;

private:
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
bool scale_by_half, EFBCopyFormat dst_format, bool is_intensity,
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;
@@ -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.

0 comments on commit e03b8e8

Please sign in to comment.
You can’t perform that action at this time.