Shader: Switch type<subtype> to type[subtype]

This commit is contained in:
Jérôme Leclercq
2022-01-26 19:24:46 +01:00
parent 29a01e975c
commit e6951d54a5
27 changed files with 506 additions and 510 deletions

View File

@@ -19,7 +19,7 @@ struct inputStruct
external
{
[set(0), binding(0)] data: uniform<inputStruct>
[set(0), binding(0)] data: uniform[inputStruct]
}
[entry(frag)]
@@ -84,12 +84,12 @@ fn main()
std::string_view nzslSource = R"(
struct inputStruct
{
value: [f32; 10]
value: array[f32, 10]
}
external
{
[set(0), binding(0)] data: uniform<inputStruct>
[set(0), binding(0)] data: uniform[inputStruct]
}
[entry(frag)]
@@ -131,49 +131,49 @@ fn main()
WHEN("removing matrix casts")
{
std::string_view nzslSource = R"(
fn testMat2ToMat2(input: mat2<f32>) -> mat2<f32>
fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32]
{
return mat2<f32>(input);
return mat2[f32](input);
}
fn testMat2ToMat3(input: mat2<f32>) -> mat3<f32>
fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32]
{
return mat3<f32>(input);
return mat3[f32](input);
}
fn testMat2ToMat4(input: mat2<f32>) -> mat4<f32>
fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32]
{
return mat4<f32>(input);
return mat4[f32](input);
}
fn testMat3ToMat2(input: mat3<f32>) -> mat2<f32>
fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32]
{
return mat2<f32>(input);
return mat2[f32](input);
}
fn testMat3ToMat3(input: mat3<f32>) -> mat3<f32>
fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32]
{
return mat3<f32>(input);
return mat3[f32](input);
}
fn testMat3ToMat4(input: mat3<f32>) -> mat4<f32>
fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32]
{
return mat4<f32>(input);
return mat4[f32](input);
}
fn testMat4ToMat2(input: mat4<f32>) -> mat2<f32>
fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32]
{
return mat2<f32>(input);
return mat2[f32](input);
}
fn testMat4ToMat3(input: mat4<f32>) -> mat3<f32>
fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32]
{
return mat3<f32>(input);
return mat3[f32](input);
}
fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32]
{
return mat4<f32>(input);
return mat4[f32](input);
}
)";
@@ -185,71 +185,71 @@ fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
REQUIRE_NOTHROW(shader = Nz::ShaderAst::Sanitize(*shader, options));
ExpectNZSL(*shader, R"(
fn testMat2ToMat2(input: mat2<f32>) -> mat2<f32>
fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32]
{
return input;
}
fn testMat2ToMat3(input: mat2<f32>) -> mat3<f32>
fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32]
{
let temp: mat3<f32>;
temp[0] = vec3<f32>(input[0], 0.000000);
temp[1] = vec3<f32>(input[1], 0.000000);
temp[2] = vec3<f32>(input[2], 1.000000);
let temp: mat3[f32];
temp[0] = vec3[f32](input[0], 0.000000);
temp[1] = vec3[f32](input[1], 0.000000);
temp[2] = vec3[f32](input[2], 1.000000);
return temp;
}
fn testMat2ToMat4(input: mat2<f32>) -> mat4<f32>
fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32]
{
let temp: mat4<f32>;
temp[0] = vec4<f32>(input[0], 0.000000, 0.000000);
temp[1] = vec4<f32>(input[1], 0.000000, 0.000000);
temp[2] = vec4<f32>(input[2], 1.000000, 0.000000);
temp[3] = vec4<f32>(input[3], 0.000000, 1.000000);
let temp: mat4[f32];
temp[0] = vec4[f32](input[0], 0.000000, 0.000000);
temp[1] = vec4[f32](input[1], 0.000000, 0.000000);
temp[2] = vec4[f32](input[2], 1.000000, 0.000000);
temp[3] = vec4[f32](input[3], 0.000000, 1.000000);
return temp;
}
fn testMat3ToMat2(input: mat3<f32>) -> mat2<f32>
fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32]
{
let temp: mat2<f32>;
let temp: mat2[f32];
temp[0] = input[0].xy;
temp[1] = input[1].xy;
return temp;
}
fn testMat3ToMat3(input: mat3<f32>) -> mat3<f32>
fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32]
{
return input;
}
fn testMat3ToMat4(input: mat3<f32>) -> mat4<f32>
fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32]
{
let temp: mat4<f32>;
temp[0] = vec4<f32>(input[0], 0.000000);
temp[1] = vec4<f32>(input[1], 0.000000);
temp[2] = vec4<f32>(input[2], 0.000000);
temp[3] = vec4<f32>(input[3], 1.000000);
let temp: mat4[f32];
temp[0] = vec4[f32](input[0], 0.000000);
temp[1] = vec4[f32](input[1], 0.000000);
temp[2] = vec4[f32](input[2], 0.000000);
temp[3] = vec4[f32](input[3], 1.000000);
return temp;
}
fn testMat4ToMat2(input: mat4<f32>) -> mat2<f32>
fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32]
{
let temp: mat2<f32>;
let temp: mat2[f32];
temp[0] = input[0].xy;
temp[1] = input[1].xy;
return temp;
}
fn testMat4ToMat3(input: mat4<f32>) -> mat3<f32>
fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32]
{
let temp: mat3<f32>;
let temp: mat3[f32];
temp[0] = input[0].xyz;
temp[1] = input[1].xyz;
temp[2] = input[2].xyz;
return temp;
}
fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32]
{
return input;
}