diff options
| author | Tilka <tilkax@gmail.com> | 2019-02-26 04:21:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-26 04:21:05 +0000 |
| commit | 6ce7f44b8a0bb3b95d3f12ebffbef7a71a443fdd (patch) | |
| tree | 98380ce3a3284c52597a6fba86589c847219ecd5 /Source/Core/VideoBackends/Vulkan/ObjectCache.h | |
| parent | 19673ce79af814ca3b77d7f8ea60458e564bfa51 (diff) | |
| parent | f039149198657c1891e1c6462ed30c31ed4b8486 (diff) | |
Merge pull request #7753 from stenzek/videocommon-all-the-things
Move a significant amount of video backend logic to VideoCommon
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/ObjectCache.h')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/ObjectCache.h | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.h b/Source/Core/VideoBackends/Vulkan/ObjectCache.h index c3502f7c66..794c52c0f0 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.h +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.h @@ -16,7 +16,6 @@ #include "Common/LinearDiskCache.h" #include "VideoBackends/Vulkan/Constants.h" -#include "VideoBackends/Vulkan/Texture2D.h" #include "VideoCommon/GeometryShaderGen.h" #include "VideoCommon/PixelShaderGen.h" @@ -27,6 +26,7 @@ namespace Vulkan { class CommandBufferManager; class VertexFormat; +class VKTexture; class StreamBuffer; class ObjectCache @@ -35,29 +35,23 @@ public: ObjectCache(); ~ObjectCache(); + // Perform at startup, create descriptor layouts, compiles all static shaders. + bool Initialize(); + void Shutdown(); + // Descriptor set layout accessor. Used for allocating descriptor sets. VkDescriptorSetLayout GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT layout) const { return m_descriptor_set_layouts[layout]; } + // Pipeline layout accessor. Used to fill in required field in PipelineInfo. VkPipelineLayout GetPipelineLayout(PIPELINE_LAYOUT layout) const { return m_pipeline_layouts[layout]; } - // Shared utility shader resources - VertexFormat* GetUtilityShaderVertexFormat() const - { - return m_utility_shader_vertex_format.get(); - } - StreamBuffer* GetUtilityShaderVertexBuffer() const - { - return m_utility_shader_vertex_buffer.get(); - } - StreamBuffer* GetUtilityShaderUniformBuffer() const - { - return m_utility_shader_uniform_buffer.get(); - } + + // Staging buffer for textures. StreamBuffer* GetTextureUploadBuffer() const { return m_texture_upload_buffer.get(); } // Static samplers @@ -65,36 +59,39 @@ public: VkSampler GetLinearSampler() const { return m_linear_sampler; } VkSampler GetSampler(const SamplerState& info); - // Dummy image for samplers that are unbound - Texture2D* GetDummyImage() const { return m_dummy_texture.get(); } - VkImageView GetDummyImageView() const { return m_dummy_texture->GetView(); } // Render pass cache. VkRenderPass GetRenderPass(VkFormat color_format, VkFormat depth_format, u32 multisamples, VkAttachmentLoadOp load_op); - // Perform at startup, create descriptor layouts, compiles all static shaders. - bool Initialize(); + // Pipeline cache. Used when creating pipelines for drivers to store compiled programs. + VkPipelineCache GetPipelineCache() const { return m_pipeline_cache; } // Clear sampler cache, use when anisotropy mode changes // WARNING: Ensure none of the objects from here are in use when calling void ClearSamplerCache(); + // Saves the pipeline cache to disk. Call when shutting down. + void SavePipelineCache(); + + // Reload pipeline cache. Call when host config changes. + void ReloadPipelineCache(); + private: bool CreateDescriptorSetLayouts(); void DestroyDescriptorSetLayouts(); bool CreatePipelineLayouts(); void DestroyPipelineLayouts(); - bool CreateUtilityShaderVertexFormat(); bool CreateStaticSamplers(); void DestroySamplers(); void DestroyRenderPassCache(); + bool CreatePipelineCache(); + bool LoadPipelineCache(); + bool ValidatePipelineCache(const u8* data, size_t data_length); + void DestroyPipelineCache(); std::array<VkDescriptorSetLayout, NUM_DESCRIPTOR_SET_LAYOUTS> m_descriptor_set_layouts = {}; std::array<VkPipelineLayout, NUM_PIPELINE_LAYOUTS> m_pipeline_layouts = {}; - 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; @@ -103,11 +100,15 @@ private: std::map<SamplerState, VkSampler> m_sampler_cache; // Dummy image for samplers that are unbound - std::unique_ptr<Texture2D> m_dummy_texture; + std::unique_ptr<VKTexture> m_dummy_texture; // Render pass cache using RenderPassCacheKey = std::tuple<VkFormat, VkFormat, u32, VkAttachmentLoadOp>; std::map<RenderPassCacheKey, VkRenderPass> m_render_pass_cache; + + // pipeline cache + VkPipelineCache m_pipeline_cache = VK_NULL_HANDLE; + std::string m_pipeline_cache_filename; }; extern std::unique_ptr<ObjectCache> g_object_cache; |
