From 024ed01bbb94bd734b2aafa89c8c7d29a0af26c0 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 24 Nov 2019 23:30:35 +1000 Subject: [PATCH] GPU/HW: Set alpha to mask bit setting --- src/core/gpu_hw.cpp | 9 +++++++++ src/core/gpu_hw.h | 4 ++++ src/core/gpu_hw_shadergen.cpp | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 01dfb328e..d2b42ff79 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -310,6 +310,15 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 m_batch_ubo_dirty = true; } + if (m_batch.check_mask_before_draw != m_GPUSTAT.check_mask_before_draw || + m_batch.set_mask_while_drawing != m_GPUSTAT.set_mask_while_drawing) + { + m_batch.check_mask_before_draw = m_GPUSTAT.check_mask_before_draw; + m_batch.set_mask_while_drawing = m_GPUSTAT.set_mask_while_drawing; + m_batch_ubo_data.u_set_mask_while_drawing = BoolToUInt32(m_GPUSTAT.set_mask_while_drawing); + m_batch_ubo_dirty = true; + } + if (m_drawing_offset_changed) { m_drawing_offset_changed = false; diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index d639f7e49..cfae19715 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -71,6 +71,8 @@ protected: TextureMode texture_mode; TransparencyMode transparency_mode; bool dithering; + bool set_mask_while_drawing; + bool check_mask_before_draw; // We need two-pass rendering when using BG-FG blending and texturing, as the transparency can be enabled // on a per-pixel basis, and the opaque pixels shouldn't be blended at all. @@ -95,6 +97,8 @@ protected: u32 u_texture_window_offset[2]; float u_src_alpha_factor; float u_dst_alpha_factor; + u32 u_set_mask_while_drawing; + u32 padding[3]; }; struct RendererStats diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index eae80eda4..e93c4bc31 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -292,7 +292,7 @@ void GPU_HW_ShaderGen::DeclareFragmentEntryPoint(std::stringstream& ss, u32 num_ void GPU_HW_ShaderGen::WriteBatchUniformBuffer(std::stringstream& ss) { DeclareUniformBuffer(ss, {"int2 u_pos_offset", "uint2 u_texture_window_mask", "uint2 u_texture_window_offset", - "float u_src_alpha_factor", "float u_dst_alpha_factor"}); + "float u_src_alpha_factor", "float u_dst_alpha_factor", "bool u_set_mask_while_drawing"}); } std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured) @@ -505,7 +505,7 @@ int4 SampleFromVRAM(int4 texpage, float2 coord) #endif // Compute output alpha (mask bit) - float output_alpha = float(semitransparent); + float output_alpha = float(u_set_mask_while_drawing ? 1 : int(semitransparent)); // Normalize float3 color = float3(icolor) / float3(255.0, 255.0, 255.0);