candlewick 0.1.0
A renderer
Loading...
Searching...
No Matches
Device.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core.h"
4#include "Tags.h"
5#include <SDL3/SDL_gpu.h>
6
7namespace candlewick {
8
13SDL_GPUShaderFormat
14auto_detect_shader_format_subset(const char *name = nullptr);
15
17struct Device {
18
19 explicit Device(NoInitT) noexcept;
20 explicit Device(SDL_GPUShaderFormat format_flags, bool debug_mode = false);
21 Device(const Device &) = delete;
22 Device(Device &&other) noexcept;
23 Device &operator=(Device &&) = delete;
24
25 void create(SDL_GPUShaderFormat format_flags, bool debug_mode = false);
26
27 operator SDL_GPUDevice *() const { return _device; }
28 operator bool() const { return _device; }
29
30 const char *driverName() const noexcept;
31
32 SDL_GPUShaderFormat shaderFormats() const {
33 return SDL_GetGPUShaderFormats(_device);
34 }
35
37 SDL_GPUDevice *release() noexcept {
38 return _device;
39 _device = nullptr;
40 }
41 void destroy() noexcept;
42
43 bool operator==(const Device &other) const {
44 return _device && (_device == other._device);
45 }
46
47private:
48 SDL_GPUDevice *_device;
49};
50
51inline Device::Device(NoInitT) noexcept : _device(nullptr) {}
52
53inline Device::Device(Device &&other) noexcept {
54 _device = other._device;
55 other._device = nullptr;
56}
57
58} // namespace candlewick
Definition Camera.h:8
SDL_GPUShaderFormat auto_detect_shader_format_subset(const char *name=nullptr)
Automatically detect which subset of shader formats (MSL, SPIR-V) are compatible with the device.
const char * driverName() const noexcept
SDL_GPUShaderFormat shaderFormats() const
Definition Device.h:32
Device(const Device &)=delete
Device(NoInitT) noexcept
Definition Device.h:51
SDL_GPUDevice * release() noexcept
Release ownership of and return the SDL_GPUDevice handle.
Definition Device.h:37
void create(SDL_GPUShaderFormat format_flags, bool debug_mode=false)
Device(SDL_GPUShaderFormat format_flags, bool debug_mode=false)
void destroy() noexcept
Device & operator=(Device &&)=delete
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6