From 1a3e8357fab8c5dfb9531c8dae0ae5b68bcef157 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Mon, 8 Jul 2024 14:22:29 +0200 Subject: [PATCH] set blend color --- src/core/renderer_mtl/renderer_mtl.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/renderer_mtl/renderer_mtl.cpp b/src/core/renderer_mtl/renderer_mtl.cpp index 06637e2b..2ce430c6 100644 --- a/src/core/renderer_mtl/renderer_mtl.cpp +++ b/src/core/renderer_mtl/renderer_mtl.cpp @@ -524,12 +524,6 @@ void RendererMTL::drawVertices(PICA::PrimType primType, std::span(pipelineHash.constantColor); - //const u8 b = Helpers::getBits<16, 8>(pipelineHash.constantColor); - //const u8 a = Helpers::getBits<24, 8>(pipelineHash.constantColor); } else { logicOp = Helpers::getBits<0, 4>(regs[PICA::InternalRegs::LogicOp]); } @@ -569,6 +563,17 @@ void RendererMTL::drawVertices(PICA::PrimType primType, std::spansetVertexBuffer(buffer.buffer, buffer.offset, VERTEX_BUFFER_BINDING_INDEX); } + // Blend color + if (pipelineHash.blendEnabled) { + u32 constantColor = regs[PICA::InternalRegs::BlendColour]; + const u8 r = constantColor & 0xff; + const u8 g = Helpers::getBits<8, 8>(constantColor); + const u8 b = Helpers::getBits<16, 8>(constantColor); + const u8 a = Helpers::getBits<24, 8>(constantColor); + + renderCommandEncoder->setBlendColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); + } + // Bind resources setupTextureEnvState(renderCommandEncoder); bindTexturesToSlots(renderCommandEncoder);