mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
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>
66 lines
1.9 KiB
HLSL
66 lines
1.9 KiB
HLSL
struct NagaConstants {
|
|
int base_vertex;
|
|
int base_instance;
|
|
uint other;
|
|
};
|
|
ConstantBuffer<NagaConstants> _NagaConstants: register(b1);
|
|
|
|
struct VertexOutput {
|
|
float4 position : SV_Position;
|
|
float3 uv : LOC0;
|
|
};
|
|
|
|
struct Data {
|
|
row_major float4x4 proj_inv;
|
|
row_major float4x4 view;
|
|
};
|
|
|
|
cbuffer r_data : register(b0) { Data r_data; }
|
|
TextureCube<float4> r_texture : register(t0);
|
|
SamplerState r_sampler : register(s0, space1);
|
|
|
|
struct VertexOutput_vs_main {
|
|
float3 uv : LOC0;
|
|
float4 position : SV_Position;
|
|
};
|
|
|
|
struct FragmentInput_fs_main {
|
|
float3 uv_1 : LOC0;
|
|
float4 position_1 : SV_Position;
|
|
};
|
|
|
|
VertexOutput ConstructVertexOutput(float4 arg0, float3 arg1) {
|
|
VertexOutput ret = (VertexOutput)0;
|
|
ret.position = arg0;
|
|
ret.uv = arg1;
|
|
return ret;
|
|
}
|
|
|
|
VertexOutput_vs_main vs_main(uint vertex_index : SV_VertexID)
|
|
{
|
|
int tmp1_ = (int)0;
|
|
int tmp2_ = (int)0;
|
|
|
|
tmp1_ = (int((_NagaConstants.base_vertex + vertex_index)) / 2);
|
|
tmp2_ = (int((_NagaConstants.base_vertex + vertex_index)) & 1);
|
|
int _expr9 = tmp1_;
|
|
int _expr15 = tmp2_;
|
|
float4 pos = float4(((float(_expr9) * 4.0) - 1.0), ((float(_expr15) * 4.0) - 1.0), 0.0, 1.0);
|
|
float4 _expr27 = r_data.view[0];
|
|
float4 _expr32 = r_data.view[1];
|
|
float4 _expr37 = r_data.view[2];
|
|
float3x3 inv_model_view = transpose(float3x3(_expr27.xyz, _expr32.xyz, _expr37.xyz));
|
|
float4x4 _expr43 = r_data.proj_inv;
|
|
float4 unprojected = mul(pos, _expr43);
|
|
const VertexOutput vertexoutput = ConstructVertexOutput(pos, mul(unprojected.xyz, inv_model_view));
|
|
const VertexOutput_vs_main vertexoutput_1 = { vertexoutput.uv, vertexoutput.position };
|
|
return vertexoutput_1;
|
|
}
|
|
|
|
float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0
|
|
{
|
|
VertexOutput in_ = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.uv_1 };
|
|
float4 _expr4 = r_texture.Sample(r_sampler, in_.uv);
|
|
return _expr4;
|
|
}
|