mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-06-08 11:23:52 +00:00
Metal: Fix maxFrameLatency setting. (#3715)
This commit is contained in:
committed by
GitHub
parent
0158b15c23
commit
526b886105
@@ -1087,7 +1087,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
}
|
||||
}
|
||||
|
||||
m_cmd.init(m_device);
|
||||
m_cmd.init(m_device, _init.resolution.maxFrameLatency);
|
||||
BGFX_FATAL(NULL != m_cmd.m_commandQueue, Fatal::UnableToInitialize, "Unable to create Metal device.");
|
||||
|
||||
for (uint8_t ii = 0; ii < BGFX_CONFIG_MAX_FRAME_LATENCY; ++ii)
|
||||
@@ -4242,10 +4242,14 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
m_pixelFormatHash = m_swapChain->resize(_width, _height, _format, _depthFormat);
|
||||
}
|
||||
|
||||
void CommandQueueMtl::init(MTL::Device* _device)
|
||||
void CommandQueueMtl::init(MTL::Device* _device, uint32_t _maxFrameLatency)
|
||||
{
|
||||
m_commandQueue = _device->newCommandQueue();
|
||||
m_framesSemaphore.post(BGFX_CONFIG_MAX_FRAME_LATENCY);
|
||||
m_maxFrameLatency = bx::min<uint32_t>(
|
||||
_maxFrameLatency != 0 ? _maxFrameLatency : BGFX_CONFIG_MAX_FRAME_LATENCY
|
||||
, BGFX_CONFIG_MAX_FRAME_LATENCY
|
||||
);
|
||||
m_framesSemaphore.post(m_maxFrameLatency);
|
||||
}
|
||||
|
||||
void CommandQueueMtl::shutdown()
|
||||
@@ -4317,9 +4321,9 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
{
|
||||
if (_finishAll)
|
||||
{
|
||||
uint32_t count = m_activeCommandBuffer != NULL
|
||||
? 2
|
||||
: 3
|
||||
const uint32_t count = m_activeCommandBuffer != NULL
|
||||
? m_maxFrameLatency - 1
|
||||
: m_maxFrameLatency
|
||||
;
|
||||
|
||||
for (uint32_t ii = 0; ii < count; ++ii)
|
||||
|
||||
@@ -610,10 +610,11 @@ namespace bgfx { namespace mtl
|
||||
, m_activeCommandBuffer(NULL)
|
||||
, m_releaseWriteIndex(0)
|
||||
, m_releaseReadIndex(0)
|
||||
, m_maxFrameLatency(BGFX_CONFIG_MAX_FRAME_LATENCY)
|
||||
{
|
||||
}
|
||||
|
||||
void init(MTL::Device* _device);
|
||||
void init(MTL::Device* _device, uint32_t _maxFrameLatency);
|
||||
void shutdown();
|
||||
MTL::CommandBuffer* alloc();
|
||||
void kick(bool _endFrame, bool _waitForFinish);
|
||||
@@ -632,6 +633,7 @@ namespace bgfx { namespace mtl
|
||||
|
||||
int m_releaseWriteIndex;
|
||||
int m_releaseReadIndex;
|
||||
uint32_t m_maxFrameLatency;
|
||||
typedef stl::vector<NS::Object*> ResourceArray;
|
||||
ResourceArray m_release[BGFX_CONFIG_MAX_FRAME_LATENCY];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user