vkd3d/tests/hlsl
Francisco Casas 4b5c7e3721 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.
2024-02-15 23:29:37 +01:00
..
abs.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
all.shader_test vkd3d-shader/dxil: Implement the DXIL CMP2 instruction. 2023-11-10 20:23:50 +01:00
angle-unit.shader_test vkd3d-shader/hlsl: Add degrees() function. 2023-11-20 22:07:19 +01:00
annotations.shader_test vkd3d-shader/hlsl: Allow annotations on techniques. 2024-01-23 20:26:19 +01:00
any.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
arithmetic-float-uniform.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
arithmetic-float.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
arithmetic-int-uniform.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
arithmetic-int.shader_test tests/shader-runner: Introduce "if" qualifier. 2024-02-13 22:51:22 +01:00
arithmetic-uint.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
array-dimension.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
array-parameters.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
array-size-expr.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
asfloat.shader_test vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
asuint.shader_test vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
attributes.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
bitwise.shader_test vkd3d-shader/spirv: Handle ITOI and UTOU in spirv_compiler_map_alu_instruction(). 2024-01-02 23:03:07 +01:00
bool-cast.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
bool-semantics.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
cast-64-bit.shader_test vkd3d-shader/dxil: Implement DX intrinsic SplitDouble. 2024-02-01 22:24:58 +01:00
cast-broadcast.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
cast-componentwise-compatible.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
cast-componentwise-equal.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
cast-to-float.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
cast-to-half.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
cast-to-int.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
cast-to-uint.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
cbuffer.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
ceil.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
cf-cond-types.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
clamp.shader_test vkd3d-shader/dxil: Implement DX intrinsic Binary. 2024-01-23 20:26:29 +01:00
clip.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
combined-samplers.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
comma.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
compute.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
conditional.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
const.shader_test vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
cross.shader_test vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
d3dcolor-to-ubyte4.shader_test vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
ddxddy.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
discard.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
distance.shader_test vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV. 2024-02-15 23:29:37 +01:00
dot.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
duplicate-modifiers.shader_test tests/shader-runner: Introduce "if" qualifier. 2024-02-13 22:51:22 +01:00
entry-point-semantics.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
exp.shader_test vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
expr-indexing.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
float-comparison.shader_test vkd3d-shader/spirv: Handle the ISINF and ISNAN instructions in spirv_compiler_emit_alu_instruction(). 2024-01-24 22:38:04 +01:00
floor.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
fmod.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
for.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
frac.shader_test vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
function-cast.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
function-overload.shader_test tests: Test overloads with signed and unsigned numeric values. 2023-11-22 22:08:05 +01:00
function-return.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
function.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
fwidth.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
gather-offset.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
gather.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
getdimensions.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
half.shader_test vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV. 2024-02-15 23:29:37 +01:00
hard-copy-prop.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
initializer-flatten.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-implicit-array.shader_test tests/shader-runner: Introduce "if" qualifier. 2024-02-13 22:51:22 +01:00
initializer-invalid-arg-count.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-local-array.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-matrix.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-multi.shader_test vkd3d-shader/hlsl: Declare vars individually when parsing struct declarations. 2023-07-04 22:39:24 +02:00
initializer-nested.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-numeric.shader_test tests/shader-runner: Introduce "if" qualifier. 2024-02-13 22:51:22 +01:00
initializer-objects.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
initializer-static-array.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
initializer-struct.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
intrinsic-override.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
invalid.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
inverse-trig.shader_test vkd3d-shader/spirv: Handle the ACOS, ASIN and ATAN instructions in spirv_compiler_emit_ext_glsl_instruction(). 2024-02-06 23:09:55 +01:00
is-front-face.shader_test vkd3d-shader/dxil: Handle semantic kind ISFRONTFACE. 2024-01-22 22:18:33 +01:00
ldexp.shader_test vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV. 2024-02-15 23:29:37 +01:00
length.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
lerp.shader_test vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV. 2024-02-15 23:29:37 +01:00
lit.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
load-level.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
log.shader_test vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
logic-operations.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
loop.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
majority-pragma.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
majority-syntax.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
majority-typedef.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
math.shader_test vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
matrix-indexing.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
matrix-semantics.shader_test tests: Do not test matrix majority on SM1-3. 2023-10-18 20:58:18 +02:00
max.shader_test vkd3d-shader/dxil: Implement DX intrinsic Binary. 2024-01-23 20:26:29 +01:00
minimum-precision.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
mul.shader_test tests: Remove unused parameter from mul() tests functions. 2023-10-31 21:59:29 +01:00
multiple-rt.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
nested-arrays.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
nointerpolation.shader_test vkd3d-shader/dxil: Handle semantic kind VERTEXID. 2024-01-22 22:18:32 +01:00
non-const-indexing.shader_test tests/shader-runner: Introduce "if" qualifier. 2024-02-13 22:51:22 +01:00
normalize.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
numeric-constructor-truncation.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
numeric-types.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
numthreads.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
object-field-offsets.shader_test vkd3d-shader/dxil: Allow empty struct types. 2023-11-02 18:23:12 +01:00
object-parameters.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
object-references.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
pow.shader_test vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
rasteriser-ordered-views.shader_test tests: Add some tests for rasteriser-ordered views. 2024-02-14 21:48:53 +01:00
reflect.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
register-reservations-numeric.shader_test vkd3d-shader/hlsl: Turn register(cX) reservations into buffer offset for SM4. 2024-01-29 22:33:27 +01:00
register-reservations-resources.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
return-implicit-conversion.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
return.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
round.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
sample-bias.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
sample-grad.shader_test vkd3d-shader/dxil: Implement DX intrinsic SampleGrad. 2024-02-14 21:48:08 +01:00
sample-level.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
sampler-offset.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
sampler.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
saturate.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
shader-interstage-interface.shader_test vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
shape.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
side-effects.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
sign.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
single-numeric-initializer.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
sm6-ternary.shader_test vkd3d-shader/ir: Introduce a simple control flow graph structurizer. 2024-02-06 23:07:07 +01:00
sm6-uav-rwtexture.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
smoothstep.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
sqrt.shader_test vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
state-block-syntax.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
static-initializer.shader_test vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
step.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
storage-qualifiers.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
struct-array.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
struct-assignment.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
struct-semantics.shader_test tests: Avoid using "SV_Position" as a name for the vertex shader input. 2023-12-14 23:19:30 +01:00
switch.shader_test tests/shader-runner: Add a 64-bit switch test. 2024-02-14 21:48:44 +01:00
swizzle-constant-prop.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
swizzle-matrix.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
swizzles.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
technique-fx_2.shader_test vkd3d-shader/tpf: Add initial support for writing fx_4_0/fx_4_1 binaries. 2024-01-11 23:04:48 +01:00
technique-fx_4.shader_test vkd3d-shader/tpf: Add initial support for writing fx_4_0/fx_4_1 binaries. 2024-01-11 23:04:48 +01:00
technique-fx_5.shader_test vkd3d-shader/fx: Initial support for fx_5_0 output. 2024-01-15 19:57:42 +01:00
ternary.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
texture-load-offset.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
texture-load-typed.shader_test vkd3d-shader/spirv: Emit a vector bitcast if necessary in spirv_compiler_emit_load_ssa_reg(). 2024-02-01 22:25:04 +01:00
texture-load.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
texture-ordering.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
transpose.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
trigonometry.shader_test vkd3d-shader/dxil: Handle hyperbolic trigonometric functions in sm6_parser_emit_dx_unary(). 2024-02-07 22:59:23 +01:00
trunc.shader_test tests: Remove [require] directives for tests that use int and bool uniforms. 2024-02-13 22:51:23 +01:00
type-names.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
uav-load.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
uav-out-param.shader_test vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
uav-rwbuffer.shader_test tests: Add some tests for rasteriser-ordered views. 2024-02-14 21:48:53 +01:00
uav-rwstructuredbuffer.shader_test tests: Add some tests for rasteriser-ordered views. 2024-02-14 21:48:53 +01:00
uav-rwtexture.shader_test tests: Add some tests for rasteriser-ordered views. 2024-02-14 21:48:53 +01:00
uniform-parameters.shader_test tests/shader-runner: Test shaders with dxcompiler. 2023-10-11 22:21:14 +02:00
uniform-semantics.shader_test vkd3d-shader/dxil: Implement the DXIL EXTRACTVAL instruction. 2023-11-01 21:47:34 +01:00
vector-indexing-uniform.shader_test tests: Use the vulkan runner to run SM1 compilation tests. 2024-01-24 22:37:44 +01:00
vector-indexing.shader_test vkd3d-shader/hlsl: Emit fixmes on non-constant vector addressing. 2024-01-15 19:57:12 +01:00
writemask-assignop-0.shader_test vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
writemask-assignop-1.shader_test vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
writemask-assignop-2.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00
writemask-assignop-3.shader_test tests: Move HLSL tests to a subdirectory. 2023-06-28 21:40:32 +02:00