GPU/Vulkan: Fix downloads messing up later commands

This commit is contained in:
Connor McLaughlin 2022-10-05 17:41:55 +10:00
parent 564a9bdeb4
commit 5f6490f68b
8 changed files with 25 additions and 15 deletions

View File

@ -69,7 +69,7 @@ bool GPU_HW::Initialize()
m_using_uv_limits = ShouldUseUVLimits();
m_chroma_smoothing = g_settings.gpu_24bit_chroma_smoothing;
m_downsample_mode = GetDownsampleMode(m_resolution_scale);
m_disable_color_perspective = ShouldDisableColorPerspective();
m_disable_color_perspective = m_supports_disable_color_perspective && ShouldDisableColorPerspective();
if (m_multisamples != g_settings.gpu_multisamples)
{
@ -96,6 +96,8 @@ bool GPU_HW::Initialize()
"OSDMessage", "Adaptive downsampling is not supported with the current renderer, using box filter instead."),
20.0f);
}
if (!m_supports_disable_color_perspective && !ShouldDisableColorPerspective())
Log_WarningPrint("Disable color perspective not supported, but should be used.");
m_pgxp_depth_buffer = g_settings.UsingPGXPDepthBuffer();
@ -146,7 +148,7 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
const bool per_sample_shading = g_settings.gpu_per_sample_shading && m_supports_per_sample_shading;
const GPUDownsampleMode downsample_mode = GetDownsampleMode(resolution_scale);
const bool use_uv_limits = ShouldUseUVLimits();
const bool disable_color_perspective = ShouldDisableColorPerspective();
const bool disable_color_perspective = m_supports_disable_color_perspective && ShouldDisableColorPerspective();
*framebuffer_changed =
(m_resolution_scale != resolution_scale || m_multisamples != multisamples || m_downsample_mode != downsample_mode);

View File

@ -374,10 +374,11 @@ protected:
BitField<u8, bool, 0, 1> m_supports_per_sample_shading;
BitField<u8, bool, 1, 1> m_supports_dual_source_blend;
BitField<u8, bool, 2, 1> m_supports_adaptive_downsampling;
BitField<u8, bool, 3, 1> m_per_sample_shading;
BitField<u8, bool, 4, 1> m_scaled_dithering;
BitField<u8, bool, 5, 1> m_chroma_smoothing;
BitField<u8, bool, 6, 1> m_disable_color_perspective;
BitField<u8, bool, 3, 1> m_supports_disable_color_perspective;
BitField<u8, bool, 4, 1> m_per_sample_shading;
BitField<u8, bool, 5, 1> m_scaled_dithering;
BitField<u8, bool, 6, 1> m_chroma_smoothing;
BitField<u8, bool, 7, 1> m_disable_color_perspective;
u8 bits = 0;
};

View File

@ -232,6 +232,7 @@ void GPU_HW_D3D11::SetCapabilities()
m_supports_dual_source_blend = true;
m_supports_per_sample_shading = (m_device->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_1);
m_supports_adaptive_downsampling = true;
m_supports_disable_color_perspective = true;
m_max_multisamples = 1;
for (u32 multisamples = 2; multisamples < D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; multisamples++)

View File

@ -240,6 +240,7 @@ void GPU_HW_D3D12::SetCapabilities()
m_supports_dual_source_blend = true;
m_supports_per_sample_shading = true;
m_supports_disable_color_perspective = true;
Log_InfoPrintf("Dual-source blend: %s", m_supports_dual_source_blend ? "supported" : "not supported");
Log_InfoPrintf("Per-sample shading: %s", m_supports_per_sample_shading ? "supported" : "not supported");
Log_InfoPrintf("Max multisamples: %u", m_max_multisamples);

View File

@ -384,6 +384,9 @@ void GPU_HW_OpenGL::SetCapabilities()
// adaptive smoothing would require texture views, which aren't in GLES.
m_supports_adaptive_downsampling = false;
// noperspective is not supported in GLSL ES.
m_supports_disable_color_perspective = (g_host_display->GetRenderAPI() == RenderAPI::OpenGL);
}
bool GPU_HW_OpenGL::CreateFramebuffer()

View File

@ -327,6 +327,7 @@ void GPU_HW_Vulkan::SetCapabilities()
m_supports_dual_source_blend = g_vulkan_context->GetDeviceFeatures().dualSrcBlend;
m_supports_per_sample_shading = g_vulkan_context->GetDeviceFeatures().sampleRateShading;
m_supports_adaptive_downsampling = true;
m_supports_disable_color_perspective = true;
Log_InfoPrintf("Dual-source blend: %s", m_supports_dual_source_blend ? "supported" : "not supported");
Log_InfoPrintf("Per-sample shading: %s", m_supports_per_sample_shading ? "supported" : "not supported");
@ -1575,6 +1576,8 @@ void GPU_HW_Vulkan::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
g_host_display->DownloadTexture(&m_vram_readback_texture, 0, 0, encoded_width, encoded_height,
&m_vram_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left],
VRAM_WIDTH * sizeof(u16));
RestoreGraphicsAPIState();
}
void GPU_HW_Vulkan::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)

View File

@ -1,4 +1,4 @@
#pragma once
#include "types.h"
static constexpr u32 SHADER_CACHE_VERSION = 6;
static constexpr u32 SHADER_CACHE_VERSION = 7;

View File

@ -269,17 +269,16 @@ VkRenderPass VulkanHostDisplay::GetRenderPassForDisplay() const
void VulkanHostDisplay::DestroyStagingBuffer()
{
if (m_readback_staging_buffer == VK_NULL_HANDLE)
return;
vmaDestroyBuffer(g_vulkan_context->GetAllocator(), m_readback_staging_buffer, m_readback_staging_allocation);
// unmapped as part of the buffer destroy
m_readback_staging_buffer = VK_NULL_HANDLE;
m_readback_staging_allocation = VK_NULL_HANDLE;
m_readback_staging_buffer_map = nullptr;
m_readback_staging_buffer_size = 0;
if (m_readback_staging_buffer != VK_NULL_HANDLE)
{
vmaDestroyBuffer(g_vulkan_context->GetAllocator(), m_readback_staging_buffer, m_readback_staging_allocation);
m_readback_staging_buffer = VK_NULL_HANDLE;
m_readback_staging_allocation = VK_NULL_HANDLE;
m_readback_staging_buffer_size = 0;
}
}
bool VulkanHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data,