mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 08:21:25 +01:00
* Allow vecN<i32> and vecN<u32> in `dot()`, first changes * Added a test case * Fix the test * Changes to baking of expressions, incl args of integer dot product * Implemented requested changes for glsl backend * Added support for integer dot product on MSL backend * Removed outdated code for hlsl and wgls writers * Implement in spv backend * Commit modified outputs from running the tests * cargo fmt * Applied requested changes for both MSL and GLSL back * Changes to spv back * Committed all test output changes * Cargo fmt * Added a comment w.r.t. VK_KHR_shader_integer_dot_product * Implemented requested svp change * Minor change to test case This is because I wanted to highlight the fact that the correct id is used in the last sum of the integer dot product expression * Changed function signature since it could not fail, changed it to simply return `void`
30 lines
724 B
WebGPU Shading Language
30 lines
724 B
WebGPU Shading Language
fn test_fma() -> vec2<f32> {
|
|
let a = vec2<f32>(2.0, 2.0);
|
|
let b = vec2<f32>(0.5, 0.5);
|
|
let c = vec2<f32>(0.5, 0.5);
|
|
|
|
// Hazard: HLSL needs a different intrinsic function for f32 and f64
|
|
// See: https://github.com/gfx-rs/naga/issues/1579
|
|
return fma(a, b, c);
|
|
}
|
|
|
|
fn test_integer_dot_product() -> i32 {
|
|
let a_2 = vec2<i32>(1);
|
|
let b_2 = vec2<i32>(1);
|
|
let c_2: i32 = dot(a_2, b_2);
|
|
|
|
let a_3 = vec3<u32>(1u);
|
|
let b_3 = vec3<u32>(1u);
|
|
let c_3: u32 = dot(a_3, b_3);
|
|
|
|
// test baking of arguments
|
|
let c_4: i32 = dot(vec4<i32>(4), vec4<i32>(2));
|
|
return c_4;
|
|
}
|
|
|
|
@stage(compute) @workgroup_size(1)
|
|
fn main() {
|
|
let a = test_fma();
|
|
let b = test_integer_dot_product();
|
|
}
|