diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-03-18 06:23:48 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-03-18 06:23:48 +0000 |
| commit | 9fb187ba9d82bccc48c3cb1169981e347953c688 (patch) | |
| tree | 5f96350b0a4b981431622017fdfd47e8a28191f4 /Graphics/GraphicsEngineVulkan | |
| parent | Added CommandQueueVk object initialization (diff) | |
| download | DiligentCore-9fb187ba9d82bccc48c3cb1169981e347953c688.tar.gz DiligentCore-9fb187ba9d82bccc48c3cb1169981e347953c688.zip | |
Updated CommandQueueVkImpl; implemened RenderDeviceVkImpl initialization
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
6 files changed, 111 insertions, 207 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h b/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h index 7bc4f7f5..c655b67d 100644 --- a/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h @@ -26,6 +26,7 @@ /// \file /// Declaration of Diligent::CommandQueueVkImpl class +#include "vulkan.h" #include "CommandQueueVk.h" #include "ObjectBase.h" @@ -38,32 +39,35 @@ class CommandQueueVkImpl : public ObjectBase<ICommandQueueVk> public: typedef ObjectBase<ICommandQueueVk> TBase; - CommandQueueVkImpl(IReferenceCounters *pRefCounters, void *pVkNativeCmdQueue, void *pVkFence); + CommandQueueVkImpl(IReferenceCounters *pRefCounters, VkQueue VkNativeCmdQueue, uint32_t QueueFamilyIndex); ~CommandQueueVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; -/* // Returns the fence value that will be signaled next time - virtual UINT64 GetNextFenceValue()override final { return m_NextFenceValue; } + // Returns the fence value that will be signaled next time + //virtual UINT64 GetNextFenceValue()override final { return m_NextFenceValue; } // Executes a given command list - virtual UINT64 ExecuteCommandList(IVkGraphicsCommandList* commandList)override final; + //virtual UINT64 ExecuteCommandList(IVkGraphicsCommandList* commandList)override final; - virtual IVkCommandQueue* GetVkCommandQueue()override final { return m_pVkCmdQueue; } + virtual VkQueue GetVkQueue()override final{return m_VkQueue;} - virtual void IdleGPU()override final; + virtual uint32_t GetQueueFamilyIndex()override final { return m_QueueFamilyIndex; } - virtual Uint64 GetCompletedFenceValue()override final; + //virtual void IdleGPU()override final; + + //virtual Uint64 GetCompletedFenceValue()override final; private: // A value that will be signaled by the command queue next - Atomics::AtomicInt64 m_NextFenceValue; + //Atomics::AtomicInt64 m_NextFenceValue; // Last fence value completed by the GPU - volatile Uint64 m_LastCompletedFenceValue = 0; - - CComPtr<IVkCommandQueue> m_pVkCmdQueue; + //volatile Uint64 m_LastCompletedFenceValue = 0; + const VkQueue m_VkQueue; + const uint32_t m_QueueFamilyIndex; +/* // The fence is signaled right after the command list has been // submitted to the command queue for execution. // All command lists with fence value less or equal to the signaled value diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index a385d950..50e66a0b 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -34,6 +34,8 @@ #include "DynamicUploadHeap.h" #include "Atomics.h" #include "CommandQueueVk.h" +#include "VulkanUtilities/VulkanInstance.h" +#include "VulkanUtilities/VulkanPhysicalDevice.h" /// Namespace for the Direct3D11 implementation of the graphics engine namespace Diligent @@ -45,7 +47,14 @@ class RenderDeviceVkImpl : public RenderDeviceBase<IRenderDeviceVk> public: typedef RenderDeviceBase<IRenderDeviceVk> TRenderDeviceBase; - RenderDeviceVkImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineVkAttribs &CreationAttribs, void *pVkDevice, ICommandQueueVk *pCmdQueue, Uint32 NumDeferredContexts ); + RenderDeviceVkImpl( IReferenceCounters *pRefCounters, + IMemoryAllocator &RawMemAllocator, + const EngineVkAttribs &CreationAttribs, + ICommandQueueVk *pCmdQueue, + std::shared_ptr<VulkanUtilities::VulkanInstance> Instance, + std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice, + VkDevice vkLogicalDevice, + Uint32 NumDeferredContexts ); ~RenderDeviceVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; @@ -96,17 +105,20 @@ public: void ReleaseUploadHeap(DynamicUploadHeap* pUploadHeap); */ private: -#if 0 virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat ); +#if 0 void ProcessReleaseQueue(Uint64 CompletedFenceValue); void DiscardStaleVkObjects(Uint64 CmdListNumber, Uint64 FenceValue); +#endif + std::shared_ptr<VulkanUtilities::VulkanInstance> m_VulkanInstance; + std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> m_PhysicalDevice; /// Vk device - CComPtr<IVkDevice> m_pVkDevice; + VkDevice m_VkDevice = VK_NULL_HANDLE; RefCntAutoPtr<ICommandQueueVk> m_pCommandQueue; EngineVkAttribs m_EngineAttribs; - +#if 0 CPUDescriptorHeap m_CPUDescriptorHeaps[Vk_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; GPUDescriptorHeap m_GPUDescriptorHeaps[2]; // Vk_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV == 0 // Vk_DESCRIPTOR_HEAP_TYPE_SAMPLER == 1 diff --git a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h index d0900687..c712ca84 100644 --- a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h @@ -26,6 +26,7 @@ /// \file /// Definition of the Diligent::ICommandQueueVk interface +#include "vulkan.h" #include "../../../Primitives/interface/Object.h" namespace Diligent @@ -47,8 +48,11 @@ public: /// \return Fence value associated with the executed command list //virtual UINT64 ExecuteCommandList(ID3D12GraphicsCommandList* commandList) = 0; - /// Returns D3D12 command queue. May return null if queue is anavailable - //virtual ID3D12CommandQueue* GetD3D12CommandQueue() = 0; + /// Returns Vulkan command queue. May return VK_NULL_HANDLE if queue is anavailable + virtual VkQueue GetVkQueue() = 0; + + /// Returns vulkan command queue family index + virtual uint32_t GetQueueFamilyIndex() = 0; /// Returns value of the last completed fence //virtual Uint64 GetCompletedFenceValue() = 0; diff --git a/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h b/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h index ce9c86e4..77b1a7b2 100644 --- a/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h @@ -26,7 +26,7 @@ /// \file /// Definition of the Diligent::ISwapChainVk interface -//#include <dxgi1_4.h> +#include "vulkan.h" #include "../../GraphicsEngine/interface/SwapChain.h" #include "TextureViewVk.h" diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp index 0d60766c..561142f6 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceFactoryVk.cpp @@ -29,8 +29,6 @@ #include "RenderDeviceVkImpl.h" #include "DeviceContextVkImpl.h" #include "SwapChainVkImpl.h" -#include "VulkanTypeConversions.h" -#include "StringTools.h" #include "EngineMemory.h" #include "CommandQueueVkImpl.h" #include "VulkanUtilities/VulkanInstance.h" @@ -54,53 +52,22 @@ public: IDeviceContext **ppContexts, Uint32 NumDeferredContexts)override final; - /*void AttachToVkDevice(void *pVkNativeDevice, - ICommandQueueVk *pCommandQueue, - const EngineVkAttribs& EngineAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts)override final; - */ + void AttachToVulkanDevice(std::shared_ptr<VulkanUtilities::VulkanInstance>, + std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice, + VkDevice vkLogicalDevice, + ICommandQueueVk *pCommandQueue, + const EngineVkAttribs& EngineAttribs, + IRenderDevice **ppDevice, + IDeviceContext **ppContexts, + Uint32 NumDeferredContexts);//override final; void CreateSwapChainVk( IRenderDevice *pDevice, - IDeviceContext *pImmediateContext, - const SwapChainDesc& SwapChainDesc, - void* pNativeWndHandle, - ISwapChain **ppSwapChain )override final; + IDeviceContext *pImmediateContext, + const SwapChainDesc& SwapChainDesc, + void* pNativeWndHandle, + ISwapChain **ppSwapChain )override final; }; -#if 0 -void GetHardwareAdapter(IDXGIFactory2* pFactory, IDXGIAdapter1** ppAdapter) -{ - CComPtr<IDXGIAdapter1> adapter; - *ppAdapter = nullptr; - - for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex) - { - DXGI_ADAPTER_DESC1 desc; - adapter->GetDesc1(&desc); - - if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) - { - // Don't select the Basic Render Driver adapter. - // If you want a software adapter, pass in "/warp" on the command line. - continue; - } - - // Check to see if the adapter supports Direct3D 12, but don't create the - // actual device yet. - if (SUCCEEDED(VkCreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, _uuidof(IVkDevice), nullptr))) - { - LOG_INFO_MESSAGE("Vk-capabale hardware found: ", NarrowString(desc.Description), " (", desc.DedicatedVideoMemory>>20, " MB)"); - break; - } - } - - *ppAdapter = adapter.Detach(); -} -#endif - - /// Creates render device and device contexts for Vulkan backend /// \param [in] CreationAttribs - Engine creation attributes. @@ -123,6 +90,25 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk( const EngineVkAttribs& Crea if( !ppDevice || !ppContexts ) return; +#if 0 + for (Uint32 Type = Vk_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; Type < Vk_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++Type) + { + auto CPUHeapAllocSize = CreationAttribs.CPUDescriptorHeapAllocationSize[Type]; + Uint32 MaxSize = 1 << 20; + if (CPUHeapAllocSize > 1 << 20) + { + LOG_ERROR("CPU Heap allocation size is too large (", CPUHeapAllocSize, "). Max allowed size is ", MaxSize); + return; + } + + if ((CPUHeapAllocSize % 16) != 0) + { + LOG_ERROR("CPU Heap allocation size (", CPUHeapAllocSize, ") is expected to be multiple of 16"); + return; + } + } +#endif + SetRawAllocator(CreationAttribs.pRawMemAllocator); *ppDevice = nullptr; @@ -192,140 +178,19 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk( const EngineVkAttribs& Crea auto &RawMemAllocator = GetRawAllocator(); pCmdQueueVk = NEW_RC_OBJ(RawMemAllocator, "CommandQueueVk instance", CommandQueueVkImpl)(Queue, QueueInfo.queueFamilyIndex); - - //vkDestroyDevice(VulkanDevice, Instance->GetVkAllocator()); - + AttachToVulkanDevice(Instance, std::move(PhysicalDevice), VulkanDevice, pCmdQueueVk, CreationAttribs, ppDevice, ppContexts, NumDeferredContexts); } catch(std::runtime_error& ) { return; } - - - - -#if 0 - for(Uint32 Type=Vk_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; Type < Vk_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++Type) - { - auto CPUHeapAllocSize = CreationAttribs.CPUDescriptorHeapAllocationSize[Type]; - Uint32 MaxSize = 1 << 20; - if( CPUHeapAllocSize > 1 << 20 ) - { - LOG_ERROR( "CPU Heap allocation size is too large (", CPUHeapAllocSize, "). Max allowed size is ", MaxSize ); - return; - } - - if( (CPUHeapAllocSize % 16) != 0 ) - { - LOG_ERROR( "CPU Heap allocation size (", CPUHeapAllocSize, ") is expected to be multiple of 16" ); - return; - } - } - - - - CComPtr<IVkDevice> VkDevice; - try - { -#if defined(_DEBUG) - // Enable the Vk debug layer. - { - CComPtr<IVkDebug> debugController; - if (SUCCEEDED(VkGetDebugInterface(__uuidof(debugController), reinterpret_cast<void**>(static_cast<IVkDebug**>(&debugController)) ))) - { - debugController->EnableDebugLayer(); - } - } -#endif - - CComPtr<IDXGIFactory4> factory; - HRESULT hr = CreateDXGIFactory1(__uuidof(factory), reinterpret_cast<void**>(static_cast<IDXGIFactory4**>(&factory)) ); - CHECK_D3D_RESULT_THROW(hr, "Failed to create DXGI factory") - - CComPtr<IDXGIAdapter1> hardwareAdapter; - GetHardwareAdapter(factory, &hardwareAdapter); - - hr = VkCreateDevice(hardwareAdapter, D3D_FEATURE_LEVEL_11_0, __uuidof(VkDevice), reinterpret_cast<void**>(static_cast<IVkDevice**>(&VkDevice)) ); - if( FAILED(hr)) - { - LOG_WARNING_MESSAGE("Failed to create hardware device. Attempting to create WARP device"); - - CComPtr<IDXGIAdapter> warpAdapter; - hr = factory->EnumWarpAdapter( __uuidof(warpAdapter), reinterpret_cast<void**>(static_cast<IDXGIAdapter**>(&warpAdapter)) ); - CHECK_D3D_RESULT_THROW(hr, "Failed to enum warp adapter") - - hr = VkCreateDevice( warpAdapter, D3D_FEATURE_LEVEL_11_0, __uuidof(VkDevice), reinterpret_cast<void**>(static_cast<IVkDevice**>(&VkDevice)) ); - CHECK_D3D_RESULT_THROW(hr, "Failed to crate warp device") - } - -#if _DEBUG - { - CComPtr<IVkInfoQueue> pInfoQueue; - hr = VkDevice->QueryInterface(__uuidof(pInfoQueue), reinterpret_cast<void**>(static_cast<IVkInfoQueue**>(&pInfoQueue))); - if( SUCCEEDED(hr) ) - { - // Suppress whole categories of messages - //Vk_MESSAGE_CATEGORY Categories[] = {}; - - // Suppress messages based on their severity level - Vk_MESSAGE_SEVERITY Severities[] = - { - Vk_MESSAGE_SEVERITY_INFO - }; - - // Suppress individual messages by their ID - //Vk_MESSAGE_ID DenyIds[] = {}; - - Vk_INFO_QUEUE_FILTER NewFilter = {}; - //NewFilter.DenyList.NumCategories = _countof(Categories); - //NewFilter.DenyList.pCategoryList = Categories; - NewFilter.DenyList.NumSeverities = _countof(Severities); - NewFilter.DenyList.pSeverityList = Severities; - //NewFilter.DenyList.NumIDs = _countof(DenyIds); - //NewFilter.DenyList.pIDList = DenyIds; - - hr = pInfoQueue->PushStorageFilter(&NewFilter); - VERIFY(SUCCEEDED(hr), "Failed to push storage filter"); - } - } -#endif - -#ifndef RELEASE - // Prevent the GPU from overclocking or underclocking to get consistent timings - //VkDevice->SetStablePowerState(TRUE); -#endif - - // Describe and create the command queue. - Vk_COMMAND_QUEUE_DESC queueDesc = {}; - queueDesc.Flags = Vk_COMMAND_QUEUE_FLAG_NONE; - queueDesc.Type = Vk_COMMAND_LIST_TYPE_DIRECT; - - CComPtr<IVkCommandQueue> pVkCmdQueue; - hr = VkDevice->CreateCommandQueue(&queueDesc, __uuidof(pVkCmdQueue), reinterpret_cast<void**>(static_cast<IVkCommandQueue**>(&pVkCmdQueue))); - CHECK_D3D_RESULT_THROW(hr, "Failed to create command queue"); - hr = pVkCmdQueue->SetName(L"Main Command Queue"); - VERIFY_EXPR(SUCCEEDED(hr)); - - CComPtr<IVkFence> pVkFence; - hr = VkDevice->CreateFence(0, Vk_FENCE_FLAG_NONE, __uuidof(pVkFence), reinterpret_cast<void**>(static_cast<IVkFence**>(&pVkFence))); - CHECK_D3D_RESULT_THROW(hr, "Failed to create main command queue fence"); - VkDevice->SetName(L"Main Command Queue fence"); - - } - catch( const std::runtime_error & ) - { - LOG_ERROR( "Failed to initialize Vk resources" ); - return; - } - - AttachToVkDevice(VkDevice, pCmdQueueVk, CreationAttribs, ppDevice, ppContexts, NumDeferredContexts); -#endif } -#if 0 -/// Attaches to existing Vk device +/// Attaches to existing Vulkan device -/// \param [in] pVkNativeDevice - pointer to native Vk device +/// \param [in] Instance - shared pointer to a VulkanUtilities::VulkanInstance object +/// \param [in] PhysicalDevice - pointer to the object representing physical device +/// \param [in] vkLogicalDevice - logical Vulkan device handle /// \param [in] pCommandQueue - pointer to the implementation of command queue /// \param [in] EngineAttribs - Engine creation attributes. /// \param [out] ppDevice - Address of the memory location where pointer to @@ -338,15 +203,17 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk( const EngineVkAttribs& Crea /// of deferred contexts is requested, pointers to the /// contexts are written to ppContexts array starting /// at position 1 -void EngineFactoryVkImpl::AttachToVkDevice(void *pVkNativeDevice, - ICommandQueueVk *pCommandQueue, - const EngineVkAttribs& EngineAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) +void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptr<VulkanUtilities::VulkanInstance> Instance, + std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice, + VkDevice vkLogicalDevice, + ICommandQueueVk *pCommandQueue, + const EngineVkAttribs& EngineAttribs, + IRenderDevice **ppDevice, + IDeviceContext **ppContexts, + Uint32 NumDeferredContexts) { - VERIFY( pVkNativeDevice && pCommandQueue && ppDevice && ppContexts, "Null pointer provided" ); - if( !pVkNativeDevice || !pCommandQueue || !ppDevice || !ppContexts ) + VERIFY( pCommandQueue && ppDevice && ppContexts, "Null pointer provided" ); + if(vkLogicalDevice == VK_NULL_HANDLE || !pCommandQueue || !ppDevice || !ppContexts ) return; *ppDevice = nullptr; @@ -355,8 +222,7 @@ void EngineFactoryVkImpl::AttachToVkDevice(void *pVkNativeDevice, try { auto &RawMemAllocator = GetRawAllocator(); - auto VkDevice = reinterpret_cast<IVkDevice*>(pVkNativeDevice); - RenderDeviceVkImpl *pRenderDeviceVk( NEW_RC_OBJ(RawMemAllocator, "RenderDeviceVkImpl instance", RenderDeviceVkImpl)(RawMemAllocator, EngineAttribs, VkDevice, pCommandQueue, NumDeferredContexts ) ); + RenderDeviceVkImpl *pRenderDeviceVk( NEW_RC_OBJ(RawMemAllocator, "RenderDeviceVkImpl instance", RenderDeviceVkImpl)(RawMemAllocator, EngineAttribs, pCommandQueue, Instance, std::move(PhysicalDevice), vkLogicalDevice, NumDeferredContexts ) ); pRenderDeviceVk->QueryInterface(IID_RenderDevice, reinterpret_cast<IObject**>(ppDevice) ); RefCntAutoPtr<DeviceContextVkImpl> pImmediateCtxVk( NEW_RC_OBJ(RawMemAllocator, "DeviceContextVkImpl instance", DeviceContextVkImpl)(pRenderDeviceVk, false, EngineAttribs, 0) ); @@ -393,7 +259,6 @@ void EngineFactoryVkImpl::AttachToVkDevice(void *pVkNativeDevice, LOG_ERROR( "Failed to create device and contexts" ); } } -#endif /// Creates a swap chain for Direct3D12-based engine implementation diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 36f2bfd8..a2854917 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -36,12 +36,21 @@ namespace Diligent { -RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineVkAttribs &CreationAttribs, void *pVkDevice, ICommandQueueVk *pCmdQueue, Uint32 NumDeferredContexts) : - TRenderDeviceBase(pRefCounters, RawMemAllocator, NumDeferredContexts, sizeof(TextureVkImpl), sizeof(TextureViewVkImpl), sizeof(BufferVkImpl), sizeof(BufferViewVkImpl), sizeof(ShaderVkImpl), sizeof(SamplerVkImpl), sizeof(PipelineStateVkImpl), sizeof(ShaderResourceBindingVkImpl))/*, - m_pVkDevice(pVkDevice), +RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters *pRefCounters, + IMemoryAllocator &RawMemAllocator, + const EngineVkAttribs &CreationAttribs, + ICommandQueueVk *pCmdQueue, + std::shared_ptr<VulkanUtilities::VulkanInstance> Instance, + std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice, + VkDevice vkLogicalDevice, + Uint32 NumDeferredContexts) : + TRenderDeviceBase(pRefCounters, RawMemAllocator, NumDeferredContexts, sizeof(TextureVkImpl), sizeof(TextureViewVkImpl), sizeof(BufferVkImpl), sizeof(BufferViewVkImpl), sizeof(ShaderVkImpl), sizeof(SamplerVkImpl), sizeof(PipelineStateVkImpl), sizeof(ShaderResourceBindingVkImpl)), + m_VulkanInstance(Instance), + m_PhysicalDevice(std::move(PhysicalDevice)), + m_VkDevice(vkLogicalDevice), m_pCommandQueue(pCmdQueue), - m_EngineAttribs(CreationAttribs), - m_FrameNumber(0), + m_EngineAttribs(CreationAttribs) + /*m_FrameNumber(0), m_NextCmdListNumber(0), m_CmdListManager(this), m_CPUDescriptorHeaps @@ -69,7 +78,7 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters *pRefCounters, IMemo */ { m_DeviceCaps.DevType = DeviceType::Vulkan; - m_DeviceCaps.MajorVersion = 12; + m_DeviceCaps.MajorVersion = 1; m_DeviceCaps.MinorVersion = 0; m_DeviceCaps.bSeparableProgramSupported = True; m_DeviceCaps.bMultithreadedResourceCreationSupported = True; @@ -90,6 +99,13 @@ RenderDeviceVkImpl::~RenderDeviceVkImpl() m_ContextPool.clear(); #endif + + if(m_PhysicalDevice) + { + // If m_PhysicalDevice is empty, the device does not own vulkan logical device and must not + // destroy it + vkDestroyDevice(m_VkDevice, m_VulkanInstance->GetVkAllocator()); + } } #if 0 @@ -399,9 +415,11 @@ bool CreateTestResource(IVkDevice *pDevice, const Vk_RESOURCE_DESC &ResDesc) auto hr = pDevice->CreateCommittedResource( &HeapProps, Vk_HEAP_FLAG_NONE, &ResDesc, Vk_RESOURCE_STATE_COMMON, nullptr, __uuidof(IVkResource), nullptr ); return hr == S_FALSE; // S_FALSE means that input parameters passed validation } +#endif void RenderDeviceVkImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) { +#if 0 auto &TexFormatInfo = m_TextureFormatsInfo[TexFormat]; VERIFY( TexFormatInfo.Supported, "Texture format is not supported" ); @@ -496,8 +514,9 @@ void RenderDeviceVkImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) ResDesc.DepthOrArraySize = TestTextureDepth; TexFormatInfo.Tex3DFmt = CreateTestResource( m_pVkDevice, ResDesc ); } -} #endif +} + IMPLEMENT_QUERY_INTERFACE( RenderDeviceVkImpl, IID_RenderDeviceVk, TRenderDeviceBase ) |
