From be75a97efebc4259e8c974d0815a635f9dd16332 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 22 Jan 2025 18:23:11 +1000 Subject: [PATCH] GPUDevice: Fix swap chain clear colour normalization --- src/util/d3d11_device.cpp | 2 +- src/util/d3d12_device.cpp | 2 +- src/util/metal_device.mm | 2 +- src/util/opengl_device.cpp | 2 +- src/util/vulkan_device.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index a52295fa0..9429d147a 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -675,7 +675,7 @@ GPUDevice::PresentResult D3D11Device::BeginPresent(GPUSwapChain* swap_chain, u32 EndTimestampQuery(); } - m_context->ClearRenderTargetView(SC->GetRTV(), GSVector4::rgba32(clear_color).F32); + m_context->ClearRenderTargetView(SC->GetRTV(), GSVector4::unorm8(clear_color).F32); m_context->OMSetRenderTargets(1, SC->GetRTVArray(), nullptr); s_stats.num_render_passes++; m_num_current_render_targets = 0; diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index 3c00160bd..daf394bc0 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -1219,7 +1219,7 @@ GPUDevice::PresentResult D3D12Device::BeginPresent(GPUSwapChain* swap_chain, u32 D3D12_RENDER_PASS_RENDER_TARGET_DESC rt_desc = {swap_chain_buf.second, {D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR, {}}, {D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, {}}}; - GSVector4::store(rt_desc.BeginningAccess.Clear.ClearValue.Color, GSVector4::rgba32(clear_color)); + GSVector4::store(rt_desc.BeginningAccess.Clear.ClearValue.Color, GSVector4::unorm8(clear_color)); cmdlist->BeginRenderPass(1, &rt_desc, nullptr, D3D12_RENDER_PASS_FLAG_NONE); std::memset(m_current_render_targets.data(), 0, sizeof(m_current_render_targets)); diff --git a/src/util/metal_device.mm b/src/util/metal_device.mm index ac8ffe043..dea122d83 100644 --- a/src/util/metal_device.mm +++ b/src/util/metal_device.mm @@ -2595,7 +2595,7 @@ GPUDevice::PresentResult MetalDevice::BeginPresent(GPUSwapChain* swap_chain, u32 SetViewportAndScissor(m_current_framebuffer_size); // Set up rendering to layer. - const GSVector4 clear_color_v = GSVector4::rgba32(clear_color); + const GSVector4 clear_color_v = GSVector4::unorm8(clear_color); id layer_texture = [m_layer_drawable texture]; MTLRenderPassDescriptor* desc = [MTLRenderPassDescriptor renderPassDescriptor]; desc.colorAttachments[0].texture = layer_texture; diff --git a/src/util/opengl_device.cpp b/src/util/opengl_device.cpp index c77d391a2..f9c4ba2f0 100644 --- a/src/util/opengl_device.cpp +++ b/src/util/opengl_device.cpp @@ -797,7 +797,7 @@ GPUDevice::PresentResult OpenGLDevice::BeginPresent(GPUSwapChain* swap_chain, u3 glBindFramebuffer(GL_FRAMEBUFFER, 0); glDisable(GL_SCISSOR_TEST); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearBufferfv(GL_COLOR, 0, GSVector4::rgba32(clear_color).F32); + glClearBufferfv(GL_COLOR, 0, GSVector4::unorm8(clear_color).F32); glColorMask(m_last_blend_state.write_r, m_last_blend_state.write_g, m_last_blend_state.write_b, m_last_blend_state.write_a); glEnable(GL_SCISSOR_TEST); diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index e6a6ef1b4..d469b4ad9 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -3399,7 +3399,7 @@ void VulkanDevice::BeginSwapChainRenderPass(VulkanSwapChain* swap_chain, u32 cle } VkClearValue clear_value; - GSVector4::store(&clear_value.color.float32, GSVector4::rgba32(clear_color)); + GSVector4::store(&clear_value.color.float32, GSVector4::unorm8(clear_color)); if (m_optional_extensions.vk_khr_dynamic_rendering) { VkRenderingAttachmentInfo ai = {VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,