-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebgpu_command_buffer.hpp
More file actions
67 lines (58 loc) · 1.8 KB
/
webgpu_command_buffer.hpp
File metadata and controls
67 lines (58 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <common/command_buffers/gpu/gpu_command_buffer.hpp>
namespace client_graphics
{
/**
* The `WebGPUCommandBuffer` class represents a recorded sequence of GPU commands.
* This is the client-side implementation that holds recorded commands for later submission.
*/
class WebGPUCommandBuffer
{
public:
WebGPUCommandBuffer(std::optional<std::string> label = std::nullopt);
~WebGPUCommandBuffer() = default;
// Non-copyable but movable
WebGPUCommandBuffer(const WebGPUCommandBuffer &) = delete;
WebGPUCommandBuffer &operator=(const WebGPUCommandBuffer &) = delete;
WebGPUCommandBuffer(WebGPUCommandBuffer &&) = default;
WebGPUCommandBuffer &operator=(WebGPUCommandBuffer &&) = default;
public:
const std::string &label() const
{
return label_;
}
bool isEmpty() const
{
return commands_.empty();
}
size_t commandCount() const
{
return commands_.size();
}
/**
* Execute the recorded commands. In the client-side implementation,
* this would typically transmit the commands to the server.
* For now, this is a placeholder for the command recording pattern.
*/
void execute() const;
private:
friend class WebGPUCommandEncoder;
friend class WebGPURenderPassEncoder;
std::string label_;
std::vector<std::shared_ptr<commandbuffers::GPUCommand>> commands_;
/**
* Add a command to the command buffer.
* This follows the same pattern as the existing GPU command buffer implementation.
*/
template <typename T, typename... Args>
void addCommand(Args &&...args)
{
auto command = std::make_shared<T>(std::forward<Args>(args)...);
commands_.push_back(command);
}
};
}