Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Context.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "utils/webgpu.hpp"
6
7namespace Graphic::Resource {
8class Context {
9 public:
10 Context() = default;
11 ~Context() = default;
12
13 void RequestDevice(void) { deviceContext.GetDevice() = adapter->requestDevice(deviceContext.GetDescriptor()); }
14
15 void Release()
16 {
17 if (instance.has_value())
18 {
19 instance->release();
20 instance.reset();
21 }
22 if (adapter.has_value())
23 {
24 adapter->release();
25 adapter.reset();
26 }
27 if (queue.has_value())
28 {
29 queue->release();
30 queue.reset();
31 }
32 deviceContext.Release();
33 if (surface.has_value())
34 {
35 surface->Release();
36 surface.reset();
37 }
38 }
39
40 std::optional<wgpu::Instance> instance;
41 std::optional<Surface> surface;
42 std::optional<wgpu::Adapter> adapter;
44 std::optional<wgpu::Queue> queue;
45};
46} // namespace Graphic::Resource
std::optional< wgpu::Instance > instance
Definition Context.hpp:40
void Release()
Definition Context.hpp:15
DeviceContext deviceContext
Definition Context.hpp:43
void RequestDevice(void)
Definition Context.hpp:13
std::optional< Surface > surface
Definition Context.hpp:41
std::optional< wgpu::Queue > queue
Definition Context.hpp:44
std::optional< wgpu::Adapter > adapter
Definition Context.hpp:42
Definition AGPUBuffer.hpp:6
Definition DeviceContext.hpp:7