mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 07:21:04 +01:00
* Implement lexing for all WGSL number literal types * Move number literal test cases * Adjust tests to match WGSL spec on number literals Suffixes are not type names and currently only a plain `u` is supported for uints. More specifically, `i` and `f` suffixes or suffixes with widths in bits like `u32` are not supported at the moment. * Add more tests for invalid number literal suffixes * Replace code too new for Rust 1.43 * Implement parsing for hexadecimal integers * Switch to enum number types, and Bytes for width * Check for negative and leading zeros in int literals * Implement parsing of hex floats with hexf-parse * Update error message tests * Update snapshot test output files * Clean up lexer state machine code * Clean up unexpected token error code * Move number literal parsing to own submodule
32 lines
1.0 KiB
WebGPU Shading Language
32 lines
1.0 KiB
WebGPU Shading Language
//TODO: merge with "interface"?
|
|
|
|
struct FragmentInput {
|
|
[[builtin(position)]] position: vec4<f32>;
|
|
[[location(0), interpolate(flat)]] flat : u32;
|
|
[[location(1), interpolate(linear)]] linear : f32;
|
|
[[location(2), interpolate(linear, centroid)]] linear_centroid : vec2<f32>;
|
|
[[location(3), interpolate(linear, sample)]] linear_sample : vec3<f32>;
|
|
[[location(4), interpolate(perspective)]] perspective : vec4<f32>;
|
|
[[location(5), interpolate(perspective, centroid)]] perspective_centroid : f32;
|
|
[[location(6), interpolate(perspective, sample)]] perspective_sample : f32;
|
|
};
|
|
|
|
[[stage(vertex)]]
|
|
fn main() -> FragmentInput {
|
|
var out: FragmentInput;
|
|
|
|
out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
|
out.flat = 8u;
|
|
out.linear = 27.0;
|
|
out.linear_centroid = vec2<f32>(64.0, 125.0);
|
|
out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
|
out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
|
out.perspective_centroid = 2197.0;
|
|
out.perspective_sample = 2744.0;
|
|
|
|
return out;
|
|
}
|
|
|
|
[[stage(fragment)]]
|
|
fn main(val : FragmentInput) { }
|