Commit Graph

2 Commits

Author SHA1 Message Date
XairRrR 70fe108712 fix(recompiler): fold extracts into a vector shuffle only between vectors
The specialization pass turned OpCompositeConstruct of extracts from one
composite into OpVectorShuffle without checking the types. When the
source is a struct (the {uint, uint} pairs of extended multiplies and
phis of them), the result is invalid SPIR-V ("The type of Vector 1 must
be a vector type"), which the NVIDIA driver (615.71.09) crashes on in
vkCreateGraphicsPipelines instead of rejecting. The fold now requires
both the source and the result to be vector types; a test builds the
struct and vector cases by hand.

Uncharted: Legacy of Thieves Collection (PPSA05684) crashed in the
driver's SPIR-V compiler right after loading its first level.
2026-10-10 19:59:14 +02:00
Slick Daddy 4dd9d45be8 fix(shader): cache operand-free constants and cover interning with a test
OpConstantTrue and OpConstantFalse carry no operand word, so they reached the
declaration cache through the variadic Constant template, which builds the key
vector, and paid an allocation on every call. ConstantBool emits both, so a
shader paid it twice per boolean constant. Add the two-word overload; the
compile-shaped benchmark drops from 10413 allocations to 415.

Add agc_spirv_module_tests covering the interning contract: a repeated
declaration returns one id and is emitted once, operand shapes that share a
leading key word stay distinct, integral and enum operands agree, decorated
types stay separate from plain ones, memoized ids survive AllocateId, modules
do not share ids, and ids stay unique and contiguous past the cache capacity.
The test passes against both the previous header and this one, so it pins the
contract rather than the implementation.

Benchmark, pre-optimization header against this one, best of five:

  hot loop x 2M              613.6 ms ->   46.3 ms   13.2x
  compile-shaped 5000 instr    4.2 ms ->    0.4 ms   10.8x
  64 compile-shaped modules  286.0 ms ->   25.4 ms   11.3x

Allocations for the compile-shaped case fall from 55217 to 415. Both builds
compute the same value over the same call sequence.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 15:58:31 +03:00