candlewick 0.7.0-59-g23c6
A tiny cross-platform renderer based on SDL3
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 auto *p = _device;
39 _device = nullptr;
40 return p;
41 }
42 void destroy() noexcept;
43
44 bool operator==(const Device &other) const {
45 return _device && (_device == other._device);
46 }
47
48private:
49 SDL_GPUDevice *_device;
50};
51
52inline Device::Device(NoInitT) noexcept : _device(nullptr) {}
53
54inline Device::Device(Device &&other) noexcept {
55 _device = other._device;
56 other._device = nullptr;
57}
58
59} // 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:52
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