diff --git a/fix/main.go b/fix/main.go index 2933ac1..0045e5a 100644 --- a/fix/main.go +++ b/fix/main.go @@ -16,7 +16,7 @@ func main() { flag.StringVar(&yamlPath, "yaml", "", "path of the yaml spec") flag.Parse() - arrays := []string{"constants", "typedefs", "enums", "bitflags", "function_types", "structs", "functions", "objects"} + arrays := []string{"constants", "typedefs", "enums", "bitflags", "structs", "callbacks", "functions", "objects"} for _, array := range arrays { SortArrayByFieldInPlace(array, "name") } diff --git a/gen/cheader.tmpl b/gen/cheader.tmpl index 033dcd0..2b7c09c 100644 --- a/gen/cheader.tmpl +++ b/gen/cheader.tmpl @@ -124,6 +124,13 @@ struct WGPU{{.Name | PascalCase}}{{$.ExtSuffix}}; {{- end}} {{ end}} +{{- if .Callbacks}} +// Callback info structure forward declarations +{{- range .Callbacks}} +struct WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}}; +{{- end}} +{{ end}} + /** * \defgroup Enumerations * \brief Enums. @@ -181,11 +188,6 @@ typedef WGPUFlags WGPU{{$bitflag.Name | PascalCase}}Flags{{$.ExtSuffix}} WGPU_EN typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; {{ end}} -{{- range .FunctionTypes}} -{{- MComment .Doc 0}} -typedef {{FunctionReturns .}} (*WGPU{{.Name | PascalCase}}{{$.ExtSuffix}})({{FunctionArgs . nil}}) WGPU_FUNCTION_ATTRIBUTE; -{{- end}} - /** * \defgroup Callbacks * \brief Callbacks through which asynchronous functions return. @@ -193,16 +195,10 @@ typedef {{FunctionReturns .}} (*WGPU{{.Name | PascalCase}}{{$.ExtSuffix}})({{Fun * @{ */ -{{- if .Objects}} -{{ range $object := .Objects}} -{{- range $method := .Methods}} -{{- if .ReturnsAsync}} -{{- MComment .Doc 0}} -typedef void (*WGPU{{$object.Name | PascalCase}}{{$method.Name | PascalCase}}Callback{{$.ExtSuffix}})({{CallbackArgs .}}) WGPU_FUNCTION_ATTRIBUTE; -{{- end}} -{{- end}} -{{- end}} -{{ end}} +{{- range .Callbacks}} +{{- MComment .Doc 0}} +typedef void (*WGPU{{.Name | PascalCase}}Callback{{$.ExtSuffix}})({{CallbackArgs .}}) WGPU_FUNCTION_ATTRIBUTE; +{{- end}} /** @} */ @@ -234,6 +230,29 @@ typedef struct WGPUChainedStructOut { * @{ */ + /** + * \defgroup WGPUCallbackInfo + * \brief Callback info structures that are used in asynchronous functions. + * + * @{ + */ + +{{- range .Callbacks}} +{{- MComment .Doc 0}} +typedef struct WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}} { + WGPUChainedStruct const * nextInChain; +{{- if eq .Style "callback_mode" }} + WGPUCallbackMode mode; +{{- end}} + WGPU{{.Name | PascalCase}}Callback{{$.ExtSuffix}} callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}} WGPU_STRUCTURE_ATTRIBUTE; +{{ end}}{{"\n" -}} + + /** @} */ + +{{- "\n"}} {{- range $struct := .Structs}} {{- MComment .Doc 0}} typedef struct WGPU{{.Name | PascalCase}}{{$.ExtSuffix}} { diff --git a/gen/gen.go b/gen/gen.go index d4360a3..672a58e 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -58,6 +58,9 @@ func (g *Generator) Gen(dst io.Writer) error { "Singularize": Singularize, "IsLast": func(i int, s any) bool { return i == reflect.ValueOf(s).Len()-1 }, "FunctionReturns": func(f Function) string { + if f.Callback != nil { + return "WGPUFuture" + } if f.Returns != nil { return g.CType(f.Returns.Type, f.Returns.Pointer, "") } @@ -162,6 +165,9 @@ func (g *Generator) CType(typ string, pointerType PointerType, suffix string) st case strings.HasPrefix(typ, "function_type."): ctype := "WGPU" + PascalCase(strings.TrimPrefix(typ, "function_type.")) + suffix return appendModifiers(ctype, pointerType) + case strings.HasPrefix(typ, "callback."): + ctype := "WGPU" + PascalCase(strings.TrimPrefix(typ, "callback.")) + "Callback" + suffix + return appendModifiers(ctype, pointerType) case strings.HasPrefix(typ, "object."): ctype := "WGPU" + PascalCase(strings.TrimPrefix(typ, "object.")) + suffix return appendModifiers(ctype, pointerType) @@ -206,21 +212,15 @@ func (g *Generator) FunctionArgs(f Function, o *Object) string { sb.WriteString(", ") } } - if len(f.ReturnsAsync) > 0 { - var name string - if o != nil { - name = PascalCase(o.Name) + PascalCase(f.Name) - } else { - name = PascalCase(f.Name) - } - fmt.Fprintf(sb, ", WGPU%sCallback callback, WGPU_NULLABLE void * userdata", name) + if f.Callback != nil { + fmt.Fprintf(sb, ", %s callbackInfo", g.CType(*f.Callback, "", "Info")) } return sb.String() } -func (g *Generator) CallbackArgs(f Function) string { +func (g *Generator) CallbackArgs(f Callback) string { sb := &strings.Builder{} - for _, arg := range f.ReturnsAsync { + for _, arg := range f.Args { if arg.Optional { sb.WriteString("WGPU_NULLABLE ") } @@ -242,7 +242,7 @@ func (g *Generator) CallbackArgs(f Function) string { fmt.Fprintf(sb, "%s%s %s, ", structPrefix, g.CType(arg.Type, arg.Pointer, typeSuffix), CamelCase(arg.Name)) } } - sb.WriteString("WGPU_NULLABLE void * userdata") + sb.WriteString("WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2") return sb.String() } @@ -324,7 +324,11 @@ func (g *Generator) StructMember(s Struct, memberIndex int) (string, error) { fmt.Fprintf(sb, "size_t %sCount;\n", CamelCase(Singularize(member.Name))) fmt.Fprintf(sb, " %s %s;", g.CType(matches[1], member.Pointer, typeSuffix), CamelCase(member.Name)) } else { - fmt.Fprintf(sb, "%s %s;", g.CType(member.Type, member.Pointer, typeSuffix), CamelCase(member.Name)) + if strings.HasPrefix(member.Type, "callback.") { + fmt.Fprintf(sb, "%s %s;", g.CType(member.Type, "", "Info"), CamelCase(member.Name)) + } else { + fmt.Fprintf(sb, "%s %s;", g.CType(member.Type, member.Pointer, typeSuffix), CamelCase(member.Name)) + } } return sb.String(), nil } diff --git a/gen/validator.go b/gen/validator.go index 6657be0..f453524 100644 --- a/gen/validator.go +++ b/gen/validator.go @@ -42,8 +42,8 @@ func mergeAndValidateDuplicates(yamlPaths []string) (errs error) { constants := make(map[string]Constant) enums := make(map[string]Enum) bitflags := make(map[string]Bitflag) - functionTypes := make(map[string]Function) structs := make(map[string]Struct) + callbacks := make(map[string]Callback) functions := make(map[string]Function) objects := make(map[string]Object) @@ -99,11 +99,11 @@ func mergeAndValidateDuplicates(yamlPaths []string) (errs error) { bitflags[bf.Name] = bf } } - for _, ft := range data.FunctionTypes { - if _, ok := functionTypes[ft.Name]; ok { - errs = errors.Join(errs, fmt.Errorf("merge: function_types.%s in %s was already found previously while parsing, duplicates are not allowed", ft.Name, yamlPath)) + for _, c := range data.Callbacks { + if _, ok := callbacks[c.Name]; ok { + errs = errors.Join(errs, fmt.Errorf("merge: callbacks.%s in %s was already found previously while parsing, duplicates are not allowed", c.Name, yamlPath)) } - functionTypes[ft.Name] = ft + callbacks[c.Name] = c } for _, s := range data.Structs { if _, ok := structs[s.Name]; ok { diff --git a/gen/yml.go b/gen/yml.go index 45ee979..d466515 100644 --- a/gen/yml.go +++ b/gen/yml.go @@ -16,8 +16,8 @@ type Yml struct { Typedefs []Typedef `yaml:"typedefs"` Enums []Enum `yaml:"enums"` Bitflags []Bitflag `yaml:"bitflags"` - FunctionTypes []Function `yaml:"function_types"` Structs []Struct `yaml:"structs"` + Callbacks []Callback `yaml:"callbacks"` Functions []Function `yaml:"functions"` Objects []Object `yaml:"objects"` } @@ -75,11 +75,18 @@ type ParameterType struct { Namespace string `yaml:"namespace"` } +type Callback struct { + Name string `yaml:"name"` + Doc string `yaml:"doc"` + Style string `yaml:"type"` + Args []ParameterType `yaml:"args"` +} + type Function struct { Name string `yaml:"name"` Doc string `yaml:"doc"` - ReturnsAsync []ParameterType `yaml:"returns_async"` Returns *ParameterType `yaml:"returns"` + Callback *string `yaml:"callback"` Args []ParameterType `yaml:"args"` } diff --git a/schema.json b/schema.json index 5ccfd1b..97cb23e 100644 --- a/schema.json +++ b/schema.json @@ -58,6 +58,10 @@ "type": "string", "pattern": "^(array<)?(typedef\\.|enum\\.|bitflag\\.|struct\\.|function_type\\.|object\\.)([a-zA-Z0-9]([a-zA-Z0-9_]*[a-zA-Z0-9])?)(>)?$" }, + "CallbackType": { + "type": "string", + "pattern": "^(callback\\.)([a-zA-Z0-9]([a-zA-Z0-9_]*[a-zA-Z0-9])?)$" + }, "Type": { "oneOf": [ { @@ -65,6 +69,9 @@ }, { "$ref": "#/definitions/ComplexType" + }, + { + "$ref": "#/definitions/CallbackType" } ] }, @@ -75,6 +82,41 @@ "mutable" ] }, + "CallbackStyle": { + "type": "string", + "enum": [ + "callback_mode", + "immediate" + ] + }, + "Callback": { + "type": "object", + "properties": { + "name": { + "$ref": "#/definitions/Name", + "description": "Callback name" + }, + "doc": { + "type": "string" + }, + "style": { + "$ref": "#/definitions/CallbackStyle", + "description": "Callback style" + }, + "args": { + "type": "array", + "description": "Optional property, list of callback arguments", + "items": { + "$ref": "#/definitions/ParameterType" + } + } + }, + "required": [ + "name", + "doc", + "style" + ] + }, "ParameterType": { "type": "object", "properties": { @@ -140,12 +182,9 @@ "type" ] }, - "returns_async": { - "type": "array", - "description": "Optional property, list of async callback arguments", - "items": { - "$ref": "#/definitions/ParameterType" - } + "callback": { + "$ref": "#/definitions/CallbackType", + "description": "Optional property, callback type for async functon" }, "args": { "type": "array", @@ -321,12 +360,6 @@ ] } }, - "function_types": { - "type": "array", - "items": { - "$ref": "#/definitions/Function" - } - }, "structs": { "type": "array", "items": { @@ -376,6 +409,12 @@ ] } }, + "callbacks": { + "type": "array", + "items": { + "$ref": "#/definitions/Callback" + } + }, "functions": { "type": "array", "items": { @@ -421,7 +460,7 @@ "typedefs", "enums", "bitflags", - "function_types", + "callbacks", "structs", "functions", "objects" diff --git a/webgpu.h b/webgpu.h index bdf1035..20cc8c9 100644 --- a/webgpu.h +++ b/webgpu.h @@ -131,6 +131,7 @@ struct WGPUCompilationMessage; struct WGPUComputePassTimestampWrites; struct WGPUConstantEntry; struct WGPUExtent3D; +struct WGPUFuture; struct WGPUInstanceDescriptor; struct WGPULimits; struct WGPUMultisampleState; @@ -167,7 +168,6 @@ struct WGPUSurfaceTexture; struct WGPUTextureBindingLayout; struct WGPUTextureDataLayout; struct WGPUTextureViewDescriptor; -struct WGPUUncapturedErrorCallbackInfo; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; struct WGPUBindGroupLayoutEntry; @@ -193,6 +193,18 @@ struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; +// Callback info structure forward declarations +struct WGPUBufferMapCallbackInfo; +struct WGPUCompilationInfoCallbackInfo; +struct WGPUCreateComputePipelineAsyncCallbackInfo; +struct WGPUCreateRenderPipelineAsyncCallbackInfo; +struct WGPUDeviceLostCallbackInfo; +struct WGPUPopErrorScopeCallbackInfo; +struct WGPUQueueWorkDoneCallbackInfo; +struct WGPURequestAdapterCallbackInfo; +struct WGPURequestDeviceCallbackInfo; +struct WGPUUncapturedErrorCallbackInfo; + /** * \defgroup Enumerations @@ -282,6 +294,13 @@ typedef enum WGPUBufferMapState { WGPUBufferMapState_Force32 = 0x7FFFFFFF } WGPUBufferMapState WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUCallbackMode { + WGPUCallbackMode_WaitAnyOnly = 0x00000001, + WGPUCallbackMode_AllowProcessEvents = 0x00000002, + WGPUCallbackMode_AllowSpontaneous = 0x00000003, + WGPUCallbackMode_Force32 = 0x7FFFFFFF +} WGPUCallbackMode WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUCompareFunction { WGPUCompareFunction_Undefined = 0x00000000, WGPUCompareFunction_Never = 0x00000001, @@ -296,10 +315,11 @@ typedef enum WGPUCompareFunction { } WGPUCompareFunction WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationInfoRequestStatus { - WGPUCompilationInfoRequestStatus_Success = 0x00000000, - WGPUCompilationInfoRequestStatus_Error = 0x00000001, - WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, + WGPUCompilationInfoRequestStatus_Success = 0x00000001, + WGPUCompilationInfoRequestStatus_InstanceDropped = 0x00000002, + WGPUCompilationInfoRequestStatus_Error = 0x00000003, + WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000004, + WGPUCompilationInfoRequestStatus_Unknown = 0x00000005, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF } WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; @@ -320,12 +340,13 @@ typedef enum WGPUCompositeAlphaMode { } WGPUCompositeAlphaMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCreatePipelineAsyncStatus { - WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, - WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, - WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, + WGPUCreatePipelineAsyncStatus_Success = 0x00000001, + WGPUCreatePipelineAsyncStatus_InstanceDropped = 0x00000002, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, + WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000005, + WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000006, + WGPUCreatePipelineAsyncStatus_Unknown = 0x00000007, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF } WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; @@ -339,6 +360,8 @@ typedef enum WGPUCullMode { typedef enum WGPUDeviceLostReason { WGPUDeviceLostReason_Unknown = 0x00000001, WGPUDeviceLostReason_Destroyed = 0x00000002, + WGPUDeviceLostReason_InstanceDropped = 0x00000003, + WGPUDeviceLostReason_FailedCreation = 0x00000004, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; @@ -401,12 +424,27 @@ typedef enum WGPULoadOp { WGPULoadOp_Force32 = 0x7FFFFFFF } WGPULoadOp WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUMapAsyncStatus { + WGPUMapAsyncStatus_Success = 0x00000001, + WGPUMapAsyncStatus_InstanceDropped = 0x00000002, + WGPUMapAsyncStatus_Error = 0x00000003, + WGPUMapAsyncStatus_Aborted = 0x00000004, + WGPUMapAsyncStatus_Unknown = 0x00000005, + WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUMipmapFilterMode { WGPUMipmapFilterMode_Nearest = 0x00000000, WGPUMipmapFilterMode_Linear = 0x00000001, WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF } WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUPopErrorScopeStatus { + WGPUPopErrorScopeStatus_Success = 0x00000001, + WGPUPopErrorScopeStatus_InstanceDropped = 0x00000002, + WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF +} WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUPowerPreference { WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, @@ -438,25 +476,28 @@ typedef enum WGPUQueryType { } WGPUQueryType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueueWorkDoneStatus { - WGPUQueueWorkDoneStatus_Success = 0x00000000, - WGPUQueueWorkDoneStatus_Error = 0x00000001, - WGPUQueueWorkDoneStatus_Unknown = 0x00000002, - WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, + WGPUQueueWorkDoneStatus_Success = 0x00000001, + WGPUQueueWorkDoneStatus_InstanceDropped = 0x00000002, + WGPUQueueWorkDoneStatus_Error = 0x00000003, + WGPUQueueWorkDoneStatus_Unknown = 0x00000004, + WGPUQueueWorkDoneStatus_DeviceLost = 0x00000005, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF } WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { - WGPURequestAdapterStatus_Success = 0x00000000, - WGPURequestAdapterStatus_Unavailable = 0x00000001, - WGPURequestAdapterStatus_Error = 0x00000002, - WGPURequestAdapterStatus_Unknown = 0x00000003, + WGPURequestAdapterStatus_Success = 0x00000001, + WGPURequestAdapterStatus_InstanceDropped = 0x00000002, + WGPURequestAdapterStatus_Unavailable = 0x00000003, + WGPURequestAdapterStatus_Error = 0x00000004, + WGPURequestAdapterStatus_Unknown = 0x00000005, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF } WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { - WGPURequestDeviceStatus_Success = 0x00000000, - WGPURequestDeviceStatus_Error = 0x00000001, - WGPURequestDeviceStatus_Unknown = 0x00000002, + WGPURequestDeviceStatus_Success = 0x00000001, + WGPURequestDeviceStatus_InstanceDropped = 0x00000002, + WGPURequestDeviceStatus_Error = 0x00000003, + WGPURequestDeviceStatus_Unknown = 0x00000004, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF } WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; @@ -775,8 +816,6 @@ typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; /** @} */ typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup Callbacks @@ -784,15 +823,16 @@ typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * * @{ */ - -typedef void (*WGPUAdapterRequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUBufferMapAsyncCallback)(WGPUBufferMapAsyncStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUInstanceRequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueOnSubmittedWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; - +typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLostReason reason, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUPopErrorScopeCallback)(WGPUPopErrorScopeStatus status, WGPUErrorType type, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUUncapturedErrorCallback)(WGPUDevice const * device, WGPUErrorType type, char const * message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; /** @} */ /** @@ -821,6 +861,85 @@ typedef struct WGPUChainedStructOut { * * @{ */ + + /** + * \defgroup WGPUCallbackInfo + * \brief Callback info structures that are used in asynchronous functions. + * + * @{ + */ +typedef struct WGPUBufferMapCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUBufferMapCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCompilationInfoCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCompilationInfoCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCreateComputePipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCreateRenderPipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUDeviceLostCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUDeviceLostCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUPopErrorScopeCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUPopErrorScopeCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUQueueWorkDoneCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUQueueWorkDoneCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestAdapterCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPURequestAdapterCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestDeviceCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPURequestDeviceCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUUncapturedErrorCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** @} */ + typedef struct WGPUAdapterInfo { WGPUChainedStructOut * nextInChain; char const * vendor; @@ -912,6 +1031,10 @@ typedef struct WGPUExtent3D { uint32_t depthOrArrayLayers; } WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUFuture { + uint64_t id; +} WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; + typedef struct WGPUInstanceDescriptor { WGPUChainedStruct const * nextInChain; } WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -1194,12 +1317,6 @@ typedef struct WGPUTextureViewDescriptor { WGPUTextureAspect aspect; } WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUUncapturedErrorCallbackInfo { - WGPUChainedStruct const * nextInChain; - WGPUErrorCallback callback; - void * userdata; -} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUVertexAttribute { WGPUVertexFormat format; uint64_t offset; @@ -1352,8 +1469,7 @@ typedef struct WGPUDeviceDescriptor { WGPUFeatureName const * requiredFeatures; WGPU_NULLABLE WGPURequiredLimits const * requiredLimits; WGPUQueueDescriptor defaultQueue; - WGPUDeviceLostCallback deviceLostCallback; - void * deviceLostUserdata; + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; } WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -1414,7 +1530,7 @@ typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeat typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; @@ -1438,7 +1554,7 @@ typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_ typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; @@ -1492,12 +1608,12 @@ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice de typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1506,7 +1622,7 @@ typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeature typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; @@ -1516,7 +1632,7 @@ typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; @@ -1534,7 +1650,7 @@ typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_A typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; @@ -1600,7 +1716,7 @@ typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTR typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUFuture (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; @@ -1670,7 +1786,7 @@ WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeature WGPU_EXPORT void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1726,7 +1842,7 @@ WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUN WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; @@ -1820,12 +1936,12 @@ WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice devic WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1834,7 +1950,7 @@ WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureNam WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; @@ -1852,7 +1968,7 @@ WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1894,7 +2010,7 @@ WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIB * * @{ */ -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; @@ -2008,7 +2124,7 @@ WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE * * @{ */ -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; diff --git a/webgpu.yml b/webgpu.yml index de6648a..52e1bd2 100644 --- a/webgpu.yml +++ b/webgpu.yml @@ -225,6 +225,22 @@ enums: - name: mapped doc: | TODO + - name: callback_mode + doc: | + TODO + entries: + - name: wait_any_only + value: 0x0001 + doc: | + TODO + - name: allow_process_events + value: 0x0002 + doc: | + TODO + - name: allow_spontaneous + value: 0x0003 + doc: | + TODO - name: compare_function doc: | TODO @@ -261,15 +277,23 @@ enums: TODO entries: - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 doc: | TODO - name: error + value: 0x0003 doc: | TODO - name: device_lost + value: 0x0004 doc: | TODO - name: unknown + value: 0x0005 doc: | TODO - name: compilation_message_type @@ -309,21 +333,31 @@ enums: TODO entries: - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 doc: | TODO - name: validation_error + value: 0x0003 doc: | TODO - name: internal_error + value: 0x0004 doc: | TODO - name: device_lost + value: 0x0005 doc: | TODO - name: device_destroyed + value: 0x0006 doc: | TODO - name: unknown + value: 0x0007 doc: | TODO - name: cull_mode @@ -351,6 +385,14 @@ enums: value: 0x0002 doc: | TODO + - name: instance_dropped + value: 0x0003 + doc: | + TODO + - name: failed_creation + value: 0x0004 + doc: | + TODO - name: error_filter doc: | TODO @@ -472,6 +514,30 @@ enums: - name: load doc: | TODO + - name: map_async_status + doc: | + TODO + entries: + - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 + doc: | + TODO + - name: error + value: 0x0003 + doc: | + TODO + - name: aborted + value: 0x0004 + doc: | + TODO + - name: unknown + value: 0x0005 + doc: | + TODO - name: mipmap_filter_mode doc: | TODO @@ -482,6 +548,18 @@ enums: - name: linear doc: | TODO + - name: pop_error_scope_status + doc: | + TODO + entries: + - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 + doc: | + TODO - name: power_preference doc: | TODO @@ -545,15 +623,23 @@ enums: TODO entries: - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 doc: | TODO - name: error + value: 0x0003 doc: | TODO - name: unknown + value: 0x0004 doc: | TODO - name: device_lost + value: 0x0005 doc: | TODO - name: request_adapter_status @@ -561,15 +647,23 @@ enums: TODO entries: - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 doc: | TODO - name: unavailable + value: 0x0003 doc: | TODO - name: error + value: 0x0004 doc: | TODO - name: unknown + value: 0x0005 doc: | TODO - name: request_device_status @@ -577,12 +671,19 @@ enums: TODO entries: - name: success + value: 0x0001 + doc: | + TODO + - name: instance_dropped + value: 0x0002 doc: | TODO - name: error + value: 0x0003 doc: | TODO - name: unknown + value: 0x0004 doc: | TODO - name: s_type @@ -1332,41 +1433,6 @@ bitflags: - name: render_attachment doc: | TODO -function_types: - - name: device_lost_callback - doc: | - TODO - args: - - name: reason - doc: | - TODO - type: enum.device_lost_reason - - name: message - doc: | - TODO - type: string - - name: userdata - doc: | - TODO - type: c_void - pointer: mutable - - name: error_callback - doc: | - TODO - args: - - name: type - doc: | - TODO - type: enum.error_type - - name: message - doc: | - TODO - type: string - - name: userdata - doc: | - TODO - type: c_void - pointer: mutable structs: - name: adapter_info doc: | @@ -1817,19 +1883,14 @@ structs: doc: | TODO type: struct.queue_descriptor - - name: device_lost_callback + - name: device_lost_callback_info doc: | TODO - type: function_type.device_lost_callback - - name: device_lost_userdata - doc: | - TODO - type: c_void - pointer: mutable + type: callback.device_lost - name: uncaptured_error_callback_info doc: | TODO - type: function_type.uncaptured_error_callback_info + type: callback.uncaptured_error - name: extent_3D doc: | TODO @@ -1871,6 +1932,15 @@ structs: TODO type: array pointer: immutable + - name: future + doc: | + TODO + type: standalone + members: + - name: id + doc: | + TODO + type: uint64 - name: image_copy_buffer doc: | TODO @@ -2876,20 +2946,6 @@ structs: doc: | TODO type: enum.texture_aspect - - name: uncaptured_error_callback_info - doc: | - TODO - type: base_in - members: - - name: callback - doc: | - TODO - type: function_type.error_callback - - name: userdata - doc: | - TODO - type: c_void - pointer: mutable - name: vertex_attribute doc: | TODO @@ -2949,6 +3005,163 @@ structs: TODO type: array pointer: immutable +callbacks: + - name: buffer_map + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.map_async_status + - name: message + doc: | + TODO + type: string + - name: compilation_info + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.compilation_info_request_status + - name: compilation_info + doc: | + TODO + type: struct.compilation_info + pointer: immutable + - name: create_compute_pipeline_async + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.create_pipeline_async_status + - name: pipeline + doc: | + TODO + type: object.compute_pipeline + - name: message + doc: | + TODO + type: string + - name: create_render_pipeline_async + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.create_pipeline_async_status + - name: pipeline + doc: | + TODO + type: object.render_pipeline + - name: message + doc: | + TODO + type: string + - name: device_lost + doc: TODO + style: callback_mode + args: + - name: device + doc: | + TODO + type: object.device + pointer: immutable + - name: reason + doc: | + TODO + type: enum.device_lost_reason + - name: message + doc: | + TODO + type: string + - name: pop_error_scope + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.pop_error_scope_status + - name: type + doc: | + TODO + type: enum.error_type + - name: message + doc: | + TODO + type: string + - name: queue_work_done + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.queue_work_done_status + - name: request_adapter + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.request_adapter_status + - name: adapter + doc: | + TODO + type: object.adapter + - name: message + doc: | + TODO + type: string + - name: request_device + doc: | + TODO + style: callback_mode + args: + - name: status + doc: | + TODO + type: enum.request_device_status + - name: device + doc: | + TODO + type: object.device + - name: message + doc: | + TODO + type: string + - name: uncaptured_error + doc: | + TODO + style: immediate + args: + - name: device + doc: | + TODO + type: object.device + pointer: immutable + - name: type + doc: | + TODO + type: enum.error_type + - name: message + doc: | + TODO + type: string functions: - name: create_instance doc: | @@ -3019,19 +3232,7 @@ objects: - name: request_device doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.request_device_status - - name: device - doc: | - TODO - type: object.device - - name: message - doc: | - TODO - type: string + callback: callback.request_device args: - name: descriptor doc: | @@ -3070,11 +3271,7 @@ objects: - name: map_async doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.buffer_map_async_status + callback: callback.buffer_map args: - name: mode doc: | @@ -3559,19 +3756,7 @@ objects: - name: create_compute_pipeline_async doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.create_pipeline_async_status - - name: pipeline - doc: | - TODO - type: object.compute_pipeline - - name: message - doc: | - TODO - type: string + callback: callback.create_compute_pipeline_async args: - name: descriptor doc: | @@ -3607,19 +3792,7 @@ objects: - name: create_render_pipeline_async doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.create_pipeline_async_status - - name: pipeline - doc: | - TODO - type: object.render_pipeline - - name: message - doc: | - TODO - type: string + callback: callback.create_render_pipeline_async args: - name: descriptor doc: | @@ -3751,16 +3924,7 @@ objects: - name: pop_error_scope doc: | TODO - args: - - name: callback - doc: | - TODO - type: function_type.error_callback - - name: userdata - doc: | - TODO - type: c_void - pointer: mutable + callback: callback.pop_error_scope - name: set_label doc: | TODO @@ -3804,19 +3968,7 @@ objects: - name: request_adapter doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.request_adapter_status - - name: adapter - doc: | - TODO - type: object.adapter - - name: message - doc: | - TODO - type: string + callback: callback.request_adapter args: - name: options doc: | @@ -3881,11 +4033,7 @@ objects: - name: on_submitted_work_done doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.queue_work_done_status + callback: callback.queue_work_done - name: write_buffer doc: | TODO @@ -4432,16 +4580,7 @@ objects: - name: get_compilation_info doc: | TODO - returns_async: - - name: status - doc: | - TODO - type: enum.compilation_info_request_status - - name: compilation_info - doc: | - TODO - type: struct.compilation_info - pointer: immutable + callback: callback.compilation_info - name: set_label doc: | TODO