mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Factor out add_binary_expr() and use it for assignment operators.
This fixes a lot of internal compiler errors with assignment operators, especially bitwise ones. The bitwise-assignment test has the motivating examples.
This commit is contained in:
committed by
Henri Verbeet
parent
ebc039d128
commit
4467c655f0
Notes:
Henri Verbeet
2024-08-19 14:29:40 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/999
104
tests/hlsl/bitwise-assignment.shader_test
Normal file
104
tests/hlsl/bitwise-assignment.shader_test
Normal file
@@ -0,0 +1,104 @@
|
||||
[require]
|
||||
shader model >= 4.0
|
||||
|
||||
[pixel shader]
|
||||
uniform uint4 nonconst;
|
||||
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
uint a = 35, r = 2;
|
||||
|
||||
uint shifted = a; shifted >>= nonconst.x;
|
||||
a >>= r;
|
||||
return float4(a, shifted, 0, 0);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 uint4 2 0 0 0
|
||||
todo(glsl) draw quad
|
||||
probe (0, 0) rgba (8, 8, 0, 0)
|
||||
|
||||
[pixel shader]
|
||||
uniform uint4 nonconst;
|
||||
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
int a = 5, b = -12;
|
||||
uint r = 1;
|
||||
|
||||
int shifted_a = a; shifted_a >>= nonconst.x;
|
||||
int shifted_b = b; shifted_b >>= nonconst.x;
|
||||
a >>= r;
|
||||
b >>= r;
|
||||
return float4(a, b, shifted_a, shifted_b);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 uint4 1 0 0 0
|
||||
todo(glsl) draw quad
|
||||
probe (0, 0) rgba (2, -6, 2, -6)
|
||||
|
||||
[pixel shader]
|
||||
uniform uint4 nonconst;
|
||||
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
uint a = 35, r = 3;
|
||||
|
||||
uint shifted = a; shifted <<= nonconst.x;
|
||||
a <<= r;
|
||||
return float4(a, shifted, 0, 0);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 uint4 3 0 0 0
|
||||
todo(glsl) draw quad
|
||||
probe (0, 0) rgba (280, 280, 0, 0)
|
||||
|
||||
[pixel shader]
|
||||
uniform uint4 nonconst;
|
||||
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
int a = 5, b = -12;
|
||||
uint r = 2;
|
||||
|
||||
int shifted_a = a; shifted_a <<= nonconst.x;
|
||||
int shifted_b = b; shifted_b <<= nonconst.x;
|
||||
a <<= r;
|
||||
b <<= r;
|
||||
return float4(a, b, shifted_a, shifted_b);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 uint4 2 0 0 0
|
||||
todo(glsl) draw quad
|
||||
probe (0, 0) rgba (20, -48, 20, -48)
|
||||
|
||||
[pixel shader fail]
|
||||
% Make sure that bitshifts DON'T work with floats
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
float x = 5.0, y = 15.0;
|
||||
x <<= y;
|
||||
y <<= x;
|
||||
return float4(x, y, 0, 0);
|
||||
}
|
||||
|
||||
[pixel shader]
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
int source = 55;
|
||||
int i = -0x4141;
|
||||
uint u = 128;
|
||||
|
||||
int a = source; a &= i;
|
||||
int b = source; b |= u;
|
||||
int c = source; c ^= i;
|
||||
|
||||
return float4(a, b, c, 0);
|
||||
}
|
||||
|
||||
[test]
|
||||
todo(glsl) draw quad
|
||||
probe (0, 0) rgba (55, 183, -16760, 0)
|
Reference in New Issue
Block a user