summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar Fernando S2023-05-24 03:55:45 +0200
committerGravatar GitHub2023-05-24 03:55:45 +0200
commit76f63889692a0836dafd626841aa050ef26b407b (patch)
tree442b586dc2ead257e4411101b05a06298c97e423 /src/video_core/renderer_vulkan
parentMerge pull request #10388 from GPUCode/fence-wait (diff)
parenttextures: add BC1 and BC3 compressors and recompression setting (diff)
downloadyuzu-76f63889692a0836dafd626841aa050ef26b407b.tar.gz
yuzu-76f63889692a0836dafd626841aa050ef26b407b.tar.xz
yuzu-76f63889692a0836dafd626841aa050ef26b407b.zip
Merge pull request #10398 from liamwhite/bcn
video_core: add ASTC recompression
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp24
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp8
2 files changed, 24 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index 8853cf0f7..b75d7220d 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -6,6 +6,7 @@
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "common/settings.h"
9#include "video_core/engines/maxwell_3d.h" 10#include "video_core/engines/maxwell_3d.h"
10#include "video_core/renderer_vulkan/maxwell_to_vk.h" 11#include "video_core/renderer_vulkan/maxwell_to_vk.h"
11#include "video_core/surface.h" 12#include "video_core/surface.h"
@@ -237,14 +238,25 @@ FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with
237 PixelFormat pixel_format) { 238 PixelFormat pixel_format) {
238 ASSERT(static_cast<size_t>(pixel_format) < std::size(tex_format_tuples)); 239 ASSERT(static_cast<size_t>(pixel_format) < std::size(tex_format_tuples));
239 FormatTuple tuple = tex_format_tuples[static_cast<size_t>(pixel_format)]; 240 FormatTuple tuple = tex_format_tuples[static_cast<size_t>(pixel_format)];
240 // Use A8B8G8R8_UNORM on hardware that doesn't support ASTC natively 241 // Transcode on hardware that doesn't support ASTC natively
241 if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) { 242 if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) {
242 const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format); 243 const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format);
243 if (is_srgb) { 244
244 tuple.format = VK_FORMAT_A8B8G8R8_SRGB_PACK32; 245 switch (Settings::values.astc_recompression.GetValue()) {
245 } else { 246 case Settings::AstcRecompression::Uncompressed:
246 tuple.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32; 247 if (is_srgb) {
247 tuple.usage |= Storage; 248 tuple.format = VK_FORMAT_A8B8G8R8_SRGB_PACK32;
249 } else {
250 tuple.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
251 tuple.usage |= Storage;
252 }
253 break;
254 case Settings::AstcRecompression::Bc1:
255 tuple.format = is_srgb ? VK_FORMAT_BC1_RGBA_SRGB_BLOCK : VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
256 break;
257 case Settings::AstcRecompression::Bc3:
258 tuple.format = is_srgb ? VK_FORMAT_BC3_SRGB_BLOCK : VK_FORMAT_BC3_UNORM_BLOCK;
259 break;
248 } 260 }
249 } 261 }
250 const bool attachable = (tuple.usage & Attachable) != 0; 262 const bool attachable = (tuple.usage & Attachable) != 0;
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index da5af25eb..8711e2a87 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1272,7 +1272,9 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
1272 if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { 1272 if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) {
1273 if (Settings::values.async_astc.GetValue()) { 1273 if (Settings::values.async_astc.GetValue()) {
1274 flags |= VideoCommon::ImageFlagBits::AsynchronousDecode; 1274 flags |= VideoCommon::ImageFlagBits::AsynchronousDecode;
1275 } else if (Settings::values.accelerate_astc.GetValue() && info.size.depth == 1) { 1275 } else if (Settings::values.astc_recompression.GetValue() ==
1276 Settings::AstcRecompression::Uncompressed &&
1277 Settings::values.accelerate_astc.GetValue() && info.size.depth == 1) {
1276 flags |= VideoCommon::ImageFlagBits::AcceleratedUpload; 1278 flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;
1277 } 1279 }
1278 flags |= VideoCommon::ImageFlagBits::Converted; 1280 flags |= VideoCommon::ImageFlagBits::Converted;
@@ -1287,7 +1289,9 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
1287 .usage = VK_IMAGE_USAGE_STORAGE_BIT, 1289 .usage = VK_IMAGE_USAGE_STORAGE_BIT,
1288 }; 1290 };
1289 current_image = *original_image; 1291 current_image = *original_image;
1290 if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { 1292 if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() &&
1293 Settings::values.astc_recompression.GetValue() ==
1294 Settings::AstcRecompression::Uncompressed) {
1291 const auto& device = runtime->device.GetLogical(); 1295 const auto& device = runtime->device.GetLogical();
1292 storage_image_views.reserve(info.resources.levels); 1296 storage_image_views.reserve(info.resources.levels);
1293 for (s32 level = 0; level < info.resources.levels; ++level) { 1297 for (s32 level = 0; level < info.resources.levels; ++level) {