mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-01-07 15:48:15 +01:00
do surface copy properly
This commit is contained in:
parent
1b44269d70
commit
be76dadb90
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -440,7 +440,7 @@ private:
|
||||
MTL::RenderPipelineState* m_presentPipelineSRGB;
|
||||
|
||||
// Hybrid pipelines
|
||||
class MetalHybridComputePipeline* m_copyTextureToTexturePipeline;
|
||||
//class MetalHybridComputePipeline* m_copyTextureToTexturePipeline;
|
||||
class MetalHybridComputePipeline* m_restrideBufferPipeline;
|
||||
|
||||
// Resources
|
||||
|
@ -31,17 +31,19 @@ fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d<float> tex
|
||||
return tex.sample(samplr, in.texCoord);
|
||||
}
|
||||
|
||||
/*
|
||||
vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d<float, access::read> src [[texture(GET_TEXTURE_BINDING(0))]], texture2d<float, access::write> 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];
|
||||
|
Loading…
Reference in New Issue
Block a user