mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-12-04 12:44:23 +00:00
6035b07b78
Fixes #1745: Support out-of-order module scope declarations in WGSL Fixes #1044: Forbid local variable shadowing in WGSL Fixes #2076: [wgsl-in] no error for duplicated type definition Fixes #2071: Global item does not support 'const' Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument Fixes #1775: Referencing a function without a return type yields an unknown identifier error. Fixes #2089: Error span reported on the declaration of a variable instead of its use Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'" Separate parsing from lowering by generating an AST, which desugars as much as possible down to something like Naga IR. The AST is then used to resolve identifiers while lowering to Naga IR. Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Co-authored-by: Jim Blandy <jimb@red-bean.com>
42 lines
1.1 KiB
WebGPU Shading Language
42 lines
1.1 KiB
WebGPU Shading Language
struct VertexOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv: vec3<f32>,
|
|
}
|
|
|
|
struct Data {
|
|
proj_inv: mat4x4<f32>,
|
|
view: mat4x4<f32>,
|
|
}
|
|
|
|
@group(0) @binding(0)
|
|
var<uniform> r_data: Data;
|
|
@group(0) @binding(1)
|
|
var r_texture: texture_cube<f32>;
|
|
@group(0) @binding(2)
|
|
var r_sampler: sampler;
|
|
|
|
@vertex
|
|
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
|
var tmp1_: i32;
|
|
var tmp2_: i32;
|
|
|
|
tmp1_ = (i32(vertex_index) / 2);
|
|
tmp2_ = (i32(vertex_index) & 1);
|
|
let _e9 = tmp1_;
|
|
let _e15 = tmp2_;
|
|
let pos = vec4<f32>(((f32(_e9) * 4.0) - 1.0), ((f32(_e15) * 4.0) - 1.0), 0.0, 1.0);
|
|
let _e27 = r_data.view[0];
|
|
let _e32 = r_data.view[1];
|
|
let _e37 = r_data.view[2];
|
|
let inv_model_view = transpose(mat3x3<f32>(_e27.xyz, _e32.xyz, _e37.xyz));
|
|
let _e43 = r_data.proj_inv;
|
|
let unprojected = (_e43 * pos);
|
|
return VertexOutput(pos, (inv_model_view * unprojected.xyz));
|
|
}
|
|
|
|
@fragment
|
|
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
|
let _e4 = textureSample(r_texture, r_sampler, in.uv);
|
|
return _e4;
|
|
}
|