-
Notifications
You must be signed in to change notification settings - Fork 53
Description
CompilationInfo is a little unique because it's one of the only places in the API that a structure of data is being returned out of the API. AdapterProperties seems to be the only close analog, but because CompilationInfo is queried with a promise in the JS API it would need to be supplied by a callback here.
So a first stab at this would suggest we'd want an API surface like that following?
typedef enum WGPUCompilationMessageType {
WGPUCompilationMessageType_Undefined = 0x00000000,
WGPUCompilationMessageType_Error = 0x00000001,
WGPUCompilationMessageType_Warning = 0x00000002,
WGPUCompilationMessageType_Info = 0x00000003,
} WGPUCompilationMessageType;
typedef struct WGPUCompilationMessage {
WGPUChainedStruct const * nextInChain; // Are these extensible?
char const * message;
WGPUCompilationMessageType type;
uint64_t lineNum;
uint64_t linePos;
} WGPUCompilationMessage;
typedef struct WGPUCompilationInfo {
WGPUChainedStruct const * nextInChain; // Are these extensible?
WGPUCompilationMessage * messages;
uint32_t messageCount;
} WGPUCompilationInfo ;
typedef void (*WGPUCompilationInfoCallback )(WGPUCompilationInfo* compilationInfo, void * userdata);
WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata);
Or, recognizing that WGPUCompilationInfo is just a list of messages, if we weren't worried about extensibility of that particular structure the callback signature could simply be:
typedef void (*WGPUCompilationInfoCallback )(WGPUCompilationMessage* messages, uint32_t messageCount, void * userdata);
I'm also not sure what sort of guarantees the library gives about lifetime of objects like this, if it's expected that it would only be valid for the duration of the callback or if the library would be expected to keep it alive and owned by the shader module after being queried.