diff --git a/Engine/gapi/metal/mtswapchain.h b/Engine/gapi/metal/mtswapchain.h index b06c30bd..689c448c 100644 --- a/Engine/gapi/metal/mtswapchain.h +++ b/Engine/gapi/metal/mtswapchain.h @@ -19,11 +19,11 @@ class MtSwapchain : public AbstractGraphicsApi::Swapchain { ~MtSwapchain(); void reset() override; - uint32_t nextImage() override; + uint32_t currentBackBufferIndex() override; uint32_t imageCount() const override; uint32_t w() const override; uint32_t h() const override; - void present(uint32_t index); + void present(); MTLPixelFormat format() const; @@ -41,7 +41,8 @@ class MtSwapchain : public AbstractGraphicsApi::Swapchain { MetalView* view = nil; Tempest::Size sz; - uint32_t imgCount = 0; + uint32_t imgCount = 0; + uint32 currentImg = 0; void releaseTex(); id mkTexture(); }; diff --git a/Engine/gapi/metal/mtswapchain.mm b/Engine/gapi/metal/mtswapchain.mm index 1595dcac..34d6a4ad 100644 --- a/Engine/gapi/metal/mtswapchain.mm +++ b/Engine/gapi/metal/mtswapchain.mm @@ -79,21 +79,23 @@ - (CALayer *)makeBackingLayer { } } -uint32_t MtSwapchain::nextImage(AbstractGraphicsApi::Semaphore*) { +uint32_t MtSwapchain::currentBackBufferIndex() { for(;;) { std::lock_guard guard(sync); for(size_t i=0; i(wnd.contentView.layer); + uint32_t i = currentImg; @autoreleasepool { id drawable = [lay nextDrawable]; diff --git a/Engine/gapi/metalapi.h b/Engine/gapi/metalapi.h index c132e0a6..e38e36e2 100644 --- a/Engine/gapi/metalapi.h +++ b/Engine/gapi/metalapi.h @@ -52,12 +52,12 @@ class MetalApi : public AbstractGraphicsApi { CommandBuffer* createCommandBuffer(Device* d) override; - void present (Device *d, Swapchain* sw, uint32_t imageId) override; + void present (Device *d, Swapchain* sw) override; void submit (Device *d, CommandBuffer* cmd, Fence* doneCpu) override; void submit (Device *d, CommandBuffer** cmd, size_t count, Fence *doneCpu) override; - void getCaps (Device *d,Props& caps) override; + void getCaps (Device *d, Props& caps) override; }; } diff --git a/Engine/gapi/metalapi.mm b/Engine/gapi/metalapi.mm index faae6037..05af015b 100644 --- a/Engine/gapi/metalapi.mm +++ b/Engine/gapi/metalapi.mm @@ -137,10 +137,6 @@ return new MtSync(); } -AbstractGraphicsApi::Semaphore *MetalApi::createSemaphore(AbstractGraphicsApi::Device*) { - return nullptr; - } - AbstractGraphicsApi::PBuffer MetalApi::createBuffer(AbstractGraphicsApi::Device *d, const void *mem, size_t count, size_t sz, size_t alignedSz, MemUsage /*usage*/, BufferHeap flg) { @@ -256,30 +252,20 @@ return new MtCommandBuffer(dx); } -void MetalApi::present(AbstractGraphicsApi::Device*, - AbstractGraphicsApi::Swapchain *sw, - uint32_t imageId, - const AbstractGraphicsApi::Semaphore*) { +void MetalApi::present(AbstractGraphicsApi::Device*, AbstractGraphicsApi::Swapchain *sw) { auto& s = *reinterpret_cast(sw); - s.present(imageId); + s.present(); } void MetalApi::submit(AbstractGraphicsApi::Device *d, AbstractGraphicsApi::CommandBuffer *cmd, - AbstractGraphicsApi::Semaphore *wait, - AbstractGraphicsApi::Semaphore *done, AbstractGraphicsApi::Fence *doneCpu) { - this->submit(d,&cmd,1,&wait,1,&done,1,doneCpu); + this->submit(d,&cmd,1,doneCpu); } void MetalApi::submit(AbstractGraphicsApi::Device*, AbstractGraphicsApi::CommandBuffer **pcmd, size_t count, - AbstractGraphicsApi::Semaphore **wait, size_t waitCnt, - AbstractGraphicsApi::Semaphore **done, size_t doneCnt, AbstractGraphicsApi::Fence *doneCpu) { - (void)wait; (void)waitCnt; - (void)done; (void)doneCnt; - auto& fence = *reinterpret_cast(doneCpu); fence.signal(); for(size_t i=0; i