gpuweb / gpuweb

Where the GPU for the Web work happens!
http://webgpu.io
Other
4.76k stars 315 forks source link

Add `subgroups-f16` feature dependency validation to subgroups proposal? #4734

Open jzm-intel opened 2 months ago

jzm-intel commented 2 months ago

Currently in the subgroups proposal we have two WebGPU features, subgroups and subgroups-f16, to enable corresponding WGSL extensions subgroups and subgroups_f16.

Since WebGPU feature subgroups-f16 is to enable using WGSL subgroups_f16 to allow using subgroups built-in function with f16 types, it is unreasonable to require this feature when creating devices without also requiring features shader-f16 and subgroups, and the adapter should report supporting subgroups-f16 only if it also supports shader-f16 and subgroups features. The same idea also applies to the WGSL extensions, i.e. it is unreasonable to enable shader_f16 extension without also enabling f16 and subgroups.

If we are going to keep subgroups-f16 feature and WGSL extension, maybe we can add notes in the subgroups proposal to states e.g.

  • When requestDevice called with subgroups-f16 feature required, the returning promise should be rejected with a TypeError if shader-f16 or subgroups is not also required.

Such validation rule may add a new aspect of features dependency into the validation.

For WGSL shader, maybe we can add notes like

  • It is a shader-creation error if subgroups_f16 extension is enabled without also enabling f16 and subgroups.
alan-baker commented 2 months ago

That certainly seems reasonable. I think this is the first instance (for WGSL at least) of dependent features.

teoxoy commented 1 month ago

I was hoping that we won't need an extra feature for this. There are very few devices/drivers that don't support both f16 and subgroups. Metal and D3D12 won't benefit from a subgroups-f16 feature either.

https://github.com/teoxoy/gpuinfo-vulkan-query/blob/8681e0074ece1b251177865203d18b018e05d67a/subgroups.txt#L1416-L1466

We are also limited by the nr of feature/limit buckets we can expose.

alan-baker commented 1 month ago

I agree that it would be nice to get to that point, but while the proposal lists subgroups-f16 it makes sense to make it dependent. We haven't really discussed removing the option yet to my knowledge in meeting.