├── .github └── workflows │ └── main.yml ├── .gitignore ├── .zigversion ├── LICENSE ├── README.md ├── build.zig ├── build.zig.zon ├── libs └── dawn │ └── include │ ├── dawn │ ├── EnumClassBitmasks.h │ ├── dawn_proc.h │ ├── dawn_proc_table.h │ ├── dawn_thread_dispatch_proc.h │ ├── native │ │ ├── D3D11Backend.h │ │ ├── D3D12Backend.h │ │ ├── D3DBackend.h │ │ ├── DawnNative.h │ │ ├── MetalBackend.h │ │ ├── NullBackend.h │ │ ├── OpenGLBackend.h │ │ ├── VulkanBackend.h │ │ └── dawn_native_export.h │ ├── platform │ │ ├── DawnPlatform.h │ │ └── dawn_platform_export.h │ ├── webgpu.h │ ├── webgpu_cpp.h │ ├── webgpu_cpp_chained_struct.h │ ├── webgpu_cpp_print.h │ └── wire │ │ ├── Wire.h │ │ ├── WireClient.h │ │ ├── WireServer.h │ │ └── dawn_wire_export.h │ ├── tint │ ├── override_id.h │ └── tint.h │ └── webgpu │ ├── webgpu.h │ ├── webgpu_cpp.h │ └── webgpu_glfw.h └── src ├── common_wgsl.zig ├── dawn.cpp ├── dawn_proc.c ├── wgpu.zig └── zgpu.zig /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | push: 7 | branches: 8 | - main 9 | concurrency: 10 | # Cancels pending runs when a PR gets updated. 11 | group: ${{ github.head_ref || github.run_id }}-${{ github.actor }} 12 | cancel-in-progress: true 13 | jobs: 14 | lint-and-build-and-test: 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, windows-latest, macos-latest] 19 | runs-on: ${{matrix.os}} 20 | steps: 21 | - name: Checkout repository 22 | uses: actions/checkout@v3 23 | - name: Read .zig-version 24 | id: zigversion 25 | uses: juliangruber/read-file-action@v1 26 | with: 27 | path: ./.zigversion 28 | - name: Install Zig 29 | uses: mlugg/setup-zig@v1 30 | with: 31 | version: ${{ steps.zigversion.outputs.content }} 32 | - name: Check format 33 | continue-on-error: true 34 | run: zig fmt --check . 35 | - name: Build and run tests 36 | run: zig build test 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore some special directories 2 | .zig-cache 3 | zig-out 4 | 5 | # Ignore some special OS files 6 | *.DS_Store 7 | -------------------------------------------------------------------------------- /.zigversion: -------------------------------------------------------------------------------- 1 | 0.14.0 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Michal Ziulek 4 | Copyright (c) 2024 zig-gamedev contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [zgpu](https://github.com/zig-gamedev/zgpu) 2 | 3 | Cross-platform graphics lib for Zig built on top of [Dawn](https://github.com/zig-gamedev/dawn) native WebGPU implementation. 4 | 5 | Supports Windows 10+ (DirectX 12), macOS 12+ (Metal) and Linux (Vulkan). 6 | 7 | ## Features 8 | 9 | - Zero-overhead wgpu API bindings ([source code](https://github.com/zig-gamedev/zgpu/blob/main/src/wgpu.zig)) 10 | - Uniform buffer pool for fast CPU->GPU transfers 11 | - Resource pools and handle-based GPU resources 12 | - Async shader compilation 13 | - GPU mipmap generator 14 | 15 | ## Getting started 16 | 17 | Example `build.zig`: 18 | 19 | ```zig 20 | pub fn build(b: *std.Build) void { 21 | const exe = b.addExecutable(.{ ... }); 22 | 23 | @import("zgpu").addLibraryPathsTo(exe); 24 | 25 | const zgpu = b.dependency("zgpu", .{}); 26 | exe.root_module.addImport("zgpu", zgpu.module("root")); 27 | 28 | if (target.result.os.tag != .emscripten) { 29 | exe.linkLibrary(zgpu.artifact("zdawn")); 30 | } 31 | } 32 | ``` 33 | 34 | ## Sample applications 35 | 36 | - [gui test (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/gui_test_wgpu) 37 | - [physically based rendering (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/physically_based_rendering_wgpu) 38 | - [bullet physics test (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/bullet_physics_test_wgpu) 39 | - [procedural mesh (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/procedural_mesh_wgpu) 40 | - [textured quad (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/textured_quad_wgpu) 41 | - [triangle (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/triangle_wgpu) 42 | 43 | ## Library overview 44 | 45 | Below you can find an overview of main `zgpu` features. 46 | 47 | ### Compile-time options 48 | 49 | You can override default options in your `build.zig`: 50 | 51 | ```zig 52 | pub fn build(b: *std.Build) void { 53 | ... 54 | 55 | const zgpu = @import("zgpu").package(b, target, optimize, .{ 56 | .options = .{ 57 | .uniforms_buffer_size = 4 * 1024 * 1024, 58 | .dawn_skip_validation = false, 59 | .buffer_pool_size = 256, 60 | .texture_pool_size = 256, 61 | .texture_view_pool_size = 256, 62 | .sampler_pool_size = 16, 63 | .render_pipeline_pool_size = 128, 64 | .compute_pipeline_pool_size = 128, 65 | .bind_group_pool_size = 32, 66 | .bind_group_layout_pool_size = 32, 67 | .pipeline_layout_pool_size = 32, 68 | }, 69 | }); 70 | 71 | zgpu.link(exe); 72 | 73 | ... 74 | } 75 | ``` 76 | 77 | ### Graphics Context 78 | 79 | Create a `GraphicsContext` using a `WindowProvider`. For example, using [zglfw](https://github.com/zig-gamedev/zglfw): 80 | 81 | ```zig 82 | const gctx = try zgpu.GraphicsContext.create( 83 | allocator, 84 | .{ 85 | .window = window, 86 | .fn_getTime = @ptrCast(&zglfw.getTime), 87 | .fn_getFramebufferSize = @ptrCast(&zglfw.Window.getFramebufferSize), 88 | 89 | // optional fields 90 | .fn_getWin32Window = @ptrCast(&zglfw.getWin32Window), 91 | .fn_getX11Display = @ptrCast(&zglfw.getX11Display), 92 | .fn_getX11Window = @ptrCast(&zglfw.getX11Window), 93 | .fn_getWaylandDisplay = @ptrCast(&zglfw.getWaylandDisplay), 94 | .fn_getWaylandSurface = @ptrCast(&zglfw.getWaylandWindow), 95 | .fn_getCocoaWindow = @ptrCast(&zglfw.getCocoaWindow), 96 | }, 97 | .{}, // default context creation options 98 | ); 99 | ``` 100 | 101 | ### Uniforms 102 | 103 | - Implemented as a uniform buffer pool 104 | - Easy to use 105 | - Efficient - only one copy operation per frame 106 | 107 | ```zig 108 | struct DrawUniforms = extern struct { 109 | object_to_world: zm.Mat, 110 | }; 111 | const mem = gctx.uniformsAllocate(DrawUniforms, 1); 112 | mem.slice[0] = .{ .object_to_world = zm.transpose(zm.translation(...)) }; 113 | 114 | pass.setBindGroup(0, bind_group, &.{mem.offset}); 115 | pass.drawIndexed(...); 116 | 117 | // When you are done encoding all commands for a frame: 118 | gctx.submit(...); // Injects *one* copy operation to transfer *all* allocated uniforms 119 | ``` 120 | 121 | ### Resource pools 122 | 123 | - Every GPU resource is identified by 32-bit integer handle 124 | - All resources are stored in one system 125 | - We keep basic info about each resource (size of the buffer, format of the texture, etc.) 126 | - You can always check if resource is valid (very useful for async operations) 127 | - System keeps basic info about resource dependencies, for example, `TextureViewHandle` knows about its 128 | parent texture and becomes invalid when parent texture becomes invalid; `BindGroupHandle` knows 129 | about all resources it binds so it becomes invalid if any of those resources become invalid 130 | 131 | ```zig 132 | const buffer_handle = gctx.createBuffer(...); 133 | 134 | if (gctx.isResourceValid(buffer_handle)) { 135 | const buffer = gctx.lookupResource(buffer_handle).?; // Returns `wgpu.Buffer` 136 | 137 | const buffer_info = gctx.lookupResourceInfo(buffer_handle).?; // Returns `zgpu.BufferInfo` 138 | std.debug.print("Buffer size is: {d}", .{buffer_info.size}); 139 | } 140 | 141 | // If you want to destroy a resource before shutting down graphics context: 142 | gctx.destroyResource(buffer_handle); 143 | 144 | ``` 145 | 146 | ### Async shader compilation 147 | 148 | - Thanks to resource pools and resources identified by handles we can easily async compile all our shaders 149 | 150 | ```zig 151 | const DemoState = struct { 152 | pipeline_handle: zgpu.PipelineLayoutHandle = .{}, 153 | ... 154 | }; 155 | const demo = try allocator.create(DemoState); 156 | 157 | // Below call schedules pipeline compilation and returns immediately. When compilation is complete 158 | // valid pipeline handle will be stored in `demo.pipeline_handle`. 159 | gctx.createRenderPipelineAsync(allocator, pipeline_layout, pipeline_descriptor, &demo.pipeline_handle); 160 | 161 | // Pass using our pipeline will be skipped until compilation is ready 162 | pass: { 163 | const pipeline = gctx.lookupResource(demo.pipeline_handle) orelse break :pass; 164 | ... 165 | 166 | pass.setPipeline(pipeline); 167 | pass.drawIndexed(...); 168 | } 169 | ``` 170 | 171 | ### Mipmap generation on the GPU 172 | 173 | - wgpu API does not provide mipmap generator 174 | - zgpu provides decent mipmap generator implemented in a compute shader 175 | - It supports 2D textures, array textures and cubemap textures of any format 176 | (`rgba8_unorm`, `rg16_float`, `rgba32_float`, etc.) 177 | - Currently it requires that: `texture_width == texture_height and isPowerOfTwo(texture_width)` 178 | - It takes ~260 microsec to generate all mips for 1024x1024 `rgba8_unorm` texture on GTX 1660 179 | 180 | ```zig 181 | // Usage: 182 | gctx.generateMipmaps(arena, command_encoder, texture_handle); 183 | ``` 184 | -------------------------------------------------------------------------------- /build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const log = std.log.scoped(.zgpu); 3 | 4 | const default_options = struct { 5 | const uniforms_buffer_size = 4 * 1024 * 1024; 6 | const dawn_skip_validation = false; 7 | const dawn_allow_unsafe_apis = false; 8 | const buffer_pool_size = 256; 9 | const texture_pool_size = 256; 10 | const texture_view_pool_size = 256; 11 | const sampler_pool_size = 16; 12 | const render_pipeline_pool_size = 128; 13 | const compute_pipeline_pool_size = 128; 14 | const bind_group_pool_size = 32; 15 | const bind_group_layout_pool_size = 32; 16 | const pipeline_layout_pool_size = 32; 17 | const max_num_bindings_per_group = 10; 18 | const max_num_bind_groups_per_pipeline = 4; 19 | }; 20 | 21 | pub fn build(b: *std.Build) void { 22 | const optimize = b.standardOptimizeOption(.{}); 23 | const target = b.standardTargetOptions(.{}); 24 | 25 | const options = .{ 26 | .uniforms_buffer_size = b.option( 27 | u64, 28 | "uniforms_buffer_size", 29 | "Set uniforms buffer size", 30 | ) orelse default_options.uniforms_buffer_size, 31 | .dawn_skip_validation = b.option( 32 | bool, 33 | "dawn_skip_validation", 34 | "Disable Dawn validation", 35 | ) orelse default_options.dawn_skip_validation, 36 | .dawn_allow_unsafe_apis = b.option( 37 | bool, 38 | "dawn_allow_unsafe_apis", 39 | "Allow unsafe WebGPU APIs (e.g. timestamp queries)", 40 | ) orelse default_options.dawn_allow_unsafe_apis, 41 | .buffer_pool_size = b.option( 42 | u32, 43 | "buffer_pool_size", 44 | "Set buffer pool size", 45 | ) orelse default_options.buffer_pool_size, 46 | .texture_pool_size = b.option( 47 | u32, 48 | "texture_pool_size", 49 | "Set texture pool size", 50 | ) orelse default_options.texture_pool_size, 51 | .texture_view_pool_size = b.option( 52 | u32, 53 | "texture_view_pool_size", 54 | "Set texture view pool size", 55 | ) orelse default_options.texture_view_pool_size, 56 | .sampler_pool_size = b.option( 57 | u32, 58 | "sampler_pool_size", 59 | "Set sample pool size", 60 | ) orelse default_options.sampler_pool_size, 61 | .render_pipeline_pool_size = b.option( 62 | u32, 63 | "render_pipeline_pool_size", 64 | "Set render pipeline pool size", 65 | ) orelse default_options.render_pipeline_pool_size, 66 | .compute_pipeline_pool_size = b.option( 67 | u32, 68 | "compute_pipeline_pool_size", 69 | "Set compute pipeline pool size", 70 | ) orelse default_options.compute_pipeline_pool_size, 71 | .bind_group_pool_size = b.option( 72 | u32, 73 | "bind_group_pool_size", 74 | "Set bind group pool size", 75 | ) orelse default_options.bind_group_pool_size, 76 | .bind_group_layout_pool_size = b.option( 77 | u32, 78 | "bind_group_layout_pool_size", 79 | "Set bind group layout pool size", 80 | ) orelse default_options.bind_group_layout_pool_size, 81 | .pipeline_layout_pool_size = b.option( 82 | u32, 83 | "pipeline_layout_pool_size", 84 | "Set pipeline layout pool size", 85 | ) orelse default_options.pipeline_layout_pool_size, 86 | .max_num_bindings_per_group = b.option( 87 | u32, 88 | "max_num_bindings_per_group", 89 | "Set maximum number of bindings per bind group", 90 | ) orelse default_options.max_num_bindings_per_group, 91 | .max_num_bind_groups_per_pipeline = b.option( 92 | u32, 93 | "max_num_bind_groups_per_pipeline", 94 | "Set maximum number of bindings groups per pipeline", 95 | ) orelse default_options.max_num_bind_groups_per_pipeline, 96 | }; 97 | 98 | const options_step = b.addOptions(); 99 | inline for (std.meta.fields(@TypeOf(options))) |field| { 100 | options_step.addOption(field.type, field.name, @field(options, field.name)); 101 | } 102 | 103 | const options_module = options_step.createModule(); 104 | 105 | _ = b.addModule("root", .{ 106 | .root_source_file = b.path("src/zgpu.zig"), 107 | .imports = &.{ 108 | .{ .name = "zgpu_options", .module = options_module }, 109 | .{ .name = "zpool", .module = b.dependency("zpool", .{}).module("root") }, 110 | }, 111 | }); 112 | 113 | const zdawn = b.addStaticLibrary(.{ 114 | .name = "zdawn", 115 | .target = target, 116 | .optimize = optimize, 117 | }); 118 | b.installArtifact(zdawn); 119 | 120 | linkSystemDeps(b, zdawn); 121 | addLibraryPathsTo(zdawn); 122 | 123 | zdawn.linkSystemLibrary("dawn"); 124 | zdawn.linkLibC(); 125 | if (target.result.abi != .msvc) 126 | zdawn.linkLibCpp(); 127 | 128 | zdawn.addIncludePath(b.path("libs/dawn/include")); 129 | zdawn.addIncludePath(b.path("src")); 130 | 131 | zdawn.addCSourceFile(.{ 132 | .file = b.path("src/dawn.cpp"), 133 | .flags = &.{ "-std=c++17", "-fno-sanitize=undefined" }, 134 | }); 135 | zdawn.addCSourceFile(.{ 136 | .file = b.path("src/dawn_proc.c"), 137 | .flags = &.{"-fno-sanitize=undefined"}, 138 | }); 139 | 140 | const test_step = b.step("test", "Run zgpu tests"); 141 | 142 | const tests = b.addTest(.{ 143 | .name = "zgpu-tests", 144 | .root_source_file = b.path("src/zgpu.zig"), 145 | .target = target, 146 | .optimize = optimize, 147 | }); 148 | tests.addIncludePath(b.path("libs/dawn/include")); 149 | tests.linkLibrary(zdawn); 150 | linkSystemDeps(b, tests); 151 | addLibraryPathsTo(tests); 152 | b.installArtifact(tests); 153 | 154 | test_step.dependOn(&b.addRunArtifact(tests).step); 155 | } 156 | 157 | pub fn linkSystemDeps(b: *std.Build, compile_step: *std.Build.Step.Compile) void { 158 | switch (compile_step.rootModuleTarget().os.tag) { 159 | .windows => { 160 | if (b.lazyDependency("system_sdk", .{})) |system_sdk| { 161 | compile_step.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu")); 162 | } 163 | compile_step.linkSystemLibrary("ole32"); 164 | compile_step.linkSystemLibrary("dxguid"); 165 | }, 166 | .macos => { 167 | if (b.lazyDependency("system_sdk", .{})) |system_sdk| { 168 | compile_step.addLibraryPath(system_sdk.path("macos12/usr/lib")); 169 | compile_step.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks")); 170 | } 171 | compile_step.linkSystemLibrary("objc"); 172 | compile_step.linkFramework("Metal"); 173 | compile_step.linkFramework("CoreGraphics"); 174 | compile_step.linkFramework("Foundation"); 175 | compile_step.linkFramework("IOKit"); 176 | compile_step.linkFramework("IOSurface"); 177 | compile_step.linkFramework("QuartzCore"); 178 | }, 179 | else => {}, 180 | } 181 | } 182 | 183 | pub fn addLibraryPathsTo(compile_step: *std.Build.Step.Compile) void { 184 | const b = compile_step.step.owner; 185 | const target = compile_step.rootModuleTarget(); 186 | switch (target.os.tag) { 187 | .windows => { 188 | if (b.lazyDependency("dawn_x86_64_windows_gnu", .{})) |dawn_prebuilt| { 189 | compile_step.addLibraryPath(dawn_prebuilt.path("")); 190 | } 191 | }, 192 | .linux => { 193 | if (target.cpu.arch.isX86()) { 194 | if (b.lazyDependency("dawn_x86_64_linux_gnu", .{})) |dawn_prebuilt| { 195 | compile_step.addLibraryPath(dawn_prebuilt.path("")); 196 | } 197 | } else if (target.cpu.arch.isAARCH64()) { 198 | if (b.lazyDependency("dawn_aarch64_linux_gnu", .{})) |dawn_prebuilt| { 199 | compile_step.addLibraryPath(dawn_prebuilt.path("")); 200 | } 201 | } 202 | }, 203 | .macos => { 204 | if (target.cpu.arch.isX86()) { 205 | if (b.lazyDependency("dawn_x86_64_macos", .{})) |dawn_prebuilt| { 206 | compile_step.addLibraryPath(dawn_prebuilt.path("")); 207 | } 208 | } else if (target.cpu.arch.isAARCH64()) { 209 | if (b.lazyDependency("dawn_aarch64_macos", .{})) |dawn_prebuilt| { 210 | compile_step.addLibraryPath(dawn_prebuilt.path("")); 211 | } 212 | } 213 | }, 214 | else => {}, 215 | } 216 | } 217 | 218 | pub fn checkTargetSupported(target: std.Target) bool { 219 | const supported = switch (target.os.tag) { 220 | .windows => target.cpu.arch.isX86() and target.abi.isGnu(), 221 | .linux => (target.cpu.arch.isX86() or target.cpu.arch.isAARCH64()) and target.abi.isGnu(), 222 | .macos => blk: { 223 | if (!target.cpu.arch.isX86() and !target.cpu.arch.isAARCH64()) break :blk false; 224 | 225 | // If min. target macOS version is lesser than the min version we have available, then 226 | // our Dawn binary is incompatible with the target. 227 | if (target.os.version_range.semver.min.order( 228 | .{ .major = 12, .minor = 0, .patch = 0 }, 229 | ) == .lt) break :blk false; 230 | break :blk true; 231 | }, 232 | else => false, 233 | }; 234 | if (supported == false) { 235 | log.warn("\n" ++ 236 | \\--------------------------------------------------------------------------- 237 | \\ 238 | \\Dawn/WebGPU binary for this target is not available. 239 | \\ 240 | \\Following targets are supported: 241 | \\ 242 | \\x86_64-windows-gnu 243 | \\x86_64-linux-gnu 244 | \\x86_64-macos.12.0.0-none 245 | \\aarch64-linux-gnu 246 | \\aarch64-macos.12.0.0-none 247 | \\ 248 | \\--------------------------------------------------------------------------- 249 | \\ 250 | , .{}); 251 | } 252 | return supported; 253 | } 254 | -------------------------------------------------------------------------------- /build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .zgpu, 3 | .fingerprint = 0x670ebe04e453a19e, 4 | .version = "0.12.0-dev", 5 | .minimum_zig_version = "0.14.0", 6 | .paths = .{ 7 | "build.zig", 8 | "build.zig.zon", 9 | "libs", 10 | "src", 11 | "README.md", 12 | "LICENSE", 13 | }, 14 | .dependencies = .{ 15 | .zpool = .{ 16 | .url = "https://github.com/zig-gamedev/zpool/archive/99a4c74ec26b1f327209782565b4adaf1c1d610f.tar.gz", 17 | .hash = "zpool-0.11.0-dev-bG692eY7AQDLTkjTbgnbg_-qgjmxUCg8hNpN1kZRrIlW", 18 | }, 19 | .system_sdk = .{ 20 | .url = "https://github.com/zig-gamedev/system_sdk/archive/c0dbf11cdc17da5904ea8a17eadc54dee26567ec.tar.gz", 21 | .hash = "system_sdk-0.3.0-dev-alwUNnYaaAJAtIdE2fg4NQfDqEKs7QCXy_qYukAOBfmF", 22 | }, 23 | .dawn_x86_64_windows_gnu = .{ 24 | .url = "https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz", 25 | .hash = "N-V-__8AAGsYnAT5RIzeAu881RveLghQ1EidqgVBVx10gVTo", 26 | .lazy = true, 27 | }, 28 | .dawn_x86_64_linux_gnu = .{ 29 | .url = "https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz", 30 | .hash = "N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB", 31 | .lazy = true, 32 | }, 33 | .dawn_aarch64_linux_gnu = .{ 34 | .url = "https://github.com/michal-z/webgpu_dawn-aarch64-linux-gnu/archive/c1f55e740a62f6942ff046e709ecd509a005dbeb.tar.gz", 35 | .hash = "N-V-__8AAJ-wTwNc0T9oSflO92iO6IxrdMeRil37UU-KQD_M", 36 | .lazy = true, 37 | }, 38 | .dawn_aarch64_macos = .{ 39 | .url = "https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz", 40 | .hash = "N-V-__8AALVIRAIf5nfpx8-4mEo2RGsynVryPQPcHk95qFM5", 41 | .lazy = true, 42 | }, 43 | .dawn_x86_64_macos = .{ 44 | .url = "https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz", 45 | .hash = "N-V-__8AAIz1QAKx8C8vft2YoHjGTjEAkH2QMR2UiAo8xZJ-", 46 | .lazy = true, 47 | }, 48 | }, 49 | } 50 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/EnumClassBitmasks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_ENUMCLASSBITMASKS_H_ 16 | #define INCLUDE_DAWN_ENUMCLASSBITMASKS_H_ 17 | 18 | #include 19 | 20 | // The operators in dawn:: namespace need be introduced into other namespaces with 21 | // using-declarations for C++ Argument Dependent Lookup to work. 22 | #define DAWN_IMPORT_BITMASK_OPERATORS \ 23 | using dawn::operator|; \ 24 | using dawn::operator&; \ 25 | using dawn::operator^; \ 26 | using dawn::operator~; \ 27 | using dawn::operator&=; \ 28 | using dawn::operator|=; \ 29 | using dawn::operator^=; \ 30 | using dawn::HasZeroOrOneBits; 31 | 32 | namespace dawn { 33 | 34 | template 35 | struct IsDawnBitmask { 36 | static constexpr bool enable = false; 37 | }; 38 | 39 | template 40 | struct LowerBitmask { 41 | static constexpr bool enable = false; 42 | }; 43 | 44 | template 45 | struct LowerBitmask::enable>::type> { 46 | static constexpr bool enable = true; 47 | using type = T; 48 | constexpr static T Lower(T t) { return t; } 49 | }; 50 | 51 | template 52 | struct BoolConvertible { 53 | using Integral = typename std::underlying_type::type; 54 | 55 | // NOLINTNEXTLINE(runtime/explicit) 56 | explicit constexpr BoolConvertible(Integral value) : value(value) {} 57 | constexpr operator bool() const { return value != 0; } 58 | constexpr operator T() const { return static_cast(value); } 59 | 60 | Integral value; 61 | }; 62 | 63 | template 64 | struct LowerBitmask> { 65 | static constexpr bool enable = true; 66 | using type = T; 67 | static constexpr type Lower(BoolConvertible t) { return t; } 68 | }; 69 | 70 | template < 71 | typename T1, 72 | typename T2, 73 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 74 | constexpr BoolConvertible::type> operator|(T1 left, T2 right) { 75 | using T = typename LowerBitmask::type; 76 | using Integral = typename std::underlying_type::type; 77 | return BoolConvertible(static_cast(LowerBitmask::Lower(left)) | 78 | static_cast(LowerBitmask::Lower(right))); 79 | } 80 | 81 | template < 82 | typename T1, 83 | typename T2, 84 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 85 | constexpr BoolConvertible::type> operator&(T1 left, T2 right) { 86 | using T = typename LowerBitmask::type; 87 | using Integral = typename std::underlying_type::type; 88 | return BoolConvertible(static_cast(LowerBitmask::Lower(left)) & 89 | static_cast(LowerBitmask::Lower(right))); 90 | } 91 | 92 | template < 93 | typename T1, 94 | typename T2, 95 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 96 | constexpr BoolConvertible::type> operator^(T1 left, T2 right) { 97 | using T = typename LowerBitmask::type; 98 | using Integral = typename std::underlying_type::type; 99 | return BoolConvertible(static_cast(LowerBitmask::Lower(left)) ^ 100 | static_cast(LowerBitmask::Lower(right))); 101 | } 102 | 103 | template 104 | constexpr BoolConvertible::type> operator~(T1 t) { 105 | using T = typename LowerBitmask::type; 106 | using Integral = typename std::underlying_type::type; 107 | return BoolConvertible(~static_cast(LowerBitmask::Lower(t))); 108 | } 109 | 110 | template < 111 | typename T, 112 | typename T2, 113 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 114 | constexpr T& operator&=(T& l, T2 right) { 115 | T r = LowerBitmask::Lower(right); 116 | l = l & r; 117 | return l; 118 | } 119 | 120 | template < 121 | typename T, 122 | typename T2, 123 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 124 | constexpr T& operator|=(T& l, T2 right) { 125 | T r = LowerBitmask::Lower(right); 126 | l = l | r; 127 | return l; 128 | } 129 | 130 | template < 131 | typename T, 132 | typename T2, 133 | typename = typename std::enable_if::enable && LowerBitmask::enable>::type> 134 | constexpr T& operator^=(T& l, T2 right) { 135 | T r = LowerBitmask::Lower(right); 136 | l = l ^ r; 137 | return l; 138 | } 139 | 140 | template 141 | constexpr bool HasZeroOrOneBits(T value) { 142 | using Integral = typename std::underlying_type::type; 143 | return (static_cast(value) & (static_cast(value) - 1)) == 0; 144 | } 145 | 146 | } // namespace dawn 147 | 148 | #endif // INCLUDE_DAWN_ENUMCLASSBITMASKS_H_ 149 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/dawn_proc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_DAWN_PROC_H_ 16 | #define INCLUDE_DAWN_DAWN_PROC_H_ 17 | 18 | #include "dawn/dawn_proc_table.h" 19 | #include "dawn/webgpu.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | // Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL 26 | // for `procs` sets up the null proctable that contains only null function pointers. It is the 27 | // default value of the proctable. Setting the proctable back to null is good practice when you 28 | // are done using libdawn_proc since further usage will cause a segfault instead of calling an 29 | // unexpected function. 30 | WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // INCLUDE_DAWN_DAWN_PROC_H_ 37 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/dawn_proc_table.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef DAWN_DAWN_PROC_TABLE_H_ 3 | #define DAWN_DAWN_PROC_TABLE_H_ 4 | 5 | #include "dawn/webgpu.h" 6 | 7 | // Note: Often allocated as a static global. Do not add a complex constructor. 8 | typedef struct DawnProcTable { 9 | WGPUProcCreateInstance createInstance; 10 | WGPUProcGetProcAddress getProcAddress; 11 | 12 | WGPUProcAdapterCreateDevice adapterCreateDevice; 13 | WGPUProcAdapterEnumerateFeatures adapterEnumerateFeatures; 14 | WGPUProcAdapterGetInstance adapterGetInstance; 15 | WGPUProcAdapterGetLimits adapterGetLimits; 16 | WGPUProcAdapterGetProperties adapterGetProperties; 17 | WGPUProcAdapterHasFeature adapterHasFeature; 18 | WGPUProcAdapterRequestDevice adapterRequestDevice; 19 | WGPUProcAdapterReference adapterReference; 20 | WGPUProcAdapterRelease adapterRelease; 21 | 22 | WGPUProcBindGroupSetLabel bindGroupSetLabel; 23 | WGPUProcBindGroupReference bindGroupReference; 24 | WGPUProcBindGroupRelease bindGroupRelease; 25 | 26 | WGPUProcBindGroupLayoutSetLabel bindGroupLayoutSetLabel; 27 | WGPUProcBindGroupLayoutReference bindGroupLayoutReference; 28 | WGPUProcBindGroupLayoutRelease bindGroupLayoutRelease; 29 | 30 | WGPUProcBufferDestroy bufferDestroy; 31 | WGPUProcBufferGetConstMappedRange bufferGetConstMappedRange; 32 | WGPUProcBufferGetMapState bufferGetMapState; 33 | WGPUProcBufferGetMappedRange bufferGetMappedRange; 34 | WGPUProcBufferGetSize bufferGetSize; 35 | WGPUProcBufferGetUsage bufferGetUsage; 36 | WGPUProcBufferMapAsync bufferMapAsync; 37 | WGPUProcBufferSetLabel bufferSetLabel; 38 | WGPUProcBufferUnmap bufferUnmap; 39 | WGPUProcBufferReference bufferReference; 40 | WGPUProcBufferRelease bufferRelease; 41 | 42 | WGPUProcCommandBufferSetLabel commandBufferSetLabel; 43 | WGPUProcCommandBufferReference commandBufferReference; 44 | WGPUProcCommandBufferRelease commandBufferRelease; 45 | 46 | WGPUProcCommandEncoderBeginComputePass commandEncoderBeginComputePass; 47 | WGPUProcCommandEncoderBeginRenderPass commandEncoderBeginRenderPass; 48 | WGPUProcCommandEncoderClearBuffer commandEncoderClearBuffer; 49 | WGPUProcCommandEncoderCopyBufferToBuffer commandEncoderCopyBufferToBuffer; 50 | WGPUProcCommandEncoderCopyBufferToTexture commandEncoderCopyBufferToTexture; 51 | WGPUProcCommandEncoderCopyTextureToBuffer commandEncoderCopyTextureToBuffer; 52 | WGPUProcCommandEncoderCopyTextureToTexture commandEncoderCopyTextureToTexture; 53 | WGPUProcCommandEncoderCopyTextureToTextureInternal commandEncoderCopyTextureToTextureInternal; 54 | WGPUProcCommandEncoderFinish commandEncoderFinish; 55 | WGPUProcCommandEncoderInjectValidationError commandEncoderInjectValidationError; 56 | WGPUProcCommandEncoderInsertDebugMarker commandEncoderInsertDebugMarker; 57 | WGPUProcCommandEncoderPopDebugGroup commandEncoderPopDebugGroup; 58 | WGPUProcCommandEncoderPushDebugGroup commandEncoderPushDebugGroup; 59 | WGPUProcCommandEncoderResolveQuerySet commandEncoderResolveQuerySet; 60 | WGPUProcCommandEncoderSetLabel commandEncoderSetLabel; 61 | WGPUProcCommandEncoderWriteBuffer commandEncoderWriteBuffer; 62 | WGPUProcCommandEncoderWriteTimestamp commandEncoderWriteTimestamp; 63 | WGPUProcCommandEncoderReference commandEncoderReference; 64 | WGPUProcCommandEncoderRelease commandEncoderRelease; 65 | 66 | WGPUProcComputePassEncoderDispatchWorkgroups computePassEncoderDispatchWorkgroups; 67 | WGPUProcComputePassEncoderDispatchWorkgroupsIndirect computePassEncoderDispatchWorkgroupsIndirect; 68 | WGPUProcComputePassEncoderEnd computePassEncoderEnd; 69 | WGPUProcComputePassEncoderInsertDebugMarker computePassEncoderInsertDebugMarker; 70 | WGPUProcComputePassEncoderPopDebugGroup computePassEncoderPopDebugGroup; 71 | WGPUProcComputePassEncoderPushDebugGroup computePassEncoderPushDebugGroup; 72 | WGPUProcComputePassEncoderSetBindGroup computePassEncoderSetBindGroup; 73 | WGPUProcComputePassEncoderSetLabel computePassEncoderSetLabel; 74 | WGPUProcComputePassEncoderSetPipeline computePassEncoderSetPipeline; 75 | WGPUProcComputePassEncoderWriteTimestamp computePassEncoderWriteTimestamp; 76 | WGPUProcComputePassEncoderReference computePassEncoderReference; 77 | WGPUProcComputePassEncoderRelease computePassEncoderRelease; 78 | 79 | WGPUProcComputePipelineGetBindGroupLayout computePipelineGetBindGroupLayout; 80 | WGPUProcComputePipelineSetLabel computePipelineSetLabel; 81 | WGPUProcComputePipelineReference computePipelineReference; 82 | WGPUProcComputePipelineRelease computePipelineRelease; 83 | 84 | WGPUProcDeviceCreateBindGroup deviceCreateBindGroup; 85 | WGPUProcDeviceCreateBindGroupLayout deviceCreateBindGroupLayout; 86 | WGPUProcDeviceCreateBuffer deviceCreateBuffer; 87 | WGPUProcDeviceCreateCommandEncoder deviceCreateCommandEncoder; 88 | WGPUProcDeviceCreateComputePipeline deviceCreateComputePipeline; 89 | WGPUProcDeviceCreateComputePipelineAsync deviceCreateComputePipelineAsync; 90 | WGPUProcDeviceCreateErrorBuffer deviceCreateErrorBuffer; 91 | WGPUProcDeviceCreateErrorExternalTexture deviceCreateErrorExternalTexture; 92 | WGPUProcDeviceCreateErrorShaderModule deviceCreateErrorShaderModule; 93 | WGPUProcDeviceCreateErrorTexture deviceCreateErrorTexture; 94 | WGPUProcDeviceCreateExternalTexture deviceCreateExternalTexture; 95 | WGPUProcDeviceCreatePipelineLayout deviceCreatePipelineLayout; 96 | WGPUProcDeviceCreateQuerySet deviceCreateQuerySet; 97 | WGPUProcDeviceCreateRenderBundleEncoder deviceCreateRenderBundleEncoder; 98 | WGPUProcDeviceCreateRenderPipeline deviceCreateRenderPipeline; 99 | WGPUProcDeviceCreateRenderPipelineAsync deviceCreateRenderPipelineAsync; 100 | WGPUProcDeviceCreateSampler deviceCreateSampler; 101 | WGPUProcDeviceCreateShaderModule deviceCreateShaderModule; 102 | WGPUProcDeviceCreateSwapChain deviceCreateSwapChain; 103 | WGPUProcDeviceCreateTexture deviceCreateTexture; 104 | WGPUProcDeviceDestroy deviceDestroy; 105 | WGPUProcDeviceEnumerateFeatures deviceEnumerateFeatures; 106 | WGPUProcDeviceForceLoss deviceForceLoss; 107 | WGPUProcDeviceGetAdapter deviceGetAdapter; 108 | WGPUProcDeviceGetLimits deviceGetLimits; 109 | WGPUProcDeviceGetQueue deviceGetQueue; 110 | WGPUProcDeviceGetSupportedSurfaceUsage deviceGetSupportedSurfaceUsage; 111 | WGPUProcDeviceHasFeature deviceHasFeature; 112 | WGPUProcDeviceInjectError deviceInjectError; 113 | WGPUProcDevicePopErrorScope devicePopErrorScope; 114 | WGPUProcDevicePushErrorScope devicePushErrorScope; 115 | WGPUProcDeviceSetDeviceLostCallback deviceSetDeviceLostCallback; 116 | WGPUProcDeviceSetLabel deviceSetLabel; 117 | WGPUProcDeviceSetLoggingCallback deviceSetLoggingCallback; 118 | WGPUProcDeviceSetUncapturedErrorCallback deviceSetUncapturedErrorCallback; 119 | WGPUProcDeviceTick deviceTick; 120 | WGPUProcDeviceValidateTextureDescriptor deviceValidateTextureDescriptor; 121 | WGPUProcDeviceReference deviceReference; 122 | WGPUProcDeviceRelease deviceRelease; 123 | 124 | WGPUProcExternalTextureDestroy externalTextureDestroy; 125 | WGPUProcExternalTextureExpire externalTextureExpire; 126 | WGPUProcExternalTextureRefresh externalTextureRefresh; 127 | WGPUProcExternalTextureSetLabel externalTextureSetLabel; 128 | WGPUProcExternalTextureReference externalTextureReference; 129 | WGPUProcExternalTextureRelease externalTextureRelease; 130 | 131 | WGPUProcInstanceCreateSurface instanceCreateSurface; 132 | WGPUProcInstanceProcessEvents instanceProcessEvents; 133 | WGPUProcInstanceRequestAdapter instanceRequestAdapter; 134 | WGPUProcInstanceReference instanceReference; 135 | WGPUProcInstanceRelease instanceRelease; 136 | 137 | WGPUProcPipelineLayoutSetLabel pipelineLayoutSetLabel; 138 | WGPUProcPipelineLayoutReference pipelineLayoutReference; 139 | WGPUProcPipelineLayoutRelease pipelineLayoutRelease; 140 | 141 | WGPUProcQuerySetDestroy querySetDestroy; 142 | WGPUProcQuerySetGetCount querySetGetCount; 143 | WGPUProcQuerySetGetType querySetGetType; 144 | WGPUProcQuerySetSetLabel querySetSetLabel; 145 | WGPUProcQuerySetReference querySetReference; 146 | WGPUProcQuerySetRelease querySetRelease; 147 | 148 | WGPUProcQueueCopyExternalTextureForBrowser queueCopyExternalTextureForBrowser; 149 | WGPUProcQueueCopyTextureForBrowser queueCopyTextureForBrowser; 150 | WGPUProcQueueOnSubmittedWorkDone queueOnSubmittedWorkDone; 151 | WGPUProcQueueSetLabel queueSetLabel; 152 | WGPUProcQueueSubmit queueSubmit; 153 | WGPUProcQueueWriteBuffer queueWriteBuffer; 154 | WGPUProcQueueWriteTexture queueWriteTexture; 155 | WGPUProcQueueReference queueReference; 156 | WGPUProcQueueRelease queueRelease; 157 | 158 | WGPUProcRenderBundleSetLabel renderBundleSetLabel; 159 | WGPUProcRenderBundleReference renderBundleReference; 160 | WGPUProcRenderBundleRelease renderBundleRelease; 161 | 162 | WGPUProcRenderBundleEncoderDraw renderBundleEncoderDraw; 163 | WGPUProcRenderBundleEncoderDrawIndexed renderBundleEncoderDrawIndexed; 164 | WGPUProcRenderBundleEncoderDrawIndexedIndirect renderBundleEncoderDrawIndexedIndirect; 165 | WGPUProcRenderBundleEncoderDrawIndirect renderBundleEncoderDrawIndirect; 166 | WGPUProcRenderBundleEncoderFinish renderBundleEncoderFinish; 167 | WGPUProcRenderBundleEncoderInsertDebugMarker renderBundleEncoderInsertDebugMarker; 168 | WGPUProcRenderBundleEncoderPopDebugGroup renderBundleEncoderPopDebugGroup; 169 | WGPUProcRenderBundleEncoderPushDebugGroup renderBundleEncoderPushDebugGroup; 170 | WGPUProcRenderBundleEncoderSetBindGroup renderBundleEncoderSetBindGroup; 171 | WGPUProcRenderBundleEncoderSetIndexBuffer renderBundleEncoderSetIndexBuffer; 172 | WGPUProcRenderBundleEncoderSetLabel renderBundleEncoderSetLabel; 173 | WGPUProcRenderBundleEncoderSetPipeline renderBundleEncoderSetPipeline; 174 | WGPUProcRenderBundleEncoderSetVertexBuffer renderBundleEncoderSetVertexBuffer; 175 | WGPUProcRenderBundleEncoderReference renderBundleEncoderReference; 176 | WGPUProcRenderBundleEncoderRelease renderBundleEncoderRelease; 177 | 178 | WGPUProcRenderPassEncoderBeginOcclusionQuery renderPassEncoderBeginOcclusionQuery; 179 | WGPUProcRenderPassEncoderDraw renderPassEncoderDraw; 180 | WGPUProcRenderPassEncoderDrawIndexed renderPassEncoderDrawIndexed; 181 | WGPUProcRenderPassEncoderDrawIndexedIndirect renderPassEncoderDrawIndexedIndirect; 182 | WGPUProcRenderPassEncoderDrawIndirect renderPassEncoderDrawIndirect; 183 | WGPUProcRenderPassEncoderEnd renderPassEncoderEnd; 184 | WGPUProcRenderPassEncoderEndOcclusionQuery renderPassEncoderEndOcclusionQuery; 185 | WGPUProcRenderPassEncoderExecuteBundles renderPassEncoderExecuteBundles; 186 | WGPUProcRenderPassEncoderInsertDebugMarker renderPassEncoderInsertDebugMarker; 187 | WGPUProcRenderPassEncoderPopDebugGroup renderPassEncoderPopDebugGroup; 188 | WGPUProcRenderPassEncoderPushDebugGroup renderPassEncoderPushDebugGroup; 189 | WGPUProcRenderPassEncoderSetBindGroup renderPassEncoderSetBindGroup; 190 | WGPUProcRenderPassEncoderSetBlendConstant renderPassEncoderSetBlendConstant; 191 | WGPUProcRenderPassEncoderSetIndexBuffer renderPassEncoderSetIndexBuffer; 192 | WGPUProcRenderPassEncoderSetLabel renderPassEncoderSetLabel; 193 | WGPUProcRenderPassEncoderSetPipeline renderPassEncoderSetPipeline; 194 | WGPUProcRenderPassEncoderSetScissorRect renderPassEncoderSetScissorRect; 195 | WGPUProcRenderPassEncoderSetStencilReference renderPassEncoderSetStencilReference; 196 | WGPUProcRenderPassEncoderSetVertexBuffer renderPassEncoderSetVertexBuffer; 197 | WGPUProcRenderPassEncoderSetViewport renderPassEncoderSetViewport; 198 | WGPUProcRenderPassEncoderWriteTimestamp renderPassEncoderWriteTimestamp; 199 | WGPUProcRenderPassEncoderReference renderPassEncoderReference; 200 | WGPUProcRenderPassEncoderRelease renderPassEncoderRelease; 201 | 202 | WGPUProcRenderPipelineGetBindGroupLayout renderPipelineGetBindGroupLayout; 203 | WGPUProcRenderPipelineSetLabel renderPipelineSetLabel; 204 | WGPUProcRenderPipelineReference renderPipelineReference; 205 | WGPUProcRenderPipelineRelease renderPipelineRelease; 206 | 207 | WGPUProcSamplerSetLabel samplerSetLabel; 208 | WGPUProcSamplerReference samplerReference; 209 | WGPUProcSamplerRelease samplerRelease; 210 | 211 | WGPUProcShaderModuleGetCompilationInfo shaderModuleGetCompilationInfo; 212 | WGPUProcShaderModuleSetLabel shaderModuleSetLabel; 213 | WGPUProcShaderModuleReference shaderModuleReference; 214 | WGPUProcShaderModuleRelease shaderModuleRelease; 215 | 216 | WGPUProcSurfaceReference surfaceReference; 217 | WGPUProcSurfaceRelease surfaceRelease; 218 | 219 | WGPUProcSwapChainGetCurrentTexture swapChainGetCurrentTexture; 220 | WGPUProcSwapChainGetCurrentTextureView swapChainGetCurrentTextureView; 221 | WGPUProcSwapChainPresent swapChainPresent; 222 | WGPUProcSwapChainReference swapChainReference; 223 | WGPUProcSwapChainRelease swapChainRelease; 224 | 225 | WGPUProcTextureCreateView textureCreateView; 226 | WGPUProcTextureDestroy textureDestroy; 227 | WGPUProcTextureGetDepthOrArrayLayers textureGetDepthOrArrayLayers; 228 | WGPUProcTextureGetDimension textureGetDimension; 229 | WGPUProcTextureGetFormat textureGetFormat; 230 | WGPUProcTextureGetHeight textureGetHeight; 231 | WGPUProcTextureGetMipLevelCount textureGetMipLevelCount; 232 | WGPUProcTextureGetSampleCount textureGetSampleCount; 233 | WGPUProcTextureGetUsage textureGetUsage; 234 | WGPUProcTextureGetWidth textureGetWidth; 235 | WGPUProcTextureSetLabel textureSetLabel; 236 | WGPUProcTextureReference textureReference; 237 | WGPUProcTextureRelease textureRelease; 238 | 239 | WGPUProcTextureViewSetLabel textureViewSetLabel; 240 | WGPUProcTextureViewReference textureViewReference; 241 | WGPUProcTextureViewRelease textureViewRelease; 242 | 243 | } DawnProcTable; 244 | 245 | #endif // DAWN_DAWN_PROC_TABLE_H_ 246 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/dawn_thread_dispatch_proc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_ 16 | #define INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_ 17 | 18 | #include "dawn/dawn_proc.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | // Call dawnProcSetProcs(&dawnThreadDispatchProcTable) and then use dawnProcSetPerThreadProcs 25 | // to set per-thread procs. 26 | WGPU_EXPORT extern DawnProcTable dawnThreadDispatchProcTable; 27 | WGPU_EXPORT void dawnProcSetPerThreadProcs(const DawnProcTable* procs); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif 32 | 33 | #endif // INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_ 34 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/D3D11Backend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "dawn/native/D3DBackend.h" 25 | 26 | namespace dawn::native::d3d11 { 27 | 28 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 29 | : public d3d::PhysicalDeviceDiscoveryOptions { 30 | PhysicalDeviceDiscoveryOptions(); 31 | explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr adapter); 32 | }; 33 | 34 | // TODO(dawn:1774): Deprecated. 35 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 36 | 37 | DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr GetD3D11Device(WGPUDevice device); 38 | 39 | } // namespace dawn::native::d3d11 40 | 41 | #endif // INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_ 42 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/D3D12Backend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "dawn/native/D3DBackend.h" 24 | 25 | struct ID3D12Device; 26 | struct ID3D12Resource; 27 | 28 | namespace dawn::native::d3d12 { 29 | 30 | class Device; 31 | 32 | enum MemorySegment { 33 | Local, 34 | NonLocal, 35 | }; 36 | 37 | DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device, 38 | uint64_t requestedReservationSize, 39 | MemorySegment memorySegment); 40 | 41 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 42 | : public d3d::PhysicalDeviceDiscoveryOptions { 43 | PhysicalDeviceDiscoveryOptions(); 44 | explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr adapter); 45 | }; 46 | 47 | // TODO(dawn:1774): Deprecated. 48 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 49 | 50 | } // namespace dawn::native::d3d12 51 | 52 | #endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_ 53 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/D3DBackend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_D3DBACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_D3DBACKEND_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include "dawn/native/DawnNative.h" 26 | #include "dawn/webgpu_cpp_chained_struct.h" 27 | 28 | namespace dawn::native::d3d { 29 | 30 | class ExternalImageDXGIImpl; 31 | 32 | DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr GetDXGIAdapter(WGPUAdapter adapter); 33 | 34 | // Can be chained in WGPURequestAdapterOptions 35 | struct DAWN_NATIVE_EXPORT RequestAdapterOptionsLUID : wgpu::ChainedStruct { 36 | RequestAdapterOptionsLUID(); 37 | 38 | ::LUID adapterLUID; 39 | }; 40 | 41 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 42 | : public PhysicalDeviceDiscoveryOptionsBase { 43 | PhysicalDeviceDiscoveryOptions(WGPUBackendType type, 44 | Microsoft::WRL::ComPtr adapter); 45 | Microsoft::WRL::ComPtr dxgiAdapter; 46 | }; 47 | 48 | // TODO(dawn:1774): Deprecated. 49 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 50 | 51 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor { 52 | public: 53 | ExternalImageDescriptorDXGISharedHandle(); 54 | 55 | // Note: SharedHandle must be a handle to a texture object. 56 | HANDLE sharedHandle = nullptr; 57 | }; 58 | 59 | struct DAWN_NATIVE_EXPORT ExternalImageDXGIFenceDescriptor { 60 | // Shared handle for the fence. This never passes ownership to the callee (when used as an input 61 | // parameter) or to the caller (when used as a return value or output parameter). 62 | HANDLE fenceHandle = nullptr; 63 | 64 | // The value that was previously signaled on this fence and should be waited on. 65 | uint64_t fenceValue = 0; 66 | }; 67 | 68 | struct DAWN_NATIVE_EXPORT ExternalImageDXGIBeginAccessDescriptor { 69 | bool isInitialized = false; // Whether the texture is initialized on import 70 | WGPUTextureUsageFlags usage = WGPUTextureUsage_None; 71 | 72 | // A list of fences to wait on before accessing the texture. 73 | std::vector waitFences; 74 | 75 | // Whether the texture is for a WebGPU swap chain. 76 | bool isSwapChainTexture = false; 77 | }; 78 | 79 | class DAWN_NATIVE_EXPORT ExternalImageDXGI { 80 | public: 81 | ~ExternalImageDXGI(); 82 | 83 | static std::unique_ptr Create( 84 | WGPUDevice device, 85 | const ExternalImageDescriptorDXGISharedHandle* descriptor); 86 | 87 | // Returns true if the external image resources are still valid, otherwise BeginAccess() is 88 | // guaranteed to fail e.g. after device destruction. 89 | bool IsValid() const; 90 | 91 | // Creates WGPUTexture wrapping the DXGI shared handle. The provided wait fences will be 92 | // synchronized before using the texture in any command lists. Empty fences (nullptr handle) are 93 | // ignored for convenience (EndAccess can return such fences). 94 | WGPUTexture BeginAccess(const ExternalImageDXGIBeginAccessDescriptor* descriptor); 95 | 96 | // Returns the signalFence that the client must wait on for correct synchronization. Can return 97 | // an empty fence (nullptr handle) if the texture wasn't accessed by Dawn. 98 | // Note that merely calling Destroy() on the WGPUTexture does not ensure synchronization. 99 | void EndAccess(WGPUTexture texture, ExternalImageDXGIFenceDescriptor* signalFence); 100 | 101 | private: 102 | explicit ExternalImageDXGI(std::unique_ptr impl); 103 | 104 | std::unique_ptr mImpl; 105 | }; 106 | 107 | } // namespace dawn::native::d3d 108 | 109 | #endif // INCLUDE_DAWN_NATIVE_D3DBACKEND_H_ 110 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/DawnNative.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_ 16 | #define INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "dawn/dawn_proc_table.h" 22 | #include "dawn/native/dawn_native_export.h" 23 | #include "dawn/webgpu.h" 24 | #include "dawn/webgpu_cpp_chained_struct.h" 25 | 26 | namespace dawn::platform { 27 | class Platform; 28 | } // namespace dawn::platform 29 | 30 | namespace wgpu { 31 | struct AdapterProperties; 32 | struct DeviceDescriptor; 33 | struct RequestAdapterOptions; 34 | } // namespace wgpu 35 | 36 | namespace dawn::native { 37 | 38 | class InstanceBase; 39 | class AdapterBase; 40 | 41 | // Each toggle is assigned with a TogglesStage, indicating the validation and earliest usage 42 | // time of the toggle. 43 | enum class ToggleStage { Instance, Adapter, Device }; 44 | 45 | // A struct to record the information of a toggle. A toggle is a code path in Dawn device that 46 | // can be manually configured to run or not outside Dawn, including workarounds, special 47 | // features and optimizations. 48 | struct ToggleInfo { 49 | const char* name; 50 | const char* description; 51 | const char* url; 52 | ToggleStage stage; 53 | }; 54 | 55 | // A struct to record the information of a feature. A feature is a GPU feature that is not 56 | // required to be supported by all Dawn backends and can only be used when it is enabled on the 57 | // creation of device. 58 | struct FeatureInfo { 59 | const char* name; 60 | const char* description; 61 | const char* url; 62 | // The enum of feature state, could be stable or experimental. Using an experimental feature 63 | // requires the AllowUnsafeAPIs toggle to be enabled. 64 | enum class FeatureState { Stable = 0, Experimental }; 65 | FeatureState featureState; 66 | }; 67 | 68 | // An adapter is an object that represent on possibility of creating devices in the system. 69 | // Most of the time it will represent a combination of a physical GPU and an API. Not that the 70 | // same GPU can be represented by multiple adapters but on different APIs. 71 | // 72 | // The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just 73 | // a reference to an underlying adapter. 74 | class DAWN_NATIVE_EXPORT Adapter { 75 | public: 76 | Adapter(); 77 | // NOLINTNEXTLINE(runtime/explicit) 78 | Adapter(AdapterBase* impl); 79 | ~Adapter(); 80 | 81 | Adapter(const Adapter& other); 82 | Adapter& operator=(const Adapter& other); 83 | 84 | // Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in 85 | // dawn.json 86 | void GetProperties(wgpu::AdapterProperties* properties) const; 87 | void GetProperties(WGPUAdapterProperties* properties) const; 88 | 89 | std::vector GetSupportedExtensions() const; 90 | std::vector GetSupportedFeatures() const; 91 | bool GetLimits(WGPUSupportedLimits* limits) const; 92 | 93 | void SetUseTieredLimits(bool useTieredLimits); 94 | 95 | // Check that the Adapter is able to support importing external images. This is necessary 96 | // to implement the swapchain and interop APIs in Chromium. 97 | bool SupportsExternalImages() const; 98 | 99 | explicit operator bool() const; 100 | 101 | // Create a device on this adapter. On an error, nullptr is returned. 102 | WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor); 103 | WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr); 104 | 105 | void RequestDevice(const wgpu::DeviceDescriptor* descriptor, 106 | WGPURequestDeviceCallback callback, 107 | void* userdata); 108 | void RequestDevice(const WGPUDeviceDescriptor* descriptor, 109 | WGPURequestDeviceCallback callback, 110 | void* userdata); 111 | void RequestDevice(std::nullptr_t descriptor, 112 | WGPURequestDeviceCallback callback, 113 | void* userdata) { 114 | RequestDevice(static_cast(descriptor), callback, userdata); 115 | } 116 | 117 | // Returns the underlying WGPUAdapter object. 118 | WGPUAdapter Get() const; 119 | 120 | // Reset the backend device object for testing purposes. 121 | void ResetInternalDeviceForTesting(); 122 | 123 | private: 124 | AdapterBase* mImpl = nullptr; 125 | }; 126 | 127 | // Base class for options passed to Instance::DiscoverPhysicalDevices. 128 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptionsBase { 129 | public: 130 | const WGPUBackendType backendType; 131 | 132 | protected: 133 | explicit PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType type); 134 | }; 135 | 136 | // Deprecated, use PhysicalDeviceDiscoveryOptionsBase instead. 137 | // TODO(dawn:1774): Remove this. 138 | using AdapterDiscoveryOptionsBase = PhysicalDeviceDiscoveryOptionsBase; 139 | 140 | enum BackendValidationLevel { Full, Partial, Disabled }; 141 | 142 | // Can be chained in InstanceDescriptor 143 | struct DAWN_NATIVE_EXPORT DawnInstanceDescriptor : wgpu::ChainedStruct { 144 | DawnInstanceDescriptor(); 145 | static constexpr size_t kFirstMemberAlignment = 146 | wgpu::detail::ConstexprMax(alignof(wgpu::ChainedStruct), alignof(uint32_t)); 147 | alignas(kFirstMemberAlignment) uint32_t additionalRuntimeSearchPathsCount = 0; 148 | const char* const* additionalRuntimeSearchPaths; 149 | dawn::platform::Platform* platform = nullptr; 150 | 151 | // Equality operators, mostly for testing. Note that this tests 152 | // strict pointer-pointer equality if the struct contains member pointers. 153 | bool operator==(const DawnInstanceDescriptor& rhs) const; 154 | }; 155 | 156 | // Represents a connection to dawn_native and is used for dependency injection, discovering 157 | // system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter). 158 | // 159 | // This is an RAII class for Dawn instances and also controls the lifetime of all adapters 160 | // for this instance. 161 | class DAWN_NATIVE_EXPORT Instance { 162 | public: 163 | explicit Instance(const WGPUInstanceDescriptor* desc = nullptr); 164 | ~Instance(); 165 | 166 | Instance(const Instance& other) = delete; 167 | Instance& operator=(const Instance& other) = delete; 168 | 169 | // Gather all physical devices in the system that can be accessed with no special options. 170 | void DiscoverDefaultPhysicalDevices(); 171 | 172 | // Adds physical devices that can be discovered with the options provided (like a 173 | // getProcAddress). The backend is chosen based on the type of the options used. Returns true on 174 | // success. 175 | bool DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options); 176 | 177 | // Deprecated, use DiscoverDefaultPhysicalDevices and DiscoverPhysicalDevices instead. 178 | // TODO(Dawn:1774): Remove these. 179 | void DiscoverDefaultAdapters(); 180 | bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options); 181 | 182 | // Discovers and returns a vector of adapters. 183 | // All systems adapters that can be found are returned if no options are passed. 184 | // Otherwise, returns adapters based on the `options`. Adapter toggles descriptor can chained 185 | // after options. 186 | std::vector EnumerateAdapters(const WGPURequestAdapterOptions* options) const; 187 | std::vector EnumerateAdapters( 188 | const wgpu::RequestAdapterOptions* options = nullptr) const; 189 | 190 | // Deprecated. Call EnumerateAdapters instead. 191 | std::vector GetAdapters() const; 192 | 193 | const ToggleInfo* GetToggleInfo(const char* toggleName); 194 | const FeatureInfo* GetFeatureInfo(WGPUFeatureName feature); 195 | 196 | // Enables backend validation layers 197 | void EnableBackendValidation(bool enableBackendValidation); 198 | void SetBackendValidationLevel(BackendValidationLevel validationLevel); 199 | 200 | // Enable debug capture on Dawn startup 201 | void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup); 202 | 203 | // Enable / disable the adapter blocklist. 204 | void EnableAdapterBlocklist(bool enable); 205 | 206 | uint64_t GetDeviceCountForTesting() const; 207 | 208 | // Returns the underlying WGPUInstance object. 209 | WGPUInstance Get() const; 210 | 211 | private: 212 | InstanceBase* mImpl = nullptr; 213 | }; 214 | 215 | // Backend-agnostic API for dawn_native 216 | DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs(); 217 | 218 | // Query the names of all the toggles that are enabled in device 219 | DAWN_NATIVE_EXPORT std::vector GetTogglesUsed(WGPUDevice device); 220 | 221 | // Backdoor to get the number of lazy clears for testing 222 | DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device); 223 | 224 | // Backdoor to get the number of deprecation warnings for testing 225 | DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device); 226 | 227 | // Backdoor to get the number of physical devices an instance knows about for testing 228 | DAWN_NATIVE_EXPORT size_t GetPhysicalDeviceCountForTesting(WGPUInstance instance); 229 | 230 | // Query if texture has been initialized 231 | DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized( 232 | WGPUTexture texture, 233 | uint32_t baseMipLevel, 234 | uint32_t levelCount, 235 | uint32_t baseArrayLayer, 236 | uint32_t layerCount, 237 | WGPUTextureAspect aspect = WGPUTextureAspect_All); 238 | 239 | // Backdoor to get the order of the ProcMap for testing 240 | DAWN_NATIVE_EXPORT std::vector GetProcMapNamesForTesting(); 241 | 242 | DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device); 243 | 244 | DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance); 245 | 246 | // ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp 247 | DAWN_NATIVE_EXPORT void EnableErrorInjector(); 248 | DAWN_NATIVE_EXPORT void DisableErrorInjector(); 249 | DAWN_NATIVE_EXPORT void ClearErrorInjector(); 250 | DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount(); 251 | DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index); 252 | 253 | // The different types of external images 254 | enum ExternalImageType { 255 | OpaqueFD, 256 | DmaBuf, 257 | IOSurface, 258 | DXGISharedHandle, 259 | EGLImage, 260 | AHardwareBuffer, 261 | }; 262 | 263 | // Common properties of external images 264 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptor { 265 | public: 266 | const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params 267 | bool isInitialized; // Whether the texture is initialized on import 268 | ExternalImageType GetType() const; 269 | 270 | protected: 271 | explicit ExternalImageDescriptor(ExternalImageType type); 272 | 273 | private: 274 | ExternalImageType mType; 275 | }; 276 | 277 | struct DAWN_NATIVE_EXPORT ExternalImageExportInfo { 278 | public: 279 | bool isInitialized = false; // Whether the texture is initialized after export 280 | ExternalImageType GetType() const; 281 | 282 | protected: 283 | explicit ExternalImageExportInfo(ExternalImageType type); 284 | 285 | private: 286 | ExternalImageType mType; 287 | }; 288 | 289 | DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle); 290 | 291 | DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle); 292 | 293 | DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer); 294 | 295 | DAWN_NATIVE_EXPORT bool BindGroupLayoutBindingsEqualForTesting(WGPUBindGroupLayout a, 296 | WGPUBindGroupLayout b); 297 | 298 | } // namespace dawn::native 299 | 300 | // Alias the DawnInstanceDescriptor up to wgpu. 301 | // TODO(dawn:1374) Remove this aliasing once the usages are updated. 302 | namespace wgpu { 303 | using dawn::native::DawnInstanceDescriptor; 304 | } // namespace wgpu 305 | 306 | // TODO(dawn:824): Remove once the deprecation period is passed. 307 | namespace dawn_native = dawn::native; 308 | 309 | #endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_ 310 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/MetalBackend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_METALBACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_METALBACKEND_H_ 17 | 18 | #include 19 | 20 | #include "dawn/native/DawnNative.h" 21 | 22 | // The specifics of the Metal backend expose types in function signatures that might not be 23 | // available in dependent's minimum supported SDK version. Suppress all availability errors using 24 | // clang's pragmas. Dependents using the types without guarded availability will still get errors 25 | // when using the types. 26 | #pragma clang diagnostic push 27 | #pragma clang diagnostic ignored "-Wunguarded-availability" 28 | 29 | struct __IOSurface; 30 | typedef __IOSurface* IOSurfaceRef; 31 | 32 | #ifdef __OBJC__ 33 | #import 34 | #endif // __OBJC__ 35 | 36 | namespace dawn::native::metal { 37 | 38 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 39 | : public PhysicalDeviceDiscoveryOptionsBase { 40 | PhysicalDeviceDiscoveryOptions(); 41 | }; 42 | 43 | // TODO(dawn:1774): Deprecated. 44 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 45 | 46 | struct DAWN_NATIVE_EXPORT ExternalImageMTLSharedEventDescriptor { 47 | // Shared event handle `id`. 48 | // This never passes ownership to the callee (when used as an input 49 | // parameter) or to the caller (when used as a return value or output parameter). 50 | #ifdef __OBJC__ 51 | id sharedEvent = nil; 52 | static_assert(sizeof(id) == sizeof(void*)); 53 | static_assert(alignof(id) == alignof(void*)); 54 | #else 55 | void* sharedEvent = nullptr; 56 | #endif 57 | 58 | // The value that was previously signaled on this event and should be waited on. 59 | uint64_t signaledValue = 0; 60 | }; 61 | 62 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorIOSurface : ExternalImageDescriptor { 63 | public: 64 | ExternalImageDescriptorIOSurface(); 65 | ~ExternalImageDescriptorIOSurface(); 66 | 67 | IOSurfaceRef ioSurface; 68 | 69 | // A list of events to wait on before accessing the texture. 70 | std::vector waitEvents; 71 | }; 72 | 73 | struct DAWN_NATIVE_EXPORT ExternalImageIOSurfaceEndAccessDescriptor 74 | : ExternalImageMTLSharedEventDescriptor { 75 | bool isInitialized; 76 | }; 77 | 78 | DAWN_NATIVE_EXPORT WGPUTexture WrapIOSurface(WGPUDevice device, 79 | const ExternalImageDescriptorIOSurface* descriptor); 80 | 81 | DAWN_NATIVE_EXPORT void IOSurfaceEndAccess(WGPUTexture texture, 82 | ExternalImageIOSurfaceEndAccessDescriptor* descriptor); 83 | 84 | // When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't 85 | // mean that the operations will be visible to other APIs/Metal devices right away. macOS 86 | // does have a global queue of graphics operations, but the command buffers are inserted there 87 | // when they are "scheduled". Submitting other operations before the command buffer is 88 | // scheduled could lead to races in who gets scheduled first and incorrect rendering. 89 | DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device); 90 | 91 | } // namespace dawn::native::metal 92 | 93 | #pragma clang diagnostic pop 94 | 95 | #endif // INCLUDE_DAWN_NATIVE_METALBACKEND_H_ 96 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/NullBackend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_NULLBACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_NULLBACKEND_H_ 17 | 18 | #include "dawn/native/DawnNative.h" 19 | 20 | namespace dawn::native::null { 21 | 22 | // Nothing for now \o/ 23 | 24 | } // namespace dawn::native::null 25 | 26 | #endif // INCLUDE_DAWN_NATIVE_NULLBACKEND_H_ 27 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/OpenGLBackend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_ 17 | 18 | typedef void* EGLImage; 19 | 20 | #include "dawn/native/DawnNative.h" 21 | #include "dawn/webgpu_cpp_chained_struct.h" 22 | 23 | namespace dawn::native::opengl { 24 | 25 | // Can be chained in WGPURequestAdapterOptions 26 | struct DAWN_NATIVE_EXPORT RequestAdapterOptionsGetGLProc : wgpu::ChainedStruct { 27 | RequestAdapterOptionsGetGLProc(); 28 | 29 | void* (*getProc)(const char*); 30 | }; 31 | 32 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 33 | : public PhysicalDeviceDiscoveryOptionsBase { 34 | explicit PhysicalDeviceDiscoveryOptions(WGPUBackendType type); 35 | 36 | void* (*getProc)(const char*); 37 | }; 38 | 39 | // TODO(dawn:1774): Deprecated. 40 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 41 | 42 | // TODO(crbug.com/dawn/810): This struct can be removed once Chrome is no longer using it. 43 | struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public PhysicalDeviceDiscoveryOptions { 44 | AdapterDiscoveryOptionsES(); 45 | }; 46 | 47 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor { 48 | public: 49 | ExternalImageDescriptorEGLImage(); 50 | 51 | ::EGLImage image; 52 | }; 53 | 54 | DAWN_NATIVE_EXPORT WGPUTexture 55 | WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor); 56 | 57 | } // namespace dawn::native::opengl 58 | 59 | #endif // INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_ 60 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/VulkanBackend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_ 16 | #define INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "dawn/native/DawnNative.h" 24 | 25 | namespace dawn::native::vulkan { 26 | 27 | DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device); 28 | 29 | DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName); 30 | 31 | struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions 32 | : public PhysicalDeviceDiscoveryOptionsBase { 33 | PhysicalDeviceDiscoveryOptions(); 34 | 35 | bool forceSwiftShader = false; 36 | }; 37 | 38 | // TODO(dawn:1774): Deprecated. 39 | using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions; 40 | 41 | enum class NeedsDedicatedAllocation { 42 | Yes, 43 | No, 44 | // Use Vulkan reflection to detect whether a dedicated allocation is needed. 45 | Detect, 46 | }; 47 | 48 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorVk : ExternalImageDescriptor { 49 | public: 50 | // The following members may be ignored if |ExternalImageDescriptor::isInitialized| is false 51 | // since the import does not need to preserve texture contents. 52 | 53 | // See https://www.khronos.org/registry/vulkan/specs/1.1/html/chap7.html. The acquire 54 | // operation old/new layouts must match exactly the layouts in the release operation. So 55 | // we may need to issue two barriers releasedOldLayout -> releasedNewLayout -> 56 | // cTextureDescriptor.usage if the new layout is not compatible with the desired usage. 57 | // The first barrier is the queue transfer, the second is the layout transition to our 58 | // desired usage. 59 | VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_GENERAL; 60 | VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_GENERAL; 61 | 62 | // Try to detect the need to use a dedicated allocation for imported images by default but let 63 | // the application override this as drivers have bugs and forget to require a dedicated 64 | // allocation. 65 | NeedsDedicatedAllocation dedicatedAllocation = NeedsDedicatedAllocation::Detect; 66 | 67 | protected: 68 | using ExternalImageDescriptor::ExternalImageDescriptor; 69 | }; 70 | 71 | struct ExternalImageExportInfoVk : ExternalImageExportInfo { 72 | public: 73 | // See comments in |ExternalImageDescriptorVk| 74 | // Contains the old/new layouts used in the queue release operation. 75 | VkImageLayout releasedOldLayout; 76 | VkImageLayout releasedNewLayout; 77 | 78 | protected: 79 | using ExternalImageExportInfo::ExternalImageExportInfo; 80 | }; 81 | 82 | // Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome 83 | #ifdef __linux__ 84 | 85 | // Common properties of external images represented by FDs. On successful import the file 86 | // descriptor's ownership is transferred to the Dawn implementation and they shouldn't be 87 | // used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the 88 | // caller can assume the FD is always consumed. 89 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptorVk { 90 | public: 91 | int memoryFD; // A file descriptor from an export of the memory of the image 92 | std::vector waitFDs; // File descriptors of semaphores which will be waited on 93 | 94 | protected: 95 | using ExternalImageDescriptorVk::ExternalImageDescriptorVk; 96 | }; 97 | 98 | // Descriptor for opaque file descriptor image import 99 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD { 100 | ExternalImageDescriptorOpaqueFD(); 101 | 102 | VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation 103 | uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation 104 | }; 105 | 106 | // The plane-wise offset and stride. 107 | struct DAWN_NATIVE_EXPORT PlaneLayout { 108 | uint64_t offset; 109 | uint32_t stride; 110 | }; 111 | 112 | // Descriptor for dma-buf file descriptor image import 113 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD { 114 | ExternalImageDescriptorDmaBuf(); 115 | 116 | static constexpr uint32_t kMaxPlanes = 3; 117 | std::array planeLayouts; 118 | uint64_t drmModifier; // DRM modifier of the buffer 119 | }; 120 | 121 | // Info struct that is written to in |ExportVulkanImage|. 122 | struct DAWN_NATIVE_EXPORT ExternalImageExportInfoFD : ExternalImageExportInfoVk { 123 | public: 124 | // Contains the exported semaphore handles. 125 | std::vector semaphoreHandles; 126 | 127 | protected: 128 | using ExternalImageExportInfoVk::ExternalImageExportInfoVk; 129 | }; 130 | 131 | struct DAWN_NATIVE_EXPORT ExternalImageExportInfoOpaqueFD : ExternalImageExportInfoFD { 132 | ExternalImageExportInfoOpaqueFD(); 133 | }; 134 | 135 | struct DAWN_NATIVE_EXPORT ExternalImageExportInfoDmaBuf : ExternalImageExportInfoFD { 136 | ExternalImageExportInfoDmaBuf(); 137 | }; 138 | 139 | #ifdef __ANDROID__ 140 | 141 | // Descriptor for AHardwareBuffer image import 142 | struct DAWN_NATIVE_EXPORT ExternalImageDescriptorAHardwareBuffer : ExternalImageDescriptorVk { 143 | public: 144 | ExternalImageDescriptorAHardwareBuffer(); 145 | 146 | struct AHardwareBuffer* handle; // The AHardwareBuffer which contains the memory of the image 147 | std::vector waitFDs; // File descriptors of semaphores which will be waited on 148 | 149 | protected: 150 | using ExternalImageDescriptorVk::ExternalImageDescriptorVk; 151 | }; 152 | 153 | struct DAWN_NATIVE_EXPORT ExternalImageExportInfoAHardwareBuffer : ExternalImageExportInfoFD { 154 | ExternalImageExportInfoAHardwareBuffer(); 155 | }; 156 | 157 | #endif // __ANDROID__ 158 | 159 | #endif // __linux__ 160 | 161 | // Imports external memory into a Vulkan image. Internally, this uses external memory / 162 | // semaphore extensions to import the image and wait on the provided synchronizaton 163 | // primitives before the texture can be used. 164 | // On failure, returns a nullptr. 165 | DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice device, 166 | const ExternalImageDescriptorVk* descriptor); 167 | 168 | // Exports external memory from a Vulkan image. This must be called on wrapped textures 169 | // before they are destroyed. It writes the semaphore to wait on and the old/new image 170 | // layouts to |info|. Pass VK_IMAGE_LAYOUT_UNDEFINED as |desiredLayout| if you don't want to 171 | // perform a layout transition. 172 | DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture, 173 | VkImageLayout desiredLayout, 174 | ExternalImageExportInfoVk* info); 175 | // |ExportVulkanImage| with default desiredLayout of VK_IMAGE_LAYOUT_UNDEFINED. 176 | DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture, ExternalImageExportInfoVk* info); 177 | 178 | } // namespace dawn::native::vulkan 179 | 180 | #endif // INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_ 181 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/native/dawn_native_export.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_ 16 | #define INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_ 17 | 18 | #if defined(DAWN_NATIVE_SHARED_LIBRARY) 19 | #if defined(_WIN32) 20 | #if defined(DAWN_NATIVE_IMPLEMENTATION) 21 | #define DAWN_NATIVE_EXPORT __declspec(dllexport) 22 | #else 23 | #define DAWN_NATIVE_EXPORT __declspec(dllimport) 24 | #endif 25 | #else // defined(_WIN32) 26 | #if defined(DAWN_NATIVE_IMPLEMENTATION) 27 | #define DAWN_NATIVE_EXPORT __attribute__((visibility("default"))) 28 | #else 29 | #define DAWN_NATIVE_EXPORT 30 | #endif 31 | #endif // defined(_WIN32) 32 | #else // defined(DAWN_NATIVE_SHARED_LIBRARY) 33 | #define DAWN_NATIVE_EXPORT 34 | #endif // defined(DAWN_NATIVE_SHARED_LIBRARY) 35 | 36 | #endif // INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_ 37 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/platform/DawnPlatform.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_ 16 | #define INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "dawn/platform/dawn_platform_export.h" 23 | #include "dawn/webgpu.h" 24 | 25 | namespace dawn::platform { 26 | 27 | enum class TraceCategory { 28 | General, // General trace events 29 | Validation, // Dawn validation 30 | Recording, // Native command recording 31 | GPUWork, // Actual GPU work 32 | }; 33 | 34 | class DAWN_PLATFORM_EXPORT CachingInterface { 35 | public: 36 | CachingInterface(); 37 | virtual ~CachingInterface(); 38 | 39 | // LoadData has two modes. The first mode is used to get a value which 40 | // corresponds to the |key|. The |valueOut| is a caller provided buffer 41 | // allocated to the size |valueSize| which is loaded with data of the 42 | // size returned. The second mode is used to query for the existence of 43 | // the |key| where |valueOut| is nullptr and |valueSize| must be 0. 44 | // The return size is non-zero if the |key| exists. 45 | virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0; 46 | 47 | // StoreData puts a |value| in the cache which corresponds to the |key|. 48 | virtual void StoreData(const void* key, 49 | size_t keySize, 50 | const void* value, 51 | size_t valueSize) = 0; 52 | 53 | private: 54 | CachingInterface(const CachingInterface&) = delete; 55 | CachingInterface& operator=(const CachingInterface&) = delete; 56 | }; 57 | 58 | class DAWN_PLATFORM_EXPORT WaitableEvent { 59 | public: 60 | WaitableEvent() = default; 61 | virtual ~WaitableEvent() = default; 62 | virtual void Wait() = 0; // Wait for completion 63 | virtual bool IsComplete() = 0; // Non-blocking check if the event is complete 64 | }; 65 | 66 | using PostWorkerTaskCallback = void (*)(void* userdata); 67 | 68 | class DAWN_PLATFORM_EXPORT WorkerTaskPool { 69 | public: 70 | WorkerTaskPool() = default; 71 | virtual ~WorkerTaskPool() = default; 72 | virtual std::unique_ptr PostWorkerTask(PostWorkerTaskCallback, 73 | void* userdata) = 0; 74 | }; 75 | 76 | class DAWN_PLATFORM_EXPORT Platform { 77 | public: 78 | Platform(); 79 | virtual ~Platform(); 80 | 81 | virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category); 82 | 83 | virtual double MonotonicallyIncreasingTime(); 84 | 85 | virtual uint64_t AddTraceEvent(char phase, 86 | const unsigned char* categoryGroupEnabled, 87 | const char* name, 88 | uint64_t id, 89 | double timestamp, 90 | int numArgs, 91 | const char** argNames, 92 | const unsigned char* argTypes, 93 | const uint64_t* argValues, 94 | unsigned char flags); 95 | 96 | // Invoked to add a UMA histogram count-based sample 97 | virtual void HistogramCustomCounts(const char* name, 98 | int sample, 99 | int min, 100 | int max, 101 | int bucketCount); 102 | 103 | // Invoked to add a UMA histogram enumeration sample 104 | virtual void HistogramEnumeration(const char* name, int sample, int boundaryValue); 105 | 106 | // Invoked to add a UMA histogram sparse sample 107 | virtual void HistogramSparse(const char* name, int sample); 108 | 109 | // Invoked to add a UMA histogram boolean sample 110 | virtual void HistogramBoolean(const char* name, bool sample); 111 | 112 | // The returned CachingInterface is expected to outlive the device which uses it to persistently 113 | // cache objects. 114 | virtual CachingInterface* GetCachingInterface(); 115 | 116 | virtual std::unique_ptr CreateWorkerTaskPool(); 117 | 118 | private: 119 | Platform(const Platform&) = delete; 120 | Platform& operator=(const Platform&) = delete; 121 | }; 122 | 123 | } // namespace dawn::platform 124 | 125 | // TODO(dawn:824): Remove once the deprecation period is passed. 126 | namespace dawn_platform = dawn::platform; 127 | 128 | #endif // INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_ 129 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/platform/dawn_platform_export.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_ 16 | #define INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_ 17 | 18 | #if defined(DAWN_PLATFORM_SHARED_LIBRARY) 19 | #if defined(_WIN32) 20 | #if defined(DAWN_PLATFORM_IMPLEMENTATION) 21 | #define DAWN_PLATFORM_EXPORT __declspec(dllexport) 22 | #else 23 | #define DAWN_PLATFORM_EXPORT __declspec(dllimport) 24 | #endif 25 | #else // defined(_WIN32) 26 | #if defined(DAWN_PLATFORM_IMPLEMENTATION) 27 | #define DAWN_PLATFORM_EXPORT __attribute__((visibility("default"))) 28 | #else 29 | #define DAWN_PLATFORM_EXPORT 30 | #endif 31 | #endif // defined(_WIN32) 32 | #else // defined(DAWN_PLATFORM_SHARED_LIBRARY) 33 | #define DAWN_PLATFORM_EXPORT 34 | #endif // defined(DAWN_PLATFORM_SHARED_LIBRARY) 35 | 36 | #endif // INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_ 37 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/webgpu_cpp_chained_struct.h: -------------------------------------------------------------------------------- 1 | #ifdef __EMSCRIPTEN__ 2 | #error "Do not include this header. Emscripten already provides headers needed for WebGPU." 3 | #endif 4 | #ifndef WEBGPU_CPP_CHAINED_STRUCT_H_ 5 | #define WEBGPU_CPP_CHAINED_STRUCT_H_ 6 | 7 | #include 8 | #include 9 | 10 | // This header file declares the ChainedStruct structures separately from the WebGPU 11 | // headers so that dependencies can directly extend structures without including the larger header 12 | // which exposes capabilities that may require correctly set proc tables. 13 | namespace wgpu { 14 | 15 | namespace detail { 16 | constexpr size_t ConstexprMax(size_t a, size_t b) { 17 | return a > b ? a : b; 18 | } 19 | } // namespace detail 20 | 21 | enum class SType : uint32_t; 22 | 23 | struct ChainedStruct { 24 | ChainedStruct const * nextInChain = nullptr; 25 | SType sType = SType(0u); 26 | }; 27 | 28 | struct ChainedStructOut { 29 | ChainedStructOut * nextInChain = nullptr; 30 | SType sType = SType(0u); 31 | }; 32 | 33 | } // namespace wgpu} 34 | 35 | #endif // WEBGPU_CPP_CHAINED_STRUCT_H_ 36 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/webgpu_cpp_print.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WEBGPU_CPP_PRINT_H_ 3 | #define WEBGPU_CPP_PRINT_H_ 4 | 5 | #include "dawn/webgpu_cpp.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace wgpu { 13 | 14 | template 15 | std::basic_ostream& operator<<(std::basic_ostream& o, AdapterType value) { 16 | switch (value) { 17 | case AdapterType::DiscreteGPU: 18 | o << "AdapterType::DiscreteGPU"; 19 | break; 20 | case AdapterType::IntegratedGPU: 21 | o << "AdapterType::IntegratedGPU"; 22 | break; 23 | case AdapterType::CPU: 24 | o << "AdapterType::CPU"; 25 | break; 26 | case AdapterType::Unknown: 27 | o << "AdapterType::Unknown"; 28 | break; 29 | default: 30 | o << "AdapterType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 31 | } 32 | return o; 33 | } 34 | template 35 | std::basic_ostream& operator<<(std::basic_ostream& o, AddressMode value) { 36 | switch (value) { 37 | case AddressMode::Repeat: 38 | o << "AddressMode::Repeat"; 39 | break; 40 | case AddressMode::MirrorRepeat: 41 | o << "AddressMode::MirrorRepeat"; 42 | break; 43 | case AddressMode::ClampToEdge: 44 | o << "AddressMode::ClampToEdge"; 45 | break; 46 | default: 47 | o << "AddressMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 48 | } 49 | return o; 50 | } 51 | template 52 | std::basic_ostream& operator<<(std::basic_ostream& o, AlphaMode value) { 53 | switch (value) { 54 | case AlphaMode::Premultiplied: 55 | o << "AlphaMode::Premultiplied"; 56 | break; 57 | case AlphaMode::Unpremultiplied: 58 | o << "AlphaMode::Unpremultiplied"; 59 | break; 60 | case AlphaMode::Opaque: 61 | o << "AlphaMode::Opaque"; 62 | break; 63 | default: 64 | o << "AlphaMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 65 | } 66 | return o; 67 | } 68 | template 69 | std::basic_ostream& operator<<(std::basic_ostream& o, BackendType value) { 70 | switch (value) { 71 | case BackendType::Undefined: 72 | o << "BackendType::Undefined"; 73 | break; 74 | case BackendType::Null: 75 | o << "BackendType::Null"; 76 | break; 77 | case BackendType::WebGPU: 78 | o << "BackendType::WebGPU"; 79 | break; 80 | case BackendType::D3D11: 81 | o << "BackendType::D3D11"; 82 | break; 83 | case BackendType::D3D12: 84 | o << "BackendType::D3D12"; 85 | break; 86 | case BackendType::Metal: 87 | o << "BackendType::Metal"; 88 | break; 89 | case BackendType::Vulkan: 90 | o << "BackendType::Vulkan"; 91 | break; 92 | case BackendType::OpenGL: 93 | o << "BackendType::OpenGL"; 94 | break; 95 | case BackendType::OpenGLES: 96 | o << "BackendType::OpenGLES"; 97 | break; 98 | default: 99 | o << "BackendType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 100 | } 101 | return o; 102 | } 103 | template 104 | std::basic_ostream& operator<<(std::basic_ostream& o, BlendFactor value) { 105 | switch (value) { 106 | case BlendFactor::Zero: 107 | o << "BlendFactor::Zero"; 108 | break; 109 | case BlendFactor::One: 110 | o << "BlendFactor::One"; 111 | break; 112 | case BlendFactor::Src: 113 | o << "BlendFactor::Src"; 114 | break; 115 | case BlendFactor::OneMinusSrc: 116 | o << "BlendFactor::OneMinusSrc"; 117 | break; 118 | case BlendFactor::SrcAlpha: 119 | o << "BlendFactor::SrcAlpha"; 120 | break; 121 | case BlendFactor::OneMinusSrcAlpha: 122 | o << "BlendFactor::OneMinusSrcAlpha"; 123 | break; 124 | case BlendFactor::Dst: 125 | o << "BlendFactor::Dst"; 126 | break; 127 | case BlendFactor::OneMinusDst: 128 | o << "BlendFactor::OneMinusDst"; 129 | break; 130 | case BlendFactor::DstAlpha: 131 | o << "BlendFactor::DstAlpha"; 132 | break; 133 | case BlendFactor::OneMinusDstAlpha: 134 | o << "BlendFactor::OneMinusDstAlpha"; 135 | break; 136 | case BlendFactor::SrcAlphaSaturated: 137 | o << "BlendFactor::SrcAlphaSaturated"; 138 | break; 139 | case BlendFactor::Constant: 140 | o << "BlendFactor::Constant"; 141 | break; 142 | case BlendFactor::OneMinusConstant: 143 | o << "BlendFactor::OneMinusConstant"; 144 | break; 145 | default: 146 | o << "BlendFactor::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 147 | } 148 | return o; 149 | } 150 | template 151 | std::basic_ostream& operator<<(std::basic_ostream& o, BlendOperation value) { 152 | switch (value) { 153 | case BlendOperation::Add: 154 | o << "BlendOperation::Add"; 155 | break; 156 | case BlendOperation::Subtract: 157 | o << "BlendOperation::Subtract"; 158 | break; 159 | case BlendOperation::ReverseSubtract: 160 | o << "BlendOperation::ReverseSubtract"; 161 | break; 162 | case BlendOperation::Min: 163 | o << "BlendOperation::Min"; 164 | break; 165 | case BlendOperation::Max: 166 | o << "BlendOperation::Max"; 167 | break; 168 | default: 169 | o << "BlendOperation::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 170 | } 171 | return o; 172 | } 173 | template 174 | std::basic_ostream& operator<<(std::basic_ostream& o, BufferBindingType value) { 175 | switch (value) { 176 | case BufferBindingType::Undefined: 177 | o << "BufferBindingType::Undefined"; 178 | break; 179 | case BufferBindingType::Uniform: 180 | o << "BufferBindingType::Uniform"; 181 | break; 182 | case BufferBindingType::Storage: 183 | o << "BufferBindingType::Storage"; 184 | break; 185 | case BufferBindingType::ReadOnlyStorage: 186 | o << "BufferBindingType::ReadOnlyStorage"; 187 | break; 188 | default: 189 | o << "BufferBindingType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 190 | } 191 | return o; 192 | } 193 | template 194 | std::basic_ostream& operator<<(std::basic_ostream& o, BufferMapAsyncStatus value) { 195 | switch (value) { 196 | case BufferMapAsyncStatus::Success: 197 | o << "BufferMapAsyncStatus::Success"; 198 | break; 199 | case BufferMapAsyncStatus::ValidationError: 200 | o << "BufferMapAsyncStatus::ValidationError"; 201 | break; 202 | case BufferMapAsyncStatus::Unknown: 203 | o << "BufferMapAsyncStatus::Unknown"; 204 | break; 205 | case BufferMapAsyncStatus::DeviceLost: 206 | o << "BufferMapAsyncStatus::DeviceLost"; 207 | break; 208 | case BufferMapAsyncStatus::DestroyedBeforeCallback: 209 | o << "BufferMapAsyncStatus::DestroyedBeforeCallback"; 210 | break; 211 | case BufferMapAsyncStatus::UnmappedBeforeCallback: 212 | o << "BufferMapAsyncStatus::UnmappedBeforeCallback"; 213 | break; 214 | case BufferMapAsyncStatus::MappingAlreadyPending: 215 | o << "BufferMapAsyncStatus::MappingAlreadyPending"; 216 | break; 217 | case BufferMapAsyncStatus::OffsetOutOfRange: 218 | o << "BufferMapAsyncStatus::OffsetOutOfRange"; 219 | break; 220 | case BufferMapAsyncStatus::SizeOutOfRange: 221 | o << "BufferMapAsyncStatus::SizeOutOfRange"; 222 | break; 223 | default: 224 | o << "BufferMapAsyncStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 225 | } 226 | return o; 227 | } 228 | template 229 | std::basic_ostream& operator<<(std::basic_ostream& o, BufferMapState value) { 230 | switch (value) { 231 | case BufferMapState::Unmapped: 232 | o << "BufferMapState::Unmapped"; 233 | break; 234 | case BufferMapState::Pending: 235 | o << "BufferMapState::Pending"; 236 | break; 237 | case BufferMapState::Mapped: 238 | o << "BufferMapState::Mapped"; 239 | break; 240 | default: 241 | o << "BufferMapState::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 242 | } 243 | return o; 244 | } 245 | template 246 | std::basic_ostream& operator<<(std::basic_ostream& o, CompareFunction value) { 247 | switch (value) { 248 | case CompareFunction::Undefined: 249 | o << "CompareFunction::Undefined"; 250 | break; 251 | case CompareFunction::Never: 252 | o << "CompareFunction::Never"; 253 | break; 254 | case CompareFunction::Less: 255 | o << "CompareFunction::Less"; 256 | break; 257 | case CompareFunction::LessEqual: 258 | o << "CompareFunction::LessEqual"; 259 | break; 260 | case CompareFunction::Greater: 261 | o << "CompareFunction::Greater"; 262 | break; 263 | case CompareFunction::GreaterEqual: 264 | o << "CompareFunction::GreaterEqual"; 265 | break; 266 | case CompareFunction::Equal: 267 | o << "CompareFunction::Equal"; 268 | break; 269 | case CompareFunction::NotEqual: 270 | o << "CompareFunction::NotEqual"; 271 | break; 272 | case CompareFunction::Always: 273 | o << "CompareFunction::Always"; 274 | break; 275 | default: 276 | o << "CompareFunction::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 277 | } 278 | return o; 279 | } 280 | template 281 | std::basic_ostream& operator<<(std::basic_ostream& o, CompilationInfoRequestStatus value) { 282 | switch (value) { 283 | case CompilationInfoRequestStatus::Success: 284 | o << "CompilationInfoRequestStatus::Success"; 285 | break; 286 | case CompilationInfoRequestStatus::Error: 287 | o << "CompilationInfoRequestStatus::Error"; 288 | break; 289 | case CompilationInfoRequestStatus::DeviceLost: 290 | o << "CompilationInfoRequestStatus::DeviceLost"; 291 | break; 292 | case CompilationInfoRequestStatus::Unknown: 293 | o << "CompilationInfoRequestStatus::Unknown"; 294 | break; 295 | default: 296 | o << "CompilationInfoRequestStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 297 | } 298 | return o; 299 | } 300 | template 301 | std::basic_ostream& operator<<(std::basic_ostream& o, CompilationMessageType value) { 302 | switch (value) { 303 | case CompilationMessageType::Error: 304 | o << "CompilationMessageType::Error"; 305 | break; 306 | case CompilationMessageType::Warning: 307 | o << "CompilationMessageType::Warning"; 308 | break; 309 | case CompilationMessageType::Info: 310 | o << "CompilationMessageType::Info"; 311 | break; 312 | default: 313 | o << "CompilationMessageType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 314 | } 315 | return o; 316 | } 317 | template 318 | std::basic_ostream& operator<<(std::basic_ostream& o, ComputePassTimestampLocation value) { 319 | switch (value) { 320 | case ComputePassTimestampLocation::Beginning: 321 | o << "ComputePassTimestampLocation::Beginning"; 322 | break; 323 | case ComputePassTimestampLocation::End: 324 | o << "ComputePassTimestampLocation::End"; 325 | break; 326 | default: 327 | o << "ComputePassTimestampLocation::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 328 | } 329 | return o; 330 | } 331 | template 332 | std::basic_ostream& operator<<(std::basic_ostream& o, CreatePipelineAsyncStatus value) { 333 | switch (value) { 334 | case CreatePipelineAsyncStatus::Success: 335 | o << "CreatePipelineAsyncStatus::Success"; 336 | break; 337 | case CreatePipelineAsyncStatus::ValidationError: 338 | o << "CreatePipelineAsyncStatus::ValidationError"; 339 | break; 340 | case CreatePipelineAsyncStatus::InternalError: 341 | o << "CreatePipelineAsyncStatus::InternalError"; 342 | break; 343 | case CreatePipelineAsyncStatus::DeviceLost: 344 | o << "CreatePipelineAsyncStatus::DeviceLost"; 345 | break; 346 | case CreatePipelineAsyncStatus::DeviceDestroyed: 347 | o << "CreatePipelineAsyncStatus::DeviceDestroyed"; 348 | break; 349 | case CreatePipelineAsyncStatus::Unknown: 350 | o << "CreatePipelineAsyncStatus::Unknown"; 351 | break; 352 | default: 353 | o << "CreatePipelineAsyncStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 354 | } 355 | return o; 356 | } 357 | template 358 | std::basic_ostream& operator<<(std::basic_ostream& o, CullMode value) { 359 | switch (value) { 360 | case CullMode::None: 361 | o << "CullMode::None"; 362 | break; 363 | case CullMode::Front: 364 | o << "CullMode::Front"; 365 | break; 366 | case CullMode::Back: 367 | o << "CullMode::Back"; 368 | break; 369 | default: 370 | o << "CullMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 371 | } 372 | return o; 373 | } 374 | template 375 | std::basic_ostream& operator<<(std::basic_ostream& o, DeviceLostReason value) { 376 | switch (value) { 377 | case DeviceLostReason::Undefined: 378 | o << "DeviceLostReason::Undefined"; 379 | break; 380 | case DeviceLostReason::Destroyed: 381 | o << "DeviceLostReason::Destroyed"; 382 | break; 383 | default: 384 | o << "DeviceLostReason::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 385 | } 386 | return o; 387 | } 388 | template 389 | std::basic_ostream& operator<<(std::basic_ostream& o, ErrorFilter value) { 390 | switch (value) { 391 | case ErrorFilter::Validation: 392 | o << "ErrorFilter::Validation"; 393 | break; 394 | case ErrorFilter::OutOfMemory: 395 | o << "ErrorFilter::OutOfMemory"; 396 | break; 397 | case ErrorFilter::Internal: 398 | o << "ErrorFilter::Internal"; 399 | break; 400 | default: 401 | o << "ErrorFilter::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 402 | } 403 | return o; 404 | } 405 | template 406 | std::basic_ostream& operator<<(std::basic_ostream& o, ErrorType value) { 407 | switch (value) { 408 | case ErrorType::NoError: 409 | o << "ErrorType::NoError"; 410 | break; 411 | case ErrorType::Validation: 412 | o << "ErrorType::Validation"; 413 | break; 414 | case ErrorType::OutOfMemory: 415 | o << "ErrorType::OutOfMemory"; 416 | break; 417 | case ErrorType::Internal: 418 | o << "ErrorType::Internal"; 419 | break; 420 | case ErrorType::Unknown: 421 | o << "ErrorType::Unknown"; 422 | break; 423 | case ErrorType::DeviceLost: 424 | o << "ErrorType::DeviceLost"; 425 | break; 426 | default: 427 | o << "ErrorType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 428 | } 429 | return o; 430 | } 431 | template 432 | std::basic_ostream& operator<<(std::basic_ostream& o, ExternalTextureRotation value) { 433 | switch (value) { 434 | case ExternalTextureRotation::Rotate0Degrees: 435 | o << "ExternalTextureRotation::Rotate0Degrees"; 436 | break; 437 | case ExternalTextureRotation::Rotate90Degrees: 438 | o << "ExternalTextureRotation::Rotate90Degrees"; 439 | break; 440 | case ExternalTextureRotation::Rotate180Degrees: 441 | o << "ExternalTextureRotation::Rotate180Degrees"; 442 | break; 443 | case ExternalTextureRotation::Rotate270Degrees: 444 | o << "ExternalTextureRotation::Rotate270Degrees"; 445 | break; 446 | default: 447 | o << "ExternalTextureRotation::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 448 | } 449 | return o; 450 | } 451 | template 452 | std::basic_ostream& operator<<(std::basic_ostream& o, FeatureName value) { 453 | switch (value) { 454 | case FeatureName::Undefined: 455 | o << "FeatureName::Undefined"; 456 | break; 457 | case FeatureName::DepthClipControl: 458 | o << "FeatureName::DepthClipControl"; 459 | break; 460 | case FeatureName::Depth32FloatStencil8: 461 | o << "FeatureName::Depth32FloatStencil8"; 462 | break; 463 | case FeatureName::TimestampQuery: 464 | o << "FeatureName::TimestampQuery"; 465 | break; 466 | case FeatureName::PipelineStatisticsQuery: 467 | o << "FeatureName::PipelineStatisticsQuery"; 468 | break; 469 | case FeatureName::TextureCompressionBC: 470 | o << "FeatureName::TextureCompressionBC"; 471 | break; 472 | case FeatureName::TextureCompressionETC2: 473 | o << "FeatureName::TextureCompressionETC2"; 474 | break; 475 | case FeatureName::TextureCompressionASTC: 476 | o << "FeatureName::TextureCompressionASTC"; 477 | break; 478 | case FeatureName::IndirectFirstInstance: 479 | o << "FeatureName::IndirectFirstInstance"; 480 | break; 481 | case FeatureName::ShaderF16: 482 | o << "FeatureName::ShaderF16"; 483 | break; 484 | case FeatureName::RG11B10UfloatRenderable: 485 | o << "FeatureName::RG11B10UfloatRenderable"; 486 | break; 487 | case FeatureName::BGRA8UnormStorage: 488 | o << "FeatureName::BGRA8UnormStorage"; 489 | break; 490 | case FeatureName::Float32Filterable: 491 | o << "FeatureName::Float32Filterable"; 492 | break; 493 | case FeatureName::DawnShaderFloat16: 494 | o << "FeatureName::DawnShaderFloat16"; 495 | break; 496 | case FeatureName::DawnInternalUsages: 497 | o << "FeatureName::DawnInternalUsages"; 498 | break; 499 | case FeatureName::DawnMultiPlanarFormats: 500 | o << "FeatureName::DawnMultiPlanarFormats"; 501 | break; 502 | case FeatureName::DawnNative: 503 | o << "FeatureName::DawnNative"; 504 | break; 505 | case FeatureName::ChromiumExperimentalDp4a: 506 | o << "FeatureName::ChromiumExperimentalDp4a"; 507 | break; 508 | case FeatureName::TimestampQueryInsidePasses: 509 | o << "FeatureName::TimestampQueryInsidePasses"; 510 | break; 511 | case FeatureName::ImplicitDeviceSynchronization: 512 | o << "FeatureName::ImplicitDeviceSynchronization"; 513 | break; 514 | case FeatureName::SurfaceCapabilities: 515 | o << "FeatureName::SurfaceCapabilities"; 516 | break; 517 | case FeatureName::TransientAttachments: 518 | o << "FeatureName::TransientAttachments"; 519 | break; 520 | case FeatureName::MSAARenderToSingleSampled: 521 | o << "FeatureName::MSAARenderToSingleSampled"; 522 | break; 523 | default: 524 | o << "FeatureName::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 525 | } 526 | return o; 527 | } 528 | template 529 | std::basic_ostream& operator<<(std::basic_ostream& o, FilterMode value) { 530 | switch (value) { 531 | case FilterMode::Nearest: 532 | o << "FilterMode::Nearest"; 533 | break; 534 | case FilterMode::Linear: 535 | o << "FilterMode::Linear"; 536 | break; 537 | default: 538 | o << "FilterMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 539 | } 540 | return o; 541 | } 542 | template 543 | std::basic_ostream& operator<<(std::basic_ostream& o, FrontFace value) { 544 | switch (value) { 545 | case FrontFace::CCW: 546 | o << "FrontFace::CCW"; 547 | break; 548 | case FrontFace::CW: 549 | o << "FrontFace::CW"; 550 | break; 551 | default: 552 | o << "FrontFace::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 553 | } 554 | return o; 555 | } 556 | template 557 | std::basic_ostream& operator<<(std::basic_ostream& o, IndexFormat value) { 558 | switch (value) { 559 | case IndexFormat::Undefined: 560 | o << "IndexFormat::Undefined"; 561 | break; 562 | case IndexFormat::Uint16: 563 | o << "IndexFormat::Uint16"; 564 | break; 565 | case IndexFormat::Uint32: 566 | o << "IndexFormat::Uint32"; 567 | break; 568 | default: 569 | o << "IndexFormat::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 570 | } 571 | return o; 572 | } 573 | template 574 | std::basic_ostream& operator<<(std::basic_ostream& o, LoadOp value) { 575 | switch (value) { 576 | case LoadOp::Undefined: 577 | o << "LoadOp::Undefined"; 578 | break; 579 | case LoadOp::Clear: 580 | o << "LoadOp::Clear"; 581 | break; 582 | case LoadOp::Load: 583 | o << "LoadOp::Load"; 584 | break; 585 | default: 586 | o << "LoadOp::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 587 | } 588 | return o; 589 | } 590 | template 591 | std::basic_ostream& operator<<(std::basic_ostream& o, LoggingType value) { 592 | switch (value) { 593 | case LoggingType::Verbose: 594 | o << "LoggingType::Verbose"; 595 | break; 596 | case LoggingType::Info: 597 | o << "LoggingType::Info"; 598 | break; 599 | case LoggingType::Warning: 600 | o << "LoggingType::Warning"; 601 | break; 602 | case LoggingType::Error: 603 | o << "LoggingType::Error"; 604 | break; 605 | default: 606 | o << "LoggingType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 607 | } 608 | return o; 609 | } 610 | template 611 | std::basic_ostream& operator<<(std::basic_ostream& o, MipmapFilterMode value) { 612 | switch (value) { 613 | case MipmapFilterMode::Nearest: 614 | o << "MipmapFilterMode::Nearest"; 615 | break; 616 | case MipmapFilterMode::Linear: 617 | o << "MipmapFilterMode::Linear"; 618 | break; 619 | default: 620 | o << "MipmapFilterMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 621 | } 622 | return o; 623 | } 624 | template 625 | std::basic_ostream& operator<<(std::basic_ostream& o, PipelineStatisticName value) { 626 | switch (value) { 627 | case PipelineStatisticName::VertexShaderInvocations: 628 | o << "PipelineStatisticName::VertexShaderInvocations"; 629 | break; 630 | case PipelineStatisticName::ClipperInvocations: 631 | o << "PipelineStatisticName::ClipperInvocations"; 632 | break; 633 | case PipelineStatisticName::ClipperPrimitivesOut: 634 | o << "PipelineStatisticName::ClipperPrimitivesOut"; 635 | break; 636 | case PipelineStatisticName::FragmentShaderInvocations: 637 | o << "PipelineStatisticName::FragmentShaderInvocations"; 638 | break; 639 | case PipelineStatisticName::ComputeShaderInvocations: 640 | o << "PipelineStatisticName::ComputeShaderInvocations"; 641 | break; 642 | default: 643 | o << "PipelineStatisticName::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 644 | } 645 | return o; 646 | } 647 | template 648 | std::basic_ostream& operator<<(std::basic_ostream& o, PowerPreference value) { 649 | switch (value) { 650 | case PowerPreference::Undefined: 651 | o << "PowerPreference::Undefined"; 652 | break; 653 | case PowerPreference::LowPower: 654 | o << "PowerPreference::LowPower"; 655 | break; 656 | case PowerPreference::HighPerformance: 657 | o << "PowerPreference::HighPerformance"; 658 | break; 659 | default: 660 | o << "PowerPreference::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 661 | } 662 | return o; 663 | } 664 | template 665 | std::basic_ostream& operator<<(std::basic_ostream& o, PresentMode value) { 666 | switch (value) { 667 | case PresentMode::Immediate: 668 | o << "PresentMode::Immediate"; 669 | break; 670 | case PresentMode::Mailbox: 671 | o << "PresentMode::Mailbox"; 672 | break; 673 | case PresentMode::Fifo: 674 | o << "PresentMode::Fifo"; 675 | break; 676 | default: 677 | o << "PresentMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 678 | } 679 | return o; 680 | } 681 | template 682 | std::basic_ostream& operator<<(std::basic_ostream& o, PrimitiveTopology value) { 683 | switch (value) { 684 | case PrimitiveTopology::PointList: 685 | o << "PrimitiveTopology::PointList"; 686 | break; 687 | case PrimitiveTopology::LineList: 688 | o << "PrimitiveTopology::LineList"; 689 | break; 690 | case PrimitiveTopology::LineStrip: 691 | o << "PrimitiveTopology::LineStrip"; 692 | break; 693 | case PrimitiveTopology::TriangleList: 694 | o << "PrimitiveTopology::TriangleList"; 695 | break; 696 | case PrimitiveTopology::TriangleStrip: 697 | o << "PrimitiveTopology::TriangleStrip"; 698 | break; 699 | default: 700 | o << "PrimitiveTopology::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 701 | } 702 | return o; 703 | } 704 | template 705 | std::basic_ostream& operator<<(std::basic_ostream& o, QueryType value) { 706 | switch (value) { 707 | case QueryType::Occlusion: 708 | o << "QueryType::Occlusion"; 709 | break; 710 | case QueryType::PipelineStatistics: 711 | o << "QueryType::PipelineStatistics"; 712 | break; 713 | case QueryType::Timestamp: 714 | o << "QueryType::Timestamp"; 715 | break; 716 | default: 717 | o << "QueryType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 718 | } 719 | return o; 720 | } 721 | template 722 | std::basic_ostream& operator<<(std::basic_ostream& o, QueueWorkDoneStatus value) { 723 | switch (value) { 724 | case QueueWorkDoneStatus::Success: 725 | o << "QueueWorkDoneStatus::Success"; 726 | break; 727 | case QueueWorkDoneStatus::Error: 728 | o << "QueueWorkDoneStatus::Error"; 729 | break; 730 | case QueueWorkDoneStatus::Unknown: 731 | o << "QueueWorkDoneStatus::Unknown"; 732 | break; 733 | case QueueWorkDoneStatus::DeviceLost: 734 | o << "QueueWorkDoneStatus::DeviceLost"; 735 | break; 736 | default: 737 | o << "QueueWorkDoneStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 738 | } 739 | return o; 740 | } 741 | template 742 | std::basic_ostream& operator<<(std::basic_ostream& o, RenderPassTimestampLocation value) { 743 | switch (value) { 744 | case RenderPassTimestampLocation::Beginning: 745 | o << "RenderPassTimestampLocation::Beginning"; 746 | break; 747 | case RenderPassTimestampLocation::End: 748 | o << "RenderPassTimestampLocation::End"; 749 | break; 750 | default: 751 | o << "RenderPassTimestampLocation::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 752 | } 753 | return o; 754 | } 755 | template 756 | std::basic_ostream& operator<<(std::basic_ostream& o, RequestAdapterStatus value) { 757 | switch (value) { 758 | case RequestAdapterStatus::Success: 759 | o << "RequestAdapterStatus::Success"; 760 | break; 761 | case RequestAdapterStatus::Unavailable: 762 | o << "RequestAdapterStatus::Unavailable"; 763 | break; 764 | case RequestAdapterStatus::Error: 765 | o << "RequestAdapterStatus::Error"; 766 | break; 767 | case RequestAdapterStatus::Unknown: 768 | o << "RequestAdapterStatus::Unknown"; 769 | break; 770 | default: 771 | o << "RequestAdapterStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 772 | } 773 | return o; 774 | } 775 | template 776 | std::basic_ostream& operator<<(std::basic_ostream& o, RequestDeviceStatus value) { 777 | switch (value) { 778 | case RequestDeviceStatus::Success: 779 | o << "RequestDeviceStatus::Success"; 780 | break; 781 | case RequestDeviceStatus::Error: 782 | o << "RequestDeviceStatus::Error"; 783 | break; 784 | case RequestDeviceStatus::Unknown: 785 | o << "RequestDeviceStatus::Unknown"; 786 | break; 787 | default: 788 | o << "RequestDeviceStatus::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 789 | } 790 | return o; 791 | } 792 | template 793 | std::basic_ostream& operator<<(std::basic_ostream& o, SType value) { 794 | switch (value) { 795 | case SType::Invalid: 796 | o << "SType::Invalid"; 797 | break; 798 | case SType::SurfaceDescriptorFromMetalLayer: 799 | o << "SType::SurfaceDescriptorFromMetalLayer"; 800 | break; 801 | case SType::SurfaceDescriptorFromWindowsHWND: 802 | o << "SType::SurfaceDescriptorFromWindowsHWND"; 803 | break; 804 | case SType::SurfaceDescriptorFromXlibWindow: 805 | o << "SType::SurfaceDescriptorFromXlibWindow"; 806 | break; 807 | case SType::SurfaceDescriptorFromCanvasHTMLSelector: 808 | o << "SType::SurfaceDescriptorFromCanvasHTMLSelector"; 809 | break; 810 | case SType::ShaderModuleSPIRVDescriptor: 811 | o << "SType::ShaderModuleSPIRVDescriptor"; 812 | break; 813 | case SType::ShaderModuleWGSLDescriptor: 814 | o << "SType::ShaderModuleWGSLDescriptor"; 815 | break; 816 | case SType::PrimitiveDepthClipControl: 817 | o << "SType::PrimitiveDepthClipControl"; 818 | break; 819 | case SType::SurfaceDescriptorFromWaylandSurface: 820 | o << "SType::SurfaceDescriptorFromWaylandSurface"; 821 | break; 822 | case SType::SurfaceDescriptorFromAndroidNativeWindow: 823 | o << "SType::SurfaceDescriptorFromAndroidNativeWindow"; 824 | break; 825 | case SType::SurfaceDescriptorFromWindowsCoreWindow: 826 | o << "SType::SurfaceDescriptorFromWindowsCoreWindow"; 827 | break; 828 | case SType::ExternalTextureBindingEntry: 829 | o << "SType::ExternalTextureBindingEntry"; 830 | break; 831 | case SType::ExternalTextureBindingLayout: 832 | o << "SType::ExternalTextureBindingLayout"; 833 | break; 834 | case SType::SurfaceDescriptorFromWindowsSwapChainPanel: 835 | o << "SType::SurfaceDescriptorFromWindowsSwapChainPanel"; 836 | break; 837 | case SType::RenderPassDescriptorMaxDrawCount: 838 | o << "SType::RenderPassDescriptorMaxDrawCount"; 839 | break; 840 | case SType::DawnTextureInternalUsageDescriptor: 841 | o << "SType::DawnTextureInternalUsageDescriptor"; 842 | break; 843 | case SType::DawnEncoderInternalUsageDescriptor: 844 | o << "SType::DawnEncoderInternalUsageDescriptor"; 845 | break; 846 | case SType::DawnInstanceDescriptor: 847 | o << "SType::DawnInstanceDescriptor"; 848 | break; 849 | case SType::DawnCacheDeviceDescriptor: 850 | o << "SType::DawnCacheDeviceDescriptor"; 851 | break; 852 | case SType::DawnAdapterPropertiesPowerPreference: 853 | o << "SType::DawnAdapterPropertiesPowerPreference"; 854 | break; 855 | case SType::DawnBufferDescriptorErrorInfoFromWireClient: 856 | o << "SType::DawnBufferDescriptorErrorInfoFromWireClient"; 857 | break; 858 | case SType::DawnTogglesDescriptor: 859 | o << "SType::DawnTogglesDescriptor"; 860 | break; 861 | case SType::DawnShaderModuleSPIRVOptionsDescriptor: 862 | o << "SType::DawnShaderModuleSPIRVOptionsDescriptor"; 863 | break; 864 | case SType::RequestAdapterOptionsLUID: 865 | o << "SType::RequestAdapterOptionsLUID"; 866 | break; 867 | case SType::RequestAdapterOptionsGetGLProc: 868 | o << "SType::RequestAdapterOptionsGetGLProc"; 869 | break; 870 | case SType::DawnMultisampleStateRenderToSingleSampled: 871 | o << "SType::DawnMultisampleStateRenderToSingleSampled"; 872 | break; 873 | case SType::DawnRenderPassColorAttachmentRenderToSingleSampled: 874 | o << "SType::DawnRenderPassColorAttachmentRenderToSingleSampled"; 875 | break; 876 | default: 877 | o << "SType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 878 | } 879 | return o; 880 | } 881 | template 882 | std::basic_ostream& operator<<(std::basic_ostream& o, SamplerBindingType value) { 883 | switch (value) { 884 | case SamplerBindingType::Undefined: 885 | o << "SamplerBindingType::Undefined"; 886 | break; 887 | case SamplerBindingType::Filtering: 888 | o << "SamplerBindingType::Filtering"; 889 | break; 890 | case SamplerBindingType::NonFiltering: 891 | o << "SamplerBindingType::NonFiltering"; 892 | break; 893 | case SamplerBindingType::Comparison: 894 | o << "SamplerBindingType::Comparison"; 895 | break; 896 | default: 897 | o << "SamplerBindingType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 898 | } 899 | return o; 900 | } 901 | template 902 | std::basic_ostream& operator<<(std::basic_ostream& o, StencilOperation value) { 903 | switch (value) { 904 | case StencilOperation::Keep: 905 | o << "StencilOperation::Keep"; 906 | break; 907 | case StencilOperation::Zero: 908 | o << "StencilOperation::Zero"; 909 | break; 910 | case StencilOperation::Replace: 911 | o << "StencilOperation::Replace"; 912 | break; 913 | case StencilOperation::Invert: 914 | o << "StencilOperation::Invert"; 915 | break; 916 | case StencilOperation::IncrementClamp: 917 | o << "StencilOperation::IncrementClamp"; 918 | break; 919 | case StencilOperation::DecrementClamp: 920 | o << "StencilOperation::DecrementClamp"; 921 | break; 922 | case StencilOperation::IncrementWrap: 923 | o << "StencilOperation::IncrementWrap"; 924 | break; 925 | case StencilOperation::DecrementWrap: 926 | o << "StencilOperation::DecrementWrap"; 927 | break; 928 | default: 929 | o << "StencilOperation::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 930 | } 931 | return o; 932 | } 933 | template 934 | std::basic_ostream& operator<<(std::basic_ostream& o, StorageTextureAccess value) { 935 | switch (value) { 936 | case StorageTextureAccess::Undefined: 937 | o << "StorageTextureAccess::Undefined"; 938 | break; 939 | case StorageTextureAccess::WriteOnly: 940 | o << "StorageTextureAccess::WriteOnly"; 941 | break; 942 | default: 943 | o << "StorageTextureAccess::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 944 | } 945 | return o; 946 | } 947 | template 948 | std::basic_ostream& operator<<(std::basic_ostream& o, StoreOp value) { 949 | switch (value) { 950 | case StoreOp::Undefined: 951 | o << "StoreOp::Undefined"; 952 | break; 953 | case StoreOp::Store: 954 | o << "StoreOp::Store"; 955 | break; 956 | case StoreOp::Discard: 957 | o << "StoreOp::Discard"; 958 | break; 959 | default: 960 | o << "StoreOp::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 961 | } 962 | return o; 963 | } 964 | template 965 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureAspect value) { 966 | switch (value) { 967 | case TextureAspect::All: 968 | o << "TextureAspect::All"; 969 | break; 970 | case TextureAspect::StencilOnly: 971 | o << "TextureAspect::StencilOnly"; 972 | break; 973 | case TextureAspect::DepthOnly: 974 | o << "TextureAspect::DepthOnly"; 975 | break; 976 | case TextureAspect::Plane0Only: 977 | o << "TextureAspect::Plane0Only"; 978 | break; 979 | case TextureAspect::Plane1Only: 980 | o << "TextureAspect::Plane1Only"; 981 | break; 982 | default: 983 | o << "TextureAspect::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 984 | } 985 | return o; 986 | } 987 | template 988 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureDimension value) { 989 | switch (value) { 990 | case TextureDimension::e1D: 991 | o << "TextureDimension::e1D"; 992 | break; 993 | case TextureDimension::e2D: 994 | o << "TextureDimension::e2D"; 995 | break; 996 | case TextureDimension::e3D: 997 | o << "TextureDimension::e3D"; 998 | break; 999 | default: 1000 | o << "TextureDimension::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1001 | } 1002 | return o; 1003 | } 1004 | template 1005 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureFormat value) { 1006 | switch (value) { 1007 | case TextureFormat::Undefined: 1008 | o << "TextureFormat::Undefined"; 1009 | break; 1010 | case TextureFormat::R8Unorm: 1011 | o << "TextureFormat::R8Unorm"; 1012 | break; 1013 | case TextureFormat::R8Snorm: 1014 | o << "TextureFormat::R8Snorm"; 1015 | break; 1016 | case TextureFormat::R8Uint: 1017 | o << "TextureFormat::R8Uint"; 1018 | break; 1019 | case TextureFormat::R8Sint: 1020 | o << "TextureFormat::R8Sint"; 1021 | break; 1022 | case TextureFormat::R16Uint: 1023 | o << "TextureFormat::R16Uint"; 1024 | break; 1025 | case TextureFormat::R16Sint: 1026 | o << "TextureFormat::R16Sint"; 1027 | break; 1028 | case TextureFormat::R16Float: 1029 | o << "TextureFormat::R16Float"; 1030 | break; 1031 | case TextureFormat::RG8Unorm: 1032 | o << "TextureFormat::RG8Unorm"; 1033 | break; 1034 | case TextureFormat::RG8Snorm: 1035 | o << "TextureFormat::RG8Snorm"; 1036 | break; 1037 | case TextureFormat::RG8Uint: 1038 | o << "TextureFormat::RG8Uint"; 1039 | break; 1040 | case TextureFormat::RG8Sint: 1041 | o << "TextureFormat::RG8Sint"; 1042 | break; 1043 | case TextureFormat::R32Float: 1044 | o << "TextureFormat::R32Float"; 1045 | break; 1046 | case TextureFormat::R32Uint: 1047 | o << "TextureFormat::R32Uint"; 1048 | break; 1049 | case TextureFormat::R32Sint: 1050 | o << "TextureFormat::R32Sint"; 1051 | break; 1052 | case TextureFormat::RG16Uint: 1053 | o << "TextureFormat::RG16Uint"; 1054 | break; 1055 | case TextureFormat::RG16Sint: 1056 | o << "TextureFormat::RG16Sint"; 1057 | break; 1058 | case TextureFormat::RG16Float: 1059 | o << "TextureFormat::RG16Float"; 1060 | break; 1061 | case TextureFormat::RGBA8Unorm: 1062 | o << "TextureFormat::RGBA8Unorm"; 1063 | break; 1064 | case TextureFormat::RGBA8UnormSrgb: 1065 | o << "TextureFormat::RGBA8UnormSrgb"; 1066 | break; 1067 | case TextureFormat::RGBA8Snorm: 1068 | o << "TextureFormat::RGBA8Snorm"; 1069 | break; 1070 | case TextureFormat::RGBA8Uint: 1071 | o << "TextureFormat::RGBA8Uint"; 1072 | break; 1073 | case TextureFormat::RGBA8Sint: 1074 | o << "TextureFormat::RGBA8Sint"; 1075 | break; 1076 | case TextureFormat::BGRA8Unorm: 1077 | o << "TextureFormat::BGRA8Unorm"; 1078 | break; 1079 | case TextureFormat::BGRA8UnormSrgb: 1080 | o << "TextureFormat::BGRA8UnormSrgb"; 1081 | break; 1082 | case TextureFormat::RGB10A2Unorm: 1083 | o << "TextureFormat::RGB10A2Unorm"; 1084 | break; 1085 | case TextureFormat::RG11B10Ufloat: 1086 | o << "TextureFormat::RG11B10Ufloat"; 1087 | break; 1088 | case TextureFormat::RGB9E5Ufloat: 1089 | o << "TextureFormat::RGB9E5Ufloat"; 1090 | break; 1091 | case TextureFormat::RG32Float: 1092 | o << "TextureFormat::RG32Float"; 1093 | break; 1094 | case TextureFormat::RG32Uint: 1095 | o << "TextureFormat::RG32Uint"; 1096 | break; 1097 | case TextureFormat::RG32Sint: 1098 | o << "TextureFormat::RG32Sint"; 1099 | break; 1100 | case TextureFormat::RGBA16Uint: 1101 | o << "TextureFormat::RGBA16Uint"; 1102 | break; 1103 | case TextureFormat::RGBA16Sint: 1104 | o << "TextureFormat::RGBA16Sint"; 1105 | break; 1106 | case TextureFormat::RGBA16Float: 1107 | o << "TextureFormat::RGBA16Float"; 1108 | break; 1109 | case TextureFormat::RGBA32Float: 1110 | o << "TextureFormat::RGBA32Float"; 1111 | break; 1112 | case TextureFormat::RGBA32Uint: 1113 | o << "TextureFormat::RGBA32Uint"; 1114 | break; 1115 | case TextureFormat::RGBA32Sint: 1116 | o << "TextureFormat::RGBA32Sint"; 1117 | break; 1118 | case TextureFormat::Stencil8: 1119 | o << "TextureFormat::Stencil8"; 1120 | break; 1121 | case TextureFormat::Depth16Unorm: 1122 | o << "TextureFormat::Depth16Unorm"; 1123 | break; 1124 | case TextureFormat::Depth24Plus: 1125 | o << "TextureFormat::Depth24Plus"; 1126 | break; 1127 | case TextureFormat::Depth24PlusStencil8: 1128 | o << "TextureFormat::Depth24PlusStencil8"; 1129 | break; 1130 | case TextureFormat::Depth32Float: 1131 | o << "TextureFormat::Depth32Float"; 1132 | break; 1133 | case TextureFormat::Depth32FloatStencil8: 1134 | o << "TextureFormat::Depth32FloatStencil8"; 1135 | break; 1136 | case TextureFormat::BC1RGBAUnorm: 1137 | o << "TextureFormat::BC1RGBAUnorm"; 1138 | break; 1139 | case TextureFormat::BC1RGBAUnormSrgb: 1140 | o << "TextureFormat::BC1RGBAUnormSrgb"; 1141 | break; 1142 | case TextureFormat::BC2RGBAUnorm: 1143 | o << "TextureFormat::BC2RGBAUnorm"; 1144 | break; 1145 | case TextureFormat::BC2RGBAUnormSrgb: 1146 | o << "TextureFormat::BC2RGBAUnormSrgb"; 1147 | break; 1148 | case TextureFormat::BC3RGBAUnorm: 1149 | o << "TextureFormat::BC3RGBAUnorm"; 1150 | break; 1151 | case TextureFormat::BC3RGBAUnormSrgb: 1152 | o << "TextureFormat::BC3RGBAUnormSrgb"; 1153 | break; 1154 | case TextureFormat::BC4RUnorm: 1155 | o << "TextureFormat::BC4RUnorm"; 1156 | break; 1157 | case TextureFormat::BC4RSnorm: 1158 | o << "TextureFormat::BC4RSnorm"; 1159 | break; 1160 | case TextureFormat::BC5RGUnorm: 1161 | o << "TextureFormat::BC5RGUnorm"; 1162 | break; 1163 | case TextureFormat::BC5RGSnorm: 1164 | o << "TextureFormat::BC5RGSnorm"; 1165 | break; 1166 | case TextureFormat::BC6HRGBUfloat: 1167 | o << "TextureFormat::BC6HRGBUfloat"; 1168 | break; 1169 | case TextureFormat::BC6HRGBFloat: 1170 | o << "TextureFormat::BC6HRGBFloat"; 1171 | break; 1172 | case TextureFormat::BC7RGBAUnorm: 1173 | o << "TextureFormat::BC7RGBAUnorm"; 1174 | break; 1175 | case TextureFormat::BC7RGBAUnormSrgb: 1176 | o << "TextureFormat::BC7RGBAUnormSrgb"; 1177 | break; 1178 | case TextureFormat::ETC2RGB8Unorm: 1179 | o << "TextureFormat::ETC2RGB8Unorm"; 1180 | break; 1181 | case TextureFormat::ETC2RGB8UnormSrgb: 1182 | o << "TextureFormat::ETC2RGB8UnormSrgb"; 1183 | break; 1184 | case TextureFormat::ETC2RGB8A1Unorm: 1185 | o << "TextureFormat::ETC2RGB8A1Unorm"; 1186 | break; 1187 | case TextureFormat::ETC2RGB8A1UnormSrgb: 1188 | o << "TextureFormat::ETC2RGB8A1UnormSrgb"; 1189 | break; 1190 | case TextureFormat::ETC2RGBA8Unorm: 1191 | o << "TextureFormat::ETC2RGBA8Unorm"; 1192 | break; 1193 | case TextureFormat::ETC2RGBA8UnormSrgb: 1194 | o << "TextureFormat::ETC2RGBA8UnormSrgb"; 1195 | break; 1196 | case TextureFormat::EACR11Unorm: 1197 | o << "TextureFormat::EACR11Unorm"; 1198 | break; 1199 | case TextureFormat::EACR11Snorm: 1200 | o << "TextureFormat::EACR11Snorm"; 1201 | break; 1202 | case TextureFormat::EACRG11Unorm: 1203 | o << "TextureFormat::EACRG11Unorm"; 1204 | break; 1205 | case TextureFormat::EACRG11Snorm: 1206 | o << "TextureFormat::EACRG11Snorm"; 1207 | break; 1208 | case TextureFormat::ASTC4x4Unorm: 1209 | o << "TextureFormat::ASTC4x4Unorm"; 1210 | break; 1211 | case TextureFormat::ASTC4x4UnormSrgb: 1212 | o << "TextureFormat::ASTC4x4UnormSrgb"; 1213 | break; 1214 | case TextureFormat::ASTC5x4Unorm: 1215 | o << "TextureFormat::ASTC5x4Unorm"; 1216 | break; 1217 | case TextureFormat::ASTC5x4UnormSrgb: 1218 | o << "TextureFormat::ASTC5x4UnormSrgb"; 1219 | break; 1220 | case TextureFormat::ASTC5x5Unorm: 1221 | o << "TextureFormat::ASTC5x5Unorm"; 1222 | break; 1223 | case TextureFormat::ASTC5x5UnormSrgb: 1224 | o << "TextureFormat::ASTC5x5UnormSrgb"; 1225 | break; 1226 | case TextureFormat::ASTC6x5Unorm: 1227 | o << "TextureFormat::ASTC6x5Unorm"; 1228 | break; 1229 | case TextureFormat::ASTC6x5UnormSrgb: 1230 | o << "TextureFormat::ASTC6x5UnormSrgb"; 1231 | break; 1232 | case TextureFormat::ASTC6x6Unorm: 1233 | o << "TextureFormat::ASTC6x6Unorm"; 1234 | break; 1235 | case TextureFormat::ASTC6x6UnormSrgb: 1236 | o << "TextureFormat::ASTC6x6UnormSrgb"; 1237 | break; 1238 | case TextureFormat::ASTC8x5Unorm: 1239 | o << "TextureFormat::ASTC8x5Unorm"; 1240 | break; 1241 | case TextureFormat::ASTC8x5UnormSrgb: 1242 | o << "TextureFormat::ASTC8x5UnormSrgb"; 1243 | break; 1244 | case TextureFormat::ASTC8x6Unorm: 1245 | o << "TextureFormat::ASTC8x6Unorm"; 1246 | break; 1247 | case TextureFormat::ASTC8x6UnormSrgb: 1248 | o << "TextureFormat::ASTC8x6UnormSrgb"; 1249 | break; 1250 | case TextureFormat::ASTC8x8Unorm: 1251 | o << "TextureFormat::ASTC8x8Unorm"; 1252 | break; 1253 | case TextureFormat::ASTC8x8UnormSrgb: 1254 | o << "TextureFormat::ASTC8x8UnormSrgb"; 1255 | break; 1256 | case TextureFormat::ASTC10x5Unorm: 1257 | o << "TextureFormat::ASTC10x5Unorm"; 1258 | break; 1259 | case TextureFormat::ASTC10x5UnormSrgb: 1260 | o << "TextureFormat::ASTC10x5UnormSrgb"; 1261 | break; 1262 | case TextureFormat::ASTC10x6Unorm: 1263 | o << "TextureFormat::ASTC10x6Unorm"; 1264 | break; 1265 | case TextureFormat::ASTC10x6UnormSrgb: 1266 | o << "TextureFormat::ASTC10x6UnormSrgb"; 1267 | break; 1268 | case TextureFormat::ASTC10x8Unorm: 1269 | o << "TextureFormat::ASTC10x8Unorm"; 1270 | break; 1271 | case TextureFormat::ASTC10x8UnormSrgb: 1272 | o << "TextureFormat::ASTC10x8UnormSrgb"; 1273 | break; 1274 | case TextureFormat::ASTC10x10Unorm: 1275 | o << "TextureFormat::ASTC10x10Unorm"; 1276 | break; 1277 | case TextureFormat::ASTC10x10UnormSrgb: 1278 | o << "TextureFormat::ASTC10x10UnormSrgb"; 1279 | break; 1280 | case TextureFormat::ASTC12x10Unorm: 1281 | o << "TextureFormat::ASTC12x10Unorm"; 1282 | break; 1283 | case TextureFormat::ASTC12x10UnormSrgb: 1284 | o << "TextureFormat::ASTC12x10UnormSrgb"; 1285 | break; 1286 | case TextureFormat::ASTC12x12Unorm: 1287 | o << "TextureFormat::ASTC12x12Unorm"; 1288 | break; 1289 | case TextureFormat::ASTC12x12UnormSrgb: 1290 | o << "TextureFormat::ASTC12x12UnormSrgb"; 1291 | break; 1292 | case TextureFormat::R8BG8Biplanar420Unorm: 1293 | o << "TextureFormat::R8BG8Biplanar420Unorm"; 1294 | break; 1295 | default: 1296 | o << "TextureFormat::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1297 | } 1298 | return o; 1299 | } 1300 | template 1301 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureSampleType value) { 1302 | switch (value) { 1303 | case TextureSampleType::Undefined: 1304 | o << "TextureSampleType::Undefined"; 1305 | break; 1306 | case TextureSampleType::Float: 1307 | o << "TextureSampleType::Float"; 1308 | break; 1309 | case TextureSampleType::UnfilterableFloat: 1310 | o << "TextureSampleType::UnfilterableFloat"; 1311 | break; 1312 | case TextureSampleType::Depth: 1313 | o << "TextureSampleType::Depth"; 1314 | break; 1315 | case TextureSampleType::Sint: 1316 | o << "TextureSampleType::Sint"; 1317 | break; 1318 | case TextureSampleType::Uint: 1319 | o << "TextureSampleType::Uint"; 1320 | break; 1321 | default: 1322 | o << "TextureSampleType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1323 | } 1324 | return o; 1325 | } 1326 | template 1327 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureViewDimension value) { 1328 | switch (value) { 1329 | case TextureViewDimension::Undefined: 1330 | o << "TextureViewDimension::Undefined"; 1331 | break; 1332 | case TextureViewDimension::e1D: 1333 | o << "TextureViewDimension::e1D"; 1334 | break; 1335 | case TextureViewDimension::e2D: 1336 | o << "TextureViewDimension::e2D"; 1337 | break; 1338 | case TextureViewDimension::e2DArray: 1339 | o << "TextureViewDimension::e2DArray"; 1340 | break; 1341 | case TextureViewDimension::Cube: 1342 | o << "TextureViewDimension::Cube"; 1343 | break; 1344 | case TextureViewDimension::CubeArray: 1345 | o << "TextureViewDimension::CubeArray"; 1346 | break; 1347 | case TextureViewDimension::e3D: 1348 | o << "TextureViewDimension::e3D"; 1349 | break; 1350 | default: 1351 | o << "TextureViewDimension::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1352 | } 1353 | return o; 1354 | } 1355 | template 1356 | std::basic_ostream& operator<<(std::basic_ostream& o, VertexFormat value) { 1357 | switch (value) { 1358 | case VertexFormat::Undefined: 1359 | o << "VertexFormat::Undefined"; 1360 | break; 1361 | case VertexFormat::Uint8x2: 1362 | o << "VertexFormat::Uint8x2"; 1363 | break; 1364 | case VertexFormat::Uint8x4: 1365 | o << "VertexFormat::Uint8x4"; 1366 | break; 1367 | case VertexFormat::Sint8x2: 1368 | o << "VertexFormat::Sint8x2"; 1369 | break; 1370 | case VertexFormat::Sint8x4: 1371 | o << "VertexFormat::Sint8x4"; 1372 | break; 1373 | case VertexFormat::Unorm8x2: 1374 | o << "VertexFormat::Unorm8x2"; 1375 | break; 1376 | case VertexFormat::Unorm8x4: 1377 | o << "VertexFormat::Unorm8x4"; 1378 | break; 1379 | case VertexFormat::Snorm8x2: 1380 | o << "VertexFormat::Snorm8x2"; 1381 | break; 1382 | case VertexFormat::Snorm8x4: 1383 | o << "VertexFormat::Snorm8x4"; 1384 | break; 1385 | case VertexFormat::Uint16x2: 1386 | o << "VertexFormat::Uint16x2"; 1387 | break; 1388 | case VertexFormat::Uint16x4: 1389 | o << "VertexFormat::Uint16x4"; 1390 | break; 1391 | case VertexFormat::Sint16x2: 1392 | o << "VertexFormat::Sint16x2"; 1393 | break; 1394 | case VertexFormat::Sint16x4: 1395 | o << "VertexFormat::Sint16x4"; 1396 | break; 1397 | case VertexFormat::Unorm16x2: 1398 | o << "VertexFormat::Unorm16x2"; 1399 | break; 1400 | case VertexFormat::Unorm16x4: 1401 | o << "VertexFormat::Unorm16x4"; 1402 | break; 1403 | case VertexFormat::Snorm16x2: 1404 | o << "VertexFormat::Snorm16x2"; 1405 | break; 1406 | case VertexFormat::Snorm16x4: 1407 | o << "VertexFormat::Snorm16x4"; 1408 | break; 1409 | case VertexFormat::Float16x2: 1410 | o << "VertexFormat::Float16x2"; 1411 | break; 1412 | case VertexFormat::Float16x4: 1413 | o << "VertexFormat::Float16x4"; 1414 | break; 1415 | case VertexFormat::Float32: 1416 | o << "VertexFormat::Float32"; 1417 | break; 1418 | case VertexFormat::Float32x2: 1419 | o << "VertexFormat::Float32x2"; 1420 | break; 1421 | case VertexFormat::Float32x3: 1422 | o << "VertexFormat::Float32x3"; 1423 | break; 1424 | case VertexFormat::Float32x4: 1425 | o << "VertexFormat::Float32x4"; 1426 | break; 1427 | case VertexFormat::Uint32: 1428 | o << "VertexFormat::Uint32"; 1429 | break; 1430 | case VertexFormat::Uint32x2: 1431 | o << "VertexFormat::Uint32x2"; 1432 | break; 1433 | case VertexFormat::Uint32x3: 1434 | o << "VertexFormat::Uint32x3"; 1435 | break; 1436 | case VertexFormat::Uint32x4: 1437 | o << "VertexFormat::Uint32x4"; 1438 | break; 1439 | case VertexFormat::Sint32: 1440 | o << "VertexFormat::Sint32"; 1441 | break; 1442 | case VertexFormat::Sint32x2: 1443 | o << "VertexFormat::Sint32x2"; 1444 | break; 1445 | case VertexFormat::Sint32x3: 1446 | o << "VertexFormat::Sint32x3"; 1447 | break; 1448 | case VertexFormat::Sint32x4: 1449 | o << "VertexFormat::Sint32x4"; 1450 | break; 1451 | default: 1452 | o << "VertexFormat::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1453 | } 1454 | return o; 1455 | } 1456 | template 1457 | std::basic_ostream& operator<<(std::basic_ostream& o, VertexStepMode value) { 1458 | switch (value) { 1459 | case VertexStepMode::Vertex: 1460 | o << "VertexStepMode::Vertex"; 1461 | break; 1462 | case VertexStepMode::Instance: 1463 | o << "VertexStepMode::Instance"; 1464 | break; 1465 | case VertexStepMode::VertexBufferNotUsed: 1466 | o << "VertexStepMode::VertexBufferNotUsed"; 1467 | break; 1468 | default: 1469 | o << "VertexStepMode::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1470 | } 1471 | return o; 1472 | } 1473 | 1474 | template 1475 | std::basic_ostream& operator<<(std::basic_ostream& o, BufferUsage value) { 1476 | o << "BufferUsage::"; 1477 | if (!static_cast(value)) { 1478 | // 0 is often explicitly declared as None. 1479 | o << "None"; 1480 | return o; 1481 | } 1482 | 1483 | bool moreThanOneBit = !HasZeroOrOneBits(value); 1484 | if (moreThanOneBit) { 1485 | o << "("; 1486 | } 1487 | 1488 | bool first = true; 1489 | if (value & BufferUsage::MapRead) { 1490 | if (!first) { 1491 | o << "|"; 1492 | } 1493 | first = false; 1494 | o << "MapRead"; 1495 | value &= ~BufferUsage::MapRead; 1496 | } 1497 | if (value & BufferUsage::MapWrite) { 1498 | if (!first) { 1499 | o << "|"; 1500 | } 1501 | first = false; 1502 | o << "MapWrite"; 1503 | value &= ~BufferUsage::MapWrite; 1504 | } 1505 | if (value & BufferUsage::CopySrc) { 1506 | if (!first) { 1507 | o << "|"; 1508 | } 1509 | first = false; 1510 | o << "CopySrc"; 1511 | value &= ~BufferUsage::CopySrc; 1512 | } 1513 | if (value & BufferUsage::CopyDst) { 1514 | if (!first) { 1515 | o << "|"; 1516 | } 1517 | first = false; 1518 | o << "CopyDst"; 1519 | value &= ~BufferUsage::CopyDst; 1520 | } 1521 | if (value & BufferUsage::Index) { 1522 | if (!first) { 1523 | o << "|"; 1524 | } 1525 | first = false; 1526 | o << "Index"; 1527 | value &= ~BufferUsage::Index; 1528 | } 1529 | if (value & BufferUsage::Vertex) { 1530 | if (!first) { 1531 | o << "|"; 1532 | } 1533 | first = false; 1534 | o << "Vertex"; 1535 | value &= ~BufferUsage::Vertex; 1536 | } 1537 | if (value & BufferUsage::Uniform) { 1538 | if (!first) { 1539 | o << "|"; 1540 | } 1541 | first = false; 1542 | o << "Uniform"; 1543 | value &= ~BufferUsage::Uniform; 1544 | } 1545 | if (value & BufferUsage::Storage) { 1546 | if (!first) { 1547 | o << "|"; 1548 | } 1549 | first = false; 1550 | o << "Storage"; 1551 | value &= ~BufferUsage::Storage; 1552 | } 1553 | if (value & BufferUsage::Indirect) { 1554 | if (!first) { 1555 | o << "|"; 1556 | } 1557 | first = false; 1558 | o << "Indirect"; 1559 | value &= ~BufferUsage::Indirect; 1560 | } 1561 | if (value & BufferUsage::QueryResolve) { 1562 | if (!first) { 1563 | o << "|"; 1564 | } 1565 | first = false; 1566 | o << "QueryResolve"; 1567 | value &= ~BufferUsage::QueryResolve; 1568 | } 1569 | 1570 | if (static_cast(value)) { 1571 | if (!first) { 1572 | o << "|"; 1573 | } 1574 | o << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1575 | } 1576 | 1577 | if (moreThanOneBit) { 1578 | o << ")"; 1579 | } 1580 | return o; 1581 | } 1582 | template 1583 | std::basic_ostream& operator<<(std::basic_ostream& o, ColorWriteMask value) { 1584 | o << "ColorWriteMask::"; 1585 | if (!static_cast(value)) { 1586 | // 0 is often explicitly declared as None. 1587 | o << "None"; 1588 | return o; 1589 | } 1590 | 1591 | bool moreThanOneBit = !HasZeroOrOneBits(value); 1592 | if (moreThanOneBit) { 1593 | o << "("; 1594 | } 1595 | 1596 | bool first = true; 1597 | if (value & ColorWriteMask::Red) { 1598 | if (!first) { 1599 | o << "|"; 1600 | } 1601 | first = false; 1602 | o << "Red"; 1603 | value &= ~ColorWriteMask::Red; 1604 | } 1605 | if (value & ColorWriteMask::Green) { 1606 | if (!first) { 1607 | o << "|"; 1608 | } 1609 | first = false; 1610 | o << "Green"; 1611 | value &= ~ColorWriteMask::Green; 1612 | } 1613 | if (value & ColorWriteMask::Blue) { 1614 | if (!first) { 1615 | o << "|"; 1616 | } 1617 | first = false; 1618 | o << "Blue"; 1619 | value &= ~ColorWriteMask::Blue; 1620 | } 1621 | if (value & ColorWriteMask::Alpha) { 1622 | if (!first) { 1623 | o << "|"; 1624 | } 1625 | first = false; 1626 | o << "Alpha"; 1627 | value &= ~ColorWriteMask::Alpha; 1628 | } 1629 | if (value & ColorWriteMask::All) { 1630 | if (!first) { 1631 | o << "|"; 1632 | } 1633 | first = false; 1634 | o << "All"; 1635 | value &= ~ColorWriteMask::All; 1636 | } 1637 | 1638 | if (static_cast(value)) { 1639 | if (!first) { 1640 | o << "|"; 1641 | } 1642 | o << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1643 | } 1644 | 1645 | if (moreThanOneBit) { 1646 | o << ")"; 1647 | } 1648 | return o; 1649 | } 1650 | template 1651 | std::basic_ostream& operator<<(std::basic_ostream& o, MapMode value) { 1652 | o << "MapMode::"; 1653 | if (!static_cast(value)) { 1654 | // 0 is often explicitly declared as None. 1655 | o << "None"; 1656 | return o; 1657 | } 1658 | 1659 | bool moreThanOneBit = !HasZeroOrOneBits(value); 1660 | if (moreThanOneBit) { 1661 | o << "("; 1662 | } 1663 | 1664 | bool first = true; 1665 | if (value & MapMode::Read) { 1666 | if (!first) { 1667 | o << "|"; 1668 | } 1669 | first = false; 1670 | o << "Read"; 1671 | value &= ~MapMode::Read; 1672 | } 1673 | if (value & MapMode::Write) { 1674 | if (!first) { 1675 | o << "|"; 1676 | } 1677 | first = false; 1678 | o << "Write"; 1679 | value &= ~MapMode::Write; 1680 | } 1681 | 1682 | if (static_cast(value)) { 1683 | if (!first) { 1684 | o << "|"; 1685 | } 1686 | o << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1687 | } 1688 | 1689 | if (moreThanOneBit) { 1690 | o << ")"; 1691 | } 1692 | return o; 1693 | } 1694 | template 1695 | std::basic_ostream& operator<<(std::basic_ostream& o, ShaderStage value) { 1696 | o << "ShaderStage::"; 1697 | if (!static_cast(value)) { 1698 | // 0 is often explicitly declared as None. 1699 | o << "None"; 1700 | return o; 1701 | } 1702 | 1703 | bool moreThanOneBit = !HasZeroOrOneBits(value); 1704 | if (moreThanOneBit) { 1705 | o << "("; 1706 | } 1707 | 1708 | bool first = true; 1709 | if (value & ShaderStage::Vertex) { 1710 | if (!first) { 1711 | o << "|"; 1712 | } 1713 | first = false; 1714 | o << "Vertex"; 1715 | value &= ~ShaderStage::Vertex; 1716 | } 1717 | if (value & ShaderStage::Fragment) { 1718 | if (!first) { 1719 | o << "|"; 1720 | } 1721 | first = false; 1722 | o << "Fragment"; 1723 | value &= ~ShaderStage::Fragment; 1724 | } 1725 | if (value & ShaderStage::Compute) { 1726 | if (!first) { 1727 | o << "|"; 1728 | } 1729 | first = false; 1730 | o << "Compute"; 1731 | value &= ~ShaderStage::Compute; 1732 | } 1733 | 1734 | if (static_cast(value)) { 1735 | if (!first) { 1736 | o << "|"; 1737 | } 1738 | o << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1739 | } 1740 | 1741 | if (moreThanOneBit) { 1742 | o << ")"; 1743 | } 1744 | return o; 1745 | } 1746 | template 1747 | std::basic_ostream& operator<<(std::basic_ostream& o, TextureUsage value) { 1748 | o << "TextureUsage::"; 1749 | if (!static_cast(value)) { 1750 | // 0 is often explicitly declared as None. 1751 | o << "None"; 1752 | return o; 1753 | } 1754 | 1755 | bool moreThanOneBit = !HasZeroOrOneBits(value); 1756 | if (moreThanOneBit) { 1757 | o << "("; 1758 | } 1759 | 1760 | bool first = true; 1761 | if (value & TextureUsage::CopySrc) { 1762 | if (!first) { 1763 | o << "|"; 1764 | } 1765 | first = false; 1766 | o << "CopySrc"; 1767 | value &= ~TextureUsage::CopySrc; 1768 | } 1769 | if (value & TextureUsage::CopyDst) { 1770 | if (!first) { 1771 | o << "|"; 1772 | } 1773 | first = false; 1774 | o << "CopyDst"; 1775 | value &= ~TextureUsage::CopyDst; 1776 | } 1777 | if (value & TextureUsage::TextureBinding) { 1778 | if (!first) { 1779 | o << "|"; 1780 | } 1781 | first = false; 1782 | o << "TextureBinding"; 1783 | value &= ~TextureUsage::TextureBinding; 1784 | } 1785 | if (value & TextureUsage::StorageBinding) { 1786 | if (!first) { 1787 | o << "|"; 1788 | } 1789 | first = false; 1790 | o << "StorageBinding"; 1791 | value &= ~TextureUsage::StorageBinding; 1792 | } 1793 | if (value & TextureUsage::RenderAttachment) { 1794 | if (!first) { 1795 | o << "|"; 1796 | } 1797 | first = false; 1798 | o << "RenderAttachment"; 1799 | value &= ~TextureUsage::RenderAttachment; 1800 | } 1801 | if (value & TextureUsage::TransientAttachment) { 1802 | if (!first) { 1803 | o << "|"; 1804 | } 1805 | first = false; 1806 | o << "TransientAttachment"; 1807 | value &= ~TextureUsage::TransientAttachment; 1808 | } 1809 | 1810 | if (static_cast(value)) { 1811 | if (!first) { 1812 | o << "|"; 1813 | } 1814 | o << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast::type>(value); 1815 | } 1816 | 1817 | if (moreThanOneBit) { 1818 | o << ")"; 1819 | } 1820 | return o; 1821 | } 1822 | 1823 | } // namespace wgpu 1824 | 1825 | #endif // WEBGPU_CPP_PRINT_H_ 1826 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/wire/Wire.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_WIRE_WIRE_H_ 16 | #define INCLUDE_DAWN_WIRE_WIRE_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "dawn/webgpu.h" 22 | #include "dawn/wire/dawn_wire_export.h" 23 | 24 | namespace dawn::wire { 25 | 26 | class DAWN_WIRE_EXPORT CommandSerializer { 27 | public: 28 | CommandSerializer(); 29 | virtual ~CommandSerializer(); 30 | CommandSerializer(const CommandSerializer& rhs) = delete; 31 | CommandSerializer& operator=(const CommandSerializer& rhs) = delete; 32 | 33 | // Get space for serializing commands. 34 | // GetCmdSpace will never be called with a value larger than 35 | // what GetMaximumAllocationSize returns. Return nullptr to indicate 36 | // a fatal error. 37 | virtual void* GetCmdSpace(size_t size) = 0; 38 | virtual bool Flush() = 0; 39 | virtual size_t GetMaximumAllocationSize() const = 0; 40 | virtual void OnSerializeError(); 41 | }; 42 | 43 | class DAWN_WIRE_EXPORT CommandHandler { 44 | public: 45 | CommandHandler(); 46 | virtual ~CommandHandler(); 47 | CommandHandler(const CommandHandler& rhs) = delete; 48 | CommandHandler& operator=(const CommandHandler& rhs) = delete; 49 | 50 | virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0; 51 | }; 52 | 53 | } // namespace dawn::wire 54 | 55 | // TODO(dawn:824): Remove once the deprecation period is passed. 56 | namespace dawn_wire = dawn::wire; 57 | 58 | #endif // INCLUDE_DAWN_WIRE_WIRE_H_ 59 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/wire/WireClient.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_WIRE_WIRECLIENT_H_ 16 | #define INCLUDE_DAWN_WIRE_WIRECLIENT_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "dawn/dawn_proc_table.h" 22 | #include "dawn/wire/Wire.h" 23 | 24 | namespace dawn::wire { 25 | 26 | namespace client { 27 | class Client; 28 | class MemoryTransferService; 29 | 30 | DAWN_WIRE_EXPORT const DawnProcTable& GetProcs(); 31 | } // namespace client 32 | 33 | struct ReservedTexture { 34 | WGPUTexture texture; 35 | uint32_t id; 36 | uint32_t generation; 37 | uint32_t deviceId; 38 | uint32_t deviceGeneration; 39 | }; 40 | 41 | struct ReservedSwapChain { 42 | WGPUSwapChain swapchain; 43 | uint32_t id; 44 | uint32_t generation; 45 | uint32_t deviceId; 46 | uint32_t deviceGeneration; 47 | }; 48 | 49 | struct ReservedDevice { 50 | WGPUDevice device; 51 | uint32_t id; 52 | uint32_t generation; 53 | }; 54 | 55 | struct ReservedInstance { 56 | WGPUInstance instance; 57 | uint32_t id; 58 | uint32_t generation; 59 | }; 60 | 61 | struct DAWN_WIRE_EXPORT WireClientDescriptor { 62 | CommandSerializer* serializer; 63 | client::MemoryTransferService* memoryTransferService = nullptr; 64 | }; 65 | 66 | class DAWN_WIRE_EXPORT WireClient : public CommandHandler { 67 | public: 68 | explicit WireClient(const WireClientDescriptor& descriptor); 69 | ~WireClient() override; 70 | 71 | const volatile char* HandleCommands(const volatile char* commands, size_t size) override; 72 | 73 | ReservedTexture ReserveTexture(WGPUDevice device, const WGPUTextureDescriptor* descriptor); 74 | ReservedSwapChain ReserveSwapChain(WGPUDevice device, 75 | const WGPUSwapChainDescriptor* descriptor); 76 | ReservedDevice ReserveDevice(); 77 | ReservedInstance ReserveInstance(); 78 | 79 | void ReclaimTextureReservation(const ReservedTexture& reservation); 80 | void ReclaimSwapChainReservation(const ReservedSwapChain& reservation); 81 | void ReclaimDeviceReservation(const ReservedDevice& reservation); 82 | void ReclaimInstanceReservation(const ReservedInstance& reservation); 83 | 84 | // Disconnects the client. 85 | // Commands allocated after this point will not be sent. 86 | void Disconnect(); 87 | 88 | private: 89 | std::unique_ptr mImpl; 90 | }; 91 | 92 | namespace client { 93 | class DAWN_WIRE_EXPORT MemoryTransferService { 94 | public: 95 | MemoryTransferService(); 96 | virtual ~MemoryTransferService(); 97 | 98 | class ReadHandle; 99 | class WriteHandle; 100 | 101 | // Create a handle for reading server data. 102 | // This may fail and return nullptr. 103 | virtual ReadHandle* CreateReadHandle(size_t) = 0; 104 | 105 | // Create a handle for writing server data. 106 | // This may fail and return nullptr. 107 | virtual WriteHandle* CreateWriteHandle(size_t) = 0; 108 | 109 | class DAWN_WIRE_EXPORT ReadHandle { 110 | public: 111 | ReadHandle(); 112 | virtual ~ReadHandle(); 113 | 114 | // Get the required serialization size for SerializeCreate 115 | virtual size_t SerializeCreateSize() = 0; 116 | 117 | // Serialize the handle into |serializePointer| so it can be received by the server. 118 | virtual void SerializeCreate(void* serializePointer) = 0; 119 | 120 | // Simply return the base address of the allocation (without applying any offset) 121 | // Returns nullptr if the allocation failed. 122 | // The data must live at least until the ReadHandle is destructued 123 | virtual const void* GetData() = 0; 124 | 125 | // Gets called when a MapReadCallback resolves. 126 | // deserialize the data update and apply 127 | // it to the range (offset, offset + size) of allocation 128 | // There could be nothing to be deserialized (if using shared memory) 129 | // Needs to check potential offset/size OOB and overflow 130 | virtual bool DeserializeDataUpdate(const void* deserializePointer, 131 | size_t deserializeSize, 132 | size_t offset, 133 | size_t size) = 0; 134 | 135 | private: 136 | ReadHandle(const ReadHandle&) = delete; 137 | ReadHandle& operator=(const ReadHandle&) = delete; 138 | }; 139 | 140 | class DAWN_WIRE_EXPORT WriteHandle { 141 | public: 142 | WriteHandle(); 143 | virtual ~WriteHandle(); 144 | 145 | // Get the required serialization size for SerializeCreate 146 | virtual size_t SerializeCreateSize() = 0; 147 | 148 | // Serialize the handle into |serializePointer| so it can be received by the server. 149 | virtual void SerializeCreate(void* serializePointer) = 0; 150 | 151 | // Simply return the base address of the allocation (without applying any offset) 152 | // The data returned should be zero-initialized. 153 | // The data returned must live at least until the WriteHandle is destructed. 154 | // On failure, the pointer returned should be null. 155 | virtual void* GetData() = 0; 156 | 157 | // Get the required serialization size for SerializeDataUpdate 158 | virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0; 159 | 160 | // Serialize a command to send the modified contents of 161 | // the subrange (offset, offset + size) of the allocation at buffer unmap 162 | // This subrange is always the whole mapped region for now 163 | // There could be nothing to be serialized (if using shared memory) 164 | virtual void SerializeDataUpdate(void* serializePointer, size_t offset, size_t size) = 0; 165 | 166 | private: 167 | WriteHandle(const WriteHandle&) = delete; 168 | WriteHandle& operator=(const WriteHandle&) = delete; 169 | }; 170 | 171 | private: 172 | MemoryTransferService(const MemoryTransferService&) = delete; 173 | MemoryTransferService& operator=(const MemoryTransferService&) = delete; 174 | }; 175 | 176 | // Backdoor to get the order of the ProcMap for testing 177 | DAWN_WIRE_EXPORT std::vector GetProcMapNamesForTesting(); 178 | } // namespace client 179 | } // namespace dawn::wire 180 | 181 | #endif // INCLUDE_DAWN_WIRE_WIRECLIENT_H_ 182 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/wire/WireServer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_WIRE_WIRESERVER_H_ 16 | #define INCLUDE_DAWN_WIRE_WIRESERVER_H_ 17 | 18 | #include 19 | 20 | #include "dawn/wire/Wire.h" 21 | 22 | struct DawnProcTable; 23 | 24 | namespace dawn::wire { 25 | 26 | namespace server { 27 | class Server; 28 | class MemoryTransferService; 29 | } // namespace server 30 | 31 | struct DAWN_WIRE_EXPORT WireServerDescriptor { 32 | const DawnProcTable* procs; 33 | CommandSerializer* serializer; 34 | server::MemoryTransferService* memoryTransferService = nullptr; 35 | }; 36 | 37 | class DAWN_WIRE_EXPORT WireServer : public CommandHandler { 38 | public: 39 | explicit WireServer(const WireServerDescriptor& descriptor); 40 | ~WireServer() override; 41 | 42 | const volatile char* HandleCommands(const volatile char* commands, size_t size) override; 43 | 44 | bool InjectTexture(WGPUTexture texture, 45 | uint32_t id, 46 | uint32_t generation, 47 | uint32_t deviceId, 48 | uint32_t deviceGeneration); 49 | bool InjectSwapChain(WGPUSwapChain swapchain, 50 | uint32_t id, 51 | uint32_t generation, 52 | uint32_t deviceId, 53 | uint32_t deviceGeneration); 54 | 55 | bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation); 56 | 57 | bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation); 58 | 59 | // Look up a device by (id, generation) pair. Returns nullptr if the generation 60 | // has expired or the id is not found. 61 | // The Wire does not have destroy hooks to allow an embedder to observe when an object 62 | // has been destroyed, but in Chrome, we need to know the list of live devices so we 63 | // can call device.Tick() on all of them periodically to ensure progress on asynchronous 64 | // work is made. Getting this list can be done by tracking the (id, generation) of 65 | // previously injected devices, and observing if GetDevice(id, generation) returns non-null. 66 | WGPUDevice GetDevice(uint32_t id, uint32_t generation); 67 | 68 | // Check if a device handle is known by the wire. 69 | // In Chrome, we need to know the list of live devices so we can call device.Tick() on all of 70 | // them periodically to ensure progress on asynchronous work is made. 71 | bool IsDeviceKnown(WGPUDevice device) const; 72 | 73 | private: 74 | std::unique_ptr mImpl; 75 | }; 76 | 77 | namespace server { 78 | class DAWN_WIRE_EXPORT MemoryTransferService { 79 | public: 80 | MemoryTransferService(); 81 | virtual ~MemoryTransferService(); 82 | 83 | class ReadHandle; 84 | class WriteHandle; 85 | 86 | // Deserialize data to create Read/Write handles. These handles are for the client 87 | // to Read/Write data. 88 | virtual bool DeserializeReadHandle(const void* deserializePointer, 89 | size_t deserializeSize, 90 | ReadHandle** readHandle) = 0; 91 | virtual bool DeserializeWriteHandle(const void* deserializePointer, 92 | size_t deserializeSize, 93 | WriteHandle** writeHandle) = 0; 94 | 95 | class DAWN_WIRE_EXPORT ReadHandle { 96 | public: 97 | ReadHandle(); 98 | virtual ~ReadHandle(); 99 | 100 | // Return the size of the command serialized if 101 | // SerializeDataUpdate is called with the same offset/size args 102 | virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0; 103 | 104 | // Gets called when a MapReadCallback resolves. 105 | // Serialize the data update for the range (offset, offset + size) into 106 | // |serializePointer| to the client There could be nothing to be serialized (if 107 | // using shared memory) 108 | virtual void SerializeDataUpdate(const void* data, 109 | size_t offset, 110 | size_t size, 111 | void* serializePointer) = 0; 112 | 113 | private: 114 | ReadHandle(const ReadHandle&) = delete; 115 | ReadHandle& operator=(const ReadHandle&) = delete; 116 | }; 117 | 118 | class DAWN_WIRE_EXPORT WriteHandle { 119 | public: 120 | WriteHandle(); 121 | virtual ~WriteHandle(); 122 | 123 | // Set the target for writes from the client. DeserializeFlush should copy data 124 | // into the target. 125 | void SetTarget(void* data); 126 | // Set Staging data length for OOB check 127 | void SetDataLength(size_t dataLength); 128 | 129 | // This function takes in the serialized result of 130 | // client::MemoryTransferService::WriteHandle::SerializeDataUpdate. 131 | // Needs to check potential offset/size OOB and overflow 132 | virtual bool DeserializeDataUpdate(const void* deserializePointer, 133 | size_t deserializeSize, 134 | size_t offset, 135 | size_t size) = 0; 136 | 137 | protected: 138 | void* mTargetData = nullptr; 139 | size_t mDataLength = 0; 140 | 141 | private: 142 | WriteHandle(const WriteHandle&) = delete; 143 | WriteHandle& operator=(const WriteHandle&) = delete; 144 | }; 145 | 146 | private: 147 | MemoryTransferService(const MemoryTransferService&) = delete; 148 | MemoryTransferService& operator=(const MemoryTransferService&) = delete; 149 | }; 150 | } // namespace server 151 | 152 | } // namespace dawn::wire 153 | 154 | #endif // INCLUDE_DAWN_WIRE_WIRESERVER_H_ 155 | -------------------------------------------------------------------------------- /libs/dawn/include/dawn/wire/dawn_wire_export.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_ 16 | #define INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_ 17 | 18 | #if defined(DAWN_WIRE_SHARED_LIBRARY) 19 | #if defined(_WIN32) 20 | #if defined(DAWN_WIRE_IMPLEMENTATION) 21 | #define DAWN_WIRE_EXPORT __declspec(dllexport) 22 | #else 23 | #define DAWN_WIRE_EXPORT __declspec(dllimport) 24 | #endif 25 | #else // defined(_WIN32) 26 | #if defined(DAWN_WIRE_IMPLEMENTATION) 27 | #define DAWN_WIRE_EXPORT __attribute__((visibility("default"))) 28 | #else 29 | #define DAWN_WIRE_EXPORT 30 | #endif 31 | #endif // defined(_WIN32) 32 | #else // defined(DAWN_WIRE_SHARED_LIBRARY) 33 | #define DAWN_WIRE_EXPORT 34 | #endif // defined(DAWN_WIRE_SHARED_LIBRARY) 35 | 36 | #endif // INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_ 37 | -------------------------------------------------------------------------------- /libs/dawn/include/tint/override_id.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Tint Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef SRC_TINT_OVERRIDE_ID_H_ 16 | #define SRC_TINT_OVERRIDE_ID_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "src/tint/reflection.h" 22 | 23 | namespace tint { 24 | 25 | /// OverrideId is a numerical identifier for an override variable, unique per program. 26 | struct OverrideId { 27 | uint16_t value = 0; 28 | 29 | /// Reflect the fields of this struct so that it can be used by tint::ForeachField() 30 | TINT_REFLECT(value); 31 | }; 32 | 33 | /// Equality operator for OverrideId 34 | /// @param lhs the OverrideId on the left of the '=' operator 35 | /// @param rhs the OverrideId on the right of the '=' operator 36 | /// @returns true if `lhs` is equal to `rhs` 37 | inline bool operator==(OverrideId lhs, OverrideId rhs) { 38 | return lhs.value == rhs.value; 39 | } 40 | 41 | /// Less-than operator for OverrideId 42 | /// @param lhs the OverrideId on the left of the '<' operator 43 | /// @param rhs the OverrideId on the right of the '<' operator 44 | /// @returns true if `lhs` comes before `rhs` 45 | inline bool operator<(OverrideId lhs, OverrideId rhs) { 46 | return lhs.value < rhs.value; 47 | } 48 | 49 | } // namespace tint 50 | 51 | namespace std { 52 | 53 | /// Custom std::hash specialization for tint::OverrideId. 54 | template <> 55 | class hash { 56 | public: 57 | /// @param id the override identifier 58 | /// @return the hash of the override identifier 59 | inline std::size_t operator()(tint::OverrideId id) const { 60 | return std::hash()(id.value); 61 | } 62 | }; 63 | 64 | } // namespace std 65 | 66 | #endif // SRC_TINT_OVERRIDE_ID_H_ 67 | -------------------------------------------------------------------------------- /libs/dawn/include/tint/tint.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Tint Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_TINT_TINT_H_ 16 | #define INCLUDE_TINT_TINT_H_ 17 | 18 | // Guard for accidental includes to private headers 19 | #define CURRENTLY_IN_TINT_PUBLIC_HEADER 20 | 21 | // TODO(tint:88): When implementing support for an install target, all of these 22 | // headers will need to be moved to include/tint/. 23 | 24 | #include "src/tint/ast/transform/first_index_offset.h" 25 | #include "src/tint/ast/transform/renamer.h" 26 | #include "src/tint/ast/transform/single_entry_point.h" 27 | #include "src/tint/ast/transform/substitute_override.h" 28 | #include "src/tint/ast/transform/vertex_pulling.h" 29 | #include "src/tint/diagnostic/printer.h" 30 | #include "src/tint/inspector/inspector.h" 31 | #include "src/tint/reader/reader.h" 32 | #include "src/tint/transform/manager.h" 33 | #include "src/tint/type/manager.h" 34 | #include "src/tint/utils/unicode.h" 35 | #include "src/tint/writer/array_length_from_uniform_options.h" 36 | #include "src/tint/writer/binding_point.h" 37 | #include "src/tint/writer/binding_remapper_options.h" 38 | #include "src/tint/writer/external_texture_options.h" 39 | #include "src/tint/writer/flatten_bindings.h" 40 | #include "src/tint/writer/writer.h" 41 | 42 | #if TINT_BUILD_SPV_READER 43 | #include "src/tint/reader/spirv/parser.h" 44 | #endif // TINT_BUILD_SPV_READER 45 | 46 | #if TINT_BUILD_WGSL_READER 47 | #include "src/tint/reader/wgsl/parser.h" 48 | #endif // TINT_BUILD_WGSL_READER 49 | 50 | #if TINT_BUILD_SPV_WRITER 51 | #include "src/tint/writer/spirv/generator.h" 52 | #endif // TINT_BUILD_SPV_WRITER 53 | 54 | #if TINT_BUILD_WGSL_WRITER 55 | #include "src/tint/writer/wgsl/generator.h" 56 | #endif // TINT_BUILD_WGSL_WRITER 57 | 58 | #if TINT_BUILD_MSL_WRITER 59 | #include "src/tint/writer/msl/generator.h" 60 | #endif // TINT_BUILD_MSL_WRITER 61 | 62 | #if TINT_BUILD_HLSL_WRITER 63 | #include "src/tint/writer/hlsl/generator.h" 64 | #endif // TINT_BUILD_HLSL_WRITER 65 | 66 | #if TINT_BUILD_GLSL_WRITER 67 | #include "src/tint/writer/glsl/generator.h" 68 | #endif // TINT_BUILD_GLSL_WRITER 69 | 70 | namespace tint { 71 | 72 | /// Initialize initializes the Tint library. Call before using the Tint API. 73 | void Initialize(); 74 | 75 | /// Shutdown uninitializes the Tint library. Call after using the Tint API. 76 | void Shutdown(); 77 | 78 | } // namespace tint 79 | 80 | #undef CURRENTLY_IN_TINT_PUBLIC_HEADER 81 | 82 | #endif // INCLUDE_TINT_TINT_H_ 83 | -------------------------------------------------------------------------------- /libs/dawn/include/webgpu/webgpu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_WEBGPU_WEBGPU_H_ 16 | #define INCLUDE_WEBGPU_WEBGPU_H_ 17 | 18 | #include "dawn/webgpu.h" 19 | 20 | #endif // INCLUDE_WEBGPU_WEBGPU_H_ 21 | -------------------------------------------------------------------------------- /libs/dawn/include/webgpu/webgpu_cpp.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_WEBGPU_WEBGPU_CPP_H_ 16 | #define INCLUDE_WEBGPU_WEBGPU_CPP_H_ 17 | 18 | #include "dawn/webgpu_cpp.h" 19 | 20 | #endif // INCLUDE_WEBGPU_WEBGPU_CPP_H_ 21 | -------------------------------------------------------------------------------- /libs/dawn/include/webgpu/webgpu_glfw.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Dawn Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INCLUDE_WEBGPU_WEBGPU_GLFW_H_ 16 | #define INCLUDE_WEBGPU_WEBGPU_GLFW_H_ 17 | 18 | #include 19 | 20 | #include "webgpu/webgpu_cpp.h" 21 | 22 | #if defined(WGPU_GLFW_SHARED_LIBRARY) 23 | #if defined(_WIN32) 24 | #if defined(WGPU_GLFW_IMPLEMENTATION) 25 | #define WGPU_GLFW_EXPORT __declspec(dllexport) 26 | #else 27 | #define WGPU_GLFW_EXPORT __declspec(dllimport) 28 | #endif 29 | #else // defined(_WIN32) 30 | #if defined(WGPU_GLFW_IMPLEMENTATION) 31 | #define WGPU_GLFW_EXPORT __attribute__((visibility("default"))) 32 | #else 33 | #define WGPU_GLFW_EXPORT 34 | #endif 35 | #endif // defined(_WIN32) 36 | #else // defined(WGPU_GLFW_SHARED_LIBRARY) 37 | #define WGPU_GLFW_EXPORT 38 | #endif // defined(WGPU_GLFW_SHARED_LIBRARY) 39 | 40 | struct GLFWwindow; 41 | 42 | namespace wgpu::glfw { 43 | 44 | // Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and 45 | // calls `instance.CreateSurface` with the correct descriptor for this window. 46 | // Returns a null wgpu::Surface on failure. 47 | WGPU_GLFW_EXPORT wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance, 48 | GLFWwindow* window); 49 | 50 | // Use for testing only. Does everything that CreateSurfaceForWindow does except the call to 51 | // CreateSurface. Useful to be able to modify the descriptor for testing, or when trying to 52 | // avoid using the global proc table. 53 | WGPU_GLFW_EXPORT std::unique_ptr SetupWindowAndGetSurfaceDescriptor( 54 | GLFWwindow* window); 55 | 56 | } // namespace wgpu::glfw 57 | 58 | #endif // INCLUDE_WEBGPU_WEBGPU_GLFW_H_ 59 | -------------------------------------------------------------------------------- /src/common_wgsl.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn csGenerateMipmaps(allocator: std.mem.Allocator, format: []const u8) [:0]const u8 { 4 | const s0 = std.fmt.allocPrint( 5 | allocator, 6 | \\ @group(0) @binding(2) var dst_mipmap1: texture_storage_2d<{s}, write>; 7 | \\ @group(0) @binding(3) var dst_mipmap2: texture_storage_2d<{s}, write>; 8 | \\ @group(0) @binding(4) var dst_mipmap3: texture_storage_2d<{s}, write>; 9 | \\ @group(0) @binding(5) var dst_mipmap4: texture_storage_2d<{s}, write>; 10 | , 11 | .{ format, format, format, format }, 12 | ) catch unreachable; 13 | defer allocator.free(s0); 14 | return std.mem.joinZ(allocator, "\n\n", &.{ s0, cs_generate_mipmaps }) catch unreachable; 15 | } 16 | 17 | // zig fmt: off 18 | const cs_generate_mipmaps = 19 | \\ struct Uniforms { 20 | \\ src_mip_level: i32, 21 | \\ num_mip_levels: u32, 22 | \\ } 23 | \\ @group(0) @binding(0) var uniforms: Uniforms; 24 | \\ @group(0) @binding(1) var src_image: texture_2d; 25 | \\ 26 | \\ var red: array; 27 | \\ var green: array; 28 | \\ var blue: array; 29 | \\ var alpha: array; 30 | \\ 31 | \\ fn storeColor(index: u32, color: vec4) { 32 | \\ red[index] = color.x; 33 | \\ green[index] = color.y; 34 | \\ blue[index] = color.z; 35 | \\ alpha[index] = color.w; 36 | \\ } 37 | \\ 38 | \\ fn loadColor(index: u32) -> vec4 { 39 | \\ return vec4(red[index], green[index], blue[index], alpha[index]); 40 | \\ } 41 | \\ 42 | \\ @compute @workgroup_size(8, 8, 1) 43 | \\ fn main( 44 | \\ @builtin(global_invocation_id) global_invocation_id: vec3, 45 | \\ @builtin(local_invocation_index) local_invocation_index : u32, 46 | \\ ) { 47 | \\ let x = i32(global_invocation_id.x * 2u); 48 | \\ let y = i32(global_invocation_id.y * 2u); 49 | \\ 50 | \\ var s00 = textureLoad(src_image, vec2(x, y), uniforms.src_mip_level); 51 | \\ var s10 = textureLoad(src_image, vec2(x + 1, y), uniforms.src_mip_level); 52 | \\ var s01 = textureLoad(src_image, vec2(x, y + 1), uniforms.src_mip_level); 53 | \\ var s11 = textureLoad(src_image, vec2(x + 1, y + 1), uniforms.src_mip_level); 54 | \\ s00 = 0.25 * (s00 + s01 + s10 + s11); 55 | \\ 56 | \\ textureStore(dst_mipmap1, vec2(global_invocation_id.xy), s00); 57 | \\ storeColor(local_invocation_index, s00); 58 | \\ if (uniforms.num_mip_levels == 1u) { 59 | \\ return; 60 | \\ } 61 | \\ workgroupBarrier(); 62 | \\ 63 | \\ if ((local_invocation_index & 0x9u) == 0u) { 64 | \\ s10 = loadColor(local_invocation_index + 1u); 65 | \\ s01 = loadColor(local_invocation_index + 8u); 66 | \\ s11 = loadColor(local_invocation_index + 9u); 67 | \\ s00 = 0.25 * (s00 + s01 + s10 + s11); 68 | \\ textureStore(dst_mipmap2, vec2(global_invocation_id.xy / 2u), s00); 69 | \\ storeColor(local_invocation_index, s00); 70 | \\ } 71 | \\ if (uniforms.num_mip_levels == 2u) { 72 | \\ return; 73 | \\ } 74 | \\ workgroupBarrier(); 75 | \\ 76 | \\ if ((local_invocation_index & 0x1Bu) == 0u) { 77 | \\ s10 = loadColor(local_invocation_index + 2u); 78 | \\ s01 = loadColor(local_invocation_index + 16u); 79 | \\ s11 = loadColor(local_invocation_index + 18u); 80 | \\ s00 = 0.25 * (s00 + s01 + s10 + s11); 81 | \\ textureStore(dst_mipmap3, vec2(global_invocation_id.xy / 4u), s00); 82 | \\ storeColor(local_invocation_index, s00); 83 | \\ } 84 | \\ if (uniforms.num_mip_levels == 3u) { 85 | \\ return; 86 | \\ } 87 | \\ workgroupBarrier(); 88 | \\ 89 | \\ if (local_invocation_index == 0u) { 90 | \\ s10 = loadColor(local_invocation_index + 4u); 91 | \\ s01 = loadColor(local_invocation_index + 32u); 92 | \\ s11 = loadColor(local_invocation_index + 36u); 93 | \\ s00 = 0.25 * (s00 + s01 + s10 + s11); 94 | \\ textureStore(dst_mipmap4, vec2(global_invocation_id.xy / 8u), s00); 95 | \\ storeColor(local_invocation_index, s00); 96 | \\ } 97 | \\ } 98 | ; 99 | // zig fmt: on 100 | -------------------------------------------------------------------------------- /src/dawn.cpp: -------------------------------------------------------------------------------- 1 | #include "dawn/native/DawnNative.h" 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct DawnNativeInstanceImpl* DawnNativeInstance; 10 | 11 | DawnNativeInstance dniCreate(void) { 12 | return reinterpret_cast(new dawn::native::Instance()); 13 | } 14 | 15 | void dniDestroy(DawnNativeInstance dni) { 16 | assert(dni); 17 | delete reinterpret_cast(dni); 18 | } 19 | 20 | WGPUInstance dniGetWgpuInstance(DawnNativeInstance dni) { 21 | assert(dni); 22 | return reinterpret_cast(dni)->Get(); 23 | } 24 | 25 | void dniDiscoverDefaultAdapters(DawnNativeInstance dni) { 26 | assert(dni); 27 | dawn::native::Instance* instance = reinterpret_cast(dni); 28 | instance->DiscoverDefaultAdapters(); 29 | } 30 | 31 | const DawnProcTable* dnGetProcs(void) { 32 | return &dawn::native::GetProcs(); 33 | } 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /src/dawn_proc.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dawn/dawn_proc.h" 3 | 4 | static DawnProcTable procs; 5 | 6 | static DawnProcTable nullProcs; 7 | 8 | void dawnProcSetProcs(const DawnProcTable* procs_) { 9 | if (procs_) { 10 | procs = *procs_; 11 | } else { 12 | procs = nullProcs; 13 | } 14 | } 15 | 16 | WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor) { 17 | return procs.createInstance(descriptor); 18 | } 19 | WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) { 20 | return procs.getProcAddress(device, procName); 21 | } 22 | 23 | WGPUDevice wgpuAdapterCreateDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor) { 24 | return procs.adapterCreateDevice(adapter, descriptor); 25 | } 26 | size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) { 27 | return procs.adapterEnumerateFeatures(adapter, features); 28 | } 29 | WGPUInstance wgpuAdapterGetInstance(WGPUAdapter adapter) { 30 | return procs.adapterGetInstance(adapter); 31 | } 32 | bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) { 33 | return procs.adapterGetLimits(adapter, limits); 34 | } 35 | void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) { 36 | procs.adapterGetProperties(adapter, properties); 37 | } 38 | bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) { 39 | return procs.adapterHasFeature(adapter, feature); 40 | } 41 | void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) { 42 | procs.adapterRequestDevice(adapter, descriptor, callback, userdata); 43 | } 44 | void wgpuAdapterReference(WGPUAdapter adapter) { 45 | procs.adapterReference(adapter); 46 | } 47 | void wgpuAdapterRelease(WGPUAdapter adapter) { 48 | procs.adapterRelease(adapter); 49 | } 50 | 51 | void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) { 52 | procs.bindGroupSetLabel(bindGroup, label); 53 | } 54 | void wgpuBindGroupReference(WGPUBindGroup bindGroup) { 55 | procs.bindGroupReference(bindGroup); 56 | } 57 | void wgpuBindGroupRelease(WGPUBindGroup bindGroup) { 58 | procs.bindGroupRelease(bindGroup); 59 | } 60 | 61 | void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) { 62 | procs.bindGroupLayoutSetLabel(bindGroupLayout, label); 63 | } 64 | void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) { 65 | procs.bindGroupLayoutReference(bindGroupLayout); 66 | } 67 | void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) { 68 | procs.bindGroupLayoutRelease(bindGroupLayout); 69 | } 70 | 71 | void wgpuBufferDestroy(WGPUBuffer buffer) { 72 | procs.bufferDestroy(buffer); 73 | } 74 | void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) { 75 | return procs.bufferGetConstMappedRange(buffer, offset, size); 76 | } 77 | WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) { 78 | return procs.bufferGetMapState(buffer); 79 | } 80 | void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) { 81 | return procs.bufferGetMappedRange(buffer, offset, size); 82 | } 83 | uint64_t wgpuBufferGetSize(WGPUBuffer buffer) { 84 | return procs.bufferGetSize(buffer); 85 | } 86 | WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) { 87 | return procs.bufferGetUsage(buffer); 88 | } 89 | void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) { 90 | procs.bufferMapAsync(buffer, mode, offset, size, callback, userdata); 91 | } 92 | void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) { 93 | procs.bufferSetLabel(buffer, label); 94 | } 95 | void wgpuBufferUnmap(WGPUBuffer buffer) { 96 | procs.bufferUnmap(buffer); 97 | } 98 | void wgpuBufferReference(WGPUBuffer buffer) { 99 | procs.bufferReference(buffer); 100 | } 101 | void wgpuBufferRelease(WGPUBuffer buffer) { 102 | procs.bufferRelease(buffer); 103 | } 104 | 105 | void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) { 106 | procs.commandBufferSetLabel(commandBuffer, label); 107 | } 108 | void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) { 109 | procs.commandBufferReference(commandBuffer); 110 | } 111 | void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) { 112 | procs.commandBufferRelease(commandBuffer); 113 | } 114 | 115 | WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor) { 116 | return procs.commandEncoderBeginComputePass(commandEncoder, descriptor); 117 | } 118 | WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) { 119 | return procs.commandEncoderBeginRenderPass(commandEncoder, descriptor); 120 | } 121 | void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) { 122 | procs.commandEncoderClearBuffer(commandEncoder, buffer, offset, size); 123 | } 124 | void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) { 125 | procs.commandEncoderCopyBufferToBuffer(commandEncoder, source, sourceOffset, destination, destinationOffset, size); 126 | } 127 | void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) { 128 | procs.commandEncoderCopyBufferToTexture(commandEncoder, source, destination, copySize); 129 | } 130 | void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) { 131 | procs.commandEncoderCopyTextureToBuffer(commandEncoder, source, destination, copySize); 132 | } 133 | void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) { 134 | procs.commandEncoderCopyTextureToTexture(commandEncoder, source, destination, copySize); 135 | } 136 | void wgpuCommandEncoderCopyTextureToTextureInternal(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) { 137 | procs.commandEncoderCopyTextureToTextureInternal(commandEncoder, source, destination, copySize); 138 | } 139 | WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor) { 140 | return procs.commandEncoderFinish(commandEncoder, descriptor); 141 | } 142 | void wgpuCommandEncoderInjectValidationError(WGPUCommandEncoder commandEncoder, char const * message) { 143 | procs.commandEncoderInjectValidationError(commandEncoder, message); 144 | } 145 | void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) { 146 | procs.commandEncoderInsertDebugMarker(commandEncoder, markerLabel); 147 | } 148 | void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) { 149 | procs.commandEncoderPopDebugGroup(commandEncoder); 150 | } 151 | void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) { 152 | procs.commandEncoderPushDebugGroup(commandEncoder, groupLabel); 153 | } 154 | void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) { 155 | procs.commandEncoderResolveQuerySet(commandEncoder, querySet, firstQuery, queryCount, destination, destinationOffset); 156 | } 157 | void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) { 158 | procs.commandEncoderSetLabel(commandEncoder, label); 159 | } 160 | void wgpuCommandEncoderWriteBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size) { 161 | procs.commandEncoderWriteBuffer(commandEncoder, buffer, bufferOffset, data, size); 162 | } 163 | void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) { 164 | procs.commandEncoderWriteTimestamp(commandEncoder, querySet, queryIndex); 165 | } 166 | void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) { 167 | procs.commandEncoderReference(commandEncoder); 168 | } 169 | void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) { 170 | procs.commandEncoderRelease(commandEncoder); 171 | } 172 | 173 | void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) { 174 | procs.computePassEncoderDispatchWorkgroups(computePassEncoder, workgroupCountX, workgroupCountY, workgroupCountZ); 175 | } 176 | void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) { 177 | procs.computePassEncoderDispatchWorkgroupsIndirect(computePassEncoder, indirectBuffer, indirectOffset); 178 | } 179 | void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) { 180 | procs.computePassEncoderEnd(computePassEncoder); 181 | } 182 | void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) { 183 | procs.computePassEncoderInsertDebugMarker(computePassEncoder, markerLabel); 184 | } 185 | void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) { 186 | procs.computePassEncoderPopDebugGroup(computePassEncoder); 187 | } 188 | void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) { 189 | procs.computePassEncoderPushDebugGroup(computePassEncoder, groupLabel); 190 | } 191 | void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { 192 | procs.computePassEncoderSetBindGroup(computePassEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets); 193 | } 194 | void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) { 195 | procs.computePassEncoderSetLabel(computePassEncoder, label); 196 | } 197 | void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) { 198 | procs.computePassEncoderSetPipeline(computePassEncoder, pipeline); 199 | } 200 | void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) { 201 | procs.computePassEncoderWriteTimestamp(computePassEncoder, querySet, queryIndex); 202 | } 203 | void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) { 204 | procs.computePassEncoderReference(computePassEncoder); 205 | } 206 | void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) { 207 | procs.computePassEncoderRelease(computePassEncoder); 208 | } 209 | 210 | WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) { 211 | return procs.computePipelineGetBindGroupLayout(computePipeline, groupIndex); 212 | } 213 | void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) { 214 | procs.computePipelineSetLabel(computePipeline, label); 215 | } 216 | void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) { 217 | procs.computePipelineReference(computePipeline); 218 | } 219 | void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) { 220 | procs.computePipelineRelease(computePipeline); 221 | } 222 | 223 | WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) { 224 | return procs.deviceCreateBindGroup(device, descriptor); 225 | } 226 | WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) { 227 | return procs.deviceCreateBindGroupLayout(device, descriptor); 228 | } 229 | WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) { 230 | return procs.deviceCreateBuffer(device, descriptor); 231 | } 232 | WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor) { 233 | return procs.deviceCreateCommandEncoder(device, descriptor); 234 | } 235 | WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) { 236 | return procs.deviceCreateComputePipeline(device, descriptor); 237 | } 238 | void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) { 239 | procs.deviceCreateComputePipelineAsync(device, descriptor, callback, userdata); 240 | } 241 | WGPUBuffer wgpuDeviceCreateErrorBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) { 242 | return procs.deviceCreateErrorBuffer(device, descriptor); 243 | } 244 | WGPUExternalTexture wgpuDeviceCreateErrorExternalTexture(WGPUDevice device) { 245 | return procs.deviceCreateErrorExternalTexture(device); 246 | } 247 | WGPUShaderModule wgpuDeviceCreateErrorShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor, char const * errorMessage) { 248 | return procs.deviceCreateErrorShaderModule(device, descriptor, errorMessage); 249 | } 250 | WGPUTexture wgpuDeviceCreateErrorTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) { 251 | return procs.deviceCreateErrorTexture(device, descriptor); 252 | } 253 | WGPUExternalTexture wgpuDeviceCreateExternalTexture(WGPUDevice device, WGPUExternalTextureDescriptor const * externalTextureDescriptor) { 254 | return procs.deviceCreateExternalTexture(device, externalTextureDescriptor); 255 | } 256 | WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) { 257 | return procs.deviceCreatePipelineLayout(device, descriptor); 258 | } 259 | WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) { 260 | return procs.deviceCreateQuerySet(device, descriptor); 261 | } 262 | WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) { 263 | return procs.deviceCreateRenderBundleEncoder(device, descriptor); 264 | } 265 | WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) { 266 | return procs.deviceCreateRenderPipeline(device, descriptor); 267 | } 268 | void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) { 269 | procs.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata); 270 | } 271 | WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor) { 272 | return procs.deviceCreateSampler(device, descriptor); 273 | } 274 | WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) { 275 | return procs.deviceCreateShaderModule(device, descriptor); 276 | } 277 | WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor) { 278 | return procs.deviceCreateSwapChain(device, surface, descriptor); 279 | } 280 | WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) { 281 | return procs.deviceCreateTexture(device, descriptor); 282 | } 283 | void wgpuDeviceDestroy(WGPUDevice device) { 284 | procs.deviceDestroy(device); 285 | } 286 | size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) { 287 | return procs.deviceEnumerateFeatures(device, features); 288 | } 289 | void wgpuDeviceForceLoss(WGPUDevice device, WGPUDeviceLostReason type, char const * message) { 290 | procs.deviceForceLoss(device, type, message); 291 | } 292 | WGPUAdapter wgpuDeviceGetAdapter(WGPUDevice device) { 293 | return procs.deviceGetAdapter(device); 294 | } 295 | bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) { 296 | return procs.deviceGetLimits(device, limits); 297 | } 298 | WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) { 299 | return procs.deviceGetQueue(device); 300 | } 301 | WGPUTextureUsageFlags wgpuDeviceGetSupportedSurfaceUsage(WGPUDevice device, WGPUSurface surface) { 302 | return procs.deviceGetSupportedSurfaceUsage(device, surface); 303 | } 304 | bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) { 305 | return procs.deviceHasFeature(device, feature); 306 | } 307 | void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message) { 308 | procs.deviceInjectError(device, type, message); 309 | } 310 | void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) { 311 | procs.devicePopErrorScope(device, callback, userdata); 312 | } 313 | void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) { 314 | procs.devicePushErrorScope(device, filter); 315 | } 316 | void wgpuDeviceSetDeviceLostCallback(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata) { 317 | procs.deviceSetDeviceLostCallback(device, callback, userdata); 318 | } 319 | void wgpuDeviceSetLabel(WGPUDevice device, char const * label) { 320 | procs.deviceSetLabel(device, label); 321 | } 322 | void wgpuDeviceSetLoggingCallback(WGPUDevice device, WGPULoggingCallback callback, void * userdata) { 323 | procs.deviceSetLoggingCallback(device, callback, userdata); 324 | } 325 | void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) { 326 | procs.deviceSetUncapturedErrorCallback(device, callback, userdata); 327 | } 328 | void wgpuDeviceTick(WGPUDevice device) { 329 | procs.deviceTick(device); 330 | } 331 | void wgpuDeviceValidateTextureDescriptor(WGPUDevice device, WGPUTextureDescriptor const * descriptor) { 332 | procs.deviceValidateTextureDescriptor(device, descriptor); 333 | } 334 | void wgpuDeviceReference(WGPUDevice device) { 335 | procs.deviceReference(device); 336 | } 337 | void wgpuDeviceRelease(WGPUDevice device) { 338 | procs.deviceRelease(device); 339 | } 340 | 341 | void wgpuExternalTextureDestroy(WGPUExternalTexture externalTexture) { 342 | procs.externalTextureDestroy(externalTexture); 343 | } 344 | void wgpuExternalTextureExpire(WGPUExternalTexture externalTexture) { 345 | procs.externalTextureExpire(externalTexture); 346 | } 347 | void wgpuExternalTextureRefresh(WGPUExternalTexture externalTexture) { 348 | procs.externalTextureRefresh(externalTexture); 349 | } 350 | void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, char const * label) { 351 | procs.externalTextureSetLabel(externalTexture, label); 352 | } 353 | void wgpuExternalTextureReference(WGPUExternalTexture externalTexture) { 354 | procs.externalTextureReference(externalTexture); 355 | } 356 | void wgpuExternalTextureRelease(WGPUExternalTexture externalTexture) { 357 | procs.externalTextureRelease(externalTexture); 358 | } 359 | 360 | WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) { 361 | return procs.instanceCreateSurface(instance, descriptor); 362 | } 363 | void wgpuInstanceProcessEvents(WGPUInstance instance) { 364 | procs.instanceProcessEvents(instance); 365 | } 366 | void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) { 367 | procs.instanceRequestAdapter(instance, options, callback, userdata); 368 | } 369 | void wgpuInstanceReference(WGPUInstance instance) { 370 | procs.instanceReference(instance); 371 | } 372 | void wgpuInstanceRelease(WGPUInstance instance) { 373 | procs.instanceRelease(instance); 374 | } 375 | 376 | void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) { 377 | procs.pipelineLayoutSetLabel(pipelineLayout, label); 378 | } 379 | void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) { 380 | procs.pipelineLayoutReference(pipelineLayout); 381 | } 382 | void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) { 383 | procs.pipelineLayoutRelease(pipelineLayout); 384 | } 385 | 386 | void wgpuQuerySetDestroy(WGPUQuerySet querySet) { 387 | procs.querySetDestroy(querySet); 388 | } 389 | uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) { 390 | return procs.querySetGetCount(querySet); 391 | } 392 | WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) { 393 | return procs.querySetGetType(querySet); 394 | } 395 | void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) { 396 | procs.querySetSetLabel(querySet, label); 397 | } 398 | void wgpuQuerySetReference(WGPUQuerySet querySet) { 399 | procs.querySetReference(querySet); 400 | } 401 | void wgpuQuerySetRelease(WGPUQuerySet querySet) { 402 | procs.querySetRelease(querySet); 403 | } 404 | 405 | void wgpuQueueCopyExternalTextureForBrowser(WGPUQueue queue, WGPUImageCopyExternalTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUCopyTextureForBrowserOptions const * options) { 406 | procs.queueCopyExternalTextureForBrowser(queue, source, destination, copySize, options); 407 | } 408 | void wgpuQueueCopyTextureForBrowser(WGPUQueue queue, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUCopyTextureForBrowserOptions const * options) { 409 | procs.queueCopyTextureForBrowser(queue, source, destination, copySize, options); 410 | } 411 | void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, uint64_t signalValue, WGPUQueueWorkDoneCallback callback, void * userdata) { 412 | procs.queueOnSubmittedWorkDone(queue, signalValue, callback, userdata); 413 | } 414 | void wgpuQueueSetLabel(WGPUQueue queue, char const * label) { 415 | procs.queueSetLabel(queue, label); 416 | } 417 | void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) { 418 | procs.queueSubmit(queue, commandCount, commands); 419 | } 420 | void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) { 421 | procs.queueWriteBuffer(queue, buffer, bufferOffset, data, size); 422 | } 423 | void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) { 424 | procs.queueWriteTexture(queue, destination, data, dataSize, dataLayout, writeSize); 425 | } 426 | void wgpuQueueReference(WGPUQueue queue) { 427 | procs.queueReference(queue); 428 | } 429 | void wgpuQueueRelease(WGPUQueue queue) { 430 | procs.queueRelease(queue); 431 | } 432 | 433 | void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) { 434 | procs.renderBundleSetLabel(renderBundle, label); 435 | } 436 | void wgpuRenderBundleReference(WGPURenderBundle renderBundle) { 437 | procs.renderBundleReference(renderBundle); 438 | } 439 | void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) { 440 | procs.renderBundleRelease(renderBundle); 441 | } 442 | 443 | void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { 444 | procs.renderBundleEncoderDraw(renderBundleEncoder, vertexCount, instanceCount, firstVertex, firstInstance); 445 | } 446 | void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) { 447 | procs.renderBundleEncoderDrawIndexed(renderBundleEncoder, indexCount, instanceCount, firstIndex, baseVertex, firstInstance); 448 | } 449 | void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) { 450 | procs.renderBundleEncoderDrawIndexedIndirect(renderBundleEncoder, indirectBuffer, indirectOffset); 451 | } 452 | void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) { 453 | procs.renderBundleEncoderDrawIndirect(renderBundleEncoder, indirectBuffer, indirectOffset); 454 | } 455 | WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor) { 456 | return procs.renderBundleEncoderFinish(renderBundleEncoder, descriptor); 457 | } 458 | void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) { 459 | procs.renderBundleEncoderInsertDebugMarker(renderBundleEncoder, markerLabel); 460 | } 461 | void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) { 462 | procs.renderBundleEncoderPopDebugGroup(renderBundleEncoder); 463 | } 464 | void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) { 465 | procs.renderBundleEncoderPushDebugGroup(renderBundleEncoder, groupLabel); 466 | } 467 | void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { 468 | procs.renderBundleEncoderSetBindGroup(renderBundleEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets); 469 | } 470 | void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) { 471 | procs.renderBundleEncoderSetIndexBuffer(renderBundleEncoder, buffer, format, offset, size); 472 | } 473 | void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) { 474 | procs.renderBundleEncoderSetLabel(renderBundleEncoder, label); 475 | } 476 | void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) { 477 | procs.renderBundleEncoderSetPipeline(renderBundleEncoder, pipeline); 478 | } 479 | void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) { 480 | procs.renderBundleEncoderSetVertexBuffer(renderBundleEncoder, slot, buffer, offset, size); 481 | } 482 | void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) { 483 | procs.renderBundleEncoderReference(renderBundleEncoder); 484 | } 485 | void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) { 486 | procs.renderBundleEncoderRelease(renderBundleEncoder); 487 | } 488 | 489 | void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) { 490 | procs.renderPassEncoderBeginOcclusionQuery(renderPassEncoder, queryIndex); 491 | } 492 | void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { 493 | procs.renderPassEncoderDraw(renderPassEncoder, vertexCount, instanceCount, firstVertex, firstInstance); 494 | } 495 | void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) { 496 | procs.renderPassEncoderDrawIndexed(renderPassEncoder, indexCount, instanceCount, firstIndex, baseVertex, firstInstance); 497 | } 498 | void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) { 499 | procs.renderPassEncoderDrawIndexedIndirect(renderPassEncoder, indirectBuffer, indirectOffset); 500 | } 501 | void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) { 502 | procs.renderPassEncoderDrawIndirect(renderPassEncoder, indirectBuffer, indirectOffset); 503 | } 504 | void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) { 505 | procs.renderPassEncoderEnd(renderPassEncoder); 506 | } 507 | void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) { 508 | procs.renderPassEncoderEndOcclusionQuery(renderPassEncoder); 509 | } 510 | void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) { 511 | procs.renderPassEncoderExecuteBundles(renderPassEncoder, bundleCount, bundles); 512 | } 513 | void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) { 514 | procs.renderPassEncoderInsertDebugMarker(renderPassEncoder, markerLabel); 515 | } 516 | void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) { 517 | procs.renderPassEncoderPopDebugGroup(renderPassEncoder); 518 | } 519 | void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) { 520 | procs.renderPassEncoderPushDebugGroup(renderPassEncoder, groupLabel); 521 | } 522 | void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { 523 | procs.renderPassEncoderSetBindGroup(renderPassEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets); 524 | } 525 | void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) { 526 | procs.renderPassEncoderSetBlendConstant(renderPassEncoder, color); 527 | } 528 | void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) { 529 | procs.renderPassEncoderSetIndexBuffer(renderPassEncoder, buffer, format, offset, size); 530 | } 531 | void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) { 532 | procs.renderPassEncoderSetLabel(renderPassEncoder, label); 533 | } 534 | void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) { 535 | procs.renderPassEncoderSetPipeline(renderPassEncoder, pipeline); 536 | } 537 | void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { 538 | procs.renderPassEncoderSetScissorRect(renderPassEncoder, x, y, width, height); 539 | } 540 | void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) { 541 | procs.renderPassEncoderSetStencilReference(renderPassEncoder, reference); 542 | } 543 | void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) { 544 | procs.renderPassEncoderSetVertexBuffer(renderPassEncoder, slot, buffer, offset, size); 545 | } 546 | void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) { 547 | procs.renderPassEncoderSetViewport(renderPassEncoder, x, y, width, height, minDepth, maxDepth); 548 | } 549 | void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) { 550 | procs.renderPassEncoderWriteTimestamp(renderPassEncoder, querySet, queryIndex); 551 | } 552 | void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) { 553 | procs.renderPassEncoderReference(renderPassEncoder); 554 | } 555 | void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) { 556 | procs.renderPassEncoderRelease(renderPassEncoder); 557 | } 558 | 559 | WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) { 560 | return procs.renderPipelineGetBindGroupLayout(renderPipeline, groupIndex); 561 | } 562 | void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) { 563 | procs.renderPipelineSetLabel(renderPipeline, label); 564 | } 565 | void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) { 566 | procs.renderPipelineReference(renderPipeline); 567 | } 568 | void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) { 569 | procs.renderPipelineRelease(renderPipeline); 570 | } 571 | 572 | void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) { 573 | procs.samplerSetLabel(sampler, label); 574 | } 575 | void wgpuSamplerReference(WGPUSampler sampler) { 576 | procs.samplerReference(sampler); 577 | } 578 | void wgpuSamplerRelease(WGPUSampler sampler) { 579 | procs.samplerRelease(sampler); 580 | } 581 | 582 | void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) { 583 | procs.shaderModuleGetCompilationInfo(shaderModule, callback, userdata); 584 | } 585 | void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) { 586 | procs.shaderModuleSetLabel(shaderModule, label); 587 | } 588 | void wgpuShaderModuleReference(WGPUShaderModule shaderModule) { 589 | procs.shaderModuleReference(shaderModule); 590 | } 591 | void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) { 592 | procs.shaderModuleRelease(shaderModule); 593 | } 594 | 595 | void wgpuSurfaceReference(WGPUSurface surface) { 596 | procs.surfaceReference(surface); 597 | } 598 | void wgpuSurfaceRelease(WGPUSurface surface) { 599 | procs.surfaceRelease(surface); 600 | } 601 | 602 | WGPUTexture wgpuSwapChainGetCurrentTexture(WGPUSwapChain swapChain) { 603 | return procs.swapChainGetCurrentTexture(swapChain); 604 | } 605 | WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain) { 606 | return procs.swapChainGetCurrentTextureView(swapChain); 607 | } 608 | void wgpuSwapChainPresent(WGPUSwapChain swapChain) { 609 | procs.swapChainPresent(swapChain); 610 | } 611 | void wgpuSwapChainReference(WGPUSwapChain swapChain) { 612 | procs.swapChainReference(swapChain); 613 | } 614 | void wgpuSwapChainRelease(WGPUSwapChain swapChain) { 615 | procs.swapChainRelease(swapChain); 616 | } 617 | 618 | WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor) { 619 | return procs.textureCreateView(texture, descriptor); 620 | } 621 | void wgpuTextureDestroy(WGPUTexture texture) { 622 | procs.textureDestroy(texture); 623 | } 624 | uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) { 625 | return procs.textureGetDepthOrArrayLayers(texture); 626 | } 627 | WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture) { 628 | return procs.textureGetDimension(texture); 629 | } 630 | WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) { 631 | return procs.textureGetFormat(texture); 632 | } 633 | uint32_t wgpuTextureGetHeight(WGPUTexture texture) { 634 | return procs.textureGetHeight(texture); 635 | } 636 | uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) { 637 | return procs.textureGetMipLevelCount(texture); 638 | } 639 | uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) { 640 | return procs.textureGetSampleCount(texture); 641 | } 642 | WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) { 643 | return procs.textureGetUsage(texture); 644 | } 645 | uint32_t wgpuTextureGetWidth(WGPUTexture texture) { 646 | return procs.textureGetWidth(texture); 647 | } 648 | void wgpuTextureSetLabel(WGPUTexture texture, char const * label) { 649 | procs.textureSetLabel(texture, label); 650 | } 651 | void wgpuTextureReference(WGPUTexture texture) { 652 | procs.textureReference(texture); 653 | } 654 | void wgpuTextureRelease(WGPUTexture texture) { 655 | procs.textureRelease(texture); 656 | } 657 | 658 | void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) { 659 | procs.textureViewSetLabel(textureView, label); 660 | } 661 | void wgpuTextureViewReference(WGPUTextureView textureView) { 662 | procs.textureViewReference(textureView); 663 | } 664 | void wgpuTextureViewRelease(WGPUTextureView textureView) { 665 | procs.textureViewRelease(textureView); 666 | } 667 | 668 | --------------------------------------------------------------------------------