-
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
Passing extensible structures to application callbacks, backward-compatibly #272
Comments
Unfortunately WGPUCompilationInfo as written isn't trivial to switch: WGPUCompilationMessage structs are extensible, but can't be allocated ahead of time by the application (it doesn't know how many there will be).
|
Feb 29 meeting:
|
Here it is: // RequestAdapterInfo
typedef void (*WGPUAdapterRequestAdapterInfoCallback)(
// This would be allowed to contain any of the allowedSTypes, but not others
struct WGPUAdapterInfo const * adapterInfo,
WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT WGPUBool wgpuAdapterRequestAdapterInfo(WGPUAdapter adapter,
// Alternatively instead of WGPUSType this could be
// a new enum (allows finer granularity)
// or a bitmask (may run out of bits).
size_t allowedSTypeCount,
WGPUSType const * allowedSTypes,
WGPUAdapterRequestAdapterInfoCallback callback,
WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE;
// GetCompilationInfo
typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(
WGPUCompilationInfoRequestStatus status,
struct WGPUCompilationInfo const * compilationInfo,
WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(
WGPUShaderModule shaderModule,
// In this case, the list would contain the STypes allowed for both
// WGPUCompilationInfo AND WGPUCompilationMessage.
// (This is unambiguous because their valid STypes should be disjoint.)
size_t allowedSTypeCount,
WGPUSType const * allowedSTypes,
WGPUShaderModuleGetCompilationInfoCallback callback,
WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; (These are the only two existing entrypoints that would need this.) |
I guess another open question is whether we need extensibility in any of the others:
They are probably all safe to leave as is. |
I'm not sure that I understand why we make the application pass in the list of sTypes it knows how to handle. Aren't they going to iterate over the sType chain with a switch anyway? If we provided some simple "FindInChain" utilities, maybe it would be sufficient to assume there won't be breakage when new sTypes are returned by the implementation. It's just that the approach with a list of sTypes seems to be adding another mechanism on top of the extension mechanism, when the latter on its own could be sufficient. |
Fair point. I hadn't thought about the fact application code would be doing the iteration thing. If that's the case, then there's not much value in avoiding returning STypes they didn't ask for. On the other hand, I think we COULD guarantee that the chain you get will be exactly the STypes you allowed in exactly the same order, then you could write code that knows exactly how far to go in the chain like So probably let's go back to just making the application deal with whatever chain we give them. (We also don't have to be mega concerned with compatibility either, because it'll only break if you update your dawn/wgpu-native/emscripten dependency. I've worked in the Web spec for too long.) Providing FindInChain utilities would be nice, though not blocking. #278 |
Mar 7 meeting:
|
Which means no change is required. |
"needs docs" to tell people how to iterate the chain. |
Raised in #266: we want a backward-compatible way of passing extended data to application-defined callbacks. This comes up in two places:
If a webgpu.h implementation suddenly starts passing new extension structs to the application, it runs the risk of the application mishandling them.
For RequestAdapterInfo we decided that the WGPUAdapterInfo should be passed as an argument to RequestAdapterInfo so the application can set up the extension chain. Then we need a wgpuAdapterInfoFreeMembers (which replaces wgpuAdapterPropertiesFreeMembers proposed in #143 but which is becoming obsolete with #266).
The text was updated successfully, but these errors were encountered: