6869 Commits

Author SHA1 Message Date
Henri Verbeet
cdf6100fe5 tests: Add yet more overload resolution tests. 2024-12-16 17:09:40 +01:00
Elizabeth Figura
5827197246 tests/shader_runner: Don't bother distinguishing directive substrings.
Consider ']' a terminator for any string.
2024-12-12 17:28:45 +01:00
Elizabeth Figura
830bdd0037 tests/shader_runner: Use a separate variable for shader type. 2024-12-12 17:26:49 +01:00
Elizabeth Figura
edb36c078f tests/shader_runner: Use is_todo instead of separate shader states. 2024-12-12 17:26:37 +01:00
Giovanni Mascellani
dd0ed989a1 vkd3d-shader/d3dbc: Normalise I/O register write masks when not disassembling.
Sometimes SM1-3 shaders contain write masks that exceed the
signature element masks. That happens because SM1-3 shaders do not
have a concept of signature and signature masks, and OTOH aren't
always able to express any given write mask.

In VSIR we don't want to deal with I/O register masks exceeding the
corresponding signature element mask or usage mask, because, for
instance, for higher shader models it can complicate dealing with
DCL_INDEX_RANGE. In order to have uniform rules for all shader
models we normalise masks coming from SM1-3 shaders.

We don't do that normalisation when disassembling, in order to
preserve the expected output.
2024-12-12 17:21:49 +01:00
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
Elizabeth Figura
70e2148fcb vkd3d-shader/hlsl: Document matrix swizzles. 2024-12-12 16:56:52 +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
6c3a60cc54 vkd3d-shader/hlsl: Constant fold casts to boolean. 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
Elizabeth Figura
77843aa837 vkd3d-shader/ir: Always initialise "*control_point_count" in vsir_signature_from_register_type().
Avoid a spurious -Wmaybe-uninitialized warning.
2024-12-11 15:33:06 +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
58d318719c tests: Test sampler array allocation. 2024-12-10 15:51:34 +01:00
Francisco Casas
a0a555878f tests: Add additional sampler allocation tests for SM1. 2024-12-10 14:02:00 +01:00
Giovanni Mascellani
c1df64b3a6 vkd3d-shader/ir: Check that signature elements do not conflict with each other. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
b6a00579a2 vkd3d-shader/ir: Validate the signature element register index, for some sysvals. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
59a3a8e2d6 vkd3d-shader/ir: Validate the signature element stream index. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
db5a3197b7 vkd3d-shader/ir: Validate the register index and count for signature elements. 2024-12-09 16:11:34 +01:00
Giovanni Mascellani
267c70fa55 vkd3d-shader/ir: Check that signature element masks are left-aligned with in a DCL_INDEX_RANGE. 2024-12-09 16:10:47 +01:00
Giovanni Mascellani
703da18955 vkd3d-shader/ir: Check that the DCL_INDEX_RANGE effective mask stabilizes after one iteration. 2024-12-09 16:10:47 +01:00
Henri Verbeet
bbeecfc835 vkd3d: Drop smaller pools in d3d12_command_allocator_reset_descriptor_pool_array().
Effectively consolidating them.
2024-12-09 16:10:22 +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
d9c4a257c2 vkd3d-shader/dxbc: Parse the SFI0 ROV requirement. 2024-12-09 16:09:16 +01:00
Henri Verbeet
b484288a82 vkd3d-shader/spirv: Parse SPIR-V instructions. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
ac2901d2cb vkd3d-shader/spirv: Parse the SPIR-V instruction schema. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
9b4f5dab77 vkd3d-shader/spirv: Parse the SPIR-V id bound. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
3f548ccf9c vkd3d-shader/spirv: Parse the SPIR-V generator magic number. 2024-12-09 16:09:16 +01:00
Giovanni Mascellani
e218dae281 vkd3d-shader/spirv: Parse the SPIR-V version number. 2024-12-09 16:08:33 +01:00
Giovanni Mascellani
6cac18e395 vkd3d-shader/spirv: Parse the SPIR-V magic number. 2024-12-09 15:41:24 +01:00