-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathGPURenderPassEncoder.h
More file actions
130 lines (113 loc) · 5.21 KB
/
GPURenderPassEncoder.h
File metadata and controls
130 lines (113 loc) · 5.21 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
#include <memory>
#include <optional>
#include <string>
#include <variant>
#include <vector>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "webgpu/webgpu_cpp.h"
#include "GPUBindGroup.h"
#include "GPUBuffer.h"
#include "GPUColor.h"
#include "GPURenderBundle.h"
#include "GPURenderPipeline.h"
namespace rnwgpu {
namespace m = margelo;
class GPURenderPassEncoder : public m::HybridObject {
public:
explicit GPURenderPassEncoder(wgpu::RenderPassEncoder instance,
std::string label)
: HybridObject("GPURenderPassEncoder"), _instance(instance),
_label(label) {}
public:
std::string getBrand() { return _name; }
void setViewport(double x, double y, double width, double height,
double minDepth, double maxDepth);
void setScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
void setBlendConstant(std::shared_ptr<GPUColor> color);
void setStencilReference(uint32_t reference);
void beginOcclusionQuery(uint32_t queryIndex);
void endOcclusionQuery();
void executeBundles(std::vector<std::shared_ptr<GPURenderBundle>> bundles);
void end();
void pushDebugGroup(std::string groupLabel);
void popDebugGroup();
void insertDebugMarker(std::string markerLabel);
void setBindGroup(
uint32_t index,
std::variant<std::nullptr_t, std::shared_ptr<GPUBindGroup>> bindGroup,
std::optional<std::vector<uint32_t>> dynamicOffsets);
void setPipeline(std::shared_ptr<GPURenderPipeline> pipeline);
void setIndexBuffer(std::shared_ptr<GPUBuffer> buffer,
wgpu::IndexFormat indexFormat,
std::optional<uint64_t> offset,
std::optional<uint64_t> size);
void setVertexBuffer(
uint32_t slot,
std::variant<std::nullptr_t, std::shared_ptr<GPUBuffer>> buffer,
std::optional<uint64_t> offset, std::optional<uint64_t> size);
void draw(uint32_t vertexCount, std::optional<uint32_t> instanceCount,
std::optional<uint32_t> firstVertex,
std::optional<uint32_t> firstInstance);
void drawIndexed(uint32_t indexCount, std::optional<uint32_t> instanceCount,
std::optional<uint32_t> firstIndex,
std::optional<double> baseVertex,
std::optional<uint32_t> firstInstance);
void drawIndirect(std::shared_ptr<GPUBuffer> indirectBuffer,
uint64_t indirectOffset);
void drawIndexedIndirect(std::shared_ptr<GPUBuffer> indirectBuffer,
uint64_t indirectOffset);
std::string getLabel() { return _label; }
void setLabel(const std::string &label) {
_label = label;
_instance.SetLabel(_label.c_str());
}
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPURenderPassEncoder::getBrand, this);
registerHybridMethod("setViewport", &GPURenderPassEncoder::setViewport,
this);
registerHybridMethod("setScissorRect",
&GPURenderPassEncoder::setScissorRect, this);
registerHybridMethod("setBlendConstant",
&GPURenderPassEncoder::setBlendConstant, this);
registerHybridMethod("setStencilReference",
&GPURenderPassEncoder::setStencilReference, this);
registerHybridMethod("beginOcclusionQuery",
&GPURenderPassEncoder::beginOcclusionQuery, this);
registerHybridMethod("endOcclusionQuery",
&GPURenderPassEncoder::endOcclusionQuery, this);
registerHybridMethod("executeBundles",
&GPURenderPassEncoder::executeBundles, this);
registerHybridMethod("end", &GPURenderPassEncoder::end, this);
registerHybridMethod("pushDebugGroup",
&GPURenderPassEncoder::pushDebugGroup, this);
registerHybridMethod("popDebugGroup", &GPURenderPassEncoder::popDebugGroup,
this);
registerHybridMethod("insertDebugMarker",
&GPURenderPassEncoder::insertDebugMarker, this);
registerHybridMethod("setBindGroup", &GPURenderPassEncoder::setBindGroup,
this);
registerHybridMethod("setPipeline", &GPURenderPassEncoder::setPipeline,
this);
registerHybridMethod("setIndexBuffer",
&GPURenderPassEncoder::setIndexBuffer, this);
registerHybridMethod("setVertexBuffer",
&GPURenderPassEncoder::setVertexBuffer, this);
registerHybridMethod("draw", &GPURenderPassEncoder::draw, this);
registerHybridMethod("drawIndexed", &GPURenderPassEncoder::drawIndexed,
this);
registerHybridMethod("drawIndirect", &GPURenderPassEncoder::drawIndirect,
this);
registerHybridMethod("drawIndexedIndirect",
&GPURenderPassEncoder::drawIndexedIndirect, this);
registerHybridGetter("label", &GPURenderPassEncoder::getLabel, this);
registerHybridSetter("label", &GPURenderPassEncoder::setLabel, this);
}
inline const wgpu::RenderPassEncoder get() { return _instance; }
size_t getMemoryPressure() override { return 1024 * 1024; }
private:
wgpu::RenderPassEncoder _instance;
std::string _label;
};
} // namespace rnwgpu