Commit Graph

3389 Commits

Author SHA1 Message Date
Zebediah Figura
8c2b8ff245 vkd3d-shader/hlsl: Synthesize the swizzle and replace the instruction inside of copy_propagation_compute_replacement().
Rename it to copy_propagation_replace_with_single_instr() accordingly.

The idea is to introduce a constant vector replacement pass which will do the
same thing.
2023-01-24 18:10:41 +01:00
Zebediah Figura
5d34790402 vkd3d-shader/hlsl: Call copy_propagation_get_value() directly in copy_propagation_transform_object_load().
copy_propagation_compute_replacement() is not doing very much for us, and
conceptually is a bit of an odd fit anyway, since it's meant to deal with
multi-component types.
2023-01-24 18:10:40 +01:00
Zebediah Figura
8fd30aa87d vkd3d-shader/hlsl: Add some swizzle manipulation definitions. 2023-01-24 18:10:39 +01:00
Francisco Casas
337b4c5db0 tests: Test constant propagation through swizzles.
The Load() method offsets are used for these tests since these must
solve to constants in order to pass.
2023-01-24 18:10:38 +01:00
Francisco Casas
cf17882189 vkd3d-shader/hlsl: Support offset argument for the texture Load() method. 2023-01-24 18:10:36 +01:00
Francisco Casas
7a7b17d0e1 tests: Test offset argument for the texture Load() method. 2023-01-24 18:10:36 +01:00
Giovanni Mascellani
1717dc0516 tests: Print DLL versions when running tests on Windows. 2023-01-24 18:10:22 +01:00
Giovanni Mascellani
2445743002 tests: Run d3d9 and d3d12 tests on non-cross builds too.
On cross builds, shaders are compiled with d3dcompiler_47.dll and
run with d3dN.dll. On non-cross builds, shaders are compiled with
vkd3d-shader and run with d3dN.dll (on Windows) or Vulkan and vkd3d
(on Linux).
2023-01-24 18:10:17 +01:00
Giovanni Mascellani
44d9e2d728 tests: Distinguish between cross and non-cross Win32 builds.
Now the tests compile correctly on non-cross Win32 builds.
2023-01-24 18:10:15 +01:00
Zebediah Figura
9c817e5e6d vkd3d-shader/hlsl: Forbid recursive calls. 2023-01-19 19:16:27 +01:00
Zebediah Figura
503be4243c tests/shader_runner: Explicitly track the expected shader compilation HRESULT instead of using a boolean flag. 2023-01-19 19:16:26 +01:00
Zebediah Figura
521f22e57a vkd3d-shader/hlsl: Store a non-constant hlsl_ir_function_decl pointer in struct hlsl_ir_call. 2023-01-19 19:16:25 +01:00
Zebediah Figura
447463e590 vkd3d-shader/hlsl: Remove the unused "intrinsic" argument from hlsl_add_function(). 2023-01-19 19:16:24 +01:00
Zebediah Figura
6c2472ce16 vkd3d-shader/hlsl: Remove some unnecessary YYABORTs from the func_prototype_no_attrs rule. 2023-01-19 19:16:22 +01:00
Francisco Casas
13c8e8b856 vkd3d-shader/hlsl: Parse step() intrinsic. 2023-01-19 19:16:17 +01:00
Francisco Casas
4e1a4a76d9 tests: Test step() intrinsic. 2023-01-19 19:16:17 +01:00
Francisco Casas
6fbf2b3e75 vkd3d-shader/hlsl: Parse sqrt() intrinsic. 2023-01-19 19:16:16 +01:00
Francisco Casas
7dbc879e2d tests: Test sqrt() intrinsic. 2023-01-19 19:16:16 +01:00
Francisco Casas
8d5f16d803 vkd3d-shader/hlsl: Support cos() intrinsic. 2023-01-19 19:16:15 +01:00
Francisco Casas
3239ea5ff1 vkd3d-shader/hlsl: Support sin() intrinsic. 2023-01-19 19:16:14 +01:00
Francisco Casas
b65c450101 vkd3d-shader/hlsl: Add additional tests for sin() and cos(). 2023-01-19 19:16:13 +01:00
Francisco Casas
2b1ec0cfe5 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_scope. 2023-01-19 19:16:08 +01:00
Francisco Casas
eabd742f3e vkd3d-shader/hlsl: Add field-level documentation to function structs. 2023-01-19 19:16:07 +01:00
Francisco Casas
c68d0ecfe0 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_buffer. 2023-01-19 19:16:06 +01:00
Francisco Casas
ba56833bb5 vkd3d-shader/hlsl: Add documentation to small hlsl.h structs. 2023-01-19 19:16:04 +01:00
Francisco Casas
06b52c0343 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_deref. 2023-01-19 19:15:59 +01:00
Francisco Casas
f33d433621 vkd3d-shader/hlsl: Add documentation to struct hlsl_reg. 2023-01-19 19:15:57 +01:00
Francisco Casas
aab9886021 vkd3d-shader/hlsl: Allow uninitialized static objects.
validate_static_object_references() validates that uninitialized static
objects are not referenced in the shader.

In case a static variable contains both numeric and object types, the
"Static variables cannot have both numeric and resource components."
error should preempt uninitialized numeric values to reach further
compilation steps.
2023-01-19 12:29:41 +01:00
Francisco Casas
17d6a4411e vkd3d-shader/hlsl: Validate that non-uniform objects are not referenced.
Note that in the future we should call
validate_static_object_references() after DCE and pruning branches,
because shaders such as these compile (at least in more modern versions
of the native compiler):

Branch pruning:
```
static RWTexture2D<float> tex;

float4 main() : sv_target
{
    if (0)
    {
        tex[int2(0, 0)] = 2;
    }
    return 0;
}
```

DCE:
```
static Texture2D tex;
uniform uint i;

float4 main() : sv_target
{
    float4 unused = tex.Load(int3(0, 1, 2));

    return 0;
}
```

These are "todo" tests in hlsl-static-initializer.shader_test
that depend on this.
2023-01-19 12:29:39 +01:00
Francisco Casas
97c9669544 tests: Add additional object references tests. 2023-01-19 12:29:39 +01:00
Giovanni Mascellani
207643b8e8 tests: Test proper initialization of static structs to zero. 2023-01-19 12:29:39 +01:00
Francisco Casas
5cfc8d378f vkd3d-shader/hlsl: Initialize static variables to 0 by default.
We are currently not initializing static values to zero by default.

Consider the following shader:
```hlsl
static float4 va;

float4 main() : sv_target
{
  return va;
}
```
we get the following output:
```
ps_5_0
dcl_output o0.xyzw
dcl_temps 2
mov r0.xyzw, r1.xyzw
mov o0.xyzw, r0.xyzw
ret
```
where r1.xyzw is not initialized.

This patch solves this by assigning the static variable the value of an
uint 0, and thus, relying on complex broadcasts.

This seems to be the behaviour of the 9.29.952.3111 version of the native
compiler, since it retrieves the following error on a shader that lacks
an initializer on a data type with object components:

```
error X3017: cannot convert from 'uint' to 'struct <unnamed>'
```
2023-01-19 12:29:36 +01:00
Zebediah Figura
61f0d6d151 vkd3d-shader/hlsl: Get rid of the "intrinsic" field of struct hlsl_ir_function.
We have a different system of generating intrinsics, which makes it easier to
deal with "polymorphic" arithmetic functions.

Defining and storing intrinsics as hlsl_ir_function_decls would also require
more space in memory (and more optimization passes to get rid of the parameter
variables), and doesn't really save us any effort in terms of source code.
2023-01-13 17:32:44 +01:00
Zebediah Figura
9cc7aaf5a1 vkd3d-shader/hlsl: Forbid returning void expressions from void functions. 2023-01-13 17:32:43 +01:00
Zebediah Figura
b29d3489de vkd3d-shader/hlsl: Generate IR for user-defined function calls. 2023-01-13 17:32:42 +01:00
Zebediah Figura
30550c0831 vkd3d-shader/hlsl: Avoid assuming that expressions have at least one argument. 2023-01-13 17:32:40 +01:00
Zebediah Figura
22a1a478ea tests: Test specifying a UAV address as an in/out parameter to a function. 2023-01-13 17:32:39 +01:00
Francisco Casas
3fbe272659 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_src. 2023-01-11 16:03:55 +01:00
Francisco Casas
04108c0e21 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_node. 2023-01-11 16:03:54 +01:00
Francisco Casas
9157a5e73f vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ctx. 2023-01-11 16:03:52 +01:00
Francisco Casas
8ff3698699 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_var. 2023-01-11 16:03:51 +01:00
Francisco Casas
0a2732428c vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_struct_field. 2023-01-11 16:03:49 +01:00
Francisco Casas
3a53da7f5b vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_type. 2023-01-11 16:03:48 +01:00
Francisco Casas
cc811dc3c2 vkd3d-shader/hlsl: Rename hlsl_struct_field.modifiers to "storage_modifiers". 2023-01-11 16:03:47 +01:00
Francisco Casas
4dbbb8beb4 vkd3d-shader/hlsl: Rename hlsl_ir_var.modifiers to "storage_modifiers". 2023-01-11 16:03:45 +01:00
Francisco Casas
23bd2d9ad8 vkd3d-shader/hlsl: Rename HLSL_STORAGE_VOLATILE to HLSL_MODIFIER_VOLATILE. 2023-01-11 16:03:43 +01:00
Fabian Maurer
9519fcb562 vkd3d-shader/hlsl: Fix typo (Coverity).
I assume this is a typo, right now it doesn't make sense.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
2023-01-11 16:03:16 +01:00
Francisco Casas
5b1030e0cb vkd3d-shader/hlsl: Use add_unary_arithmetic_expr() in intrinsic_pow().
Using add_unary_arithmetic_expr() instead of hlsl_new_unary_expr()
allows the intrinsic to work with matrices.

Otherwise we get:

E5017: Aborting due to not yet implemented feature: Copying from unsupported node type.

because an HLSL_IR_EXPR reaches split_matrix_copies().
2023-01-11 16:02:59 +01:00
Francisco Casas
6770ecbdf4 vkd3d-shader/hlsl: Introduce elementwise_intrinsic_float_convert_args(). 2023-01-11 16:02:57 +01:00
Francisco Casas
9ceed76a9c vkd3d-shader/hlsl: Convert elementwise intrinsics args to the proper common type. 2023-01-11 16:02:56 +01:00