[Vulkan] Native 24-bit unorm depth where available
This commit is contained in:
parent
83e9984539
commit
2621dabf0f
|
@ -183,9 +183,22 @@ VulkanRenderTargetCache::~VulkanRenderTargetCache() { Shutdown(true); }
|
|||
bool VulkanRenderTargetCache::Initialize() {
|
||||
const ui::vulkan::VulkanProvider& provider =
|
||||
command_processor_.GetVulkanProvider();
|
||||
const ui::vulkan::VulkanProvider::InstanceFunctions& ifn = provider.ifn();
|
||||
VkPhysicalDevice physical_device = provider.physical_device();
|
||||
const ui::vulkan::VulkanProvider::DeviceFunctions& dfn = provider.dfn();
|
||||
VkDevice device = provider.device();
|
||||
|
||||
// Format support.
|
||||
constexpr VkFormatFeatureFlags kUsedDepthFormatFeatures =
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
VkFormatProperties depth_unorm24_properties;
|
||||
ifn.vkGetPhysicalDeviceFormatProperties(
|
||||
physical_device, VK_FORMAT_D24_UNORM_S8_UINT, &depth_unorm24_properties);
|
||||
depth_unorm24_vulkan_format_supported_ =
|
||||
(depth_unorm24_properties.optimalTilingFeatures &
|
||||
kUsedDepthFormatFeatures) == kUsedDepthFormatFeatures;
|
||||
|
||||
// Descriptor set layouts.
|
||||
VkDescriptorSetLayoutBinding descriptor_set_layout_bindings[2];
|
||||
descriptor_set_layout_bindings[0].binding = 0;
|
||||
|
@ -1235,7 +1248,10 @@ VkRenderPass VulkanRenderTargetCache::GetRenderPass(RenderPassKey key) {
|
|||
|
||||
VkFormat VulkanRenderTargetCache::GetDepthVulkanFormat(
|
||||
xenos::DepthRenderTargetFormat format) const {
|
||||
// TODO(Triang3l): Conditional 24-bit depth.
|
||||
if (format == xenos::DepthRenderTargetFormat::kD24S8 &&
|
||||
depth_unorm24_vulkan_format_supported()) {
|
||||
return VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
}
|
||||
return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
}
|
||||
|
||||
|
@ -1582,6 +1598,18 @@ RenderTargetCache::RenderTarget* VulkanRenderTargetCache::CreateRenderTarget(
|
|||
descriptor_set_index_transfer_source);
|
||||
}
|
||||
|
||||
bool VulkanRenderTargetCache::IsHostDepthEncodingDifferent(
|
||||
xenos::DepthRenderTargetFormat format) const {
|
||||
// TODO(Triang3l): Conversion directly in shaders.
|
||||
switch (format) {
|
||||
case xenos::DepthRenderTargetFormat::kD24S8:
|
||||
return !depth_unorm24_vulkan_format_supported();
|
||||
case xenos::DepthRenderTargetFormat::kD24FS8:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VulkanRenderTargetCache::GetEdramBufferUsageMasks(
|
||||
EdramBufferUsage usage, VkPipelineStageFlags& stage_mask_out,
|
||||
VkAccessFlags& access_mask_out) {
|
||||
|
|
|
@ -142,6 +142,9 @@ class VulkanRenderTargetCache final : public RenderTargetCache {
|
|||
!cvars::snorm16_render_target_full_range;
|
||||
}
|
||||
|
||||
bool depth_unorm24_vulkan_format_supported() const {
|
||||
return depth_unorm24_vulkan_format_supported_;
|
||||
}
|
||||
bool depth_float24_round() const { return depth_float24_round_; }
|
||||
|
||||
bool msaa_2x_attachments_supported() const {
|
||||
|
@ -172,11 +175,8 @@ class VulkanRenderTargetCache final : public RenderTargetCache {
|
|||
|
||||
RenderTarget* CreateRenderTarget(RenderTargetKey key) override;
|
||||
|
||||
// TODO(Triang3l): Check actual unorm24 support.
|
||||
bool IsHostDepthEncodingDifferent(
|
||||
xenos::DepthRenderTargetFormat format) const override {
|
||||
return true;
|
||||
}
|
||||
xenos::DepthRenderTargetFormat format) const override;
|
||||
|
||||
private:
|
||||
enum class EdramBufferUsage {
|
||||
|
@ -840,6 +840,7 @@ class VulkanRenderTargetCache final : public RenderTargetCache {
|
|||
|
||||
bool gamma_render_target_as_srgb_ = false;
|
||||
|
||||
bool depth_unorm24_vulkan_format_supported_ = false;
|
||||
bool depth_float24_round_ = false;
|
||||
|
||||
bool msaa_2x_attachments_supported_ = false;
|
||||
|
|
Loading…
Reference in New Issue