gpuweb / gpuweb

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

wgsl: support extended integer arithmetic for add, subtract, multiply #1565

Open dneto0 opened 3 years ago

dneto0 commented 3 years ago

SPIR-V has:

MSL has

I haven't looked at HLSL yet.


update: Fixed typo in expansion of madhi.

alan-baker commented 3 years ago

The SPIR-V opcodes OpIAddCarry and OpISubBorrow both interpret the inputs as unsigned integers only. So support is only partially available. For example, 2 + (-1) would yield a carry.

kdashg commented 3 years ago
WGSL meeting minutes 2021-05-11 * AB: should be post-MVP * MM: not clear what HLSL offers for this * TR: mul_high is exposed in DXIL, but not in HLSL * MM: what is our rule for this: will all implementations that rely on HLSL go straight to DXIL, or do we want compatibility with HLSL the language. * DN: DXIL path is at least one year from now for us, so we want support in HLSL itself * GR: also not clear that DXIL-only operations are as widely tested. * MM: so we should only implement things which are supported by HLSL.
Kangz commented 2 years ago

ANGLE polyfills these methods when translating HLSL to GLSL. The translations can be found here and here.

Kangz commented 2 years ago

This was in post-MVP, should it be post-V1 or V1?

Kangz commented 2 years ago

This was in post-MVP, should it be post-V1 or V1?

litherum commented 2 years ago

I think there's a typo in the OP:

madhi(x,y,c) return madhi(x,y)+c.

should be

madhi(x,y,c) return mulhi(x, y) + c.

kdashg commented 2 years ago
WGSL meeting minutes 2022-01-25 * DN: Google happy post-V1 * RM: ok either way * _Post V1_