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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>