mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-01-07 15:48:15 +01:00
always do texture copies on gpu
This commit is contained in:
parent
be76dadb90
commit
35740c5c8e
@ -10,7 +10,7 @@ LatteTextureMtl::LatteTextureMtl(class MetalRenderer* mtlRenderer, Latte::E_DIM
|
||||
: LatteTexture(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth), m_mtlr(mtlRenderer), m_format(format), m_isDepth(isDepth)
|
||||
{
|
||||
MTL::TextureDescriptor* desc = MTL::TextureDescriptor::alloc()->init();
|
||||
desc->setStorageMode(m_mtlr->GetOptimalTextureStorageMode());
|
||||
desc->setStorageMode(MTL::StorageModePrivate);
|
||||
desc->setCpuCacheMode(MTL::CPUCacheModeWriteCombined);
|
||||
|
||||
sint32 effectiveBaseWidth = width;
|
||||
|
@ -45,7 +45,7 @@ MetalRenderer::MetalRenderer()
|
||||
m_commandQueue = m_device->newCommandQueue();
|
||||
|
||||
// Feature support
|
||||
m_isAppleGPU = false;//m_device->supportsFamily(MTL::GPUFamilyApple1);
|
||||
m_isAppleGPU = m_device->supportsFamily(MTL::GPUFamilyApple1);
|
||||
m_hasUnifiedMemory = m_device->hasUnifiedMemory();
|
||||
m_supportsMetal3 = m_device->supportsFamily(MTL::GPUFamilyMetal3);
|
||||
m_recommendedMaxVRAMUsage = m_device->recommendedMaxWorkingSetSize();
|
||||
@ -519,26 +519,26 @@ void MetalRenderer::texture_loadSlice(LatteTexture* hostTexture, sint32 width, s
|
||||
size_t bytesPerRow = GetMtlTextureBytesPerRow(textureMtl->GetFormat(), textureMtl->IsDepth(), width);
|
||||
// No need to set bytesPerImage for 3D textures, since we always load just one slice
|
||||
//size_t bytesPerImage = GetMtlTextureBytesPerImage(textureMtl->GetFormat(), textureMtl->IsDepth(), height, bytesPerRow);
|
||||
if (m_isAppleGPU)
|
||||
{
|
||||
textureMtl->GetTexture()->replaceRegion(MTL::Region(0, 0, offsetZ, width, height, 1), mipIndex, sliceIndex, pixelData, bytesPerRow, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto blitCommandEncoder = GetBlitCommandEncoder();
|
||||
//if (m_isAppleGPU)
|
||||
//{
|
||||
// textureMtl->GetTexture()->replaceRegion(MTL::Region(0, 0, offsetZ, width, height, 1), mipIndex, sliceIndex, pixelData, bytesPerRow, 0);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
auto blitCommandEncoder = GetBlitCommandEncoder();
|
||||
|
||||
// Allocate a temporary buffer
|
||||
auto& bufferAllocator = m_memoryManager->GetTemporaryBufferAllocator();
|
||||
auto allocation = bufferAllocator.GetBufferAllocation(compressedImageSize);
|
||||
auto buffer = bufferAllocator.GetBuffer(allocation.bufferIndex);
|
||||
// Allocate a temporary buffer
|
||||
auto& bufferAllocator = m_memoryManager->GetTemporaryBufferAllocator();
|
||||
auto allocation = bufferAllocator.GetBufferAllocation(compressedImageSize);
|
||||
auto buffer = bufferAllocator.GetBuffer(allocation.bufferIndex);
|
||||
|
||||
// Copy the data to the temporary buffer
|
||||
memcpy(allocation.data, pixelData, compressedImageSize);
|
||||
//buffer->didModifyRange(NS::Range(allocation.offset, allocation.size));
|
||||
// Copy the data to the temporary buffer
|
||||
memcpy(allocation.data, pixelData, compressedImageSize);
|
||||
//buffer->didModifyRange(NS::Range(allocation.offset, allocation.size));
|
||||
|
||||
// Copy the data from the temporary buffer to the texture
|
||||
blitCommandEncoder->copyFromBuffer(buffer, allocation.offset, bytesPerRow, 0, MTL::Size(width, height, 1), textureMtl->GetTexture(), sliceIndex, mipIndex, MTL::Origin(0, 0, offsetZ));
|
||||
}
|
||||
// Copy the data from the temporary buffer to the texture
|
||||
blitCommandEncoder->copyFromBuffer(buffer, allocation.offset, bytesPerRow, 0, MTL::Size(width, height, 1), textureMtl->GetTexture(), sliceIndex, mipIndex, MTL::Origin(0, 0, offsetZ));
|
||||
//}
|
||||
}
|
||||
|
||||
void MetalRenderer::texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a)
|
||||
|
@ -397,10 +397,10 @@ public:
|
||||
return m_pixelFormatSupport;
|
||||
}
|
||||
|
||||
MTL::StorageMode GetOptimalTextureStorageMode() const
|
||||
{
|
||||
return (m_isAppleGPU ? MTL::StorageModeShared : MTL::StorageModePrivate);
|
||||
}
|
||||
//MTL::StorageMode GetOptimalTextureStorageMode() const
|
||||
//{
|
||||
// return (m_isAppleGPU ? MTL::StorageModeShared : MTL::StorageModePrivate);
|
||||
//}
|
||||
|
||||
MTL::ResourceOptions GetOptimalBufferStorageMode() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user