| 99 | } |
| 100 | |
| 101 | bool GraphicsService::Init() |
| 102 | { |
| 103 | ASSERT(GPUDevice::Instance == nullptr); |
| 104 | PROFILE_MEM(Graphics); |
| 105 | |
| 106 | // Create and initialize graphics device |
| 107 | LOG_FLOOR(); |
| 108 | LOG(Info, "Creating Graphics Device..."); |
| 109 | PixelFormatExtensions::Init(); |
| 110 | GPUDevice* device = nullptr; |
| 111 | |
| 112 | // Null |
| 113 | if (!device && CommandLine::Options.Null.IsTrue()) |
| 114 | { |
| 115 | #if GRAPHICS_API_NULL |
| 116 | device = CreateGPUDeviceNull(); |
| 117 | #else |
| 118 | LOG(Warning, "Null backend not available"); |
| 119 | #endif |
| 120 | } |
| 121 | |
| 122 | // Vulkan |
| 123 | if (!device && CommandLine::Options.Vulkan.IsTrue()) |
| 124 | { |
| 125 | #if GRAPHICS_API_VULKAN |
| 126 | device = CreateGPUDeviceVulkan(); |
| 127 | #else |
| 128 | LOG(Warning, "Vulkan backend not available"); |
| 129 | #endif |
| 130 | } |
| 131 | |
| 132 | // DirectX 12 |
| 133 | if (!device && CommandLine::Options.D3D12.IsTrue()) |
| 134 | { |
| 135 | #if GRAPHICS_API_DIRECTX12 |
| 136 | if (Platform::IsWindows10()) |
| 137 | { |
| 138 | device = CreateGPUDeviceDX12(); |
| 139 | } |
| 140 | #else |
| 141 | LOG(Warning, "DirectX 12 backend not available"); |
| 142 | #endif |
| 143 | } |
| 144 | |
| 145 | // DirectX 11 and DirectX 10 |
| 146 | if (!device && (CommandLine::Options.D3D11.IsTrue() || CommandLine::Options.D3D10.IsTrue())) |
| 147 | { |
| 148 | #if GRAPHICS_API_DIRECTX11 |
| 149 | device = CreateGPUDeviceDX11(); |
| 150 | #else |
| 151 | LOG(Warning, "DirectX 11 backend not available"); |
| 152 | #endif |
| 153 | } |
| 154 | |
| 155 | // Platform default |
| 156 | if (!device) |
| 157 | { |
| 158 | #if GRAPHICS_API_DIRECTX11 |
no test coverage detected