@@ -92,6 +92,11 @@ MTL::RenderPipelineState* MetalPipelineCache::GetPipelineState(const LatteFetchS
92
92
desc->setFragmentFunction (mtlPixelShader->GetFunction ());
93
93
// TODO: don't always set the vertex descriptor?
94
94
desc->setVertexDescriptor (vertexDescriptor);
95
+
96
+ // Color attachments
97
+ const Latte::LATTE_CB_COLOR_CONTROL& colorControlReg = LatteGPUState.contextNew .CB_COLOR_CONTROL ;
98
+ uint32 blendEnableMask = colorControlReg.get_BLEND_MASK ();
99
+ uint32 renderTargetMask = LatteGPUState.contextNew .CB_TARGET_MASK .get_MASK ();
95
100
for (uint8 i = 0 ; i < 8 ; i++)
96
101
{
97
102
const auto & colorBuffer = activeFBO->colorBuffer [i];
@@ -102,12 +107,9 @@ MTL::RenderPipelineState* MetalPipelineCache::GetPipelineState(const LatteFetchS
102
107
}
103
108
auto colorAttachment = desc->colorAttachments ()->object (i);
104
109
colorAttachment->setPixelFormat (texture->GetRGBAView ()->pixelFormat ());
110
+ colorAttachment->setWriteMask (GetMtlColorWriteMask ((renderTargetMask >> (i * 4 )) & 0xF ));
105
111
106
112
// Blending
107
- const Latte::LATTE_CB_COLOR_CONTROL& colorControlReg = LatteGPUState.contextNew .CB_COLOR_CONTROL ;
108
- uint32 blendEnableMask = colorControlReg.get_BLEND_MASK ();
109
- uint32 renderTargetMask = LatteGPUState.contextNew .CB_TARGET_MASK .get_MASK ();
110
-
111
113
bool blendEnabled = ((blendEnableMask & (1 << i))) != 0 ;
112
114
// Only float data type is blendable
113
115
if (blendEnabled && GetMtlPixelFormatInfo (texture->format , false ).dataType == MetalDataType::FLOAT)
@@ -120,7 +122,6 @@ MTL::RenderPipelineState* MetalPipelineCache::GetPipelineState(const LatteFetchS
120
122
auto srcRgbBlendFactor = GetMtlBlendFactor (blendControlReg.get_COLOR_SRCBLEND ());
121
123
auto dstRgbBlendFactor = GetMtlBlendFactor (blendControlReg.get_COLOR_DSTBLEND ());
122
124
123
- colorAttachment->setWriteMask ((renderTargetMask >> (i * 4 )) & 0xF );
124
125
colorAttachment->setRgbBlendOperation (rgbBlendOp);
125
126
colorAttachment->setSourceRGBBlendFactor (srcRgbBlendFactor);
126
127
colorAttachment->setDestinationRGBBlendFactor (dstRgbBlendFactor);
@@ -138,6 +139,8 @@ MTL::RenderPipelineState* MetalPipelineCache::GetPipelineState(const LatteFetchS
138
139
}
139
140
}
140
141
}
142
+
143
+ // Depth stencil attachment
141
144
if (activeFBO->depthBuffer .texture )
142
145
{
143
146
auto texture = static_cast <LatteTextureViewMtl*>(activeFBO->depthBuffer .texture );
0 commit comments