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
cf17882189
vkd3d-shader/hlsl: Support offset argument for the texture Load() method.
2023-01-24 18:10:36 +01:00
Zebediah Figura
9c817e5e6d
vkd3d-shader/hlsl: Forbid recursive calls.
2023-01-19 19:16:27 +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
6fbf2b3e75
vkd3d-shader/hlsl: Parse 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
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
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
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
Francisco Casas
a7bb5a0835
vkd3d-shader/hlsl: Support smoothstep() intrinsic.
2023-01-11 16:02:52 +01:00
Francisco Casas
09e7218539
vkd3d-shader/hlsl: Support transpose() intrinsic.
2023-01-11 16:02:50 +01:00
Henri Verbeet
1eaf73147c
Release 1.6.
2022-12-07 16:08:16 +01:00
Conor McCarthy
1b11b57652
vkd3d-shader: Introduce DESCRIPTOR_INFO_FLAG_UAV_ATOMICS and always declare UAV images with known type for atomic ops.
...
Atomic ops on images with Unknown type will cause SPIR-V validation failure,
and assertion failure in Mesa debug builds. D3D12 allows atomics on typed
buffers, and this requires a distinction to be made between UAV reads and
atomic ops.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53874
2022-11-21 18:28:54 +01:00
Francisco Casas
43631bde4d
vkd3d-shader/hlsl: Revert expr_compatible_data_types() args names to "t1" and "t2".
...
Unlike compatible_data_types() and implicit_compatible_data_types(),
this function is intended to be symmetrical. So it makes sense to
preserve the names "t1" and "t2" for the arguments.
2022-11-18 22:29:07 +01:00
Francisco Casas
bd501ce336
vkd3d-shader/hlsl: Don't produce a parse error on empty buffer_body.
2022-11-18 22:29:06 +01:00
Francisco Casas
f100f5b726
vkd3d-shader/hlsl: Check for non-static object references on resource stores.
2022-11-18 22:29:04 +01:00
Francisco Casas
f21693b284
vkd3d-shader/hlsl: Use reg_size as component count when allocating a single register.
...
Otherwise, for instance, the added test results in:
debug_hlsl_writemask: Assertion `!(writemask & ~VKD3DSP_WRITEMASK_ALL)' failed.
Which happens in allocate_variable_temp_register() when the variable's
type reg_size is <= 4 but its component count is larger, which may
happen if it contains objects.
2022-11-10 22:48:26 +01:00
Francisco Casas
90e6e418a3
vkd3d-shader/hlsl: Use the base type of the array elements in write_sm1_type().
2022-11-10 22:48:23 +01:00
Francisco Casas
6873b71304
vkd3d-shader/hlsl: Validate that statics don't contain both resources and numerics.
2022-11-10 22:48:21 +01:00
Francisco Casas
2fa913ccaa
vkd3d-shader/hlsl: Validate that extern structs don't contain objects SM < 5.
...
It is worth noting that these checks should also be included for
declarations inside cbuffers, once they are implemented.
2022-11-10 22:48:19 +01:00
Francisco Casas
3153ce3145
vkd3d-shader/hlsl: Don't allocate object types as constant registers.
2022-11-10 22:48:16 +01:00
Francisco Casas
6f6ba8aa56
vkd3d-shader/hlsl: Properly free new store node memory if init_deref() fails.
2022-11-10 22:48:11 +01:00
Zebediah Figura
3857ca06fa
vkd3d-shader/hlsl: Write SM4 dcl_thread_group instructions.
2022-11-08 20:53:08 +01:00
Zebediah Figura
718c79b823
vkd3d-shader/hlsl: Parse the numthreads attribute.
2022-11-08 20:53:04 +01:00
Zebediah Figura
d6799bd5d3
vkd3d-shader/hlsl: Parse function attributes.
2022-11-08 20:53:03 +01:00
Zebediah Figura
da56f41ceb
vkd3d-shader/hlsl: Use hlsl_new_synthetic_var() in hlsl_new_func_decl().
2022-11-08 20:53:01 +01:00
Zebediah Figura
1019bbead6
vkd3d-shader/hlsl: Add a hlsl_fixme() for compute shader thread counts.
...
In particular so that we don't cause test crashes by outputting invalid compute
shaders.
2022-11-08 20:52:59 +01:00
Zebediah Figura
520c7457a9
vkd3d-shader/sm4: Use a flat array to store destination types.
...
This cuts about 12 kB off of the 64-bit build.
2022-11-08 20:52:36 +01:00
Zebediah Figura
4173158c8b
vkd3d-shader/sm4: Use a flat array to store source types.
2022-11-08 20:52:34 +01:00
Zebediah Figura
e2aed38509
vkd3d-shader/spirv: Avoid using DXBC-specific definitions.
2022-11-08 20:52:32 +01:00
Zebediah Figura
ba08825ccd
vkd3d-shader/sm4: Use the VKD3D_DXBC_MAX_SOURCE_COUNT macro where possible.
2022-11-08 20:52:31 +01:00
Zebediah Figura
35b48a8b04
vkd3d-shader/spirv: Rename struct vkd3d_dxbc_compiler to struct spirv_compiler.
...
We would like to generate SPIR-V for input formats other than DXBC.
The "vkd3d_" prefix is dropped, partly to make names shorter, and partly to help
clarify what is an internal function.
I prefer avoiding the vkd3d_* prefix on all internal functions, for these
reasons. However, I'm open to restoring it.
2022-11-08 20:52:29 +01:00
Zebediah Figura
58c7c4b806
vkd3d-common: Always prefix debug output with "vkd3d".
...
Make it clear which library the debug output is coming from, without relying on
the function name including "vkd3d".
2022-11-08 20:52:27 +01:00
Zebediah Figura
c416627e64
vkd3d-shader/hlsl: Propagate copies for resource store instructions.
2022-10-31 22:07:47 +01:00
Zebediah Figura
9bdae4dfaa
vkd3d-shader/hlsl: Write SM4 UAV store instructions.
2022-10-31 22:07:45 +01:00
Zebediah Figura
03f9d16047
vkd3d-shader/hlsl: Parse UAV stores.
2022-10-31 22:07:44 +01:00
Zebediah Figura
0a2aaa690e
vkd3d-shader/hlsl: Implement typed UAV loads.
2022-10-31 22:07:43 +01:00
Zebediah Figura
12e397de9a
vkd3d-shader/hlsl: Write SM4 UAV declarations.
2022-10-31 22:07:41 +01:00
Zebediah Figura
2ec67e0f10
vkd3d-shader/hlsl: Allocate UAVs.
2022-10-31 22:07:40 +01:00
Francisco Casas
5af7316a12
vkd3d-shader/hlsl: Support explicit cast between component-wise compatible types.
2022-10-25 21:25:58 +02:00
Francisco Casas
d21fd584b1
vkd3d-shader/hlsl: Support implicit casts between component-wise equal types.
2022-10-25 21:25:57 +02:00
Francisco Casas
1c77811648
vkd3d-shader/hlsl: Remove incorrect criteria for accepting implicit casts.
2022-10-25 21:25:55 +02:00
Francisco Casas
d93ce28995
vkd3d-shader/hlsl: Handle complex types in add_cast().
...
This extends the support of this function, whether doing broadcasts or
component-wise casts, to struct and array types.
2022-10-25 21:25:51 +02:00
Francisco Casas
0a345a2b73
vkd3d-shader/hlsl: Rename "t1" and "t2" arguments as "src" and "dst".
2022-10-25 21:25:49 +02:00
Brendan Shanks
963ea98a52
vkd3d-common: Add a Windows implementation of vkd3d_set_thread_name().
2022-10-25 21:25:38 +02:00
Zebediah Figura
0ef04659c7
vkd3d-shader/hlsl: Parse UAV types.
2022-10-19 21:59:55 +02:00
Zebediah Figura
fea50d243c
vkd3d-shader/hlsl: Parse texture index expressions.
2022-10-19 21:59:55 +02:00
Zebediah Figura
7115a94063
vkd3d-shader/hlsl: Cast array indices inside of add_array_load().
...
Mostly in the interest of keeping the yacc code as simple as possible.
2022-10-19 21:59:55 +02:00
Giovanni Mascellani
0a07ac6f88
vkd3d-shader/hlsl: Lower float modulus.
...
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:17 +02:00
Giovanni Mascellani
eb119878f7
vkd3d-shader/hlsl: Lower int modulus.
...
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:15 +02:00
Giovanni Mascellani
85856473f6
vkd3d-shader/hlsl: Write SM4 fractional part instructions.
...
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:13 +02:00
Francisco Casas
5a1b0dbf44
vkd3d-shader/hlsl: Always go through implicit conversion in assignments.
...
Otherwise we silently skip some type checks.
2022-10-17 17:58:56 +02:00
Giovanni Mascellani
eb7b594002
vkd3d-shader/hlsl: Lower int division.
2022-10-17 17:58:17 +02:00
Giovanni Mascellani
4c13ae5764
vkd3d-shader/hlsl: Lower int absolute value.
2022-10-17 17:58:14 +02:00
Giovanni Mascellani
5442f4236c
vkd3d-shader/hlsl: Write SM4 square root instructions.
2022-10-17 17:58:12 +02:00
Giovanni Mascellani
8e5aefb309
vkd3d-shader/hlsl: Parse length() intrinsic.
2022-10-17 17:58:09 +02:00
Zebediah Figura
6b45f290f7
vkd3d-shader/hlsl: Pass a location pointer to init_node().
...
Instead of a flat location structure.
2022-10-12 21:58:03 +02:00
Zebediah Figura
20fc4375ad
vkd3d-shader/hlsl: Introduce a hlsl_new_expr() helper.
2022-10-12 21:58:01 +02:00
Zebediah Figura
1e10b5e616
vkd3d-shader/hlsl: Write SM4 reinterpret instructions.
2022-10-12 21:57:59 +02:00
Zebediah Figura
2d4d2e1244
vkd3d-shader/hlsl: Parse the asuint() intrinsic.
2022-10-12 21:57:57 +02:00
Giovanni Mascellani
1655d309bd
vkd3d-shader/hlsl: Write SM4 rsq instructions.
2022-10-10 21:13:04 +02:00
Giovanni Mascellani
d600f0488e
vkd3d-shader/hlsl: Parse normalize intrinsic.
...
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-10 21:13:03 +02:00
Zebediah Figura
b74a546034
vkd3d-shader/hlsl: Use hlsl_new_constant() in more places.
2022-09-28 19:11:08 +02:00
Zebediah Figura
f8da100052
vkd3d-shader/hlsl: Use hlsl_new_int_constant() in the "primary_expr" rule.
2022-09-28 19:11:05 +02:00
Zebediah Figura
3fc2fdc37f
vkd3d-shader/hlsl: Introduce a hlsl_new_bool_constant() helper.
2022-09-28 19:11:02 +02:00
Zebediah Figura
4c5fd9c7b9
vkd3d-shader/hlsl: Introduce a hlsl_new_float_constant() helper.
2022-09-28 19:10:58 +02:00
Zebediah Figura
15a0b44ada
vkd3d-shader/hlsl: Pass the arguments to hlsl_new_resource_load() as an indirect structure.
...
The function has far too many arguments, including multiple different arguments
with the same type. Use a structure for clarity and to avoid errors.
Merge hlsl_new_sample_lod() into hlsl_new_resource_load() accordingly.
2022-09-27 20:14:54 +02:00
Zebediah Figura
fb724d60e3
vkd3d-shader/hlsl: Make the source parameter to hlsl_copy_deref() const.
2022-09-27 20:14:53 +02:00
Zebediah Figura
e3123f5bd0
vkd3d-shader/hlsl: Pass only a template string to hlsl_new_synthetic_var().
...
Synthesize the internal name from the template inside of this function.
2022-09-27 20:14:51 +02:00
Zebediah Figura
991cddd139
vkd3d-shader/hlsl: Handle failure from hlsl_copy_deref().
2022-09-27 20:14:49 +02:00
Zebediah Figura
32999fc12b
vkd3d-common: Tweak the WARN for VKD3D_ERROR_INVALID_SHADER.
...
vkd3d-shader does not consume only bytecode anymore.
2022-09-27 20:14:42 +02:00