From f2b77095a0ee65dfc89aae7259de17b4f4b8d055 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 9 Oct 2023 09:54:37 +0200 Subject: [PATCH] Update to wgpu-native 0.17.0.2 (#370) * New webgpu.h and wgpu.h * Fix parsing * Codegen and apply fixes * Fix features and default backend * use undefined limits from lib * Fix handling of error messages. Shader messages are now also nicely formatted already * Fix min bind size and a few missed drops * these drop/release methods seem to work now * Support old feature names * revert last * flake * run codegen again * Fix shadertoy examples shader code * Fix loop to avoid hanging example-tests on the glsl examples * More renaming drop -> release * use matching manylinyx by cibuildwheel * try * wrong copy-paste * dont build 32bit Linux wheel, because we have no such binary for wgpu-native * more build tweaks * Hide repeating error messages. * changelog * lib calls raise Python errors * Fix features * Append to changelog * Fix tests * undo the undoing of an earlier change * Update CHANGELOG.md Co-authored-by: Korijn van Golen --------- Co-authored-by: Korijn van Golen --- .github/workflows/ci.yml | 6 +- CHANGELOG.md | 9 + codegen/hparser.py | 20 +- codegen/rspatcher.py | 8 +- codegen/tests/test_codegen_rspatcher.py | 4 +- examples/shadertoy_blink.py | 4 +- examples/shadertoy_circuits.py | 4 +- examples/shadertoy_flyby.py | 18 +- examples/shadertoy_gen_art.py | 12 +- examples/shadertoy_glsl_flame.py | 10 +- examples/shadertoy_liberation.py | 8 +- examples/shadertoy_matrix.py | 18 +- examples/shadertoy_riders.py | 4 +- examples/shadertoy_sea.py | 34 +- examples/shadertoy_star.py | 22 +- tests/test_rs_basics.py | 128 ++- wgpu/backends/rs.py | 373 +++---- wgpu/backends/rs_ffi.py | 16 +- wgpu/backends/rs_helpers.py | 263 +++-- wgpu/backends/rs_mappings.py | 41 +- wgpu/gui/offscreen.py | 15 +- wgpu/resources/codegen_report.md | 17 +- wgpu/resources/webgpu.h | 1219 +++++++++++++---------- wgpu/resources/wgpu.h | 113 +-- wgpu/utils/shadertoy.py | 6 + 25 files changed, 1298 insertions(+), 1074 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6109020..5fada066 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,7 +214,11 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools twine - name: Build wheels - uses: pypa/cibuildwheel@v2.1.3 + uses: pypa/cibuildwheel@v2.16.2 + env: + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 + CIBW_ARCHS_LINUX: x86_64 + CIBW_SKIP: cp39-musllinux_x86_64 with: output-dir: dist - name: Twine check diff --git a/CHANGELOG.md b/CHANGELOG.md index 4afc04fa..5349a11f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,15 @@ Added: * New `wgpu.wgsl_language_features` property, which for now always returns an empty set. * The `GPUShaderModule.compilation_info` property (and its async version) are replaced with a `get_compilation_info()` method. +* The WebGPU features "bgra8unorm-storage" and "float32-filterable" are now available. + +Changed: + +* The binary wheels are now based on manylinux 2.28, and the 32bit Linux wheels are no longer built. +* In WGSL: toplevel constants must be defined using `const`, using `let` will now fail. +* In WGSL: it is no longer possible to re-declare an existing variable name. +* Error messages may look a bit different, since wgpu-native now produces nice messages replacing our custom ones. +* Errors produced by a call into a wgpu-native function now produce a Python exception (no more async logging of errors). ### [v0.9.5] - 02-10-2023 diff --git a/codegen/hparser.py b/codegen/hparser.py index 2557bde5..effdd260 100644 --- a/codegen/hparser.py +++ b/codegen/hparser.py @@ -17,11 +17,21 @@ def _get_wgpu_header(): # Just removing them, plus a few extra lines, seems to do the trick. lines2 = [] for line in lines1: - if line.startswith("#"): + if line.startswith("#define ") and len(line.split()) > 2 and "0x" in line: + line = line.replace("(", "").replace(")", "") + elif line.startswith("#"): continue elif 'extern "C"' in line: continue - line = line.replace("WGPU_EXPORT ", "") + for define_to_drop in [ + "WGPU_EXPORT ", + "WGPU_NULLABLE ", + " WGPU_OBJECT_ATTRIBUTE", + " WGPU_ENUM_ATTRIBUTE", + " WGPU_FUNCTION_ATTRIBUTE", + " WGPU_STRUCTURE_ATTRIBUTE", + ]: + line = line.replace(define_to_drop, "") lines2.append(line) return "\n".join(lines2) @@ -68,7 +78,7 @@ def _parse_from_h(self): code = self.source # Collect enums and flags. This is easy. - # Note that flags are defines as enums and then defined as flags later. + # Note that flags are first defined as enums and then redefined as flags later. i1 = i2 = i3 = i4 = 0 while True: # Find enum @@ -113,7 +123,9 @@ def _parse_from_h(self): # Turn some enums into flags for line in code.splitlines(): if line.startswith("typedef WGPUFlags "): - name = line.strip().strip(";").split()[-1] + parts = line.strip().strip(";").split() + assert len(parts) == 3 + name = parts[-1] if name.endswith("Flags"): assert name.startswith("WGPU") name = name[4:-5] diff --git a/codegen/rspatcher.py b/codegen/rspatcher.py index 68e5bbd0..94adda8f 100644 --- a/codegen/rspatcher.py +++ b/codegen/rspatcher.py @@ -190,11 +190,15 @@ def apply(self, code): detected = set() for line, i in self.iter_lines(): - if "lib.wgpu" in line: - start = line.index("lib.wgpu") + 4 + if "lib.wgpu" in line or "libf.wgpu" in line: + start = line.index(".wgpu") + 1 end = line.index("(", start) name = line[start:end] indent = " " * (len(line) - len(line.lstrip())) + if "lib.wgpu" in line: + self.insert_line( + i, f"{indent}# FIXME: wgpu func calls must be done from libf" + ) if name not in hp.functions: msg = f"unknown C function {name}" self.insert_line(i, f"{indent}# FIXME: {msg}") diff --git a/codegen/tests/test_codegen_rspatcher.py b/codegen/tests/test_codegen_rspatcher.py index 65314c09..ce3114c8 100644 --- a/codegen/tests/test_codegen_rspatcher.py +++ b/codegen/tests/test_codegen_rspatcher.py @@ -10,8 +10,8 @@ def dedent(code): def test_patch_functions(): code1 = """ - lib.wgpuAdapterRequestDevice(1, 2, 3) - lib.wgpuFooBar(1, 2, 3) + libf.wgpuAdapterRequestDevice(1, 2, 3) + libf.wgpuFooBar(1, 2, 3) """ code2 = patch_rs_backend(dedent(code1)) diff --git a/examples/shadertoy_blink.py b/examples/shadertoy_blink.py index dac1cf5a..6c1877d8 100644 --- a/examples/shadertoy_blink.py +++ b/examples/shadertoy_blink.py @@ -2,9 +2,9 @@ shader_code = """ -fn render(p: vec2) -> vec3 { +fn render(p_: vec2) -> vec3 { let s = sin(i_time) * sin(i_time) * sin(i_time) + 0.5; - var p = p; + var p = p_; var d = length(p * 0.8) - pow(2.0 * abs(0.5 - fract(atan2(p.y, p.x) / 3.1416 * 2.5 + i_time * 0.3)), 2.5) * 0.1; var col = vec3(0.0); diff --git a/examples/shadertoy_circuits.py b/examples/shadertoy_circuits.py index 3a383371..e8d6be64 100644 --- a/examples/shadertoy_circuits.py +++ b/examples/shadertoy_circuits.py @@ -16,8 +16,8 @@ return mat2x2(c, s, -s, c); } -fn fractal(p: vec2) -> vec3 { - var p = vec2(p.x/p.y,1./p.y); +fn fractal(p_: vec2) -> vec3 { + var p = vec2(p_.x/p_.y,1./p_.y); p.y+=i_time*sign(p.y); p.x+=sin(i_time*.1)*sign(p.y)*4.; p.y=fract(p.y*.05); diff --git a/examples/shadertoy_flyby.py b/examples/shadertoy_flyby.py index 41fd39b5..73a015f8 100644 --- a/examples/shadertoy_flyby.py +++ b/examples/shadertoy_flyby.py @@ -28,8 +28,8 @@ return mat2x2(c, s, -s, c); } -fn fractal(p: vec2) -> vec3 { - var p = fract(p*0.1); +fn fractal(p_: vec2) -> vec3 { + var p = fract(p_*0.1); var m = 1000.0; for (var i = 0; i < 7; i = i + 1) { p = ( abs(p) / clamp( abs(p.x*p.y), 0.25, 2.0 ) ) - 1.2; @@ -39,8 +39,8 @@ return m*vec3(abs(p.x),m,abs(p.y)); } -fn coso(pp: vec3) -> f32 { - var pp = pp; +fn coso(pp_: vec3) -> f32 { + var pp = pp_; pp*=.7; pp = vec3( pp.xy * rot(pp.z*2.0), pp.z); @@ -63,11 +63,11 @@ return d; } -fn de(p: vec3) -> f32 { +fn de(p_: vec3) -> f32 { hit=0.; br=1000.; - let pp = p - sphpos; - var p = p; + let pp = p_ - sphpos; + var p = p_; let pxy = p.xy - path(p.z).xy; p.x = pxy.x; p.y = pxy.y; @@ -98,8 +98,8 @@ } -fn march(fro: vec3, dir: vec3) -> vec3 { - var dir = dir; +fn march(fro: vec3, dir_: vec3) -> vec3 { + var dir = dir_; var uv: vec2 = vec2( atan2( dir.x , dir.y ) + i_time * 0.5, length(dir.xy) + sin(i_time * 0.2)); var col: vec3 = fractal(uv); var d: f32 = 0.0; diff --git a/examples/shadertoy_gen_art.py b/examples/shadertoy_gen_art.py index 49721b94..4e858f5d 100644 --- a/examples/shadertoy_gen_art.py +++ b/examples/shadertoy_gen_art.py @@ -4,13 +4,13 @@ // migrated from: https://www.shadertoy.com/view/mds3DX -let SHAPE_SIZE : f32 = .618; -let CHROMATIC_ABBERATION : f32 = .01; -let ITERATIONS : f32 = 10.; -let INITIAL_LUMA : f32= .5; +const SHAPE_SIZE : f32 = .618; +const CHROMATIC_ABBERATION : f32 = .01; +const ITERATIONS : f32 = 10.; +const INITIAL_LUMA : f32= .5; -let PI : f32 = 3.14159265359; -let TWO_PI : f32 = 6.28318530718; +const PI : f32 = 3.14159265359; +const TWO_PI : f32 = 6.28318530718; fn rotate2d(_angle : f32) -> mat2x2 { return mat2x2(cos(_angle),-sin(_angle),sin(_angle),cos(_angle)); diff --git a/examples/shadertoy_glsl_flame.py b/examples/shadertoy_glsl_flame.py index 9e02a9c4..a81172e5 100644 --- a/examples/shadertoy_glsl_flame.py +++ b/examples/shadertoy_glsl_flame.py @@ -38,7 +38,7 @@ float d = 0.0, glow = 0.0, eps = 0.02; vec3 p = org; bool glowed = false; - + for(int i=0; i<64; i++) { d = scene(p) + eps; @@ -58,15 +58,15 @@ { vec2 v = -1.0 + 2.0 * fragCoord.xy / iResolution.xy; v.x *= iResolution.x/iResolution.y; - + vec3 org = vec3(0., -2., 4.); vec3 dir = normalize(vec3(v.x*1.6, -v.y, -1.5)); - + vec4 p = raymarch(org, dir); float glow = p.w; - + vec4 col = mix(vec4(1.,.5,.1,1.), vec4(0.1,.5,1.,1.), p.y*.02+.4); - + fragColor = mix(vec4(0.), col, pow(glow*2.,4.)); //fragColor = mix(vec4(1.), mix(vec4(1.,.5,.1,1.),vec4(0.1,.5,1.,1.),p.y*.02+.4), pow(glow*2.,4.)); diff --git a/examples/shadertoy_liberation.py b/examples/shadertoy_liberation.py index 4d2d3ab1..09140578 100644 --- a/examples/shadertoy_liberation.py +++ b/examples/shadertoy_liberation.py @@ -22,12 +22,12 @@ return x - y * floor( x / y ); } -fn de(pos: vec3) -> f32 { +fn de(pos_: vec3) -> f32 { var t = mod1(i_time, 17.0); var a = smoothstep(13.0, 15.0, t) * 8.0 - smoothstep(4.0, 0.0, t) * 4.0; var f = sin(i_time * 5.0 + sin(i_time * 20.0) * 0.2); - var pos = pos; + var pos = pos_; let pxz = pos.xz * rot(i_time + 0.5); pos.x = pxz.x; @@ -93,14 +93,14 @@ return normalize( vec3( de(p + d.yxx), de(p + d.xyx), de(p + d.xxy) ) - de(p) ); } -fn march(fro: vec3, dir: vec3, frag_coord: vec2) -> vec3 { +fn march(fro: vec3, dir_: vec3, frag_coord: vec2) -> vec3 { var d = 0.0; var td = 0.0; var maxdist = 30.0; var p = fro; var col = vec3(0.0); - var dir = dir; + var dir = dir_; for (var i = 0; i < 100; i+=1) { var d2 = de(p) * (1.0 - hash12(frag_coord.xy + i_time) * 0.2); diff --git a/examples/shadertoy_matrix.py b/examples/shadertoy_matrix.py index ee01b811..1687df15 100644 --- a/examples/shadertoy_matrix.py +++ b/examples/shadertoy_matrix.py @@ -4,7 +4,7 @@ // migrated from https://www.shadertoy.com/view/NlsXDH, By Kali -let det = 0.001; +const det = 0.001; var t: f32; var boxhit: f32; @@ -38,8 +38,8 @@ return p; } -fn fractal(p: vec2) -> f32 { - var p = abs( 5.0 - mod_2( p*0.2, 10.0 ) ) - 5.0; +fn fractal(p_: vec2) -> f32 { + var p = abs( 5.0 - mod_2( p_*0.2, 10.0 ) ) - 5.0; var ot = 1000.; for (var i = 0; i < 7; i+=1) { p = abs(p) / clamp(p.x*p.y, 0.25, 2.0) - 1.0; @@ -56,7 +56,8 @@ return length(max(vec3(0.),c))+min(0.,max(c.x,max(c.y,c.z))); } -fn de(p: vec3) -> f32 { +fn de(p_: vec3) -> f32 { + var p = p_; boxhit = 0.0; var p2 = p-adv; @@ -74,7 +75,6 @@ let b = box(p2, vec3(1.0)); - var p = p; let p_xy = p.xy - path(p.z).xy; p.x = p_xy.x; p.y = p_xy.y; @@ -130,8 +130,8 @@ return g; } -fn lookat(dir: vec3, up: vec3) -> mat3x3 { - let dir = normalize(dir); +fn lookat(dir_: vec3, up: vec3) -> mat3x3 { + let dir = normalize(dir_); let rt = normalize(cross(dir, normalize(up))); return mat3x3(rt, cross(rt, dir), dir); } @@ -141,8 +141,8 @@ t=i_time*7.0; let fro=path(t); adv=path(t+6.+sin(t*.1)*3.); - let dir=normalize(vec3(uv, 0.7)); - let dir=lookat(adv-fro, vec3(0.0, 1.0, 0.0)) * dir; + var dir=normalize(vec3(uv, 0.7)); + dir=lookat(adv-fro, vec3(0.0, 1.0, 0.0)) * dir; let col=march(fro, dir, frag_coord); return vec4(col,1.0); } diff --git a/examples/shadertoy_riders.py b/examples/shadertoy_riders.py index ddec8e89..ce040b66 100644 --- a/examples/shadertoy_riders.py +++ b/examples/shadertoy_riders.py @@ -10,8 +10,8 @@ return mat2x2(c, s, -s, c); } -fn render(p: vec2) -> vec3 { - var p = p; +fn render(p_: vec2) -> vec3 { + var p = p_; p*=rot(i_time*.1)*(.0002+.7*pow(smoothstep(0.0,0.5,abs(0.5-fract(i_time*.01))),3.)); p.y-=.2266; p.x+=.2082; diff --git a/examples/shadertoy_sea.py b/examples/shadertoy_sea.py index 6645a806..fa02caa7 100644 --- a/examples/shadertoy_sea.py +++ b/examples/shadertoy_sea.py @@ -4,21 +4,21 @@ // migrated from https://www.shadertoy.com/view/Ms2SD1, "Seascape" by Alexander Alekseev aka TDM - 2014 -let NUM_STEPS = 8; -let PI = 3.141592; -let EPSILON = 0.001; +const NUM_STEPS = 8; +const PI = 3.141592; +const EPSILON = 0.001; -let ITER_GEOMETRY = 3; -let ITER_FRAGMENT = 5; +const ITER_GEOMETRY = 3; +const ITER_FRAGMENT = 5; -let SEA_HEIGHT = 0.6; -let SEA_CHOPPY = 4.0; -let SEA_SPEED = 0.8; -let SEA_FREQ = 0.16; -let SEA_BASE = vec3(0.0,0.09,0.18); -let SEA_WATER_COLOR = vec3(0.48, 0.54, 0.36); +const SEA_HEIGHT = 0.6; +const SEA_CHOPPY = 4.0; +const SEA_SPEED = 0.8; +const SEA_FREQ = 0.16; +const SEA_BASE = vec3(0.0,0.09,0.18); +const SEA_WATER_COLOR = vec3(0.48, 0.54, 0.36); -// let octave_m = mat2x2(1.6, 1.2, -1.2, 1.6); +// const octave_m = mat2x2(1.6, 1.2, -1.2, 1.6); fn hash( p : vec2 ) -> f32 { // let h = dot(p,vec2(127.1,311.7)); // percession issue? @@ -60,15 +60,15 @@ } // sky -fn getSkyColor( e : vec3 ) -> vec3 { - var e = e; +fn getSkyColor( e_ : vec3 ) -> vec3 { + var e = e_; e.y = (max(e.y,0.0) * 0.8 + 0.2) * 0.8; return vec3(pow(1.0-e.y, 2.0), 1.0-e.y, 0.6+(1.0-e.y)*0.4) * 1.1; } // sea -fn sea_octave( uv : vec2, choppy : f32 ) -> f32 { - let uv = uv + noise(uv); +fn sea_octave( uv_ : vec2, choppy : f32 ) -> f32 { + let uv = uv_ + noise(uv_); var wv = 1.0-abs(sin(uv)); let swv = abs(cos(uv)); wv = mix(wv,swv,wv); @@ -197,7 +197,7 @@ } color = color / 9.0; - let color = getPixel(frag_coord, time); + color = getPixel(frag_coord, time); // post return vec4(pow(color, vec3(0.65)), 1.0); diff --git a/examples/shadertoy_star.py b/examples/shadertoy_star.py index 7884ece6..48e95ab5 100644 --- a/examples/shadertoy_star.py +++ b/examples/shadertoy_star.py @@ -4,20 +4,20 @@ // migrated from: https://www.shadertoy.com/view/XlfGRj, By Kali -let iterations = 17; -let formuparam = 0.53; +const iterations = 17; +const formuparam = 0.53; -let volsteps = 20; -let stepsize = 0.1; +const volsteps = 20; +const stepsize = 0.1; -let zoom = 0.800; -let tile = 0.850; -let speed = 0.010; +const zoom = 0.800; +const tile = 0.850; +const speed = 0.010; -let brightness = 0.0015; -let darkmatter = 0.300; -let distfading = 0.730; -let saturation = 0.850; +const brightness = 0.0015; +const darkmatter = 0.300; +const distfading = 0.730; +const saturation = 0.850; fn mod3( p1 : vec3, p2 : vec3 ) -> vec3 { let mx = p1.x - p2.x * floor( p1.x / p2.x ); diff --git a/tests/test_rs_basics.py b/tests/test_rs_basics.py index 9c339e5c..e60a04fe 100644 --- a/tests/test_rs_basics.py +++ b/tests/test_rs_basics.py @@ -711,24 +711,27 @@ def test_parse_shader_error1(caplog): """ expected = """ - Shader error: label: Some("") - Parsing error: invalid field accessor `invalid_attr` + Validation Error - ┌─ wgsl:9:8 + Caused by: + In wgpuDeviceCreateShaderModule + + Shader '' parsing error: invalid field accessor `invalid_attr` + ┌─ wgsl:9:9 │ 9 │ out.invalid_attr = vec4(0.0, 0.0, 1.0); │ ^^^^^^^^^^^^ invalid accessor - │ - = note: + + + invalid field accessor `invalid_attr` """ code = dedent(code) expected = dedent(expected) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) - error = caplog.records[0].msg.strip() + error = err.value.message assert error == expected, f"Expected:\n\n{expected}" @@ -744,24 +747,27 @@ def test_parse_shader_error2(caplog): """ expected = """ - Shader error: label: Some("") - Parsing error: expected ',', found ';' + Validation Error + + Caused by: + In wgpuDeviceCreateShaderModule - ┌─ wgsl:2:37 + Shader '' parsing error: expected ',', found ';' + ┌─ wgsl:2:38 │ 2 │ @location(0) texcoord : vec2; │ ^ expected ',' - │ - = note: + + + expected ',', found ';' """ code = dedent(code) expected = dedent(expected) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) - error = caplog.records[0].msg.strip() + error = err.value.message assert error == expected, f"Expected:\n\n{expected}" @@ -777,24 +783,29 @@ def test_parse_shader_error3(caplog): """ expected = """ - Shader error: label: Some("") - Parsing error: unknown scalar type: 'f3' + Validation Error - ┌─ wgsl:3:38 + Caused by: + In wgpuDeviceCreateShaderModule + + Shader '' parsing error: unknown scalar type: 'f3' + ┌─ wgsl:3:39 │ 3 │ @builtin(position) position: vec4, │ ^^ unknown scalar type │ - = note: "Valid scalar types are f16, f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, bool" + = note: Valid scalar types are f32, f64, i32, u32, bool + + + unknown scalar type: 'f3' """ code = dedent(code) expected = dedent(expected) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) - error = caplog.records[0].msg.strip() + error = err.value.message assert error == expected, f"Expected:\n\n{expected}" @@ -810,17 +821,33 @@ def test_parse_shader_error4(caplog): """ expected = """ - Shader error: label: Some("") - { message: "Index 4 is out of bounds for expression [7]", labels: [], notes: [] } + Validation Error + + Caused by: + In wgpuDeviceCreateShaderModule + + Shader validation error: + ┌─ :1:1 + │ + 1 │ ╭ fn foobar() { + 2 │ │ let m = mat2x2(0.0, 0.0, 0.0, 0.); + 3 │ │ let scales = m[4]; + │ │ ^^^^ naga::Expression [9] + │ ╰──────────────────────^ naga::Function [1] + + + Function [1] 'foobar' is invalid + Expression [9] is invalid + Type resolution failed + Index 4 is out of bounds for expression [7] """ code = dedent(code) expected = dedent(expected) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) - error = caplog.records[0].msg.strip() + error = err.value.message assert error == expected, f"Expected:\n\n{expected}" @@ -846,27 +873,32 @@ def test_validate_shader_error1(caplog): expected1 = """Left: Load { pointer: [3] } of type Matrix { columns: Quad, rows: Quad, width: 4 }""" expected2 = """Right: Load { pointer: [6] } of type Vector { size: Tri, kind: Float, width: 4 }""" expected3 = """ - Shader error: label: Some("") - Validation error: Function(Expression { handle: [8], error: InvalidBinaryOperandTypes(Multiply, [5], [7]) }) + Validation Error + + Caused by: + In wgpuDeviceCreateShaderModule - ┌─ wgsl:10:19 + Shader validation error: + ┌─ :10:20 │ 10 │ out.position = matrics * out.position; - │ ^^^^^^^^^^^^^^^^^^^^^^ InvalidBinaryOperandTypes(Multiply, [5], [7]) - │ - = note: + │ ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [8] + + + Entry point vs_main at Vertex is invalid + Expression [8] is invalid + Operation Multiply can't work with [5] and [7] """ code = dedent(code) expected3 = dedent(expected3) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) # skip error info assert caplog.records[0].msg == expected1 assert caplog.records[1].msg == expected2 - assert caplog.records[2].msg.strip() == expected3, f"Expected:\n\n{expected3}" + assert err.value.message.strip() == expected3, f"Expected:\n\n{expected3}" def test_validate_shader_error2(caplog): @@ -891,26 +923,30 @@ def test_validate_shader_error2(caplog): expected1 = """Returning Some(Vector { size: Tri, kind: Float, width: 4 }) where Some(Vector { size: Quad, kind: Float, width: 4 }) is expected""" expected2 = """ - Shader error: label: Some("") - Validation error: Function(InvalidReturnType(Some([9]))) + Validation Error - ┌─ wgsl:9:15 + Caused by: + In wgpuDeviceCreateShaderModule + + Shader validation error: + ┌─ :9:16 │ 9 │ return vec3(1.0, 0.0, 1.0); - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Function(InvalidReturnType(Some([9]))) - │ - = note: + │ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [9] + + + Entry point fs_main at Vertex is invalid + The `return` value Some([9]) does not match the function return value """ code = dedent(code) expected2 = dedent(expected2) - - with raises(RuntimeError): + with raises(wgpu.GPUError) as err: device.create_shader_module(code=code) # skip error info assert caplog.records[0].msg == expected1 - assert caplog.records[1].msg.strip() == expected2, f"Expected:\n\n{expected2}" + assert err.value.message.strip() == expected2, f"Expected:\n\n{expected2}" if __name__ == "__main__": diff --git a/wgpu/backends/rs.py b/wgpu/backends/rs.py index 111af27f..f6a7a7b2 100644 --- a/wgpu/backends/rs.py +++ b/wgpu/backends/rs.py @@ -48,10 +48,11 @@ get_surface_id_from_canvas, get_memoryview_from_address, get_memoryview_and_address, - parse_wgsl_error, to_snake_case, to_camel_case, - delayed_dropper, + DelayedReleaser, + ErrorHandler, + SafeLibCalls, ) @@ -59,32 +60,22 @@ apidiff = ApiDiff() # The wgpu-native version that we target/expect -__version__ = "0.14.2.3" -__commit_sha__ = "b6a188c6ac386b249d8decaf806e87946058383e" +__version__ = "0.17.0.2" +__commit_sha__ = "dd9845c9ae41e10794a50617ead08febad66bf97" version_info = tuple(map(int, __version__.split("."))) check_expected_version(version_info) # produces a warning on mismatch # %% Helper functions and objects -WGPU_LIMIT_U32_UNDEFINED = 0xFFFFFFFF -WGPU_LIMIT_U64_UNDEFINED = 0xFFFFFFFFFFFFFFFF - - -# Features in WebGPU that don't map to wgpu-native yet -KNOWN_MISSING_FEATURES = [ - "bgra8unorm-storage", - "float32-filterable", -] # Features that wgpu-native supports that are not part of WebGPU NATIVE_FEATURES = ( - "multi_draw_indirect", - "push_constants", - "texture_adapter_specific_format_features", - "multi_draw_indirect", - "multi_draw_indirect_count", - "vertex_writable_storage", + "PushConstants", + "TextureAdapterSpecificFormatFeatures", + "MultiDrawIndirect", + "MultiDrawIndirectCount", + "VertexWritableStorage", ) # Object to be able to bind the lifetime of objects to other objects @@ -197,6 +188,11 @@ def check_struct(struct_name, d): raise ValueError(f"Invalid keys in {struct_name}: {invalid_keys}") +delayed_releaser = DelayedReleaser() +error_handler = ErrorHandler(logger) +libf = SafeLibCalls(lib, error_handler) + + # %% The API @@ -238,7 +234,7 @@ def request_adapter(self, *, canvas, power_preference=None): # See https://github.com/gfx-rs/wgpu/issues/1416 # todo: for the moment we default to forcing Vulkan on Windows force_backend = os.getenv("WGPU_BACKEND_TYPE", None) - backend = enum_str2int["BackendType"]["Null"] + backend = enum_str2int["BackendType"]["Undefined"] if force_backend is None: # Allow OUR defaults if sys.platform.startswith("win"): backend = enum_str2int["BackendType"]["Vulkan"] @@ -255,21 +251,14 @@ def request_adapter(self, *, canvas, power_preference=None): # ----- Request adapter - # H: chain: WGPUChainedStruct, backend: WGPUBackendType - extras = new_struct_p( - "WGPUAdapterExtras *", - backend=backend, - # not used: chain - ) - extras.chain.sType = lib.WGPUSType_AdapterExtras - - # H: nextInChain: WGPUChainedStruct *, compatibleSurface: WGPUSurface, powerPreference: WGPUPowerPreference, forceFallbackAdapter: bool + # H: nextInChain: WGPUChainedStruct *, compatibleSurface: WGPUSurface, powerPreference: WGPUPowerPreference, backendType: WGPUBackendType, forceFallbackAdapter: bool struct = new_struct_p( "WGPURequestAdapterOptions *", compatibleSurface=surface_id, - nextInChain=ffi.cast("WGPUChainedStruct * ", extras), powerPreference=power_preference or "high-performance", forceFallbackAdapter=False, + backendType=backend, + # not used: nextInChain ) adapter_id = None @@ -282,8 +271,8 @@ def callback(status, result, message, userdata): nonlocal adapter_id adapter_id = result - # H: void f(WGPUInstance instance, WGPURequestAdapterOptions const * options /* nullable */, WGPURequestAdapterCallback callback, void * userdata) - lib.wgpuInstanceRequestAdapter(get_wgpu_instance(), struct, callback, ffi.NULL) + # H: void f(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) + libf.wgpuInstanceRequestAdapter(get_wgpu_instance(), struct, callback, ffi.NULL) # For now, Rust will call the callback immediately # todo: when wgpu gets an event loop -> while run wgpu event loop or something @@ -307,7 +296,7 @@ def callback(status, result, message, userdata): ) # H: void f(WGPUAdapter adapter, WGPUAdapterProperties * properties) - lib.wgpuAdapterGetProperties(adapter_id, c_properties) + libf.wgpuAdapterGetProperties(adapter_id, c_properties) def to_py_str(key): char_p = getattr(c_properties, key) @@ -340,7 +329,7 @@ def to_py_str(key): ) c_limits = c_supported_limits.limits # H: bool f(WGPUAdapter adapter, WGPUSupportedLimits * limits) - lib.wgpuAdapterGetLimits(adapter_id, c_supported_limits) + libf.wgpuAdapterGetLimits(adapter_id, c_supported_limits) limits = {to_snake_case(k): getattr(c_limits, k) for k in sorted(dir(c_limits))} # ----- Get adapter features @@ -349,20 +338,16 @@ def to_py_str(key): features = set() for f in sorted(enums.FeatureName): key = f"FeatureName.{f}" - if key not in enummap: - if f not in KNOWN_MISSING_FEATURES: # pragma: no cover - raise RuntimeError(f"Unexpected feature {f}") - continue i = enummap[key] # H: bool f(WGPUAdapter adapter, WGPUFeatureName feature) - if lib.wgpuAdapterHasFeature(adapter_id, i): + if libf.wgpuAdapterHasFeature(adapter_id, i): features.add(f) # Native features for f in NATIVE_FEATURES: - i = getattr(lib, f"WGPUNativeFeature_{f.upper()}") + i = getattr(lib, f"WGPUNativeFeature_{f}") # H: bool f(WGPUAdapter adapter, WGPUFeatureName feature) - if lib.wgpuAdapterHasFeature(adapter_id, i): + if libf.wgpuAdapterHasFeature(adapter_id, i): features.add(f) # ----- Done @@ -394,8 +379,8 @@ def _generate_report(self): # not used: gl ) - # H: void f(WGPUInstance instance, WGPUGlobalReport* report) - lib.wgpuGenerateReport(get_wgpu_instance(), struct) + # H: void f(WGPUInstance instance, WGPUGlobalReport * report) + libf.wgpuGenerateReport(get_wgpu_instance(), struct) report = {} @@ -471,7 +456,7 @@ def get_current_texture(self): if self._current_texture is None: self._create_native_swap_chain_if_needed() # H: WGPUTextureView f(WGPUSwapChain swapChain) - view_id = lib.wgpuSwapChainGetCurrentTextureView(self._internal) + view_id = libf.wgpuSwapChainGetCurrentTextureView(self._internal) size = self._surface_size[0], self._surface_size[1], 1 self._current_texture = GPUTextureView( "swap_chain", view_id, self._device, None, size @@ -485,7 +470,7 @@ def present(self): and self._current_texture is not None ): # H: void f(WGPUSwapChain swapChain) - lib.wgpuSwapChainPresent(self._internal) + libf.wgpuSwapChainPresent(self._internal) # Reset - always ask for a fresh texture (exactly once) on each draw self._current_texture = None @@ -516,27 +501,9 @@ def _create_native_swap_chain_if_needed(self): # * https://github.com/gfx-rs/wgpu/blob/e54a36ee/wgpu-types/src/lib.rs#L2663-L2678 # * https://github.com/pygfx/wgpu-py/issues/256 - present_mode = 2 if getattr(canvas, "_vsync", True) else 0 - - if self._device: - # Get present mode - adapter_id = self._device.adapter._internal - c_count = ffi.new("size_t *") - # H: WGPUPresentMode const * f(WGPUSurface surface, WGPUAdapter adapter, size_t * count) - c_modes = lib.wgpuSurfaceGetSupportedPresentModes( - self._surface_id, adapter_id, c_count - ) - try: - count = c_count[0] - supported_modes = [1 * c_modes[i] for i in range(count)] - finally: - t = ffi.typeof(c_modes) - # H: void f(void* ptr, size_t size, size_t align) - lib.wgpuFree(c_modes, count * ffi.sizeof(t), ffi.alignof(t)) - - # Use a supported one if our preference is not supported - if supported_modes and present_mode not in supported_modes: - present_mode = supported_modes[0] + pm_fifo = lib.WGPUPresentMode_Fifo + pm_immediate = lib.WGPUPresentMode_Immediate + present_mode = pm_fifo if getattr(canvas, "_vsync", True) else pm_immediate # H: nextInChain: WGPUChainedStruct *, label: char *, usage: WGPUTextureUsageFlags/int, format: WGPUTextureFormat, width: int, height: int, presentMode: WGPUPresentMode struct = new_struct_p( @@ -553,10 +520,10 @@ def _create_native_swap_chain_if_needed(self): # Destroy old one if self._internal is not None: # H: void f(WGPUSwapChain swapChain) - lib.wgpuSwapChainDrop(self._internal) + libf.wgpuSwapChainRelease(self._internal) # H: WGPUSwapChain f(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor) - self._internal = lib.wgpuDeviceCreateSwapChain( + self._internal = libf.wgpuDeviceCreateSwapChain( self._device._internal, self._surface_id, struct ) @@ -603,11 +570,11 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUSwapChain swapChain) - lib.wgpuSwapChainDrop(internal) + libf.wgpuSwapChainRelease(internal) if self._surface_id is not None and lib is not None: self._surface_id, surface_id = None, self._surface_id # H: void f(WGPUSurface surface) - lib.wgpuSurfaceDrop(surface_id) + libf.wgpuSurfaceRelease(surface_id) class GPUObjectBase(base.GPUObjectBase): @@ -659,8 +626,8 @@ def request_device_tracing( def _request_device( self, label, required_features, required_limits, default_queue, trace_path ): - # This is a good moment to drop destroyed objects - delayed_dropper.drop_all_pending() + # This is a good moment to release destroyed objects + delayed_releaser.release_all_pending() # ---- Handle features @@ -668,13 +635,17 @@ def _request_device( c_features = set() for f in required_features: - if not isinstance(f, int): + if isinstance(f, str): + if "_" in f: + f = "".join(x.title() for x in f.split("_")) i1 = enummap.get(f"FeatureName.{f}", None) - i2 = getattr(lib, f"WGPUNativeFeature_{f.upper()}", None) + i2 = getattr(lib, f"WGPUNativeFeature_{f}", None) i = i2 if i1 is None else i1 if i is None: # pragma: no cover raise KeyError(f"Unknown feature: '{f}'") c_features.add(i) + else: + raise TypeError("Features must be given as str.") c_features = sorted(c_features) # makes it a list @@ -715,7 +686,7 @@ def _request_device( if trace_path: # no-cover c_trace_path = ffi.new("char []", trace_path.encode()) - # H: chain: WGPUChainedStruct, tracePath: char* + # H: chain: WGPUChainedStruct, tracePath: char * extras = new_struct_p( "WGPUDeviceExtras *", tracePath=c_trace_path, @@ -723,9 +694,20 @@ def _request_device( ) extras.chain.sType = lib.WGPUSType_DeviceExtras + # ----- Device lost + + @ffi.callback("void(WGPUDeviceLostReason, char *, void *)") + def device_lost_callback(c_reason, c_message, userdata): + reason = enum_int2str["DeviceLostReason"].get(c_reason, "Unknown") + message = ffi.string(c_message).decode(errors="ignore") + error_handler.log_error(f"The WGPU device was lost ({reason}):\n{message}") + + # Keep the ref alive + self._device_lost_callback = device_lost_callback + # ----- Request device - # H: nextInChain: WGPUChainedStruct *, label: char *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *, defaultQueue: WGPUQueueDescriptor + # H: nextInChain: WGPUChainedStruct *, label: char *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *, defaultQueue: WGPUQueueDescriptor, deviceLostCallback: WGPUDeviceLostCallback, deviceLostUserdata: void * struct = new_struct_p( "WGPUDeviceDescriptor *", label=to_c_label(label), @@ -734,6 +716,8 @@ def _request_device( requiredFeatures=ffi.new("WGPUFeatureName []", c_features), requiredLimits=c_required_limits, defaultQueue=queue_struct, + deviceLostCallback=device_lost_callback, + # not used: deviceLostUserdata ) device_id = None @@ -746,8 +730,8 @@ def callback(status, result, message, userdata): nonlocal device_id device_id = result - # H: void f(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor /* nullable */, WGPURequestDeviceCallback callback, void * userdata) - lib.wgpuAdapterRequestDevice(self._internal, struct, callback, ffi.NULL) + # H: void f(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) + libf.wgpuAdapterRequestDevice(self._internal, struct, callback, ffi.NULL) if device_id is None: # pragma: no cover raise RuntimeError("Could not obtain new device id.") @@ -762,7 +746,7 @@ def callback(status, result, message, userdata): ) c_limits = c_supported_limits.limits # H: bool f(WGPUDevice device, WGPUSupportedLimits * limits) - lib.wgpuDeviceGetLimits(device_id, c_supported_limits) + libf.wgpuDeviceGetLimits(device_id, c_supported_limits) limits = {to_snake_case(k): getattr(c_limits, k) for k in dir(c_limits)} # ----- Get device features @@ -771,26 +755,22 @@ def callback(status, result, message, userdata): features = set() for f in sorted(enums.FeatureName): key = f"FeatureName.{f}" - if key not in enummap: - if f not in KNOWN_MISSING_FEATURES: # pragma: no cover - raise RuntimeError(f"Unexpected feature {f}") - continue i = enummap[key] # H: bool f(WGPUDevice device, WGPUFeatureName feature) - if lib.wgpuDeviceHasFeature(device_id, i): + if libf.wgpuDeviceHasFeature(device_id, i): features.add(f) # Native features for f in NATIVE_FEATURES: - i = getattr(lib, f"WGPUNativeFeature_{f.upper()}") + i = getattr(lib, f"WGPUNativeFeature_{f}") # H: bool f(WGPUDevice device, WGPUFeatureName feature) - if lib.wgpuDeviceHasFeature(device_id, i): + if libf.wgpuDeviceHasFeature(device_id, i): features.add(f) # ---- Get queue # H: WGPUQueue f(WGPUDevice device) - queue_id = lib.wgpuDeviceGetQueue(device_id) + queue_id = libf.wgpuDeviceGetQueue(device_id) queue = GPUQueue("", queue_id, None) # ----- Done @@ -814,7 +794,7 @@ async def request_device_async( def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal - delayed_dropper.drop_soon("wgpuAdapterDrop", internal) + delayed_releaser.release_soon("wgpuAdapterRelease", internal) class GPUDevice(base.GPUDevice, GPUObjectBase): @@ -825,38 +805,16 @@ def __init__(self, label, internal, adapter, features, limits, queue): def uncaptured_error_callback(c_type, c_message, userdata): error_type = enum_int2str["ErrorType"].get(c_type, "Unknown") message = ffi.string(c_message).decode(errors="ignore") - message = message.replace("\\n", "\n") - - shader_error = parse_wgsl_error(message) - - if shader_error: - self._on_error(shader_error) - else: - self._on_error(f"Uncaught WGPU error ({error_type}):\n{message}") - - @ffi.callback("void(WGPUDeviceLostReason, char *, void *)") - def device_lost_callback(c_reason, c_message, userdata): - reason = enum_int2str["DeviceLostReason"].get(c_reason, "Unknown") - message = ffi.string(c_message).decode(errors="ignore") - message = message.replace("\\n", "\n") - self._on_error(f"The WGPU device was lost ({reason}):\n{message}") + message = "\n".join(line.rstrip() for line in message.splitlines()) + error_handler.handle_error(error_type, message) - # Keep the refs alive + # Keep the ref alive self._uncaptured_error_callback = uncaptured_error_callback - self._device_lost_callback = device_lost_callback # H: void f(WGPUDevice device, WGPUErrorCallback callback, void * userdata) - lib.wgpuDeviceSetUncapturedErrorCallback( + libf.wgpuDeviceSetUncapturedErrorCallback( self._internal, uncaptured_error_callback, ffi.NULL ) - # H: void f(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata) - lib.wgpuDeviceSetDeviceLostCallback( - self._internal, device_lost_callback, ffi.NULL - ) - - def _on_error(self, message): - """Log the error message (for errors produced by wgpu).""" - logger.error(message) def create_buffer( self, @@ -884,7 +842,7 @@ def create_buffer_with_data(self, *, label="", data, usage: "flags.BufferUsage") # Copy the data to the mapped memory # H: void * f(WGPUBuffer buffer, size_t offset, size_t size) - dst_ptr = lib.wgpuBufferGetMappedRange(buffer._internal, 0, size) + dst_ptr = libf.wgpuBufferGetMappedRange(buffer._internal, 0, size) dst_address = int(ffi.cast("intptr_t", dst_ptr)) dst_m = get_memoryview_from_address(dst_address, size) dst_m[:] = m # nicer than ctypes.memmove(dst_address, src_address, m.nbytes) @@ -904,7 +862,7 @@ def _create_buffer(self, label, size, usage, mapped_at_creation): # not used: nextInChain ) # H: WGPUBuffer f(WGPUDevice device, WGPUBufferDescriptor const * descriptor) - id = lib.wgpuDeviceCreateBuffer(self._internal, struct) + id = libf.wgpuDeviceCreateBuffer(self._internal, struct) # Note that there is wgpuBufferGetSize and wgpuBufferGetUsage, # but we already know these, so they are kindof useless? # Return wrapped buffer @@ -938,6 +896,9 @@ def create_texture( "create_texture(.. view_formats is not yet supported." ) + if not mip_level_count: + mip_level_count = 1 # or lib.WGPU_MIP_LEVEL_COUNT_UNDEFINED ? + # H: nextInChain: WGPUChainedStruct *, label: char *, usage: WGPUTextureUsageFlags/int, dimension: WGPUTextureDimension, size: WGPUExtent3D, format: WGPUTextureFormat, mipLevelCount: int, sampleCount: int, viewFormatCount: int, viewFormats: WGPUTextureFormat * struct = new_struct_p( "WGPUTextureDescriptor *", @@ -953,7 +914,7 @@ def create_texture( # not used: viewFormats ) # H: WGPUTexture f(WGPUDevice device, WGPUTextureDescriptor const * descriptor) - id = lib.wgpuDeviceCreateTexture(self._internal, struct) + id = libf.wgpuDeviceCreateTexture(self._internal, struct) # Note that there are methods (e.g. wgpuTextureGetHeight) to get # the below props, but we know them now, so why bother? @@ -999,8 +960,8 @@ def create_sampler( # not used: nextInChain ) - # H: WGPUSampler f(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */) - id = lib.wgpuDeviceCreateSampler(self._internal, struct) + # H: WGPUSampler f(WGPUDevice device, WGPUSamplerDescriptor const * descriptor) + id = libf.wgpuDeviceCreateSampler(self._internal, struct) return GPUSampler(label, id, self) def create_bind_group_layout( @@ -1018,11 +979,7 @@ def create_bind_group_layout( check_struct("BufferBindingLayout", info) min_binding_size = info.get("min_binding_size", None) if min_binding_size is None: - min_binding_size = WGPU_LIMIT_U64_UNDEFINED - elif min_binding_size == 0: - raise ValueError( - "min_binding_size should not be 0, use a proper value or None for default." - ) + min_binding_size = 0 # lib.WGPU_LIMIT_U64_UNDEFINED # H: nextInChain: WGPUChainedStruct *, type: WGPUBufferBindingType, hasDynamicOffset: bool, minBindingSize: int buffer = new_struct( "WGPUBufferBindingLayout", @@ -1095,7 +1052,7 @@ def create_bind_group_layout( ) # H: WGPUBindGroupLayout f(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) - id = lib.wgpuDeviceCreateBindGroupLayout(self._internal, struct) + id = libf.wgpuDeviceCreateBindGroupLayout(self._internal, struct) return GPUBindGroupLayout(label, id, self, entries) @@ -1166,7 +1123,7 @@ def create_bind_group( ) # H: WGPUBindGroup f(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) - id = lib.wgpuDeviceCreateBindGroup(self._internal, struct) + id = libf.wgpuDeviceCreateBindGroup(self._internal, struct) return GPUBindGroup(label, id, self, entries) def create_pipeline_layout( @@ -1185,7 +1142,7 @@ def create_pipeline_layout( ) # H: WGPUPipelineLayout f(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) - id = lib.wgpuDeviceCreatePipelineLayout(self._internal, struct) + id = libf.wgpuDeviceCreatePipelineLayout(self._internal, struct) return GPUPipelineLayout(label, id, self, bind_group_layouts) def create_shader_module( @@ -1227,7 +1184,7 @@ def create_shader_module( ) ) c_defines = ffi.new("WGPUShaderDefine []", defines) - # H: chain: WGPUChainedStruct, stage: WGPUShaderStage, code: char *, defineCount: int, defines: WGPUShaderDefine*/WGPUShaderDefine * + # H: chain: WGPUChainedStruct, stage: WGPUShaderStage, code: char *, defineCount: int, defines: WGPUShaderDefine * source_struct = new_struct_p( "WGPUShaderModuleGLSLDescriptor *", code=ffi.new("char []", code.encode()), @@ -1282,7 +1239,7 @@ def create_shader_module( hints=ffi.NULL, ) # H: WGPUShaderModule f(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) - id = lib.wgpuDeviceCreateShaderModule(self._internal, struct) + id = libf.wgpuDeviceCreateShaderModule(self._internal, struct) if id == ffi.NULL: raise RuntimeError("Shader module creation failed") return GPUShaderModule(label, id, self) @@ -1316,7 +1273,7 @@ def create_compute_pipeline( ) # H: WGPUComputePipeline f(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) - id = lib.wgpuDeviceCreateComputePipeline(self._internal, struct) + id = libf.wgpuDeviceCreateComputePipeline(self._internal, struct) return GPUComputePipeline(label, id, self, layout) async def create_compute_pipeline_async( @@ -1518,7 +1475,7 @@ def create_render_pipeline( ) # H: WGPURenderPipeline f(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) - id = lib.wgpuDeviceCreateRenderPipeline(self._internal, struct) + id = libf.wgpuDeviceCreateRenderPipeline(self._internal, struct) return GPURenderPipeline(label, id, self, layout) async def create_render_pipeline_async( @@ -1550,8 +1507,8 @@ def create_command_encoder(self, *, label=""): # not used: nextInChain ) - # H: WGPUCommandEncoder f(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor /* nullable */) - id = lib.wgpuDeviceCreateCommandEncoder(self._internal, struct) + # H: WGPUCommandEncoder f(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor) + id = libf.wgpuDeviceCreateCommandEncoder(self._internal, struct) return GPUCommandEncoder(label, id, self) def create_render_bundle_encoder( @@ -1572,7 +1529,7 @@ def create_query_set(self, *, label="", type: "enums.QueryType", count: int): def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal - delayed_dropper.drop_soon("wgpuDeviceDrop", internal) + delayed_releaser.release_soon("wgpuDeviceRelease", internal) class GPUBuffer(base.GPUBuffer, GPUObjectBase): @@ -1591,15 +1548,15 @@ def callback(status_, user_data_p): # Map it self._map_state = enums.BufferMapState.pending # H: void f(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) - lib.wgpuBufferMapAsync( + libf.wgpuBufferMapAsync( self._internal, lib.WGPUMapMode_Read, 0, size, callback, ffi.NULL ) # Let it do some cycles # H: void f(WGPUInstance instance) - # lib.wgpuInstanceProcessEvents(get_wgpu_instance()) + # libf.wgpuInstanceProcessEvents(get_wgpu_instance()) # H: bool f(WGPUDevice device, bool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) - lib.wgpuDevicePoll(self._device._internal, True, ffi.NULL) + libf.wgpuDevicePoll(self._device._internal, True, ffi.NULL) if status != 0: # no-cover raise RuntimeError(f"Could not read buffer data ({status}).") @@ -1607,7 +1564,7 @@ def callback(status_, user_data_p): # Copy data # H: void * f(WGPUBuffer buffer, size_t offset, size_t size) - src_ptr = lib.wgpuBufferGetMappedRange(self._internal, 0, size) + src_ptr = libf.wgpuBufferGetMappedRange(self._internal, 0, size) src_address = int(ffi.cast("intptr_t", src_ptr)) src_m = get_memoryview_from_address(src_address, size) data[:] = src_m @@ -1635,15 +1592,15 @@ def callback(status_, user_data_p): # Map it self._map_state = enums.BufferMapState.pending # H: void f(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) - lib.wgpuBufferMapAsync( + libf.wgpuBufferMapAsync( self._internal, lib.WGPUMapMode_Write, 0, size, callback, ffi.NULL ) # Let it do some cycles # H: void f(WGPUInstance instance) - # lib.wgpuInstanceProcessEvents(get_wgpu_instance()) + # libf.wgpuInstanceProcessEvents(get_wgpu_instance()) # H: bool f(WGPUDevice device, bool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) - lib.wgpuDevicePoll(self._device._internal, True, ffi.NULL) + libf.wgpuDevicePoll(self._device._internal, True, ffi.NULL) if status != 0: # no-cover raise RuntimeError(f"Could not read buffer data ({status}).") @@ -1651,7 +1608,7 @@ def callback(status_, user_data_p): # Copy data # H: void * f(WGPUBuffer buffer, size_t offset, size_t size) - src_ptr = lib.wgpuBufferGetMappedRange(self._internal, 0, size) + src_ptr = libf.wgpuBufferGetMappedRange(self._internal, 0, size) src_address = int(ffi.cast("intptr_t", src_ptr)) src_m = get_memoryview_from_address(src_address, size) src_m[:] = data @@ -1660,7 +1617,7 @@ def callback(status_, user_data_p): def _unmap(self): # H: void f(WGPUBuffer buffer) - lib.wgpuBufferUnmap(self._internal) + libf.wgpuBufferUnmap(self._internal) self._map_state = enums.BufferMapState.unmapped def destroy(self): @@ -1670,7 +1627,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUBuffer buffer) - lib.wgpuBufferDrop(internal) + libf.wgpuBufferRelease(internal) class GPUTexture(base.GPUTexture, GPUObjectBase): @@ -1697,7 +1654,7 @@ def create_view( mip_level_count = self._tex_info["mip_level_count"] - base_mip_level if not array_layer_count: if dimension in ("1d", "2d", "3d"): - array_layer_count = 1 + array_layer_count = 1 # or WGPU_ARRAY_LAYER_COUNT_UNDEFINED ? elif dimension == "cube": array_layer_count = 6 elif dimension in ("2d-array", "cube-array"): @@ -1716,8 +1673,8 @@ def create_view( arrayLayerCount=array_layer_count, # not used: nextInChain ) - # H: WGPUTextureView f(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */) - id = lib.wgpuTextureCreateView(self._internal, struct) + # H: WGPUTextureView f(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor) + id = libf.wgpuTextureCreateView(self._internal, struct) return GPUTextureView(label, id, self._device, self, self.size) def destroy(self): @@ -1727,7 +1684,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUTexture texture) - lib.wgpuTextureDrop(internal) + libf.wgpuTextureRelease(internal) class GPUTextureView(base.GPUTextureView, GPUObjectBase): @@ -1735,7 +1692,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUTextureView textureView) - lib.wgpuTextureViewDrop(internal) + libf.wgpuTextureViewRelease(internal) class GPUSampler(base.GPUSampler, GPUObjectBase): @@ -1743,7 +1700,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUSampler sampler) - lib.wgpuSamplerDrop(internal) + libf.wgpuSamplerRelease(internal) class GPUBindGroupLayout(base.GPUBindGroupLayout, GPUObjectBase): @@ -1751,7 +1708,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUBindGroupLayout bindGroupLayout) - lib.wgpuBindGroupLayoutDrop(internal) + libf.wgpuBindGroupLayoutRelease(internal) class GPUBindGroup(base.GPUBindGroup, GPUObjectBase): @@ -1759,7 +1716,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUBindGroup bindGroup) - lib.wgpuBindGroupDrop(internal) + libf.wgpuBindGroupRelease(internal) class GPUPipelineLayout(base.GPUPipelineLayout, GPUObjectBase): @@ -1767,7 +1724,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUPipelineLayout pipelineLayout) - lib.wgpuPipelineLayoutDrop(internal) + libf.wgpuPipelineLayoutRelease(internal) class GPUShaderModule(base.GPUShaderModule, GPUObjectBase): @@ -1778,7 +1735,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUShaderModule shaderModule) - lib.wgpuShaderModuleDrop(internal) + libf.wgpuShaderModuleRelease(internal) class GPUPipelineBase(base.GPUPipelineBase): @@ -1790,7 +1747,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUComputePipeline computePipeline) - lib.wgpuComputePipelineDrop(internal) + libf.wgpuComputePipelineRelease(internal) class GPURenderPipeline(base.GPURenderPipeline, GPUPipelineBase, GPUObjectBase): @@ -1798,13 +1755,13 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPURenderPipeline renderPipeline) - lib.wgpuRenderPipelineDrop(internal) + libf.wgpuRenderPipelineRelease(internal) class GPUCommandBuffer(base.GPUCommandBuffer, GPUObjectBase): def _destroy(self): # Since command buffers get destroyed when you submit them, we - # must only drop them if they've not been submitted, or we get + # must only release them if they've not been submitted, or we get # 'Cannot remove a vacant resource'. Got this info from the # wgpu chat. Also see # https://docs.rs/wgpu-core/latest/src/wgpu_core/device/mod.rs.html#4180-4194 @@ -1812,7 +1769,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUCommandBuffer commandBuffer) - lib.wgpuCommandBufferDrop(internal) + libf.wgpuCommandBufferRelease(internal) class GPUCommandsMixin(base.GPUCommandsMixin): @@ -1832,13 +1789,13 @@ def set_bind_group( c_offsets = ffi.new("uint32_t []", offsets) bind_group_id = bind_group._internal if isinstance(self, GPUComputePassEncoder): - # H: void f(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) - lib.wgpuComputePassEncoderSetBindGroup( + # H: void f(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) + libf.wgpuComputePassEncoderSetBindGroup( self._internal, index, bind_group_id, len(offsets), c_offsets ) else: - # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets) - lib.wgpuRenderPassEncoderSetBindGroup( + # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) + libf.wgpuRenderPassEncoderSetBindGroup( self._internal, index, bind_group_id, @@ -1855,12 +1812,12 @@ def push_debug_group(self, group_label): return # noqa if isinstance(self, GPUComputePassEncoder): # H: void f(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) - lib.wgpuComputePassEncoderPushDebugGroup( + libf.wgpuComputePassEncoderPushDebugGroup( self._internal, c_group_label, color ) else: # H: void f(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) - lib.wgpuRenderPassEncoderPushDebugGroup( + libf.wgpuRenderPassEncoderPushDebugGroup( self._internal, c_group_label, color ) @@ -1869,10 +1826,10 @@ def pop_debug_group(self): return # noqa if isinstance(self, GPUComputePassEncoder): # H: void f(WGPUComputePassEncoder computePassEncoder) - lib.wgpuComputePassEncoderPopDebugGroup(self._internal) + libf.wgpuComputePassEncoderPopDebugGroup(self._internal) else: # H: void f(WGPURenderPassEncoder renderPassEncoder) - lib.wgpuRenderPassEncoderPopDebugGroup(self._internal) + libf.wgpuRenderPassEncoderPopDebugGroup(self._internal) def insert_debug_marker(self, marker_label): c_marker_label = ffi.new("char []", marker_label.encode()) @@ -1881,12 +1838,12 @@ def insert_debug_marker(self, marker_label): return # noqa if isinstance(self, GPUComputePassEncoder): # H: void f(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) - lib.wgpuComputePassEncoderInsertDebugMarker( + libf.wgpuComputePassEncoderInsertDebugMarker( self._internal, c_marker_label, color ) else: # H: void f(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) - lib.wgpuRenderPassEncoderInsertDebugMarker( + libf.wgpuRenderPassEncoderInsertDebugMarker( self._internal, c_marker_label, color ) @@ -1895,14 +1852,14 @@ class GPURenderCommandsMixin(base.GPURenderCommandsMixin): def set_pipeline(self, pipeline): pipeline_id = pipeline._internal # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) - lib.wgpuRenderPassEncoderSetPipeline(self._internal, pipeline_id) + libf.wgpuRenderPassEncoderSetPipeline(self._internal, pipeline_id) def set_index_buffer(self, buffer, index_format, offset=0, size=None): if not size: size = buffer.size - offset c_index_format = enummap[f"IndexFormat.{index_format}"] # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) - lib.wgpuRenderPassEncoderSetIndexBuffer( + libf.wgpuRenderPassEncoderSetIndexBuffer( self._internal, buffer._internal, c_index_format, int(offset), int(size) ) @@ -1910,20 +1867,20 @@ def set_vertex_buffer(self, slot, buffer, offset=0, size=None): if not size: size = buffer.size - offset # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) - lib.wgpuRenderPassEncoderSetVertexBuffer( + libf.wgpuRenderPassEncoderSetVertexBuffer( self._internal, int(slot), buffer._internal, int(offset), int(size) ) def draw(self, vertex_count, instance_count=1, first_vertex=0, first_instance=0): # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) - lib.wgpuRenderPassEncoderDraw( + libf.wgpuRenderPassEncoderDraw( self._internal, vertex_count, instance_count, first_vertex, first_instance ) def draw_indirect(self, indirect_buffer, indirect_offset): buffer_id = indirect_buffer._internal # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) - lib.wgpuRenderPassEncoderDrawIndirect( + libf.wgpuRenderPassEncoderDrawIndirect( self._internal, buffer_id, int(indirect_offset) ) @@ -1936,7 +1893,7 @@ def draw_indexed( first_instance=0, ): # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) - lib.wgpuRenderPassEncoderDrawIndexed( + libf.wgpuRenderPassEncoderDrawIndexed( self._internal, index_count, instance_count, @@ -1948,7 +1905,7 @@ def draw_indexed( def draw_indexed_indirect(self, indirect_buffer, indirect_offset): buffer_id = indirect_buffer._internal # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) - lib.wgpuRenderPassEncoderDrawIndexedIndirect( + libf.wgpuRenderPassEncoderDrawIndexedIndirect( self._internal, buffer_id, int(indirect_offset) ) @@ -1969,8 +1926,8 @@ def begin_compute_pass( # not used: timestampWriteCount # not used: timestampWrites ) - # H: WGPUComputePassEncoder f(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor /* nullable */) - raw_pass = lib.wgpuCommandEncoderBeginComputePass(self._internal, struct) + # H: WGPUComputePassEncoder f(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor) + raw_pass = libf.wgpuCommandEncoderBeginComputePass(self._internal, struct) return GPUComputePassEncoder(label, raw_pass, self) def begin_render_pass( @@ -2060,7 +2017,7 @@ def begin_render_pass( ) # H: WGPURenderPassEncoder f(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) - raw_pass = lib.wgpuCommandEncoderBeginRenderPass(self._internal, struct) + raw_pass = libf.wgpuCommandEncoderBeginRenderPass(self._internal, struct) return GPURenderPassEncoder(label, raw_pass, self) def clear_buffer(self, buffer, offset=0, size=None): @@ -2077,7 +2034,7 @@ def clear_buffer(self, buffer, offset=0, size=None): if offset + size > buffer.size: # pragma: no cover raise ValueError("buffer size out of range") # H: void f(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) - lib.wgpuCommandEncoderClearBuffer( + libf.wgpuCommandEncoderClearBuffer( self._internal, buffer._internal, int(offset), size ) @@ -2096,7 +2053,7 @@ def copy_buffer_to_buffer( if not isinstance(destination, GPUBuffer): # pragma: no cover raise TypeError("copy_buffer_to_buffer() destination must be a GPUBuffer.") # H: void f(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) - lib.wgpuCommandEncoderCopyBufferToBuffer( + libf.wgpuCommandEncoderCopyBufferToBuffer( self._internal, source._internal, int(source_offset), @@ -2159,7 +2116,7 @@ def copy_buffer_to_texture(self, source, destination, copy_size): ) # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) - lib.wgpuCommandEncoderCopyBufferToTexture( + libf.wgpuCommandEncoderCopyBufferToTexture( self._internal, c_source, c_destination, @@ -2220,7 +2177,7 @@ def copy_texture_to_buffer(self, source, destination, copy_size): ) # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) - lib.wgpuCommandEncoderCopyTextureToBuffer( + libf.wgpuCommandEncoderCopyTextureToBuffer( self._internal, c_source, c_destination, @@ -2281,7 +2238,7 @@ def copy_texture_to_texture(self, source, destination, copy_size): ) # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) - lib.wgpuCommandEncoderCopyTextureToTexture( + libf.wgpuCommandEncoderCopyTextureToTexture( self._internal, c_source, c_destination, @@ -2295,10 +2252,10 @@ def finish(self, *, label=""): label=to_c_label(label), # not used: nextInChain ) - # H: WGPUCommandBuffer f(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor /* nullable */) - id = lib.wgpuCommandEncoderFinish(self._internal, struct) + # H: WGPUCommandBuffer f(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor) + id = libf.wgpuCommandEncoderFinish(self._internal, struct) # WGPU destroys the command encoder when it's finished. So we set - # _internal to None to avoid dropping a nonexistent object. + # _internal to None to avoid releasing a nonexistent object. self._internal = None return GPUCommandBuffer(label, id, self) @@ -2316,7 +2273,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUCommandEncoder commandEncoder) - lib.wgpuCommandEncoderDrop(internal) + libf.wgpuCommandEncoderRelease(internal) class GPUComputePassEncoder( @@ -2331,31 +2288,32 @@ class GPUComputePassEncoder( def set_pipeline(self, pipeline): pipeline_id = pipeline._internal # H: void f(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) - lib.wgpuComputePassEncoderSetPipeline(self._internal, pipeline_id) + libf.wgpuComputePassEncoderSetPipeline(self._internal, pipeline_id) def dispatch_workgroups( self, workgroup_count_x, workgroup_count_y=1, workgroup_count_z=1 ): # H: void f(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) - lib.wgpuComputePassEncoderDispatchWorkgroups( + libf.wgpuComputePassEncoderDispatchWorkgroups( self._internal, workgroup_count_x, workgroup_count_y, workgroup_count_z ) def dispatch_workgroups_indirect(self, indirect_buffer, indirect_offset): buffer_id = indirect_buffer._internal # H: void f(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) - lib.wgpuComputePassEncoderDispatchWorkgroupsIndirect( + libf.wgpuComputePassEncoderDispatchWorkgroupsIndirect( self._internal, buffer_id, int(indirect_offset) ) def end(self): # H: void f(WGPUComputePassEncoder computePassEncoder) - lib.wgpuComputePassEncoderEnd(self._internal) + libf.wgpuComputePassEncoderEnd(self._internal) def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal - internal # wgpuComputePassEncoderDrop segfaults, also when delayed + # H: void f(WGPUComputePassEncoder computePassEncoder) + internal # panics: libf.wgpuComputePassEncoderRelease(internal) class GPURenderPassEncoder( @@ -2368,7 +2326,7 @@ class GPURenderPassEncoder( ): def set_viewport(self, x, y, width, height, min_depth, max_depth): # H: void f(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) - lib.wgpuRenderPassEncoderSetViewport( + libf.wgpuRenderPassEncoderSetViewport( self._internal, float(x), float(y), @@ -2380,7 +2338,7 @@ def set_viewport(self, x, y, width, height, min_depth, max_depth): def set_scissor_rect(self, x, y, width, height): # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) - lib.wgpuRenderPassEncoderSetScissorRect( + libf.wgpuRenderPassEncoderSetScissorRect( self._internal, int(x), int(y), int(width), int(height) ) @@ -2395,15 +2353,15 @@ def set_blend_constant(self, color): a=color[3], ) # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) - lib.wgpuRenderPassEncoderSetBlendConstant(self._internal, c_color) + libf.wgpuRenderPassEncoderSetBlendConstant(self._internal, c_color) def set_stencil_reference(self, reference): # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) - lib.wgpuRenderPassEncoderSetStencilReference(self._internal, int(reference)) + libf.wgpuRenderPassEncoderSetStencilReference(self._internal, int(reference)) def end(self): # H: void f(WGPURenderPassEncoder renderPassEncoder) - lib.wgpuRenderPassEncoderEnd(self._internal) + libf.wgpuRenderPassEncoderEnd(self._internal) def execute_bundles(self, bundles): raise NotImplementedError() @@ -2417,7 +2375,8 @@ def end_occlusion_query(self): def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal - internal # wgpuRenderPassEncoderDrop segfaults, also when delayed + # H: void f(WGPURenderPassEncoder renderPassEncoder) + internal # panics: libf.wgpuRenderPassEncoderRelease(internal) class GPURenderBundleEncoder( @@ -2435,17 +2394,17 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPURenderBundleEncoder renderBundleEncoder) - lib.wgpuRenderBundleEncoderDrop(internal) + libf.wgpuRenderBundleEncoderRelease(internal) class GPUQueue(base.GPUQueue, GPUObjectBase): def submit(self, command_buffers): command_buffer_ids = [cb._internal for cb in command_buffers] c_command_buffers = ffi.new("WGPUCommandBuffer []", command_buffer_ids) - # H: void f(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands) - lib.wgpuQueueSubmit(self._internal, len(command_buffer_ids), c_command_buffers) + # H: void f(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) + libf.wgpuQueueSubmit(self._internal, len(command_buffer_ids), c_command_buffers) # WGPU destroys the resource when submitting. We follow this - # to avoid dropping a nonexistent object. + # to avoid releasing a nonexistent object. for cb in command_buffers: cb._internal = None @@ -2477,7 +2436,7 @@ def write_buffer(self, buffer, buffer_offset, data, data_offset=0, size=None): # if we lose our reference to the data once we leave this function. c_data = ffi.cast("uint8_t *", address + data_offset) # H: void f(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) - lib.wgpuQueueWriteBuffer( + libf.wgpuQueueWriteBuffer( self._internal, buffer._internal, buffer_offset, c_data, data_length ) @@ -2567,7 +2526,7 @@ def write_texture(self, destination, data, data_layout, size): ) # H: void f(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) - lib.wgpuQueueWriteTexture( + libf.wgpuQueueWriteTexture( self._internal, c_destination, c_data, data_length, c_data_layout, c_size ) @@ -2595,7 +2554,7 @@ def read_texture(self, source, data_layout, size): destination = { "buffer": tmp_buffer, "offset": 0, - "bytes_per_row": full_stride, + "bytes_per_row": full_stride, # or WGPU_COPY_STRIDE_UNDEFINED ? "rows_per_image": data_layout.get("rows_per_image", size[1]), } @@ -2636,7 +2595,7 @@ def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPURenderBundle renderBundle) - lib.wgpuRenderBundleDrop(internal) + libf.wgpuRenderBundleRelease(internal) class GPUDeviceLostInfo(base.GPUDeviceLostInfo): @@ -2670,7 +2629,7 @@ def destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal # H: void f(WGPUQuerySet querySet) - lib.wgpuQuerySetDrop(internal) + libf.wgpuQuerySetRelease(internal) class GPUExternalTexture(base.GPUExternalTexture, GPUObjectBase): diff --git a/wgpu/backends/rs_ffi.py b/wgpu/backends/rs_ffi.py index 3e0ad703..d681dcbd 100644 --- a/wgpu/backends/rs_ffi.py +++ b/wgpu/backends/rs_ffi.py @@ -33,13 +33,23 @@ def _get_wgpu_header(*filenames): # Just removing them, plus a few extra lines, seems to do the trick. lines2 = [] for line in lines1: - if line.startswith("#"): + if line.startswith("#define ") and len(line.split()) > 2 and "0x" in line: + line = line.replace("(", "").replace(")", "") + elif line.startswith("#"): continue elif 'extern "C"' in line: continue - line = line.replace("WGPU_EXPORT ", "") + for define_to_drop in [ + "WGPU_EXPORT ", + "WGPU_NULLABLE ", + " WGPU_OBJECT_ATTRIBUTE", + " WGPU_ENUM_ATTRIBUTE", + " WGPU_FUNCTION_ATTRIBUTE", + " WGPU_STRUCTURE_ATTRIBUTE", + ]: + line = line.replace(define_to_drop, "") lines2.append(line) - return "".join(lines2) + return "\n".join(lines2) def get_wgpu_lib_path(): diff --git a/wgpu/backends/rs_helpers.py b/wgpu/backends/rs_helpers.py index f22af1f3..714bf7ba 100644 --- a/wgpu/backends/rs_helpers.py +++ b/wgpu/backends/rs_helpers.py @@ -1,9 +1,25 @@ import os +import re import sys import ctypes -import re from .rs_ffi import ffi, lib +from ..base import ( + GPUError, + GPUOutOfMemoryError, + GPUValidationError, + GPUPipelineError, + GPUInternalError, +) + + +ERROR_TYPES = { + "": GPUError, + "OutOfMemory": GPUOutOfMemoryError, + "Validation": GPUValidationError, + "Pipeline": GPUPipelineError, + "Internal": GPUInternalError, +} if sys.platform.startswith("darwin"): @@ -63,7 +79,7 @@ def get_memoryview_from_address(address, nbytes, format="B"): def get_wgpu_instance(): """Get the global wgpu instance.""" - # Note, we could also use wgpuInstanceDrop, + # Note, we could also use wgpuInstanceRelease, # but we keep a global instance, so we don't have to. global _the_instance if _the_instance is None: @@ -254,128 +270,6 @@ def color_string(color, string): ) # TODO: simple error message -def parse_wgsl_error(message): - """Parse a WGPU shader error message, give an easy-to-understand error prompt.""" - - err_msg = ["\n"] - - match = _wgsl_error_tmpl.match(message) - - if match: - error_type = match.group(1) - source = match.group(2) - source = source.replace("\\t", " ") - label = match.group(3) - # inner_error_type = match.group(4) - inner_error = match.group(5) - err_msg.append(color_string(33, f"Shader error: label: {label}")) - - if error_type and inner_error: - if error_type == "Parsing": - match2 = _wgsl_inner_parsing_error_tmpl.match(inner_error) - if match2: - err_msg.append( - color_string(33, f"Parsing error: {match2.group(1)}") - ) - start = int(match2.group(2)) - end = int(match2.group(3)) - label = match2.group(4) - note = match2.group(5) - err_msg += _wgsl_parse_extract_line(source, start, end, label, note) - else: - err_msg += [color_string(33, inner_error)] - - elif error_type == "Validation": - match2 = _wgsl_inner_validation_error_tmpl.match(inner_error) - if match2: - error = match2.group(4) - err_msg.append(color_string(33, f"Validation error: {error}")) - start = int(match2.group(5)) - end = int(match2.group(6)) - error_match = _wgsl_inner_validation_error_info_tmpl.search(error) - label = error_match.group(1) if error_match else error - note = "" - err_msg += _wgsl_parse_extract_line(source, start, end, label, note) - else: - err_msg += [color_string(33, inner_error)] - - return "\n".join(err_msg) - - return None # Does not look like a shader error - - -def _wgsl_parse_extract_line(source, start, end, label, note): - # Find next newline after the end pos - try: - next_n = source.index("\n", end) - except ValueError: - next_n = len(source) - - # Truncate and convert to lines - lines = source[:next_n].splitlines(True) - line_num = len(lines) - - # Collect the lines relevant to this error - error_lines = [] - line_pos = start - next_n - while line_pos < 0: - line = lines[line_num - 1] - line_length = len(line) - line_pos += line_length - - start_pos = line_pos - if start_pos < 0: - start_pos = 0 - end_pos = line_length - (next_n - end) - if end_pos > line_length: - end_pos = line_length - - error_lines.insert(0, (line_num, line, start_pos, end_pos)) - - next_n -= line_length - line_num -= 1 - - def pad_str(s, line_num=None): - pad = len(str(len(lines))) - if line_num is not None: - pad -= len(str(line_num)) - return f"{' '*pad}{line_num} {s}".rstrip() - else: - return f"{' '*pad} {s}".rstrip() - - err_msg = [""] - - # Show header - if len(error_lines) == 1: - prefix = pad_str(color_string(36, "┌─")) - err_msg.append(prefix + f" wgsl:{len(lines)}:{line_pos}") - else: - prefix = pad_str(color_string(36, "┌─")) - err_msg.append(prefix + f" wgsl:{line_num+1}--{len(lines)}") - - # Add lines - err_msg.append(pad_str(color_string(36, "│"))) - for line_num, line, _, _ in error_lines: - prefix = color_string(36, pad_str("│", line_num)) - err_msg.append(prefix + f" {line}".rstrip()) - - # Show annotation - if len(error_lines) == 1: - prefix = pad_str(color_string(36, "│")) - annotation = f" {' '*error_lines[0][2] + '^'*(end-start)} {label}" - err_msg.append(prefix + color_string(33, annotation)) - else: - prefix = pad_str(color_string(36, "│")) - annotation = color_string(33, f" ^^^{label}") - err_msg.append(prefix + annotation) - - err_msg.append(pad_str(color_string(36, "│"))) - err_msg.append(pad_str(color_string(36, f"= note: {note}".rstrip()))) - err_msg.append("\n") - - return err_msg - - # The functions below are copied from codegen/utils.py @@ -411,27 +305,120 @@ def to_camel_case(name): return name2 -class DelayedDropper: - """Helps drop objects at a later time.""" +class DelayedReleaser: + """Helps release objects at a later time.""" - # I found that when wgpuDeviceDrop() was called in Device._destroy, - # the tests would hang. I found that the drop call was done around + # I found that when wgpuDeviceRelease() was called in Device._destroy, + # the tests would hang. I found that the release call was done around # the time when another device was used (e.g. to create a buffer # or shader module). For some reason, the delay in destruction (by # Python's CG) causes a deadlock or something. We seem to be able - # to fix this by doing the actual dropping later - e.g. when the + # to fix this by doing the actual release later - e.g. when the # user creates a new device. Seems to be the same for the adapter. def __init__(self): - self._things_to_drop = [] + self._things_to_release = [] + + def release_soon(self, fun, i): + self._things_to_release.append((fun, i)) - def drop_soon(self, fun, i): - self._things_to_drop.append((fun, i)) + def release_all_pending(self): + while self._things_to_release: + fun, i = self._things_to_release.pop(0) + release_func = getattr(lib, fun) + release_func(i) - def drop_all_pending(self): - while self._things_to_drop: - fun, i = self._things_to_drop.pop(0) - drop_fun = getattr(lib, fun) - drop_fun(i) +class ErrorHandler: + """Object that logs errors, with the option to collect incoming + errors elsewhere. + """ -delayed_dropper = DelayedDropper() + def __init__(self, logger): + self._logger = logger + self._proxy_stack = [] + self._error_message_counts = {} + + def capture(self, func): + """Send incoming error messages to the given func instead of logging them.""" + self._proxy_stack.append(func) + + def release(self, func): + """Release the given func.""" + f = self._proxy_stack.pop(-1) + if f is not func: + self._proxy_stack.clear() + self._logger.warning("ErrorHandler capture/release out of sync") + + def handle_error(self, error_type: str, message: str): + """Handle an error message.""" + if self._proxy_stack: + self._proxy_stack[-1](error_type, message) + else: + self.log_error(message) + + def log_error(self, message): + """Hanle an error message by logging it, bypassing any capturing.""" + # Get count for this message. Use a hash that does not use the + # digits in the message, because of id's getting renewed on + # each draw. + h = hash("".join(c for c in message if not c.isdigit())) + count = self._error_message_counts.get(h, 0) + 1 + self._error_message_counts[h] = count + + # Decide what to do + if count == 1: + self._logger.error(message) + elif count < 10: + self._logger.error(message.splitlines()[0] + f" ({count})") + elif count == 10: + self._logger.error(message.splitlines()[0] + " (hiding from now)") + + +class SafeLibCalls: + """Object that copies all library functions, but wrapped in such + a way that errors occuring in that call are raised as exceptions. + """ + + def __init__(self, lib, error_handler): + self._error_handler = error_handler + self._error_message = None + self._make_function_copies(lib) + + def _make_function_copies(self, lib): + for name in dir(lib): + if name.startswith("wgpu"): + ob = getattr(lib, name) + if callable(ob): + setattr(self, name, self._make_proxy_func(name, ob)) + + def _handle_error(self, error_type, message): + # If we already had an error, we log the earlier one now + if self._error_message: + self._error_handler.log_error(self._error_message[1]) + # Store new error + self._error_message = (error_type, message) + + def _make_proxy_func(self, name, ob): + def proxy_func(*args): + # Make the call, with error capturing on + handle_error = self._handle_error + self._error_handler.capture(handle_error) + try: + result = ob(*args) + finally: + self._error_handler.release(handle_error) + + # Handle the error. + if self._error_message: + error_type, message = self._error_message + self._error_message = None + cls = ERROR_TYPES.get(error_type, GPUError) + wgpu_error = cls(message) + # The line below will be the bottom line in the traceback, + # so better make it informative! As far as I know there is + # no way to exclude this frame from the traceback. + raise wgpu_error # the frame above is more interesting ↑↑ + return result + + proxy_func.__name__ = name + return proxy_func diff --git a/wgpu/backends/rs_mappings.py b/wgpu/backends/rs_mappings.py index 5eed1e6f..177ab799 100644 --- a/wgpu/backends/rs_mappings.py +++ b/wgpu/backends/rs_mappings.py @@ -4,7 +4,7 @@ # flake8: noqa -# There are 227 enum mappings +# There are 232 enum mappings enummap = { "AddressMode.clamp-to-edge": 2, @@ -31,6 +31,9 @@ "BufferBindingType.read-only-storage": 3, "BufferBindingType.storage": 2, "BufferBindingType.uniform": 1, + "BufferMapState.mapped": 2, + "BufferMapState.pending": 1, + "BufferMapState.unmapped": 0, "CompareFunction.always": 8, "CompareFunction.equal": 6, "CompareFunction.greater": 4, @@ -49,8 +52,10 @@ "ErrorFilter.internal": 2, "ErrorFilter.out-of-memory": 1, "ErrorFilter.validation": 0, + "FeatureName.bgra8unorm-storage": 11, "FeatureName.depth-clip-control": 1, "FeatureName.depth32float-stencil8": 2, + "FeatureName.float32-filterable": 12, "FeatureName.indirect-first-instance": 8, "FeatureName.rg11b10ufloat-renderable": 10, "FeatureName.shader-f16": 9, @@ -290,26 +295,28 @@ enum_str2int = { "BackendType": { - "Null": 0, - "WebGPU": 1, - "D3D11": 2, - "D3D12": 3, - "Metal": 4, - "Vulkan": 5, - "OpenGL": 6, - "OpenGLES": 7, + "Undefined": 0, + "Null": 1, + "WebGPU": 2, + "D3D11": 3, + "D3D12": 4, + "Metal": 5, + "Vulkan": 6, + "OpenGL": 7, + "OpenGLES": 8, } } enum_int2str = { "BackendType": { - 0: "Null", - 1: "WebGPU", - 2: "D3D11", - 3: "D3D12", - 4: "Metal", - 5: "Vulkan", - 6: "OpenGL", - 7: "OpenGLES", + 0: "Undefined", + 1: "Null", + 2: "WebGPU", + 3: "D3D11", + 4: "D3D12", + 5: "Metal", + 6: "Vulkan", + 7: "OpenGL", + 8: "OpenGLES", }, "AdapterType": { 0: "DiscreteGPU", diff --git a/wgpu/gui/offscreen.py b/wgpu/gui/offscreen.py index 77ce7127..79296f2f 100644 --- a/wgpu/gui/offscreen.py +++ b/wgpu/gui/offscreen.py @@ -90,14 +90,15 @@ async def mainloop_iter(): def run(): """Handle all tasks scheduled with call_later and return.""" - # This runs the stub coroutine mainloop_iter. - # Additionally, asyncio will run all pending callbacks - # scheduled with call_later. loop = asyncio.get_event_loop_policy().get_event_loop() - if not loop.is_running(): - loop.run_until_complete(mainloop_iter()) - else: - return # Probably an interactive session + # If the loop is already running, this is likely an interactive session or something + if loop.is_running(): + return + + # Run stub mainloop, so that all currently pending tasks are handled + loop.run_until_complete(mainloop_iter()) + + # Cancel all remaining tasks (those that are scheduled later) for t in asyncio.all_tasks(loop=loop): t.cancel() diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index 292d5438..01516948 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -2,8 +2,8 @@ ## Preparing * The webgpu.idl defines 39 classes with 78 functions * The webgpu.idl defines 5 flags, 33 enums, 59 structs -* The wgpu.h defines 174 functions -* The wgpu.h defines 6 flags, 47 enums, 86 structs +* The wgpu.h defines 198 functions +* The wgpu.h defines 6 flags, 49 enums, 88 structs ## Updating API * Wrote 5 flags to flags.py * Wrote 33 enums to enums.py @@ -19,18 +19,15 @@ * Validated 39 classes, 111 methods, 44 properties ### Patching API for backends/rs.py * Diffs for GPUAdapter: add request_device_tracing -* Validated 39 classes, 100 methods, 0 properties +* Validated 39 classes, 99 methods, 0 properties ## Validating rs.py -* Enum field FeatureName.bgra8unorm-storage missing in wgpu.h -* Enum field FeatureName.float32-filterable missing in wgpu.h -* Enum BufferMapState missing in wgpu.h * Enum field TextureFormat.rgb10a2uint missing in wgpu.h * Enum PipelineErrorReason missing in wgpu.h * Enum AutoLayoutMode missing in wgpu.h * Enum field VertexFormat.unorm10-10-10-2 missing in wgpu.h * Enum CanvasAlphaMode missing in wgpu.h * Enum field DeviceLostReason.unknown missing in wgpu.h -* Wrote 227 enum mappings and 47 struct-field mappings to rs_mappings.py -* Validated 92 C function calls -* Not using 90 C functions -* Validated 73 C structs +* Wrote 232 enum mappings and 47 struct-field mappings to rs_mappings.py +* Validated 91 C function calls +* Not using 115 C functions +* Validated 72 C structs diff --git a/wgpu/resources/webgpu.h b/wgpu/resources/webgpu.h index fefb624f..3878705c 100644 --- a/wgpu/resources/webgpu.h +++ b/wgpu/resources/webgpu.h @@ -48,6 +48,22 @@ # define WGPU_EXPORT #endif // defined(WGPU_SHARED_LIBRARY) +#if !defined(WGPU_OBJECT_ATTRIBUTE) +#define WGPU_OBJECT_ATTRIBUTE +#endif +#if !defined(WGPU_ENUM_ATTRIBUTE) +#define WGPU_ENUM_ATTRIBUTE +#endif +#if !defined(WGPU_STRUCTURE_ATTRIBUTE) +#define WGPU_STRUCTURE_ATTRIBUTE +#endif +#if !defined(WGPU_FUNCTION_ATTRIBUTE) +#define WGPU_FUNCTION_ATTRIBUTE +#endif +#if !defined(WGPU_NULLABLE) +#define WGPU_NULLABLE +#endif + #include #include #include @@ -62,29 +78,101 @@ typedef uint32_t WGPUFlags; -typedef struct WGPUAdapterImpl* WGPUAdapter; -typedef struct WGPUBindGroupImpl* WGPUBindGroup; -typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; -typedef struct WGPUBufferImpl* WGPUBuffer; -typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer; -typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder; -typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder; -typedef struct WGPUComputePipelineImpl* WGPUComputePipeline; -typedef struct WGPUDeviceImpl* WGPUDevice; -typedef struct WGPUInstanceImpl* WGPUInstance; -typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout; -typedef struct WGPUQuerySetImpl* WGPUQuerySet; -typedef struct WGPUQueueImpl* WGPUQueue; -typedef struct WGPURenderBundleImpl* WGPURenderBundle; -typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder; -typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder; -typedef struct WGPURenderPipelineImpl* WGPURenderPipeline; -typedef struct WGPUSamplerImpl* WGPUSampler; -typedef struct WGPUShaderModuleImpl* WGPUShaderModule; -typedef struct WGPUSurfaceImpl* WGPUSurface; -typedef struct WGPUSwapChainImpl* WGPUSwapChain; -typedef struct WGPUTextureImpl* WGPUTexture; -typedef struct WGPUTextureViewImpl* WGPUTextureView; +typedef struct WGPUAdapterImpl* WGPUAdapter WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUBindGroupImpl* WGPUBindGroup WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUBufferImpl* WGPUBuffer WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUComputePipelineImpl* WGPUComputePipeline WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUDeviceImpl* WGPUDevice WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUInstanceImpl* WGPUInstance WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUQuerySetImpl* WGPUQuerySet WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUQueueImpl* WGPUQueue WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderBundleImpl* WGPURenderBundle WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPURenderPipelineImpl* WGPURenderPipeline WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUSamplerImpl* WGPUSampler WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUShaderModuleImpl* WGPUShaderModule WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUSwapChainImpl* WGPUSwapChain WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; +typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; + +// Structure forward declarations +struct WGPUAdapterProperties; +struct WGPUBindGroupEntry; +struct WGPUBlendComponent; +struct WGPUBufferBindingLayout; +struct WGPUBufferDescriptor; +struct WGPUColor; +struct WGPUCommandBufferDescriptor; +struct WGPUCommandEncoderDescriptor; +struct WGPUCompilationMessage; +struct WGPUComputePassTimestampWrite; +struct WGPUConstantEntry; +struct WGPUExtent3D; +struct WGPUInstanceDescriptor; +struct WGPULimits; +struct WGPUMultisampleState; +struct WGPUOrigin3D; +struct WGPUPipelineLayoutDescriptor; +struct WGPUPrimitiveDepthClipControl; +struct WGPUPrimitiveState; +struct WGPUQuerySetDescriptor; +struct WGPUQueueDescriptor; +struct WGPURenderBundleDescriptor; +struct WGPURenderBundleEncoderDescriptor; +struct WGPURenderPassDepthStencilAttachment; +struct WGPURenderPassDescriptorMaxDrawCount; +struct WGPURenderPassTimestampWrite; +struct WGPURequestAdapterOptions; +struct WGPUSamplerBindingLayout; +struct WGPUSamplerDescriptor; +struct WGPUShaderModuleCompilationHint; +struct WGPUShaderModuleSPIRVDescriptor; +struct WGPUShaderModuleWGSLDescriptor; +struct WGPUStencilFaceState; +struct WGPUStorageTextureBindingLayout; +struct WGPUSurfaceDescriptor; +struct WGPUSurfaceDescriptorFromAndroidNativeWindow; +struct WGPUSurfaceDescriptorFromCanvasHTMLSelector; +struct WGPUSurfaceDescriptorFromMetalLayer; +struct WGPUSurfaceDescriptorFromWaylandSurface; +struct WGPUSurfaceDescriptorFromWindowsHWND; +struct WGPUSurfaceDescriptorFromXcbWindow; +struct WGPUSurfaceDescriptorFromXlibWindow; +struct WGPUSwapChainDescriptor; +struct WGPUTextureBindingLayout; +struct WGPUTextureDataLayout; +struct WGPUTextureViewDescriptor; +struct WGPUVertexAttribute; +struct WGPUBindGroupDescriptor; +struct WGPUBindGroupLayoutEntry; +struct WGPUBlendState; +struct WGPUCompilationInfo; +struct WGPUComputePassDescriptor; +struct WGPUDepthStencilState; +struct WGPUImageCopyBuffer; +struct WGPUImageCopyTexture; +struct WGPUProgrammableStageDescriptor; +struct WGPURenderPassColorAttachment; +struct WGPURequiredLimits; +struct WGPUShaderModuleDescriptor; +struct WGPUSupportedLimits; +struct WGPUTextureDescriptor; +struct WGPUVertexBufferLayout; +struct WGPUBindGroupLayoutDescriptor; +struct WGPUColorTargetState; +struct WGPUComputePipelineDescriptor; +struct WGPUDeviceDescriptor; +struct WGPURenderPassDescriptor; +struct WGPUVertexState; +struct WGPUFragmentState; +struct WGPURenderPipelineDescriptor; typedef enum WGPUAdapterType { WGPUAdapterType_DiscreteGPU = 0x00000000, @@ -92,26 +180,27 @@ typedef enum WGPUAdapterType { WGPUAdapterType_CPU = 0x00000002, WGPUAdapterType_Unknown = 0x00000003, WGPUAdapterType_Force32 = 0x7FFFFFFF -} WGPUAdapterType; +} WGPUAdapterType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUAddressMode { WGPUAddressMode_Repeat = 0x00000000, WGPUAddressMode_MirrorRepeat = 0x00000001, WGPUAddressMode_ClampToEdge = 0x00000002, WGPUAddressMode_Force32 = 0x7FFFFFFF -} WGPUAddressMode; +} WGPUAddressMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBackendType { - WGPUBackendType_Null = 0x00000000, - WGPUBackendType_WebGPU = 0x00000001, - WGPUBackendType_D3D11 = 0x00000002, - WGPUBackendType_D3D12 = 0x00000003, - WGPUBackendType_Metal = 0x00000004, - WGPUBackendType_Vulkan = 0x00000005, - WGPUBackendType_OpenGL = 0x00000006, - WGPUBackendType_OpenGLES = 0x00000007, + WGPUBackendType_Undefined = 0x00000000, + WGPUBackendType_Null = 0x00000001, + WGPUBackendType_WebGPU = 0x00000002, + WGPUBackendType_D3D11 = 0x00000003, + WGPUBackendType_D3D12 = 0x00000004, + WGPUBackendType_Metal = 0x00000005, + WGPUBackendType_Vulkan = 0x00000006, + WGPUBackendType_OpenGL = 0x00000007, + WGPUBackendType_OpenGLES = 0x00000008, WGPUBackendType_Force32 = 0x7FFFFFFF -} WGPUBackendType; +} WGPUBackendType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendFactor { WGPUBlendFactor_Zero = 0x00000000, @@ -128,7 +217,7 @@ typedef enum WGPUBlendFactor { WGPUBlendFactor_Constant = 0x0000000B, WGPUBlendFactor_OneMinusConstant = 0x0000000C, WGPUBlendFactor_Force32 = 0x7FFFFFFF -} WGPUBlendFactor; +} WGPUBlendFactor WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendOperation { WGPUBlendOperation_Add = 0x00000000, @@ -137,7 +226,7 @@ typedef enum WGPUBlendOperation { WGPUBlendOperation_Min = 0x00000003, WGPUBlendOperation_Max = 0x00000004, WGPUBlendOperation_Force32 = 0x7FFFFFFF -} WGPUBlendOperation; +} WGPUBlendOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferBindingType { WGPUBufferBindingType_Undefined = 0x00000000, @@ -145,17 +234,27 @@ typedef enum WGPUBufferBindingType { WGPUBufferBindingType_Storage = 0x00000002, WGPUBufferBindingType_ReadOnlyStorage = 0x00000003, WGPUBufferBindingType_Force32 = 0x7FFFFFFF -} WGPUBufferBindingType; +} WGPUBufferBindingType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferMapAsyncStatus { WGPUBufferMapAsyncStatus_Success = 0x00000000, - WGPUBufferMapAsyncStatus_Error = 0x00000001, + WGPUBufferMapAsyncStatus_ValidationError = 0x00000001, WGPUBufferMapAsyncStatus_Unknown = 0x00000002, WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, WGPUBufferMapAsyncStatus_DestroyedBeforeCallback = 0x00000004, WGPUBufferMapAsyncStatus_UnmappedBeforeCallback = 0x00000005, + WGPUBufferMapAsyncStatus_MappingAlreadyPending = 0x00000006, + WGPUBufferMapAsyncStatus_OffsetOutOfRange = 0x00000007, + WGPUBufferMapAsyncStatus_SizeOutOfRange = 0x00000008, WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUBufferMapAsyncStatus; +} WGPUBufferMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUBufferMapState { + WGPUBufferMapState_Unmapped = 0x00000000, + WGPUBufferMapState_Pending = 0x00000001, + WGPUBufferMapState_Mapped = 0x00000002, + WGPUBufferMapState_Force32 = 0x7FFFFFFF +} WGPUBufferMapState WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompareFunction { WGPUCompareFunction_Undefined = 0x00000000, @@ -168,7 +267,7 @@ typedef enum WGPUCompareFunction { WGPUCompareFunction_NotEqual = 0x00000007, WGPUCompareFunction_Always = 0x00000008, WGPUCompareFunction_Force32 = 0x7FFFFFFF -} WGPUCompareFunction; +} WGPUCompareFunction WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationInfoRequestStatus { WGPUCompilationInfoRequestStatus_Success = 0x00000000, @@ -176,49 +275,50 @@ typedef enum WGPUCompilationInfoRequestStatus { WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF -} WGPUCompilationInfoRequestStatus; +} WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationMessageType { WGPUCompilationMessageType_Error = 0x00000000, WGPUCompilationMessageType_Warning = 0x00000001, WGPUCompilationMessageType_Info = 0x00000002, WGPUCompilationMessageType_Force32 = 0x7FFFFFFF -} WGPUCompilationMessageType; +} WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUComputePassTimestampLocation { WGPUComputePassTimestampLocation_Beginning = 0x00000000, WGPUComputePassTimestampLocation_End = 0x00000001, WGPUComputePassTimestampLocation_Force32 = 0x7FFFFFFF -} WGPUComputePassTimestampLocation; +} WGPUComputePassTimestampLocation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCreatePipelineAsyncStatus { WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_Error = 0x00000001, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000003, - WGPUCreatePipelineAsyncStatus_Unknown = 0x00000004, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, + WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, + WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, + WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUCreatePipelineAsyncStatus; +} WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCullMode { WGPUCullMode_None = 0x00000000, WGPUCullMode_Front = 0x00000001, WGPUCullMode_Back = 0x00000002, WGPUCullMode_Force32 = 0x7FFFFFFF -} WGPUCullMode; +} WGPUCullMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUDeviceLostReason { WGPUDeviceLostReason_Undefined = 0x00000000, WGPUDeviceLostReason_Destroyed = 0x00000001, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF -} WGPUDeviceLostReason; +} WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorFilter { WGPUErrorFilter_Validation = 0x00000000, WGPUErrorFilter_OutOfMemory = 0x00000001, WGPUErrorFilter_Internal = 0x00000002, WGPUErrorFilter_Force32 = 0x7FFFFFFF -} WGPUErrorFilter; +} WGPUErrorFilter WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorType { WGPUErrorType_NoError = 0x00000000, @@ -228,7 +328,7 @@ typedef enum WGPUErrorType { WGPUErrorType_Unknown = 0x00000004, WGPUErrorType_DeviceLost = 0x00000005, WGPUErrorType_Force32 = 0x7FFFFFFF -} WGPUErrorType; +} WGPUErrorType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFeatureName { WGPUFeatureName_Undefined = 0x00000000, @@ -242,40 +342,42 @@ typedef enum WGPUFeatureName { WGPUFeatureName_IndirectFirstInstance = 0x00000008, WGPUFeatureName_ShaderF16 = 0x00000009, WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000A, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000B, + WGPUFeatureName_Float32Filterable = 0x0000000C, WGPUFeatureName_Force32 = 0x7FFFFFFF -} WGPUFeatureName; +} WGPUFeatureName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFilterMode { WGPUFilterMode_Nearest = 0x00000000, WGPUFilterMode_Linear = 0x00000001, WGPUFilterMode_Force32 = 0x7FFFFFFF -} WGPUFilterMode; +} WGPUFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFrontFace { WGPUFrontFace_CCW = 0x00000000, WGPUFrontFace_CW = 0x00000001, WGPUFrontFace_Force32 = 0x7FFFFFFF -} WGPUFrontFace; +} WGPUFrontFace WGPU_ENUM_ATTRIBUTE; typedef enum WGPUIndexFormat { WGPUIndexFormat_Undefined = 0x00000000, WGPUIndexFormat_Uint16 = 0x00000001, WGPUIndexFormat_Uint32 = 0x00000002, WGPUIndexFormat_Force32 = 0x7FFFFFFF -} WGPUIndexFormat; +} WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPULoadOp { WGPULoadOp_Undefined = 0x00000000, WGPULoadOp_Clear = 0x00000001, WGPULoadOp_Load = 0x00000002, WGPULoadOp_Force32 = 0x7FFFFFFF -} WGPULoadOp; +} WGPULoadOp WGPU_ENUM_ATTRIBUTE; typedef enum WGPUMipmapFilterMode { WGPUMipmapFilterMode_Nearest = 0x00000000, WGPUMipmapFilterMode_Linear = 0x00000001, WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF -} WGPUMipmapFilterMode; +} WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPipelineStatisticName { WGPUPipelineStatisticName_VertexShaderInvocations = 0x00000000, @@ -284,21 +386,21 @@ typedef enum WGPUPipelineStatisticName { WGPUPipelineStatisticName_FragmentShaderInvocations = 0x00000003, WGPUPipelineStatisticName_ComputeShaderInvocations = 0x00000004, WGPUPipelineStatisticName_Force32 = 0x7FFFFFFF -} WGPUPipelineStatisticName; +} WGPUPipelineStatisticName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPowerPreference { WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, WGPUPowerPreference_HighPerformance = 0x00000002, WGPUPowerPreference_Force32 = 0x7FFFFFFF -} WGPUPowerPreference; +} WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPresentMode { WGPUPresentMode_Immediate = 0x00000000, WGPUPresentMode_Mailbox = 0x00000001, WGPUPresentMode_Fifo = 0x00000002, WGPUPresentMode_Force32 = 0x7FFFFFFF -} WGPUPresentMode; +} WGPUPresentMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPrimitiveTopology { WGPUPrimitiveTopology_PointList = 0x00000000, @@ -307,14 +409,14 @@ typedef enum WGPUPrimitiveTopology { WGPUPrimitiveTopology_TriangleList = 0x00000003, WGPUPrimitiveTopology_TriangleStrip = 0x00000004, WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF -} WGPUPrimitiveTopology; +} WGPUPrimitiveTopology WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueryType { WGPUQueryType_Occlusion = 0x00000000, WGPUQueryType_PipelineStatistics = 0x00000001, WGPUQueryType_Timestamp = 0x00000002, WGPUQueryType_Force32 = 0x7FFFFFFF -} WGPUQueryType; +} WGPUQueryType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueueWorkDoneStatus { WGPUQueueWorkDoneStatus_Success = 0x00000000, @@ -322,13 +424,13 @@ typedef enum WGPUQueueWorkDoneStatus { WGPUQueueWorkDoneStatus_Unknown = 0x00000002, WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF -} WGPUQueueWorkDoneStatus; +} WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURenderPassTimestampLocation { WGPURenderPassTimestampLocation_Beginning = 0x00000000, WGPURenderPassTimestampLocation_End = 0x00000001, WGPURenderPassTimestampLocation_Force32 = 0x7FFFFFFF -} WGPURenderPassTimestampLocation; +} WGPURenderPassTimestampLocation WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { WGPURequestAdapterStatus_Success = 0x00000000, @@ -336,14 +438,14 @@ typedef enum WGPURequestAdapterStatus { WGPURequestAdapterStatus_Error = 0x00000002, WGPURequestAdapterStatus_Unknown = 0x00000003, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF -} WGPURequestAdapterStatus; +} WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { WGPURequestDeviceStatus_Success = 0x00000000, WGPURequestDeviceStatus_Error = 0x00000001, WGPURequestDeviceStatus_Unknown = 0x00000002, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF -} WGPURequestDeviceStatus; +} WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSType { WGPUSType_Invalid = 0x00000000, @@ -359,7 +461,7 @@ typedef enum WGPUSType { WGPUSType_SurfaceDescriptorFromXcbWindow = 0x0000000A, WGPUSType_RenderPassDescriptorMaxDrawCount = 0x0000000F, WGPUSType_Force32 = 0x7FFFFFFF -} WGPUSType; +} WGPUSType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSamplerBindingType { WGPUSamplerBindingType_Undefined = 0x00000000, @@ -367,7 +469,7 @@ typedef enum WGPUSamplerBindingType { WGPUSamplerBindingType_NonFiltering = 0x00000002, WGPUSamplerBindingType_Comparison = 0x00000003, WGPUSamplerBindingType_Force32 = 0x7FFFFFFF -} WGPUSamplerBindingType; +} WGPUSamplerBindingType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStencilOperation { WGPUStencilOperation_Keep = 0x00000000, @@ -379,42 +481,34 @@ typedef enum WGPUStencilOperation { WGPUStencilOperation_IncrementWrap = 0x00000006, WGPUStencilOperation_DecrementWrap = 0x00000007, WGPUStencilOperation_Force32 = 0x7FFFFFFF -} WGPUStencilOperation; +} WGPUStencilOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStorageTextureAccess { WGPUStorageTextureAccess_Undefined = 0x00000000, WGPUStorageTextureAccess_WriteOnly = 0x00000001, WGPUStorageTextureAccess_Force32 = 0x7FFFFFFF -} WGPUStorageTextureAccess; +} WGPUStorageTextureAccess WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStoreOp { WGPUStoreOp_Undefined = 0x00000000, WGPUStoreOp_Store = 0x00000001, WGPUStoreOp_Discard = 0x00000002, WGPUStoreOp_Force32 = 0x7FFFFFFF -} WGPUStoreOp; +} WGPUStoreOp WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureAspect { WGPUTextureAspect_All = 0x00000000, WGPUTextureAspect_StencilOnly = 0x00000001, WGPUTextureAspect_DepthOnly = 0x00000002, WGPUTextureAspect_Force32 = 0x7FFFFFFF -} WGPUTextureAspect; - -typedef enum WGPUTextureComponentType { - WGPUTextureComponentType_Float = 0x00000000, - WGPUTextureComponentType_Sint = 0x00000001, - WGPUTextureComponentType_Uint = 0x00000002, - WGPUTextureComponentType_DepthComparison = 0x00000003, - WGPUTextureComponentType_Force32 = 0x7FFFFFFF -} WGPUTextureComponentType; +} WGPUTextureAspect WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureDimension { WGPUTextureDimension_1D = 0x00000000, WGPUTextureDimension_2D = 0x00000001, WGPUTextureDimension_3D = 0x00000002, WGPUTextureDimension_Force32 = 0x7FFFFFFF -} WGPUTextureDimension; +} WGPUTextureDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureFormat { WGPUTextureFormat_Undefined = 0x00000000, @@ -513,7 +607,7 @@ typedef enum WGPUTextureFormat { WGPUTextureFormat_ASTC12x12Unorm = 0x0000005D, WGPUTextureFormat_ASTC12x12UnormSrgb = 0x0000005E, WGPUTextureFormat_Force32 = 0x7FFFFFFF -} WGPUTextureFormat; +} WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureSampleType { WGPUTextureSampleType_Undefined = 0x00000000, @@ -523,7 +617,7 @@ typedef enum WGPUTextureSampleType { WGPUTextureSampleType_Sint = 0x00000004, WGPUTextureSampleType_Uint = 0x00000005, WGPUTextureSampleType_Force32 = 0x7FFFFFFF -} WGPUTextureSampleType; +} WGPUTextureSampleType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureViewDimension { WGPUTextureViewDimension_Undefined = 0x00000000, @@ -534,7 +628,7 @@ typedef enum WGPUTextureViewDimension { WGPUTextureViewDimension_CubeArray = 0x00000005, WGPUTextureViewDimension_3D = 0x00000006, WGPUTextureViewDimension_Force32 = 0x7FFFFFFF -} WGPUTextureViewDimension; +} WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexFormat { WGPUVertexFormat_Undefined = 0x00000000, @@ -569,14 +663,14 @@ typedef enum WGPUVertexFormat { WGPUVertexFormat_Sint32x3 = 0x0000001D, WGPUVertexFormat_Sint32x4 = 0x0000001E, WGPUVertexFormat_Force32 = 0x7FFFFFFF -} WGPUVertexFormat; +} WGPUVertexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexStepMode { WGPUVertexStepMode_Vertex = 0x00000000, WGPUVertexStepMode_Instance = 0x00000001, WGPUVertexStepMode_VertexBufferNotUsed = 0x00000002, WGPUVertexStepMode_Force32 = 0x7FFFFFFF -} WGPUVertexStepMode; +} WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferUsage { WGPUBufferUsage_None = 0x00000000, @@ -591,8 +685,8 @@ typedef enum WGPUBufferUsage { WGPUBufferUsage_Indirect = 0x00000100, WGPUBufferUsage_QueryResolve = 0x00000200, WGPUBufferUsage_Force32 = 0x7FFFFFFF -} WGPUBufferUsage; -typedef WGPUFlags WGPUBufferUsageFlags; +} WGPUBufferUsage WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUBufferUsageFlags WGPU_ENUM_ATTRIBUTE; typedef enum WGPUColorWriteMask { WGPUColorWriteMask_None = 0x00000000, @@ -602,16 +696,16 @@ typedef enum WGPUColorWriteMask { WGPUColorWriteMask_Alpha = 0x00000008, WGPUColorWriteMask_All = 0x0000000F, WGPUColorWriteMask_Force32 = 0x7FFFFFFF -} WGPUColorWriteMask; -typedef WGPUFlags WGPUColorWriteMaskFlags; +} WGPUColorWriteMask WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUColorWriteMaskFlags WGPU_ENUM_ATTRIBUTE; typedef enum WGPUMapMode { WGPUMapMode_None = 0x00000000, WGPUMapMode_Read = 0x00000001, WGPUMapMode_Write = 0x00000002, WGPUMapMode_Force32 = 0x7FFFFFFF -} WGPUMapMode; -typedef WGPUFlags WGPUMapModeFlags; +} WGPUMapMode WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUMapModeFlags WGPU_ENUM_ATTRIBUTE; typedef enum WGPUShaderStage { WGPUShaderStage_None = 0x00000000, @@ -619,8 +713,8 @@ typedef enum WGPUShaderStage { WGPUShaderStage_Fragment = 0x00000002, WGPUShaderStage_Compute = 0x00000004, WGPUShaderStage_Force32 = 0x7FFFFFFF -} WGPUShaderStage; -typedef WGPUFlags WGPUShaderStageFlags; +} WGPUShaderStage WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUShaderStageFlags WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureUsage { WGPUTextureUsage_None = 0x00000000, @@ -630,18 +724,29 @@ typedef enum WGPUTextureUsage { WGPUTextureUsage_StorageBinding = 0x00000008, WGPUTextureUsage_RenderAttachment = 0x00000010, WGPUTextureUsage_Force32 = 0x7FFFFFFF -} WGPUTextureUsage; -typedef WGPUFlags WGPUTextureUsageFlags; +} WGPUTextureUsage WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; + +typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef struct WGPUChainedStruct { struct WGPUChainedStruct const * next; WGPUSType sType; -} WGPUChainedStruct; +} WGPUChainedStruct WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUChainedStructOut { struct WGPUChainedStructOut * next; WGPUSType sType; -} WGPUChainedStructOut; +} WGPUChainedStructOut WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUAdapterProperties { WGPUChainedStructOut * nextInChain; @@ -653,87 +758,90 @@ typedef struct WGPUAdapterProperties { char const * driverDescription; WGPUAdapterType adapterType; WGPUBackendType backendType; -} WGPUAdapterProperties; +} WGPUAdapterProperties WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupEntry { WGPUChainedStruct const * nextInChain; uint32_t binding; - WGPUBuffer buffer; // nullable + WGPU_NULLABLE WGPUBuffer buffer; uint64_t offset; uint64_t size; - WGPUSampler sampler; // nullable - WGPUTextureView textureView; // nullable -} WGPUBindGroupEntry; + WGPU_NULLABLE WGPUSampler sampler; + WGPU_NULLABLE WGPUTextureView textureView; +} WGPUBindGroupEntry WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBlendComponent { WGPUBlendOperation operation; WGPUBlendFactor srcFactor; WGPUBlendFactor dstFactor; -} WGPUBlendComponent; +} WGPUBlendComponent WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBufferBindingLayout { WGPUChainedStruct const * nextInChain; WGPUBufferBindingType type; bool hasDynamicOffset; uint64_t minBindingSize; -} WGPUBufferBindingLayout; +} WGPUBufferBindingLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBufferDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUBufferUsageFlags usage; uint64_t size; bool mappedAtCreation; -} WGPUBufferDescriptor; +} WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUColor { double r; double g; double b; double a; -} WGPUColor; +} WGPUColor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCommandBufferDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable -} WGPUCommandBufferDescriptor; + WGPU_NULLABLE char const * label; +} WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCommandEncoderDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable -} WGPUCommandEncoderDescriptor; + WGPU_NULLABLE char const * label; +} WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCompilationMessage { WGPUChainedStruct const * nextInChain; - char const * message; // nullable + WGPU_NULLABLE char const * message; WGPUCompilationMessageType type; uint64_t lineNum; uint64_t linePos; uint64_t offset; uint64_t length; -} WGPUCompilationMessage; + uint64_t utf16LinePos; + uint64_t utf16Offset; + uint64_t utf16Length; +} WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePassTimestampWrite { WGPUQuerySet querySet; uint32_t queryIndex; WGPUComputePassTimestampLocation location; -} WGPUComputePassTimestampWrite; +} WGPUComputePassTimestampWrite WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUConstantEntry { WGPUChainedStruct const * nextInChain; char const * key; double value; -} WGPUConstantEntry; +} WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUExtent3D { uint32_t width; uint32_t height; uint32_t depthOrArrayLayers; -} WGPUExtent3D; +} WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUInstanceDescriptor { WGPUChainedStruct const * nextInChain; -} WGPUInstanceDescriptor; +} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPULimits { uint32_t maxTextureDimension1D; @@ -760,39 +868,40 @@ typedef struct WGPULimits { uint32_t maxInterStageShaderComponents; uint32_t maxInterStageShaderVariables; uint32_t maxColorAttachments; + uint32_t maxColorAttachmentBytesPerSample; uint32_t maxComputeWorkgroupStorageSize; uint32_t maxComputeInvocationsPerWorkgroup; uint32_t maxComputeWorkgroupSizeX; uint32_t maxComputeWorkgroupSizeY; uint32_t maxComputeWorkgroupSizeZ; uint32_t maxComputeWorkgroupsPerDimension; -} WGPULimits; +} WGPULimits WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUMultisampleState { WGPUChainedStruct const * nextInChain; uint32_t count; uint32_t mask; bool alphaToCoverageEnabled; -} WGPUMultisampleState; +} WGPUMultisampleState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUOrigin3D { uint32_t x; uint32_t y; uint32_t z; -} WGPUOrigin3D; +} WGPUOrigin3D WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUPipelineLayoutDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t bindGroupLayoutCount; + WGPU_NULLABLE char const * label; + size_t bindGroupLayoutCount; WGPUBindGroupLayout const * bindGroupLayouts; -} WGPUPipelineLayoutDescriptor; +} WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUPrimitiveState typedef struct WGPUPrimitiveDepthClipControl { WGPUChainedStruct chain; bool unclippedDepth; -} WGPUPrimitiveDepthClipControl; +} WGPUPrimitiveDepthClipControl WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUPrimitiveState { WGPUChainedStruct const * nextInChain; @@ -800,37 +909,37 @@ typedef struct WGPUPrimitiveState { WGPUIndexFormat stripIndexFormat; WGPUFrontFace frontFace; WGPUCullMode cullMode; -} WGPUPrimitiveState; +} WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQuerySetDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUQueryType type; uint32_t count; WGPUPipelineStatisticName const * pipelineStatistics; - uint32_t pipelineStatisticsCount; -} WGPUQuerySetDescriptor; + size_t pipelineStatisticsCount; +} WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQueueDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable -} WGPUQueueDescriptor; + WGPU_NULLABLE char const * label; +} WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable -} WGPURenderBundleDescriptor; + WGPU_NULLABLE char const * label; +} WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleEncoderDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t colorFormatsCount; + WGPU_NULLABLE char const * label; + size_t colorFormatsCount; WGPUTextureFormat const * colorFormats; WGPUTextureFormat depthStencilFormat; uint32_t sampleCount; bool depthReadOnly; bool stencilReadOnly; -} WGPURenderBundleEncoderDescriptor; +} WGPURenderBundleEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassDepthStencilAttachment { WGPUTextureView view; @@ -842,35 +951,36 @@ typedef struct WGPURenderPassDepthStencilAttachment { WGPUStoreOp stencilStoreOp; uint32_t stencilClearValue; bool stencilReadOnly; -} WGPURenderPassDepthStencilAttachment; +} WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPURenderPassDescriptor typedef struct WGPURenderPassDescriptorMaxDrawCount { WGPUChainedStruct chain; uint64_t maxDrawCount; -} WGPURenderPassDescriptorMaxDrawCount; +} WGPURenderPassDescriptorMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassTimestampWrite { WGPUQuerySet querySet; uint32_t queryIndex; WGPURenderPassTimestampLocation location; -} WGPURenderPassTimestampWrite; +} WGPURenderPassTimestampWrite WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURequestAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPUSurface compatibleSurface; // nullable + WGPU_NULLABLE WGPUSurface compatibleSurface; WGPUPowerPreference powerPreference; + WGPUBackendType backendType; bool forceFallbackAdapter; -} WGPURequestAdapterOptions; +} WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSamplerBindingLayout { WGPUChainedStruct const * nextInChain; WGPUSamplerBindingType type; -} WGPUSamplerBindingLayout; +} WGPUSamplerBindingLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUAddressMode addressModeU; WGPUAddressMode addressModeV; WGPUAddressMode addressModeW; @@ -881,119 +991,119 @@ typedef struct WGPUSamplerDescriptor { float lodMaxClamp; WGPUCompareFunction compare; uint16_t maxAnisotropy; -} WGPUSamplerDescriptor; +} WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUShaderModuleCompilationHint { WGPUChainedStruct const * nextInChain; char const * entryPoint; WGPUPipelineLayout layout; -} WGPUShaderModuleCompilationHint; +} WGPUShaderModuleCompilationHint WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUShaderModuleDescriptor typedef struct WGPUShaderModuleSPIRVDescriptor { WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; -} WGPUShaderModuleSPIRVDescriptor; +} WGPUShaderModuleSPIRVDescriptor WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUShaderModuleDescriptor typedef struct WGPUShaderModuleWGSLDescriptor { WGPUChainedStruct chain; char const * code; -} WGPUShaderModuleWGSLDescriptor; +} WGPUShaderModuleWGSLDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUStencilFaceState { WGPUCompareFunction compare; WGPUStencilOperation failOp; WGPUStencilOperation depthFailOp; WGPUStencilOperation passOp; -} WGPUStencilFaceState; +} WGPUStencilFaceState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUStorageTextureBindingLayout { WGPUChainedStruct const * nextInChain; WGPUStorageTextureAccess access; WGPUTextureFormat format; WGPUTextureViewDimension viewDimension; -} WGPUStorageTextureBindingLayout; +} WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSurfaceDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable -} WGPUSurfaceDescriptor; + WGPU_NULLABLE char const * label; +} WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { WGPUChainedStruct chain; void * window; -} WGPUSurfaceDescriptorFromAndroidNativeWindow; +} WGPUSurfaceDescriptorFromAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { WGPUChainedStruct chain; char const * selector; -} WGPUSurfaceDescriptorFromCanvasHTMLSelector; +} WGPUSurfaceDescriptorFromCanvasHTMLSelector WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromMetalLayer { WGPUChainedStruct chain; void * layer; -} WGPUSurfaceDescriptorFromMetalLayer; +} WGPUSurfaceDescriptorFromMetalLayer WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromWaylandSurface { WGPUChainedStruct chain; void * display; void * surface; -} WGPUSurfaceDescriptorFromWaylandSurface; +} WGPUSurfaceDescriptorFromWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromWindowsHWND { WGPUChainedStruct chain; void * hinstance; void * hwnd; -} WGPUSurfaceDescriptorFromWindowsHWND; +} WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromXcbWindow { WGPUChainedStruct chain; void * connection; uint32_t window; -} WGPUSurfaceDescriptorFromXcbWindow; +} WGPUSurfaceDescriptorFromXcbWindow WGPU_STRUCTURE_ATTRIBUTE; // Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromXlibWindow { WGPUChainedStruct chain; void * display; uint32_t window; -} WGPUSurfaceDescriptorFromXlibWindow; +} WGPUSurfaceDescriptorFromXlibWindow WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSwapChainDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUTextureUsageFlags usage; WGPUTextureFormat format; uint32_t width; uint32_t height; WGPUPresentMode presentMode; -} WGPUSwapChainDescriptor; +} WGPUSwapChainDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureBindingLayout { WGPUChainedStruct const * nextInChain; WGPUTextureSampleType sampleType; WGPUTextureViewDimension viewDimension; bool multisampled; -} WGPUTextureBindingLayout; +} WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureDataLayout { WGPUChainedStruct const * nextInChain; uint64_t offset; uint32_t bytesPerRow; uint32_t rowsPerImage; -} WGPUTextureDataLayout; +} WGPUTextureDataLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureViewDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUTextureFormat format; WGPUTextureViewDimension dimension; uint32_t baseMipLevel; @@ -1001,21 +1111,21 @@ typedef struct WGPUTextureViewDescriptor { uint32_t baseArrayLayer; uint32_t arrayLayerCount; WGPUTextureAspect aspect; -} WGPUTextureViewDescriptor; +} WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexAttribute { WGPUVertexFormat format; uint64_t offset; uint32_t shaderLocation; -} WGPUVertexAttribute; +} WGPUVertexAttribute WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUBindGroupLayout layout; - uint32_t entryCount; + size_t entryCount; WGPUBindGroupEntry const * entries; -} WGPUBindGroupDescriptor; +} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupLayoutEntry { WGPUChainedStruct const * nextInChain; @@ -1025,25 +1135,25 @@ typedef struct WGPUBindGroupLayoutEntry { WGPUSamplerBindingLayout sampler; WGPUTextureBindingLayout texture; WGPUStorageTextureBindingLayout storageTexture; -} WGPUBindGroupLayoutEntry; +} WGPUBindGroupLayoutEntry WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBlendState { WGPUBlendComponent color; WGPUBlendComponent alpha; -} WGPUBlendState; +} WGPUBlendState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCompilationInfo { WGPUChainedStruct const * nextInChain; - uint32_t messageCount; + size_t messageCount; WGPUCompilationMessage const * messages; -} WGPUCompilationInfo; +} WGPUCompilationInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePassDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t timestampWriteCount; + WGPU_NULLABLE char const * label; + size_t timestampWriteCount; WGPUComputePassTimestampWrite const * timestampWrites; -} WGPUComputePassDescriptor; +} WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUDepthStencilState { WGPUChainedStruct const * nextInChain; @@ -1057,13 +1167,13 @@ typedef struct WGPUDepthStencilState { int32_t depthBias; float depthBiasSlopeScale; float depthBiasClamp; -} WGPUDepthStencilState; +} WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUImageCopyBuffer { WGPUChainedStruct const * nextInChain; WGPUTextureDataLayout layout; WGPUBuffer buffer; -} WGPUImageCopyBuffer; +} WGPUImageCopyBuffer WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUImageCopyTexture { WGPUChainedStruct const * nextInChain; @@ -1071,519 +1181,608 @@ typedef struct WGPUImageCopyTexture { uint32_t mipLevel; WGPUOrigin3D origin; WGPUTextureAspect aspect; -} WGPUImageCopyTexture; +} WGPUImageCopyTexture WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUProgrammableStageDescriptor { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; char const * entryPoint; - uint32_t constantCount; + size_t constantCount; WGPUConstantEntry const * constants; -} WGPUProgrammableStageDescriptor; +} WGPUProgrammableStageDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassColorAttachment { - WGPUTextureView view; // nullable - WGPUTextureView resolveTarget; // nullable + WGPU_NULLABLE WGPUTextureView view; + WGPU_NULLABLE WGPUTextureView resolveTarget; WGPULoadOp loadOp; WGPUStoreOp storeOp; WGPUColor clearValue; -} WGPURenderPassColorAttachment; +} WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURequiredLimits { WGPUChainedStruct const * nextInChain; WGPULimits limits; -} WGPURequiredLimits; +} WGPURequiredLimits WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t hintCount; + WGPU_NULLABLE char const * label; + size_t hintCount; WGPUShaderModuleCompilationHint const * hints; -} WGPUShaderModuleDescriptor; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSupportedLimits { WGPUChainedStructOut * nextInChain; WGPULimits limits; -} WGPUSupportedLimits; +} WGPUSupportedLimits WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable + WGPU_NULLABLE char const * label; WGPUTextureUsageFlags usage; WGPUTextureDimension dimension; WGPUExtent3D size; WGPUTextureFormat format; uint32_t mipLevelCount; uint32_t sampleCount; - uint32_t viewFormatCount; + size_t viewFormatCount; WGPUTextureFormat const * viewFormats; -} WGPUTextureDescriptor; +} WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexBufferLayout { uint64_t arrayStride; WGPUVertexStepMode stepMode; - uint32_t attributeCount; + size_t attributeCount; WGPUVertexAttribute const * attributes; -} WGPUVertexBufferLayout; +} WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t entryCount; + WGPU_NULLABLE char const * label; + size_t entryCount; WGPUBindGroupLayoutEntry const * entries; -} WGPUBindGroupLayoutDescriptor; +} WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUColorTargetState { WGPUChainedStruct const * nextInChain; WGPUTextureFormat format; - WGPUBlendState const * blend; // nullable + WGPU_NULLABLE WGPUBlendState const * blend; WGPUColorWriteMaskFlags writeMask; -} WGPUColorTargetState; +} WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePipelineDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - WGPUPipelineLayout layout; // nullable + WGPU_NULLABLE char const * label; + WGPU_NULLABLE WGPUPipelineLayout layout; WGPUProgrammableStageDescriptor compute; -} WGPUComputePipelineDescriptor; +} WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUDeviceDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t requiredFeaturesCount; + WGPU_NULLABLE char const * label; + size_t requiredFeaturesCount; WGPUFeatureName const * requiredFeatures; - WGPURequiredLimits const * requiredLimits; // nullable + WGPU_NULLABLE WGPURequiredLimits const * requiredLimits; WGPUQueueDescriptor defaultQueue; -} WGPUDeviceDescriptor; + WGPUDeviceLostCallback deviceLostCallback; + void * deviceLostUserdata; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - uint32_t colorAttachmentCount; + WGPU_NULLABLE char const * label; + size_t colorAttachmentCount; WGPURenderPassColorAttachment const * colorAttachments; - WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; // nullable - WGPUQuerySet occlusionQuerySet; // nullable - uint32_t timestampWriteCount; + WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; + WGPU_NULLABLE WGPUQuerySet occlusionQuerySet; + size_t timestampWriteCount; WGPURenderPassTimestampWrite const * timestampWrites; -} WGPURenderPassDescriptor; +} WGPURenderPassDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; char const * entryPoint; - uint32_t constantCount; + size_t constantCount; WGPUConstantEntry const * constants; - uint32_t bufferCount; + size_t bufferCount; WGPUVertexBufferLayout const * buffers; -} WGPUVertexState; +} WGPUVertexState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUFragmentState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; char const * entryPoint; - uint32_t constantCount; + size_t constantCount; WGPUConstantEntry const * constants; - uint32_t targetCount; + size_t targetCount; WGPUColorTargetState const * targets; -} WGPUFragmentState; +} WGPUFragmentState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPipelineDescriptor { WGPUChainedStruct const * nextInChain; - char const * label; // nullable - WGPUPipelineLayout layout; // nullable + WGPU_NULLABLE char const * label; + WGPU_NULLABLE WGPUPipelineLayout layout; WGPUVertexState vertex; WGPUPrimitiveState primitive; - WGPUDepthStencilState const * depthStencil; // nullable + WGPU_NULLABLE WGPUDepthStencilState const * depthStencil; WGPUMultisampleState multisample; - WGPUFragmentState const * fragment; // nullable -} WGPURenderPipelineDescriptor; + WGPU_NULLABLE WGPUFragmentState const * fragment; +} WGPURenderPipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; #ifdef __cplusplus extern "C" { #endif -typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata); -typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, WGPUCompilationInfo const * compilationInfo, void * userdata); -typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata); -typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata); -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata); -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata); -typedef void (*WGPUProc)(void); -typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void * userdata); -typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata); -typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata); - #if !defined(WGPU_SKIP_PROCS) -typedef WGPUInstance (*WGPUProcCreateInstance)(WGPUInstanceDescriptor const * descriptor); -typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName); +typedef WGPUInstance (*WGPUProcCreateInstance)(WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; // Procs of Adapter -typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features); -typedef bool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits); -typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties); -typedef bool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature); -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor /* nullable */, WGPURequestDeviceCallback callback, void * userdata); +typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +typedef bool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; +typedef bool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroup -typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label); +typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroupLayout -typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, char const * label); +typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of Buffer -typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer); -typedef void const * (*WGPUProcBufferGetConstMappedRange)(WGPUBuffer buffer, size_t offset, size_t size); -typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size); -typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer); -typedef WGPUBufferUsage (*WGPUProcBufferGetUsage)(WGPUBuffer buffer); -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata); -typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label); -typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer); +typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void const * (*WGPUProcBufferGetConstMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandBuffer -typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, char const * label); +typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandBufferReference)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandEncoder -typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor /* nullable */); -typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor); -typedef void (*WGPUProcCommandEncoderClearBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); -typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size); -typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize); -typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize); -typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize); -typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor /* nullable */); -typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel); -typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder); -typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); -typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); -typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, char const * label); -typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderClearBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePassEncoder -typedef void (*WGPUProcComputePassEncoderBeginPipelineStatisticsQuery)(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -typedef void (*WGPUProcComputePassEncoderDispatchWorkgroups)(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ); -typedef void (*WGPUProcComputePassEncoderDispatchWorkgroupsIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef void (*WGPUProcComputePassEncoderEnd)(WGPUComputePassEncoder computePassEncoder); -typedef void (*WGPUProcComputePassEncoderEndPipelineStatisticsQuery)(WGPUComputePassEncoder computePassEncoder); -typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * markerLabel); -typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder); -typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); -typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, char const * label); -typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline); +typedef void (*WGPUProcComputePassEncoderBeginPipelineStatisticsQuery)(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderDispatchWorkgroups)(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderDispatchWorkgroupsIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderEnd)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderEndPipelineStatisticsQuery)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePipeline -typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex); -typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, char const * label); +typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Device -typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor); -typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); -typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor); -typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor /* nullable */); -typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata); -typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); -typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); -typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); -typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata); -typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */); -typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); -typedef WGPUSwapChain (*WGPUProcDeviceCreateSwapChain)(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); -typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor); -typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device); -typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features); -typedef bool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits); -typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device); -typedef bool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature); -typedef bool (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata); -typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter); -typedef void (*WGPUProcDeviceSetDeviceLostCallback)(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata); -typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label); -typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUSwapChain (*WGPUProcDeviceCreateSwapChain)(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +typedef bool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +typedef bool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Procs of Instance -typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); -typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance); -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPURequestAdapterOptions const * options /* nullable */, WGPURequestAdapterCallback callback, void * userdata); +typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; // Procs of PipelineLayout -typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, char const * label); +typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of QuerySet -typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet); -typedef uint32_t (*WGPUProcQuerySetGetCount)(WGPUQuerySet querySet); -typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet); -typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, char const * label); +typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcQuerySetGetCount)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata); -typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label); -typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands); -typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size); -typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize); +typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueReference)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of RenderBundle +typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleReference)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundleEncoder -typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); -typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor /* nullable */); -typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel); -typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder); -typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); -typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size); -typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, char const * label); -typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); -typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPassEncoder -typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); -typedef void (*WGPUProcRenderPassEncoderBeginPipelineStatisticsQuery)(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); -typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef void (*WGPUProcRenderPassEncoderEnd)(WGPURenderPassEncoder renderPassEncoder); -typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder); -typedef void (*WGPUProcRenderPassEncoderEndPipelineStatisticsQuery)(WGPURenderPassEncoder renderPassEncoder); -typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); -typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel); -typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder); -typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); -typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -typedef void (*WGPUProcRenderPassEncoderSetBlendConstant)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); -typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size); -typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, char const * label); -typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); -typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); -typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); -typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); -typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); +typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderBeginPipelineStatisticsQuery)(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderEnd)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderEndPipelineStatisticsQuery)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetBlendConstant)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPipeline -typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex); -typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, char const * label); +typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Sampler -typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, char const * label); +typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata); -typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label); +typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; // Procs of Surface -typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter); +typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Procs of SwapChain -typedef WGPUTextureView (*WGPUProcSwapChainGetCurrentTextureView)(WGPUSwapChain swapChain); -typedef void (*WGPUProcSwapChainPresent)(WGPUSwapChain swapChain); +typedef WGPUTextureView (*WGPUProcSwapChainGetCurrentTextureView)(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSwapChainPresent)(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSwapChainReference)(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSwapChainRelease)(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; // Procs of Texture -typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */); -typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture); -typedef uint32_t (*WGPUProcTextureGetDepthOrArrayLayers)(WGPUTexture texture); -typedef WGPUTextureDimension (*WGPUProcTextureGetDimension)(WGPUTexture texture); -typedef WGPUTextureFormat (*WGPUProcTextureGetFormat)(WGPUTexture texture); -typedef uint32_t (*WGPUProcTextureGetHeight)(WGPUTexture texture); -typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture); -typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture); -typedef WGPUTextureUsage (*WGPUProcTextureGetUsage)(WGPUTexture texture); -typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture); -typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, char const * label); +typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcTextureGetDepthOrArrayLayers)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUTextureDimension (*WGPUProcTextureGetDimension)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUTextureFormat (*WGPUProcTextureGetFormat)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcTextureGetHeight)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUTextureUsageFlags (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureReference)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; // Procs of TextureView -typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, char const * label); +typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureViewReference)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; #endif // !defined(WGPU_SKIP_PROCS) #if !defined(WGPU_SKIP_DECLARATIONS) -WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor); -WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName); +WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; // Methods of Adapter -WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features); -WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits); -WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties); -WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature); -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor /* nullable */, WGPURequestDeviceCallback callback, void * userdata); +WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; // Methods of BindGroup -WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label); +WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; // Methods of BindGroupLayout -WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label); +WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; // Methods of Buffer -WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer); -WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size); -WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size); -WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer); -WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer); -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata); -WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label); -WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer); +WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; // Methods of CommandBuffer -WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label); +WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; // Methods of CommandEncoder -WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor /* nullable */); -WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor); -WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); -WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size); -WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize); -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize); -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize); -WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor /* nullable */); -WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel); -WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder); -WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel); -WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); -WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label); -WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; // Methods of ComputePassEncoder -WGPU_EXPORT void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ); -WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder); -WGPU_EXPORT void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); -WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel); -WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder); -WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel); -WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label); -WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline); +WGPU_EXPORT void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Methods of ComputePipeline -WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex); -WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label); +WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; // Methods of Device -WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor); -WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); -WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor); -WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor /* nullable */); -WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata); -WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); -WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); -WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); -WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata); -WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */); -WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); -WGPU_EXPORT WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); -WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor); -WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device); -WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features); -WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits); -WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device); -WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature); -WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata); -WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter); -WGPU_EXPORT void wgpuDeviceSetDeviceLostCallback(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata); -WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label); -WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata); +WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Methods of Instance -WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); -WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance); -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options /* nullable */, WGPURequestAdapterCallback callback, void * userdata); +WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; // Methods of PipelineLayout -WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label); +WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; // Methods of QuerySet -WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet); -WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet); -WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet); -WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label); +WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Methods of Queue -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata); -WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label); -WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands); -WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size); -WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize); +WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; + +// Methods of RenderBundle +WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; // Methods of RenderBundleEncoder -WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); -WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor /* nullable */); -WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel); -WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder); -WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); -WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size); -WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label); -WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); -WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); +WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; // Methods of RenderPassEncoder -WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); -WGPU_EXPORT void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); -WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder); -WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder); -WGPU_EXPORT void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); -WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); -WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel); -WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder); -WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); -WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); -WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size); -WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label); -WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); -WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); -WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); -WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); -WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); +WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Methods of RenderPipeline -WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex); -WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label); +WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; // Methods of Sampler -WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label); +WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Methods of ShaderModule -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata); -WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label); +WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; // Methods of Surface -WGPU_EXPORT WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter); +WGPU_EXPORT WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Methods of SwapChain -WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain); -WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain); +WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSwapChainReference(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSwapChainRelease(WGPUSwapChain swapChain) WGPU_FUNCTION_ATTRIBUTE; // Methods of Texture -WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */); -WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture); -WGPU_EXPORT uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture); -WGPU_EXPORT WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture); -WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture); -WGPU_EXPORT uint32_t wgpuTextureGetHeight(WGPUTexture texture); -WGPU_EXPORT uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture); -WGPU_EXPORT uint32_t wgpuTextureGetSampleCount(WGPUTexture texture); -WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture); -WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture); -WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label); +WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuTextureGetHeight(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; // Methods of TextureView -WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label); +WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; #endif // !defined(WGPU_SKIP_DECLARATIONS) diff --git a/wgpu/resources/wgpu.h b/wgpu/resources/wgpu.h index edd475ea..dd36031b 100644 --- a/wgpu/resources/wgpu.h +++ b/wgpu/resources/wgpu.h @@ -3,18 +3,6 @@ #include "webgpu.h" -// must be used to free the strings & slices returned by the library, -// for other wgpu objects use appropriate drop functions. -// -// first parameter `type` has to be type of derefrenced value -// for example -> -// -// size_t count; -// const WGPUTextureFormat* formats = wgpuSurfaceGetSupportedFormats(surface, adapter, &count); -// WGPU_FREE(WGPUTextureFormat, formats, count); // notice `WGPUTextureFormat` instead of `WGPUTextureFormat *` -// -#define WGPU_FREE(type, ptr, len) wgpuFree((void *)ptr, len * sizeof(type), _Alignof(type)) - typedef enum WGPUNativeSType { // Start at 6 to prevent collisions with webgpu STypes WGPUSType_DeviceExtras = 0x60000001, @@ -24,15 +12,17 @@ typedef enum WGPUNativeSType { WGPUSType_ShaderModuleGLSLDescriptor = 0x60000005, WGPUSType_SupportedLimitsExtras = 0x60000003, WGPUSType_InstanceExtras = 0x60000006, + WGPUSType_SwapChainDescriptorExtras = 0x60000007, WGPUNativeSType_Force32 = 0x7FFFFFFF } WGPUNativeSType; typedef enum WGPUNativeFeature { - WGPUNativeFeature_PUSH_CONSTANTS = 0x60000001, - WGPUNativeFeature_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES = 0x60000002, - WGPUNativeFeature_MULTI_DRAW_INDIRECT = 0x60000003, - WGPUNativeFeature_MULTI_DRAW_INDIRECT_COUNT = 0x60000004, - WGPUNativeFeature_VERTEX_WRITABLE_STORAGE = 0x60000005, + WGPUNativeFeature_PushConstants = 0x60000001, + WGPUNativeFeature_TextureAdapterSpecificFormatFeatures = 0x60000002, + WGPUNativeFeature_MultiDrawIndirect = 0x60000003, + WGPUNativeFeature_MultiDrawIndirectCount = 0x60000004, + WGPUNativeFeature_VertexWritableStorage = 0x60000005, + WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; typedef enum WGPULogLevel { @@ -61,19 +51,33 @@ typedef enum WGPUInstanceBackend { } WGPUInstanceBackend; typedef WGPUFlags WGPUInstanceBackendFlags; +typedef enum WGPUDx12Compiler { + WGPUDx12Compiler_Undefined = 0x00000000, + WGPUDx12Compiler_Fxc = 0x00000001, + WGPUDx12Compiler_Dxc = 0x00000002, + WGPUDx12Compiler_Force32 = 0x7FFFFFFF +} WGPUDx12Compiler; + +typedef enum WGPUCompositeAlphaMode { + WGPUCompositeAlphaMode_Auto = 0x00000000, + WGPUCompositeAlphaMode_Opaque = 0x00000001, + WGPUCompositeAlphaMode_PreMultiplied = 0x00000002, + WGPUCompositeAlphaMode_PostMultiplied = 0x00000003, + WGPUCompositeAlphaMode_Inherit = 0x00000004, + WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF +} WGPUCompositeAlphaMode; + typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; WGPUInstanceBackendFlags backends; + WGPUDx12Compiler dx12ShaderCompiler; + const char * dxilPath; + const char * dxcPath; } WGPUInstanceExtras; -typedef struct WGPUAdapterExtras { - WGPUChainedStruct chain; - WGPUBackendType backend; -} WGPUAdapterExtras; - typedef struct WGPUDeviceExtras { WGPUChainedStruct chain; - const char* tracePath; + const char * tracePath; } WGPUDeviceExtras; typedef struct WGPURequiredLimitsExtras { @@ -115,7 +119,7 @@ typedef struct WGPUShaderModuleGLSLDescriptor { WGPUShaderStage stage; char const * code; uint32_t defineCount; - WGPUShaderDefine* defines; + WGPUShaderDefine * defines; } WGPUShaderModuleGLSLDescriptor; typedef struct WGPUStorageReport { @@ -153,15 +157,37 @@ typedef struct WGPUGlobalReport { WGPUHubReport gl; } WGPUGlobalReport; +typedef struct WGPUSurfaceCapabilities { + size_t formatCount; + WGPUTextureFormat * formats; + size_t presentModeCount; + WGPUPresentMode * presentModes; + size_t alphaModeCount; + WGPUCompositeAlphaMode * alphaModes; +} WGPUSurfaceCapabilities; + +typedef struct WGPUSwapChainDescriptorExtras { + WGPUChainedStruct chain; + WGPUCompositeAlphaMode alphaMode; + size_t viewFormatCount; + WGPUTextureFormat const * viewFormats; +} WGPUSwapChainDescriptorExtras; + +typedef struct WGPUInstanceEnumerateAdapterOptions { + WGPUChainedStruct const * nextInChain; + WGPUInstanceBackendFlags backends; +} WGPUInstanceEnumerateAdapterOptions; + typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); #ifdef __cplusplus extern "C" { #endif -void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport* report); +void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report); +size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); -WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands); +WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. bool wgpuDevicePoll(WGPUDevice device, bool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); @@ -172,13 +198,7 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); -// Returns slice of supported texture formats -// caller owns the formats slice and must WGPU_FREE() it -WGPUTextureFormat const * wgpuSurfaceGetSupportedFormats(WGPUSurface surface, WGPUAdapter adapter, size_t * count); - -// Returns slice of supported present modes -// caller owns the present modes slice and must WGPU_FREE() it -WGPUPresentMode const * wgpuSurfaceGetSupportedPresentModes(WGPUSurface surface, WGPUAdapter adapter, size_t * count); +void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities); void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void* const data); @@ -188,33 +208,6 @@ void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); -void wgpuInstanceDrop(WGPUInstance instance); -void wgpuAdapterDrop(WGPUAdapter adapter); -void wgpuBindGroupDrop(WGPUBindGroup bindGroup); -void wgpuBindGroupLayoutDrop(WGPUBindGroupLayout bindGroupLayout); -void wgpuBufferDrop(WGPUBuffer buffer); -void wgpuCommandBufferDrop(WGPUCommandBuffer commandBuffer); -void wgpuCommandEncoderDrop(WGPUCommandEncoder commandEncoder); -void wgpuRenderPassEncoderDrop(WGPURenderPassEncoder renderPassEncoder); -void wgpuComputePassEncoderDrop(WGPUComputePassEncoder computePassEncoder); -void wgpuRenderBundleEncoderDrop(WGPURenderBundleEncoder renderBundleEncoder); -void wgpuComputePipelineDrop(WGPUComputePipeline computePipeline); -void wgpuDeviceDrop(WGPUDevice device); -void wgpuPipelineLayoutDrop(WGPUPipelineLayout pipelineLayout); -void wgpuQuerySetDrop(WGPUQuerySet querySet); -void wgpuRenderBundleDrop(WGPURenderBundle renderBundle); -void wgpuRenderPipelineDrop(WGPURenderPipeline renderPipeline); -void wgpuSamplerDrop(WGPUSampler sampler); -void wgpuShaderModuleDrop(WGPUShaderModule shaderModule); -void wgpuSurfaceDrop(WGPUSurface surface); -void wgpuSwapChainDrop(WGPUSwapChain swapChain); -void wgpuTextureDrop(WGPUTexture texture); -void wgpuTextureViewDrop(WGPUTextureView textureView); - -// must be used to free the strings & slices returned by the library, -// for other wgpu objects use appropriate drop functions. -void wgpuFree(void* ptr, size_t size, size_t align); - #ifdef __cplusplus } // extern "C" #endif diff --git a/wgpu/utils/shadertoy.py b/wgpu/utils/shadertoy.py index 6b202127..849c55b3 100644 --- a/wgpu/utils/shadertoy.py +++ b/wgpu/utils/shadertoy.py @@ -25,6 +25,7 @@ } """ + builtin_variables_glsl = """ #version 450 core @@ -45,6 +46,7 @@ #define mainImage shader_main """ + fragment_code_glsl = """ layout(location = 0) in vec2 uv; @@ -75,6 +77,8 @@ } """ + + vertex_code_wgsl = """ struct Varyings { @@ -100,6 +104,7 @@ } """ + builtin_variables_wgsl = """ var i_resolution: vec3; @@ -113,6 +118,7 @@ """ + fragment_code_wgsl = """ struct ShadertoyInput {