mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 13:34:18 +01:00
sync between command buffers
This commit is contained in:
parent
ed32feb3d9
commit
a52095b40a
@ -27,6 +27,8 @@
|
||||
#include "imgui/imgui_extension.h"
|
||||
#include "imgui/imgui_impl_metal.h"
|
||||
|
||||
#define EVENT_VALUE_WRAP 4096
|
||||
|
||||
extern bool hasValidFramebufferAttached;
|
||||
|
||||
float supportBufferData[512 * 4];
|
||||
@ -48,6 +50,9 @@ MetalRenderer::MetalRenderer()
|
||||
|
||||
CheckForPixelFormatSupport(m_pixelFormatSupport);
|
||||
|
||||
// Synchronization resources
|
||||
m_event = m_device->newEvent();
|
||||
|
||||
// Resources
|
||||
MTL::SamplerDescriptor* samplerDescriptor = MTL::SamplerDescriptor::alloc()->init();
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
@ -161,6 +166,8 @@ MetalRenderer::~MetalRenderer()
|
||||
|
||||
m_occlusionQuery.m_resultBuffer->release();
|
||||
|
||||
m_event->release();
|
||||
|
||||
m_commandQueue->release();
|
||||
m_device->release();
|
||||
}
|
||||
@ -1509,6 +1516,10 @@ MTL::CommandBuffer* MetalRenderer::GetCommandBuffer()
|
||||
MTL::CommandBuffer* mtlCommandBuffer = m_commandQueue->commandBuffer();
|
||||
m_currentCommandBuffer = {mtlCommandBuffer};
|
||||
|
||||
// Wait for the previous command buffer
|
||||
if (m_eventValue != -1)
|
||||
mtlCommandBuffer->encodeWait(m_event, m_eventValue);
|
||||
|
||||
m_recordedDrawcalls = 0;
|
||||
m_commitTreshold = m_defaultCommitTreshlod;
|
||||
|
||||
@ -1682,6 +1693,10 @@ void MetalRenderer::CommitCommandBuffer()
|
||||
// m_memoryManager->GetTemporaryBufferAllocator().CommandBufferFinished(commandBuffer.m_commandBuffer);
|
||||
//});
|
||||
|
||||
// Signal event
|
||||
m_eventValue = (m_eventValue + 1) % EVENT_VALUE_WRAP;
|
||||
m_currentCommandBuffer.m_commandBuffer->encodeSignalEvent(m_event, m_eventValue);
|
||||
|
||||
m_currentCommandBuffer.m_commandBuffer->commit();
|
||||
m_currentCommandBuffer.m_commandBuffer->release();
|
||||
m_currentCommandBuffer.m_commited = true;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalOutputShaderCache.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalAttachmentsInfo.h"
|
||||
#include <cstdint>
|
||||
|
||||
struct MetalBufferAllocation
|
||||
{
|
||||
@ -459,6 +460,10 @@ private:
|
||||
// Void vertex pipelines
|
||||
class MetalVoidVertexPipeline* m_copyBufferToBufferPipeline;
|
||||
|
||||
// Synchronization resources
|
||||
MTL::Event* m_event;
|
||||
int32_t m_eventValue = -1;
|
||||
|
||||
// Resources
|
||||
MTL::SamplerState* m_nearestSampler;
|
||||
MTL::SamplerState* m_linearSampler;
|
||||
|
Loading…
Reference in New Issue
Block a user