diff options
| author | 2021-06-19 00:55:13 -0400 | |
|---|---|---|
| committer | 2021-06-19 09:00:33 -0400 | |
| commit | 31b125ef578dd5df4e289d1057154dd34f73cb19 (patch) | |
| tree | c44e0bfe5d201587da1de1351692617f24769b98 /src/video_core/renderer_vulkan | |
| parent | Merge pull request #6484 from CaptV0rt3x/discord-rpc (diff) | |
| download | yuzu-31b125ef578dd5df4e289d1057154dd34f73cb19.tar.gz yuzu-31b125ef578dd5df4e289d1057154dd34f73cb19.tar.xz yuzu-31b125ef578dd5df4e289d1057154dd34f73cb19.zip | |
astc: Various robustness enhancements for the gpu decoder
These changes should help in reducing crashes/drivers panics that may
occur due to synchronization issues between the shader completion and
later access of the decoded texture.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_compute_pass.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp index e11406e58..123bed794 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp | |||
| @@ -40,9 +40,9 @@ constexpr u32 ASTC_BINDING_ENC_BUFFER = 1; | |||
| 40 | constexpr u32 ASTC_BINDING_6_TO_8_BUFFER = 2; | 40 | constexpr u32 ASTC_BINDING_6_TO_8_BUFFER = 2; |
| 41 | constexpr u32 ASTC_BINDING_7_TO_8_BUFFER = 3; | 41 | constexpr u32 ASTC_BINDING_7_TO_8_BUFFER = 3; |
| 42 | constexpr u32 ASTC_BINDING_8_TO_8_BUFFER = 4; | 42 | constexpr u32 ASTC_BINDING_8_TO_8_BUFFER = 4; |
| 43 | constexpr u32 ASTC_BINDING_BYTE_TO_16_BUFFER = 5; | 43 | constexpr u32 ASTC_BINDING_SWIZZLE_BUFFER = 5; |
| 44 | constexpr u32 ASTC_BINDING_SWIZZLE_BUFFER = 6; | 44 | constexpr u32 ASTC_BINDING_OUTPUT_IMAGE = 6; |
| 45 | constexpr u32 ASTC_BINDING_OUTPUT_IMAGE = 7; | 45 | constexpr size_t ASTC_NUM_BINDINGS = 7; |
| 46 | 46 | ||
| 47 | VkPushConstantRange BuildComputePushConstantRange(std::size_t size) { | 47 | VkPushConstantRange BuildComputePushConstantRange(std::size_t size) { |
| 48 | return { | 48 | return { |
| @@ -71,7 +71,7 @@ std::array<VkDescriptorSetLayoutBinding, 2> BuildInputOutputDescriptorSetBinding | |||
| 71 | }}; | 71 | }}; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | std::array<VkDescriptorSetLayoutBinding, 8> BuildASTCDescriptorSetBindings() { | 74 | std::array<VkDescriptorSetLayoutBinding, ASTC_NUM_BINDINGS> BuildASTCDescriptorSetBindings() { |
| 75 | return {{ | 75 | return {{ |
| 76 | { | 76 | { |
| 77 | .binding = ASTC_BINDING_INPUT_BUFFER, | 77 | .binding = ASTC_BINDING_INPUT_BUFFER, |
| @@ -109,13 +109,6 @@ std::array<VkDescriptorSetLayoutBinding, 8> BuildASTCDescriptorSetBindings() { | |||
| 109 | .pImmutableSamplers = nullptr, | 109 | .pImmutableSamplers = nullptr, |
| 110 | }, | 110 | }, |
| 111 | { | 111 | { |
| 112 | .binding = ASTC_BINDING_BYTE_TO_16_BUFFER, | ||
| 113 | .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | ||
| 114 | .descriptorCount = 1, | ||
| 115 | .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT, | ||
| 116 | .pImmutableSamplers = nullptr, | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | .binding = ASTC_BINDING_SWIZZLE_BUFFER, | 112 | .binding = ASTC_BINDING_SWIZZLE_BUFFER, |
| 120 | .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | 113 | .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 121 | .descriptorCount = 1, | 114 | .descriptorCount = 1, |
| @@ -143,7 +136,8 @@ VkDescriptorUpdateTemplateEntryKHR BuildInputOutputDescriptorUpdateTemplate() { | |||
| 143 | }; | 136 | }; |
| 144 | } | 137 | } |
| 145 | 138 | ||
| 146 | std::array<VkDescriptorUpdateTemplateEntryKHR, 8> BuildASTCPassDescriptorUpdateTemplateEntry() { | 139 | std::array<VkDescriptorUpdateTemplateEntryKHR, ASTC_NUM_BINDINGS> |
| 140 | BuildASTCPassDescriptorUpdateTemplateEntry() { | ||
| 147 | return {{ | 141 | return {{ |
| 148 | { | 142 | { |
| 149 | .dstBinding = ASTC_BINDING_INPUT_BUFFER, | 143 | .dstBinding = ASTC_BINDING_INPUT_BUFFER, |
| @@ -186,14 +180,6 @@ std::array<VkDescriptorUpdateTemplateEntryKHR, 8> BuildASTCPassDescriptorUpdateT | |||
| 186 | .stride = sizeof(DescriptorUpdateEntry), | 180 | .stride = sizeof(DescriptorUpdateEntry), |
| 187 | }, | 181 | }, |
| 188 | { | 182 | { |
| 189 | .dstBinding = ASTC_BINDING_BYTE_TO_16_BUFFER, | ||
| 190 | .dstArrayElement = 0, | ||
| 191 | .descriptorCount = 1, | ||
| 192 | .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | ||
| 193 | .offset = ASTC_BINDING_BYTE_TO_16_BUFFER * sizeof(DescriptorUpdateEntry), | ||
| 194 | .stride = sizeof(DescriptorUpdateEntry), | ||
| 195 | }, | ||
| 196 | { | ||
| 197 | .dstBinding = ASTC_BINDING_SWIZZLE_BUFFER, | 183 | .dstBinding = ASTC_BINDING_SWIZZLE_BUFFER, |
| 198 | .dstArrayElement = 0, | 184 | .dstArrayElement = 0, |
| 199 | .descriptorCount = 1, | 185 | .descriptorCount = 1, |
| @@ -222,15 +208,6 @@ struct AstcPushConstants { | |||
| 222 | u32 block_height_mask; | 208 | u32 block_height_mask; |
| 223 | }; | 209 | }; |
| 224 | 210 | ||
| 225 | struct AstcBufferData { | ||
| 226 | decltype(SWIZZLE_TABLE) swizzle_table_buffer = SWIZZLE_TABLE; | ||
| 227 | decltype(EncodingsValues) encoding_values = EncodingsValues; | ||
| 228 | decltype(REPLICATE_6_BIT_TO_8_TABLE) replicate_6_to_8 = REPLICATE_6_BIT_TO_8_TABLE; | ||
| 229 | decltype(REPLICATE_7_BIT_TO_8_TABLE) replicate_7_to_8 = REPLICATE_7_BIT_TO_8_TABLE; | ||
| 230 | decltype(REPLICATE_8_BIT_TO_8_TABLE) replicate_8_to_8 = REPLICATE_8_BIT_TO_8_TABLE; | ||
| 231 | decltype(REPLICATE_BYTE_TO_16_TABLE) replicate_byte_to_16 = REPLICATE_BYTE_TO_16_TABLE; | ||
| 232 | } constexpr ASTC_BUFFER_DATA; | ||
| 233 | |||
| 234 | } // Anonymous namespace | 211 | } // Anonymous namespace |
| 235 | 212 | ||
| 236 | VKComputePass::VKComputePass(const Device& device, VKDescriptorPool& descriptor_pool, | 213 | VKComputePass::VKComputePass(const Device& device, VKDescriptorPool& descriptor_pool, |
| @@ -517,9 +494,6 @@ void ASTCDecoderPass::Assemble(Image& image, const StagingBufferRef& map, | |||
| 517 | sizeof(AstcBufferData::replicate_7_to_8)); | 494 | sizeof(AstcBufferData::replicate_7_to_8)); |
| 518 | update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, replicate_8_to_8), | 495 | update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, replicate_8_to_8), |
| 519 | sizeof(AstcBufferData::replicate_8_to_8)); | 496 | sizeof(AstcBufferData::replicate_8_to_8)); |
| 520 | update_descriptor_queue.AddBuffer(*data_buffer, | ||
| 521 | offsetof(AstcBufferData, replicate_byte_to_16), | ||
| 522 | sizeof(AstcBufferData::replicate_byte_to_16)); | ||
| 523 | update_descriptor_queue.AddBuffer(*data_buffer, sizeof(AstcBufferData), | 497 | update_descriptor_queue.AddBuffer(*data_buffer, sizeof(AstcBufferData), |
| 524 | sizeof(SWIZZLE_TABLE)); | 498 | sizeof(SWIZZLE_TABLE)); |
| 525 | update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level)); | 499 | update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level)); |
| @@ -569,6 +543,7 @@ void ASTCDecoderPass::Assemble(Image& image, const StagingBufferRef& map, | |||
| 569 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, | 543 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, |
| 570 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, image_barrier); | 544 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, image_barrier); |
| 571 | }); | 545 | }); |
| 546 | scheduler.Finish(); | ||
| 572 | } | 547 | } |
| 573 | 548 | ||
| 574 | } // namespace Vulkan | 549 | } // namespace Vulkan |