2023-10-13 16:55:50 +02:00
|
|
|
[pixel shader fail(sm<6) todo]
|
|
|
|
uniform half h;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2025-06-06 12:33:42 +02:00
|
|
|
[pixel shader]
|
|
|
|
float4 var;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
half4 ret = var + 0.5;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) f32(1.5, 2.5, 3.5, 4.5)
|
|
|
|
|
|
|
|
[require]
|
|
|
|
shader model >= 2.0
|
|
|
|
shader model < 3.0
|
|
|
|
|
|
|
|
[pixel shader d3dbc-hex]
|
|
|
|
% The same as above, but in bytecode format so we test the partial precision
|
|
|
|
% destination modifier.
|
2025-07-31 18:40:08 +02:00
|
|
|
ffff0200 % ps_2_0
|
|
|
|
05000051 a00f0001 3f000000 00000000 00000000 00000000 % def c1, 0.5, 0, 0, 0
|
|
|
|
02000001 800f0000 a0e40000 % mov r0, c0
|
|
|
|
03000002 802f0000 80e40000 a0000001 % add_pp r0, r0, c1.x
|
|
|
|
02000001 802f0800 80e40000 % mov_pp oC0, r0
|
|
|
|
0000ffff % end
|
2025-06-06 12:33:42 +02:00
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) f32(1.5, 2.5, 3.5, 4.5)
|
|
|
|
|
2023-10-13 16:55:50 +02:00
|
|
|
[require]
|
|
|
|
options: backcompat
|
|
|
|
|
vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV.
For temporary registers, SM1-SM3 integer types are internally
represented as floating point, so, in order to perform a cast
from ints to floats we need a mere MOV.
For constant integer registers "iN" there is no operation for casting
from a floating point register to them. For address registers "aN", and
the loop counting register "aL", vertex shaders have the "mova" operation
but we haven't used these registers in any way yet.
We probably would want to introduce these as synthetic variables
allocated in a special register set. In that case we have to remember to
use MOVA instead of MOV in the store operations, but they shouldn't be src
or dst of CAST operations.
Regarding constant integer registers, in some shaders, constants are
expected to be received formatted as an integer, such as:
int m;
float4 main() : sv_target
{
float4 res = {0, 0, 0, 0};
for (int k = 0; k < m; ++k)
res += k;
return res;
}
which compiles as:
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// m i0 1
//
ps_3_0
def c0, 0, 1, 0, 0
mov r0, c0.x
mov r1.x, c0.x
rep i0
add r0, r0, r1.x
add r1.x, r1.x, c0.y
endrep
mov oC0, r0
but this only happens if the integer constant is used directly in an
instruction that needs it, and as I said there is no instruction that
allows converting them to a float representation.
Notice how a more complex shader, that performs operations with this
integer variable "m":
int m;
float4 main() : sv_target
{
float4 res = {0, 0, 0, 0};
for (int k = 0; k < m * m; ++k)
res += k;
return res;
}
gives the following output:
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// m c0 1
//
ps_3_0
def c1, 0, 0, 1, 0
defi i0, 255, 0, 0, 0
mul r0.x, c0.x, c0.x
mov r1, c1.y
mov r0.y, c1.y
rep i0
mov r0.z, r0.x
break_ge r0.y, r0.z
add r1, r0.y, r1
add r0.y, r0.y, c1.z
endrep
mov oC0, r1
Meaning that the uniform "m" is just stored as a floating point in
"c0", the constant integer register "i0" is just set to 255 (hoping
it is a high enough value) using "defi", and the "break_ge"
involving c0 is used to break from the loop.
We could potentially use this approach to implement loops from SM3
without expecting the variables being received as constant integer
registers.
According to the D3D documentation, for SM1-SM3 constant integer
registers are only used by the 'loop' and 'rep' instructions.
2023-10-20 18:38:12 -03:00
|
|
|
[pixel shader]
|
2023-10-13 16:55:50 +02:00
|
|
|
uniform half h;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float 10.0
|
2024-11-04 18:54:30 +08:00
|
|
|
draw quad
|
2024-02-10 13:16:22 -06:00
|
|
|
probe (0, 0) rgba (10.0, 10.0, 10.0, 10.0)
|
2025-05-20 16:40:35 +02:00
|
|
|
|
2025-05-20 16:45:03 +02:00
|
|
|
[require]
|
|
|
|
shader model >= 4.0
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
uniform float4 f;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
min16float4 h = f;
|
|
|
|
return h * min16float4(h[1], 2.0, 0.5, -0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 0.0 0.0 0.0
|
2025-07-14 22:22:04 +02:00
|
|
|
todo(msl & sm>=6) draw quad
|
2025-05-20 16:45:03 +02:00
|
|
|
probe (0, 0) rgba(0.0, 0.0, 0.0, 0.0)
|
|
|
|
uniform 0 float4 3.0 5.0 -0.2 -10.0
|
2025-07-14 22:22:04 +02:00
|
|
|
todo(msl & sm>=6) draw quad
|
2025-05-20 16:45:03 +02:00
|
|
|
probe (0, 0) rgba(15.0, 10.0, -0.1, 5.0) 4096
|
|
|
|
|
2025-05-20 16:40:35 +02:00
|
|
|
[require]
|
|
|
|
shader model >= 6.2
|
|
|
|
native-16-bit
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
uniform float4 f;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
half4 h = f;
|
|
|
|
return h * half4(h[1], 2.0, 0.5, -0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 0.0 0.0 0.0
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) rgba(0.0, 0.0, 0.0, 0.0)
|
|
|
|
uniform 0 float4 3.0 5.0 -0.2 -10.0
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) rgba(15.0, 10.0, -9.99755859e-002, 5.0)
|
|
|
|
uniform 0 float4 32768.0 32768.0 -32768.0 -32768.0
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) rgba(1e100, 1e100, -16384.0, 16384.0)
|
|
|
|
uniform 0 float4 0.000062 0.000062 5.97e-8 5.97e-8
|
|
|
|
draw quad
|
|
|
|
probe (0, 0) rgba(0.0, 1.23977661e-004, 0.0, 0.0)
|