mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Vulkan: Simplify palette texture conversion
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/Vulkan/StreamBuffer.h"
|
||||
#include "VideoBackends/Vulkan/TextureCache.h"
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
#include "VideoCommon/TextureDecoder.h"
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
@ -25,14 +26,14 @@ public:
|
||||
~TextureConverter();
|
||||
|
||||
VkRenderPass GetEncodingRenderPass() const { return m_encoding_render_pass; }
|
||||
Texture2D* GetEncodingTexture() const { return m_encoding_texture.get(); }
|
||||
VkFramebuffer GetEncodingTextureFramebuffer() const { return m_encoding_texture_framebuffer; }
|
||||
StagingTexture2D* GetDownloadTexture() const { return m_download_texture.get(); }
|
||||
Texture2D* GetEncodingTexture() const { return m_encoding_render_texture.get(); }
|
||||
VkFramebuffer GetEncodingTextureFramebuffer() const { return m_encoding_render_framebuffer; }
|
||||
StagingTexture2D* GetDownloadTexture() const { return m_encoding_download_texture.get(); }
|
||||
bool Initialize();
|
||||
|
||||
void ConvertTexture(VkCommandBuffer command_buffer, VkRenderPass render_pass,
|
||||
VkFramebuffer dst_framebuffer, Texture2D* src_texture, u32 width, u32 height,
|
||||
void* palette, TlutFormat format, u32 src_format);
|
||||
// Applies palette to dst_entry, using indices from src_entry.
|
||||
void ConvertTexture(TextureCache::TCacheEntry* dst_entry, TextureCache::TCacheEntry* src_entry,
|
||||
VkRenderPass render_pass, const void* palette, TlutFormat palette_format);
|
||||
|
||||
// Uses an encoding shader to copy src_texture to dest_ptr.
|
||||
// NOTE: Executes the current command buffer.
|
||||
@ -48,28 +49,30 @@ private:
|
||||
static const VkFormat ENCODING_TEXTURE_FORMAT = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
static const size_t NUM_PALETTE_CONVERSION_SHADERS = 3;
|
||||
|
||||
bool CreateUniformBuffer();
|
||||
bool CreateTexelBuffer();
|
||||
VkBufferView CreateTexelBufferView(VkFormat format) const;
|
||||
|
||||
bool CompilePaletteConversionShaders();
|
||||
|
||||
bool CompileEncodingShaders();
|
||||
bool CreateEncodingRenderPass();
|
||||
bool CreateEncodingTexture();
|
||||
bool CreateDownloadTexture();
|
||||
bool CreateEncodingDownloadTexture();
|
||||
|
||||
// Shared between conversion types
|
||||
std::unique_ptr<StreamBuffer> m_texel_buffer;
|
||||
VkBufferView m_texel_buffer_view_r16_uint = VK_NULL_HANDLE;
|
||||
size_t m_texel_buffer_size = 0;
|
||||
|
||||
// Palette conversion - taking an indexed texture and applying palette
|
||||
std::array<VkShaderModule, NUM_PALETTE_CONVERSION_SHADERS> m_palette_conversion_shaders = {};
|
||||
|
||||
std::unique_ptr<StreamBuffer> m_palette_stream_buffer;
|
||||
VkBufferView m_palette_buffer_view = VK_NULL_HANDLE;
|
||||
|
||||
std::unique_ptr<StreamBuffer> m_uniform_buffer;
|
||||
|
||||
std::array<VkShaderModule, NUM_TEXTURE_ENCODING_SHADERS> m_texture_encoding_shaders = {};
|
||||
|
||||
// Texture encoding - RGBA8->GX format in memory
|
||||
std::array<VkShaderModule, NUM_TEXTURE_ENCODING_SHADERS> m_encoding_shaders = {};
|
||||
VkRenderPass m_encoding_render_pass = VK_NULL_HANDLE;
|
||||
|
||||
std::unique_ptr<Texture2D> m_encoding_texture;
|
||||
VkFramebuffer m_encoding_texture_framebuffer = VK_NULL_HANDLE;
|
||||
|
||||
std::unique_ptr<StagingTexture2D> m_download_texture;
|
||||
std::unique_ptr<Texture2D> m_encoding_render_texture;
|
||||
VkFramebuffer m_encoding_render_framebuffer = VK_NULL_HANDLE;
|
||||
std::unique_ptr<StagingTexture2D> m_encoding_download_texture;
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
Reference in New Issue
Block a user