@@ -126,7 +126,10 @@ bool MetalRenderer::GetVRAMInfo(int& usageInMB, int& totalInMB) const
126
126
127
127
void MetalRenderer::ClearColorbuffer (bool padView)
128
128
{
129
- debug_printf (" MetalRenderer::ClearColorbuffer not implemented\n " );
129
+ if (!AcquireNextDrawable ())
130
+ return ;
131
+
132
+ ClearColorTextureInternal (m_drawable->texture (), 0 , 0 , 0 .0f , 0 .0f , 0 .0f , 0 .0f );
130
133
}
131
134
132
135
void MetalRenderer::DrawEmptyFrame (bool mainWindow)
@@ -283,19 +286,7 @@ void MetalRenderer::texture_clearColorSlice(LatteTexture* hostTexture, sint32 sl
283
286
{
284
287
auto mtlTexture = static_cast <LatteTextureMtl*>(hostTexture)->GetTexture ();
285
288
286
- MTL::RenderPassDescriptor* renderPassDescriptor = MTL::RenderPassDescriptor::alloc ()->init ();
287
- auto colorAttachment = renderPassDescriptor->colorAttachments ()->object (0 );
288
- colorAttachment->setTexture (mtlTexture);
289
- colorAttachment->setClearColor (MTL::ClearColor (r, g, b, a));
290
- colorAttachment->setLoadAction (MTL::LoadActionClear);
291
- colorAttachment->setStoreAction (MTL::StoreActionStore);
292
- colorAttachment->setSlice (sliceIndex);
293
- colorAttachment->setLevel (mipIndex);
294
-
295
- MTL::Texture* colorRenderTargets[8 ] = {nullptr };
296
- colorRenderTargets[0 ] = mtlTexture;
297
- GetRenderCommandEncoder (renderPassDescriptor, colorRenderTargets, nullptr , true );
298
- renderPassDescriptor->release ();
289
+ ClearColorTextureInternal (mtlTexture, sliceIndex, mipIndex, r, g, b, a);
299
290
}
300
291
301
292
void MetalRenderer::texture_clearDepthSlice (LatteTexture* hostTexture, uint32 sliceIndex, sint32 mipIndex, bool clearDepth, bool clearStencil, float depthValue, uint32 stencilValue)
@@ -1162,3 +1153,20 @@ void MetalRenderer::RebindRenderState(MTL::RenderCommandEncoder* renderCommandEn
1162
1153
}
1163
1154
}
1164
1155
}
1156
+
1157
+ void MetalRenderer::ClearColorTextureInternal (MTL::Texture* mtlTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a)
1158
+ {
1159
+ MTL::RenderPassDescriptor* renderPassDescriptor = MTL::RenderPassDescriptor::alloc ()->init ();
1160
+ auto colorAttachment = renderPassDescriptor->colorAttachments ()->object (0 );
1161
+ colorAttachment->setTexture (mtlTexture);
1162
+ colorAttachment->setClearColor (MTL::ClearColor (r, g, b, a));
1163
+ colorAttachment->setLoadAction (MTL::LoadActionClear);
1164
+ colorAttachment->setStoreAction (MTL::StoreActionStore);
1165
+ colorAttachment->setSlice (sliceIndex);
1166
+ colorAttachment->setLevel (mipIndex);
1167
+
1168
+ MTL::Texture* colorRenderTargets[8 ] = {nullptr };
1169
+ colorRenderTargets[0 ] = mtlTexture;
1170
+ GetRenderCommandEncoder (renderPassDescriptor, colorRenderTargets, nullptr , true );
1171
+ renderPassDescriptor->release ();
1172
+ }
0 commit comments