diff options
| author | 2021-08-01 18:57:45 -0300 | |
|---|---|---|
| committer | 2021-11-16 22:11:29 +0100 | |
| commit | e66d5b88a6f1c2d85c5cd8e351c6ed52c96a0ecf (patch) | |
| tree | 0107548906df0b9d42e89451489be6a54ed71bf3 /src/video_core/renderer_vulkan | |
| parent | shader: Properly blacklist and scale image loads (diff) | |
| download | yuzu-e66d5b88a6f1c2d85c5cd8e351c6ed52c96a0ecf.tar.gz yuzu-e66d5b88a6f1c2d85c5cd8e351c6ed52c96a0ecf.tar.xz yuzu-e66d5b88a6f1c2d85c5cd8e351c6ed52c96a0ecf.zip | |
shader: Properly scale image reads and add GL SPIR-V support
Thanks for everything!
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/pipeline_helper.h | 22 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 3 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h index bce4220c6..85ae726d1 100644 --- a/src/video_core/renderer_vulkan/pipeline_helper.h +++ b/src/video_core/renderer_vulkan/pipeline_helper.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "shader_recompiler/backend/spirv/emit_spirv.h" | ||
| 13 | #include "shader_recompiler/shader_info.h" | 14 | #include "shader_recompiler/shader_info.h" |
| 14 | #include "video_core/renderer_vulkan/vk_texture_cache.h" | 15 | #include "video_core/renderer_vulkan/vk_texture_cache.h" |
| 15 | #include "video_core/renderer_vulkan/vk_update_descriptor.h" | 16 | #include "video_core/renderer_vulkan/vk_update_descriptor.h" |
| @@ -20,7 +21,7 @@ | |||
| 20 | 21 | ||
| 21 | namespace Vulkan { | 22 | namespace Vulkan { |
| 22 | 23 | ||
| 23 | constexpr size_t MAX_RESCALING_WORDS = 4; | 24 | using Shader::Backend::SPIRV::NUM_TEXTURE_AND_IMAGE_SCALING_WORDS; |
| 24 | 25 | ||
| 25 | class DescriptorLayoutBuilder { | 26 | class DescriptorLayoutBuilder { |
| 26 | public: | 27 | public: |
| @@ -74,7 +75,8 @@ public: | |||
| 74 | .stageFlags = static_cast<VkShaderStageFlags>( | 75 | .stageFlags = static_cast<VkShaderStageFlags>( |
| 75 | is_compute ? VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_ALL_GRAPHICS), | 76 | is_compute ? VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_ALL_GRAPHICS), |
| 76 | .offset = 0, | 77 | .offset = 0, |
| 77 | .size = (is_compute ? 0 : sizeof(f32)) + sizeof(std::array<u32, MAX_RESCALING_WORDS>), | 78 | .size = (is_compute ? 0 : sizeof(f32)) + |
| 79 | sizeof(std::array<u32, NUM_TEXTURE_AND_IMAGE_SCALING_WORDS>), | ||
| 78 | }; | 80 | }; |
| 79 | return device->GetLogical().CreatePipelineLayout({ | 81 | return device->GetLogical().CreatePipelineLayout({ |
| 80 | .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, | 82 | .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, |
| @@ -146,14 +148,25 @@ public: | |||
| 146 | } | 148 | } |
| 147 | } | 149 | } |
| 148 | 150 | ||
| 149 | const std::array<u32, MAX_RESCALING_WORDS>& Data() const noexcept { | 151 | void PushImage(bool is_rescaled) noexcept { |
| 152 | *image_ptr |= is_rescaled ? image_bit : 0; | ||
| 153 | image_bit <<= 1; | ||
| 154 | if (image_bit == 0) { | ||
| 155 | image_bit = 1u; | ||
| 156 | ++image_ptr; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 160 | const std::array<u32, NUM_TEXTURE_AND_IMAGE_SCALING_WORDS>& Data() const noexcept { | ||
| 150 | return words; | 161 | return words; |
| 151 | } | 162 | } |
| 152 | 163 | ||
| 153 | private: | 164 | private: |
| 154 | std::array<u32, MAX_RESCALING_WORDS> words{}; | 165 | std::array<u32, NUM_TEXTURE_AND_IMAGE_SCALING_WORDS> words{}; |
| 155 | u32* texture_ptr{words.data()}; | 166 | u32* texture_ptr{words.data()}; |
| 167 | u32* image_ptr{words.data() + Shader::Backend::SPIRV::NUM_TEXTURE_SCALING_WORDS}; | ||
| 156 | u32 texture_bit{1u}; | 168 | u32 texture_bit{1u}; |
| 169 | u32 image_bit{1u}; | ||
| 157 | }; | 170 | }; |
| 158 | 171 | ||
| 159 | inline void PushImageDescriptors(TextureCache& texture_cache, | 172 | inline void PushImageDescriptors(TextureCache& texture_cache, |
| @@ -181,6 +194,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache, | |||
| 181 | } | 194 | } |
| 182 | const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)}; | 195 | const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)}; |
| 183 | update_descriptor_queue.AddImage(vk_image_view); | 196 | update_descriptor_queue.AddImage(vk_image_view); |
| 197 | rescaling.PushImage(texture_cache.IsRescaling(image_view)); | ||
| 184 | } | 198 | } |
| 185 | } | 199 | } |
| 186 | } | 200 | } |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 691ef0841..eb8b4e08b 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -139,9 +139,6 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program | |||
| 139 | } else { | 139 | } else { |
| 140 | info.previous_stage_stores.mask.set(); | 140 | info.previous_stage_stores.mask.set(); |
| 141 | } | 141 | } |
| 142 | for (const auto& stage : programs) { | ||
| 143 | info.num_textures += Shader::NumDescriptors(stage.info.texture_descriptors); | ||
| 144 | } | ||
| 145 | const Shader::Stage stage{program.stage}; | 142 | const Shader::Stage stage{program.stage}; |
| 146 | const bool has_geometry{key.unique_hashes[4] != 0 && !programs[4].is_geometry_passthrough}; | 143 | const bool has_geometry{key.unique_hashes[4] != 0 && !programs[4].is_geometry_passthrough}; |
| 147 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; | 144 | const bool gl_ndc{key.state.ndc_minus_one_to_one != 0}; |