2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

vk_texture_cache: Use 3D scale helpers for MSAA texture scaling on Intel Windows drivers

Fixes a crash when scaling MSAA textures in titles such as Sonic Colors Ultimate.
This commit is contained in:
ameerj 2021-12-23 22:30:10 -05:00
parent 516325eba8
commit f9e0681d59
4 changed files with 35 additions and 20 deletions

View file

@ -1344,7 +1344,6 @@ bool Image::ScaleUp(bool ignore) {
return false; return false;
} }
has_scaled = true; has_scaled = true;
const auto& device = runtime->device;
if (!scaled_image) { if (!scaled_image) {
const bool is_2d = info.type == ImageType::e2D; const bool is_2d = info.type == ImageType::e2D;
const u32 scaled_width = resolution.ScaleUp(info.size.width); const u32 scaled_width = resolution.ScaleUp(info.size.width);
@ -1352,7 +1351,7 @@ bool Image::ScaleUp(bool ignore) {
auto scaled_info = info; auto scaled_info = info;
scaled_info.size.width = scaled_width; scaled_info.size.width = scaled_width;
scaled_info.size.height = scaled_height; scaled_info.size.height = scaled_height;
scaled_image = MakeImage(device, scaled_info); scaled_image = MakeImage(runtime->device, scaled_info);
auto& allocator = runtime->memory_allocator; auto& allocator = runtime->memory_allocator;
scaled_commit = MemoryCommit(allocator.Commit(scaled_image, MemoryUsage::DeviceLocal)); scaled_commit = MemoryCommit(allocator.Commit(scaled_image, MemoryUsage::DeviceLocal));
ignore = false; ignore = false;
@ -1361,18 +1360,13 @@ bool Image::ScaleUp(bool ignore) {
if (ignore) { if (ignore) {
return true; return true;
} }
if (aspect_mask == 0) { if (aspect_mask == 0) {
aspect_mask = ImageAspectMask(info.format); aspect_mask = ImageAspectMask(info.format);
} }
static constexpr auto OPTIMAL_FORMAT = FormatType::Optimal; if (NeedsScaleHelper()) {
const PixelFormat format = StorageFormat(info.format);
const auto vk_format = MaxwellToVK::SurfaceFormat(device, OPTIMAL_FORMAT, false, format).format;
const auto blit_usage = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT;
if (device.IsFormatSupported(vk_format, blit_usage, OPTIMAL_FORMAT)) {
BlitScale(*scheduler, *original_image, *scaled_image, info, aspect_mask, resolution);
} else {
return BlitScaleHelper(true); return BlitScaleHelper(true);
} else {
BlitScale(*scheduler, *original_image, *scaled_image, info, aspect_mask, resolution);
} }
return true; return true;
} }
@ -1394,15 +1388,10 @@ bool Image::ScaleDown(bool ignore) {
if (aspect_mask == 0) { if (aspect_mask == 0) {
aspect_mask = ImageAspectMask(info.format); aspect_mask = ImageAspectMask(info.format);
} }
static constexpr auto OPTIMAL_FORMAT = FormatType::Optimal; if (NeedsScaleHelper()) {
const PixelFormat format = StorageFormat(info.format);
const auto& device = runtime->device;
const auto vk_format = MaxwellToVK::SurfaceFormat(device, OPTIMAL_FORMAT, false, format).format;
const auto blit_usage = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT;
if (device.IsFormatSupported(vk_format, blit_usage, OPTIMAL_FORMAT)) {
BlitScale(*scheduler, *scaled_image, *original_image, info, aspect_mask, resolution, false);
} else {
return BlitScaleHelper(false); return BlitScaleHelper(false);
} else {
BlitScale(*scheduler, *scaled_image, *original_image, info, aspect_mask, resolution, false);
} }
return true; return true;
} }
@ -1470,6 +1459,20 @@ bool Image::BlitScaleHelper(bool scale_up) {
return true; return true;
} }
bool Image::NeedsScaleHelper() const {
const auto& device = runtime->device;
const bool needs_msaa_helper = info.num_samples > 1 && device.CantBlitMSAA();
if (needs_msaa_helper) {
return true;
}
static constexpr auto OPTIMAL_FORMAT = FormatType::Optimal;
const PixelFormat format = StorageFormat(info.format);
const auto vk_format = MaxwellToVK::SurfaceFormat(device, OPTIMAL_FORMAT, false, format).format;
const auto blit_usage = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT;
const bool needs_blit_helper = !device.IsFormatSupported(vk_format, blit_usage, OPTIMAL_FORMAT);
return needs_blit_helper;
}
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
ImageId image_id_, Image& image) ImageId image_id_, Image& image)
: VideoCommon::ImageViewBase{info, image.info, image_id_}, device{&runtime.device}, : VideoCommon::ImageViewBase{info, image.info, image_id_}, device{&runtime.device},

View file

@ -148,6 +148,8 @@ public:
private: private:
bool BlitScaleHelper(bool scale_up); bool BlitScaleHelper(bool scale_up);
bool NeedsScaleHelper() const;
VKScheduler* scheduler{}; VKScheduler* scheduler{};
TextureCacheRuntime* runtime{}; TextureCacheRuntime* runtime{};

View file

@ -638,15 +638,20 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
} }
} }
if (ext_vertex_input_dynamic_state && driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { const bool is_intel_windows = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS;
if (ext_vertex_input_dynamic_state && is_intel_windows) {
LOG_WARNING(Render_Vulkan, "Blacklisting Intel for VK_EXT_vertex_input_dynamic_state"); LOG_WARNING(Render_Vulkan, "Blacklisting Intel for VK_EXT_vertex_input_dynamic_state");
ext_vertex_input_dynamic_state = false; ext_vertex_input_dynamic_state = false;
} }
if (is_float16_supported && driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { if (is_float16_supported && is_intel_windows) {
// Intel's compiler crashes when using fp16 on Astral Chain, disable it for the time being. // Intel's compiler crashes when using fp16 on Astral Chain, disable it for the time being.
LOG_WARNING(Render_Vulkan, "Blacklisting Intel proprietary from float16 math"); LOG_WARNING(Render_Vulkan, "Blacklisting Intel proprietary from float16 math");
is_float16_supported = false; is_float16_supported = false;
} }
if (is_intel_windows) {
LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits");
cant_blit_msaa = true;
}
supports_d24_depth = supports_d24_depth =
IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,

View file

@ -350,6 +350,10 @@ public:
return supports_d24_depth; return supports_d24_depth;
} }
bool CantBlitMSAA() const {
return cant_blit_msaa;
}
private: private:
/// Checks if the physical device is suitable. /// Checks if the physical device is suitable.
void CheckSuitability(bool requires_swapchain) const; void CheckSuitability(bool requires_swapchain) const;
@ -443,6 +447,7 @@ private:
bool has_renderdoc{}; ///< Has RenderDoc attached bool has_renderdoc{}; ///< Has RenderDoc attached
bool has_nsight_graphics{}; ///< Has Nsight Graphics attached bool has_nsight_graphics{}; ///< Has Nsight Graphics attached
bool supports_d24_depth{}; ///< Supports D24 depth buffers. bool supports_d24_depth{}; ///< Supports D24 depth buffers.
bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting.
// Telemetry parameters // Telemetry parameters
std::string vendor_name; ///< Device's driver name. std::string vendor_name; ///< Device's driver name.