From b066d51dfa03b960028fc6f88c8de133eb6db1da Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 22 Oct 2016 20:50:36 +1000 Subject: Vulkan: Remove parameters/members of single-instance classes There's not a lot of point in passing these around or storing them (texture cache/state tracker mainly) as there will only ever be a single instance of the class. Also adds downcast helpers such as Vulkan::Renderer::GetInstance(). --- Source/Core/VideoBackends/Vulkan/TextureCache.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/TextureCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.h b/Source/Core/VideoBackends/Vulkan/TextureCache.h index 18c8bd6020..1de1bbfc10 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.h +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.h @@ -23,7 +23,9 @@ public: TextureCache(); ~TextureCache(); - bool Initialize(StateTracker* state_tracker); + static TextureCache* GetInstance(); + + bool Initialize(); bool CompileShaders() override; void DeleteShaders() override; @@ -37,8 +39,8 @@ public: private: struct TCacheEntry : TCacheEntryBase { - TCacheEntry(const TCacheEntryConfig& config_, TextureCache* parent, - std::unique_ptr texture, VkFramebuffer framebuffer); + TCacheEntry(const TCacheEntryConfig& config_, std::unique_ptr texture, + VkFramebuffer framebuffer); ~TCacheEntry(); Texture2D* GetTexture() const { return m_texture.get(); } @@ -55,7 +57,6 @@ private: bool Save(const std::string& filename, unsigned int level) override; private: - TextureCache* m_parent; std::unique_ptr m_texture; // If we're an EFB copy, framebuffer for drawing into. @@ -68,8 +69,6 @@ private: VkRenderPass GetRenderPassForTextureUpdate(const Texture2D* texture) const; - StateTracker* m_state_tracker = nullptr; - VkRenderPass m_initialize_render_pass = VK_NULL_HANDLE; VkRenderPass m_update_render_pass = VK_NULL_HANDLE; -- cgit v1.2.3 From 01b3c0f0362166ebf37983be1f5fc389550f6f05 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 22 Oct 2016 21:00:52 +1000 Subject: Vulkan: Make TextureCache::TCacheEntry public --- Source/Core/VideoBackends/Vulkan/TextureCache.h | 38 ++++++++++++------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/TextureCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.h b/Source/Core/VideoBackends/Vulkan/TextureCache.h index 1de1bbfc10..0b8bfa5ef3 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.h +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.h @@ -20,23 +20,6 @@ class TextureEncoder; class TextureCache : public TextureCacheBase { public: - TextureCache(); - ~TextureCache(); - - static TextureCache* GetInstance(); - - bool Initialize(); - - bool CompileShaders() override; - void DeleteShaders() override; - void ConvertTexture(TCacheEntryBase* base_entry, TCacheEntryBase* base_unconverted, void* palette, - TlutFormat format) override; - - void CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, - u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, - bool is_intensity, bool scale_by_half) override; - -private: struct TCacheEntry : TCacheEntryBase { TCacheEntry(const TCacheEntryConfig& config_, std::unique_ptr texture, @@ -58,15 +41,30 @@ private: private: std::unique_ptr m_texture; - - // If we're an EFB copy, framebuffer for drawing into. VkFramebuffer m_framebuffer; }; + TextureCache(); + ~TextureCache(); + + static TextureCache* GetInstance(); + + bool Initialize(); + + bool CompileShaders() override; + void DeleteShaders() override; + TCacheEntryBase* CreateTexture(const TCacheEntryConfig& config) override; - bool CreateRenderPasses(); + void ConvertTexture(TCacheEntryBase* base_entry, TCacheEntryBase* base_unconverted, void* palette, + TlutFormat format) override; + void CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, + u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, + bool is_intensity, bool scale_by_half) override; + +private: + bool CreateRenderPasses(); VkRenderPass GetRenderPassForTextureUpdate(const Texture2D* texture) const; VkRenderPass m_initialize_render_pass = VK_NULL_HANDLE; -- cgit v1.2.3 From 3593fa27abc9bce5ca6db9e6a22be8174fd4a60d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 22 Oct 2016 21:19:09 +1000 Subject: Vulkan: Move CopyRectangleFromTexture to TextureCache --- Source/Core/VideoBackends/Vulkan/TextureCache.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Source/Core/VideoBackends/Vulkan/TextureCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.h b/Source/Core/VideoBackends/Vulkan/TextureCache.h index 0b8bfa5ef3..34654e5bc3 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.h +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.h @@ -63,10 +63,21 @@ public: u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, bool is_intensity, bool scale_by_half) override; + void CopyRectangleFromTexture(TCacheEntry* dst_texture, const MathUtil::Rectangle& dst_rect, + Texture2D* src_texture, const MathUtil::Rectangle& src_rect); + private: bool CreateRenderPasses(); VkRenderPass GetRenderPassForTextureUpdate(const Texture2D* texture) const; + // Copies the contents of a texture using vkCmdCopyImage + void CopyTextureRectangle(TCacheEntry* dst_texture, const MathUtil::Rectangle& dst_rect, + Texture2D* src_texture, const MathUtil::Rectangle& src_rect); + + // Copies (and optionally scales) the contents of a texture using a framgent shader. + void ScaleTextureRectangle(TCacheEntry* dst_texture, const MathUtil::Rectangle& dst_rect, + Texture2D* src_texture, const MathUtil::Rectangle& src_rect); + VkRenderPass m_initialize_render_pass = VK_NULL_HANDLE; VkRenderPass m_update_render_pass = VK_NULL_HANDLE; -- cgit v1.2.3 From 5182e6b549f6b25379de840ee639cb8969423c8b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 22 Oct 2016 22:41:42 +1000 Subject: Vulkan: Implement virtual/real XFB support --- Source/Core/VideoBackends/Vulkan/TextureCache.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Source/Core/VideoBackends/Vulkan/TextureCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.h b/Source/Core/VideoBackends/Vulkan/TextureCache.h index 34654e5bc3..5da9515991 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.h +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.h @@ -66,6 +66,14 @@ public: void CopyRectangleFromTexture(TCacheEntry* dst_texture, const MathUtil::Rectangle& dst_rect, Texture2D* src_texture, const MathUtil::Rectangle& src_rect); + // Encodes texture to guest memory in XFB (YUYV) format. + void EncodeYUYVTextureToMemory(void* dst_ptr, u32 dst_width, u32 dst_stride, u32 dst_height, + Texture2D* src_texture, const MathUtil::Rectangle& src_rect); + + // Decodes data from guest memory in XFB (YUYV) format to a RGBA format texture on the GPU. + void DecodeYUYVTextureFromMemory(TCacheEntry* dst_texture, const void* src_ptr, u32 src_width, + u32 src_stride, u32 src_height); + private: bool CreateRenderPasses(); VkRenderPass GetRenderPassForTextureUpdate(const Texture2D* texture) const; @@ -90,6 +98,8 @@ private: VkShaderModule m_copy_shader = VK_NULL_HANDLE; VkShaderModule m_efb_color_to_tex_shader = VK_NULL_HANDLE; VkShaderModule m_efb_depth_to_tex_shader = VK_NULL_HANDLE; + VkShaderModule m_rgb_to_yuyv_shader = VK_NULL_HANDLE; + VkShaderModule m_yuyv_to_rgb_shader = VK_NULL_HANDLE; }; } // namespace Vulkan -- cgit v1.2.3