-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathGPUQuerySet.h
More file actions
74 lines (56 loc) · 1.88 KB
/
GPUQuerySet.h
File metadata and controls
74 lines (56 loc) · 1.88 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
#pragma once
#include <string>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "webgpu/webgpu_cpp.h"
namespace rnwgpu {
namespace m = margelo;
class GPUQuerySet : public m::HybridObject {
public:
explicit GPUQuerySet(wgpu::QuerySet instance, std::string label)
: HybridObject("GPUQuerySet"), _instance(instance), _label(label) {}
public:
std::string getBrand() { return _name; }
void destroy();
wgpu::QueryType getType();
uint32_t getCount();
std::string getLabel() { return _label; }
void setLabel(const std::string &label) {
_label = label;
_instance.SetLabel(_label.c_str());
}
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPUQuerySet::getBrand, this);
registerHybridMethod("destroy", &GPUQuerySet::destroy, this);
registerHybridGetter("type", &GPUQuerySet::getType, this);
registerHybridGetter("count", &GPUQuerySet::getCount, this);
registerHybridGetter("label", &GPUQuerySet::getLabel, this);
registerHybridSetter("label", &GPUQuerySet::setLabel, this);
}
inline const wgpu::QuerySet get() { return _instance; }
size_t getMemoryPressure() override {
const uint32_t count = getCount();
const wgpu::QueryType type = getType();
size_t bytesPerQuery = 16; // default to an overshoot
switch (type) {
case wgpu::QueryType::Occlusion:
bytesPerQuery = 16; // occlusion result is 64-bit; pad to 16 for safety
break;
case wgpu::QueryType::Timestamp:
bytesPerQuery = 16; // timestamps are 64-bit; double to overshoot
break;
case wgpu::QueryType::PipelineStatistics: {
constexpr size_t kAssumedCountersPerQuery = 8;
bytesPerQuery = 8 * kAssumedCountersPerQuery;
break;
}
default:
break;
}
return static_cast<size_t>(count) * bytesPerQuery;
}
private:
wgpu::QuerySet _instance;
std::string _label;
};
} // namespace rnwgpu