From d670948ad2ba0f1b759db2292dd11e9305ec2822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 5 Nov 2017 10:08:41 +0100 Subject: [PATCH] Cleanups and fixes around Vulkan stencil upload. thx unknown --- GPU/D3D11/StencilBufferD3D11.cpp | 3 --- GPU/Vulkan/StencilBufferVulkan.cpp | 19 ++++++------------- GPU/Vulkan/VulkanUtil.cpp | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/GPU/D3D11/StencilBufferD3D11.cpp b/GPU/D3D11/StencilBufferD3D11.cpp index c8825d121b..9a8a44a888 100644 --- a/GPU/D3D11/StencilBufferD3D11.cpp +++ b/GPU/D3D11/StencilBufferD3D11.cpp @@ -28,9 +28,6 @@ #include "GPU/D3D11/TextureCacheD3D11.h" #include "GPU/D3D11/D3D11Util.h" -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - struct StencilValueUB { uint32_t u_stencilValue[4]; }; diff --git a/GPU/Vulkan/StencilBufferVulkan.cpp b/GPU/Vulkan/StencilBufferVulkan.cpp index 2958ba6518..effbb8a779 100644 --- a/GPU/Vulkan/StencilBufferVulkan.cpp +++ b/GPU/Vulkan/StencilBufferVulkan.cpp @@ -27,29 +27,22 @@ #include "GPU/Vulkan/TextureCacheVulkan.h" #include "GPU/Vulkan/VulkanUtil.h" -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - -struct StencilValueUB { - uint32_t u_stencilValue[4]; -}; - static const char *stencil_fs = R"(#version 400 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable layout (binding = 0) uniform sampler2D tex; layout(push_constant) uniform params { - int u_stencilValue; + int u_stencilValue; }; layout (location = 0) in vec2 v_texcoord0; layout (location = 0) out vec4 fragColor0; void main() { - vec4 index = texture(tex, v_texcoord0); + vec4 index = texture(tex, v_texcoord0); int indexBits = int(floor(index.a * 255.99)) & 0xFF; if ((indexBits & u_stencilValue) == 0) discard; - fragColor0 = index.aaaa; + fragColor0 = index.aaaa; } )"; @@ -60,9 +53,9 @@ layout (location = 0) out vec2 v_texcoord0; out gl_PerVertex { vec4 gl_Position; }; void main() { int id = gl_VertexIndex; - v_texcoord0.x = (id == 2) ? 2.0 : 0.0; - v_texcoord0.y = (id == 1) ? 2.0 : 0.0; - gl_Position = vec4(v_texcoord0 * vec2(2.0, 2.0) + vec2(-1.0, -1.0), 0.0, 1.0); + v_texcoord0.x = (id == 2) ? 2.0 : 0.0; + v_texcoord0.y = (id == 1) ? 2.0 : 0.0; + gl_Position = vec4(v_texcoord0 * vec2(2.0, 2.0) + vec2(-1.0, -1.0), 0.0, 1.0); } )"; diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 14ba80dccb..01d001a0e3 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -210,7 +210,7 @@ VkPipeline Vulkan2D::GetPipeline(VkRenderPass rp, VkShaderModule vs, VkShaderMod VkPipelineColorBlendAttachmentState blend0 = {}; blend0.blendEnable = false; - blend0.colorWriteMask = depthStencilMode == VK2DDepthStencilMode::STENCIL_REPLACE_ALWAYS ? 0 : 0xF; + blend0.colorWriteMask = depthStencilMode == VK2DDepthStencilMode::STENCIL_REPLACE_ALWAYS ? VK_COLOR_COMPONENT_A_BIT : 0xF; VkPipelineColorBlendStateCreateInfo cbs = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; cbs.pAttachments = &blend0;