-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathGPUCommandEncoder.h
More file actions
110 lines (93 loc) · 4.42 KB
/
GPUCommandEncoder.h
File metadata and controls
110 lines (93 loc) · 4.42 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include <memory>
#include <string>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "webgpu/webgpu_cpp.h"
#include "GPUBuffer.h"
#include "GPUCommandBuffer.h"
#include "GPUCommandBufferDescriptor.h"
#include "GPUComputePassDescriptor.h"
#include "GPUComputePassEncoder.h"
#include "GPUExtent3D.h"
#include "GPUImageCopyBuffer.h"
#include "GPUImageCopyTexture.h"
#include "GPUQuerySet.h"
#include "GPURenderPassDescriptor.h"
#include "GPURenderPassEncoder.h"
namespace rnwgpu {
namespace m = margelo;
class GPUCommandEncoder : public m::HybridObject {
public:
explicit GPUCommandEncoder(wgpu::CommandEncoder instance, std::string label)
: HybridObject("GPUCommandEncoder"), _instance(instance), _label(label) {}
public:
std::string getBrand() { return _name; }
std::shared_ptr<GPURenderPassEncoder>
beginRenderPass(std::shared_ptr<GPURenderPassDescriptor> descriptor);
std::shared_ptr<GPUComputePassEncoder> beginComputePass(
std::optional<std::shared_ptr<GPUComputePassDescriptor>> descriptor);
void copyBufferToBuffer(std::shared_ptr<GPUBuffer> source,
uint64_t sourceOffset,
std::shared_ptr<GPUBuffer> destination,
uint64_t destinationOffset, uint64_t size);
void copyBufferToTexture(std::shared_ptr<GPUImageCopyBuffer> source,
std::shared_ptr<GPUImageCopyTexture> destination,
std::shared_ptr<GPUExtent3D> copySize);
void copyTextureToBuffer(std::shared_ptr<GPUImageCopyTexture> source,
std::shared_ptr<GPUImageCopyBuffer> destination,
std::shared_ptr<GPUExtent3D> copySize);
void copyTextureToTexture(std::shared_ptr<GPUImageCopyTexture> source,
std::shared_ptr<GPUImageCopyTexture> destination,
std::shared_ptr<GPUExtent3D> copySize);
void clearBuffer(std::shared_ptr<GPUBuffer> buffer,
std::optional<uint64_t> offset,
std::optional<uint64_t> size);
void resolveQuerySet(std::shared_ptr<GPUQuerySet> querySet,
uint32_t firstQuery, uint32_t queryCount,
std::shared_ptr<GPUBuffer> destination,
uint64_t destinationOffset);
std::shared_ptr<GPUCommandBuffer>
finish(std::optional<std::shared_ptr<GPUCommandBufferDescriptor>> descriptor);
void pushDebugGroup(std::string groupLabel);
void popDebugGroup();
void insertDebugMarker(std::string markerLabel);
std::string getLabel() { return _label; }
void setLabel(const std::string &label) {
_label = label;
_instance.SetLabel(_label.c_str());
}
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPUCommandEncoder::getBrand, this);
registerHybridMethod("beginRenderPass", &GPUCommandEncoder::beginRenderPass,
this);
registerHybridMethod("beginComputePass",
&GPUCommandEncoder::beginComputePass, this);
registerHybridMethod("copyBufferToBuffer",
&GPUCommandEncoder::copyBufferToBuffer, this);
registerHybridMethod("copyBufferToTexture",
&GPUCommandEncoder::copyBufferToTexture, this);
registerHybridMethod("copyTextureToBuffer",
&GPUCommandEncoder::copyTextureToBuffer, this);
registerHybridMethod("copyTextureToTexture",
&GPUCommandEncoder::copyTextureToTexture, this);
registerHybridMethod("clearBuffer", &GPUCommandEncoder::clearBuffer, this);
registerHybridMethod("resolveQuerySet", &GPUCommandEncoder::resolveQuerySet,
this);
registerHybridMethod("finish", &GPUCommandEncoder::finish, this);
registerHybridMethod("pushDebugGroup", &GPUCommandEncoder::pushDebugGroup,
this);
registerHybridMethod("popDebugGroup", &GPUCommandEncoder::popDebugGroup,
this);
registerHybridMethod("insertDebugMarker",
&GPUCommandEncoder::insertDebugMarker, this);
registerHybridGetter("label", &GPUCommandEncoder::getLabel, this);
registerHybridSetter("label", &GPUCommandEncoder::setLabel, this);
}
inline const wgpu::CommandEncoder get() { return _instance; }
size_t getMemoryPressure() override { return 1024 * 1024; }
private:
wgpu::CommandEncoder _instance;
std::string _label;
};
} // namespace rnwgpu