4#include "Direct3D12/GraphicsDeviceD3D12.h"
8#include "Direct3D11/GraphicsDeviceD3D11.h"
12#include "OpenGL20/GraphicsDeviceGL20.h"
16#include "OpenGLES30/GraphicsDeviceGLES30.h"
20#include "Vulkan/GraphicsDeviceVK.h"
24#include "WebGPU/GraphicsDeviceWebGPU.h"
28#include "Null/GraphicsDeviceNull.h"
31#include "Foundation/Collections/SmallVector.h"
69 if (name ==
"Direct3D12" || name ==
"DirectX12") {
71 }
if (name ==
"Direct3D11" || name ==
"DirectX11") {
73 }
else if (name ==
"OpenGL20" || name ==
"OpenGL") {
75 }
else if (name ==
"OpenGLES30") {
77 }
else if (name ==
"Vulkan") {
79 }
else if (name ==
"Dawn" || name ==
"WebGPU") {
81 }
else if (name ==
"Null") {
92 template<
typename DeviceType>
95 auto device = Memory::create<DeviceType>(allocatorInfo->
baseAllocator, allocatorInfo);
97 devices.push_back({ device, *allocatorInfo });
110 auto allocatorInfo = externalAllocatorInfo ? externalAllocatorInfo : &defaultAllocatorInfo;
115 return createDevice(allocatorInfo);
116#ifdef COGS_DIRECT3D12
118 return create<GraphicsDeviceD3D12>(allocatorInfo);
120#ifdef COGS_DIRECT3D11
122 return create<GraphicsDeviceD3D11>(allocatorInfo);
126 return create<GraphicsDeviceGL20>(allocatorInfo);
128#ifdef COGS_OPENGLES30
130 return create<GraphicsDeviceGLES30>(allocatorInfo);
134 return create<GraphicsDeviceVK>(allocatorInfo);
138 return create<GraphicsDeviceWebGPU>(allocatorInfo);
142 return create<GraphicsDeviceNull>(allocatorInfo);
150 for (
size_t i = 0; i < devices.size(); ++i) {
151 if (devices[i].device == device) {
157 size_t deviceSize = 0;
160#ifdef COGS_DIRECT3D12
165#ifdef COGS_DIRECT3D11
175#ifdef COGS_OPENGLES30
201 devices[index].allocatorInfo.baseAllocator->deallocate(device, deviceSize);
202 devices.erase(devices.begin() + index);
Represents a graphics device used to manage graphics resources and issue drawing commands.
virtual ~IGraphicsDevice()=default
Destructor.
virtual GraphicsDeviceType getType() const
Get the type of the graphics device.
static Allocator * defaultAllocator()
Gets the system default allocator.
Provides a weakly referenced view over the contents of a string.
Contains all Cogs related functionality.
GraphicsDeviceType
Contains types of graphics devices that may be supported.
@ Direct3D12
Graphics device using the Direct3D 12 API.
@ OpenGLES30
Graphics device using the OpenGLES 3.0 API.
@ Vulkan
Graphics device using the Vulkan API.
@ Direct3D11
Graphics device using the Direct3D 11 API.
@ Unknown
Unknown type of graphics device.
@ OpenGL20
Graphics device using OpenGL, supporting at least OpenGL 2.0.
@ Null
Null device that implements no rendering functionality.
@ WebGPU
Graphics device using the WebGPU API Backend.
static void releaseDevice(class IGraphicsDevice *device)
Release the given graphics device, freeing all associated resources.
static class IGraphicsDevice * createDevice(RenderingAllocatorInfo *allocatorInfo=nullptr)
Creates a graphics device.
Memory::Allocator * baseAllocator
Base allocator. Used for misc. internal memory allocations.