-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathGPUComputePipeline.h
More file actions
58 lines (41 loc) · 1.48 KB
/
GPUComputePipeline.h
File metadata and controls
58 lines (41 loc) · 1.48 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
#pragma once
#include <memory>
#include <string>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "webgpu/webgpu_cpp.h"
#include "GPUBindGroupLayout.h"
namespace rnwgpu {
namespace m = margelo;
class GPUComputePipeline : public m::HybridObject {
public:
explicit GPUComputePipeline(wgpu::ComputePipeline instance, std::string label)
: HybridObject("GPUComputePipeline"), _instance(instance), _label(label) {
}
public:
std::string getBrand() { return _name; }
std::shared_ptr<GPUBindGroupLayout> getBindGroupLayout(uint32_t index);
std::string getLabel() { return _label; }
void setLabel(const std::string &label) {
_label = label;
_instance.SetLabel(_label.c_str());
}
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPUComputePipeline::getBrand, this);
registerHybridMethod("getBindGroupLayout",
&GPUComputePipeline::getBindGroupLayout, this);
registerHybridGetter("label", &GPUComputePipeline::getLabel, this);
registerHybridSetter("label", &GPUComputePipeline::setLabel, this);
}
inline const wgpu::ComputePipeline get() { return _instance; }
size_t getMemoryPressure() override {
// Compute pipelines retain compiled shader state and backend caches.
// Overshoot intentionally to reflect the native resources they fan out to.
return 3 * 1024 * 1024; // 3MB
}
private:
wgpu::ComputePipeline _instance;
std::string _label;
friend class GPUDevice;
};
} // namespace rnwgpu