Commit Graph

812 Commits

Author SHA1 Message Date
Henri Verbeet
e1aa12f94b vkd3d-shader/ir: Pass a uint32_t write mask to vkd3d_write_mask_get_component_idx(). 2023-12-13 22:33:03 +01:00
Giovanni Mascellani
ec4986e9e2 vkd3d-shader/spirv: Honor force_validation after emitting SPIR-V code. 2023-12-13 22:32:25 +01:00
Conor McCarthy
cdb9eecfd1 vkd3d-shader/spirv: Introduce a compiler feature flag for int64 capability. 2023-12-12 22:50:53 +01:00
Conor McCarthy
0610867334 vkd3d-shader/spirv: Emit an error if 64-bit integers are used. 2023-12-12 22:50:48 +01:00
Conor McCarthy
1929432559 vkd3d-shader: Introduce an instruction flag to suppress masking of bitwise shift counts.
DXIL does not use implicit masking of shift counts.
2023-12-12 22:50:46 +01:00
Conor McCarthy
2037daae32 vkd3d-shader/spirv: Bitcast if necessary in the spirv_compiler_emit_mov() general implementation.
In SM 6, this is needed when storing an asfloat() or asuint() result in
an indexable temp, because dxc performs the bitcast by casting the
destination pointer.
2023-12-11 23:18:52 +01:00
Zebediah Figura
66cb2815f0 vkd3d-shader/spirv: Declare I/O registers from the signature.
Instead of parsing DCL instructions.

This allows sm1 to work without further effort, and simplifies sm6 code.
2023-12-11 23:18:44 +01:00
Zebediah Figura
8876030590 vkd3d-shader/spirv: Do not use the output_info array for patch constants. 2023-12-11 23:18:40 +01:00
Conor McCarthy
cb88844a3d vkd3d-shader: Add a register index to struct vkd3d_shader_immediate_constant_buffer. 2023-12-07 21:56:47 +01:00
Conor McCarthy
ef940cb778 vkd3d-shader/spirv: Support declared component type and count in immediate constant buffers. 2023-12-07 21:56:45 +01:00
Conor McCarthy
16cb6fdbad vkd3d-shader/spirv: Support constant initialisers in indexable temps. 2023-12-07 21:56:44 +01:00
Conor McCarthy
69c3946c85 vkd3d-shader/spirv: Support declared component type and count in indexable temps. 2023-12-07 21:56:41 +01:00
Henri Verbeet
0c33f82f72 Release 1.10. 2023-12-06 15:31:21 +01:00
Conor McCarthy
9fcc904834 vkd3d-shader/spirv: Always emit clip/cull builtins as an array.
Clip/cull distance can appear as input in pixel shaders, and the
array size must not be forced to zero.
2023-12-06 15:31:20 +01:00
Conor McCarthy
b4d03c0221 vkd3d-shader/spirv: Do not emit a fixme for SV_TARGET in vkd3d_get_spirv_builtin(). 2023-12-04 22:22:55 +01:00
Conor McCarthy
f11e1461aa vkd3d-shader/spirv: Do not emit a fixme for SV_TARGET in get_spirv_builtin_for_sysval(). 2023-12-04 22:22:54 +01:00
Conor McCarthy
eb05e434ff vkd3d-shader/dxil: Implement the DXIL LOAD instruction. 2023-11-22 22:07:59 +01:00
Conor McCarthy
a0f5d70792 vkd3d-shader/dxil: Support global variable initialisers. 2023-11-22 22:07:57 +01:00
Conor McCarthy
85d5f83fb7 vkd3d-shader/dxil: Implement default address space global variables. 2023-11-22 22:07:54 +01:00
Conor McCarthy
fb588b8d1a vkd3d-shader/spirv: Avoid invalid bool-to-bool conversion in spirv_compiler_emit_movc().
Shaders parsed from DXIL contain a bool condition register, so calling
spirv_compiler_emit_int_to_bool() results in an invalid bool/uint
comparison.
2023-11-15 21:48:36 +01:00
Conor McCarthy
08b8730866 vkd3d-shader/spirv: Return an error if an invalid handler is encountered.
Prevents return of an invalid SPIR-V module.
2023-11-15 21:48:31 +01:00
Henri Verbeet
215a2c4ede vkd3d-shader/ir: Introduce vsir_register_is_descriptor(). 2023-11-13 23:19:10 +01:00
Conor McCarthy
22960753e9 vkd3d-shader/spirv: Introduce orderedness to comparison instructions. 2023-11-10 20:23:51 +01:00
Conor McCarthy
1dd141535c vkd3d-shader/spirv: Support bool dst register in spirv_compiler_emit_comparison_instruction(). 2023-11-10 20:23:48 +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
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
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
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
Conor McCarthy
3e0638148a vkd3d-shader/spirv: Support VKD3D_DATA_UINT in spirv_compiler_emit_neg().
The DXIL parser uses unsigned types even if the source code uses signed,
so unsigned values may be negated.
2023-11-06 23:09:02 +01:00
Conor McCarthy
4905d047bd vkd3d-shader/spirv: Handle the UMUL instruction. 2023-11-06 23:09:01 +01:00
Conor McCarthy
acbc80cba2 vkd3d-shader/spirv: Introduce an IDIV instruction. 2023-11-06 23:09:00 +01:00
Conor McCarthy
c8d3515d8b vkd3d-shader/spirv: Introduce an FREM instruction. 2023-11-06 23:08:58 +01:00
Giovanni Mascellani
0d4aebd2e7 vkd3d-shader: Explicitly cast vkd3d_shader_global_flags to uint64_t.
On macOS vkd3d_shader_global_flags has underlying type unsigned long,
while uint64_t is defined as unsigned long long. This difference
causes a few warnings to be raised.
2023-11-06 23:08:37 +01:00
Zebediah Figura
f05be8ff12 vkd3d-shader/spirv: No longer handle builtin array size mismatch in spirv_compiler_emit_input().
This is taken care of by prior I/O lowering. We no longer need to deal with this here.
2023-11-06 23:07:59 +01:00
Zebediah Figura
fa23165cc0 vkd3d-shader/spirv: Remove handling of VKD3DSPR_OUTCONTROLPOINT.
I/O normalization removes this register type.
2023-11-06 23:07:58 +01:00
Zebediah Figura
b73d2c978d vkd3d-shader/ir: Check for vocp usage during IR normalization.
The hull shader barrier used for this was broken by I/O normalization, since
vocp is no longer exposed to the spirv backend.

Restore this barrier by checking for vocp during normalization instead.
2023-11-06 23:07:56 +01:00
Conor McCarthy
e899b67bbf vkd3d-shader/spirv: Support scalar swizzle of vector SSA registers. 2023-11-01 21:47:33 +01:00
Zebediah Figura
a66acea1b5 vkd3d-shader/spirv: Always use the sysval from the signature. 2023-10-31 21:59:40 +01:00
Zebediah Figura
eef62b95c1 vkd3d-shader/spirv: Use the interpolation mode from the signature. 2023-10-31 21:59:39 +01:00
Conor McCarthy
9b64d04ed3 vkd3d-shader/spirv: Align constant buffer sizes to 16 bytes.
DXIL constant buffer sizes are not aligned to 16 bytes.
2023-10-19 23:07:40 +02:00
Henri Verbeet
4e8ba62481 vkd3d-shader/spirv: Initialise "symbol.descriptor_array" in spirv_compiler_emit_combined_sampler_declarations().
Besides simply avoiding carrying around some uninitialised data, we
check "symbol->descriptor_array" in spirv_compiler_prepare_image(), both
for separate resources and for combined resource/sampler symbols.
2023-10-17 22:18:44 +02:00
Conor McCarthy
06f8a88466 vkd3d-shader: Define more global flags. 2023-10-17 22:18:23 +02:00
Francisco Casas
f0da419a8c vkd3d-shader: Remove unnecessary fallthroughs (clangd). 2023-10-12 23:27:19 +02:00
Conor McCarthy
df4e1b7393 vkd3d-shader/dxil: Read immediate constant arrays. 2023-10-11 22:21:19 +02:00
Conor McCarthy
75c2af3640 vkd3d-shader/spirv: When declaring a CBV initialise the register with the register index range.
The declaration instruction register contains id, range first, and range
last. The backend includes range first in the variable name. After commit
e8b3561252 it was always zero, and since commit 67f0196c33 it is
UINT_MAX, so constant buffers are named, e.g., "%cb0_4294967295".
2023-10-09 21:58:01 +02:00
Zebediah Figura
a4c5f3a798 vkd3d-shader/spirv: Add a debug name for the push constant buffer. 2023-10-09 21:57:53 +02:00
Henri Verbeet
98d158d004 vkd3d-shader/tpf: Get rid of the output map.
Map output registers in the backend instead, as needed.
2023-10-09 21:57:46 +02:00
Francisco Casas
e904660497 vkd3d-shader: Turn vkd3d_shader_register.immconst_type into vkd3d_shader_register.dimension. 2023-09-26 22:07:04 +02:00
Francisco Casas
6f5cb219f4 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_default_control_point_phase(). 2023-09-26 22:07:00 +02:00
Francisco Casas
81802e27d0 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_resource_declaration(). 2023-09-26 22:06:59 +02:00
Francisco Casas
314c6e4808 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_sampler_declaration(). 2023-09-26 22:06:58 +02:00
Francisco Casas
b2f262467f vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_dcl_immediate_constant_buffer(). 2023-09-26 22:06:56 +02:00
Francisco Casas
67f0196c33 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_cbv_declaration(). 2023-09-26 22:06:55 +02:00
Francisco Casas
04529bc0b7 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_dcl_indexable_temp(). 2023-09-26 22:06:54 +02:00
Francisco Casas
e174f6b413 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_hull_shader_builtins(). 2023-09-26 22:06:53 +02:00
Francisco Casas
89d7bd7a81 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_get_invocation_id(). 2023-09-26 22:06:52 +02:00
Conor McCarthy
575135a9ce vkd3d-shader/spirv: Build undefined values once. 2023-09-25 22:07:05 +02:00
Conor McCarthy
3249723972 vkd3d-shader/spirv: Introduce a Static Single Assignment register type. 2023-09-25 22:07:04 +02:00
Zebediah Figura
257a351f37 vkd3d-shader/spirv: Flush NaN to zero in ftoi. 2023-09-25 22:06:45 +02:00
Zebediah Figura
a5b6162d25 vkd3d-shader/spirv: Clamp ftoi upper bound to INT_MAX. 2023-09-25 22:06:44 +02:00
Zebediah Figura
9dee15da5b vkd3d-shader/spirv: Clamp ftoi lower bound to INT_MIN. 2023-09-25 22:06:43 +02:00
Zebediah Figura
cc893a3368 vkd3d-shader/spirv: Clamp ftou upper bound to UINT_MAX. 2023-09-25 22:06:41 +02:00
Zebediah Figura
491146fa94 vkd3d-shader/spirv: Clamp ftou lower bound to zero. 2023-09-25 22:06:39 +02:00
Henri Verbeet
90d4529f27 Release 1.9. 2023-09-21 19:16:32 +02:00
Conor McCarthy
3badab2086 vkd3d-shader: Handle size in bytes in spirv_compiler_emit_cbv_declaration().
The caller passes a byte size now.
2023-09-04 20:25:33 +02:00
Conor McCarthy
61a550017f vkd3d-shader/spirv: Handle signature element mask left shift in spirv_compiler_emit_output().
Element masks can have a left shift in DXIL, but these must start at
bit 0 in the register info. The SPIR-V declaration will either be a
builtin or have SpvDecorationComponent.
2023-08-30 22:48:43 +02:00
Conor McCarthy
ebc461f795 vkd3d-shader/spirv: Handle signature element mask left shift in calculate_clip_or_cull_distance_mask().
In DXIL these masks can have a left shift.
2023-08-30 22:48:41 +02:00
Zebediah Figura
9624e2f904 vkd3d-shader/spirv: Declare SRVs and UAVs from the descriptor info. 2023-08-28 20:40:02 +02:00
Zebediah Figura
e8b3561252 vkd3d-shader/spirv: Declare constant buffers from the descriptor info. 2023-08-28 20:40:01 +02:00
Zebediah Figura
547768bcdd vkd3d-shader/spirv: Declare samplers from the descriptor info. 2023-08-28 20:39:59 +02:00
Zebediah Figura
a1e10e5c90 vkd3d-shader/spirv: Split spirv_compiler_has_combined_sampler() into two functions.
These functions do not really share any code in common.
2023-08-28 20:39:57 +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
Zebediah Figura
4e9798f6f7 vkd3d-shader: Introduce struct vkd3d_shader_scan_descriptor_info1. 2023-08-14 18:38:11 +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
Zebediah Figura
e0e261eac3 vkd3d-shader/spirv: Emit variables for flat constant buffers. 2023-07-17 22:56:47 +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
Andrey Gusev
d4d960cb8b vkd3d-shader/spirv: Add support for VKD3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE interpolation qualifier.
Used by F1 2018.
2023-07-10 23:17:59 +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
Henri Verbeet
771e442af1 Release 1.8. 2023-06-22 22:00:20 +02:00
Conor McCarthy
bce2a898b3 vkd3d-shader/spirv: Take ownership of the shader signatures in spirv_compiler_create().
Fixes leakage of the replacement elements in shader_signature_merge().
2023-06-19 22:44:07 +02:00
Zebediah Figura
df0a031ad8 vkd3d-shader/spirv: Retrieve input sysvals from the signature for geometry shaders as well.
This only affects clip and cull distances. The HLSL compiler emits these using
dcl_input, but the previous shader (vertex or TES) will write them as a SPIRV
builtin, and hence we want to read this as a SPIRV builtin as well.

This fixes validation errors in Wine's test_clip_distance().
2023-06-12 22:50:19 +02:00
Jan Sikorski
bb680e73de vkd3d-shader/spirv: Ensure that the OpLabel emitted vkd3d_spirv_builder_begin_main_function() gets terminated. 2023-05-26 19:11:55 +02:00
Conor McCarthy
4a64cf74c3 vkd3d-shader/spirv: Use the register index count in I/O relative address assertions. 2023-05-26 19:11:07 +02:00
Conor McCarthy
06dd0ccd4c vkd3d-shader/spirv: Use the register index count in I/O register assertions. 2023-05-26 19:11:03 +02:00
Conor McCarthy
178a7677e2 vkd3d-shader/spirv: Use the register index count in shader_register_get_io_indices(). 2023-05-26 19:11:02 +02:00
Conor McCarthy
d46250a59b vkd3d-shader/spirv: Use the register index count in default register dereferences. 2023-05-26 19:11:00 +02:00
Conor McCarthy
a2b3f70d8e vkd3d-shader/spirv: Use the register index count in aggregate register dereferences. 2023-05-26 19:10:58 +02:00
Conor McCarthy
ad08864134 vkd3d-shader/spirv: Use the register index count in spirv_compiler_get_register_name(). 2023-05-26 19:10:56 +02:00
Conor McCarthy
b3927726cc vkd3d-shader/spirv: Use the register index count in non-I/O variable registers in vkd3d_symbol_make_register(). 2023-05-26 19:10:54 +02:00
Conor McCarthy
ec5f195b6b vkd3d-shader/spirv: Use the register index count in I/O registers in vkd3d_symbol_make_register(). 2023-05-26 19:10:52 +02:00
Conor McCarthy
532fe01818 vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_default_control_point_phase(). 2023-05-26 19:10:49 +02:00
Conor McCarthy
9c6040df02 vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_dcl_indexable_temp(). 2023-05-26 19:10:47 +02:00
Conor McCarthy
bf1ecc0f60 vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_hull_shader_builtins(). 2023-05-26 19:10:33 +02:00
Conor McCarthy
7e58511b76 vkd3d-shader/spirv: Set the register index count in spirv_compiler_get_invocation_id(). 2023-05-26 19:10:30 +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
31682c52c7 vkd3d-shader/spirv: Support emitting multi-dimensional array variables. 2023-05-24 22:00:27 +02:00
Conor McCarthy
6dd1b01284 vkd3d-shader/tpf: Validate index range declarations. 2023-05-09 21:51:31 +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
Zebediah Figura
d8ef0c69a8 vkd3d-shader/spirv: Do not declare resources as multisampled if the sample count is 1.
It is illegal to match a SPIR-V multisampled resource to a Vulkan resource which
is not multisampled. Vulkan considers a resource to be multisampled if its
sample count is greater than 1 (and SPIR-V does not care about the sample count).

This fixes validation errors in the case where the sample count does actually
match the resource. In order to provide correct behaviour when there is a
mismatch, or when the sample count is missing, we will need yet another
additional interface. In the absence of that it seems best to provide a best
guess.

This fixes a validation error with the not-yet-committed merge request 135, when
the d3d11 runner is run through Wine with the Vulkan backend.
2023-04-19 20:45:39 +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
28774b3649 vkd3d-shader/spirv: Move spirv_compiler_destroy() to avoid forward declarations. 2023-04-06 17:52:01 +02:00
Zebediah Figura
70cfd58be6 vkd3d-shader/spirv: Introduce a spirv_compile() helper. 2023-04-06 17:51:59 +02:00
Conor McCarthy
c61f9f477c vkd3d-shader/spirv: Declare the phase SPIR-V function in spirv_compiler_enter_shader_phase().
The convoluted code path is no longer needed.
2023-04-03 17:58:26 +02:00
Conor McCarthy
b8472d2270 vkd3d-shader/spirv: Remove the hull shader phase array.
With no more than one phase each of control point and fork/join type,
an array is not required.
2023-04-03 17:58:24 +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
Conor McCarthy
eabdccb117 vkd3d-shader/ir: Merge all shader IR fork and join phases into a single phase.
Normalise the incoming vkd3d_shader_instruction IR to the shader model 6
pattern. This allows generation of a single patch constant function in
SPIR-V.
2023-04-03 17:58:21 +02:00
Henri Verbeet
57d92a15cf Release 1.7. 2023-03-24 11:22:28 +01:00
Henri Verbeet
8509ec1e72 vkd3d-shader/spirv: Update the current source location in spirv_compiler_generate_spirv(). 2023-03-13 22:10:00 +01:00
Giovanni Mascellani
a1c6bb85ad vkd3d-shader: Do not pass client-given strings as printf()-style format strings. 2023-02-27 22:12:26 +01:00
Zebediah Figura
8fc8d34ea0 vkd3d-shader/spirv: Introduce an option to control whether point size is written. 2023-02-02 20:51:18 +01:00
Conor McCarthy
d14f42be9d vkd3d-shader/spirv: Pass a parser pointer to spirv_compiler_generate_spirv(). 2023-01-24 18:11:16 +01:00
Henri Verbeet
1eaf73147c Release 1.6. 2022-12-07 16:08:16 +01:00
Conor McCarthy
1b11b57652 vkd3d-shader: Introduce DESCRIPTOR_INFO_FLAG_UAV_ATOMICS and always declare UAV images with known type for atomic ops.
Atomic ops on images with Unknown type will cause SPIR-V validation failure,
and assertion failure in Mesa debug builds. D3D12 allows atomics on typed
buffers, and this requires a distinction to be made between UAV reads and
atomic ops.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53874
2022-11-21 18:28:54 +01:00
Zebediah Figura
e2aed38509 vkd3d-shader/spirv: Avoid using DXBC-specific definitions. 2022-11-08 20:52:32 +01:00
Zebediah Figura
35b48a8b04 vkd3d-shader/spirv: Rename struct vkd3d_dxbc_compiler to struct spirv_compiler.
We would like to generate SPIR-V for input formats other than DXBC.

The "vkd3d_" prefix is dropped, partly to make names shorter, and partly to help
clarify what is an internal function.

I prefer avoiding the vkd3d_* prefix on all internal functions, for these
reasons. However, I'm open to restoring it.
2022-11-08 20:52:29 +01:00
Henri Verbeet
56b2f56b86 Release 1.5. 2022-09-21 16:47:49 +02:00
Martin Storsjö
1c61b20616 vkd3d-shader/spirv: Fix the signature of vkd3d_spirv_build_op_type_image.
Don't assume that enums and uint32_t parameters are identical. Clang
16 changes the diagonstic for incompatible function pointer types
from a warning into an error by default.

This fixes the following error, when built (for aarch64, but probably
also for other architectures) in MSVC mode:

../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:1083:13: error: incompatible function pointer types passing 'uint32_t (struct vkd3d_spirv_builder *, uint32_t, SpvDim, uint32_t, uint32_t, uint32_t, uint32_t, SpvImageFormat)' (aka 'unsigned int (struct vkd3d_spirv_builder *, unsigned int, enum SpvDim_, unsigned int, unsigned int, unsigned int, unsigned int, enum SpvImageFormat_)') to parameter of type 'vkd3d_spirv_build7_pfn' (aka 'unsigned int (*)(struct vkd3d_spirv_builder *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)') [-Wincompatible-function-pointer-types]
            vkd3d_spirv_build_op_type_image);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:612:68: note: passing argument to parameter 'build_pfn' here
        SpvOp op, const uint32_t *operands, vkd3d_spirv_build7_pfn build_pfn)
                                                                   ^

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-08-15 21:59:38 +02:00
Conor McCarthy
3dbd2ceca6 vkd3d-shader: Introduce a compile option to use Unknown format for typed UAV loads.
Specifying R32 for UAVs created with a vector format, e.g. R32G32B32A32_FLOAT,
results in only the red being loaded/stored, potentially causing images to
contain only the red component.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2022-08-09 22:14:28 +02:00
Stefan Dösinger
aae4e31ba8 vkd3d-shader: Initialize counter_var_info unconditionally. 2022-07-25 21:09:30 +02:00
Henri Verbeet
9d4df5e704 Release 1.4.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-22 18:31:51 +02:00
Zebediah Figura
14f77294b1 vkd3d-shader/spirv: Do not print a warning for VKD3D_SHADER_COMPILE_OPTION_API_VERSION.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-07 19:39:52 +02:00
Zebediah Figura
9839850b87 vkd3d-shader: Remove the workaround for sample_c.
The current workaround is broken for texture cube arrays, which already have 4
components.

Sampling with the components not packed together apparently succeeds with newer
NVidia drivers, so just remove the workaround. Tested with 470.103.01 on a GTX
1060.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52886
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-26 16:02:09 +02:00
Francois Gouget
b64482e7c7 vkd3d-shader/spirv: Fix the spelling of some comments.
Signed-off-by: Francois Gouget <fgouget@free.fr>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-07 16:39:09 +01:00
Henri Verbeet
d1d9e713f2 Release 1.3.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 21:32:57 +01:00
Henri Verbeet
062f0a25d3 vkd3d-shader/spirv: Pass vkd3d-shader formatting options to vkd3d_spirv_binary_to_text().
Instead of making the caller convert them.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-01 22:31:33 +01:00
Henri Verbeet
beb6b8efc7 vkd3d-shader/spirv: Properly compare integers in vkd3d_symbol_compare().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-28 22:23:30 +01:00
Henri Verbeet
7e08773d4e vkd3d-shader/spirv: Properly compare integers in vkd3d_spirv_declaration_compare().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-28 22:23:28 +01:00
Conor McCarthy
440286e9de vkd3d-shader/spirv: Enable descriptor indexing if runtime arrays are used.
SpvCapabilityRuntimeDescriptorArrayEXT requires descriptor indexing and
a validation error will result if it is not enabled.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-18 09:22:51 +01:00
Conor McCarthy
758b984c41 vkd3d-shader/spirv: Support UAV counter descriptor arrays.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-07 16:49:06 +01:00
Conor McCarthy
3816fa403f vkd3d-shader/spirv: Support runtime descriptor array offsets using push constants.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-15 19:25:38 +01:00
Conor McCarthy
535d4a78b1 vkd3d-shader/spirv: Use runtime descriptor arrays.
Runtime descriptor arrays should be used for descriptor bindings with
a variable count.

Support for SpvCapabilityRuntimeDescriptorArrayEXT is required by the
Vulkan spec as part of descriptor indexing support.

The current implementation depends on a separate array declaration for
each range because binding_base_idx is stored in the array data. This
occurs in practice because binding.count is always different. Use of
runtime arrays eliminates the count from the key, so binding_base_idx
must be separated from the array data.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-24 21:55:46 +01:00
Conor McCarthy
dbd7e18364 vkd3d-shader/spirv: Shift the private variable destination mask instead of the source mask.
Otherwise if the input is located above position 0 in the private array
it will be swizzled incorrectly, e.g. a.yz instead of a.xy in
test_domain_shader_inputs().

Based on a vkd3d-proton patch by Hans-Kristian Arntzen.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-17 15:27:31 +01:00