mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
fix: issues on Intel Macs
This commit is contained in:
parent
96d6168c50
commit
a693bf564f
@ -39,7 +39,7 @@ public:
|
|||||||
MetalBufferAllocation GetBufferAllocation(size_t size)
|
MetalBufferAllocation GetBufferAllocation(size_t size)
|
||||||
{
|
{
|
||||||
// Align the size
|
// Align the size
|
||||||
size = Align(size, 16);
|
size = Align(size, 128);
|
||||||
|
|
||||||
// First, try to find a free range
|
// First, try to find a free range
|
||||||
for (uint32 i = 0; i < m_freeBufferRanges.size(); i++)
|
for (uint32 i = 0; i < m_freeBufferRanges.size(); i++)
|
||||||
|
@ -126,7 +126,7 @@ MetalRenderer::MetalRenderer()
|
|||||||
presentFragmentFunction->release();
|
presentFragmentFunction->release();
|
||||||
|
|
||||||
error = nullptr;
|
error = nullptr;
|
||||||
renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat(MTL::PixelFormatRGBA8Unorm);
|
renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat(MTL::PixelFormatBGRA8Unorm);
|
||||||
#ifdef CEMU_DEBUG_ASSERT
|
#ifdef CEMU_DEBUG_ASSERT
|
||||||
renderPipelineDescriptor->setLabel(GetLabel("Present pipeline linear", renderPipelineDescriptor));
|
renderPipelineDescriptor->setLabel(GetLabel("Present pipeline linear", renderPipelineDescriptor));
|
||||||
#endif
|
#endif
|
||||||
@ -138,7 +138,7 @@ MetalRenderer::MetalRenderer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
error = nullptr;
|
error = nullptr;
|
||||||
renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat(MTL::PixelFormatRGBA8Unorm_sRGB);
|
renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat(MTL::PixelFormatBGRA8Unorm_sRGB);
|
||||||
#ifdef CEMU_DEBUG_ASSERT
|
#ifdef CEMU_DEBUG_ASSERT
|
||||||
renderPipelineDescriptor->setLabel(GetLabel("Present pipeline sRGB", renderPipelineDescriptor));
|
renderPipelineDescriptor->setLabel(GetLabel("Present pipeline sRGB", renderPipelineDescriptor));
|
||||||
#endif
|
#endif
|
||||||
@ -185,7 +185,9 @@ MetalRenderer::~MetalRenderer()
|
|||||||
|
|
||||||
void MetalRenderer::InitializeLayer(const Vector2i& size, bool mainWindow)
|
void MetalRenderer::InitializeLayer(const Vector2i& size, bool mainWindow)
|
||||||
{
|
{
|
||||||
GetLayer(mainWindow) = MetalLayerHandle(m_device, size);
|
auto& layer = GetLayer(mainWindow);
|
||||||
|
layer = MetalLayerHandle(m_device, size);
|
||||||
|
layer.GetLayer()->setPixelFormat(MTL::PixelFormatBGRA8Unorm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalRenderer::ResizeLayer(const Vector2i& size, bool mainWindow)
|
void MetalRenderer::ResizeLayer(const Vector2i& size, bool mainWindow)
|
||||||
@ -381,7 +383,7 @@ ImTextureID MetalRenderer::GenerateTexture(const std::vector<uint8>& data, const
|
|||||||
desc->setPixelFormat(MTL::PixelFormatRGBA8Unorm);
|
desc->setPixelFormat(MTL::PixelFormatRGBA8Unorm);
|
||||||
desc->setWidth(size.x);
|
desc->setWidth(size.x);
|
||||||
desc->setHeight(size.y);
|
desc->setHeight(size.y);
|
||||||
desc->setStorageMode(MTL::StorageModeShared);
|
desc->setStorageMode(m_isAppleGPU ? MTL::StorageModeShared : MTL::StorageModeManaged);
|
||||||
desc->setUsage(MTL::TextureUsageShaderRead);
|
desc->setUsage(MTL::TextureUsageShaderRead);
|
||||||
|
|
||||||
MTL::Texture* texture = m_device->newTexture(desc);
|
MTL::Texture* texture = m_device->newTexture(desc);
|
||||||
@ -507,11 +509,14 @@ void MetalRenderer::texture_loadSlice(LatteTexture* hostTexture, sint32 width, s
|
|||||||
auto blitCommandEncoder = GetBlitCommandEncoder();
|
auto blitCommandEncoder = GetBlitCommandEncoder();
|
||||||
|
|
||||||
// Allocate a temporary buffer
|
// Allocate a temporary buffer
|
||||||
auto allocation = m_memoryManager->GetTemporaryBufferAllocator().GetBufferAllocation(compressedImageSize);
|
// HACK: use the persistent buffer allocator so as to avoid any issues
|
||||||
auto buffer = m_memoryManager->GetTemporaryBufferAllocator().GetBuffer(allocation.bufferIndex);
|
auto& bufferAllocator = m_memoryManager->GetBufferAllocator();
|
||||||
|
auto allocation = bufferAllocator.GetBufferAllocation(compressedImageSize);
|
||||||
|
auto buffer = bufferAllocator.GetBuffer(allocation.bufferIndex);
|
||||||
|
|
||||||
// Copy the data to the temporary buffer
|
// Copy the data to the temporary buffer
|
||||||
memcpy(allocation.data, pixelData, compressedImageSize);
|
memcpy(allocation.data, pixelData, compressedImageSize);
|
||||||
|
buffer->didModifyRange(NS::Range(allocation.offset, allocation.size));
|
||||||
|
|
||||||
// Copy the data from the temporary buffer to the texture
|
// 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));
|
blitCommandEncoder->copyFromBuffer(buffer, allocation.offset, bytesPerRow, 0, MTL::Size(width, height, 1), textureMtl->GetTexture(), sliceIndex, mipIndex, MTL::Origin(0, 0, offsetZ));
|
||||||
@ -1474,7 +1479,7 @@ bool MetalRenderer::AcquireDrawable(bool mainWindow)
|
|||||||
const bool latteBufferUsesSRGB = mainWindow ? LatteGPUState.tvBufferUsesSRGB : LatteGPUState.drcBufferUsesSRGB;
|
const bool latteBufferUsesSRGB = mainWindow ? LatteGPUState.tvBufferUsesSRGB : LatteGPUState.drcBufferUsesSRGB;
|
||||||
if (latteBufferUsesSRGB != m_state.m_usesSRGB)
|
if (latteBufferUsesSRGB != m_state.m_usesSRGB)
|
||||||
{
|
{
|
||||||
layer.GetLayer()->setPixelFormat(latteBufferUsesSRGB ? MTL::PixelFormatRGBA8Unorm_sRGB : MTL::PixelFormatRGBA8Unorm);
|
layer.GetLayer()->setPixelFormat(latteBufferUsesSRGB ? MTL::PixelFormatBGRA8Unorm_sRGB : MTL::PixelFormatBGRA8Unorm);
|
||||||
m_state.m_usesSRGB = latteBufferUsesSRGB;
|
m_state.m_usesSRGB = latteBufferUsesSRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user