-
Notifications
You must be signed in to change notification settings - Fork 45
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
wgpuAdapterGetProperties is sync but requestAdapterInfo is async #266
Comments
Would it make sense to replace |
Seems sensible? At least in C it doesn't seem super necessary to keep the retrieval of info async. |
Seems like this is something emscripten layer would have to workaround, because in the native it doesn't make sense to make it async, info callbacks can be especially annoying when enumerating adapters.
not sure how to avoid that |
That's the idea of "Somehow include in the wgpuInstanceRequestAdapter call whether you want to retrieve the properties or not": if you don't ask for it in RequestAdapterOptions, then we don't need to add the extra delay or the extra data access. I think that's a pretty good option. Maybe it would look something like a new field in RequestAdapterOptions that's a bitfield with just 1 bit so far (0 = don't requestAdapterInfo(), 1 = do requestAdapterInfo()). Later on we might have extra bits to ask for more info. |
Feb 1 meeting:
|
Out of curiosity, what are the next steps? |
Add WGPUAdapterRequestAdapterInfo to the C API (on our side, implement in Dawn) matching the usual patterns for async things. It will use futures, but we could have a stopgap version without futures if we really need one. |
Thanks! Here's #269 |
Hm, I forgot we also wanted to remove wgpuAdapterGetProperties. |
Adding agenda label, but I'd like to get a proposal written down (from someone) before we discuss it. |
(oops reposted old minutes) |
Feb 15 meeting:
|
It is also a problem for GetCompilationInfo, which is more complicated because both WGPUCompilationInfo and WGPUCompilationMessage are extensible. Filed #272 |
The API that I think we came to for AdapterInfo - I took some liberties in filling in details, in particular moving backendType and adapterType to the core struct because it's sometimes possible to populate them in Wasm. typedef struct WGPUAdapterInfo {
WGPUChainedStructOut * nextInChain;
char const * vendor;
char const * architecture;
char const * device;
char const * description;
// Wasm can always tell you this, it's WGPUBackendType_WebGPU
WGPUBackendType backendType;
// Wasm may occasionally know this (e.g. if forceFallbackAdapter=true). Otherwise Unknown.
WGPUAdapterType adapterType;
} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE;
// Chains off WGPUAdapterInfo
typedef struct WGPUAdapterInfoVendorDeviceID {
WGPUChainedStruct chain;
uint32_t vendorID;
uint32_t deviceID;
} WGPUAdapterInfoNative WGPU_STRUCTURE_ATTRIBUTE; WGPUAdapterInfoVendorDeviceID's SType would be in the 0x0001_xxxx range: #214 (comment) EDIT: had a wrong signature. removed it, posted correct one below. |
(Unfortunately this doesn't make CompilationInfo in #272 any easier) |
The proposal above looks good, and in native/wire I believe the |
Oh yes, right, I copied yours with the bool and deleted the wrong one. (Later will become a WGPUStatus or whatever) |
Feb 29 meeting:
|
(comment moved to #272 (comment)) |
Posted a different proposal on #272 (comment). |
A few more thoughts for now.
|
Mar 7 meeting:
|
Out of curiosity, how would you fix the JS API? |
I haven't gotten around to opening a proposal yet but the gist is add the adapter info as adapter.adapterInfo or adapter.getAdapterInfo(). If there's a way to get adapter info without a prompt, then IMO there's no reason it needs to be async. We don't need async in order to dynamically decide what to expose / measure what we've exposed; properties on GPUAdapterInfo are already getters. |
Mar 28 meeting:
|
(And we can always do the requestAdapterInfo-in-wgpuInstanceRequestAdapter trick regardless of whether it is.) Actual design depended on #279, but that's resolved now too, so we need a proposal. Most likely we just make it look like GetProperties but restructure as needed. |
I think we reuse the structs and FreeMembers definitions proposed above, and the getter is simply as Corentin wrote it: typedef struct WGPUAdapterInfo {
WGPUChainedStructOut * nextInChain;
char const * vendor;
char const * architecture;
char const * device;
char const * description;
// Wasm can always tell you this, it's WGPUBackendType_WebGPU
WGPUBackendType backendType;
// Wasm may occasionally know this (e.g. if forceFallbackAdapter=true). Otherwise Unknown.
WGPUAdapterType adapterType;
} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE;
// Chains off WGPUAdapterInfo
typedef struct WGPUAdapterInfoVendorDeviceID {
WGPUChainedStruct chain;
uint32_t vendorID;
uint32_t deviceID;
} WGPUAdapterInfoVendorDeviceID WGPU_STRUCTURE_ATTRIBUTE;
WGPU_EXPORT wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUStatus wgpuAdapterGetInfo(WGPUAdapter adapter,
WGPUAdapterInfo *info) WGPU_FUNCTION_ATTRIBUTE; or "GetAdapterInfo". I've proposed |
typedef struct WGPUAdapterInfo {
WGPUChainedStructOut * nextInChain;
char const * vendor;
char const * architecture;
char const * device;
char const * description;
// Wasm can always tell you this, it's WGPUBackendType_WebGPU
WGPUBackendType backendType;
// Wasm may occasionally know this (e.g. if forceFallbackAdapter=true). Otherwise Unknown.
WGPUAdapterType adapterType;
// Vendor/device ID are zero if you can't get them (like on Wasm)
uint32_t vendorID;
uint32_t deviceID;
} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE;
WGPU_EXPORT wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUStatus wgpuAdapterGetInfo(WGPUAdapter adapter,
WGPUAdapterInfo *info) WGPU_FUNCTION_ATTRIBUTE; |
Apr 11 meeting:
|
Shall we close this issue? |
Yes, I think so. Thanks! |
Oops (#304), we forgot to remove WGPUAdapterProperties/wgpuAdapterGetProperties along with that. The new wgpuAdapterGetInfo replaces both wgpuAdapterRequestAdapterInfo and wgpuAdapterGetProperties (that's why we added the vendor/device ID to the struct). |
Originally posted by @beaufortfrancois in emscripten-core/emscripten#21072 (comment)
Originally posted by @kainino0x in emscripten-core/emscripten#21072 (comment)
The text was updated successfully, but these errors were encountered: