载入中...
搜索中...
未找到
wgpu_types.h
浏览该文件的文档.
1#pragma once
2
3// Lightweight WebGPU helper types shared by the webgpu backend layer.
4// This header only depends on the wgpu C++ wrapper (webgpu_cpp.h); it must not
5// include any engine module headers (AGENTS.md layering rules).
6
7#if defined(__EMSCRIPTEN__) && __has_include(<webgpu/webgpu_cpp.h>)
8#include <webgpu/webgpu_cpp.h>
9#else
10#include <dawn/webgpu_cpp.h>
11#endif
12
13#include <cstdint>
14#include <cstring>
15#include <string>
16
17namespace eve::graphics::webgpu {
18
20inline WGPUStringView sv(const char *s) {
21 return WGPUStringView{s, s ? std::strlen(s) : 0};
22}
23
25inline WGPUStringView sv(const std::string &s) {
26 return WGPUStringView{s.data(), s.size()};
27}
28
34[[nodiscard]] inline wgpu::ShaderModule makeWgslModule(wgpu::Device &dev, const char *wgsl) {
35 wgpu::ShaderSourceWGSL wgslDesc{};
36 wgslDesc.code = wgsl;
37 wgpu::ShaderModuleDescriptor desc{};
38 desc.nextInChain = &wgslDesc;
39 return dev.CreateShaderModule(&desc);
40}
41
42} // namespace eve::graphics::webgpu
const std::string & s
scene::NodeDesc desc
WGPUStringView sv(const char *s)
Build a WGPUStringView from a C string (null-safe, length auto-computed).
Definition wgpu_types.h:20
wgpu::ShaderModule makeWgslModule(wgpu::Device &dev, const char *wgsl)
Create an owning shader module; retain it until pipeline creation completes.
Definition wgpu_types.h:34