diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp index f4d4490e..3a3a6b54 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp @@ -10,6 +10,7 @@ MetalLayerHandle::MetalLayerHandle(MTL::Device* device, const Vector2i& size) m_layer = (CA::MetalLayer*)CreateMetalLayer(windowInfo.handle, m_layerScaleX, m_layerScaleY); m_layer->setDevice(device); m_layer->setDrawableSize(CGSize{(float)size.x * m_layerScaleX, (float)size.y * m_layerScaleY}); + m_layer->setFramebufferOnly(true); } MetalLayerHandle::~MetalLayerHandle() diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index eb009ecd..95b72c40 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -159,7 +159,7 @@ MetalRenderer::MetalRenderer() auto copyTextureToColorPipelineDescriptor = MTL::RenderPipelineDescriptor::alloc()->init(); // Hybrid pipelines - m_copyTextureToTexturePipeline = new MetalHybridComputePipeline(this, utilityLibrary, "vertexCopyTextureToTexture"); + //m_copyTextureToTexturePipeline = new MetalHybridComputePipeline(this, utilityLibrary, "vertexCopyTextureToTexture"); m_restrideBufferPipeline = new MetalHybridComputePipeline(this, utilityLibrary, "vertexRestrideBuffer"); utilityLibrary->release(); @@ -168,7 +168,7 @@ MetalRenderer::MetalRenderer() MetalRenderer::~MetalRenderer() { - delete m_copyTextureToTexturePipeline; + //delete m_copyTextureToTexturePipeline; delete m_restrideBufferPipeline; m_presentPipelineLinear->release(); @@ -686,9 +686,12 @@ void MetalRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* so sint32 effectiveCopyWidth = width; sint32 effectiveCopyHeight = height; LatteTexture_scaleToEffectiveSize(sourceTexture, &effectiveCopyWidth, &effectiveCopyHeight, 0); - sint32 sourceEffectiveWidth, sourceEffectiveHeight; - sourceTexture->GetEffectiveSize(sourceEffectiveWidth, sourceEffectiveHeight, srcMip); + //sint32 sourceEffectiveWidth, sourceEffectiveHeight; + //sourceTexture->GetEffectiveSize(sourceEffectiveWidth, sourceEffectiveHeight, srcMip); + texture_copyImageSubData(sourceTexture, srcMip, 0, 0, srcSlice, destinationTexture, dstMip, 0, 0, dstSlice, effectiveCopyWidth, effectiveCopyHeight, 0); + + /* sint32 texSrcMip = srcMip; sint32 texSrcSlice = srcSlice; sint32 texDstMip = dstMip; @@ -729,8 +732,6 @@ void MetalRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* so } else { - // TODO: uncomment - /* bool copyingToWholeRegion = ((effectiveCopyWidth == dstTextureMtl->GetMipWidth(dstMip) && effectiveCopyHeight == dstTextureMtl->GetMipHeight(dstMip))); auto renderPassDescriptor = MTL::RenderPassDescriptor::alloc()->init(); @@ -753,10 +754,10 @@ void MetalRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* so renderCommandEncoder->drawPrimitives(MTL::PrimitiveTypeTriangle, NS::UInteger(0), NS::UInteger(3)); EndEncoding(); - */ debug_printf("surface copy with no render command encoder, skipping copy\n"); } + */ } void MetalRenderer::bufferCache_init(const sint32 bufferSize) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h index 8fe3a8d9..2ada50c3 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h @@ -440,7 +440,7 @@ private: MTL::RenderPipelineState* m_presentPipelineSRGB; // Hybrid pipelines - class MetalHybridComputePipeline* m_copyTextureToTexturePipeline; + //class MetalHybridComputePipeline* m_copyTextureToTexturePipeline; class MetalHybridComputePipeline* m_restrideBufferPipeline; // Resources diff --git a/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h b/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h index c7a62546..cf355f61 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h @@ -31,17 +31,19 @@ fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d tex return tex.sample(samplr, in.texCoord); } +/* vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d src [[texture(GET_TEXTURE_BINDING(0))]], texture2d dst [[texture(GET_TEXTURE_BINDING(1))]], constant uint32_t& width [[buffer(GET_BUFFER_BINDING(0))]]) { uint2 coord = uint2(vid % width, vid / width); return dst.write(float4(src.read(coord).r, 0.0, 0.0, 0.0), coord); } +*/ struct RestrideParams { uint oldStride; uint newStride; }; -/* TODO: use uint32? Since that would require less iterations */ +// TODO: use uint32? Since that would require less iterations vertex void vertexRestrideBuffer(uint vid [[vertex_id]], device uint8_t* src [[buffer(GET_BUFFER_BINDING(0))]], device uint8_t* dst [[buffer(GET_BUFFER_BINDING(1))]], constant RestrideParams& params [[buffer(GET_BUFFER_BINDING(2))]]) { for (uint32_t i = 0; i < params.oldStride; i++) { dst[vid * params.newStride + i] = src[vid * params.oldStride + i];