Commit Graph

4693 Commits

Author SHA1 Message Date
Giovanni Mascellani
0f4bda9c9d vkd3d-shader/ir: Keep track of hull shader phases. 2023-11-09 21:15:38 +01:00
Conor McCarthy
5768c019c1 vkd3d-shader/ir: Check the handler before changing it to NOP in remove_dead_code(). 2023-11-09 21:15:29 +01:00
Zebediah Figura
ade8899456 vkd3d-shader/hlsl: Use hlsl_types_are_equal() in func_decl_matches().
Besides reusing code, this now handles UAV types correctly.
2023-11-09 21:15:21 +01:00
Zebediah Figura
8f041fbe6f vkd3d-shader/hlsl: Return bool from compare_function_decl(). 2023-11-09 21:15:19 +01:00
Zebediah Figura
fef118555c vkd3d-shader/hlsl: Do not prioritize an exact match when looking up functions.
Native does not always do this. For example, functions whose parameters are
float and float1 always result in an "ambiguous function call" error.

This does not fix any tests, because the relevant tests previously (incorrectly)
succeeded, and now fail with:

E5017: Aborting due to not yet implemented feature: Prioritize between multiple compatible function overloads.

when they should simply fail.
2023-11-09 21:15:17 +01:00
Zebediah Figura
514d179b70 vkd3d-shader/hlsl: Do not consider scalars and 1-dimensional vectors to be equivalent in function parameters. 2023-11-09 21:15:14 +01:00
Zebediah Figura
b1c2852cd7 vkd3d-shader/hlsl: Store function overloads in a list.
The choice to store them in an rbtree was made early on. It does not seem likely
that HLSL programs would define many overloads for any of their functions, but I
suspect the idea was rather that intrinsics would be defined as plain
hlsl_ir_function_decl structures [cf. 447463e590]
and that some intrinsics that could operate on any type would therefore need
many overrides.

This is not how we deal with intrinsics, however. When the first intrinsics were
implemented I made the choice disregard this intended design, and instead match
and convert their types manually, in C. Nothing that has happened in the time
since has led me to question that choice, and in fact, the flexibility with
which we must accommodate functions has led me to believe that matching in this
way was definitely the right choice. The main other designs I see would have
been:

* define each intrinsic variant separately using existing HLSL types. Besides
  efficiency concerns (i.e. this would take more space in memory, and would take
  longer to generate each variant), the normal type-matching rules don't really
  apply to intrinsics.

  [For example: elementwise intrinsics like abs() return the same type as the
  input, including preserving the distinction between float and float1. It is
  legal to define separate HLSL overloads taking float and float1, but trying to
  invoke these functions yields an "ambiguous function call" error.]

* introduce new (semi-)generic types. This is far more code and ends up acting
  like our current scheme (with helpers) in a slightly more complex form.

So I think we can go ahead and rip out this vestige of the original design for
intrinsics.

As for why to change it: rbtrees are simply more complex to deal with, and it
seems unlikely to me that the difference is going to matter. I do not expect any
program to define large quantities of intrinsics; linked list search should be
good enough.
2023-11-09 21:15:11 +01:00
Zebediah Figura
2b59a759d5 vkd3d-shader/hlsl: Rename hlsl_get_func_decl() to hlsl_get_first_func_decl(). 2023-11-09 21:15:09 +01:00
Zebediah Figura
3e35570221 tests: Add some more tests for function overloads. 2023-11-09 21:15:08 +01:00
Zebediah Figura
011e31f624 vkd3d-shader/spirv: Remove no longer used private_output_variable_array_idx array. 2023-11-09 21:15:01 +01:00
Zebediah Figura
8513f567fa vkd3d-shader/spirv: Look up builtins by vkd3d_shader_sysval_semantic.
Instead of by vkd3d_shader_input_sysval_semantic.
2023-11-09 21:14:57 +01:00
Zebediah Figura
87cb66dd43 vkd3d-shader/spirv: Simplify spirv_compiler_emit_dcl_input(). 2023-11-09 21:14:55 +01:00
Zebediah Figura
c7a7d9a18c vkd3d-shader/ir: Normalize all I/O registers to INPUT/OUTPUT/PATCHCONST.
Specifically, map COLOROUT to OUTPUT, and map INCONTROLPOINT to INPUT for domain
shaders as well as hull shaders.

Obscure the non-existent differences from the view of the backend.
2023-11-09 21:14:52 +01:00
Zebediah Figura
133e313800 vkd3d-shader/dxil: Do not use COLOROUT for PS outputs.
sm4 does not use this; only sm1 does. In following patches we will normalize it
to OUTPUT.
2023-11-09 21:14:49 +01:00
Conor McCarthy
90d178bf12 vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
Conor McCarthy
bd77cbb33f vkd3d-shader/spirv: Support double in spirv_compiler_emit_ftou(). 2023-11-09 21:14:40 +01:00
Conor McCarthy
92d546f3a2 vkd3d-shader/spirv: Support double in spirv_compiler_emit_ftoi(). 2023-11-09 21:14:37 +01:00
Conor McCarthy
169210558d vkd3d-shader/spirv: Handle unsigned result in spirv_compiler_emit_ftoi(). 2023-11-09 21:14:35 +01:00
Conor McCarthy
58ffb5d181 vkd3d-shader/spirv: Introduce integer width cast instructions.
ITOI and UTOU may cast from a bool to a 32-bit integer. Cast to a 64-bit
integer from a smaller type will be added later.
2023-11-09 21:14:32 +01:00
Conor McCarthy
7de4ac2e48 vkd3d-shader/spirv: Support bool cast in spirv_compiler_emit_alu_instruction(). 2023-11-09 21:14:30 +01:00
Conor McCarthy
5b87d6419a vkd3d-shader/spirv: Support bool logic ops in spirv_compiler_emit_alu_instruction(). 2023-11-09 21:14:27 +01:00
Conor McCarthy
b43dab50c1 vkd3d-shader/spirv: Support bitcast in spirv_compiler_emit_load_ssa_reg(). 2023-11-09 21:14:25 +01:00
Henri Verbeet
2252f012ea vkd3d: Add support for the ID3D12Resource1 interface. 2023-11-09 21:14:20 +01:00
Henri Verbeet
557b32a504 vkd3d-compiler: Introduce an option to specify the origin of fragment coordinates. 2023-11-09 21:14:14 +01:00
Henri Verbeet
e7eec3e023 vkd3d-shader/spirv: Allow the origin of fragment coordinates to be specified.
We typically want to use lower-left in OpenGL environments when rendering to
FBOs.
2023-11-09 21:14:12 +01:00
Zebediah Figura
0805ce121e tests: Add more semantics to test_nop_tessellation_shaders().
To act as a regression test for 852eefc01d.
2023-11-08 22:49:51 +01:00
Henri Verbeet
375b3e0db3 vkd3d-compiler: Sort the options in the usage text. 2023-11-08 22:49:47 +01:00
Henri Verbeet
4c4843126e vkd3d-compiler: Slightly reword the --semantic-compat-map usage text. 2023-11-08 22:49:47 +01:00
Henri Verbeet
c5cc467394 vkd3d: Report D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE for UAV formats. 2023-11-08 22:49:43 +01:00
Henri Verbeet
000843b7c8 vkd3d: Report D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD for UAV formats when we have "uav_read_without_format". 2023-11-08 22:49:43 +01:00
Nikolay Sivov
4778d051df vkd3d-shader: Add constant folding for 'floor'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +01:00
Nikolay Sivov
634ec96b52 vkd3d-shader: Add a missing entry to instruction debug print helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +01:00
Nikolay Sivov
955932fb55 vkd3d-shader: Add constant folding for 'ceil'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +01:00
Nikolay Sivov
9a70ae5b6a vkd3d-shader: Add support for floor() on SM1-3.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +01:00
Nikolay Sivov
aaef82e680 vkd3d-shader: Add support for ceil() on SM1-3.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +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
Nikolay Sivov
4284b7c522 vkd3d-shader/hlsl: Parse ceil() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:37 +01:00
Nikolay Sivov
e57bf3db0b tests: Add some tests for ceil().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:37 +01:00
Nikolay Sivov
76e42fbd21 vkd3d-shader/hlsl: Implement ternary operator for SM1.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:31 +01:00
Nikolay Sivov
522a0dfb56 vkd3d-shader/hlsl: Add tex2Dlod() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:26 +01:00
Zebediah Figura
852eefc01d vkd3d-shader/ir: Synthesize HS inputs with the register index and write mask of the signature element.
This pass was written as if to output normalized I/O, but it runs before the I/O
normalization pass.

Fixes: 98b5e2c6e0
2023-11-07 22:26:53 +01:00
Zebediah Figura
12240efa79 vkd3d-shader/spirv: Use register counts from the signature and shader desc. 2023-11-07 22:26:49 +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
Zebediah Figura
3ff22ac5af vkd3d-shader/spirv: Use the array sizes for shader phase builtins as well. 2023-11-07 22:26:47 +01:00
Giovanni Mascellani
f8fcfc52d8 ci: Expect builds to always succeed, even when tests are allowed to fail. 2023-11-07 22:26:36 +01:00
Zebediah Figura
f0a6c7de1d vkd3d-shader/hlsl: Record partial allocations in allocate_range(). 2023-11-07 22:26:11 +01:00
Zebediah Figura
c683fc9402 vkd3d-shader/hlsl: Check that a partial register's mask is also available in is_range_available(). 2023-11-07 22:26:10 +01:00
Giovanni Mascellani
7d49f9637a vkd3d-shader/ir: Check that SWITCH blocks are correctly nested. 2023-11-07 22:26:05 +01:00
Giovanni Mascellani
93632fb407 vkd3d-shader/ir: Check that REP blocks are correctly nested. 2023-11-07 22:26:04 +01:00
Giovanni Mascellani
92c36615ed vkd3d-shader/ir: Check that LOOP blocks are correctly nested. 2023-11-07 22:26:03 +01:00