538 Commits

Author SHA1 Message Date
Giovanni Mascellani
64126a00c3 vkd3d-shader/ir: Give more meaningful names to I/O normalisation levels.
The previous names "not normalised" and "fully normalised" have meanings
which are likely to change with time. OTOH including a description of the
normalisation level in the enumerant seems excessive. Relating
normalisation levels to shader model versions might be a reasonable
compromise.
2024-12-12 17:21:49 +01:00
Elizabeth Figura
09095403ac vkd3d-shader/hlsl: Store swizzles in vsir format.
The previous format matched sm1 and sm4, but if we're going to be feeding
everything through vsir, we want vsir's format.
2024-12-12 17:20:23 +01:00
Elizabeth Figura
474a0ac4e2 vkd3d-shader/hlsl: Use swizzle helpers in more places. 2024-12-12 17:11:53 +01:00
Elizabeth Figura
a905a78a96 vkd3d-shader/hlsl: Use a structure for matrix swizzles. 2024-12-12 17:11:27 +01:00
Victor Chiletto
ed6061dfae vkd3d-shader/hlsl: Drop the _ir_ infix from enum hlsl_loop_unroll_type. 2024-12-12 16:54:07 +01:00
Victor Chiletto
a1d995e740 vkd3d-shader/hlsl: Unroll loops with conditional jumps. 2024-12-12 16:54:04 +01:00
Victor Chiletto
351d58a95b vkd3d-shader/hlsl: Partially defer continue resolution.
We need 'for' iter blocks to be separate for loop unrolling.
2024-12-12 16:41:34 +01:00
Victor Chiletto
5d8448a44e vkd3d-shader/hlsl: Remove loop_unrolling_find_unrollable_loop().
Since loop unrolling doesn't clone the entire program anymore, we can
express it as a hlsl_transform_ir() transform.
2024-12-12 16:41:34 +01:00
Victor Chiletto
de3a365fea vkd3d-shader/hlsl: Do not clone the entire program for loop unrolling. 2024-12-12 16:41:34 +01:00
Victor Chiletto
0a8c4a6fa2 vkd3d-shader/hlsl: Run copy propagation incrementally during loop unrolling. 2024-12-12 16:41:34 +01:00
Victor Chiletto
7bee33f948 vkd3d-shader/hlsl: Allow copy propagation to be stopped early. 2024-12-12 16:41:34 +01:00
Victor Chiletto
3cb9e8dc3b vkd3d-shader/hlsl: Explicitly track the copy propagation state stack. 2024-12-12 16:41:18 +01:00
Shaun Ren
2c9cf7c78b vkd3d-shader/hlsl: Implement normalization of binary expressions.
We normalize binary expressions by attempting to group constants
together, in order to facilitate further simplification of the
expressions.

For any binary operator OP, non-constants x, y, and constants a, b, we
apply the following rewrite rules:

  a OP x -> x OP a, if OP is commutative.

  (x OP a) OP b -> x OP (a OP b), if OP is associative.

  (x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative.

  x OP (y OP a) -> (x OP y) OP a, if OP is associative.

Note that we consider floating point operations to be
non-associative.
2024-12-11 15:32:22 +01:00
Francisco Casas
65b67e84a8 vkd3d-shader/tpf: Remove hlsl_ctx from tpf_compiler.
This completes the hlsl->vsir->tpf translation.
2024-12-10 15:52:52 +01:00
Francisco Casas
f22729461e vkd3d-shader/hlsl: Store hull and domain shader properties in vsir_program.
The alternative to adding the vsir_program->tess_output_primitive and
vsir_program->tess_partitioning fields would be to emit the vsir
DCL_TESSELLATOR_OUTPUT_PRIMITIVE and DCL_TESSELLATOR_PARTITIONING
instructions, like DXIL does, but I think that the preference is to store
these kind of data directly in the vsir_program.
2024-12-10 15:52:52 +01:00
Francisco Casas
347e7a396d vkd3d-shader/hlsl: Generate CTAB outside sm1_generate_vsir().
For consistency with the sm4_generate_rdef() and sm4_generate_vsir()
functions.
2024-12-10 15:52:52 +01:00
Francisco Casas
ca9bb2e089 vkd3d-shader/hlsl: Generate RDEF outside tpf_compile(). 2024-12-10 15:52:52 +01:00
Francisco Casas
ecddc39b31 vkd3d-shader/hlsl: Store SM4 constant buffer declarations in vsir program. 2024-12-10 15:52:52 +01:00
Francisco Casas
aa3a716249 vkd3d-shader/hlsl: Allow lowering separate sampler arrays on deref offset 0. 2024-12-10 15:52:52 +01:00
Francisco Casas
2c9269ac3a vkd3d-shader/hlsl: Allocate samplers by decreasing bind count in SM1. 2024-12-10 15:52:50 +01:00
Francisco Casas
455846a305 vkd3d-shader/hlsl: Support combined samplers from texture arrays. 2024-12-10 15:51:43 +01:00
Francisco Casas
3a6bf3be24 vkd3d-shader/hlsl: Lower separated samplers for SM1.
The combined sampler is created as a SAMPLER instead of a TEXTURE
because that fits all our current infrastructure. The only problem is
that in the CTAB it must appear as a Texture, so the new field
hlsl_type.is_combined_sampler is added.

Co-authored-by: Elizabeth Figura <zfigura@codeweavers.com>
2024-12-10 15:51:43 +01:00
Francisco Casas
d2feb33b47 vkd3d-shader/hlsl: Store SM4 texture declarations in the vsir program. 2024-12-09 16:09:16 +01:00
Francisco Casas
1d290bf5db vkd3d-shader/hlsl: Store SM4 sampler declarations in the vsir program.
Looking at the implementation of shader_sm4_read_dcl_sampler(), vsir
stores the resource index range both in

    vkd3d_shader_instruction.declaration.sampler.range

and in the

    vkd3d_shader_instruction.declaration.sampler.src.reg.idx[1-2]

indexes, so we do the same.

It is also worth noting that for shader models lower than 5.1, vsir
has a normalization on the ins->declaration src register indexes.
Refer to the following comment:

    /* SM5.1 places a symbol identifier in idx[0] and moves
     * other values up one slot. Normalize to SM5.1. */

on shader_sm4_read_param().

This normalization is also added to the generated vsir instructions.
2024-12-09 16:09:16 +01:00
Francisco Casas
37a61bf41a vkd3d-shader/hlsl: Store the global flags in the vsir program. 2024-12-09 16:09:16 +01:00
Francisco Casas
d3108de72a vkd3d-shader/hlsl: Store ROV feature requirement in the vsir_program. 2024-12-09 16:09:16 +01:00
Francisco Casas
198c3dc7b9 vkd3d-shader/hlsl: Remove hlsl_ir_vsir_instruction_ref, again. 2024-11-27 13:03:15 +01:00
Francisco Casas
d6d6f37578 vkd3d-shader/hlsl: Migrate SM4 control flow instructions to the vsir program.
Translate the instructions that contain hlsl_blocks. Also move
other control flow instructions such as HS_CONTROL_POINT_PHASE and
RET to the vsir_program so that we can directly iterate over it now.
2024-11-27 13:02:53 +01:00
Francisco Casas
28ad600b43 vkd3d-shader/hlsl: Store SM4 jumps in the vsir program. 2024-11-27 12:54:15 +01:00
Francisco Casas
4f549155c5 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_RESINFOs in the vsir program. 2024-11-24 00:01:03 +01:00
Francisco Casas
c89f503604 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_SAMPLE_INFOs in the vsir program. 2024-11-24 00:00:46 +01:00
Francisco Casas
4382af6e1b vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_GATHERs in the vsir program. 2024-11-23 23:55:07 +01:00
Francisco Casas
42ce821603 vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_SAMPLEs in the vsir program. 2024-11-23 23:52:24 +01:00
Francisco Casas
52b81f42eb vkd3d-shader/hlsl: Store SM4 HLSL_RESOURCE_LOADs in the vsir program. 2024-11-23 23:49:57 +01:00
Francisco Casas
64bc0515e0 vkd3d-shader/hlsl: Add special allocation rules for FFACE and SAMPLE. 2024-11-23 23:13:13 +01:00
Francisco Casas
ad5377f995 vkd3d-shader/hlsl: Add special allocation rules for PRIMID, RTINDEX, and VPINDEX.
These system values are bound to the same allocation rules as other
semantics: they can share registers with other semantics with the same
interpolation mode and they prefer forming shorter writemasks. However,
for some reason, these don't allow further semantics to share the same
register once allocated, except among themselves.
2024-11-23 23:10:46 +01:00
Anna (navi) Figueiredo Gomes
9f3bbab2f0 vkd3d-shader/hlsl: Implement cast from bool to int for SM1. 2024-11-21 19:28:46 +01:00
Nikolay Sivov
1a6409cd5b vkd3d-shader/hlsl: Add parser support for stream-output object types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-11-21 19:28:46 +01:00
Francisco Casas
13dfccc1c6 vkd3d-shader/hlsl: Store SM4 resource stores in the vsir program. 2024-11-21 19:28:46 +01:00
Francisco Casas
5b4af411f5 vkd3d-shader/hlsl: Store SM4 loads in the vsir program. 2024-11-21 19:28:46 +01:00
Francisco Casas
874ca85a95 vkd3d-shader/hlsl: Store SM4 stores in the vsir program. 2024-11-21 19:28:46 +01:00
Elizabeth Figura
683e11aece vkd3d-shader/hlsl: Silence a spurious -Wmaybe-uninitialized in sm4_generate_vsir_instr_dcl_semantic(). 2024-11-14 14:12:13 +01:00
Francisco Casas
5df836c513 vkd3d-shader/hlsl: Store SM4 MOD in the vsir program. 2024-11-06 22:49:12 +01:00
Francisco Casas
30bc6965a2 vkd3d-shader/hlsl: Store SM4 DOT in the vsir program. 2024-11-06 22:48:13 +01:00
Francisco Casas
e8b373e3ff vkd3d-shader/hlsl: Store SM4 DIV in the vsir program. 2024-11-06 22:47:42 +01:00
Francisco Casas
24f4308982 vkd3d-shader/hlsl: Store SM4 MUL in the vsir program. 2024-11-06 22:45:46 +01:00
Francisco Casas
e4d36bd855 vkd3d-shader/hlsl: Store SM4 SAT in the vsir program. 2024-11-06 22:45:23 +01:00
Francisco Casas
2e3f4a01bf vkd3d-shader/hlsl: Store SM4 RCP in the vsir program. 2024-11-06 22:40:50 +01:00
Francisco Casas
3c4889add3 vkd3d-shader/hlsl: Store SM4 SIN and COS in the vsir program. 2024-11-06 22:38:04 +01:00
Francisco Casas
befba8e813 vkd3d-shader/hlsl: Store SM4 casts in the vsir program. 2024-11-06 22:27:49 +01:00