Commit Graph

254 Commits

Author SHA1 Message Date
Conor McCarthy
e54f770669 vkd3d-shader/dxil: Implement the DXIL CALL instruction. 2023-08-30 22:48:48 +02:00
Conor McCarthy
58d6e44501 vkd3d-shader/dxil: Validate the function block count. 2023-08-30 22:48:45 +02:00
Zebediah Figura
9624e2f904 vkd3d-shader/spirv: Declare SRVs and UAVs from the descriptor info. 2023-08-28 20:40:02 +02:00
Conor McCarthy
61841e9423 vkd3d-shader/tpf: Handle the swizzle type bitfield in dst param tokens. 2023-08-28 20:39:49 +02:00
Conor McCarthy
92021b7a3c vkd3d-shader/tpf: Use the default vec4 swizzle if a src param contains a mask. 2023-08-28 20:39:46 +02:00
Conor McCarthy
7e5d9e3b6f vkd3d-shader/tpf: Handle the dimension bitfield in src param tokens. 2023-08-28 20:39:45 +02:00
Conor McCarthy
5c706152fa vkd3d-shader/tpf: Validate the src register of case conditions.
Case values are constants in TPF.
2023-08-28 20:39:43 +02:00
Nikolay Sivov
1153f6bb34 vkd3d-shader/hlsl: Parse "if" statement attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-24 21:43:49 +02:00
Zebediah Figura
c1ebba9515 vkd3d-shader: Add structure stride to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Zebediah Figura
88f85ffb50 vkd3d-shader: Add constant buffer size to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Zebediah Figura
8c465c81cf vkd3d-shader: Add sample count to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Nikolay Sivov
932c5e36dc vkd3d-shader/hlsl: Add constant folding for 'log2'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:20 +02:00
Nikolay Sivov
58bc61e48d vkd3d-shader/hlsl: Add constant folding for 'sqrt'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:18 +02:00
Zebediah Figura
7d02922541 vkd3d-shader: Add register ID to struct vkd3d_shader_descriptor_info1. 2023-08-14 18:38:11 +02:00
Zebediah Figura
4e9798f6f7 vkd3d-shader: Introduce struct vkd3d_shader_scan_descriptor_info1. 2023-08-14 18:38:11 +02:00
Francisco Casas
2258e9d0f3 vkd3d-shader/tpf: Make register_type_table an array of structs with lookup tables. 2023-08-14 18:38:06 +02:00
Zebediah Figura
d932fba7c3 vkd3d-shader/spirv: Make output varyings not consumed by the next stage private variables. 2023-08-03 21:20:42 +09:00
Zebediah Figura
11475ef62a vkd3d-shader: Implement remapping shader output registers to match the next shader's semantics. 2023-08-03 21:20:42 +09:00
Zebediah Figura
cb96482500 vkd3d-shader: Add a separate field for the target location of a signature element.
We want to be able to remap input signatures based on the signature index, but
signature normalization both reorders the signature, and requires the old
register index, so add a new field for this.
2023-08-03 21:20:39 +09:00
Conor McCarthy
402c93fa68 vkd3d-shader/spirv: Introduce an undefined register type. 2023-07-20 22:32:52 +02:00
Conor McCarthy
3e553aaaa7 vkd3d-shader/dxil: Emit the shader instructions.
Sufficient for compiling a no-op pixel shader.
2023-07-20 22:32:51 +02:00
Zebediah Figura
e9fb067d4c vkd3d-shader/ir: Move normalization code from spirv.c to ir.c.
It is not spirv-specific and will (presumably) be used for GLSL as well.
2023-07-17 22:56:43 +02:00
Zebediah Figura
d077562f79 vkd3d-shader/d3dbc: Scan descriptors for constant register sets. 2023-07-17 22:56:39 +02:00
Conor McCarthy
5d33fb4633 vkd3d-shader/dxil: Read numeric constants. 2023-07-11 22:43:57 +02:00
Conor McCarthy
c96143abdc vkd3d-shader/dxil: Read global function declarations. 2023-07-11 22:43:55 +02:00
Conor McCarthy
22157c3da3 vkd3d-shader/dxil: Validate the module format version. 2023-07-11 22:43:53 +02:00
Conor McCarthy
eca4b62c7e vkd3d-shader/dxil: Read the value symbol table. 2023-07-11 22:43:49 +02:00
Conor McCarthy
571d807dd8 vkd3d-shader/dxil: Read the type table. 2023-07-11 22:43:48 +02:00
Zebediah Figura
e489098878 vkd3d-shader: Record a global temporary count per sm4 shader.
Store it in the shader_desc, and declare temps from that when compiling SPIR-V,
instead of parsing dcl_instructions.

As part of this change, we declare a single, global temps array (with Private
scope instead of Function) which is as large as the maximum of all dcl_temps
instructions. It is not clear to me whether this will improve, hurt, or have no
significant effect on the lower-level compiler. An alternative is to still
redeclare a new temps array every time (although still with a smaller size).
2023-07-04 22:39:45 +02:00
Conor McCarthy
6775f7ba66 vkd3d-shader/dxil: Read and validate DXIL bitcode unabbreviated blocks. 2023-06-28 21:40:34 +02:00
Zebediah Figura
7e1fcdca89 vkd3d-shader: Synthesize signatures for d3dbc shaders. 2023-06-27 22:33:41 +02:00
Conor McCarthy
6835e8176f vkd3d-shader/ir: Normalise signatures and input/output registers to the Shader Model 6 pattern.
In Shader Model 6 each signature element can span a range of register
indices, or 'rows', and system values do not share a register index with
non-system values. Inputs and outputs are referenced by element index
instead of register index. This patch merges multiple signature elements
into a single element under the following conditions:

- The register index in a load or store is specified dynamically by
  including a relative address parameter with a base register index. The
  dcl_index_range instruction is used to identify these.
- A register declaration is split across multiple elements which declare
  different components of the register.
- A patch constant function writes tessellation factors. These are an
  array in SPIR-V, but in SM 5.x each factor is declared as a separate
  register, and these are dynamically indexed by the fork/join instance
  id. Elimination of multiple fork/join phases converts the indices to
  constants, but merging the signature elements into a single arrayed
  element matches the SPIR-V output.

All references to input/output register indices are converted to element
indices. If a relative address is present, the element index is moved up
a slot so it cannot be confused with a constant offset. Existing code
only handles register index relative addressing for tessellation factors.
This patch adds generic support for it.
2023-05-24 22:00:29 +02:00
Conor McCarthy
110e48e54d vkd3d-shader/ir: Eliminate struct vkd3d_shader_normaliser. 2023-05-24 22:00:28 +02:00
Conor McCarthy
6dd1b01284 vkd3d-shader/tpf: Validate index range declarations. 2023-05-09 21:51:31 +02:00
Conor McCarthy
d565fbdcd6 vkd3d-shader/tpf: Validate input/output registers. 2023-05-09 21:51:29 +02:00
Conor McCarthy
2166088b0b vkd3d-shader/tpf: Validate signature element masks. 2023-05-09 21:51:28 +02:00
Conor McCarthy
b8e6482365 vkd3d-shader/tpf: Validate signature element register indices. 2023-05-09 21:51:19 +02:00
Conor McCarthy
adf7db021c vkd3d-shader/tpf: Validate input/output register index counts. 2023-05-09 21:51:17 +02:00
Francisco Casas
3e9a9c5051 vkd3d-shader/hlsl: Track objects sampling dimension. 2023-05-08 20:24:15 +02:00
Conor McCarthy
a0a18b1620 vkd3d-shader: Introduce an internal shader signature structure.
A register count is required for Shader Model 6 signatures, including
those normalised from earlier models.
2023-05-03 21:12:07 +02:00
Nikolay Sivov
6da7d16d4c vkd3d-shader/trace: Add separate id for discard.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-26 22:46:49 +02:00
Henri Verbeet
804e315b68 vkd3d-shader/sm4: Move the TPF parser from dxbc.c to hlsl_sm4.c. 2023-04-20 22:54:28 +02:00
Henri Verbeet
09566e2c25 vkd3d-shader: Get rid of the "ptr" field from struct vkd3d_shader_parser.
This is an implementation detail.
2023-04-12 21:54:53 +02:00
Henri Verbeet
c4d307a08d vkd3d-shader: Get rid of the "instruction_idx" field from struct vkd3d_shader_parser.
This is unused now.
2023-04-12 21:54:51 +02:00
Conor McCarthy
98b5e2c6e0 vkd3d-shader/ir: Insert hull shader control point input declarations if no control point phase is defined.
The SPIR-V backend will emit a default control point phase. Inserting
inputs into the IR allows handling of declarations via the usual path
instead of an ad hoc implementation which may not match later changes
to input handling.
2023-04-12 21:54:28 +02:00
Conor McCarthy
14295a224d vkd3d-shader/ir: Normalise control point phase output registers to include the control point id.
In SPIR-V the address must include the invocation id, but in TPF it
is implicit. Move the register index up one slot and insert an
OUTPOINTID relative address.
2023-04-12 21:54:27 +02:00
Zebediah Figura
a60c47ff39 vkd3d-shader: Explicitly align the size in bytecode_get_next_offset() and rename it accordingly. 2023-04-06 17:52:16 +02:00
Zebediah Figura
70cfd58be6 vkd3d-shader/spirv: Introduce a spirv_compile() helper. 2023-04-06 17:51:59 +02:00
Henri Verbeet
d6d9aab31c vkd3d-shader: Align the start offset instead of the size in bytecode_put_bytes().
The practical effect this has is that we avoid potential trailing padding at
the end of DXBC blobs. Unfortunately this also means we need to be more
careful about using bytecode_get_size() to find the offset where subsequent
data would get written, although in many cases this follows a put_u32() call.
2023-04-04 22:01:36 +02:00
Conor McCarthy
16a7de4b38 vkd3d-shader/trace: Trace the normalised instruction array after tracing the input. 2023-04-03 17:58:23 +02:00