diff --git a/Engine/gapi/abstractgraphicsapi.h b/Engine/gapi/abstractgraphicsapi.h index fa430e2b..f34802a6 100644 --- a/Engine/gapi/abstractgraphicsapi.h +++ b/Engine/gapi/abstractgraphicsapi.h @@ -317,13 +317,10 @@ namespace Tempest { virtual bool wait(uint64_t time) = 0; virtual void reset() = 0; }; - struct Semaphore:NoCopy { - virtual ~Semaphore()=default; - }; struct Swapchain:NoCopy { virtual ~Swapchain()=default; virtual void reset()=0; - virtual uint32_t nextImage(Semaphore* onReady)=0; + virtual uint32_t nextImage()=0; virtual uint32_t imageCount() const=0; virtual uint32_t w() const=0; virtual uint32_t h() const=0; @@ -442,8 +439,6 @@ namespace Tempest { virtual Fence* createFence(Device *d)=0; - virtual Semaphore* createSemaphore(Device *d)=0; - virtual CommandBuffer* createCommandBuffer(Device* d)=0; @@ -458,14 +453,10 @@ namespace Tempest { const uint32_t w, const uint32_t h, uint32_t mip) = 0; virtual void readBytes (Device* d, Buffer* buf, void* out, size_t size) = 0; - virtual void present (Device *d,Swapchain* sw,uint32_t imageId,const Semaphore *wait)=0; + virtual void present (Device *d, Swapchain* sw, uint32_t imageId)=0; - virtual void submit (Device *d,CommandBuffer* cmd,Semaphore* wait,Semaphore* onReady,Fence* onReadyCpu)=0; - virtual void submit (Device *d, - CommandBuffer** cmd,size_t count, - Semaphore** wait, size_t waitCnt, - Semaphore** done, size_t doneCnt, - Fence* doneCpu)=0; + virtual void submit (Device *d, CommandBuffer* cmd, Fence* fence)=0; + virtual void submit (Device *d, CommandBuffer** cmd, size_t count, Fence* fence)=0; virtual void getCaps (Device *d,Props& caps)=0; diff --git a/Engine/gapi/directx12/dxfence.h b/Engine/gapi/directx12/dxfence.h index 2e59bdd1..e97a41c9 100644 --- a/Engine/gapi/directx12/dxfence.h +++ b/Engine/gapi/directx12/dxfence.h @@ -31,7 +31,4 @@ class DxFence : public AbstractGraphicsApi::Fence { HANDLE event=nullptr; }; -class DxSemaphore : public AbstractGraphicsApi::Semaphore { - }; - }} diff --git a/Engine/gapi/directx12/dxswapchain.cpp b/Engine/gapi/directx12/dxswapchain.cpp index 9e8eb33c..568d6257 100644 --- a/Engine/gapi/directx12/dxswapchain.cpp +++ b/Engine/gapi/directx12/dxswapchain.cpp @@ -86,9 +86,8 @@ void DxSwapchain::reset() { } } -uint32_t DxSwapchain::nextImage(AbstractGraphicsApi::Semaphore*) { - uint32_t img = impl->GetCurrentBackBufferIndex(); - return img; +uint32_t DxSwapchain::nextImage() { + return impl->GetCurrentBackBufferIndex(); } void DxSwapchain::queuePresent() { diff --git a/Engine/gapi/directx12/dxswapchain.h b/Engine/gapi/directx12/dxswapchain.h index 6927af60..d6037f91 100644 --- a/Engine/gapi/directx12/dxswapchain.h +++ b/Engine/gapi/directx12/dxswapchain.h @@ -27,7 +27,7 @@ class DxSwapchain : public AbstractGraphicsApi::Swapchain { void reset() override; uint32_t imageCount() const override { return imgCount; } - uint32_t nextImage(AbstractGraphicsApi::Semaphore* onReady) override; + uint32_t nextImage() override; void queuePresent(); diff --git a/Engine/gapi/directx12api.cpp b/Engine/gapi/directx12api.cpp index de572dba..81c66ca7 100644 --- a/Engine/gapi/directx12api.cpp +++ b/Engine/gapi/directx12api.cpp @@ -103,8 +103,6 @@ struct DirectX12Api::Impl { void submit(AbstractGraphicsApi::Device* d, ID3D12CommandList** cmd, size_t count, - AbstractGraphicsApi::Semaphore** /*wait*/, size_t /*waitCnt*/, - AbstractGraphicsApi::Semaphore** /*done*/, size_t /*doneCnt*/, AbstractGraphicsApi::Fence* doneCpu){ Detail::DxDevice& dx = *reinterpret_cast(d); Detail::DxFence& fcpu = *reinterpret_cast(doneCpu); @@ -222,10 +220,6 @@ AbstractGraphicsApi::Fence* DirectX12Api::createFence(AbstractGraphicsApi::Devic return new DxFence(*dx); } -AbstractGraphicsApi::Semaphore* DirectX12Api::createSemaphore(AbstractGraphicsApi::Device*) { - return nullptr; - } - AbstractGraphicsApi::PBuffer DirectX12Api::createBuffer(AbstractGraphicsApi::Device* d, const void* mem, size_t count, size_t size, size_t alignedSz, MemUsage usage, BufferHeap flg) { @@ -418,8 +412,7 @@ AbstractGraphicsApi::CommandBuffer* DirectX12Api::createCommandBuffer(Device* d) return new DxCommandBuffer(*dx); } -void DirectX12Api::present(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::Swapchain* sw, - uint32_t imageId, const AbstractGraphicsApi::Semaphore*) { +void DirectX12Api::present(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::Swapchain* sw, uint32_t imageId) { // TODO: handle imageId (void)imageId; Detail::DxDevice& dx = *reinterpret_cast(d); @@ -429,20 +422,16 @@ void DirectX12Api::present(AbstractGraphicsApi::Device* d, AbstractGraphicsApi:: sx->queuePresent(); } -void DirectX12Api::submit(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::CommandBuffer* cmd, - AbstractGraphicsApi::Semaphore* wait, - AbstractGraphicsApi::Semaphore* done, AbstractGraphicsApi::Fence* doneCpu) { +void DirectX12Api::submit(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::CommandBuffer* cmd, AbstractGraphicsApi::Fence* doneCpu) { Detail::DxDevice& dx = *reinterpret_cast(d); Detail::DxCommandBuffer& bx = *reinterpret_cast(cmd); ID3D12CommandList* cmdList[] = { bx.impl.get() }; dx.waitData(); - impl->submit(d,cmdList,1,&wait,1,&done,1,doneCpu); + impl->submit(d,cmdList,1,doneCpu); } -void DirectX12Api::submit(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::CommandBuffer** cmd, size_t count, - AbstractGraphicsApi::Semaphore** wait, size_t waitCnt, AbstractGraphicsApi::Semaphore** done, - size_t doneCnt, AbstractGraphicsApi::Fence* doneCpu) { +void DirectX12Api::submit(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::CommandBuffer** cmd, size_t count, AbstractGraphicsApi::Fence* doneCpu) { Detail::DxDevice& dx = *reinterpret_cast(d); ID3D12CommandList* cmdListStk[16]={}; std::unique_ptr cmdListHeap; @@ -456,7 +445,7 @@ void DirectX12Api::submit(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::C cmdList[i] = bx.impl.get(); } dx.waitData(); - impl->submit(d,cmdList,count,wait,waitCnt,done,doneCnt,doneCpu); + impl->submit(d,cmdList,count,doneCpu); } void DirectX12Api::getCaps(AbstractGraphicsApi::Device* d, AbstractGraphicsApi::Props& caps) { diff --git a/Engine/gapi/directx12api.h b/Engine/gapi/directx12api.h index eff584a7..186cddd9 100644 --- a/Engine/gapi/directx12api.h +++ b/Engine/gapi/directx12api.h @@ -39,8 +39,6 @@ class DirectX12Api : public AbstractGraphicsApi { Fence* createFence(Device *d) override; - Semaphore* createSemaphore(Device *d) override; - PBuffer createBuffer(Device* d, const void *mem, size_t count, size_t size, size_t alignedSz, MemUsage usage, BufferHeap flg) override; PTexture createTexture(Device* d,const Pixmap& p,TextureFormat frm,uint32_t mips) override; @@ -58,14 +56,10 @@ class DirectX12Api : public AbstractGraphicsApi { CommandBuffer* createCommandBuffer(Device* d) override; - void present (Device *d,Swapchain* sw,uint32_t imageId, const Semaphore *wait) override; + void present (Device *d, Swapchain* sw, uint32_t imageId) override; - void submit (Device *d, CommandBuffer* cmd, Semaphore* wait, Semaphore* onReady, Fence* doneCpu) override; - void submit (Device *d, - CommandBuffer** cmd, size_t count, - Semaphore** wait, size_t waitCnt, - Semaphore** done, size_t doneCnt, - Fence *doneCpu) 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; diff --git a/Engine/gapi/metal/mtswapchain.h b/Engine/gapi/metal/mtswapchain.h index 0329604e..b06c30bd 100644 --- a/Engine/gapi/metal/mtswapchain.h +++ b/Engine/gapi/metal/mtswapchain.h @@ -19,7 +19,7 @@ class MtSwapchain : public AbstractGraphicsApi::Swapchain { ~MtSwapchain(); void reset() override; - uint32_t nextImage(AbstractGraphicsApi::Semaphore* onReady) override; + uint32_t nextImage() override; uint32_t imageCount() const override; uint32_t w() const override; uint32_t h() const override; diff --git a/Engine/gapi/metalapi.h b/Engine/gapi/metalapi.h index 939c48d6..c132e0a6 100644 --- a/Engine/gapi/metalapi.h +++ b/Engine/gapi/metalapi.h @@ -34,7 +34,6 @@ class MetalApi : public AbstractGraphicsApi { PShader createShader(Device *d, const void* source, size_t src_size) override; Fence* createFence(Device *d) override; - Semaphore* createSemaphore(Device *d) override; PBuffer createBuffer(Device* d, const void *mem, size_t count, size_t size, size_t alignedSz, MemUsage usage, BufferHeap flg) override; @@ -53,14 +52,10 @@ class MetalApi : public AbstractGraphicsApi { CommandBuffer* createCommandBuffer(Device* d) override; - void present (Device *d,Swapchain* sw,uint32_t imageId, const Semaphore *wait) override; + void present (Device *d, Swapchain* sw, uint32_t imageId) override; - void submit (Device *d, CommandBuffer* cmd, Semaphore* wait, Semaphore* done, Fence* doneCpu) override; - void submit (Device *d, - CommandBuffer** cmd, size_t count, - Semaphore** wait, size_t waitCnt, - Semaphore** done, size_t doneCnt, - Fence *doneCpu) 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; }; diff --git a/Engine/gapi/vulkan/vdevice.cpp b/Engine/gapi/vulkan/vdevice.cpp index 1ec85193..46be3c57 100644 --- a/Engine/gapi/vulkan/vdevice.cpp +++ b/Engine/gapi/vulkan/vdevice.cpp @@ -5,7 +5,6 @@ #include "vcommandbuffer.h" #include "vcommandpool.h" #include "vfence.h" -#include "vsemaphore.h" #include "vswapchain.h" #include "vbuffer.h" #include "vtexture.h" @@ -357,21 +356,6 @@ VDevice::MemIndex VDevice::memoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFl return ret; } -VkResult VDevice::present(VSwapchain &sw, const VSemaphore *wait, size_t wSize, uint32_t imageId) { - VkPresentInfoKHR presentInfo = {}; - presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; - - presentInfo.waitSemaphoreCount = uint32_t(wSize); - presentInfo.pWaitSemaphores = &wait->impl; - - VkSwapchainKHR swapChains[] = {sw.swapChain}; - presentInfo.swapchainCount = 1; - presentInfo.pSwapchains = swapChains; - presentInfo.pImageIndices = &imageId; - - return presentQueue->present(presentInfo); - } - void VDevice::waitIdle() { waitIdleSync(queues,sizeof(queues)/sizeof(queues[0])); } diff --git a/Engine/gapi/vulkan/vdevice.h b/Engine/gapi/vulkan/vdevice.h index f0e45749..69b9568c 100644 --- a/Engine/gapi/vulkan/vdevice.h +++ b/Engine/gapi/vulkan/vdevice.h @@ -19,7 +19,6 @@ namespace Tempest { namespace Detail { class VFence; -class VSemaphore; class VTexture; @@ -203,7 +202,6 @@ class VDevice : public AbstractGraphicsApi::Device { PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2 = nullptr; PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2 = nullptr; - VkResult present(VSwapchain& sw,const VSemaphore *wait,size_t wSize,uint32_t imageId); void waitIdle() override; void submit(VCommandBuffer& cmd,VFence& sync); diff --git a/Engine/gapi/vulkan/vsemaphore.cpp b/Engine/gapi/vulkan/vsemaphore.cpp deleted file mode 100644 index 736f782d..00000000 --- a/Engine/gapi/vulkan/vsemaphore.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#if defined(TEMPEST_BUILD_VULKAN) - -#include "vsemaphore.h" - -#include "vdevice.h" - -using namespace Tempest::Detail; - -VSemaphore::VSemaphore(VDevice &device) - :device(device.device.impl){ - VkSemaphoreCreateInfo semaphoreInfo = {}; - semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - semaphoreInfo.flags = 0; - - vkAssert(vkCreateSemaphore(device.device.impl,&semaphoreInfo,nullptr,&impl)); - } - -VSemaphore::VSemaphore(VSemaphore &&other) { - std::swap(device,other.device); - std::swap(impl,other.impl); - } - -VSemaphore::~VSemaphore() { - if(device==nullptr) - return; - vkDestroySemaphore(device,impl,nullptr); - } - -#endif diff --git a/Engine/gapi/vulkan/vsemaphore.h b/Engine/gapi/vulkan/vsemaphore.h deleted file mode 100644 index 106bb684..00000000 --- a/Engine/gapi/vulkan/vsemaphore.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include "vulkan_sdk.h" - -namespace Tempest { -namespace Detail { - -class VDevice; - -class VSemaphore : public AbstractGraphicsApi::Semaphore { - public: - VSemaphore(VDevice& dev); - VSemaphore(VSemaphore&& other); - ~VSemaphore(); - - VkSemaphore impl = VK_NULL_HANDLE; - - private: - VkDevice device=nullptr; - }; - -}} diff --git a/Engine/gapi/vulkan/vswapchain.cpp b/Engine/gapi/vulkan/vswapchain.cpp index ecebabcf..464311bb 100644 --- a/Engine/gapi/vulkan/vswapchain.cpp +++ b/Engine/gapi/vulkan/vswapchain.cpp @@ -5,7 +5,6 @@ #include #include "vdevice.h" -#include "vsemaphore.h" using namespace Tempest; using namespace Tempest::Detail; @@ -223,7 +222,7 @@ uint32_t VSwapchain::getImageCount(const SwapChainSupport& support) const { return imageCount; } -uint32_t VSwapchain::nextImage(AbstractGraphicsApi::Semaphore*) { +uint32_t VSwapchain::nextImage() { auto& slot = sync[syncIndex]; uint32_t id = uint32_t(-1); VkResult code = vkAcquireNextImageKHR(device.device.impl, diff --git a/Engine/gapi/vulkan/vswapchain.h b/Engine/gapi/vulkan/vswapchain.h index d3215a00..7a650e70 100644 --- a/Engine/gapi/vulkan/vswapchain.h +++ b/Engine/gapi/vulkan/vswapchain.h @@ -5,8 +5,6 @@ namespace Tempest { -class Semaphore; - namespace Detail { class VDevice; @@ -30,7 +28,7 @@ class VSwapchain : public AbstractGraphicsApi::Swapchain { void reset() override; uint32_t imageCount() const override { return uint32_t(views.size()); } - uint32_t nextImage(AbstractGraphicsApi::Semaphore* onReady) override; + uint32_t nextImage() override; VkSwapchainKHR swapChain=VK_NULL_HANDLE; std::vector views; diff --git a/Engine/gapi/vulkan/vulkanapi_impl.cpp b/Engine/gapi/vulkan/vulkanapi_impl.cpp index 158a7c97..f58b186c 100644 --- a/Engine/gapi/vulkan/vulkanapi_impl.cpp +++ b/Engine/gapi/vulkan/vulkanapi_impl.cpp @@ -1,6 +1,5 @@ #if defined(TEMPEST_BUILD_VULKAN) -#include "vsemaphore.h" #include "vulkanapi_impl.h" #include diff --git a/Engine/gapi/vulkanapi.cpp b/Engine/gapi/vulkanapi.cpp index 1efef6d0..e99f0fa2 100644 --- a/Engine/gapi/vulkanapi.cpp +++ b/Engine/gapi/vulkanapi.cpp @@ -11,7 +11,6 @@ #include "vulkan/vbuffer.h" #include "vulkan/vshader.h" #include "vulkan/vfence.h" -#include "vulkan/vsemaphore.h" #include "vulkan/vcommandpool.h" #include "vulkan/vcommandbuffer.h" #include "vulkan/vdescriptorarray.h" @@ -139,10 +138,6 @@ AbstractGraphicsApi::Fence *VulkanApi::createFence(AbstractGraphicsApi::Device * return new Detail::VFence(*dx); } -AbstractGraphicsApi::Semaphore *VulkanApi::createSemaphore(AbstractGraphicsApi::Device*) { - return nullptr; - } - AbstractGraphicsApi::PBuffer VulkanApi::createBuffer(AbstractGraphicsApi::Device *d, const void *mem, size_t count, size_t size, size_t alignedSz, MemUsage usage, BufferHeap flg) { @@ -299,7 +294,7 @@ AbstractGraphicsApi::CommandBuffer* VulkanApi::createCommandBuffer(AbstractGraph return new Detail::VCommandBuffer(*dx); } -void VulkanApi::present(Device *d, Swapchain *sw, uint32_t imageId, const Semaphore*) { +void VulkanApi::present(Device *d, Swapchain *sw, uint32_t imageId) { Detail::VDevice* dx=reinterpret_cast(d); Detail::VSwapchain* sx=reinterpret_cast(sw); @@ -333,23 +328,15 @@ void VulkanApi::present(Device *d, Swapchain *sw, uint32_t imageId, const Semaph Detail::vkAssert(code); } -void VulkanApi::submit(Device *d, - CommandBuffer* cmd, - Semaphore* wait, - Semaphore* onReady, - Fence *onReadyCpu) { +void VulkanApi::submit(Device *d, CommandBuffer* cmd, Fence *doneCpu) { Detail::VDevice* dx=reinterpret_cast(d); Detail::VCommandBuffer* cx=reinterpret_cast(cmd); - auto* rc=reinterpret_cast(onReadyCpu); + auto* rc=reinterpret_cast(doneCpu); impl->submit(dx,&cx,1,rc); } -void VulkanApi::submit(AbstractGraphicsApi::Device *d, - AbstractGraphicsApi::CommandBuffer **cmd, size_t count, - Semaphore **wait, size_t waitCnt, - Semaphore **done, size_t doneCnt, - Fence *doneCpu) { +void VulkanApi::submit(AbstractGraphicsApi::Device *d, AbstractGraphicsApi::CommandBuffer **cmd, size_t count, Fence* doneCpu) { auto* dx = reinterpret_cast(d); auto* rc = reinterpret_cast(doneCpu); impl->submit(dx,reinterpret_cast(cmd),count,rc); diff --git a/Engine/gapi/vulkanapi.h b/Engine/gapi/vulkanapi.h index 9d6d6151..ffdefc47 100644 --- a/Engine/gapi/vulkanapi.h +++ b/Engine/gapi/vulkanapi.h @@ -43,8 +43,6 @@ class VulkanApi : public AbstractGraphicsApi { Fence* createFence(Device *d) override; - Semaphore* createSemaphore(Device *d) override; - PBuffer createBuffer (Device* d, const void *mem, size_t count, size_t size, size_t alignedSz, MemUsage usage, BufferHeap flg) override; PTexture createTexture(Device* d,const Pixmap& p,TextureFormat frm,uint32_t mips) override; PTexture createTexture(Device* d,const uint32_t w,const uint32_t h,uint32_t mips, TextureFormat frm) override; @@ -57,14 +55,10 @@ class VulkanApi : public AbstractGraphicsApi { CommandBuffer* createCommandBuffer(Device* d) override; - void present (Device *d,Swapchain* sw,uint32_t imageId, const Semaphore *wait) override; + void present (Device *d, Swapchain* sw, uint32_t imageId) override; - void submit (Device *d,CommandBuffer* cmd,Semaphore* wait,Semaphore* onReady,Fence* onReadyCpu) override; - void submit (Device *d, - CommandBuffer** cmd, size_t count, - Semaphore** wait, size_t waitCnt, - Semaphore** done, size_t doneCnt, - Fence *doneCpu) override; + void submit (Device *d, CommandBuffer* cmd, Fence* onReadyCpu) override; + void submit (Device *d, CommandBuffer** cmd, size_t count, Fence *doneCpu) override; void getCaps (Device *d, Props& props) override; diff --git a/Engine/graphics/device.cpp b/Engine/graphics/device.cpp index b0fbf7c8..fbcbcdd2 100644 --- a/Engine/graphics/device.cpp +++ b/Engine/graphics/device.cpp @@ -1,6 +1,5 @@ #include "device.h" -#include #include #include #include @@ -51,68 +50,39 @@ void Device::waitIdle() { impl.dev->waitIdle(); } -void Device::submit(const CommandBuffer &cmd, const Semaphore &wait) { - api.submit(dev,cmd.impl.handler,wait.impl.handler,nullptr,nullptr); +void Device::submit(const CommandBuffer &cmd) { + api.submit(dev,cmd.impl.handler,nullptr); } void Device::submit(const CommandBuffer &cmd, Fence &fdone) { - const Tempest::CommandBuffer *c[] = {&cmd}; - submit(c,1,nullptr,0,nullptr,0,&fdone); + api.submit(dev,cmd.impl.handler,fdone.impl.handler); } -void Device::submit(const CommandBuffer &cmd, const Semaphore &wait, Semaphore &done, Fence &fdone) { - api.submit(dev,cmd.impl.handler,wait.impl.handler,done.impl.handler,fdone.impl.handler); - } - -void Device::submit(const Tempest::CommandBuffer *cmd[], size_t count, - const Semaphore *wait[], size_t waitCnt, - Semaphore *done[], size_t doneCnt, - Fence *fdone) { - if(count+waitCnt+doneCnt<64) { +void Device::submit(const Tempest::CommandBuffer *cmd[], size_t count, Fence *fdone) { + if(count<=64) { void* ptr[64]; auto cx = reinterpret_cast(ptr); - auto wx = reinterpret_cast(ptr+count); - auto dx = reinterpret_cast(ptr+count+waitCnt); - implSubmit(cmd, cx, count, - wait, wx, waitCnt, - done, dx, doneCnt, - fdone->impl.handler); + implSubmit(cmd, cx, count, fdone->impl.handler); } else { - std::unique_ptr ptr(new void*[count+waitCnt+doneCnt]); + std::unique_ptr ptr(new void*[count]); auto cx = reinterpret_cast(ptr.get()); - auto wx = reinterpret_cast(ptr.get()+count); - auto dx = reinterpret_cast(ptr.get()+count+waitCnt); - implSubmit(cmd, cx, count, - wait, wx, waitCnt, - done, dx, doneCnt, - fdone->impl.handler); + implSubmit(cmd, cx, count, fdone->impl.handler); } } -void Device::present(Swapchain& sw, uint32_t img, const Semaphore& wait) { - api.present(dev,sw.impl.handler,img,wait.impl.handler); +void Device::present(Swapchain& sw, uint32_t img) { + api.present(dev,sw.impl.handler,img); sw.framesCounter++; sw.framesIdMod=(sw.framesIdMod+1)%maxFramesInFlight(); } -void Device::implSubmit(const CommandBuffer* cmd[], AbstractGraphicsApi::CommandBuffer* hcmd[], size_t count, - const Semaphore* wait[], AbstractGraphicsApi::Semaphore* hwait[], size_t waitCnt, - Semaphore* done[], AbstractGraphicsApi::Semaphore* hdone[], size_t doneCnt, - AbstractGraphicsApi::Fence* fdone) { +void Device::implSubmit(const CommandBuffer* cmd[], AbstractGraphicsApi::CommandBuffer* hcmd[], size_t count, AbstractGraphicsApi::Fence* fdone) { for(size_t i=0;iimpl.handler; - for(size_t i=0;iimpl.handler; - for(size_t i=0;iimpl.handler; - api.submit(dev, - hcmd, count, - hwait, waitCnt, - hdone, doneCnt, - fdone); + api.submit(dev, hcmd, count, fdone); } Shader Device::loadShader(RFile &file) { @@ -382,11 +352,6 @@ Fence Device::fence() { return f; } -Semaphore Device::semaphore() { - Semaphore f(*this,api.createSemaphore(dev)); - return f; - } - ComputePipeline Device::pipeline(const Shader& comp) { if(!comp.impl) return ComputePipeline(); diff --git a/Engine/graphics/device.h b/Engine/graphics/device.h index 3a28c5a7..eef003ec 100644 --- a/Engine/graphics/device.h +++ b/Engine/graphics/device.h @@ -28,7 +28,6 @@ namespace Tempest { class Fence; -class Semaphore; class CommandPool; class RFile; @@ -54,14 +53,10 @@ class Device { uint8_t maxFramesInFlight() const; void waitIdle(); - void submit(const CommandBuffer& cmd,const Semaphore& wait); - void submit(const CommandBuffer& cmd,Fence& fdone); - void submit(const CommandBuffer& cmd,const Semaphore& wait,Semaphore& done,Fence& fdone); - void submit(const CommandBuffer *cmd[], size_t count, - const Semaphore* wait[], size_t waitCnt, - Semaphore* done[], size_t doneCnt, - Fence* fdone); - void present(Swapchain& sw, uint32_t img, const Semaphore& wait); + void submit(const CommandBuffer& cmd); + void submit(const CommandBuffer& cmd, Fence& fdone); + void submit(const CommandBuffer *cmd[], size_t count, Fence* fdone); + void present(Swapchain& sw, uint32_t img); Swapchain swapchain(SystemApi::Window* w) const; @@ -168,8 +163,6 @@ class Device { ComputePipeline pipeline(const Shader &comp); Fence fence(); - Semaphore semaphore(); - CommandBuffer commandBuffer(); const Builtin& builtin() const; @@ -196,9 +189,7 @@ class Device { implPipeline(const RenderState &st, const Shader* shaders[], size_t stride, Topology tp); void implSubmit(const Tempest::CommandBuffer *cmd[], AbstractGraphicsApi::CommandBuffer* hcmd[], size_t count, - const Semaphore* wait[], AbstractGraphicsApi::Semaphore* hwait[], size_t waitCnt, - Semaphore* done[], AbstractGraphicsApi::Semaphore* hdone[], size_t doneCnt, - AbstractGraphicsApi::Fence* fdone); + AbstractGraphicsApi::Fence* fdone); static TextureFormat formatOf(const Attachment& a); diff --git a/Engine/graphics/semaphore.cpp b/Engine/graphics/semaphore.cpp deleted file mode 100644 index 33ded8c4..00000000 --- a/Engine/graphics/semaphore.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "semaphore.h" -#include - -using namespace Tempest; - -Semaphore::Semaphore(Device &dev, AbstractGraphicsApi::Semaphore *impl) - :dev(&dev),impl(impl) { - } - -Semaphore::~Semaphore() { - delete impl.handler; - } diff --git a/Engine/graphics/semaphore.h b/Engine/graphics/semaphore.h deleted file mode 100644 index f6a6e9f0..00000000 --- a/Engine/graphics/semaphore.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include "../utility/dptr.h" - -namespace Tempest { - -class Device; -class Swapchain; - -class Semaphore final { - public: - Semaphore(Semaphore&& f)=default; - ~Semaphore(); - Semaphore& operator = (Semaphore&& other)=default; - - private: - Semaphore(Tempest::Device& dev,AbstractGraphicsApi::Semaphore* f); - - Tempest::Device* dev=nullptr; - Detail::DPtr impl; - - friend class Tempest::Device; - friend class Tempest::Swapchain; - }; - -} diff --git a/Engine/graphics/swapchain.cpp b/Engine/graphics/swapchain.cpp index 6e90cbf7..5ff4bafb 100644 --- a/Engine/graphics/swapchain.cpp +++ b/Engine/graphics/swapchain.cpp @@ -2,7 +2,6 @@ #include #include -#include using namespace Tempest; @@ -62,6 +61,6 @@ Attachment& Swapchain::frame(size_t id) { return img[id]; } -uint32_t Swapchain::nextImage(Semaphore& onReady) { - return impl.handler->nextImage(onReady.impl.handler); +uint32_t Swapchain::nextImage() { + return impl.handler->nextImage(); } diff --git a/Engine/graphics/swapchain.h b/Engine/graphics/swapchain.h index 55e23f6f..8efac738 100644 --- a/Engine/graphics/swapchain.h +++ b/Engine/graphics/swapchain.h @@ -5,7 +5,6 @@ namespace Tempest { class Device; -class Semaphore; class Frame; class Attachment; @@ -27,7 +26,7 @@ class Swapchain final { uint64_t frameCounter() const; Attachment& frame(size_t id); - uint32_t nextImage(Semaphore& onReady); + uint32_t nextImage(); private: Swapchain(AbstractGraphicsApi::Swapchain* sw); diff --git a/Engine/include/Tempest/Semaphore b/Engine/include/Tempest/Semaphore deleted file mode 100644 index 4887137c..00000000 --- a/Engine/include/Tempest/Semaphore +++ /dev/null @@ -1 +0,0 @@ -#include "../graphics/semaphore.h"