Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to wgpu-native 22.1 #547

Merged
merged 45 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ec811b7
update to latest idl
Vipitis Aug 4, 2024
2d02899
update headers
Vipitis Aug 4, 2024
eabef10
fix adapter properties
Vipitis Aug 4, 2024
18ee534
fix perferred format
Vipitis Aug 4, 2024
0b6f02d
remaining report
Vipitis Aug 4, 2024
0f3d294
fix error callback
Vipitis Aug 5, 2024
ee686c5
set default format
Vipitis Aug 5, 2024
a72ce93
cube progress
Vipitis Aug 6, 2024
5f10556
working cube and triangle
Vipitis Aug 8, 2024
57600f1
make ._release() part of end()
Vipitis Aug 10, 2024
299c29c
implement _get_surface_capabilities as private method
Vipitis Aug 10, 2024
afdfe42
update whitespaces and ids in expected errrors
Vipitis Aug 10, 2024
8e19cc5
surpress depth slice warning
Vipitis Aug 10, 2024
880bb0f
use tagged release
Vipitis Aug 29, 2024
734985d
handle device lost as error too
Vipitis Sep 1, 2024
b806471
lint
Vipitis Sep 1, 2024
e02c878
decode error type from message
Vipitis Sep 1, 2024
47b11f2
update to 22.1.0.2
Vipitis Sep 3, 2024
c5ec55d
Merge branch 'main' into wgpu22-1
almarklein Sep 4, 2024
ee8ec56
Merge branch 'main' into wgpu22-1
almarklein Sep 4, 2024
d9bf136
remove typo
almarklein Sep 4, 2024
e75c3ff
Yes, device must be passed to constructor, not self
almarklein Sep 4, 2024
b628c8f
device-lost
almarklein Sep 4, 2024
d6975c9
bind stuff to device, not adapter
almarklein Sep 5, 2024
4117b42
check errors
almarklein Sep 9, 2024
1bf48ec
allow rust to release adpater-info members
almarklein Sep 9, 2024
9f99b23
tone_mapping is a placeholder for now
almarklein Sep 9, 2024
dcd2cc8
cleanup
almarklein Sep 9, 2024
a226748
disable on_submitted_work_done, and add comments
almarklein Sep 9, 2024
c8511ed
todos, flake
almarklein Sep 9, 2024
1fd8b73
fix memtests
almarklein Sep 9, 2024
89fbde4
flake and clean
almarklein Sep 9, 2024
e59ec66
help pypy maybe
almarklein Sep 9, 2024
572c434
codegen
almarklein Sep 9, 2024
989db92
guard against null values
almarklein Sep 9, 2024
b49ba8e
revert storing pass encoders
almarklein Sep 9, 2024
ec93171
Merge branch 'wgpu22-1' of github.com:Vipitis/wgpu-py into wgpu22-1
almarklein Sep 9, 2024
4505f0b
refactor capabilities
almarklein Sep 9, 2024
7303636
fix
almarklein Sep 9, 2024
916047d
Fix that surfaces were not compatible
almarklein Sep 11, 2024
be1ceb2
Update how to handle capabilities of incompatible surfaces
almarklein Sep 11, 2024
a32db95
black/flake
almarklein Sep 11, 2024
af66a97
clean up
almarklein Sep 11, 2024
0434de7
codegen
almarklein Sep 11, 2024
dc44af9
Merge branch 'main' into wgpu22-1
almarklein Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions download-wgpu-native.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def get_arch():

def main(version, os_string, arch, upstream):
for build in ["release"]: # ["release", "debug"]
if os_string == "windows":
arch += "-msvc" # -gnu is also available.
filename = f"wgpu-{os_string}-{arch}-{build}.zip"
url = f"https://github.com/{upstream}/releases/download/v{version}/{filename}"
tmp = tempfile.gettempdir()
Expand Down
1 change: 0 additions & 1 deletion examples/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
render_texture_format = present_context.get_preferred_format(device.adapter)
present_context.configure(device=device, format=render_texture_format)


# %% Generate data

# pos texcoord
Expand Down
40 changes: 20 additions & 20 deletions tests/test_wgpu_native_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_parse_shader_error1(caplog):
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader '' parsing error: invalid field accessor `invalid_attr`
┌─ wgsl:9:9
Expand All @@ -38,7 +38,7 @@ def test_parse_shader_error1(caplog):
│ ^^^^^^^^^^^^ invalid accessor


invalid field accessor `invalid_attr`
invalid field accessor `invalid_attr`
"""

code = dedent(code)
Expand All @@ -65,7 +65,7 @@ def test_parse_shader_error2(caplog):
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader '' parsing error: expected ',', found ';'
┌─ wgsl:2:38
Expand All @@ -74,7 +74,7 @@ def test_parse_shader_error2(caplog):
│ ^ expected ','


expected ',', found ';'
expected ',', found ';'
"""

code = dedent(code)
Expand All @@ -101,7 +101,7 @@ def test_parse_shader_error3(caplog):
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader '' parsing error: unknown scalar type: 'f3'
┌─ wgsl:3:39
Expand All @@ -112,7 +112,7 @@ def test_parse_shader_error3(caplog):
= note: Valid scalar types are f32, f64, i32, u32, bool


unknown scalar type: 'f3'
unknown scalar type: 'f3'
"""

code = dedent(code)
Expand All @@ -139,12 +139,12 @@ def test_parse_shader_error4(caplog):
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader '' parsing error: Index 4 is out of bounds for expression [11]
Shader '' parsing error: Index 4 is out of bounds for expression [10]


Index 4 is out of bounds for expression [11]
Index 4 is out of bounds for expression [10]
"""

code = dedent(code)
Expand Down Expand Up @@ -175,24 +175,24 @@ def test_validate_shader_error1(caplog):
}
"""

expected1 = """Left: Load { pointer: [3] } of type Matrix { columns: Quad, rows: Quad, scalar: Scalar { kind: Float, width: 4 } }"""
expected2 = """Right: Load { pointer: [6] } of type Vector { size: Tri, scalar: Scalar { kind: Float, width: 4 } }"""
expected1 = """Left: Load { pointer: [2] } of type Matrix { columns: Quad, rows: Quad, scalar: Scalar { kind: Float, width: 4 } }"""
expected2 = """Right: Load { pointer: [5] } of type Vector { size: Tri, scalar: Scalar { kind: Float, width: 4 } }"""
expected3 = """
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader validation error:
┌─ :10:20
10 │ out.position = matrics * out.position;
│ ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [8]
│ ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [7]


Entry point vs_main at Vertex is invalid
Expression [8] is invalid
Operation Multiply can't work with [5] and [7]
Entry point vs_main at Vertex is invalid
Expression [7] is invalid
Operation Multiply can't work with [4] and [6]
"""

code = dedent(code)
Expand Down Expand Up @@ -231,17 +231,17 @@ def test_validate_shader_error2(caplog):
Validation Error

Caused by:
In wgpuDeviceCreateShaderModule
In wgpuDeviceCreateShaderModule

Shader validation error:
┌─ :9:16
9 │ return vec3<f32>(1.0, 0.0, 1.0);
│ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [9]
│ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [8]


Entry point fs_main at Vertex is invalid
The `return` value Some([9]) does not match the function return value
Entry point fs_main at Vertex is invalid
The `return` value Some([8]) does not match the function return value
"""

code = dedent(code)
Expand Down
8 changes: 1 addition & 7 deletions tests_mem/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_release_canvas_context(n):
"expected_counts_after_create": {
"CanvasContext": (n, 0),
},
"ignore": {"CommandBuffer"},
}

canvases = weakref.WeakSet()
Expand All @@ -80,13 +81,6 @@ def test_release_canvas_context(n):
# Check that the canvas objects are really deleted
assert not canvases

# This is a bit weird, but somehow this tests produces a dangling
# CommandBuffer for reasons likely related to the internals of
# wgpu-core. The lines below allocate and release a new
# CommandBuffer, which solves the issue :)
command_encoder = DEVICE.create_command_encoder()
command_encoder.finish()


TEST_FUNCS = [test_release_canvas_context]

Expand Down
8 changes: 3 additions & 5 deletions tests_mem/test_gui_glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_release_canvas_context(n):

from wgpu.gui.glfw import WgpuCanvas # noqa

yield {}
yield {
"ignore": {"CommandBuffer"},
}

canvases = weakref.WeakSet()

Expand All @@ -61,10 +63,6 @@ def test_release_canvas_context(n):
# Check that the canvas objects are really deleted
assert not canvases, f"Still {len(canvases)} canvases"

# Help clear dangling CommandBuffer, see test_gui.py
command_encoder = DEVICE.create_command_encoder()
command_encoder.finish()


if __name__ == "__main__":
# testutils.TEST_ITERS = 40 # Uncomment for a mem-usage test run
Expand Down
24 changes: 20 additions & 4 deletions tests_mem/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def test_release_command_buffer(n):
# Note: a command encoder can only be used once (it gets destroyed on finish())
yield {
"expected_counts_after_create": {
"CommandEncoder": (n, 0),
"CommandBuffer": (n, n),
},
}
Expand Down Expand Up @@ -144,7 +143,10 @@ def test_release_compute_pass_encoder(n):
}

for i in range(n):
yield command_encoder.begin_compute_pass()
pass_encoder = command_encoder.begin_compute_pass()
yield pass_encoder
pass_encoder.end()
del pass_encoder


@create_and_release
Expand Down Expand Up @@ -217,7 +219,6 @@ def test_release_render_bundle_encoder(n):
def test_release_render_bundle(n):
yield {
"expected_counts_after_create": {
"RenderBundleEncoder": (n, 0),
"RenderBundle": (n, n),
},
}
Expand All @@ -230,7 +231,19 @@ def test_release_render_bundle(n):
def test_release_render_pass_encoder(n):
# Note: RenderPassEncoder does not really exist in wgpu-core
# -> Check gpu.diagnostics.wgpu_native_counts.print_report(), nothing there that ends with "Encoder".
# Also, release() is called in end() - not sure if this will be forever.

command_encoder = DEVICE.create_command_encoder()
texture_view = DEVICE.create_texture(
size=(16, 16, 1),
usage=wgpu.TextureUsage.RENDER_ATTACHMENT,
format="rgba8unorm",
).create_view()
ca = {
"view": texture_view,
"load_op": wgpu.LoadOp.load,
"store_op": wgpu.StoreOp.store,
}

yield {
"expected_counts_after_create": {
Expand All @@ -239,7 +252,10 @@ def test_release_render_pass_encoder(n):
}

for i in range(n):
yield command_encoder.begin_render_pass(color_attachments=[])
pass_encoder = command_encoder.begin_render_pass(color_attachments=[ca])
yield pass_encoder
pass_encoder.end()
del pass_encoder


@create_and_release
Expand Down
12 changes: 7 additions & 5 deletions tests_mem/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ def get_counts():
counts_native.get(key, default)["count"],
)
counts.pop("total")

return counts


def get_excess_counts(counts1, counts2):
def get_excess_counts(counts1, counts2, ignore=()):
"""Compare two counts dicts, and return a new dict with the fields
that have increased counts.
"""
Expand All @@ -126,6 +125,8 @@ def get_excess_counts(counts1, counts2):
more_native = c2 - c1
if more_py or more_native:
more[name] = more_py, more_native
for key in ignore:
more.pop(key, None)
return more


Expand Down Expand Up @@ -167,6 +168,7 @@ def core_test_func():
options = {
"expected_counts_after_create": {ob_name: (n_objects, n_objects)},
"expected_counts_after_release": {},
"ignore": (),
}

func_options = next(generator)
Expand Down Expand Up @@ -198,15 +200,15 @@ def core_test_func():

# Measure peak object counts
counts2 = get_counts()
more2 = get_excess_counts(counts1, counts2)
more2 = get_excess_counts(counts1, counts2, options["ignore"])
if not TEST_ITERS:
print(" more after create:", more2)

# Make sure the actual object has increased
assert more2 # not empty
assert (
more2 == options["expected_counts_after_create"]
), f"Exepected:\n{options['expected_counts_after_create']}\nGot:\n{more2}"
), f"Expected:\n{options['expected_counts_after_create']}\nGot:\n{more2}"

# It's ok if other objects are created too ...

Expand All @@ -218,7 +220,7 @@ def core_test_func():

# Measure after-release object counts
counts3 = get_counts()
more3 = get_excess_counts(counts1, counts3)
more3 = get_excess_counts(counts1, counts3, options["ignore"])
if not TEST_ITERS:
print(" more after release:", more3)

Expand Down
10 changes: 6 additions & 4 deletions wgpu/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def configure(
usage: "flags.TextureUsage" = 0x10,
view_formats: "List[enums.TextureFormat]" = [],
color_space: str = "srgb",
tone_mapping: "structs.CanvasToneMapping" = {},
alpha_mode: "enums.CanvasAlphaMode" = "opaque",
):
"""Configures the presentation context for the associated canvas.
Expand All @@ -222,7 +223,8 @@ def configure(
color_space (PredefinedColorSpace): The color space that values written
into textures returned by ``get_current_texture()`` should be displayed with.
Default "srgb".
alpha_mode (enums.CanvasAlphaMode): Determines the effect that alpha values
tone_mapping (enums.CanvasToneMappingMode): Not yet supported.
alpha_mode (structs.CanvasAlphaMode): Determines the effect that alpha values
will have on the content of textures returned by ``get_current_texture()``
when read, displayed, or used as an image source. Default "opaque".
"""
Expand Down Expand Up @@ -380,16 +382,16 @@ def is_fallback_adapter(self):
# IDL: [SameObject] readonly attribute GPUAdapterInfo info;
@property
def info(self):
"""A dict with information about this adapter, such as the vendor and devicen name."""
"""A dict with information about this adapter, such as the vendor and device name."""
# Note: returns a dict rather than an GPUAdapterInfo instance.
return self._adapter_info

@apidiff.add("Useful in multi-gpu environments")
@property
def summary(self):
"""A one-line summary of the info of this adapter (name, adapter_type, backend_type)."""
"""A one-line summary of the info of this adapter (description, adapter_type, backend_type)."""
d = self._adapter_info
return f"{d['device']} ({d['adapter_type']}) via {d['backend_type']}"
return f"{d['description']} ({d['adapter_type']}) via {d['backend_type']}"
almarklein marked this conversation as resolved.
Show resolved Hide resolved


class GPUObjectBase:
Expand Down
4 changes: 2 additions & 2 deletions wgpu/backends/wgpu_native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


# The wgpu-native version that we target/expect
__version__ = "0.19.4.1"
__commit_sha__ = "d89e5a93f5fd0bb3ce28f09571dbbefea37712c9"
__version__ = "22.1.0.2"
__commit_sha__ = "3e18e3d3e5fd433053875464447c36d980625f0b"
version_info = tuple(map(int, __version__.split(".")))
_check_expected_version(version_info) # produces a warning on mismatch

Expand Down
Loading