فهرست منبع

Some refactoring and some D3D code

Panagiotis Christopoulos Charitos 1 سال پیش
والد
کامیت
4b1af034ee
41فایلهای تغییر یافته به همراه436 افزوده شده و 140 حذف شده
  1. 1 1
      AnKi/Gr/BackendCommon/Common.h
  2. 0 0
      AnKi/Gr/BackendCommon/Format.def.h
  3. 1 1
      AnKi/Gr/BackendCommon/Functions.cpp
  4. 1 1
      AnKi/Gr/BackendCommon/Functions.h
  5. 0 0
      AnKi/Gr/BackendCommon/InstantiationMacros.def.h
  6. 3 3
      AnKi/Gr/BackendCommon/MicroObjectRecycler.h
  7. 1 1
      AnKi/Gr/BackendCommon/MicroObjectRecycler.inl.h
  8. 4 4
      AnKi/Gr/CMakeLists.txt
  9. 1 1
      AnKi/Gr/Common.cpp
  10. 1 1
      AnKi/Gr/Common.h
  11. 16 1
      AnKi/Gr/D3D/D3DCommandBuffer.cpp
  12. 2 0
      AnKi/Gr/D3D/D3DCommandBuffer.h
  13. 36 1
      AnKi/Gr/D3D/D3DCommon.h
  14. 26 8
      AnKi/Gr/D3D/D3DDescriptorHeap.h
  15. 0 7
      AnKi/Gr/D3D/D3DFence.cpp
  16. 4 0
      AnKi/Gr/D3D/D3DFence.h
  17. 7 71
      AnKi/Gr/D3D/D3DGrManager.cpp
  18. 2 10
      AnKi/Gr/D3D/D3DGrManager.h
  19. 107 0
      AnKi/Gr/D3D/D3DSwapchainFactory.cpp
  20. 112 0
      AnKi/Gr/D3D/D3DSwapchainFactory.h
  21. 81 1
      AnKi/Gr/D3D/D3DTexture.cpp
  22. 8 3
      AnKi/Gr/D3D/D3DTexture.h
  23. 1 1
      AnKi/Gr/Vulkan/VkCommandBuffer.h
  24. 2 2
      AnKi/Gr/Vulkan/VkCommandBufferFactory.h
  25. 1 1
      AnKi/Gr/Vulkan/VkCommon.h
  26. 1 1
      AnKi/Gr/Vulkan/VkDescriptorSetFactory.cpp
  27. 0 0
      AnKi/Gr/Vulkan/VkDescriptorSetFactory.h
  28. 1 1
      AnKi/Gr/Vulkan/VkFrameGarbageCollector.cpp
  29. 2 2
      AnKi/Gr/Vulkan/VkPipelineFactory.cpp
  30. 1 1
      AnKi/Gr/Vulkan/VkPipelineFactory.h
  31. 1 1
      AnKi/Gr/Vulkan/VkPipelineLayoutFactory.cpp
  32. 1 1
      AnKi/Gr/Vulkan/VkPipelineLayoutFactory.h
  33. 1 1
      AnKi/Gr/Vulkan/VkSemaphoreFactory.h
  34. 1 1
      AnKi/Gr/Vulkan/VkShader.h
  35. 2 2
      AnKi/Gr/Vulkan/VkShaderProgram.cpp
  36. 2 2
      AnKi/Gr/Vulkan/VkShaderProgram.h
  37. 1 1
      AnKi/Gr/Vulkan/VkSwapchainFactory.cpp
  38. 1 4
      AnKi/Gr/Vulkan/VkSwapchainFactory.h
  39. 1 1
      AnKi/Gr/Vulkan/VkTexture.cpp
  40. 1 1
      AnKi/Gr/Vulkan/VkTexture.h
  41. 1 1
      AnKi/Resource/ShaderProgramResource.h

+ 1 - 1
AnKi/Gr/Common/BackendCommon.h → AnKi/Gr/BackendCommon/Common.h

@@ -5,7 +5,7 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <AnKi/Util/StdTypes.h>
+#include <AnKi/Gr/Common.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 0 - 0
AnKi/Gr/Common/Format.def.h → AnKi/Gr/BackendCommon/Format.def.h


+ 1 - 1
AnKi/Gr/Common/Functions.cpp → AnKi/Gr/BackendCommon/Functions.cpp

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Gr/Common/Functions.h>
+#include <AnKi/Gr/BackendCommon/Functions.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Common/Functions.h → AnKi/Gr/BackendCommon/Functions.h

@@ -5,7 +5,7 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <AnKi/Gr/Common.h>
+#include <AnKi/Gr/BackendCommon/Common.h>
 #include <AnKi/Math.h>
 #include <AnKi/Math.h>
 
 
 namespace anki {
 namespace anki {

+ 0 - 0
AnKi/Gr/Common/InstantiationMacros.def.h → AnKi/Gr/BackendCommon/InstantiationMacros.def.h


+ 3 - 3
AnKi/Gr/Vulkan/VkMicroObjectRecycler.h → AnKi/Gr/BackendCommon/MicroObjectRecycler.h

@@ -5,12 +5,12 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <AnKi/Gr/Vulkan/VkCommon.h>
+#include <AnKi/Gr/BackendCommon/Common.h>
 #include <AnKi/Util/DynamicArray.h>
 #include <AnKi/Util/DynamicArray.h>
 
 
 namespace anki {
 namespace anki {
 
 
-/// @addtogroup vulkan
+/// @addtogroup graphics
 /// @{
 /// @{
 
 
 /// Helper class for MicroXXX objects. It expects a specific interface for the T.
 /// Helper class for MicroXXX objects. It expects a specific interface for the T.
@@ -82,4 +82,4 @@ private:
 
 
 } // end namespace anki
 } // end namespace anki
 
 
-#include <AnKi/Gr/Vulkan/VkMicroObjectRecycler.inl.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.inl.h>

+ 1 - 1
AnKi/Gr/Vulkan/VkMicroObjectRecycler.inl.h → AnKi/Gr/BackendCommon/MicroObjectRecycler.inl.h

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Gr/Vulkan/VkMicroObjectRecycler.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 4 - 4
AnKi/Gr/CMakeLists.txt

@@ -6,7 +6,7 @@ set(backend_sources
 	RenderGraph.cpp
 	RenderGraph.cpp
 	ShaderProgram.cpp
 	ShaderProgram.cpp
 	Utils/StackGpuMemoryPool.cpp
 	Utils/StackGpuMemoryPool.cpp
-	Common/Functions.cpp
+	BackendCommon/Functions.cpp
 	Utils/SegregatedListsGpuMemoryPool.cpp)
 	Utils/SegregatedListsGpuMemoryPool.cpp)
 
 
 set(backend_headers
 set(backend_headers
@@ -30,9 +30,9 @@ set(backend_headers
 	PipelineQuery.h
 	PipelineQuery.h
 	GrUpscaler.h
 	GrUpscaler.h
 	Utils/StackGpuMemoryPool.h
 	Utils/StackGpuMemoryPool.h
-	Common/Functions.h
-	Common/InstantiationMacros.def.h
-	Common/Format.def.h
+	BackendCommon/Functions.h
+	BackendCommon/InstantiationMacros.def.h
+	BackendCommon/Format.def.h
 	Utils/SegregatedListsGpuMemoryPool.h)
 	Utils/SegregatedListsGpuMemoryPool.h)
 
 
 if(VULKAN)
 if(VULKAN)

+ 1 - 1
AnKi/Gr/Common.cpp

@@ -39,7 +39,7 @@ FormatInfo getFormatInfo(Format fmt)
 		out = {componentCount,      texelSize, blockWidth, blockHeight, blockSize, shaderType, DepthStencilAspectBit::k##depthStencil, \
 		out = {componentCount,      texelSize, blockWidth, blockHeight, blockSize, shaderType, DepthStencilAspectBit::k##depthStencil, \
 			   ANKI_STRINGIZE(type)}; \
 			   ANKI_STRINGIZE(type)}; \
 		break;
 		break;
-#include <AnKi/Gr/Common/Format.def.h>
+#include <AnKi/Gr/BackendCommon/Format.def.h>
 #undef ANKI_FORMAT_DEF
 #undef ANKI_FORMAT_DEF
 
 
 	default:
 	default:

+ 1 - 1
AnKi/Gr/Common.h

@@ -404,7 +404,7 @@ enum class Format : U32
 	kNone = 0,
 	kNone = 0,
 
 
 #define ANKI_FORMAT_DEF(type, id, componentCount, texelSize, blockWidth, blockHeight, blockSize, shaderType, depthStencil) k##type = id,
 #define ANKI_FORMAT_DEF(type, id, componentCount, texelSize, blockWidth, blockHeight, blockSize, shaderType, depthStencil) k##type = id,
-#include <AnKi/Gr/Common/Format.def.h>
+#include <AnKi/Gr/BackendCommon/Format.def.h>
 #undef ANKI_FORMAT_DEF
 #undef ANKI_FORMAT_DEF
 };
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(Format)
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(Format)

+ 16 - 1
AnKi/Gr/D3D/D3DCommandBuffer.cpp

@@ -175,7 +175,22 @@ void CommandBuffer::bindShaderProgram(ShaderProgram* prog)
 void CommandBuffer::beginRenderPass(ConstWeakArray<RenderTarget> colorRts, RenderTarget* depthStencilRt, U32 minx, U32 miny, U32 width, U32 height,
 void CommandBuffer::beginRenderPass(ConstWeakArray<RenderTarget> colorRts, RenderTarget* depthStencilRt, U32 minx, U32 miny, U32 width, U32 height,
 									TextureView* vrsRt, U8 vrsRtTexelSizeX, U8 vrsRtTexelSizeY)
 									TextureView* vrsRt, U8 vrsRtTexelSizeX, U8 vrsRtTexelSizeY)
 {
 {
-	ANKI_ASSERT(!"TODO");
+	ANKI_D3D_SELF(CommandBufferImpl);
+
+	Array<D3D12_RENDER_PASS_RENDER_TARGET_DESC, kMaxColorRenderTargets> colorRtDescs;
+	for(U32 i = 0; i < colorRts.getSize(); ++i)
+	{
+		const RenderTarget& rt = colorRts[i];
+		D3D12_RENDER_PASS_RENDER_TARGET_DESC& desc = colorRtDescs[i];
+
+		desc = {};
+		// desc.cpuDescriptor = rt.m_view->
+		desc.BeginningAccess.Type = convertLoadOp(rt.m_loadOperation);
+		memcpy(&desc.BeginningAccess.Clear.ClearValue.Color, &rt.m_clearValue.m_colorf[0], sizeof(F32) * 4);
+		desc.EndingAccess.Type = convertStoreOp(rt.m_storeOperation);
+	}
+
+	// self.m_cmdList->BeginRenderPass(colorRts.getSize(), )
 }
 }
 
 
 void CommandBuffer::endRenderPass()
 void CommandBuffer::endRenderPass()

+ 2 - 0
AnKi/Gr/D3D/D3DCommandBuffer.h

@@ -16,6 +16,8 @@ namespace anki {
 /// Command buffer implementation.
 /// Command buffer implementation.
 class CommandBufferImpl final : public CommandBuffer
 class CommandBufferImpl final : public CommandBuffer
 {
 {
+	friend class CommandBuffer;
+
 public:
 public:
 	CommandBufferImpl(CString name)
 	CommandBufferImpl(CString name)
 		: CommandBuffer(name)
 		: CommandBuffer(name)

+ 36 - 1
AnKi/Gr/D3D/D3DCommon.h

@@ -7,7 +7,7 @@
 
 
 #include <AnKi/Gr/Common.h>
 #include <AnKi/Gr/Common.h>
 #include <AnKi/Util/Logger.h>
 #include <AnKi/Util/Logger.h>
-#include <AnKi/Gr/Common/BackendCommon.h>
+#include <AnKi/Gr/BackendCommon/Common.h>
 #include <string>
 #include <string>
 #include <locale>
 #include <locale>
 #include <codecvt>
 #include <codecvt>
@@ -87,6 +87,41 @@ void safeRelease(T*& p)
 ID3D12Device& getDevice();
 ID3D12Device& getDevice();
 
 
 GrManagerImpl& getGrManagerImpl();
 GrManagerImpl& getGrManagerImpl();
+
+inline [[nodiscard]] D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE convertLoadOp(RenderTargetLoadOperation ak)
+{
+	D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE out;
+	switch(ak)
+	{
+	case RenderTargetLoadOperation::kClear:
+		out = D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR;
+		break;
+	case RenderTargetLoadOperation::kDontCare:
+		out = D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD;
+		break;
+	default:
+		ANKI_ASSERT(ak == RenderTargetLoadOperation::kLoad);
+		out = D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE;
+		break;
+	}
+	return out;
+}
+
+inline [[nodiscard]] D3D12_RENDER_PASS_ENDING_ACCESS_TYPE convertStoreOp(RenderTargetStoreOperation ak)
+{
+	D3D12_RENDER_PASS_ENDING_ACCESS_TYPE out;
+	switch(ak)
+	{
+	case RenderTargetStoreOperation::kDontCare:
+		out = D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD;
+		break;
+	default:
+		ANKI_ASSERT(ak == RenderTargetStoreOperation::kStore);
+		out = D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE;
+		break;
+	}
+	return out;
+}
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 26 - 8
AnKi/Gr/D3D/D3DDescriptorHeap.h

@@ -9,9 +9,22 @@
 
 
 namespace anki {
 namespace anki {
 
 
+// Forward
+class DescriptorHeap;
+
 /// @addtogroup directx
 /// @addtogroup directx
 /// @{
 /// @{
 
 
+/// @memberof DescriptorHeap.
+class DescriptorHeapHandle
+{
+public:
+	D3D12_CPU_DESCRIPTOR_HANDLE m_cpuHandle = {};
+#if ANKI_ASSERTIONS_ENABLED
+	DescriptorHeap* m_father = nullptr;
+#endif
+};
+
 class DescriptorHeap
 class DescriptorHeap
 {
 {
 public:
 public:
@@ -44,7 +57,7 @@ public:
 	}
 	}
 
 
 	/// @note Thread-safe.
 	/// @note Thread-safe.
-	D3D12_CPU_DESCRIPTOR_HANDLE allocate()
+	DescriptorHeapHandle allocate()
 	{
 	{
 		ANKI_ASSERT(m_heap);
 		ANKI_ASSERT(m_heap);
 		U16 idx;
 		U16 idx;
@@ -59,29 +72,34 @@ public:
 		}
 		}
 
 
 		idx = m_freeDescriptors[idx];
 		idx = m_freeDescriptors[idx];
-		D3D12_CPU_DESCRIPTOR_HANDLE out;
-		out.ptr = m_heapStart.ptr + PtrSize(idx) * m_descriptorSize;
+		DescriptorHeapHandle out;
+		out.m_cpuHandle.ptr = m_heapStart.ptr + PtrSize(idx) * m_descriptorSize;
+#if ANKI_ASSERTIONS_ENABLED
+		out.m_father = this;
+#endif
 		return out;
 		return out;
 	}
 	}
 
 
 	/// @note Thread-safe.
 	/// @note Thread-safe.
-	void free(D3D12_CPU_DESCRIPTOR_HANDLE handle)
+	void free(DescriptorHeapHandle& handle)
 	{
 	{
 		ANKI_ASSERT(m_heap);
 		ANKI_ASSERT(m_heap);
-		if(handle.ptr == 0)
+		if(handle.m_cpuHandle.ptr == 0)
 		{
 		{
 			return;
 			return;
 		}
 		}
 
 
-		ANKI_ASSERT(handle.ptr != 0 && handle.ptr >= m_heapStart.ptr
-					&& handle.ptr < m_heapStart.ptr + PtrSize(m_descriptorSize) + m_freeDescriptors.getSize());
+		ANKI_ASSERT(handle.m_father == this);
+		ANKI_ASSERT(handle.m_cpuHandle.ptr != 0 && handle.m_cpuHandle.ptr >= m_heapStart.ptr
+					&& handle.m_cpuHandle.ptr < m_heapStart.ptr + PtrSize(m_descriptorSize) + m_freeDescriptors.getSize());
 
 
-		const U16 idx = U16((handle.ptr - m_heapStart.ptr) / m_descriptorSize);
+		const U16 idx = U16((handle.m_cpuHandle.ptr - m_heapStart.ptr) / m_descriptorSize);
 
 
 		LockGuard lock(m_mtx);
 		LockGuard lock(m_mtx);
 		ANKI_ASSERT(m_freeDescriptorsHead > 0);
 		ANKI_ASSERT(m_freeDescriptorsHead > 0);
 		--m_freeDescriptorsHead;
 		--m_freeDescriptorsHead;
 		m_freeDescriptors[m_freeDescriptorsHead] = idx;
 		m_freeDescriptors[m_freeDescriptorsHead] = idx;
+		handle = {};
 	}
 	}
 
 
 private:
 private:

+ 0 - 7
AnKi/Gr/D3D/D3DFence.cpp

@@ -132,13 +132,6 @@ void FenceFactory::trimSignaledFences(Bool wait)
 		const Bool signaled = fence->clientWait((wait) ? kMaxFenceOrSemaphoreWaitTime : 0.0f);
 		const Bool signaled = fence->clientWait((wait) ? kMaxFenceOrSemaphoreWaitTime : 0.0f);
 		if(signaled)
 		if(signaled)
 		{
 		{
-			if(!CloseHandle(fence->m_event))
-			{
-				ANKI_D3D_LOGE("CloseHandle() failed");
-			}
-
-			safeRelease(fence->m_fence);
-
 			deleteInstance(GrMemoryPool::getSingleton(), fence);
 			deleteInstance(GrMemoryPool::getSingleton(), fence);
 
 
 			ANKI_ASSERT(m_aliveFenceCount > 0);
 			ANKI_ASSERT(m_aliveFenceCount > 0);

+ 4 - 0
AnKi/Gr/D3D/D3DFence.h

@@ -26,6 +26,10 @@ public:
 	~MicroFence()
 	~MicroFence()
 	{
 	{
 		ANKI_ASSERT(!done());
 		ANKI_ASSERT(!done());
+		if(!CloseHandle(m_event))
+		{
+			ANKI_D3D_LOGE("CloseHandle() failed");
+		}
 		safeRelease(m_fence);
 		safeRelease(m_fence);
 	}
 	}
 
 

+ 7 - 71
AnKi/Gr/D3D/D3DGrManager.cpp

@@ -170,8 +170,8 @@ TexturePtr GrManager::acquireNextPresentableTexture()
 {
 {
 	ANKI_D3D_SELF(GrManagerImpl);
 	ANKI_D3D_SELF(GrManagerImpl);
 
 
-	self.m_swapchain.m_backbufferIdx = self.m_swapchain.m_swapchain->GetCurrentBackBufferIndex();
-	return self.m_swapchain.m_textures[self.m_swapchain.m_backbufferIdx];
+	self.m_crntSwapchain->m_backbufferIdx = self.m_crntSwapchain->m_swapchain->GetCurrentBackBufferIndex();
+	return self.m_crntSwapchain->m_textures[self.m_crntSwapchain->m_backbufferIdx];
 }
 }
 
 
 void GrManager::swapBuffers()
 void GrManager::swapBuffers()
@@ -179,7 +179,7 @@ void GrManager::swapBuffers()
 	ANKI_TRACE_SCOPED_EVENT(D3DSwapBuffers);
 	ANKI_TRACE_SCOPED_EVENT(D3DSwapBuffers);
 	ANKI_D3D_SELF(GrManagerImpl);
 	ANKI_D3D_SELF(GrManagerImpl);
 
 
-	self.m_swapchain.m_swapchain->Present((g_vsyncCVar.get()) ? 1 : 0, (g_vsyncCVar.get()) ? 0 : DXGI_PRESENT_ALLOW_TEARING);
+	self.m_crntSwapchain->m_swapchain->Present((g_vsyncCVar.get()) ? 1 : 0, (g_vsyncCVar.get()) ? 0 : DXGI_PRESENT_ALLOW_TEARING);
 
 
 	MicroFencePtr presentFence = FenceFactory::getSingleton().newInstance();
 	MicroFencePtr presentFence = FenceFactory::getSingleton().newInstance();
 	presentFence->signal(GpuQueueType::kGeneral);
 	presentFence->signal(GpuQueueType::kGeneral);
@@ -235,7 +235,6 @@ ANKI_NEW_GR_OBJECT(Sampler)
 ANKI_NEW_GR_OBJECT(Shader)
 ANKI_NEW_GR_OBJECT(Shader)
 ANKI_NEW_GR_OBJECT(ShaderProgram)
 ANKI_NEW_GR_OBJECT(ShaderProgram)
 ANKI_NEW_GR_OBJECT(CommandBuffer)
 ANKI_NEW_GR_OBJECT(CommandBuffer)
-// ANKI_NEW_GR_OBJECT_NO_INIT_INFO(OcclusionQuery)
 ANKI_NEW_GR_OBJECT_NO_INIT_INFO(TimestampQuery)
 ANKI_NEW_GR_OBJECT_NO_INIT_INFO(TimestampQuery)
 ANKI_NEW_GR_OBJECT(PipelineQuery)
 ANKI_NEW_GR_OBJECT(PipelineQuery)
 ANKI_NEW_GR_OBJECT_NO_INIT_INFO(RenderGraph)
 ANKI_NEW_GR_OBJECT_NO_INIT_INFO(RenderGraph)
@@ -283,7 +282,7 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 		AddVectoredExceptionHandler(true, vexHandler);
 		AddVectoredExceptionHandler(true, vexHandler);
 	}
 	}
 
 
-	ComPtr<IDXGIFactory4> factory2;
+	ComPtr<IDXGIFactory2> factory2;
 	ANKI_D3D_CHECK(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory2)));
 	ANKI_D3D_CHECK(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory2)));
 	ComPtr<IDXGIFactory6> factory6;
 	ComPtr<IDXGIFactory6> factory6;
 	ANKI_D3D_CHECK(factory2->QueryInterface(IID_PPV_ARGS(&factory6)));
 	ANKI_D3D_CHECK(factory2->QueryInterface(IID_PPV_ARGS(&factory6)));
@@ -382,55 +381,7 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 	ANKI_CHECK(RtvDescriptorHeap::getSingleton().init(D3D12_DESCRIPTOR_HEAP_TYPE_RTV, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, kMaxRtvDescriptors,
 	ANKI_CHECK(RtvDescriptorHeap::getSingleton().init(D3D12_DESCRIPTOR_HEAP_TYPE_RTV, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, kMaxRtvDescriptors,
 													  m_limits.m_rtvDescriptorSize));
 													  m_limits.m_rtvDescriptorSize));
 
 
-	// Create swapchain
-	{
-		const NativeWindowSdl& window = static_cast<NativeWindowSdl&>(NativeWindow::getSingleton());
-
-		SDL_SysWMinfo wmInfo;
-		SDL_VERSION(&wmInfo.version);
-		SDL_GetWindowWMInfo(window.m_sdlWindow, &wmInfo);
-		const HWND hwnd = wmInfo.info.win.window;
-
-		// Describe and create the swap chain.
-		DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
-		swapChainDesc.BufferCount = kMaxFramesInFlight;
-		swapChainDesc.Width = window.getWidth();
-		swapChainDesc.Height = window.getHeight();
-		swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
-		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
-		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
-		swapChainDesc.SampleDesc.Count = 1;
-
-		ComPtr<IDXGISwapChain1> swapChain;
-		// Swap chain needs the queue so that it can force a flush on it.
-		ANKI_D3D_CHECK(factory2->CreateSwapChainForHwnd(m_queues[GpuQueueType::kGeneral], hwnd, &swapChainDesc, nullptr, nullptr, &swapChain));
-
-		swapChain->QueryInterface(IID_PPV_ARGS(&m_swapchain.m_swapchain));
-
-		// Does not support fullscreen transitions.
-		factory2->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
-
-		m_swapchain.m_backbufferIdx = m_swapchain.m_swapchain->GetCurrentBackBufferIndex();
-
-		// Store swapchain RTVs
-		for(U32 i = 0; i < kMaxFramesInFlight; ++i)
-		{
-			m_swapchain.m_rtvHandles[i] = RtvDescriptorHeap::getSingleton().allocate();
-			ANKI_D3D_CHECK(m_swapchain.m_swapchain->GetBuffer(i, IID_PPV_ARGS(&m_swapchain.m_rtvResources[i])));
-			m_device->CreateRenderTargetView(m_swapchain.m_rtvResources[i], nullptr, m_swapchain.m_rtvHandles[i]);
-
-			TextureInitInfo init("SwapchainImg");
-			init.m_width = window.getWidth();
-			init.m_height = window.getHeight();
-			init.m_format = Format::kR8G8B8A8_Unorm;
-			init.m_usage = TextureUsageBit::kFramebufferRead | TextureUsageBit::kFramebufferWrite | TextureUsageBit::kPresent;
-			init.m_type = TextureType::k2D;
-
-			TextureImpl* tex = newInstance<TextureImpl>(GrMemoryPool::getSingleton(), init.getName());
-			m_swapchain.m_textures[i].reset(tex);
-		}
-	}
-
+	SwapchainFactory::allocateSingleton();
 	FenceFactory::allocateSingleton();
 	FenceFactory::allocateSingleton();
 
 
 	return Error::kNone;
 	return Error::kNone;
@@ -440,22 +391,9 @@ void GrManagerImpl::destroy()
 {
 {
 	ANKI_D3D_LOGI("Destroying D3D backend");
 	ANKI_D3D_LOGI("Destroying D3D backend");
 
 
-	FenceFactory::freeSingleton();
-
-	for(D3D12_CPU_DESCRIPTOR_HANDLE handle : m_swapchain.m_rtvHandles)
-	{
-		RtvDescriptorHeap::getSingleton().free(handle);
-	}
-
-	for(ID3D12Resource* rsrc : m_swapchain.m_rtvResources)
-	{
-		safeRelease(rsrc);
-	}
-
-	safeRelease(m_swapchain.m_swapchain);
-	m_swapchain = {};
-
+	SwapchainFactory::freeSingleton();
 	RtvDescriptorHeap::freeSingleton();
 	RtvDescriptorHeap::freeSingleton();
+	FenceFactory::freeSingleton();
 
 
 	safeRelease(m_queues[GpuQueueType::kGeneral]);
 	safeRelease(m_queues[GpuQueueType::kGeneral]);
 	safeRelease(m_queues[GpuQueueType::kCompute]);
 	safeRelease(m_queues[GpuQueueType::kCompute]);
@@ -470,8 +408,6 @@ void GrManagerImpl::destroy()
 		}
 		}
 	}
 	}
 
 
-	ANKI_D3D_LOGI("Destroying D3D backend completed");
-
 	GrMemoryPool::freeSingleton();
 	GrMemoryPool::freeSingleton();
 }
 }
 
 

+ 2 - 10
AnKi/Gr/D3D/D3DGrManager.h

@@ -8,7 +8,7 @@
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/D3D/D3DCommon.h>
 #include <AnKi/Gr/D3D/D3DCommon.h>
 #include <AnKi/Gr/D3D/D3DFence.h>
 #include <AnKi/Gr/D3D/D3DFence.h>
-#include <AnKi/Gr/D3D/D3DTexture.h>
+#include <AnKi/Gr/D3D/D3DSwapchainFactory.h>
 
 
 namespace anki {
 namespace anki {
 
 
@@ -59,15 +59,7 @@ private:
 
 
 	Mutex m_globalMtx;
 	Mutex m_globalMtx;
 
 
-	class
-	{
-	public:
-		IDXGISwapChain3* m_swapchain = nullptr;
-		Array<D3D12_CPU_DESCRIPTOR_HANDLE, kMaxFramesInFlight> m_rtvHandles = {};
-		Array<ID3D12Resource*, kMaxFramesInFlight> m_rtvResources = {};
-		Array<TexturePtr, kMaxFramesInFlight> m_textures;
-		U32 m_backbufferIdx = 0;
-	} m_swapchain;
+	MicroSwapchainPtr m_crntSwapchain;
 
 
 	class PerFrame
 	class PerFrame
 	{
 	{

+ 107 - 0
AnKi/Gr/D3D/D3DSwapchainFactory.cpp

@@ -0,0 +1,107 @@
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include <AnKi/Gr/D3D/D3DSwapchainFactory.h>
+#include <AnKi/Gr/D3D/D3DDescriptorHeap.h>
+#include <AnKi/Gr/D3D/D3DTexture.h>
+#include <AnKi/Gr/D3D/D3DGrManager.h>
+#include <AnKi/Window/NativeWindowSdl.h>
+
+#if ANKI_WINDOWING_SYSTEM_SDL
+#	include <AnKi/Window/NativeWindowSdl.h>
+#	include <SDL_syswm.h>
+#endif
+
+namespace anki {
+
+MicroSwapchain::MicroSwapchain()
+{
+	if(initInternal())
+	{
+		ANKI_D3D_LOGF("Error creating the swapchain. Will not try to recover");
+	}
+}
+
+MicroSwapchain::~MicroSwapchain()
+{
+	// First release the textures
+	m_textures = {};
+
+	for(ID3D12Resource* rsrc : m_rtvResources)
+	{
+		safeRelease(rsrc);
+	}
+
+	safeRelease(m_swapchain);
+}
+
+Error MicroSwapchain::initInternal()
+{
+	const NativeWindowSdl& window = static_cast<NativeWindowSdl&>(NativeWindow::getSingleton());
+
+	SDL_SysWMinfo wmInfo;
+	SDL_VERSION(&wmInfo.version);
+	SDL_GetWindowWMInfo(window.m_sdlWindow, &wmInfo);
+	const HWND hwnd = wmInfo.info.win.window;
+
+	ComPtr<IDXGIFactory2> factory2;
+	ANKI_D3D_CHECK(CreateDXGIFactory2((g_validationCVar.get()) ? DXGI_CREATE_FACTORY_DEBUG : 0, IID_PPV_ARGS(&factory2)));
+
+	// Describe and create the swap chain.
+	DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
+	swapChainDesc.BufferCount = kMaxFramesInFlight;
+	swapChainDesc.Width = window.getWidth();
+	swapChainDesc.Height = window.getHeight();
+	swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+	swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+	swapChainDesc.SampleDesc.Count = 1;
+
+	ComPtr<IDXGISwapChain1> swapChain;
+	// Swap chain needs the queue so that it can force a flush on it.
+	ANKI_D3D_CHECK(factory2->CreateSwapChainForHwnd(&getGrManagerImpl().getCommandQueue(GpuQueueType::kGeneral), hwnd, &swapChainDesc, nullptr,
+													nullptr, &swapChain));
+
+	swapChain->QueryInterface(IID_PPV_ARGS(&m_swapchain));
+
+	// Does not support fullscreen transitions.
+	factory2->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
+
+	m_backbufferIdx = m_swapchain->GetCurrentBackBufferIndex();
+
+	// Store swapchain RTVs
+	for(U32 i = 0; i < kMaxFramesInFlight; ++i)
+	{
+		ANKI_D3D_CHECK(m_swapchain->GetBuffer(i, IID_PPV_ARGS(&m_rtvResources[i])));
+
+		TextureInitInfo init("SwapchainImg");
+		init.m_width = window.getWidth();
+		init.m_height = window.getHeight();
+		init.m_format = Format::kR8G8B8A8_Unorm;
+		init.m_usage = TextureUsageBit::kFramebufferRead | TextureUsageBit::kFramebufferWrite | TextureUsageBit::kPresent;
+		init.m_type = TextureType::k2D;
+
+		TextureImpl* tex = newInstance<TextureImpl>(GrMemoryPool::getSingleton(), init.getName());
+		m_textures[i].reset(tex);
+
+		ANKI_CHECK(tex->initExternal(m_rtvResources[i], init));
+	}
+
+	return Error::kNone;
+}
+
+MicroSwapchainPtr SwapchainFactory::newInstance()
+{
+	// Delete stale swapchains (they are stale because they are probably out of data) and always create a new one
+	m_recycler.trimCache();
+
+	// This is useless but call it to avoid assertions
+	[[maybe_unused]] MicroSwapchain* dummy = m_recycler.findToReuse();
+	ANKI_ASSERT(dummy == nullptr);
+
+	return MicroSwapchainPtr(anki::newInstance<MicroSwapchain>(GrMemoryPool::getSingleton()));
+}
+
+} // end namespace anki

+ 112 - 0
AnKi/Gr/D3D/D3DSwapchainFactory.h

@@ -0,0 +1,112 @@
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#pragma once
+
+#include <AnKi/Gr/D3D/D3DFence.h>
+#include <AnKi/Gr/D3D/D3DTexture.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.h>
+
+namespace anki {
+
+/// @addtogroup directx
+/// @{
+
+/// A wrapper for the swapchain.
+class MicroSwapchain
+{
+	friend class MicroSwapchainPtrDeleter;
+	friend class SwapchainFactory;
+
+public:
+	IDXGISwapChain3* m_swapchain = nullptr;
+
+	Array<ID3D12Resource*, kMaxFramesInFlight> m_rtvResources = {};
+
+	Array<TexturePtr, kMaxFramesInFlight> m_textures;
+
+	U32 m_backbufferIdx = 0;
+
+	MicroSwapchain();
+
+	~MicroSwapchain();
+
+	void retain() const
+	{
+		m_refcount.fetchAdd(1);
+	}
+
+	I32 release() const
+	{
+		return m_refcount.fetchSub(1);
+	}
+
+	I32 getRefcount() const
+	{
+		return m_refcount.load();
+	}
+
+	void setFence(MicroFence* fence)
+	{
+		m_fence.reset(fence);
+	}
+
+	MicroFence* getFence() const
+	{
+		return m_fence.tryGet();
+	}
+
+	/// Interface method.
+	void onFenceDone()
+	{
+		// Do nothing
+	}
+
+private:
+	MicroFencePtr m_fence;
+	mutable Atomic<I32> m_refcount = {0};
+
+	Error initInternal();
+};
+
+/// Deleter for MicroSwapchainPtr smart pointer.
+class MicroSwapchainPtrDeleter
+{
+public:
+	void operator()(MicroSwapchain* x);
+};
+
+/// MicroSwapchain smart pointer.
+using MicroSwapchainPtr = IntrusivePtr<MicroSwapchain, MicroSwapchainPtrDeleter>;
+
+/// Swapchain factory.
+class SwapchainFactory : public MakeSingleton<SwapchainFactory>
+{
+	friend class MicroSwapchainPtrDeleter;
+	friend class MicroSwapchain;
+
+public:
+	SwapchainFactory() = default;
+
+	~SwapchainFactory()
+	{
+		m_recycler.destroy();
+	}
+
+	MicroSwapchainPtr newInstance();
+
+private:
+	MicroObjectRecycler<MicroSwapchain> m_recycler;
+};
+/// @}
+
+inline void MicroSwapchainPtrDeleter::operator()(MicroSwapchain* s)
+{
+	ANKI_ASSERT(s);
+	SwapchainFactory::getSingleton().m_recycler.recycle(s);
+}
+/// @}
+
+} // end namespace anki

+ 81 - 1
AnKi/Gr/D3D/D3DTexture.cpp

@@ -22,10 +22,90 @@ Texture* Texture::newInstance(const TextureInitInfo& init)
 
 
 TextureImpl::~TextureImpl()
 TextureImpl::~TextureImpl()
 {
 {
+	for(DescriptorHeapHandle& handle : m_rtvHandles)
+	{
+		RtvDescriptorHeap::getSingleton().free(handle);
+	}
+
+	const Bool external = !!(m_usage & TextureUsageBit::kPresent);
+	if(!external)
+	{
+		safeRelease(m_resource);
+	}
 }
 }
 
 
-Error TextureImpl::initInternal(ID3D12Resource* image, const TextureInitInfo& init)
+Error TextureImpl::initInternal(ID3D12Resource* external, const TextureInitInfo& init)
 {
 {
+	m_width = init.m_width;
+	m_height = init.m_height;
+	m_depth = init.m_depth;
+	m_layerCount = init.m_layerCount;
+	m_texType = init.m_type;
+	m_usage = init.m_usage;
+	m_format = init.m_format;
+	m_aspect = getFormatInfo(init.m_format).isDepth() ? DepthStencilAspectBit::kDepth : DepthStencilAspectBit::kNone;
+	m_aspect |= getFormatInfo(init.m_format).isStencil() ? DepthStencilAspectBit::kStencil : DepthStencilAspectBit::kNone;
+
+	if(m_texType == TextureType::k3D)
+	{
+		m_mipCount = min<U32>(init.m_mipmapCount, computeMaxMipmapCount3d(m_width, m_height, m_depth));
+	}
+	else
+	{
+		m_mipCount = min<U32>(init.m_mipmapCount, computeMaxMipmapCount2d(m_width, m_height));
+	}
+
+	if(external)
+	{
+		ANKI_ASSERT(!!(m_usage & TextureUsageBit::kPresent));
+		m_resource = external;
+	}
+	else
+	{
+		ANKI_ASSERT(!"TODO");
+	}
+
+	const U32 faceCount = (m_texType == TextureType::kCube || m_texType == TextureType::kCubeArray) ? 6 : 1;
+	U32 surfaceCount = 0;
+	if(m_texType != TextureType::k3D)
+	{
+		surfaceCount = m_layerCount * m_mipCount * faceCount;
+	}
+
+	// Create RTVs
+	if(!!(m_usage & TextureUsageBit::kAllFramebuffer))
+	{
+		ANKI_ASSERT(m_texType != TextureType::k3D && m_texType != TextureType::k1D);
+		m_rtvHandles.resize(surfaceCount);
+		for(U32 layer = 0; layer < m_layerCount; ++layer)
+		{
+			for(U32 face = 0; face < faceCount; ++face)
+			{
+				for(U32 mip = 0; mip < m_mipCount; ++mip)
+				{
+					D3D12_RENDER_TARGET_VIEW_DESC desc = {};
+
+					if(m_texType == TextureType::k2D)
+					{
+						desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
+						desc.Texture2D.MipSlice = mip;
+						desc.Texture2D.PlaneSlice = 0;
+					}
+					else
+					{
+						desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
+						desc.Texture2DArray.ArraySize = 1;
+						desc.Texture2DArray.FirstArraySlice = layer * m_layerCount + face;
+					}
+
+					DescriptorHeapHandle& handle = m_rtvHandles[layer * faceCount * m_mipCount + face * m_mipCount + mip];
+					handle = RtvDescriptorHeap::getSingleton().allocate();
+					getDevice().CreateRenderTargetView(m_resource, (external) ? nullptr : &desc, handle.m_cpuHandle);
+				}
+			}
+		}
+	}
+
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 

+ 8 - 3
AnKi/Gr/D3D/D3DTexture.h

@@ -16,6 +16,8 @@ namespace anki {
 /// Texture container.
 /// Texture container.
 class TextureImpl final : public Texture
 class TextureImpl final : public Texture
 {
 {
+	friend class Texture;
+
 public:
 public:
 	TextureImpl(CString name)
 	TextureImpl(CString name)
 		: Texture(name)
 		: Texture(name)
@@ -29,13 +31,16 @@ public:
 		return initInternal(nullptr, inf);
 		return initInternal(nullptr, inf);
 	}
 	}
 
 
-	Error initExternal(ID3D12Resource* image, const TextureInitInfo& init)
+	Error initExternal(ID3D12Resource* external, const TextureInitInfo& init)
 	{
 	{
-		return initInternal(image, init);
+		return initInternal(external, init);
 	}
 	}
 
 
 private:
 private:
-	Error initInternal(ID3D12Resource* image, const TextureInitInfo& init);
+	ID3D12Resource* m_resource = nullptr;
+	GrDynamicArray<DescriptorHeapHandle> m_rtvHandles;
+
+	Error initInternal(ID3D12Resource* external, const TextureInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkCommandBuffer.h

@@ -14,7 +14,7 @@
 #include <AnKi/Gr/Vulkan/VkPipelineQuery.h>
 #include <AnKi/Gr/Vulkan/VkPipelineQuery.h>
 #include <AnKi/Gr/Vulkan/VkBuffer.h>
 #include <AnKi/Gr/Vulkan/VkBuffer.h>
 #include <AnKi/Gr/Vulkan/VkTexture.h>
 #include <AnKi/Gr/Vulkan/VkTexture.h>
-#include <AnKi/Gr/Vulkan/VkPipeline.h>
+#include <AnKi/Gr/Vulkan/VkPipelineFactory.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/List.h>
 
 

+ 2 - 2
AnKi/Gr/Vulkan/VkCommandBufferFactory.h

@@ -7,8 +7,8 @@
 
 
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
 #include <AnKi/Gr/CommandBuffer.h>
 #include <AnKi/Gr/CommandBuffer.h>
-#include <AnKi/Gr/Vulkan/VkMicroObjectRecycler.h>
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/List.h>
 
 
 namespace anki {
 namespace anki {

+ 1 - 1
AnKi/Gr/Vulkan/VkCommon.h

@@ -6,7 +6,7 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Gr/Common.h>
 #include <AnKi/Gr/Common.h>
-#include <AnKi/Gr/Common/BackendCommon.h>
+#include <AnKi/Gr/BackendCommon/Common.h>
 
 
 #if ANKI_WINDOWING_SYSTEM_HEADLESS
 #if ANKI_WINDOWING_SYSTEM_HEADLESS
 // Do nothing
 // Do nothing

+ 1 - 1
AnKi/Gr/Vulkan/VkDescriptorSet.cpp → AnKi/Gr/Vulkan/VkDescriptorSetFactory.cpp

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Core/StatsSet.h>
 #include <AnKi/Core/StatsSet.h>

+ 0 - 0
AnKi/Gr/Vulkan/VkDescriptorSet.h → AnKi/Gr/Vulkan/VkDescriptorSetFactory.h


+ 1 - 1
AnKi/Gr/Vulkan/VkFrameGarbageCollector.cpp

@@ -5,7 +5,7 @@
 
 
 #include <AnKi/Gr/Vulkan/VkFrameGarbageCollector.h>
 #include <AnKi/Gr/Vulkan/VkFrameGarbageCollector.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Gr/Fence.h>
 #include <AnKi/Gr/Fence.h>
 
 
 namespace anki {
 namespace anki {

+ 2 - 2
AnKi/Gr/Vulkan/VkPipeline.cpp → AnKi/Gr/Vulkan/VkPipelineFactory.cpp

@@ -3,9 +3,9 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Gr/Vulkan/VkPipeline.h>
+#include <AnKi/Gr/Vulkan/VkPipelineFactory.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
-#include <AnKi/Gr/Common/Functions.h>
+#include <AnKi/Gr/BackendCommon/Functions.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Util/Filesystem.h>
 #include <AnKi/Util/Filesystem.h>
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkPipeline.h → AnKi/Gr/Vulkan/VkPipelineFactory.h

@@ -5,7 +5,7 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Gr/ShaderProgram.h>
 #include <AnKi/Gr/ShaderProgram.h>
 #include <AnKi/Gr/Vulkan/VkShaderProgram.h>
 #include <AnKi/Gr/Vulkan/VkShaderProgram.h>
 #include <AnKi/Util/HashMap.h>
 #include <AnKi/Util/HashMap.h>

+ 1 - 1
AnKi/Gr/Vulkan/VkPipelineLayout.cpp → AnKi/Gr/Vulkan/VkPipelineLayoutFactory.cpp

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#include <AnKi/Gr/Vulkan/VkPipelineLayout.h>
+#include <AnKi/Gr/Vulkan/VkPipelineLayoutFactory.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkPipelineLayout.h → AnKi/Gr/Vulkan/VkPipelineLayoutFactory.h

@@ -5,7 +5,7 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Util/HashMap.h>
 #include <AnKi/Util/HashMap.h>
 
 
 namespace anki {
 namespace anki {

+ 1 - 1
AnKi/Gr/Vulkan/VkSemaphoreFactory.h

@@ -6,7 +6,7 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
-#include <AnKi/Gr/Vulkan/VkMicroObjectRecycler.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkShader.h

@@ -6,7 +6,7 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Gr/Shader.h>
 #include <AnKi/Gr/Shader.h>
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 #include <AnKi/Util/BitSet.h>
 #include <AnKi/Util/BitSet.h>
 
 
 namespace anki {
 namespace anki {

+ 2 - 2
AnKi/Gr/Vulkan/VkShaderProgram.cpp

@@ -6,8 +6,8 @@
 #include <AnKi/Gr/Vulkan/VkShaderProgram.h>
 #include <AnKi/Gr/Vulkan/VkShaderProgram.h>
 #include <AnKi/Gr/Vulkan/VkShader.h>
 #include <AnKi/Gr/Vulkan/VkShader.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
-#include <AnKi/Gr/Vulkan/VkPipeline.h>
-#include <AnKi/Gr/Common/Functions.h>
+#include <AnKi/Gr/Vulkan/VkPipelineFactory.h>
+#include <AnKi/Gr/BackendCommon/Functions.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 2 - 2
AnKi/Gr/Vulkan/VkShaderProgram.h

@@ -6,8 +6,8 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Gr/ShaderProgram.h>
 #include <AnKi/Gr/ShaderProgram.h>
-#include <AnKi/Gr/Vulkan/VkPipelineLayout.h>
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkPipelineLayoutFactory.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkSwapchainFactory.cpp

@@ -82,7 +82,7 @@ Error MicroSwapchain::initInternal()
 	case id: \
 	case id: \
 		akFormat = Format::k##type; \
 		akFormat = Format::k##type; \
 		break;
 		break;
-#include <AnKi/Gr/Common/Format.def.h>
+#include <AnKi/Gr/BackendCommon/Format.def.h>
 #undef ANKI_FORMAT_DEF
 #undef ANKI_FORMAT_DEF
 			default:
 			default:
 				akFormat = Format::kNone;
 				akFormat = Format::kNone;

+ 1 - 4
AnKi/Gr/Vulkan/VkSwapchainFactory.h

@@ -6,14 +6,11 @@
 #pragma once
 #pragma once
 
 
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
 #include <AnKi/Gr/Vulkan/VkFenceFactory.h>
-#include <AnKi/Gr/Vulkan/VkMicroObjectRecycler.h>
+#include <AnKi/Gr/BackendCommon/MicroObjectRecycler.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/Ptr.h>
 
 
 namespace anki {
 namespace anki {
 
 
-// Forward
-class SwapchainFactory;
-
 /// @addtogroup vulkan
 /// @addtogroup vulkan
 /// @{
 /// @{
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkTexture.cpp

@@ -5,7 +5,7 @@
 
 
 #include <AnKi/Gr/Vulkan/VkTexture.h>
 #include <AnKi/Gr/Vulkan/VkTexture.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
 #include <AnKi/Gr/Vulkan/VkGrManager.h>
-#include <AnKi/Gr/Vulkan/VkDescriptorSet.h>
+#include <AnKi/Gr/Vulkan/VkDescriptorSetFactory.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Vulkan/VkTexture.h

@@ -7,7 +7,7 @@
 
 
 #include <AnKi/Gr/Texture.h>
 #include <AnKi/Gr/Texture.h>
 #include <AnKi/Gr/Vulkan/VkGpuMemoryManager.h>
 #include <AnKi/Gr/Vulkan/VkGpuMemoryManager.h>
-#include <AnKi/Gr/Common/Functions.h>
+#include <AnKi/Gr/BackendCommon/Functions.h>
 #include <AnKi/Util/HashMap.h>
 #include <AnKi/Util/HashMap.h>
 
 
 namespace anki {
 namespace anki {

+ 1 - 1
AnKi/Resource/ShaderProgramResource.h

@@ -7,7 +7,7 @@
 
 
 #include <AnKi/Resource/ResourceObject.h>
 #include <AnKi/Resource/ResourceObject.h>
 #include <AnKi/ShaderCompiler/ShaderProgramCompiler.h>
 #include <AnKi/ShaderCompiler/ShaderProgramCompiler.h>
-#include <AnKi/Gr/Common/Functions.h>
+#include <AnKi/Gr/BackendCommon/Functions.h>
 #include <AnKi/Gr/ShaderProgram.h>
 #include <AnKi/Gr/ShaderProgram.h>
 #include <AnKi/Util/BitSet.h>
 #include <AnKi/Util/BitSet.h>
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/String.h>