Browse Source

[TEST] ASTC fixes

vk-experiments9
CamilleLaVey 5 days ago
parent
commit
b38556d4f6
  1. 4
      src/video_core/host_shaders/astc_decoder.comp
  2. 27
      src/video_core/renderer_vulkan/vk_texture_cache.cpp
  3. 1
      src/video_core/renderer_vulkan/vk_texture_cache.h
  4. 3
      src/video_core/vulkan_common/vulkan_device.cpp
  5. 3
      src/video_core/vulkan_common/vulkan_device.h

4
src/video_core/host_shaders/astc_decoder.comp

@ -1384,11 +1384,7 @@ void DecompressBlock(ivec3 coord) {
p = Cf / 65535.0f; p = Cf / 65535.0f;
} }
#ifdef VULKAN
imageStore(dest_image, coord + ivec3(i, j, 0), p.gbar);
#else
imageStore(dest_image, coord + ivec3(i, j, 0), clamp(p, 0.0f, 1.0f).gbar); imageStore(dest_image, coord + ivec3(i, j, 0), clamp(p, 0.0f, 1.0f).gbar);
#endif
} }
} }
} }

27
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -144,11 +144,6 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
info.size.depth == 1; info.size.depth == 1;
} }
[[nodiscard]] bool WillUseWidenedAstcFormat(const Device& device, const ImageInfo& info) {
return WillUseAcceleratedAstcDecode(device, info) &&
!VideoCore::Surface::IsPixelFormatSRGB(info.format);
}
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info, [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
std::optional<VkFormat> format_override = {}) { std::optional<VkFormat> format_override = {}) {
auto format_info = auto format_info =
@ -1810,12 +1805,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
: VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler}, : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler},
runtime{&runtime_}, runtime{&runtime_},
original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info,
WillUseWidenedAstcFormat(runtime_.device, info)
? std::span<const VkFormat>{}
: runtime->ViewFormats(info.format),
WillUseWidenedAstcFormat(runtime_.device, info)
? std::make_optional(VK_FORMAT_R32G32B32A32_SFLOAT)
: std::nullopt)),
runtime->ViewFormats(info.format))),
aspect_mask(ImageAspectMask(info.format)) { aspect_mask(ImageAspectMask(info.format)) {
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) {
switch (Settings::values.accelerate_astc.GetValue()) { switch (Settings::values.accelerate_astc.GetValue()) {
@ -1846,9 +1836,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
Settings::values.astc_recompression.GetValue() == Settings::values.astc_recompression.GetValue() ==
Settings::AstcRecompression::Uncompressed) { Settings::AstcRecompression::Uncompressed) {
const auto& device = runtime->device.GetLogical(); const auto& device = runtime->device.GetLogical();
const VkFormat storage_format = WillUseWidenedAstcFormat(runtime->device, info)
? VK_FORMAT_R32G32B32A32_SFLOAT
: VK_FORMAT_A8B8G8R8_UNORM_PACK32;
const VkFormat storage_format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
for (s32 level = 0; level < info.resources.levels; ++level) { for (s32 level = 0; level < info.resources.levels; ++level) {
storage_image_views[level] = storage_image_views[level] =
MakeStorageView(device, level, *original_image, storage_format); MakeStorageView(device, level, *original_image, storage_format);
@ -2239,9 +2227,7 @@ VkImageView Image::StorageImageView(s32 level) noexcept {
auto format_info = auto format_info =
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format); MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
if (WillUseAcceleratedAstcDecode(runtime->device, info)) { if (WillUseAcceleratedAstcDecode(runtime->device, info)) {
format_info.format = WillUseWidenedAstcFormat(runtime->device, info)
? VK_FORMAT_R32G32B32A32_SFLOAT
: VK_FORMAT_A8B8G8R8_UNORM_PACK32;
format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
} }
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image), view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image),
format_info.format); format_info.format);
@ -2417,11 +2403,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
SanitizeDepthStencilSwizzle(swizzle, device->SupportsDepthStencilSwizzleOne()); SanitizeDepthStencilSwizzle(swizzle, device->SupportsDepthStencilSwizzleOne());
} }
} }
uses_widened_astc_format = WillUseWidenedAstcFormat(*device, image.info);
auto format_info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format); auto format_info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format);
if (uses_widened_astc_format) {
format_info.format = VK_FORMAT_R32G32B32A32_SFLOAT;
}
if (device->ApiVersion() >= VK_API_VERSION_1_3) { if (device->ApiVersion() >= VK_API_VERSION_1_3) {
const VkFormatProperties3 properties3 = const VkFormatProperties3 properties3 =
device->GetPhysical().GetFormatProperties3(format_info.format); device->GetPhysical().GetFormatProperties3(format_info.format);
@ -2567,9 +2549,6 @@ VkImageView ImageView::StorageView(Shader::TextureType texture_type,
auto& view{typeless_storage_views[static_cast<size_t>(texture_type)]}; auto& view{typeless_storage_views[static_cast<size_t>(texture_type)]};
if (!view) { if (!view) {
auto info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format); auto info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format);
if (uses_widened_astc_format) {
info.format = VK_FORMAT_R32G32B32A32_SFLOAT;
}
view = MakeView(info.format, VK_IMAGE_ASPECT_COLOR_BIT, texture_type); view = MakeView(info.format, VK_IMAGE_ASPECT_COLOR_BIT, texture_type);
} }
return *view; return *view;

1
src/video_core/renderer_vulkan/vk_texture_cache.h

@ -449,7 +449,6 @@ private:
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT; VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT;
u32 buffer_size = 0; u32 buffer_size = 0;
bool uses_widened_astc_format = false;
bool supports_depth_comparison = false; bool supports_depth_comparison = false;
}; };

3
src/video_core/vulkan_common/vulkan_device.cpp

@ -837,7 +837,8 @@ bool Device::ComputeIsOptimalAstcSupported() const {
VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SRGB_BLOCK, VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SRGB_BLOCK, VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
}; };
if (!features.features.textureCompressionASTC_LDR) {
if (!features.features.textureCompressionASTC_LDR ||
!features.texture_compression_astc_hdr.textureCompressionASTC_HDR) {
return false; return false;
} }
const auto format_feature_usage{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | const auto format_feature_usage{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |

3
src/video_core/vulkan_common/vulkan_device.h

@ -380,8 +380,7 @@ FN_MAX_LIMIT_LIST
} }
bool IsOptimalAstcSupported() const { bool IsOptimalAstcSupported() const {
return features.features.textureCompressionASTC_LDR &&
features.texture_compression_astc_hdr.textureCompressionASTC_HDR;
return is_optimal_astc_supported;
} }
/// Returns true if BCn is natively supported. /// Returns true if BCn is natively supported.

Loading…
Cancel
Save