-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathGPUExternalTexture.h
More file actions
50 lines (35 loc) · 1.24 KB
/
GPUExternalTexture.h
File metadata and controls
50 lines (35 loc) · 1.24 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
#pragma once
#include <string>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "webgpu/webgpu_cpp.h"
namespace rnwgpu {
namespace m = margelo;
class GPUExternalTexture : public m::HybridObject {
public:
explicit GPUExternalTexture(wgpu::ExternalTexture instance, std::string label)
: HybridObject("GPUExternalTexture"), _instance(instance), _label(label) {
}
public:
std::string getBrand() { return _name; }
std::string getLabel() { return _label; }
void setLabel(const std::string &label) {
_label = label;
_instance.SetLabel(_label.c_str());
}
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPUExternalTexture::getBrand, this);
registerHybridGetter("label", &GPUExternalTexture::getLabel, this);
registerHybridSetter("label", &GPUExternalTexture::setLabel, this);
}
inline const wgpu::ExternalTexture get() { return _instance; }
size_t getMemoryPressure() override {
// External textures usually wrap decoder/camera surfaces (multi-MB frames).
constexpr size_t kExternalTextureFloor = 8 * 1024 * 1024; // 8MB baseline
return kExternalTextureFloor + _label.capacity();
}
private:
wgpu::ExternalTexture _instance;
std::string _label;
};
} // namespace rnwgpu