-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathGPUQuerySet.h
More file actions
73 lines (54 loc) · 1.74 KB
/
Copy pathGPUQuerySet.h
File metadata and controls
73 lines (54 loc) · 1.74 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
#pragma once
#include <string>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "AsyncRunner.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 {
uint32_t count = getCount();
wgpu::QueryType type = getType();
// Estimate bytes per query based on type
size_t bytesPerQuery = 8; // Default estimate
switch (type) {
case wgpu::QueryType::Occlusion:
bytesPerQuery = 8; // 64-bit counter
break;
case wgpu::QueryType::Timestamp:
bytesPerQuery = 8; // 64-bit timestamp
break;
default:
bytesPerQuery = 8; // Safe default
break;
}
return static_cast<size_t>(count) * bytesPerQuery;
}
private:
wgpu::QuerySet _instance;
std::string _label;
};
} // namespace rnwgpu