renderer_vulkan: Fix incorrect depth format detection
* Intel iGPUs don't support blit on all depth/stencil formats which caused issues since the runtime checks for this while the renderpass cache does not
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -151,10 +151,9 @@ void Instance::CreateFormatTable() {
|
|||||||
VideoCore::PixelFormat::D24S8};
|
VideoCore::PixelFormat::D24S8};
|
||||||
|
|
||||||
const vk::FormatFeatureFlags storage_usage = vk::FormatFeatureFlagBits::eStorageImage;
|
const vk::FormatFeatureFlags storage_usage = vk::FormatFeatureFlagBits::eStorageImage;
|
||||||
|
const vk::FormatFeatureFlags transfer_usage = vk::FormatFeatureFlagBits::eSampledImage;
|
||||||
const vk::FormatFeatureFlags blit_usage =
|
const vk::FormatFeatureFlags blit_usage =
|
||||||
vk::FormatFeatureFlagBits::eSampledImage | vk::FormatFeatureFlagBits::eTransferDst |
|
vk::FormatFeatureFlagBits::eBlitSrc | vk::FormatFeatureFlagBits::eBlitDst;
|
||||||
vk::FormatFeatureFlagBits::eTransferSrc | vk::FormatFeatureFlagBits::eBlitSrc |
|
|
||||||
vk::FormatFeatureFlagBits::eBlitDst;
|
|
||||||
|
|
||||||
for (const auto& pixel_format : pixel_formats) {
|
for (const auto& pixel_format : pixel_formats) {
|
||||||
const vk::Format format = ToVkFormat(pixel_format);
|
const vk::Format format = ToVkFormat(pixel_format);
|
||||||
@ -166,6 +165,8 @@ void Instance::CreateFormatTable() {
|
|||||||
? vk::FormatFeatureFlagBits::eDepthStencilAttachment
|
? vk::FormatFeatureFlagBits::eDepthStencilAttachment
|
||||||
: vk::FormatFeatureFlagBits::eColorAttachment;
|
: vk::FormatFeatureFlagBits::eColorAttachment;
|
||||||
|
|
||||||
|
const bool supports_transfer =
|
||||||
|
(properties.optimalTilingFeatures & transfer_usage) == transfer_usage;
|
||||||
const bool supports_blit = (properties.optimalTilingFeatures & blit_usage) == blit_usage;
|
const bool supports_blit = (properties.optimalTilingFeatures & blit_usage) == blit_usage;
|
||||||
const bool supports_attachment =
|
const bool supports_attachment =
|
||||||
(properties.optimalTilingFeatures & attachment_usage) == attachment_usage;
|
(properties.optimalTilingFeatures & attachment_usage) == attachment_usage;
|
||||||
@ -174,7 +175,7 @@ void Instance::CreateFormatTable() {
|
|||||||
|
|
||||||
// Find the most inclusive usage flags for this format
|
// Find the most inclusive usage flags for this format
|
||||||
vk::ImageUsageFlags best_usage;
|
vk::ImageUsageFlags best_usage;
|
||||||
if (supports_blit) {
|
if (supports_blit || supports_transfer) {
|
||||||
best_usage |= vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst |
|
best_usage |= vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst |
|
||||||
vk::ImageUsageFlagBits::eTransferSrc;
|
vk::ImageUsageFlagBits::eTransferSrc;
|
||||||
}
|
}
|
||||||
@ -203,7 +204,8 @@ void Instance::CreateFormatTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const u32 index = static_cast<u32>(pixel_format);
|
const u32 index = static_cast<u32>(pixel_format);
|
||||||
format_table[index] = FormatTraits{.blit_support = supports_blit,
|
format_table[index] = FormatTraits{.transfer_support = supports_transfer,
|
||||||
|
.blit_support = supports_blit,
|
||||||
.attachment_support = supports_attachment,
|
.attachment_support = supports_attachment,
|
||||||
.storage_support = supports_storage,
|
.storage_support = supports_storage,
|
||||||
.usage = best_usage,
|
.usage = best_usage,
|
||||||
|
@ -19,7 +19,8 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
struct FormatTraits {
|
struct FormatTraits {
|
||||||
bool blit_support = false; ///< True if the format supports omnidirectonal blit operations
|
bool transfer_support = false; ///< True if the format supports transfer operations
|
||||||
|
bool blit_support = false; ///< True if the format supports blit operations
|
||||||
bool attachment_support = false; ///< True if the format supports being used as an attachment
|
bool attachment_support = false; ///< True if the format supports being used as an attachment
|
||||||
bool storage_support = false; ///< True if the format supports storage operations
|
bool storage_support = false; ///< True if the format supports storage operations
|
||||||
vk::ImageUsageFlags usage{}; ///< Most supported usage for the native format
|
vk::ImageUsageFlags usage{}; ///< Most supported usage for the native format
|
||||||
|
@ -661,7 +661,7 @@ void PipelineCache::SaveDiskCache() {
|
|||||||
cache_file.Close();
|
cache_file.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PipelineCache::IsCacheValid(const u8* data, u32 size) const {
|
bool PipelineCache::IsCacheValid(const u8* data, u64 size) const {
|
||||||
if (size < sizeof(vk::PipelineCacheHeaderVersionOne)) {
|
if (size < sizeof(vk::PipelineCacheHeaderVersionOne)) {
|
||||||
LOG_ERROR(Render_Vulkan, "Pipeline cache failed validation: Invalid header");
|
LOG_ERROR(Render_Vulkan, "Pipeline cache failed validation: Invalid header");
|
||||||
return false;
|
return false;
|
||||||
|
@ -213,7 +213,7 @@ private:
|
|||||||
void SaveDiskCache();
|
void SaveDiskCache();
|
||||||
|
|
||||||
/// Returns true when the disk data can be used by the current driver
|
/// Returns true when the disk data can be used by the current driver
|
||||||
bool IsCacheValid(const u8* data, u32 size) const;
|
bool IsCacheValid(const u8* data, u64 size) const;
|
||||||
|
|
||||||
/// Create shader disk cache directories. Returns true on success.
|
/// Create shader disk cache directories. Returns true on success.
|
||||||
bool EnsureDirectories() const;
|
bool EnsureDirectories() const;
|
||||||
|
@ -47,10 +47,15 @@ RenderpassCache::RenderpassCache(const Instance& instance, TaskScheduler& schedu
|
|||||||
const FormatTraits color_traits = instance.GetTraits(ToFormatColor(color));
|
const FormatTraits color_traits = instance.GetTraits(ToFormatColor(color));
|
||||||
const FormatTraits depth_traits = instance.GetTraits(ToFormatDepth(depth));
|
const FormatTraits depth_traits = instance.GetTraits(ToFormatDepth(depth));
|
||||||
|
|
||||||
const vk::Format color_format =
|
const vk::Format color_format = color_traits.transfer_support &&
|
||||||
color_traits.attachment_support ? color_traits.native : color_traits.fallback;
|
color_traits.blit_support &&
|
||||||
|
color_traits.attachment_support
|
||||||
|
? color_traits.native
|
||||||
|
: color_traits.fallback;
|
||||||
const vk::Format depth_format =
|
const vk::Format depth_format =
|
||||||
depth_traits.attachment_support ? depth_traits.native : depth_traits.fallback;
|
depth_traits.transfer_support && depth_traits.attachment_support
|
||||||
|
? depth_traits.native
|
||||||
|
: depth_traits.fallback;
|
||||||
|
|
||||||
if (color_format == vk::Format::eUndefined && depth_format == vk::Format::eUndefined) {
|
if (color_format == vk::Format::eUndefined && depth_format == vk::Format::eUndefined) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <thread>
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "video_core/renderer_vulkan/vk_common.h"
|
#include "video_core/renderer_vulkan/vk_common.h"
|
||||||
|
@ -115,7 +115,8 @@ ImageAlloc TextureRuntime::Allocate(u32 width, u32 height, VideoCore::PixelForma
|
|||||||
const FormatTraits traits = instance.GetTraits(format);
|
const FormatTraits traits = instance.GetTraits(format);
|
||||||
const vk::ImageAspectFlags aspect = ToVkAspect(VideoCore::GetFormatType(format));
|
const vk::ImageAspectFlags aspect = ToVkAspect(VideoCore::GetFormatType(format));
|
||||||
|
|
||||||
const bool is_suitable = traits.blit_support && traits.attachment_support;
|
const bool is_suitable = traits.transfer_support && traits.attachment_support &&
|
||||||
|
(traits.blit_support || aspect & vk::ImageAspectFlagBits::eDepth);
|
||||||
const vk::Format vk_format = is_suitable ? traits.native : traits.fallback;
|
const vk::Format vk_format = is_suitable ? traits.native : traits.fallback;
|
||||||
const vk::ImageUsageFlags vk_usage = is_suitable ? traits.usage : GetImageUsage(aspect);
|
const vk::ImageUsageFlags vk_usage = is_suitable ? traits.usage : GetImageUsage(aspect);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user