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

Upgrade to latest webgpu headers #445

Open
wants to merge 31 commits into
base: trunk
Choose a base branch
from

Conversation

eliemichel
Copy link
Contributor

This builds on top of #441 (which upgrades wgpu-core to v23.0.0), as well as the commits added to #427 after it was forked.

  • Only minor compatibility changes were needed to upgrade to latest webgpu.h (@PJB3005 did all the heavy work, thanks!).
  • The list in unimplemented.rs needs to be double checked.
  • I've upgraded the examples, but did not intensively tested it in other contexts.

PJB3005 and others added 30 commits September 19, 2024 17:53
This goes up to webgpu-native/webgpu-headers@2b59747

Things I *didn't* do:

* I didn't update the library to make sure "instance dropped" callback
  error codes are guaranteed to happen, like they seem to be in Dawn.

List of changes (roughly in order of header commits):

Various enum and struct renames

Updated callbacks to use the new *CallbackInfo structs and 2-userdata system. Also updated functions to return WGPUFuture, though the WGPUFuture thing is just stubbed out at the moment as I don't think wgpu-core has the necessary functionality for it. wgpuInstanceWaitAny is unimplemented!()

DepthClipControl merged into PrimitiveState, related code simplified.

Updated depthWriteEnabled to use an optional bool, mostly matters due to added validation.

Add TODOs for missing features (sliced 3D compressed textures)

*Reference() became *AddRef()

Added unorm10-10-10-2 vertex format

Usage field in TextureViewDescriptor, just used for validation as wgpu-core doesn't allow specifying it anyways.

Removed maxInterStageShaderComponents

Added clang_macro_fallback to bindgen config, since the headers switched to using UINT32_MAX etc. UINT64_MAX still doesn't work so I had to manually define those.

Renamed flags enums. Added a conversion helper function to convert them from u64 -> u32 for mapping. (means added direct dependency on bitflags crate)

Removed device argument from (unimplemented) wgpuGetProcAddress

Suboptimal surface texture acquisition moved to enum return value, was easy since wgpu-core already returns it like that.

"Undefined" present mode added, it just selects FIFO.
This enum was replaced with WGPUMapAsyncStatus, but I didn't quite notice. The error codes map different.
Replaces *EnumerateFeatures with *GetFeatures.

Also fixes CI due to fix in headers.
Upstream removed the "Flags" suffix from flags types and moved them to no longer be C enums. This matches that change. WGPUInstanceFlag still has "Flag" in the name because, well, there'd be nothing left to distinguish it from WGPUInstance, and it makes sense for it.
Also updates wgpu.h to use WGPUStringView everywhere.
All stubs, since we don't have WaitAny at the moment.
Update to webgpu-native/webgpu-headers@f1cdc3f

Also went through a bunch of existing enum conversions and fixed up some seemingly spec-incorrect cases of undefined enums not being handled properly.

As part of this, I made a new helper map_enum_with_undefined!() which distinguishes undefined and unknown enum values. Previously, much code relied on undefined being caught in the same net as an unknown value. This is no longer the case.
This updates the headers to webgpu-native/webgpu-headers@af63d34

These changes are exclusively in the header enum values, so no Rust code needs changing. Making this a separate commit for easier review.
Update headers to webgpu-native/webgpu-headers@b7656d0

Adds dual source blending. Other two features (float32 blendable and clip distances feature in wgsl) are not supported by wgpu.

Also made map_blend_factor use the shorter macro form, as all the enum names match (they didn't 3 years ago when this code was originally written, according to Git history).
Oops that's not how these chained structs work.
Updates headers to webgpu-native/webgpu-headers@6f549cc

Also made matching changes to wgpu.h
@eliemichel
Copy link
Contributor Author

Build available in this release: v23.0.0-beta @ eliemichel/wgpu-native

@ygdrasil-io
Copy link
Contributor

@eliemichel should we test with the latest release or stick with the beta ?

@ygdrasil-io
Copy link
Contributor

@eliemichel your v23.0.0-gamma, the triangle sample work fine on desktop Mac arm64.
Untested yet on iOs.

On Android the sample crash with :

2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  Logging hang event. Number of tasks already hung: 0
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  Metadata:
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 file: device/generic/goldfish-opengl/system/vulkan_enc/VkEncoder.cpp
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 function: vkCreateGraphicsPipelines
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 line: 8005
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 msg: vkCreateGraphicsPipelines in VkEncoder
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 thread: 6340 (0x000018c4)
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 process name: io.ygdrasil.wgpu.debug
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 Additional information:
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 	 seqno: 84
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 	 packetSize: 624
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  	 	 packetContents:  61 4E 00 00 70 02 00 00 54 00 00 00 02 00 00 00 02 00 03 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 01 00 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 20 00 00 00 02 00 0A 00 00 00 00 04 6D 61 69 6E 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 21 00 00 00 02 00 0A 00 00 00 00 04 6D 61 69 6E 00 00 00 00 00 00 00 00 B4 00 00 7A 6E EF 1A 38 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B4 00 00 7A 6E EF 1A 68 14 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B4 00 00 7A 6E EF 1A 88 16 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 B4 00 00 7A 6E EF 1A B8 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3F B4 00 00 7A 6E EF 1A F8 18 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 
2024-12-20 12:06:54.820  6340-6368  androidemu              io.ygdrasil.wgpu.debug               E  HealthMonitor: Number of unresponsive tasks increased: 0 -> 1

if I switch to OpenGL :

2024-12-20 11:50:21.206  3241-3241  BufferQueueProducer     io.ygdrasil.wgpu.debug               E  [SurfaceView[io.ygdrasil.wgpu.debug/io.ygdrasil.wgpu.MainActivity]#1(BLAST Consumer)1](id:ca900000001,api:1,p:3241,c:3241) connect: already connected (cur=1 req=1)
2024-12-20 11:50:21.206  3241-3241  libEGL                  io.ygdrasil.wgpu.debug               E  eglCreateWindowSurface: native_window_api_connect (win=0xb400007a5eeff0a0) failed (0xffffffea) (already connected to another API?)
2024-12-20 11:50:21.206  3241-3241  libEGL                  io.ygdrasil.wgpu.debug               E  eglCreateWindowSurfaceTmpl:689 error 3003 (EGL_BAD_ALLOC)

I did not change the android code since the last version, only the binding.
I will dig if the issues come from my code or wgpu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants