Skip to content

Commit f00e6b4

Browse files
committed
Move some initialisation from Instance.Init() to GraphicsCore Init()
1 parent 1ae23fa commit f00e6b4

2 files changed

Lines changed: 51 additions & 42 deletions

File tree

src/engine/renderer-vulkan/GraphicsCore/Init.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,65 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737

3838
#include "../Shared/Timer.h"
3939

40+
#include "../Error.h"
41+
4042
#include "../Thread/TaskList.h"
4143
#include "../Sync/Fence.h"
4244

4345
#include "GraphicsCoreStore.h"
4446
#include "Instance.h"
4547

48+
#include "PhysicalDevice.h"
49+
50+
#include "EngineConfig.h"
51+
52+
#include "Memory/DescriptorSet.h"
53+
#include "Memory/EngineAllocator.h"
54+
#include "ResourceSystem.h"
55+
4656
#include "Init.h"
4757

58+
#include "SwapChain.h"
59+
#include "Vulkan.h"
60+
4861
#include "Memory/CoreThreadMemory.h"
4962
void InitGraphicsEngine() {
5063
instance.Init( "Daemon-vulkan", CLIENT_WINDOW_TITLE );
64+
65+
std::string foundQueues = "Found queues: graphics (present: true)";
66+
graphicsQueue.Init( device, queuesConfig.graphicsQueue.id, queuesConfig.graphicsQueue.queueCount );
67+
68+
uint32 presentSupported;
69+
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevice, queuesConfig.graphicsQueue.id, mainSwapChain.surface, &presentSupported );
70+
71+
if ( !presentSupported ) {
72+
Err( "Graphics queue doesn't support present" );
73+
return;
74+
}
75+
76+
uint32 presentSupported;
77+
if ( queuesConfig.computeQueue.unique ) {
78+
computeQueue.Init( device, queuesConfig.computeQueue.id, queuesConfig.computeQueue.queueCount );
79+
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevice, queuesConfig.computeQueue.id, mainSwapChain.surface, &presentSupported );
80+
foundQueues += Str::Format( ", async compute (present: %s)", ( bool ) presentSupported );
81+
}
82+
83+
if ( queuesConfig.transferQueue.unique ) {
84+
transferQueue.Init( device, queuesConfig.transferQueue.id, queuesConfig.transferQueue.queueCount );
85+
foundQueues += Str::Format( ", async transfer" );
86+
}
87+
88+
if ( queuesConfig.sparseQueue.unique ) {
89+
sparseQueue.Init( device, queuesConfig.sparseQueue.id, queuesConfig.sparseQueue.queueCount );
90+
foundQueues += Str::Format( ", async sparse binding" );
91+
}
92+
93+
Log::Notice( foundQueues );
94+
95+
AllocDescriptors( engineConfig.maxImages, engineConfig.maxStorageImages );
96+
97+
engineAllocator.Init();
98+
5199
InitCmdPools();
52100

53101
FenceMain initExecCmdFence;

src/engine/renderer-vulkan/GraphicsCore/Instance.cpp

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040

4141
#include "../Error.h"
4242

43-
#include "Vulkan.h"
4443
#include "../VulkanLoader/VulkanLoadFunctions.h"
4544

46-
#include "SwapChain.h"
45+
#include "Vulkan.h"
4746

4847
#include "CapabilityPack.h"
49-
#include "EngineConfig.h"
50-
#include "QueuesConfig.h"
5148
#include "PhysicalDevice.h"
52-
#include "Queue.h"
49+
#include "SwapChain.h"
50+
#include "QueuesConfig.h"
5351

5452
#include "GraphicsCoreStore.h"
5553

56-
#include "Memory/DescriptorSet.h"
57-
#include "Memory/EngineAllocator.h"
58-
5954
#include "Instance.h"
6055

61-
6256
void Instance::Init( const char* engineName, const char* appName ) {
6357
VkApplicationInfo appInfo {
6458
.pApplicationName = appName,
@@ -123,37 +117,4 @@ void Instance::Init( const char* engineName, const char* appName ) {
123117
VulkanLoadDeviceFunctions( device );
124118

125119
mainSwapChain.Init( instance );
126-
127-
std::string foundQueues = "Found queues: graphics (present: true)";
128-
graphicsQueue.Init( device, queuesConfig.graphicsQueue.id, queuesConfig.graphicsQueue.queueCount );
129-
130-
uint32 presentSupported;
131-
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevice, queuesConfig.graphicsQueue.id, mainSwapChain.surface, &presentSupported );
132-
133-
if ( !presentSupported ) {
134-
Err( "Graphics queue doesn't support present" );
135-
return;
136-
}
137-
138-
if( queuesConfig.computeQueue.unique ) {
139-
computeQueue.Init( device, queuesConfig.computeQueue.id, queuesConfig.computeQueue.queueCount );
140-
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevice, queuesConfig.computeQueue.id, mainSwapChain.surface, &presentSupported );
141-
foundQueues += Str::Format( ", async compute (present: %s)", ( bool ) presentSupported );
142-
}
143-
144-
if ( queuesConfig.transferQueue.unique ) {
145-
transferQueue.Init( device, queuesConfig.transferQueue.id, queuesConfig.transferQueue.queueCount );
146-
foundQueues += Str::Format( ", async transfer" );
147-
}
148-
149-
if ( queuesConfig.sparseQueue.unique ) {
150-
sparseQueue.Init( device, queuesConfig.sparseQueue.id, queuesConfig.sparseQueue.queueCount );
151-
foundQueues += Str::Format( ", async sparse binding" );
152-
}
153-
154-
Log::Notice( foundQueues );
155-
156-
AllocDescriptors( engineConfig.maxImages, engineConfig.maxStorageImages );
157-
158-
engineAllocator.Init();
159120
}

0 commit comments

Comments
 (0)