[wgsl-in] eagerly evaluate const-expressions

[wgsl-in] support const-expressions in attributes

allow `Splat` as an evaluated const-expression type
This commit is contained in:
teoxoy authored and Teodor Tanasoaia committed 2023-10-12 13:13:26 +02:00
1 parent c5d884fca8
commit a730236b68
44 files changed
+2917 -2770

No files matched your search

+2 -5
View File
@@ -50,11 +50,8 @@ void main()
float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx);
int cit2_[4] = Constructarray4_int_(0, 1, 2, 3);
bool ic0_ = bool((bool)0);
int ic1_ = int((int)0);
uint ic2_ = uint((uint)0);
float ic3_ = float((float)0);
uint2 ic4_ = uint2((uint2)0);
float2x3 ic5_ = float2x3((float2x3)0);
uint2 ic4_ = uint2(0u, 0u);
float2x3 ic5_ = float2x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0));
uint2 ic6_ = asuint((uint2)0);
float2x3 ic7_ = asfloat((float2x3)0);
}
+70 -70
View File
@@ -246,74 +246,74 @@ float4 texture_sample() : SV_Target0
float2 tc = (0.5).xx;
float3 tc3_ = (0.5).xxx;
float4 _expr9 = image_1d.Sample(sampler_reg, tc.x);
float4 _expr10 = a;
a = (_expr10 + _expr9);
float4 _expr14 = image_2d.Sample(sampler_reg, tc);
float4 _expr15 = a;
a = (_expr15 + _expr14);
float4 _expr19 = image_2d.Sample(sampler_reg, tc, int2(3, 1));
float4 _expr20 = a;
a = (_expr20 + _expr19);
float4 _expr24 = image_2d.SampleLevel(sampler_reg, tc, 2.3);
float4 _expr25 = a;
a = (_expr25 + _expr24);
float4 _expr29 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(3, 1));
float4 _expr30 = a;
a = (_expr30 + _expr29);
float4 _expr35 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(3, 1));
float4 _expr36 = a;
a = (_expr36 + _expr35);
float4 _expr41 = image_2d_array.Sample(sampler_reg, float3(tc, 0u));
float4 _expr42 = a;
a = (_expr42 + _expr41);
float4 _expr47 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(3, 1));
float4 _expr48 = a;
a = (_expr48 + _expr47);
float4 _expr53 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3);
float4 _expr54 = a;
a = (_expr54 + _expr53);
float4 _expr59 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(3, 1));
float4 _expr60 = a;
a = (_expr60 + _expr59);
float4 _expr66 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(3, 1));
float4 _expr67 = a;
a = (_expr67 + _expr66);
float4 _expr72 = image_2d_array.Sample(sampler_reg, float3(tc, 0));
float4 _expr73 = a;
a = (_expr73 + _expr72);
float4 _expr78 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(3, 1));
float4 _expr79 = a;
a = (_expr79 + _expr78);
float4 _expr84 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3);
float4 _expr85 = a;
a = (_expr85 + _expr84);
float4 _expr90 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(3, 1));
float4 _expr91 = a;
a = (_expr91 + _expr90);
float4 _expr97 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(3, 1));
float4 _expr98 = a;
a = (_expr98 + _expr97);
float4 _expr103 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u));
float4 _expr104 = a;
a = (_expr104 + _expr103);
float4 _expr109 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3);
float4 _expr110 = a;
a = (_expr110 + _expr109);
float4 _expr116 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0);
float4 _expr117 = a;
a = (_expr117 + _expr116);
float4 _expr122 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0));
float4 _expr123 = a;
a = (_expr123 + _expr122);
float4 _expr128 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3);
float4 _expr129 = a;
a = (_expr129 + _expr128);
float4 _expr135 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0);
float4 _expr136 = a;
a = (_expr136 + _expr135);
float4 _expr138 = a;
return _expr138;
float4 _expr8 = image_1d.Sample(sampler_reg, 0.5);
float4 _expr9 = a;
a = (_expr9 + _expr8);
float4 _expr13 = image_2d.Sample(sampler_reg, tc);
float4 _expr14 = a;
a = (_expr14 + _expr13);
float4 _expr18 = image_2d.Sample(sampler_reg, tc, int2(int2(3, 1)));
float4 _expr19 = a;
a = (_expr19 + _expr18);
float4 _expr23 = image_2d.SampleLevel(sampler_reg, tc, 2.3);
float4 _expr24 = a;
a = (_expr24 + _expr23);
float4 _expr28 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(3, 1)));
float4 _expr29 = a;
a = (_expr29 + _expr28);
float4 _expr34 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(3, 1)));
float4 _expr35 = a;
a = (_expr35 + _expr34);
float4 _expr40 = image_2d_array.Sample(sampler_reg, float3(tc, 0u));
float4 _expr41 = a;
a = (_expr41 + _expr40);
float4 _expr46 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(int2(3, 1)));
float4 _expr47 = a;
a = (_expr47 + _expr46);
float4 _expr52 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3);
float4 _expr53 = a;
a = (_expr53 + _expr52);
float4 _expr58 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(int2(3, 1)));
float4 _expr59 = a;
a = (_expr59 + _expr58);
float4 _expr65 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(int2(3, 1)));
float4 _expr66 = a;
a = (_expr66 + _expr65);
float4 _expr71 = image_2d_array.Sample(sampler_reg, float3(tc, 0));
float4 _expr72 = a;
a = (_expr72 + _expr71);
float4 _expr77 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(int2(3, 1)));
float4 _expr78 = a;
a = (_expr78 + _expr77);
float4 _expr83 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3);
float4 _expr84 = a;
a = (_expr84 + _expr83);
float4 _expr89 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(int2(3, 1)));
float4 _expr90 = a;
a = (_expr90 + _expr89);
float4 _expr96 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(int2(3, 1)));
float4 _expr97 = a;
a = (_expr97 + _expr96);
float4 _expr102 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u));
float4 _expr103 = a;
a = (_expr103 + _expr102);
float4 _expr108 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3);
float4 _expr109 = a;
a = (_expr109 + _expr108);
float4 _expr115 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0);
float4 _expr116 = a;
a = (_expr116 + _expr115);
float4 _expr121 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0));
float4 _expr122 = a;
a = (_expr122 + _expr121);
float4 _expr127 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3);
float4 _expr128 = a;
a = (_expr128 + _expr127);
float4 _expr134 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0);
float4 _expr135 = a;
a = (_expr135 + _expr134);
float4 _expr137 = a;
return _expr137;
}
float texture_sample_comparison() : SV_Target0
@@ -354,9 +354,9 @@ float4 gather() : SV_Target0
{
float2 tc_2 = (0.5).xx;
float4 s2d = image_2d.GatherGreen(sampler_reg, tc_2);
float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_2, int2(3, 1));
float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_2, int2(int2(3, 1)));
float4 s2d_depth = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5);
float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2(3, 1));
float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2(int2(3, 1)));
uint4 u = image_2d_u32_.Gather(sampler_reg, tc_2);
int4 i = image_2d_i32_.Gather(sampler_reg, tc_2);
float4 f = (float4(u) + float4(i));
+29 -83
View File
@@ -10,9 +10,9 @@ float4 builtins()
float4 s3_ = (bool4(false, false, false, false) ? v_f32_zero : v_f32_one);
float4 m1_ = lerp(v_f32_zero, v_f32_one, v_f32_half);
float4 m2_ = lerp(v_f32_zero, v_f32_one, 0.1);
float b1_ = asfloat(v_i32_one.x);
float b1_ = asfloat(1);
float4 b2_ = asfloat(v_i32_one);
int4 v_i32_zero = int4(v_f32_zero);
int4 v_i32_zero = int4(0, 0, 0, 0);
return (((((float4(((s1_).xxxx + v_i32_zero)) + s2_) + m1_) + m2_) + (b1_).xxxx) + b2_);
}
@@ -46,10 +46,7 @@ float3 bool_cast(float3 x)
void logical()
{
bool neg0_ = !(true);
bool2 neg1_ = !((true).xx);
bool or_ = (true || false);
bool and_ = (true && false);
bool2 neg1_ = bool2(false, false);
bool bitwise_or0_ = (true | false);
bool3 bitwise_or1_ = ((true).xxx | (false).xxx);
bool bitwise_and0_ = (true & false);
@@ -58,74 +55,59 @@ void logical()
void arithmetic()
{
int2 neg1_1 = -((1).xx);
float2 neg2_ = -((1.0).xx);
int add0_ = (2 + 1);
uint add1_ = (2u + 1u);
float add2_ = (2.0 + 1.0);
int2 neg1_1 = int2(-1, -1);
float2 neg2_ = float2(-1.0, -1.0);
int2 add3_ = ((2).xx + (1).xx);
uint3 add4_ = ((2u).xxx + (1u).xxx);
float4 add5_ = ((2.0).xxxx + (1.0).xxxx);
int sub0_ = (2 - 1);
uint sub1_ = (2u - 1u);
float sub2_ = (2.0 - 1.0);
int2 sub3_ = ((2).xx - (1).xx);
uint3 sub4_ = ((2u).xxx - (1u).xxx);
float4 sub5_ = ((2.0).xxxx - (1.0).xxxx);
int mul0_ = (2 * 1);
uint mul1_ = (2u * 1u);
float mul2_ = (2.0 * 1.0);
int2 mul3_ = ((2).xx * (1).xx);
uint3 mul4_ = ((2u).xxx * (1u).xxx);
float4 mul5_ = ((2.0).xxxx * (1.0).xxxx);
int div0_ = (2 / 1);
uint div1_ = (2u / 1u);
float div2_ = (2.0 / 1.0);
int2 div3_ = ((2).xx / (1).xx);
uint3 div4_ = ((2u).xxx / (1u).xxx);
float4 div5_ = ((2.0).xxxx / (1.0).xxxx);
int rem0_ = (2 % 1);
uint rem1_ = (2u % 1u);
float rem2_ = fmod(2.0, 1.0);
int2 rem3_ = ((2).xx % (1).xx);
uint3 rem4_ = ((2u).xxx % (1u).xxx);
float4 rem5_ = fmod((2.0).xxxx, (1.0).xxxx);
{
int2 add0_1 = ((2).xx + (1).xx);
int2 add1_1 = ((2).xx + (1).xx);
uint2 add2_1 = ((2u).xx + (1u).xx);
int2 add0_ = ((2).xx + (1).xx);
int2 add1_ = ((2).xx + (1).xx);
uint2 add2_ = ((2u).xx + (1u).xx);
uint2 add3_1 = ((2u).xx + (1u).xx);
float2 add4_1 = ((2.0).xx + (1.0).xx);
float2 add5_1 = ((2.0).xx + (1.0).xx);
int2 sub0_1 = ((2).xx - (1).xx);
int2 sub1_1 = ((2).xx - (1).xx);
uint2 sub2_1 = ((2u).xx - (1u).xx);
int2 sub0_ = ((2).xx - (1).xx);
int2 sub1_ = ((2).xx - (1).xx);
uint2 sub2_ = ((2u).xx - (1u).xx);
uint2 sub3_1 = ((2u).xx - (1u).xx);
float2 sub4_1 = ((2.0).xx - (1.0).xx);
float2 sub5_1 = ((2.0).xx - (1.0).xx);
int2 mul0_1 = ((2).xx * 1);
int2 mul1_1 = (2 * (1).xx);
uint2 mul2_1 = ((2u).xx * 1u);
uint2 mul3_1 = (2u * (1u).xx);
float2 mul4_1 = ((2.0).xx * 1.0);
float2 mul5_1 = (2.0 * (1.0).xx);
int2 div0_1 = ((2).xx / (1).xx);
int2 div1_1 = ((2).xx / (1).xx);
uint2 div2_1 = ((2u).xx / (1u).xx);
int2 mul0_ = int2(2, 2);
int2 mul1_ = int2(2, 2);
uint2 mul2_ = uint2(2u, 2u);
uint2 mul3_1 = uint2(2u, 2u);
float2 mul4_1 = float2(2.0, 2.0);
float2 mul5_1 = float2(2.0, 2.0);
int2 div0_ = ((2).xx / (1).xx);
int2 div1_ = ((2).xx / (1).xx);
uint2 div2_ = ((2u).xx / (1u).xx);
uint2 div3_1 = ((2u).xx / (1u).xx);
float2 div4_1 = ((2.0).xx / (1.0).xx);
float2 div5_1 = ((2.0).xx / (1.0).xx);
int2 rem0_1 = ((2).xx % (1).xx);
int2 rem1_1 = ((2).xx % (1).xx);
uint2 rem2_1 = ((2u).xx % (1u).xx);
int2 rem0_ = ((2).xx % (1).xx);
int2 rem1_ = ((2).xx % (1).xx);
uint2 rem2_ = ((2u).xx % (1u).xx);
uint2 rem3_1 = ((2u).xx % (1u).xx);
float2 rem4_1 = fmod((2.0).xx, (1.0).xx);
float2 rem5_1 = fmod((2.0).xx, (1.0).xx);
}
float3x3 add = ((float3x3)0 + (float3x3)0);
float3x3 sub = ((float3x3)0 - (float3x3)0);
float3x3 mul_scalar0_ = mul(1.0, (float3x3)0);
float3x3 mul_scalar1_ = mul((float3x3)0, 2.0);
float3x3 mul_scalar0_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0));
float3x3 mul_scalar1_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0));
float3 mul_vector0_ = mul((1.0).xxxx, (float4x3)0);
float4 mul_vector1_ = mul((float4x3)0, (2.0).xxx);
float3x3 mul_ = mul((float3x4)0, (float4x3)0);
@@ -133,67 +115,37 @@ void arithmetic()
void bit()
{
int flip0_ = ~(1);
uint flip1_ = ~(1u);
int2 flip2_ = ~((1).xx);
uint3 flip3_ = ~((1u).xxx);
int or0_ = (2 | 1);
uint or1_ = (2u | 1u);
int2 flip2_ = int2(-2, -2);
uint3 flip3_ = uint3(4294967294u, 4294967294u, 4294967294u);
int2 or2_ = ((2).xx | (1).xx);
uint3 or3_ = ((2u).xxx | (1u).xxx);
int and0_ = (2 & 1);
uint and1_ = (2u & 1u);
int2 and2_ = ((2).xx & (1).xx);
uint3 and3_ = ((2u).xxx & (1u).xxx);
int xor0_ = (2 ^ 1);
uint xor1_ = (2u ^ 1u);
int2 xor2_ = ((2).xx ^ (1).xx);
uint3 xor3_ = ((2u).xxx ^ (1u).xxx);
int shl0_ = (2 << 1u);
uint shl1_ = (2u << 1u);
int2 shl2_ = ((2).xx << (1u).xx);
uint3 shl3_ = ((2u).xxx << (1u).xxx);
int shr0_ = (2 >> 1u);
uint shr1_ = (2u >> 1u);
int2 shr2_ = ((2).xx >> (1u).xx);
uint3 shr3_ = ((2u).xxx >> (1u).xxx);
}
void comparison()
{
bool eq0_ = (2 == 1);
bool eq1_ = (2u == 1u);
bool eq2_ = (2.0 == 1.0);
bool2 eq3_ = ((2).xx == (1).xx);
bool3 eq4_ = ((2u).xxx == (1u).xxx);
bool4 eq5_ = ((2.0).xxxx == (1.0).xxxx);
bool neq0_ = (2 != 1);
bool neq1_ = (2u != 1u);
bool neq2_ = (2.0 != 1.0);
bool2 neq3_ = ((2).xx != (1).xx);
bool3 neq4_ = ((2u).xxx != (1u).xxx);
bool4 neq5_ = ((2.0).xxxx != (1.0).xxxx);
bool lt0_ = (2 < 1);
bool lt1_ = (2u < 1u);
bool lt2_ = (2.0 < 1.0);
bool2 lt3_ = ((2).xx < (1).xx);
bool3 lt4_ = ((2u).xxx < (1u).xxx);
bool4 lt5_ = ((2.0).xxxx < (1.0).xxxx);
bool lte0_ = (2 <= 1);
bool lte1_ = (2u <= 1u);
bool lte2_ = (2.0 <= 1.0);
bool2 lte3_ = ((2).xx <= (1).xx);
bool3 lte4_ = ((2u).xxx <= (1u).xxx);
bool4 lte5_ = ((2.0).xxxx <= (1.0).xxxx);
bool gt0_ = (2 > 1);
bool gt1_ = (2u > 1u);
bool gt2_ = (2.0 > 1.0);
bool2 gt3_ = ((2).xx > (1).xx);
bool3 gt4_ = ((2u).xxx > (1u).xxx);
bool4 gt5_ = ((2.0).xxxx > (1.0).xxxx);
bool gte0_ = (2 >= 1);
bool gte1_ = (2u >= 1u);
bool gte2_ = (2.0 >= 1.0);
bool2 gte3_ = ((2).xx >= (1).xx);
bool3 gte4_ = ((2u).xxx >= (1u).xxx);
bool4 gte5_ = ((2.0).xxxx >= (1.0).xxxx);
@@ -241,13 +193,7 @@ void assignment()
void negation_avoids_prefix_decrement()
{
int p1_ = -(-2);
int p2_ = -(-3);
int p3_ = -(-(4));
int p4_ = -(-(-5));
int p5_ = -(-(-(-(6))));
int p6_ = -(-(-(-(-7))));
int p7_ = -(-(-(-(-8))));
return;
}
[numthreads(1, 1, 1)]
@@ -255,7 +201,7 @@ void main()
{
const float4 _e0 = builtins();
const float4 _e1 = splat();
const float3 _e4 = bool_cast(v_f32_one.xyz);
const float3 _e6 = bool_cast(float3(1.0, 1.0, 1.0));
logical();
arithmetic();
bit();