Commit Graph

597 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen 3b8a13e63d vkd3d-shader: Implement robust UAV counters.
It's technically undefined to use NULL UAV counters,
but drivers all implement some form of robust behavior here
when presented with NULL counters, so we'll have to follow suit.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:07:47 +02:00
Hans-Kristian Arntzen 9b5f3bfc26 vkd3d-shader: Fix GRAD sample on cubes.
offset_component_count was set to 0 for cubes, but GRAD path also
uses the variable to check how many components to use for GRAD.
OFFSET is not supported for cubes, so that's likely why it was bugged.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-28 12:14:41 +02:00
Hans-Kristian Arntzen acef5429c5 vkd3d-shader: Workaround trivial compiler warning.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:54:07 +02:00
Hans-Kristian Arntzen 7a002698f3 vkd3d-shader: Prefer InBounds access chains for root descriptors.
Gets better codegen, since compiler no longer has to assume
that negative indices can be generated, which means full 64-bit sign
extension and addressing math (slow).

Based on experiments, no native driver lets -1 indices work,
so it's safe to make the u32 assumption.

See test_root_descriptor_offset_sign as a justification for this change.

Also, see https://gitlab.freedesktop.org/mesa/mesa/-/issues/6562
for discussion on InBounds.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:38 +02:00
Philip Rebohle 890ba87a7c vkd3d-shader: Merge i/o variables using the same location.
Fixes a number of issues observed in tessellation shaders,
and potentially geometry shaders, when inputs and/or outputs
are array variables.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-10-18 17:25:18 +02:00
Hans-Kristian Arntzen 32c5abf496 vkd3d-shader: Add INVARIANT_POSITION quirk.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 2152500014 vkd3d-shader: Refactor out quirk selection.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 0f802b151e vkd3d-shader: Avoid undefined result for Ibfe/Ubfe/Bfi.
Width + offset must not overflow in SPIR-V. SM 5+ is well-defined here.
It's enough to just clamp the width against 32 - offset in all cases.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 15:45:02 +02:00
Hans-Kristian Arntzen d9cd18b1ca vkd3d-shader: Handle vectorized FIRSTBIT_HI.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-01 16:23:52 +02:00
Joshua Ashton 56e12d88ce vkd3d-shader: Fix multiple constant buffers with RAW_VA
Consider we have declarations of CB0 of size 36 and CB1 of size 153.
Previously we'd just return the struct of CB0 when accessing CB1 because it came first as we didn't consider the size.

Psychonauts 2 indexes into CB1 by constant values above 36.
There is no reason a compiler could not eliminate these reads as it is technically out of bounds for the underlying array type.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-08-26 14:05:52 +02:00
Joshua Ashton a53a7f8d7c vkd3d-shader: Restrict descriptor-qa extras and logic to VKD3D_ENABLE_DESCRIPTOR_QA
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-07-08 16:52:58 +02:00
Hans-Kristian Arntzen 1ea31701c5 vkd3d: Move F1 2020 workaround over to quirks system.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen cb61a4c83a vkd3d-shader: Implement sample explicit LOD override.
In control flow, we can force LOD 0.0 to avoid undefined result when
games sample with implicit LOD in non-quad uniform control flow.

Behavior on different implementations is:
- Helper lanes come to life and interpolate shader input.
- LOD is clamped to 0.0 in divergent control flow.

This hack is not safe in general, since we force 0.0 even when the
control flow is quad uniform.

This is the most practical solution for the problem for now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen a08e493a3a vkd3d-shader: Add interface for shader workarounds.
Don't really have much of a choice for the short term. :\

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 4c101a4e81 vkd3d-shader: Keep track of early returns.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 8589a425fe vkd3d-shader: Emit NoContraction for MAD/DFMA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:01:46 +02:00
conor42 3b1f34217c vkd3d-shader: Fix a bug in constant double vector handling.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-06-09 20:54:02 -07:00
Hans-Kristian Arntzen a83c99ba77 vkd3d-shader: Don't apply offset buffers for non-bindless resources.
Fixes root descriptors when BDA support is disabled.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 23:30:51 +02:00
Hans-Kristian Arntzen a3fb2f1cd6 vkd3d-shader: Opt-in to early fragment tests with descriptor QA.
Since we introduce side effects, avoid full late-Z for everything, which
is slow, and not necessarily correct either.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 077740f15c vkd3d-shader: Implement descriptor QA for DXBC as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Joshua Ashton 0c8349cb8e vkd3d-shader: Remove vkd3d_shader_domain_shader_compile_arguments
This is never used by anything, and all the info is in the shader anyway.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 220e1146ee vkd3d-shader: Make vkd3d_shader_transform_feedback_info a member
Moves it into vkd3d_shader_interface_info, this doesn't need to be
a pNext.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 07e801192f vkd3d-shader: Resolve arguments to variable before passing to epilogue
Otherwise we pass in a pointer which is bad, or a local value which is also illegal for some reason.

It has to be a "memory object declaration".

Found via. spirv-val

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 4470ec63cc vkd3d-shader: Don't emit builtin clip/cull arrays for hull shaders
There are no output built-ins here, just per-vertex stuff passed directly to DS to deal with there.

Closes: #227

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 94a9719557 vkd3d-shader: Rename vkd3d_dxbc_compiler_emit_shader_signature_outputs to vkd3d_dxbc_compiler_emit_clip_cull_outputs
This only ever emits these.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 000407d74c vkd3d-shader: Enable Clip/Cull distance capabilities
Found via. spirv-val

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Hans-Kristian Arntzen e7b6cf4089 vkd3d-shader: Report error if binding is not found in root signature.
Error out early.

Fixes some crashes when we keep going after having seen completely
broken bindings.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Joshua Ashton 043fd304f8 vkd3d-shader: Add force_tgsm_barriers config flag
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 16:29:57 +02:00
Philip Rebohle 6476fabb0b vkd3d-shader: Implement support for SV_InnerCoverage.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle 5e94183975 vkd3d-shader: Do not insert branch to loop header if outside of block.
Fixes invalid SPIR-V in case there is an unconditional break right
before the loop ends.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-04 13:36:31 +01:00
Philip Rebohle ba8e306452 vkd3d-shader: Ignore break instructions if there is no active block.
This can happen if a continue statement is immediately followed
by a break instruction in a switch case.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-04 13:36:31 +01:00
Hans-Kristian Arntzen fdcf583cbc vkd3d: Rename COUNTER buffer to AUX_BUFFER.
We will use the same pointer buffer to handle acceleration structures,
so unify this buffer under a new name. Simplifies some of the binding
code since SRV path and UAV path looks more similar now.

Only difference is that UAV path uses BDA -> uint32_t,
and SRV uses BDA -> RTAccelerationStructure.

RT requires BDA, so the fallback descriptor set (storage texel buffer) is never used for RT.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Philip Rebohle 6bddcb4352 vkd3d: Store both byte range and element range in offset buffer.
The first range will store the byte offset, the second one will
be the typed buffer range. Typed descriptors should write both.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Henri Verbeet c42f4d11e2 vkd3d-shader: Decorate "precise" arithmetic instructions with SpvDecorationNoContraction.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
2021-01-12 15:22:11 +01:00
Hans-Kristian Arntzen e6961afca6 vkd3d-shader: Emit typed format for UAVs which use atomics.
Mesa will assert if not, and the format must be known here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-04 16:08:26 +01:00
Joshua Ashton e27a153a22 vkd3d-shader: Fix saturates of fp64 types
Closes: #419

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-27 11:11:59 +01:00
Philip Rebohle 9d57489225 vkd3d-shader: Correctly handle infinity in f32tof16.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-23 15:46:55 +01:00
Philip Rebohle bab9b0af92 vkd3d: Support offset buffers for raw/structured texel buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 12:27:19 +01:00
Philip Rebohle 8fe83f5e9c vkd3d-shader: Correctly handle bit shifts greater than 31 bits.
This is undefined behaviour in SPIR-V, but well-defined in
DXBC, so we should explicitly 'and' the shift amount with 31.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-17 15:26:36 +01:00
Hans-Kristian Arntzen a1d851e717 vkd3d-shader: Do not require Int64 to use root descriptors.
Can just use uvec2. Also improves performance on ACO since ACO cannot
promote uint64_t to SGPR yet, u32x2 however, works fine and can be
bitcast to pointer as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-13 17:10:48 +01:00
Philip Rebohle c11b58418a vkd3d-shader: Support physical storage buffer root SRVs/UAVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 4313eaa59c vkd3d-shader: Support physical storage buffer root CBVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 5d2b0e6632 vkd3d-shader: Add loadv/storev helpers for aligned memory access.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 6c9d0cea69 vkd3d-shader: Rename descriptor_table_var_id -> root_parameter_var_id.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 4b3cec53fc vkd3d-shader: Declare push constants for root descriptor VAs.
We'll always place them at the beginning of the push constant
buffer in order to avoid potential alignment issues.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 2689c9e0a3 vkd3d-shader: Enable Int64 capability as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle f69564c6c1 vkd3d-shader: Implement buffer reference type declarations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Joshua Ashton 8dea487861 meta: Add missing newlines to end of files
Remove trailing whitespace also

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-05 17:16:57 +01:00
Hans-Kristian Arntzen 7e14f80e2a vkd3d-shader: Emit OpSource with DXBC hash.
Makes it possible to backtrace which shader we're working with
when we get raw SPIR-V from unrelated sources (Fossilize or RADV crash
dumps for example).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-05 15:57:16 +01:00
Hans-Kristian Arntzen bcd03de770 vkd3d-shader: Implement typed buffer offset.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00