summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ameerj2021-06-19 10:56:13 -0400
committerGravatar ameerj2021-06-19 10:56:13 -0400
commitace20ba4a4774ae3c42f2ef5566c7113f3b980b3 (patch)
tree088a7d63269fcd65e84d465cc2c821662674cffc /src/video_core/renderer_vulkan
parentastc: Various robustness enhancements for the gpu decoder (diff)
downloadyuzu-ace20ba4a4774ae3c42f2ef5566c7113f3b980b3.tar.gz
yuzu-ace20ba4a4774ae3c42f2ef5566c7113f3b980b3.tar.xz
yuzu-ace20ba4a4774ae3c42f2ef5566c7113f3b980b3.zip
astc_decoder.comp: Remove unnecessary LUT SSBOs
We can move them to instead be compile time constants within the shader.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pass.cpp74
1 files changed, 10 insertions, 64 deletions
diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp
index 123bed794..205cd3b05 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp
+++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp
@@ -30,19 +30,16 @@
30namespace Vulkan { 30namespace Vulkan {
31 31
32using Tegra::Texture::SWIZZLE_TABLE; 32using Tegra::Texture::SWIZZLE_TABLE;
33using Tegra::Texture::ASTC::EncodingsValues; 33using Tegra::Texture::ASTC::ASTC_ENCODINGS_VALUES;
34using namespace Tegra::Texture::ASTC; 34using namespace Tegra::Texture::ASTC;
35 35
36namespace { 36namespace {
37 37
38constexpr u32 ASTC_BINDING_INPUT_BUFFER = 0; 38constexpr u32 ASTC_BINDING_INPUT_BUFFER = 0;
39constexpr u32 ASTC_BINDING_ENC_BUFFER = 1; 39constexpr u32 ASTC_BINDING_ENC_BUFFER = 1;
40constexpr u32 ASTC_BINDING_6_TO_8_BUFFER = 2; 40constexpr u32 ASTC_BINDING_SWIZZLE_BUFFER = 2;
41constexpr u32 ASTC_BINDING_7_TO_8_BUFFER = 3; 41constexpr u32 ASTC_BINDING_OUTPUT_IMAGE = 3;
42constexpr u32 ASTC_BINDING_8_TO_8_BUFFER = 4; 42constexpr size_t ASTC_NUM_BINDINGS = 4;
43constexpr u32 ASTC_BINDING_SWIZZLE_BUFFER = 5;
44constexpr u32 ASTC_BINDING_OUTPUT_IMAGE = 6;
45constexpr size_t ASTC_NUM_BINDINGS = 7;
46 43
47VkPushConstantRange BuildComputePushConstantRange(std::size_t size) { 44VkPushConstantRange BuildComputePushConstantRange(std::size_t size) {
48 return { 45 return {
@@ -88,27 +85,6 @@ std::array<VkDescriptorSetLayoutBinding, ASTC_NUM_BINDINGS> BuildASTCDescriptorS
88 .pImmutableSamplers = nullptr, 85 .pImmutableSamplers = nullptr,
89 }, 86 },
90 { 87 {
91 .binding = ASTC_BINDING_6_TO_8_BUFFER,
92 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
93 .descriptorCount = 1,
94 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
95 .pImmutableSamplers = nullptr,
96 },
97 {
98 .binding = ASTC_BINDING_7_TO_8_BUFFER,
99 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
100 .descriptorCount = 1,
101 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
102 .pImmutableSamplers = nullptr,
103 },
104 {
105 .binding = ASTC_BINDING_8_TO_8_BUFFER,
106 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
107 .descriptorCount = 1,
108 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
109 .pImmutableSamplers = nullptr,
110 },
111 {
112 .binding = ASTC_BINDING_SWIZZLE_BUFFER, 88 .binding = ASTC_BINDING_SWIZZLE_BUFFER,
113 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 89 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
114 .descriptorCount = 1, 90 .descriptorCount = 1,
@@ -156,30 +132,6 @@ BuildASTCPassDescriptorUpdateTemplateEntry() {
156 .stride = sizeof(DescriptorUpdateEntry), 132 .stride = sizeof(DescriptorUpdateEntry),
157 }, 133 },
158 { 134 {
159 .dstBinding = ASTC_BINDING_6_TO_8_BUFFER,
160 .dstArrayElement = 0,
161 .descriptorCount = 1,
162 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
163 .offset = ASTC_BINDING_6_TO_8_BUFFER * sizeof(DescriptorUpdateEntry),
164 .stride = sizeof(DescriptorUpdateEntry),
165 },
166 {
167 .dstBinding = ASTC_BINDING_7_TO_8_BUFFER,
168 .dstArrayElement = 0,
169 .descriptorCount = 1,
170 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
171 .offset = ASTC_BINDING_7_TO_8_BUFFER * sizeof(DescriptorUpdateEntry),
172 .stride = sizeof(DescriptorUpdateEntry),
173 },
174 {
175 .dstBinding = ASTC_BINDING_8_TO_8_BUFFER,
176 .dstArrayElement = 0,
177 .descriptorCount = 1,
178 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
179 .offset = ASTC_BINDING_8_TO_8_BUFFER * sizeof(DescriptorUpdateEntry),
180 .stride = sizeof(DescriptorUpdateEntry),
181 },
182 {
183 .dstBinding = ASTC_BINDING_SWIZZLE_BUFFER, 135 .dstBinding = ASTC_BINDING_SWIZZLE_BUFFER,
184 .dstArrayElement = 0, 136 .dstArrayElement = 0,
185 .descriptorCount = 1, 137 .descriptorCount = 1,
@@ -400,7 +352,7 @@ ASTCDecoderPass::ASTCDecoderPass(const Device& device_, VKScheduler& scheduler_,
400ASTCDecoderPass::~ASTCDecoderPass() = default; 352ASTCDecoderPass::~ASTCDecoderPass() = default;
401 353
402void ASTCDecoderPass::MakeDataBuffer() { 354void ASTCDecoderPass::MakeDataBuffer() {
403 constexpr size_t TOTAL_BUFFER_SIZE = sizeof(ASTC_BUFFER_DATA) + sizeof(SWIZZLE_TABLE); 355 constexpr size_t TOTAL_BUFFER_SIZE = sizeof(ASTC_ENCODINGS_VALUES) + sizeof(SWIZZLE_TABLE);
404 data_buffer = device.GetLogical().CreateBuffer(VkBufferCreateInfo{ 356 data_buffer = device.GetLogical().CreateBuffer(VkBufferCreateInfo{
405 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, 357 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
406 .pNext = nullptr, 358 .pNext = nullptr,
@@ -414,9 +366,10 @@ void ASTCDecoderPass::MakeDataBuffer() {
414 data_buffer_commit = memory_allocator.Commit(data_buffer, MemoryUsage::Upload); 366 data_buffer_commit = memory_allocator.Commit(data_buffer, MemoryUsage::Upload);
415 367
416 const auto staging_ref = staging_buffer_pool.Request(TOTAL_BUFFER_SIZE, MemoryUsage::Upload); 368 const auto staging_ref = staging_buffer_pool.Request(TOTAL_BUFFER_SIZE, MemoryUsage::Upload);
417 std::memcpy(staging_ref.mapped_span.data(), &ASTC_BUFFER_DATA, sizeof(ASTC_BUFFER_DATA)); 369 std::memcpy(staging_ref.mapped_span.data(), &ASTC_ENCODINGS_VALUES,
370 sizeof(ASTC_ENCODINGS_VALUES));
418 // Tack on the swizzle table at the end of the buffer 371 // Tack on the swizzle table at the end of the buffer
419 std::memcpy(staging_ref.mapped_span.data() + sizeof(ASTC_BUFFER_DATA), &SWIZZLE_TABLE, 372 std::memcpy(staging_ref.mapped_span.data() + sizeof(ASTC_ENCODINGS_VALUES), &SWIZZLE_TABLE,
420 sizeof(SWIZZLE_TABLE)); 373 sizeof(SWIZZLE_TABLE));
421 374
422 scheduler.Record([src = staging_ref.buffer, offset = staging_ref.offset, dst = *data_buffer, 375 scheduler.Record([src = staging_ref.buffer, offset = staging_ref.offset, dst = *data_buffer,
@@ -486,15 +439,8 @@ void ASTCDecoderPass::Assemble(Image& image, const StagingBufferRef& map,
486 update_descriptor_queue.Acquire(); 439 update_descriptor_queue.Acquire();
487 update_descriptor_queue.AddBuffer(map.buffer, input_offset, 440 update_descriptor_queue.AddBuffer(map.buffer, input_offset,
488 image.guest_size_bytes - swizzle.buffer_offset); 441 image.guest_size_bytes - swizzle.buffer_offset);
489 update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, encoding_values), 442 update_descriptor_queue.AddBuffer(*data_buffer, 0, sizeof(ASTC_ENCODINGS_VALUES));
490 sizeof(AstcBufferData::encoding_values)); 443 update_descriptor_queue.AddBuffer(*data_buffer, sizeof(ASTC_ENCODINGS_VALUES),
491 update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, replicate_6_to_8),
492 sizeof(AstcBufferData::replicate_6_to_8));
493 update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, replicate_7_to_8),
494 sizeof(AstcBufferData::replicate_7_to_8));
495 update_descriptor_queue.AddBuffer(*data_buffer, offsetof(AstcBufferData, replicate_8_to_8),
496 sizeof(AstcBufferData::replicate_8_to_8));
497 update_descriptor_queue.AddBuffer(*data_buffer, sizeof(AstcBufferData),
498 sizeof(SWIZZLE_TABLE)); 444 sizeof(SWIZZLE_TABLE));
499 update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level)); 445 update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
500 446