-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathGPUShaderModule.cpp
More file actions
38 lines (34 loc) · 1.37 KB
/
Copy pathGPUShaderModule.cpp
File metadata and controls
38 lines (34 loc) · 1.37 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
#include "GPUShaderModule.h"
#include <memory>
#include <utility>
namespace rnwgpu {
std::future<std::shared_ptr<GPUCompilationInfo>>
GPUShaderModule::getCompilationInfo() {
return _async->runAsync([=](wgpu::Instance *instance) {
wgpu::CompilationInfo compilationInfo;
auto result = std::make_shared<GPUCompilationInfo>();
auto future = _instance.GetCompilationInfo(
wgpu::CallbackMode::WaitAnyOnly,
[&result](wgpu::CompilationInfoRequestStatus status,
wgpu::CompilationInfo const *compilationInfo) {
if (status == wgpu::CompilationInfoRequestStatus::Success &&
compilationInfo) {
for (size_t i = 0; i < compilationInfo->messageCount; ++i) {
const auto &wgpuMessage = compilationInfo->messages[i];
GPUCompilationMessage message;
message.message =
wgpuMessage.message.length ? wgpuMessage.message.data : "";
message.type = wgpuMessage.type;
message.lineNum = wgpuMessage.lineNum;
message.linePos = wgpuMessage.linePos;
message.offset = wgpuMessage.offset;
message.length = wgpuMessage.length;
result->_messages.push_back(std::move(message));
}
}
});
instance->WaitAny(future, UINT64_MAX);
return result;
});
}
} // namespace rnwgpu