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

Add PostTask hook #457

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gen/cheader.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ struct WGPU{{.Name | PascalCase}}{{$.ExtSuffix}};
struct WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}};
{{- end}}
{{ end}}
struct WGPUPostTaskCallbackInfo;

/**
* \defgroup Enumerations Enumerations
Expand Down Expand Up @@ -322,6 +323,14 @@ typedef struct WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}} {
/*.userdata2=*/NULL _wgpu_COMMA \
})
{{ end}}{{"\n" -}}
typedef struct WGPUPostTaskHookInfo {
WGPUPostTaskHook hook;
WGPU_NULLABLE void* userdata1;
WGPU_NULLABLE void* userdata2;
}

typedef (*WGPUImplementationTaskFunction)(void* impldata);
typedef (*WGPUPostTaskHook)(WGPUImplementationTaskFlags flags, WGPUImplementationTaskFunction task, void* impldata, void* userdata1, void* userdata2);

/** @} */

Expand Down
5 changes: 5 additions & 0 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (g *Generator) Gen(dst io.Writer) error {
s += "\n\nThis is a \\ref NonNullInputString."
case "out_string":
s += "\n\nThis is an \\ref OutputString."
case "post_task_hook_info":
}

s += "\n\nThe `INIT` macro sets this to " + g.DefaultValue(*member, true /* isDocString */) + "."
Expand Down Expand Up @@ -238,6 +239,8 @@ func (g *Generator) CType(typ string, pointerType PointerType, suffix string) st
return appendModifiers("WGPUBool", pointerType)
case "nullable_string", "string_with_default_empty", "out_string":
return "WGPUStringView"
case "post_task_hook_info":
return "WGPUPostTaskHookInfo"
case "uint16":
return appendModifiers("uint16_t", pointerType)
case "uint32":
Expand Down Expand Up @@ -603,6 +606,8 @@ func (g *Generator) DefaultValue(member ParameterType, isDocString bool) string
return ref("WGPU_STRING_VIEW_INIT")
case member.Type == "c_void":
return literal("NULL")
case member.Type == "post_task_hook_info":
return literal("NULL")
default:
panic("invalid prefix: " + member.Type + " in member " + member.Name)
}
Expand Down
1 change: 1 addition & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"nullable_string",
"string_with_default_empty",
"out_string",
"post_task_hook_info",
"uint16",
"uint32",
"uint64",
Expand Down
23 changes: 23 additions & 0 deletions webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ struct WGPURequestAdapterCallbackInfo;
struct WGPURequestDeviceCallbackInfo;
struct WGPUUncapturedErrorCallbackInfo;

struct WGPUPostTaskCallbackInfo;

/**
* \defgroup Enumerations Enumerations
Expand Down Expand Up @@ -1164,6 +1165,14 @@ static const WGPUColorWriteMask WGPUColorWriteMask_Blue = 0x0000000000000004;
static const WGPUColorWriteMask WGPUColorWriteMask_Alpha = 0x0000000000000008;
static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F /* Red | Green | Blue | Alpha */;

/**
* Flags indicating types of work contained in the task.
*/
typedef WGPUFlags WGPUImplementationTaskFlags;
static const WGPUImplementationTaskFlags WGPUImplementationTaskFlags_None = 0x0000000000000000;
static const WGPUImplementationTaskFlags WGPUImplementationTaskFlags_CPUWork = 0x0000000000000001;
static const WGPUImplementationTaskFlags WGPUImplementationTaskFlags_BlockingIO = 0x0000000000000002;

typedef WGPUFlags WGPUMapMode;
static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000;
static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001;
Expand Down Expand Up @@ -1508,6 +1517,15 @@ typedef struct WGPUUncapturedErrorCallbackInfo {
/*.userdata2=*/NULL _wgpu_COMMA \
})

typedef struct WGPUPostTaskHookInfo {
WGPUPostTaskHook hook;
kainino0x marked this conversation as resolved.
Show resolved Hide resolved
WGPU_NULLABLE void* userdata1;
WGPU_NULLABLE void* userdata2;
}

typedef (*WGPUImplementationTaskFunction)(void* impldata);
typedef (*WGPUPostTaskHook)(WGPUImplementationTaskFlags flags, WGPUImplementationTaskFunction task, void* impldata, void* userdata1, void* userdata2);

/** @} */

/**
Expand Down Expand Up @@ -3768,6 +3786,10 @@ typedef struct WGPUInstanceDescriptor {
* The `INIT` macro sets this to @ref WGPU_INSTANCE_CAPABILITIES_INIT.
*/
WGPUInstanceCapabilities features;
/**
* The `INIT` macro sets this to `NULL`.
*/
WGPUPostTaskHookInfo postTaskHook;
} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE;

/**
Expand All @@ -3776,6 +3798,7 @@ typedef struct WGPUInstanceDescriptor {
#define WGPU_INSTANCE_DESCRIPTOR_INIT _wgpu_MAKE_INIT_STRUCT(WGPUInstanceDescriptor, { \
/*.nextInChain=*/NULL _wgpu_COMMA \
/*.features=*/WGPU_INSTANCE_CAPABILITIES_INIT _wgpu_COMMA \
/*.postTaskHook=*/NULL _wgpu_COMMA \
})

/**
Expand Down
13 changes: 13 additions & 0 deletions webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,16 @@ enums:
doc: |
TODO
bitflags:
- name: implementation_task_flags
doc:
Flags indicating types of work contained in the task.
entries:
- name: none
doc: TODO
- name: CPU_work
doc: TODO
- name: blocking_IO
doc: TODO
- name: buffer_usage
doc: |
TODO
Expand Down Expand Up @@ -2033,6 +2043,9 @@ structs:
- name: features
doc: Instance features to enable
type: struct.instance_capabilities
- name: post_task_hook
doc: TODO
type: post_task_hook_info
- name: limits
doc: |
TODO
Expand Down
Loading