2023-01-05 10:32:11 -08:00
|
|
|
[pixel shader fail]
|
|
|
|
sampler sam;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
Texture2D tex;
|
|
|
|
|
|
|
|
tex = tex; // Uninitialized assignment to self.
|
|
|
|
return tex.Sample(sam, float2(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-08 09:21:55 -07:00
|
|
|
[require]
|
|
|
|
shader model >= 4.0
|
|
|
|
|
2023-01-23 10:22:40 -08:00
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2023-01-23 10:22:40 -08:00
|
|
|
0.77 0.77 0.77 0.77
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 1]
|
|
|
|
size (2d, 1, 1)
|
2023-01-23 10:22:40 -08:00
|
|
|
0.64 0.64 0.64 0.64
|
|
|
|
|
|
|
|
[sampler 0]
|
|
|
|
filter linear linear linear
|
|
|
|
address clamp clamp clamp
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
Texture2D t_good, t_bad;
|
|
|
|
sampler sam;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
Texture2D a, b[1];
|
|
|
|
|
|
|
|
// This is basically a 'b[0] = t_good' but so that the copy-prop is delayed
|
|
|
|
int4 co = {0, 0, 0, 0};
|
|
|
|
b[(int) co.x + (int) co.y] = t_good;
|
|
|
|
|
|
|
|
a = b[0];
|
|
|
|
b[0] = t_bad;
|
|
|
|
|
|
|
|
// 'a' should be 't_good', not 't_bad' at this point
|
|
|
|
return 100 * a.Sample(sam, float2(0, 0)) + t_good.Sample(sam, float2(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (77.77, 77.77, 77.77, 77.77)
|
2023-01-23 10:22:40 -08:00
|
|
|
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 2, 2)
|
2022-08-08 09:21:55 -07:00
|
|
|
0.1 0.2 0.3 0.4 0.5 0.7 0.6 0.8
|
|
|
|
0.6 0.5 0.2 0.1 0.8 0.0 0.7 1.0
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
Texture2D t;
|
|
|
|
|
|
|
|
struct foo {
|
|
|
|
int3 a;
|
|
|
|
Texture2D b;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main(float4 pos : sv_position) : sv_target
|
|
|
|
{
|
|
|
|
struct foo q;
|
|
|
|
|
|
|
|
q.a = int3(pos.xy, 0);
|
|
|
|
q.b = t;
|
|
|
|
return q.b.Load(q.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2022-08-08 09:21:55 -07:00
|
|
|
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
|
|
|
|
probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8)
|
|
|
|
probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1)
|
|
|
|
probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
|
|
|
|
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2022-08-08 09:21:55 -07:00
|
|
|
1.0 1.0 1.0 1.0
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 1]
|
|
|
|
size (2d, 1, 1)
|
2022-08-08 09:21:55 -07:00
|
|
|
2.0 2.0 2.0 1.0
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 2]
|
|
|
|
size (2d, 1, 1)
|
2022-08-08 09:21:55 -07:00
|
|
|
3.0 3.0 3.0 1.0
|
|
|
|
|
2023-04-25 11:03:50 -07:00
|
|
|
[pixel shader]
|
2022-08-08 09:21:55 -07:00
|
|
|
Texture2D tex[3];
|
|
|
|
|
|
|
|
struct foo {
|
|
|
|
float4 p;
|
|
|
|
Texture2D t;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
struct foo s[3];
|
|
|
|
|
|
|
|
s[0].t = tex[0];
|
|
|
|
s[1].t = tex[1];
|
|
|
|
s[2].t = tex[2];
|
|
|
|
return 100 * s[2].t.Load(0) + 10 * s[0].t.Load(0) + s[1].t.Load(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (312, 312, 312, 111)
|
2022-08-08 09:21:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
Texture2D tex1;
|
|
|
|
Texture2D tex2;
|
|
|
|
Texture2D tex3;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
Texture2D t[3][2];
|
|
|
|
|
|
|
|
t[0][0] = tex1; // Note: Only invalid in shader model 5.1, array ref. cannot be used as l-value.
|
|
|
|
t[0][1] = tex2;
|
|
|
|
t[1][0] = tex3;
|
|
|
|
t[1][1] = tex1;
|
|
|
|
t[2][0] = tex2;
|
|
|
|
t[2][1] = tex3;
|
|
|
|
return 1000 * t[2][0].Load(0) + 100 * t[1][1].Load(0) + 10 * t[2][1].Load(0) + t[0][1].Load(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (2132, 2132, 2132, 1111)
|
2022-08-08 09:21:55 -07:00
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2022-08-08 09:21:55 -07:00
|
|
|
Texture2D tex[3];
|
|
|
|
uniform int n;
|
|
|
|
|
|
|
|
struct foo {
|
|
|
|
float4 p;
|
|
|
|
Texture2D t;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
struct foo s[3];
|
|
|
|
|
|
|
|
s[0].t = tex[0];
|
|
|
|
s[1].t = tex[1];
|
|
|
|
s[2].t = tex[2];
|
|
|
|
return s[n].t.Load(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2022-08-08 09:21:55 -07:00
|
|
|
// Note: Only valid in shader model 5.1
|
|
|
|
Texture2D tex[3];
|
|
|
|
uniform int n;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return tex[n].Load(0);
|
|
|
|
}
|
2022-10-31 08:35:16 -07:00
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2022-11-09 11:41:50 -08:00
|
|
|
// Note: Only valid in shader model 5.1
|
|
|
|
RWTexture2D<float4> tex[3];
|
|
|
|
uniform int n;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
tex[n][int2(0, 0)] = 0.6;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
vkd3d-shader/hlsl: Replace loads with constants in copy prop.
If a hlsl_ir_load loads a variable whose components are stored from different
instructions, copy propagation doesn't replace it.
But if all these instructions are constants (which currently is the case
for value constructors), the load could be replaced with a constant value.
Which is expected in some other instructions, e.g. texel_offsets when
using aoffimmi modifiers.
For instance, this shader:
```
sampler s;
Texture2D t;
float4 main() : sv_target
{
return t.Gather(s, float2(0.6, 0.6), int2(0, 0));
}
```
results in the following IR before applying the patch:
```
float | 6.00000024e-01
float | 6.00000024e-01
uint | 0
| = (<constructor-2>[@4].x @2)
uint | 1
| = (<constructor-2>[@6].x @3)
float2 | <constructor-2>
int | 0
int | 0
uint | 0
| = (<constructor-5>[@11].x @9)
uint | 1
| = (<constructor-5>[@13].x @10)
int2 | <constructor-5>
float4 | gather_red(resource = t, sampler = s, coords = @8, offset = @15)
| return
| = (<output-sv_target0> @16)
```
and this IR afterwards:
```
float2 | {6.00000024e-01 6.00000024e-01 }
int2 | {0 0 }
float4 | gather_red(resource = t, sampler = s, coords = @2, offset = @3)
| return
| = (<output-sv_target0> @4)
```
2022-11-17 12:49:28 -08:00
|
|
|
[pixel shader]
|
2022-10-31 08:35:16 -07:00
|
|
|
Texture2D tex;
|
|
|
|
uniform float f;
|
|
|
|
|
|
|
|
struct apple
|
|
|
|
{
|
|
|
|
Texture2D tex1;
|
|
|
|
Texture2D tex2;
|
|
|
|
float3 aa;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
struct apple a = {tex, tex, 1.0, 2.0, 3.0};
|
|
|
|
|
|
|
|
a.aa += f;
|
|
|
|
return a.aa.xyzx;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float 10.0
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
vkd3d-shader/hlsl: Replace loads with constants in copy prop.
If a hlsl_ir_load loads a variable whose components are stored from different
instructions, copy propagation doesn't replace it.
But if all these instructions are constants (which currently is the case
for value constructors), the load could be replaced with a constant value.
Which is expected in some other instructions, e.g. texel_offsets when
using aoffimmi modifiers.
For instance, this shader:
```
sampler s;
Texture2D t;
float4 main() : sv_target
{
return t.Gather(s, float2(0.6, 0.6), int2(0, 0));
}
```
results in the following IR before applying the patch:
```
float | 6.00000024e-01
float | 6.00000024e-01
uint | 0
| = (<constructor-2>[@4].x @2)
uint | 1
| = (<constructor-2>[@6].x @3)
float2 | <constructor-2>
int | 0
int | 0
uint | 0
| = (<constructor-5>[@11].x @9)
uint | 1
| = (<constructor-5>[@13].x @10)
int2 | <constructor-5>
float4 | gather_red(resource = t, sampler = s, coords = @8, offset = @15)
| return
| = (<output-sv_target0> @16)
```
and this IR afterwards:
```
float2 | {6.00000024e-01 6.00000024e-01 }
int2 | {0 0 }
float4 | gather_red(resource = t, sampler = s, coords = @2, offset = @3)
| return
| = (<output-sv_target0> @4)
```
2022-11-17 12:49:28 -08:00
|
|
|
probe (0, 0) rgba (11.0, 12.0, 13.0, 11.0)
|
2022-12-05 16:38:50 -08:00
|
|
|
|
|
|
|
|
2022-12-05 16:48:28 -08:00
|
|
|
[pixel shader fail]
|
2022-12-05 16:38:50 -08:00
|
|
|
float4 main(Texture2D tex2) : sv_target
|
|
|
|
{
|
|
|
|
Texture2D tex1;
|
|
|
|
tex2 = tex1;
|
|
|
|
return tex2.Load(int3(0, 0, 0));
|
|
|
|
}
|
2023-01-05 10:32:11 -08:00
|
|
|
|
|
|
|
|
|
|
|
[require]
|
|
|
|
shader model >= 5.0
|
|
|
|
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2023-01-05 10:32:11 -08:00
|
|
|
1.0 2.0 3.0 4.0
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader todo fail(sm>=6)]
|
2023-01-05 10:32:11 -08:00
|
|
|
struct apple {
|
|
|
|
Texture2D tex;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main(struct apple input) : sv_target
|
|
|
|
{
|
|
|
|
input.tex = input.tex; // Assignment to self.
|
|
|
|
return input.tex.Load(int3(0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
todo draw quad
|
|
|
|
todo probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|