diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 1e2c34ae4..63633ab3b 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -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); diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 8deebce53..66ab8c9da 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -374,10 +374,11 @@ protected: BitField m_supports_per_sample_shading; BitField m_supports_dual_source_blend; BitField m_supports_adaptive_downsampling; - BitField m_per_sample_shading; - BitField m_scaled_dithering; - BitField m_chroma_smoothing; - BitField m_disable_color_perspective; + BitField m_supports_disable_color_perspective; + BitField m_per_sample_shading; + BitField m_scaled_dithering; + BitField m_chroma_smoothing; + BitField m_disable_color_perspective; u8 bits = 0; }; diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index b6794b7b0..d96ac916a 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -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++) diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index 277e380b0..6be7f1e62 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -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); diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index a19e42099..3efdafa6d 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -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() diff --git a/src/core/gpu_hw_vulkan.cpp b/src/core/gpu_hw_vulkan.cpp index 02bdaaa3e..ed345e323 100644 --- a/src/core/gpu_hw_vulkan.cpp +++ b/src/core/gpu_hw_vulkan.cpp @@ -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) diff --git a/src/core/shader_cache_version.h b/src/core/shader_cache_version.h index f867c0411..5ff168003 100644 --- a/src/core/shader_cache_version.h +++ b/src/core/shader_cache_version.h @@ -1,4 +1,4 @@ #pragma once #include "types.h" -static constexpr u32 SHADER_CACHE_VERSION = 6; \ No newline at end of file +static constexpr u32 SHADER_CACHE_VERSION = 7; \ No newline at end of file diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 68fae71f2..c005cabe2 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -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,