From d1dd910f1743d579ede07418508688f586b165c2 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 27 Dec 2016 12:59:52 +1000 Subject: [PATCH 1/2] Vulkan: Clear alpha channel to 0 when pixel format has no alpha channel --- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 9c558aa9f9..4097b31ab6 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -345,9 +345,10 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha bpmem.zcontrol.pixel_format == PEControl::RGB8_Z24 || bpmem.zcontrol.pixel_format == PEControl::Z24) { - // Force alpha writes, and set the color to 0xFF. + // Force alpha writes, and clear the alpha channel. This is different to the other backends, + // where the existing values of the alpha channel are preserved. alpha_enable = true; - color |= 0xFF000000; + color &= 0x00FFFFFF; } // Convert RGBA8 -> floating-point values. From e6249619a0262a0da5827e0c6d26f63fbfcad156 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 27 Dec 2016 13:05:17 +1000 Subject: [PATCH 2/2] Vulkan/GL: Set the alpha channel to 0 when creating the EFB framebuffer --- Source/Core/VideoBackends/OGL/FramebufferManager.cpp | 4 ++-- Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp index 2a99f25826..b4a8f0f024 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp @@ -233,10 +233,10 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_efbDepth, 0, i); } - // EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f + // EFB framebuffer is currently bound, make sure to clear it before use. glViewport(0, 0, m_targetWidth, m_targetHeight); glScissor(0, 0, m_targetWidth, m_targetHeight); - glClearColor(0.f, 0.f, 0.f, 1.f); + glClearColor(0.f, 0.f, 0.f, 0.f); glClearDepthf(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp index e102be287a..f5c0e038f6 100644 --- a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp @@ -333,7 +333,7 @@ bool FramebufferManager::CreateEFBFramebuffer() VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // Clear the contents of the buffers. - static const VkClearColorValue clear_color = {{0.0f, 0.0f, 0.0f, 1.0f}}; + static const VkClearColorValue clear_color = {{0.0f, 0.0f, 0.0f, 0.0f}}; static const VkClearDepthStencilValue clear_depth = {0.0f, 0}; VkImageSubresourceRange clear_color_range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, m_efb_layers}; VkImageSubresourceRange clear_depth_range = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, m_efb_layers};