Skip to content

[WebGPU] Support dispatch constants with uniform buffers - #25285

Open
anutosh491 wants to merge 1 commit into
iree-org:mainfrom
anutosh491:fix-webgpu-dispatch-constants
Open

anutosh491 wants to merge 1 commit into
iree-org:mainfrom
anutosh491:fix-webgpu-dispatch-constants

Conversation

@anutosh491

Copy link
Copy Markdown
Member

I hit this while running D-FINE on WebGPU. Dispatches using push constants failed during WGSL generation because Tint rejected the immediate address space. The runtime also wasn't carrying these values through the WebGPU dispatch instruction.

This reuses Tint's ChangeImmediateToUniform transformation and binds the resulting uniform buffer at group 1, binding 0. Dispatch constants are copied into the instruction stream, with an owned copy for deferred dispatches. Temporary buffers use the existing cleanup mechanism.

@devtbi devtbi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally looks okay, did not find anything major but I'm also not a WebGPU expert :D maybe @AGindinson wants to give it a quick look too


tint::core::ir::Module irModule = irResult.Move();
tint::core::ir::transform::ChangeImmediateToUniformConfig uniformConfig;
uniformConfig.immediate_binding_point = tint::BindingPoint{1, 0};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 1,0?

return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"dispatch constants must be 32-bit aligned");
}
uint32_t binding_count = (uint32_t)bindings.count;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless otherwise guaranteed, needs checking if .count fits into uint32

}
uint32_t binding_count = (uint32_t)bindings.count;
uint32_t constant_count = constants.data_length / sizeof(uint32_t);
uint32_t header_size = constant_count ? 7 : 6;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic numbers

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants