From dd7351be3d8f6f160c50466e6ae628346c4979a0 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 18 Mar 2019 07:54:27 -0700 Subject: Moved NumDeferredContexts parameter from factory functions to EngineCreateInfo (fixed https://github.com/DiligentGraphics/DiligentCore/issues/76) --- .../include/RenderDeviceVkImpl.h | 17 +++++---- .../interface/EngineFactoryVk.h | 8 ++--- .../GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 42 ++++++++-------------- .../src/RenderDeviceVkImpl.cpp | 5 ++- 4 files changed, 28 insertions(+), 44 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index 167949df..ec762ec9 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -55,15 +55,14 @@ class RenderDeviceVkImpl final : public RenderDeviceNextGenBase, ICommandQueueVk>; - RenderDeviceVkImpl( IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - const EngineVkCreateInfo& EngineCI, - size_t CommandQueueCount, - ICommandQueueVk** pCmdQueues, - std::shared_ptr Instance, - std::unique_ptr PhysicalDevice, - std::shared_ptr LogicalDevice, - Uint32 NumDeferredContexts ); + RenderDeviceVkImpl(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineVkCreateInfo& EngineCI, + size_t CommandQueueCount, + ICommandQueueVk** pCmdQueues, + std::shared_ptr Instance, + std::unique_ptr PhysicalDevice, + std::shared_ptr LogicalDevice); ~RenderDeviceVkImpl(); virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface )override final; diff --git a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h index 633e11b2..3b5363b0 100644 --- a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h @@ -57,16 +57,14 @@ class IEngineFactoryVk : public IObject { public: virtual void CreateDeviceAndContextsVk(const EngineVkCreateInfo& EngineCI, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) = 0; + IRenderDevice** ppDevice, + IDeviceContext** ppContexts) = 0; //virtual void AttachToVulkanDevice(void *pVkNativeDevice, // class ICommandQueueVk *pCommandQueue, // const EngineVkCreateInfo& EngineCI, // IRenderDevice **ppDevice, - // IDeviceContext **ppContexts, - // Uint32 NumDeferredContexts) = 0; + // IDeviceContext **ppContexts) = 0; virtual void CreateSwapChainVk(IRenderDevice* pDevice, IDeviceContext* pImmediateContext, diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index 4014e6b6..7f5a4fee 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -56,8 +56,7 @@ public: void CreateDeviceAndContextsVk(const EngineVkCreateInfo& EngineCI, IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts)override final; + IDeviceContext** ppContexts)override final; void AttachToVulkanDevice(std::shared_ptr Instance, std::unique_ptr PhysicalDevice, @@ -66,8 +65,7 @@ public: ICommandQueueVk** ppCommandQueues, const EngineVkCreateInfo& EngineCI, IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts);//override final; + IDeviceContext** ppContexts);//override final; void CreateSwapChainVk(IRenderDevice* pDevice, IDeviceContext* pImmediateContext, @@ -82,17 +80,12 @@ public: /// \param [out] ppDevice - Address of the memory location where pointer to /// the created device will be written /// \param [out] ppContexts - Address of the memory location where pointers to -/// the contexts will be written. The new immediate -/// context goes at position 0. If NumDeferredContexts > 0, +/// the contexts will be written. Immediate context goes at +/// position 0. If EngineCI.NumDeferredContexts > 0, /// pointers to the deferred contexts are written afterwards. -/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number -/// of deferred contexts is requested, pointers to the -/// contexts are written to ppContexts array starting -/// at position 1 void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& EngineCI, IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts) + IDeviceContext** ppContexts) { VERIFY( ppDevice && ppContexts, "Null pointer provided" ); if( !ppDevice || !ppContexts ) @@ -120,7 +113,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En SetRawAllocator(EngineCI.pRawMemAllocator); *ppDevice = nullptr; - memset(ppContexts, 0, sizeof(*ppContexts) * (1 + NumDeferredContexts)); + memset(ppContexts, 0, sizeof(*ppContexts) * (1 + EngineCI.NumDeferredContexts)); try { @@ -192,7 +185,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En pCmdQueueVk = NEW_RC_OBJ(RawMemAllocator, "CommandQueueVk instance", CommandQueueVkImpl)(LogicalDevice, QueueInfo.queueFamilyIndex); std::array CommandQueues = {{pCmdQueueVk}}; - AttachToVulkanDevice(Instance, std::move(PhysicalDevice), LogicalDevice, CommandQueues.size(), CommandQueues.data(), EngineCI, ppDevice, ppContexts, NumDeferredContexts); + AttachToVulkanDevice(Instance, std::move(PhysicalDevice), LogicalDevice, CommandQueues.size(), CommandQueues.data(), EngineCI, ppDevice, ppContexts); FenceDesc Desc; Desc.Name = "Command queue fence"; @@ -218,13 +211,9 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En /// \param [out] ppDevice - Address of the memory location where pointer to /// the created device will be written /// \param [out] ppContexts - Address of the memory location where pointers to -/// the contexts will be written. Pointer to the immediate -/// context goes at position 0. If NumDeferredContexts > 0, -/// pointers to the deferred contexts go afterwards. -/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number -/// of deferred contexts is requested, pointers to the -/// contexts are written to ppContexts array starting -/// at position 1 +/// the contexts will be written. Immediate context goes at +/// position 0. If EngineCI.NumDeferredContexts > 0, +/// pointers to the deferred contexts are written afterwards. void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptr Instance, std::unique_ptr PhysicalDevice, std::shared_ptr LogicalDevice, @@ -232,20 +221,19 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptrQueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice) ); std::shared_ptr GenerateMipsHelper(new GenerateMipsVkHelper(*pRenderDeviceVk)); @@ -256,7 +244,7 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptrQueryInterface(IID_DeviceContext, reinterpret_cast(ppContexts) ); pRenderDeviceVk->SetImmediateContext(pImmediateCtxVk); - for (Uint32 DeferredCtx = 0; DeferredCtx < NumDeferredContexts; ++DeferredCtx) + for (Uint32 DeferredCtx = 0; DeferredCtx < EngineCI.NumDeferredContexts; ++DeferredCtx) { RefCntAutoPtr pDeferredCtxVk( NEW_RC_OBJ(RawMemAllocator, "DeviceContextVkImpl instance", DeviceContextVkImpl)(pRenderDeviceVk, true, EngineCI, 1+DeferredCtx, 0, GenerateMipsHelper) ); // We must call AddRef() (implicitly through QueryInterface()) because pRenderDeviceVk will @@ -272,7 +260,7 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptrRelease(); *ppDevice = nullptr; } - for(Uint32 ctx=0; ctx < 1 + NumDeferredContexts; ++ctx) + for(Uint32 ctx=0; ctx < 1 + EngineCI.NumDeferredContexts; ++ctx) { if( ppContexts[ctx] != nullptr ) { diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index a126a937..2870b0d4 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -44,15 +44,14 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters* ICommandQueueVk** CmdQueues, std::shared_ptr Instance, std::unique_ptr PhysicalDevice, - std::shared_ptr LogicalDevice, - Uint32 NumDeferredContexts) : + std::shared_ptr LogicalDevice) : TRenderDeviceBase { pRefCounters, RawMemAllocator, CommandQueueCount, CmdQueues, - NumDeferredContexts, + EngineCI.NumDeferredContexts, sizeof(TextureVkImpl), sizeof(TextureViewVkImpl), sizeof(BufferVkImpl), -- cgit v1.2.3