-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebgpu_adapter.cpp
More file actions
50 lines (44 loc) · 1.32 KB
/
webgpu_adapter.cpp
File metadata and controls
50 lines (44 loc) · 1.32 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
#include "./webgpu_adapter.hpp"
#include "./webgpu_device.hpp"
#include <iostream>
#include <stdexcept>
namespace client_graphics
{
using namespace std;
// WebGPUAdapter implementation
WebGPUAdapter::WebGPUAdapter(const commandbuffers::GPUAdapterInfo &info)
: adapter_info_(info)
, features_()
, limits_()
{
// Initialize with default features and limits
// In a full implementation, these would be queried from the actual adapter
}
std::unique_ptr<WebGPUDevice> WebGPUAdapter::requestDevice(
std::optional<std::string> label,
const std::vector<std::string> &requiredFeatures,
const std::unordered_map<std::string, uint32_t> &requiredLimits)
{
// Validate required features
for (const auto &feature : requiredFeatures)
{
if (features_.find(feature) == features_.end())
{
// Feature not supported
return nullptr;
}
}
// Validate required limits
for (const auto &[limitName, requiredValue] : requiredLimits)
{
auto it = limits_.find(limitName);
if (it == limits_.end() || it->second < requiredValue)
{
// Limit not supported or insufficient
return nullptr;
}
}
// Create device with the requested configuration
return std::make_unique<WebGPUDevice>(adapter_info_, label);
}
}