@@ -60,14 +60,12 @@ MetalRenderer::MetalRenderer()
60
60
}
61
61
62
62
// Hybrid pipelines
63
- m_copyDepthToColorPipeline = new MetalHybridComputePipeline (this , m_utilityLibrary, " vertexCopyDepthToColor" , " kernelCopyDepthToColor" );
64
- m_copyColorToDepthPipeline = new MetalHybridComputePipeline (this , m_utilityLibrary, " vertexCopyColorToDepth" , " kernelCopyColorToDepth" );
63
+ m_copyTextureToTexturePipeline = new MetalHybridComputePipeline (this , m_utilityLibrary, " vertexCopyTextureToTexture" , " kernelCopyTextureToTexture" );
65
64
}
66
65
67
66
MetalRenderer::~MetalRenderer ()
68
67
{
69
- delete m_copyDepthToColorPipeline;
70
- delete m_copyColorToDepthPipeline;
68
+ delete m_copyTextureToTexturePipeline;
71
69
72
70
m_presentPipeline->release ();
73
71
@@ -476,26 +474,28 @@ void MetalRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* so
476
474
return ;
477
475
}
478
476
479
- MetalHybridComputePipeline* copyPipeline;
480
- if (srcTextureMtl->IsDepth ())
481
- copyPipeline = m_copyDepthToColorPipeline;
482
- else
483
- copyPipeline = m_copyColorToDepthPipeline;
484
-
485
477
MTL::Texture* textures[] = {srcTextureMtl->GetTexture (), dstTextureMtl->GetTexture ()};
486
478
479
+ struct CopyParams
480
+ {
481
+ uint32 width;
482
+ uint32 srcMip;
483
+ uint32 srcSlice;
484
+ uint32 dstMip;
485
+ uint32 dstSlice;
486
+ } params{(uint32)effectiveCopyWidth, (uint32)texSrcMip, (uint32)texSrcSlice, (uint32)texDstMip, (uint32)texDstSlice};
487
+
487
488
if (m_encoderType == MetalEncoderType::Render)
488
489
{
489
490
auto renderCommandEncoder = static_cast <MTL::RenderCommandEncoder*>(m_commandEncoder);
490
491
491
- renderCommandEncoder->setRenderPipelineState (copyPipeline ->GetRenderPipelineState ());
492
+ renderCommandEncoder->setRenderPipelineState (m_copyTextureToTexturePipeline ->GetRenderPipelineState ());
492
493
493
494
renderCommandEncoder->setViewport (MTL::Viewport{0.0 , 0.0 , (double )effectiveCopyWidth, (double )effectiveCopyHeight, 0.0 , 1.0 });
494
495
renderCommandEncoder->setScissorRect (MTL::ScissorRect{0 , 0 , (uint32)effectiveCopyWidth, (uint32)effectiveCopyHeight});
495
496
496
497
renderCommandEncoder->setVertexTextures (textures, NS::Range (0 , 2 ));
497
- renderCommandEncoder->setVertexBytes (&effectiveCopyWidth, sizeof (uint32), 0 );
498
- // TODO: set slices and mips
498
+ renderCommandEncoder->setVertexBytes (¶ms, sizeof (params), 0 );
499
499
500
500
renderCommandEncoder->drawPrimitives (MTL::PrimitiveTypeTriangle, NS::UInteger (0 ), NS::UInteger (3 ));
501
501
}
0 commit comments