Francisco Casas
8fca801591
vkd3d-shader/tpf: Use the extra_bits field for _nz on discard.
2024-04-09 12:27:03 -05:00
Francisco Casas
3a0a4b625f
vkd3d-shader/hlsl: Merge HLSL_OP3_MOVC into HLSL_OP3_TERNARY.
2024-04-09 12:27:02 -05:00
Zebediah Figura
2247288003
vkd3d-shader/tpf: Set the user-packed flag for sm5.0 resources as well.
2024-03-27 22:36:39 +01:00
Zebediah Figura
7b87895289
vkd3d-shader/tpf: Write the component count as the column count for structs.
2024-03-27 22:36:37 +01:00
Zebediah Figura
5bf23cb2f5
vkd3d-shader/tpf: Explicitly write the class and base type for non-numeric types.
...
Avoid relying on that information being stored in the hlsl_type.
2024-03-27 22:36:36 +01:00
Zebediah Figura
34e9c101e8
vkd3d-shader/tpf: Do not write structs with no numeric fields into the RDEF.
2024-03-27 22:36:35 +01:00
Zebediah Figura
622fcda9ee
vkd3d-shader/tpf: Do not write non-numeric struct fields into the RDEF.
2024-03-27 22:36:33 +01:00
Henri Verbeet
abf76372e0
vkd3d-shader/ir: Pass a struct vsir_program to vsir_validate().
2024-03-14 23:24:29 +01:00
Conor McCarthy
6dd54eeb09
vkd3d-shader/spirv: Support zero-initialisation for workgroup memory.
2024-03-14 22:48:41 +01:00
Giovanni Mascellani
1690b0b554
vkd3d-shader: Remove the bytecode fields from vkd3d_shader_desc.
2024-03-11 22:09:32 +01:00
Giovanni Mascellani
204c8afb9c
vkd3d-shader/dxbc: Remove flag is_dxil.
...
The full shader profile is already available in vsir_program.
2024-03-11 22:09:31 +01:00
Giovanni Mascellani
470d83a9da
vkd3d-shader: Move shader signatures to vsir_program.
2024-03-11 22:09:31 +01:00
Giovanni Mascellani
56dc0c9842
vkd3d-shader/dxbc: Decouple vkd3d_shader_desc from DXBC parsing.
2024-03-11 22:09:30 +01:00
Giovanni Mascellani
5204b92fa0
vkd3d-shader/tpf: Remove a useless parameter to shader_sm4_init().
2024-03-11 22:09:28 +01:00
Zebediah Figura
9177df883e
vkd3d-shader/hlsl: Write the SFI0 section and "REQUIRES_ROVS" flag when ROVs are used.
2024-03-04 22:34:46 +01:00
Henri Verbeet
7029d821be
configure: Build with -Wtype-limits.
...
libs/vkd3d-shader/tpf.c: In function ‘write_sm4_unary_op_with_two_destinations’:
libs/vkd3d-shader/tpf.c:4489:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
assert(1 - dst_idx >= 0);
^~
libs/vkd3d-shader/tpf.c: In function ‘write_sm4_binary_op_with_two_destinations’:
libs/vkd3d-shader/tpf.c:4549:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
assert(1 - dst_idx >= 0);
^~
2024-02-22 22:46:22 +01:00
Henri Verbeet
d4223a03c8
vkd3d-shader/hlsl: Replace HLSL_MODIFIER_RASTERIZER_ORDERED with a hlsl_type.e.resource flag.
2024-02-21 23:23:08 +01:00
Henri Verbeet
49d14613a5
vkd3d-shader/hlsl: Introduce hlsl_type.e.resource.
2024-02-21 23:23:06 +01:00
Evan Tang
7b41abaa1b
vkd3d-shader/hlsl: Support SV_PrimitiveID in pixel shaders.
2024-02-19 21:12:23 +01:00
Francisco Casas
c249461e97
vkd3d-shader/hlsl: Parse Buffer types.
2024-02-19 21:11:55 +01:00
Evan Tang
ee867bd470
vkd3d-shader/hlsl: Parse rasteriser-ordered view types.
2024-02-15 23:29:46 +01:00
Henri Verbeet
d38221bd68
vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_src_params().
2024-02-01 00:08:23 +01:00
Henri Verbeet
47ec24ebad
vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_dst_params().
2024-02-01 00:08:22 +01:00
Giovanni Mascellani
1f536238a8
vkd3d-shader: Use 64 bit swizzles for 64 bit data types in VSIR.
...
The handling of write masks and swizzles for 64 bit data types is
currently irregular: write masks are always 64 bit, while swizzles
are usually 32 bit, except for SSA registers with are 64 bit.
With this change we always use 64 bit swizzles, in order to make
the situation less surprising and make it easier to convert
registers between SSA and TEMP.
64 bit swizzles are always required to have X in their last two
components.
2024-01-29 22:33:33 +01:00
Henri Verbeet
98c6e85b33
vkd3d-shader/ir: Store control point counts in struct vsir_program.
2024-01-23 20:27:32 +01:00
Giovanni Mascellani
dc56320b31
vkd3d-shader/tpf: Support SV_ViewportArrayIndex in pixel and vertex shaders.
2024-01-22 22:19:14 +01:00
Giovanni Mascellani
3a90f3e29d
vkd3d-shader/tpf: Support SV_InstanceID in vertex shaders.
2024-01-22 22:19:13 +01:00
Giovanni Mascellani
b500381b5c
vkd3d-shader/tpf: Support SV_RenderTargetArrayIndex in pixel and vertex shaders.
2024-01-22 22:19:12 +01:00
Henri Verbeet
adc02eada8
vkd3d-shader/ir: Store the temporary register count in struct vsir_program.
2024-01-22 22:18:53 +01:00
Henri Verbeet
23dcd4f22b
vkd3d-shader/ir: Store the shader version in struct vsir_program.
2024-01-22 22:18:50 +01:00
Henri Verbeet
fc9043be3c
vkd3d-shader/ir: Introduce struct vsir_program.
2024-01-22 22:18:48 +01:00
Conor McCarthy
c40093474e
vkd3d-shader/tpf: Validate sysvals in index range declarations.
2024-01-17 22:29:01 +01:00
Conor McCarthy
418e8d8100
vkd3d-shader/ir: Expand index range write masks to cover all element masks.
...
For example, this occurred in a shader:
reg_idx write_mask
0 xyz
1 xyzw
2 xyzw
3 xyz
The dcl_indexrange instruction covered only xyz, so once merged, searching for
xyzw failed.
It is impossible to declare an input array where elements have different
component counts, but the optimiser can create this case. One way for
this to occur is to dynamically index input values via a local array
containing copies of the input values. The optimiser converts this to
dynamically indexed inputs.
2024-01-17 22:28:56 +01:00
Conor McCarthy
559d9d4ee0
vkd3d-shader/ir: Include an initial label instruction in the first control flow block.
2024-01-17 22:28:41 +01:00
Conor McCarthy
b4b2b0d3ac
vkd3d-shader/spirv: Declare indexable temps as Private unless function scope is specified.
2024-01-17 22:28:39 +01:00
Henri Verbeet
68b898fcb6
vkd3d-shader/tpf: Store the "precise" mask as a uint32_t in shader_sm4_read_instruction().
2024-01-15 19:58:22 +01:00
Henri Verbeet
ad2af68d2a
vkd3d-shader/tpf: Store the "recognized_bits" mask as a uint32_t in shader_sm4_read_instruction_modifier().
2024-01-15 19:58:21 +01:00
Henri Verbeet
b8903f5526
vkd3d-shader/tpf: Store the current token as a uint32_t in shader_sm4_read_dst_param().
2024-01-15 19:58:20 +01:00
Henri Verbeet
fd854bc0c0
vkd3d-shader/tpf: Store the current token as a uint32_t in shader_sm4_read_src_param().
2024-01-15 19:58:19 +01:00
Henri Verbeet
c5facd4e03
vkd3d-shader/tpf: Store the "addressing" token as a uint32_t in shader_sm4_read_param().
2024-01-15 19:58:18 +01:00
Henri Verbeet
b1c538e0fe
vkd3d-shader/tpf: Store the "components" token as a uint32_t in shader_sm4_read_dcl_resource().
2024-01-15 19:58:17 +01:00
Henri Verbeet
9896394220
vkd3d-shader/tpf: Pass a uint32_t modifier token to shader_sm4_read_instruction_modifier().
2024-01-15 19:58:15 +01:00
Giovanni Mascellani
78d95889bd
vkd3d-shader: Make *src and *dst mutable in vkd3d_shader_instruction.
...
They were originally made const because no optimization/normalization
pass existed. Now having to cast away const all the time is becoming
more and more burdening.
2024-01-11 23:05:11 +01:00
Henri Verbeet
60842b7181
vkd3d-shader/ir: Store source parameter swizzles as a uint32_t.
2024-01-04 22:23:51 +01:00
Henri Verbeet
e33d3b3954
vkd3d-shader/ir: Rename the "immconst_uint" field of struct vkd3d_shader_register to "immconst_u32".
...
For consistency with the rest of vkd3d-shader; e.g. put_u32() and
read_u32().
2024-01-03 22:37:39 +01:00
Henri Verbeet
8a1de71fb1
vkd3d-shader/ir: Pass a uint32_t swizzle to vkd3d_swizzle_get_component().
2023-12-14 23:19:49 +01:00
Henri Verbeet
3759186193
vkd3d-shader/ir: Pass a uint32_t write mask to vkd3d_write_mask_64_from_32().
2023-12-13 22:33:06 +01:00
Henri Verbeet
713adaa56a
vkd3d-shader/ir: Pass a uint32_t write mask to vkd3d_write_mask_component_count().
2023-12-13 22:33:04 +01:00
Zebediah Figura
cabf9996f9
vkd3d-shader/tpf: Do not uninvert used masks for domain shader patch constants.
2023-12-11 23:18:42 +01:00
Conor McCarthy
cb88844a3d
vkd3d-shader: Add a register index to struct vkd3d_shader_immediate_constant_buffer.
2023-12-07 21:56:47 +01:00
Conor McCarthy
ffae57eb8d
vkd3d-shader/dxil: Support null constant arrays.
2023-12-07 21:56:43 +01:00
Nikolay Sivov
6a4a9a4518
vkd3d-shader/hlsl: Handle 'linear centroid' modifier.
2023-11-28 00:10:12 +01:00
Zebediah Figura
10957bebbf
vkd3d-shader/tpf: Remove an unnecessary local variable declaration.
...
Found with -Wshadow.
2023-11-28 00:09:56 +01:00
Conor McCarthy
85d5f83fb7
vkd3d-shader/dxil: Implement default address space global variables.
2023-11-22 22:07:54 +01:00
Nikolay Sivov
88caf87789
vkd3d-shader/hlsl: Add a helper to check for a numeric type.
2023-11-15 21:48:49 +01:00
Henri Verbeet
215a2c4ede
vkd3d-shader/ir: Introduce vsir_register_is_descriptor().
2023-11-13 23:19:10 +01:00
Conor McCarthy
22960753e9
vkd3d-shader/spirv: Introduce orderedness to comparison instructions.
2023-11-10 20:23:51 +01:00
Nikolay Sivov
dd6a9135f4
vkd3d-shader/hlsl: Implement tex2Dproj().
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-10 20:23:41 +01:00
Nikolay Sivov
494f681bf6
vkd3d-shader/tpf: Add support for ceil().
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:38 +01:00
Zebediah Figura
0058764f01
vkd3d-shader: Store the control point counts in struct vkd3d_shader_desc.
2023-11-07 22:26:49 +01:00
Francisco Casas
0ef25ad137
vkd3d-shader/tpf: Support relative addressing for indexable temps in SM4.
...
For relative addressing, the vkd3d_shader_registers must point to
another vkd3d_shader_src_param. For now, use the sm4_instruction to save
them, since the only purpose of this struct is to be used as paramter
for write_sm4_instruction.
2023-11-07 22:25:49 +01:00
Francisco Casas
281796c526
vkd3d-shader/tpf: Move sm4_register_from_node() up.
2023-11-07 22:25:48 +01:00
Francisco Casas
e10d41d799
vkd3d-shader/tpf: Support writing relative addressing indexes.
2023-11-07 22:25:47 +01:00
Francisco Casas
617a20bffc
vkd3d-shader/tpf: Write register index addressing.
2023-11-07 22:25:45 +01:00
Francisco Casas
043526a9f7
vkd3d-shader/tpf: Encode dst and src registers using the same function.
...
This function will also be required to encode rel_addr registers.
2023-11-07 22:25:44 +01:00
Henri Verbeet
aa5380f32a
vkd3d-shader/tpf: Do not write RDEF constant buffer entries for HLSL_CLASS_OBJECT variables.
...
RWBuffer objects would trigger a vkd3d_unreachable() in sm4_base_type().
It would be easy enough to add the required case there, but (manual,
unfortunately) tests show that we aren't supposed to write constant
buffer entries for objects in the first place, as you'd expect.
This particular path ends up being exercised by vkd3d's internal UAV
clear shaders, but unfortunately it looks like our RDEF data may have
more issues; the ability to write tests for it would seem helpful.
2023-11-06 23:09:47 +01:00
Francisco Casas
98b5eb474a
vkd3d-shader/tpf: Don't pass 0x4 as mask for vec4 constant src registers.
...
Co-authored-by: Evan Tang <etang@codeweavers.com>
Evan Tang reported that new fixmes appeared on the shader_runner when
running some of his tests after
f50d0ae2cb
.
vkd3d:652593:fixme:shader_sm4_read_src_param Unhandled mask 0x4.
The change to blame seems to be this added line in
sm4_src_from_constant_value().
+ src->swizzle = VKD3D_SHADER_NO_SWIZZLE;
On tpf binaries the last 12 bits of each src register in an instruction
specify the swizzle, and there are 5 possible combinations:
Dimension NONE
-------- 00
Dimension SCALAR
-------- 01
Dimension VEC4, with a 4 bit writemask:
---- xxxx 00 01
Dimension VEC4, with an 8 bit swizzle:
xx xx xx xx 01 01
Dimension VEC4, with a 2bit scalar dimension number:
------ xx 10 01
So far, we have only seen src registers use 4 bit writemasks in a
single case: for vec4 constants, and it is always zero.
So we expect this:
---- 0000 00 01
Now, I probably wanted to initialize src->swizzle to zero when writing
constants, but VKD3D_SHADER_NO_SWIZZLE is not zero, it is actually the
default swizzle:
11 10 01 00
And the last 4 bits (0x4) get written in the mask part, which causes
the reader to complain.
2023-11-06 23:09:10 +01:00
Giovanni Mascellani
26e4191d4b
vkd3d-shader/ir: Validate the register dimension.
2023-11-02 18:22:47 +01:00
Zebediah Figura
15b69721de
vkd3d-shader/tpf: Set the interpolation mode for signature elements.
2023-10-31 21:59:38 +01:00
Francisco Casas
eef2163375
vkd3d-shader/tpf: Declare indexable temps.
...
If var->indexable, then the variable is given a unique register number,
regardless of its lifetime.
2023-10-31 21:59:22 +01:00
Nikolay Sivov
bc2a4ee66a
vkd3d-shader/tpf: Write out 'switch' statements.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-31 21:59:05 +01:00
Conor McCarthy
1e5f91b371
vkd3d-shader: Emit IR CBV declaration sizes in bytes.
...
DXIL declares CBV sizes in bytes and they are not aligned to 16 bytes.
2023-10-19 23:07:43 +02:00
Nikolay Sivov
e242b46922
vkd3d-shader/tpf: Convert some of the semantic names to system values names when in compatibility mode.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-19 23:03:23 +02:00
Conor McCarthy
06f8a88466
vkd3d-shader: Define more global flags.
2023-10-17 22:18:23 +02:00
Francisco Casas
432fa8fa8f
vkd3d-shader/tpf: Avoid translations to D3DDECLUSAGE and back (clangd).
2023-10-12 23:27:19 +02:00
Francisco Casas
f0da419a8c
vkd3d-shader: Remove unnecessary fallthroughs (clangd).
2023-10-12 23:27:19 +02:00
Conor McCarthy
df4e1b7393
vkd3d-shader/dxil: Read immediate constant arrays.
2023-10-11 22:21:19 +02:00
Nikolay Sivov
3af629cf8c
vkd3d-shader/tpf: Output interpolation modifiers for input declarations.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:31 +02:00
Nikolay Sivov
c5414fa92f
vkd3d-shader/tpf: Write 'continue' instruction.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:17 +02:00
Henri Verbeet
98d158d004
vkd3d-shader/tpf: Get rid of the output map.
...
Map output registers in the backend instead, as needed.
2023-10-09 21:57:46 +02:00
Francisco Casas
014960b64b
vkd3d-shader/tpf: Use lookup table for opcode_info_from_sm4().
...
Makes get_opcode_info() and thus, tpf reading a little faster.
2023-10-05 16:16:27 +02:00
Francisco Casas
88b644a11d
vkd3d-shader/tpf: Don't store sm4 instruction extra bits in the opcode.
...
Adding extra bits to instr->opcode doesn't seem correct, given that it
is an enum.
For instance, get_opcode_info() would return NULL if additional bits are
added to instr->opcode. This is not a problem now because that function
is called when reading and not writing.
2023-10-05 16:16:24 +02:00
Francisco Casas
0a5fa80f02
vkd3d-shader/tpf: Apply mask to swizzle when swizzle type is scalar.
...
In native's output, for scalar swizzles only the first component of the
swizzle is written, the others are left as zero.
2023-10-05 16:16:21 +02:00
Francisco Casas
f06169afc5
vkd3d-shader/tpf: Don't calculate instruction size in advance.
...
Co-authored-by: Henri Verbeet <hverbeet@codeweavers.com>
2023-10-05 16:16:19 +02:00
Francisco Casas
4ab6572be7
vkd3d-shader/hlsl: Replace hlsl_type_get_regset() uses with hlsl_deref_get_regset().
2023-10-05 16:15:37 +02:00
Francisco Casas
cd0e3786c3
vkd3d-shader/hlsl: Avoid hlsl_type_get_regset() in sm4_get_extern_resources().
2023-10-05 16:15:28 +02:00
Francisco Casas
dfce1e7f4a
vkd3d-shader/hlsl: Make regset an output argument in hlsl_type_get_component_offset().
...
Components only span across a single regset, so instead of expecting the
regset as input for the offset, hlsl_type_get_component_offset() can
actually retrieve it.
2023-10-05 16:15:26 +02:00
Alistair Leslie-Hughes
71715cc434
vkd3d-shader: Fix compiler warning.
...
vkd3d-shader/tpf.c:3810:39: warning: passing argument 2 of ‘sm4_register_from_node’ from incompatible pointer type [-Wincompatible-pointer-types]
vkd3d-shader/tpf.c:4750:59: warning: passing argument 3 of ‘sm4_register_from_deref’ from incompatible pointer type [-Wincompatible-pointer-types]
Change to use uint32_t as requested.
2023-10-05 16:14:44 +02:00
Francisco Casas
c92772657f
vkd3d-shader/tpf: Replace sm4_src_register with vkd3d_shader_src_param.
2023-10-03 21:27:48 +02:00
Francisco Casas
13f62e60e1
vkd3d-shader/tpf: Remove sm4_src_register.swizzle_type.
2023-10-03 21:27:47 +02:00
Francisco Casas
32f03468fc
vkd3d-shader/tpf: Make sm4_src_register.mod a vkd3d_shader_src_modifier enum.
2023-10-03 21:27:45 +02:00
Francisco Casas
f50d0ae2cb
vkd3d-shader/tpf: Store vkd3d-shader swizzles in sm4_src_register.swizzle.
2023-09-28 23:13:16 +02:00
Francisco Casas
ef9ec28eb0
vkd3d-shader/tpf: Replace sm4_dst_register with vkd3d_shader_dst_param.
2023-09-28 23:13:14 +02:00
Francisco Casas
d41d8f8771
vkd3d-shader/tpf: Rename sm4_dst_register.writemask to write_mask.
2023-09-28 23:13:12 +02:00
Francisco Casas
8e0fe29bfc
vkd3d-shader/tpf: Replace sm4_register with vkd3d_shader_register.
2023-09-27 22:34:31 +02:00
Francisco Casas
10bbc7eda5
vkd3d-shader/tpf: Move sm4_register.mod to sm4_src_register.
2023-09-27 22:34:30 +02:00
Francisco Casas
8124ba3a54
vkd3d-shader/tpf: Put sm4_register.immconst_uint inside a union.
2023-09-27 22:34:28 +02:00
Francisco Casas
0c8b74cb39
vkd3d-shader/tpf: Turn sm4_register.dim into an enum vkd3d_shader_dimension.
2023-09-27 22:34:26 +02:00
Francisco Casas
33f47c5ae9
vkd3d-shader/tpf: Parse register dimension for all register types.
2023-09-26 22:07:04 +02:00
Francisco Casas
e904660497
vkd3d-shader: Turn vkd3d_shader_register.immconst_type into vkd3d_shader_register.dimension.
2023-09-26 22:07:04 +02:00