Skip to content

Commit ddc5f59

Browse files
authored
Update to latest wgpu-native (#222)
* bump to latest wgpu-native * Update as needed * Update examples * changelog * fix tests
1 parent 268dadf commit ddc5f59

File tree

10 files changed

+184
-83
lines changed

10 files changed

+184
-83
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Possible sections in each release:
1818
* Security: in case of vulnerabilities.
1919

2020

21+
### [v0.7.0] - TBD
22+
23+
Changed:
24+
25+
* Now targeting wgpu-native v0.11.0.1, containing many upstream fixes and improvements.
26+
* The `[[block]]` syntax in shaders has been dropped.
27+
28+
2129
### [v0.6.0] - 16-12-2021
2230

2331
Added:

examples/compute_noop.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
shader_source = """
1414
15-
[[block]]
1615
struct DataContainer {
1716
data: [[stride(4)]] array<i32>;
1817
};

examples/cube.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147

148148

149149
shader_source = """
150-
[[block]]
151150
struct Locals {
152151
transform: mat4x4<f32>;
153152
};

tests/test_compute.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
simple_compute_shader = """
19-
[[block]]
2019
struct DataContainer { data: [[stride(4)]] array<i32>; };
2120
2221
[[group(0), binding(0)]]
@@ -120,7 +119,6 @@ def test_compute_0_1_spirv():
120119
def test_compute_1_3():
121120

122121
compute_shader = """
123-
[[block]]
124122
struct DataContainer { data: [[stride(4)]] array<i32>; };
125123
126124
[[group(0), binding(0)]]
@@ -156,7 +154,6 @@ def test_compute_1_3():
156154
def test_compute_indirect():
157155

158156
compute_shader = """
159-
[[block]]
160157
struct DataContainer { data: [[stride(4)]] array<i32>; };
161158
162159
[[group(0), binding(0)]]
@@ -263,7 +260,6 @@ def test_compute_indirect():
263260

264261
def test_compute_fails():
265262
compute_shader = """
266-
[[block]]
267263
struct DataContainer { data: [[stride(4)]] array<i32>; };
268264
269265
[[group(0), binding(0)]]

tests/test_gui_glfw.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import sys
88
import time
9+
import asyncio
910

1011
import wgpu.backends.rs # noqa
1112
from pytest import skip
@@ -38,7 +39,9 @@ def test_glfw_canvas_basics():
3839
canvas = WgpuCanvas()
3940

4041
canvas.set_logical_size(300, 200)
41-
glfw.poll_events()
42+
etime = time.time() + 0.1
43+
while time.time() < etime:
44+
glfw.poll_events()
4245
lsize = canvas.get_logical_size()
4346
assert isinstance(lsize, tuple) and len(lsize) == 2
4447
assert isinstance(lsize[0], float) and isinstance(lsize[1], float)
@@ -76,7 +79,9 @@ def test_glfw_canvas_render():
7679
import glfw
7780
from wgpu.gui.glfw import update_glfw_canvasses, WgpuCanvas
7881

79-
canvas = WgpuCanvas()
82+
loop = asyncio.get_event_loop()
83+
84+
canvas = WgpuCanvas(max_fps=9999)
8085

8186
# wgpu.utils.get_default_device()
8287
adapter = wgpu.request_adapter(canvas=canvas, power_preference="high-performance")
@@ -93,30 +98,29 @@ def draw_frame2():
9398
canvas.request_draw(draw_frame2)
9499

95100
# Give it a few rounds to start up
96-
for i in range(5):
97-
glfw.poll_events()
98-
update_glfw_canvasses()
101+
async def miniloop():
102+
for i in range(10):
103+
glfw.poll_events()
104+
update_glfw_canvasses()
105+
await asyncio.sleep(0.01)
106+
107+
loop.run_until_complete(miniloop())
99108
# There should have been exactly one draw now
100109
assert frame_counter == 1
101110

102111
# Ask for a lot of draws
103112
for i in range(5):
104113
canvas.request_draw()
105114
# Process evens for a while
106-
for i in range(5):
107-
glfw.poll_events()
108-
update_glfw_canvasses()
115+
loop.run_until_complete(miniloop())
109116
# We should have had just one draw
110117
assert frame_counter == 2
111118

112119
# Change the canvase size
113120
canvas.set_logical_size(300, 200)
114121
canvas.set_logical_size(400, 300)
115-
for i in range(5):
116-
time.sleep(0.01)
117-
glfw.poll_events()
118-
update_glfw_canvasses()
119122
# We should have had just one draw
123+
loop.run_until_complete(miniloop())
120124
assert frame_counter == 3
121125

122126
# canvas.close()

tests/test_rs_basics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def test_tuple_from_tuple_or_dict():
7979

8080

8181
compute_shader_wgsl = """
82-
[[block]]
8382
struct ArrayContainer { data: [[stride(4)]] array<i32>; };
8483
8584
[[group(0), binding(0)]]

wgpu/backends/rs.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
apidiff = ApiDiff()
5757

5858
# The wgpu-native version that we target/expect
59-
__version__ = "0.10.4.1"
60-
__commit_sha__ = "b4dd62d1781c923ae0b52195fb9e710a7fc6b177"
59+
__version__ = "0.11.0.1"
60+
__commit_sha__ = "9d962ef667ef6006cca7bac7489d5bf303a2a244"
6161
version_info = tuple(map(int, __version__.split(".")))
6262
check_expected_version(version_info) # produces a warning on mismatch
6363

@@ -445,10 +445,10 @@ def _request_device(self, label, features, required_limits, trace_path):
445445
# H: chain: WGPUChainedStruct, nativeFeatures: WGPUNativeFeature, label: char*, tracePath: char*
446446
extras = new_struct_p(
447447
"WGPUDeviceExtras *",
448-
label=to_c_label(label),
449448
tracePath=c_trace_path,
450449
nativeFeatures=lib.WGPUNativeFeature_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
451450
# not used: chain
451+
# not used: label
452452
)
453453
extras.chain.sType = lib.WGPUSType_DeviceExtras
454454

@@ -464,9 +464,10 @@ def _request_device(self, label, features, required_limits, trace_path):
464464
for key, val in required_limits.items():
465465
setattr(c_limits, to_camel_case(key), val)
466466

467-
# H: nextInChain: WGPUChainedStruct *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *
467+
# H: nextInChain: WGPUChainedStruct *, label: char *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *
468468
struct = new_struct_p(
469469
"WGPUDeviceDescriptor *",
470+
label=to_c_label(label),
470471
nextInChain=ffi.cast("WGPUChainedStruct * ", extras),
471472
requiredFeaturesCount=0,
472473
requiredFeatures=ffi.new("WGPUFeatureName []", []),
@@ -848,10 +849,10 @@ def create_shader_module(self, *, label="", code: str, source_map: dict = None):
848849

849850
if isinstance(code, str):
850851
# WGSL
851-
# H: chain: WGPUChainedStruct, source: char *
852+
# H: chain: WGPUChainedStruct, code: char *
852853
source_struct = new_struct_p(
853854
"WGPUShaderModuleWGSLDescriptor *",
854-
source=ffi.new("char []", code.encode()),
855+
code=ffi.new("char []", code.encode()),
855856
# not used: chain
856857
)
857858
source_struct[0].chain.next = ffi.NULL
@@ -1422,11 +1423,13 @@ def _destroy(self):
14221423

14231424
class GPUCommandEncoder(base.GPUCommandEncoder, GPUObjectBase):
14241425
def begin_compute_pass(self, *, label=""):
1425-
# H: nextInChain: WGPUChainedStruct *, label: char *
1426+
# H: nextInChain: WGPUChainedStruct *, label: char *, timestampWriteCount: int, timestampWrites: WGPUComputePassTimestampWrite *
14261427
struct = new_struct_p(
14271428
"WGPUComputePassDescriptor *",
14281429
label=to_c_label(label),
14291430
# not used: nextInChain
1431+
# not used: timestampWriteCount
1432+
# not used: timestampWrites
14301433
)
14311434
# H: WGPUComputePassEncoder f(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor)
14321435
raw_pass = lib.wgpuCommandEncoderBeginComputePass(self._internal, struct)
@@ -1508,7 +1511,7 @@ def begin_render_pass(
15081511
),
15091512
)
15101513

1511-
# H: nextInChain: WGPUChainedStruct *, label: char *, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet
1514+
# H: nextInChain: WGPUChainedStruct *, label: char *, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet, timestampWriteCount: int, timestampWrites: WGPURenderPassTimestampWrite *
15121515
struct = new_struct_p(
15131516
"WGPURenderPassDescriptor *",
15141517
label=to_c_label(label),
@@ -1517,6 +1520,8 @@ def begin_render_pass(
15171520
depthStencilAttachment=c_depth_stencil_attachment,
15181521
# not used: occlusionQuerySet
15191522
# not used: nextInChain
1523+
# not used: timestampWriteCount
1524+
# not used: timestampWrites
15201525
)
15211526

15221527
# H: WGPURenderPassEncoder f(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor)

wgpu/backends/rs_mappings.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# flake8: noqa
66

7-
# There are 187 enum mappings
7+
# There are 188 enum mappings
88

99
enummap = {
1010
"AddressMode.clamp-to-edge": 2,
@@ -48,7 +48,6 @@
4848
"DeviceLostReason.destroyed": 1,
4949
"ErrorFilter.out-of-memory": 2,
5050
"ErrorFilter.validation": 1,
51-
"FeatureName.depth-clamping": 1,
5251
"FeatureName.depth24unorm-stencil8": 2,
5352
"FeatureName.depth32float-stencil8": 3,
5453
"FeatureName.pipeline-statistics-query": 5,
@@ -66,8 +65,8 @@
6665
"PipelineStatisticName.compute-shader-invocations": 4,
6766
"PipelineStatisticName.fragment-shader-invocations": 3,
6867
"PipelineStatisticName.vertex-shader-invocations": 0,
69-
"PowerPreference.high-performance": 1,
70-
"PowerPreference.low-power": 0,
68+
"PowerPreference.high-performance": 2,
69+
"PowerPreference.low-power": 1,
7170
"PrimitiveTopology.line-list": 1,
7271
"PrimitiveTopology.line-strip": 2,
7372
"PrimitiveTopology.point-list": 0,
@@ -96,26 +95,28 @@
9695
"TextureDimension.1d": 0,
9796
"TextureDimension.2d": 1,
9897
"TextureDimension.3d": 2,
99-
"TextureFormat.bc1-rgba-unorm": 42,
100-
"TextureFormat.bc1-rgba-unorm-srgb": 43,
101-
"TextureFormat.bc2-rgba-unorm": 44,
102-
"TextureFormat.bc2-rgba-unorm-srgb": 45,
103-
"TextureFormat.bc3-rgba-unorm": 46,
104-
"TextureFormat.bc3-rgba-unorm-srgb": 47,
105-
"TextureFormat.bc4-r-snorm": 49,
106-
"TextureFormat.bc4-r-unorm": 48,
107-
"TextureFormat.bc5-rg-snorm": 51,
108-
"TextureFormat.bc5-rg-unorm": 50,
109-
"TextureFormat.bc6h-rgb-float": 53,
110-
"TextureFormat.bc6h-rgb-ufloat": 52,
111-
"TextureFormat.bc7-rgba-unorm": 54,
112-
"TextureFormat.bc7-rgba-unorm-srgb": 55,
98+
"TextureFormat.bc1-rgba-unorm": 44,
99+
"TextureFormat.bc1-rgba-unorm-srgb": 45,
100+
"TextureFormat.bc2-rgba-unorm": 46,
101+
"TextureFormat.bc2-rgba-unorm-srgb": 47,
102+
"TextureFormat.bc3-rgba-unorm": 48,
103+
"TextureFormat.bc3-rgba-unorm-srgb": 49,
104+
"TextureFormat.bc4-r-snorm": 51,
105+
"TextureFormat.bc4-r-unorm": 50,
106+
"TextureFormat.bc5-rg-snorm": 53,
107+
"TextureFormat.bc5-rg-unorm": 52,
108+
"TextureFormat.bc6h-rgb-float": 55,
109+
"TextureFormat.bc6h-rgb-ufloat": 54,
110+
"TextureFormat.bc7-rgba-unorm": 56,
111+
"TextureFormat.bc7-rgba-unorm-srgb": 57,
113112
"TextureFormat.bgra8unorm": 23,
114113
"TextureFormat.bgra8unorm-srgb": 24,
115114
"TextureFormat.depth16unorm": 38,
116115
"TextureFormat.depth24plus": 39,
117116
"TextureFormat.depth24plus-stencil8": 40,
118-
"TextureFormat.depth32float": 41,
117+
"TextureFormat.depth24unorm-stencil8": 41,
118+
"TextureFormat.depth32float": 42,
119+
"TextureFormat.depth32float-stencil8": 43,
119120
"TextureFormat.r16float": 7,
120121
"TextureFormat.r16sint": 6,
121122
"TextureFormat.r16uint": 5,

wgpu/resources/codegen_report.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
## Preparing
33
* The webgpu.idl defines 33 classes with 83 functions
44
* The webgpu.idl defines 5 flags, 31 enums, 54 structs
5-
* The wgpu.h defines 128 functions
6-
* The wgpu.h defines 5 flags, 43 enums, 67 structs
5+
* The wgpu.h defines 131 functions
6+
* The wgpu.h defines 5 flags, 46 enums, 69 structs
77
## Updating API
88
* Wrote 5 flags to flags.py
99
* Wrote 31 enums to enums.py
@@ -25,10 +25,9 @@
2525
* Validated 33 classes, 95 methods, 0 properties
2626
## Validating rs.py
2727
* Enum PredefinedColorSpace missing in wgpu.h
28-
* Enum field TextureFormat.depth24unorm-stencil8 missing in wgpu.h
29-
* Enum field TextureFormat.depth32float-stencil8 missing in wgpu.h
28+
* Enum field FeatureName.depth-clamping missing in wgpu.h
3029
* Enum CanvasCompositingAlphaMode missing in wgpu.h
31-
* Wrote 187 enum mappings and 47 struct-field mappings to rs_mappings.py
30+
* Wrote 188 enum mappings and 47 struct-field mappings to rs_mappings.py
3231
* Validated 79 C function calls
33-
* Not using 54 C functions
32+
* Not using 57 C functions
3433
* Validated 69 C structs

0 commit comments

Comments
 (0)