6937 Commits

Author SHA1 Message Date
Francisco Casas
efd7f2e014 vkd3d-shader/hlsl: Don't lower separate samples with texel offsets. 2025-01-14 17:59:50 +01:00
Francisco Casas
0a5955372a vkd3d-shader/hlsl: Lower separate SampleGrad() for SM1. 2025-01-14 17:59:50 +01:00
Francisco Casas
00b79cd781 tests: Test SampleGrad() on ps_3_0.
fxc compiles this method even without the backcompat option.

Furthermore, it even does it on ps_2_0 despite the fact that it maps to
a texldd instruction, which is not available on plain ps_2_0, nor ps_2_b,
only on ps_2_a and ps_3_0 according to documentation.

It is worth mentioning that the additional offset parameter is not
supported when lowering.
2025-01-14 17:59:50 +01:00
Giovanni Mascellani
c7e173a1ff vkd3d: Log the requested feature levels for D3D12_FEATURE_FEATURE_LEVELS. 2025-01-13 16:41:53 +01:00
Henri Verbeet
fb4b150f27 demos: Use the assembler to embed HLSL sources. 2025-01-13 16:39:35 +01:00
Henri Verbeet
4227858cfe vkd3d-shader/hlsl: Move RDEF generation to hlsl_codegen.c. 2025-01-10 20:03:14 +01:00
Francisco Casas
9b3b47b1b8 vkd3d-shader: Avoid left shifting signed integers. (ubsan)
Otherwise ubsan reports these errors on the bitwise.shader_test:

    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of negative value -12
2025-01-10 19:51:55 +01:00
Francisco Casas
8056058aa1 vkd3d-shader: Avoid passing NULL to memset(). (ubsan)
Otherwise ubsan reports errors such as:

    libs/vkd3d-shader/spirv.c:7266:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
7b23cd4d3c vkd3d-shader: Avoid passing NULL to qsort(). (ubsan)
Otherwise ubsan reports runtime errors such as:

    libs/vkd3d-shader/ir.c:4731:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
eaf4d0bfbf vkd3d-shader: Avoid passing NULL to memcpy(). (ubsan)
Otherwise when passing "-fsanitize=undefined" to the compiler, ubsan
reports such as:

   libs/vkd3d-shader/ir.c:3794:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:43 +01:00
Elizabeth Figura
29bac62ba2 vkd3d-shader/hlsl: Move the "dimx" and "dimy" fields to the type-specific union. 2025-01-10 19:38:13 +01:00
Elizabeth Figura
392398794f vkd3d-shader/d3dbc: Do not access the type dimensions for non-numeric types. 2025-01-10 19:24:21 +01:00
Elizabeth Figura
1ff1a51e4b vkd3d-shader/hlsl: Avoid some uses of the default case when switching over hlsl_base_type.
Since we have -Wswitch, this forces the developer to update all relevant
switches when an enum case is added.

Places where the default is just a FIXME are left alone.
2025-01-10 19:24:10 +01:00
Shaun Ren
646087d54c vkd3d-shader/hlsl: Collect together terms with constant coefficients.
We apply distributivity to applicable expressions, specifically with
the following rewrite rules:

  (x OPL a) OPR (x OPL b) -> x OPL (a OPR b)
  (y OPR (x OPL a)) OPR (x OPL b) -> y OPR (x OPL (a OPR b))
  ((x OPL a) OPR y) OPR (x OPL b) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR ((x OPL b) OPR y) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR (y OPR (x OPL b)) -> (x OPL (a OPR b)) OPR y

where a, b are constants.
2025-01-10 19:17:43 +01:00
Henri Verbeet
b60995b106 tests/shader_runner: Do not use skip() for shader model requirements.
Like we did before commit 067e6deee4aba447c6627ce02b58c6bdcd90470e.
These skips aren't all that interesting; it's entirely intentional that
e.g. a 2.0-3.0 run wouldn't run 4.0 shaders.
2024-12-19 21:17:05 +01:00
Henri Verbeet
45d9a097e6 vkd3d-shader/hlsl: Move sm4_free_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
b143754360 vkd3d-shader/hlsl: Move sm4_get_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
0236c480e3 vkd3d-shader/hlsl: Make sm4_get_interpolation_mode() static. 2024-12-19 21:09:32 +01:00
Giovanni Mascellani
4f7eb890ef vkd3d-shader/ir: Validate OUTCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
495e10e93b vkd3d-shader/ir: Validate INCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
513609ef0e vkd3d-shader/ir: Validate INPUT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
23d4bd1dae vkd3d-shader/ir: Validate PATCHCONST source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
67420aa8b6 vkd3d-shader/ir: Validate OUTPUT source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
7de7025750 vkd3d-shader/ir: Disallow array signature elements for normalisation levels < SM6. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
922af42aca tests/hlsl: Add some clip/cull distance tests. 2024-12-19 20:54:56 +01:00
Anna (navi) Figueiredo Gomes
d5ed4df254 tests/shader_runner: Add a "mesa<23.3" tag. 2024-12-19 20:34:55 +01:00
Henri Verbeet
31ea11fb0e tests/shader_runner: Ignore the "backcompat" option for shader model 5.1+. 2024-12-19 12:24:02 +01:00
Elizabeth Figura
d164752efc vkd3d-shader/d3dbc: Introduce d3dbc_parse_register(). 2024-12-18 17:30:16 +01:00
Elizabeth Figura
3c53293028 vkd3d-shader/ir: Separate VKD3DSPR_OUTPUT and VKD3DSPR_TEXCRDOUT.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
8132239ed2 vkd3d-shader/ir: Separate VKD3DSPR_ADDR and VKD3DSPR_TEXTURE.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
0df5dea653 vkd3d-shader/d3d-asm: Define register names in a table. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
65f3f56f63 vkd3d-shader/d3dbc: Normalize to a single VKD3DSPR_CONST register set when reading.
We don't need VKD3DSPR_CONST2 et al in the IR, even for disassembly.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
118617916a vkd3d-shader: Explicitly translate between d3dbc and vsir register types. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
dd450c526f tests/d3d12: Make the dtof test a bit more interesting. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
efe686105d vkd3d-shader/spirv: Correctly implement DTOU. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
4130ce5bb9 vkd3d-shader/spirv: Correctly implement DTOI. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
f416713608 vkd3d-shader/spirv: Correctly implement DTOF. 2024-12-18 17:30:16 +01:00
Francisco Casas
825784322d vkd3d-shader/ir: Properly lower texldp. 2024-12-18 17:30:15 +01:00
Francisco Casas
02fc26507b tests/hlsl: Test tex2Dproj(). 2024-12-18 17:29:10 +01:00
Francisco Casas
7cc802afd7 vkd3d-shader/ir: Properly lower texldb. 2024-12-18 17:27:43 +01:00
Francisco Casas
59df26af79 vkd3d-shader/hlsl: Lower sample lods for SM1.
For SM1 the lod bias should be in src0.w.
2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
f09ac4959e vkd3d-shader/hlsl: Implement the GatherCmp() methods. 2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
fd8bcc188f tests/hlsl: Add GatherCmp() tests. 2024-12-18 17:27:43 +01:00
Conor McCarthy
8d479d2ea6 vkd3d-shader/dxil: Implement DX intrinsic EvalCentroid. 2024-12-18 17:27:43 +01:00
Conor McCarthy
1bb3b13c0a vkd3d-shader/dxil: Implement DX intrinsic EvalSampleIndex. 2024-12-18 17:27:43 +01:00
Giovanni Mascellani
ed552e4519 tests/hlsl: Add tests for the EvaluateAttribute*() intrinsics.
Based on earlier tests by Conor McCarthy.
2024-12-18 17:27:31 +01:00
Giovanni Mascellani
a68fd1b0de vkd3d-shader/ir: Simplify shader_register_normalise_arrayed_addressing().
The two branches do essentially the same thing, but in different
ways and each one omitting different details. In particular there
is no need to discriminate on whether the register is a relative
address, we can just copy the NULL pointer.
2024-12-17 16:44:00 +01:00
Giovanni Mascellani
3db458697e vkd3d-shader/ir: Remove a redundant assignment.
The hull shader control point normalisation pass already ensures
that output registers in the control point phase have two
indices (the control point index and the register index).
2024-12-17 16:44:00 +01:00
Henri Verbeet
e8cc288426 vkd3d-shader/hlsl: Move CTAB generation to hlsl_codegen.c. 2024-12-17 16:42:53 +01:00
Henri Verbeet
c681673993 vkd3d-shader/d3dbc: Separate writing the comment bytecode from write_sm1_uniforms().
Consistent with how D3DXFindShaderComment() allows looking up comments
by tag. This also makes it a little easier to move CTAB generation out
of d3dbc.c.
2024-12-17 16:42:53 +01:00