Checks the floor and caps, that more memory used outside the texture
caches never raises the budget, and that a budget above the floor
leaves room for the live sampled textures plus an eighth of the budget,
on 2-32 GiB heaps.
Co-authored-by: JJenkx <31495916+JJenkx@users.noreply.github.com>
StorageTextureBudget reserved the larger of the sampled textures alive
and their 2 GiB floor. The sampled budget already reserves
TextureCacheBudget, at least the storage cap, for the storage cache, so
on an 8 GB card the two caches each kept the other's maximum: with
3936 MiB used outside the caches on a 7189 MiB budget and 49 MiB of
sampled textures, the storage budget came out at 306 MiB and sat at its
512 MiB floor while about 2.7 GB of the budget stayed free.
The storage budget now reserves the sampled textures alive and gives
room back as they grow, at its next read. Where they hold 2 GiB or more
the budget is unchanged.
Texture and storage images now refuse more array layers than the
device's maxImageArrayLayers. The mock context left that limit at 0,
so agc_depth_copy_kept_bytes failed creating its 8x8 storage image.
Give it the 2048 layers real devices report.
AI-assisted: yes
A layered draw into a color view of slices 0 to 5 of a 2D surface whose
CB_COLOR_ATTRIB3 declares one slice was refused. The CB clamps the
render target array index to the view's SLICE_MAX, not to the surface's
slice count, so each layer is written one slice pitch further on.
PPSA01317 renders a 512x512 cube map this way. Such a view now renders as
a 2D array of the view's last slice + 1 slices.
AI-assisted: yes
A draw whose vertex shader exports the render target array index into a
color view of several slices of a 2D array target was refused. The view
now renders layers lastSlice - slice + 1 through a 2D array attachment
view of the array's resident image starting at its first slice, and the
draw marks every rendered slice dirty. A view of several slices of a
surface that is not a 2D array is still refused, as is a layered draw
without the array's resident image.
AI-assisted: yes
With DB_SHADER_CONTROL.STENCIL_OP_VAL_EXPORT_ENABLE the pixel shader
supplies the value that REPLACE_OP and the add and subtract operations
use in place of DB_STENCILREFMASK.STENCILOPVAL. The bit was refused as a
whole, which stopped Onimusha: Way of the Sword (PPSA27836) at a
DB_SHADER_CONTROL 0x45 draw with DB_STENCIL_CONTROL 0x40040 (REPLACE_OP
on depth pass, both faces), write mask 0xff and compare ALWAYS.
The export is accepted with the 32_GR and 32_ABGR Z formats. When no
reachable operation through a non-zero write mask reads the value, it
cannot change the result and is ignored. Without a test value export, a
reachable REPLACE_OP becomes REPLACE with the exported value as
FragStencilRefEXT (or the bounded replay on devices without the
extension), provided both faces compare without the test value and use
no ONES or REPLACE_TEST; early tests throw. The add and subtract
operations, and REPLACE_OP with a test value export, still throw.
The value is read from bits 8-15 of the second MRTZ channel: the
title's pixel shader shifts it left by 8 right before exp mrtz
(v_lshlrev_b32 v0, 8, v0). That is the only evidence for the layout and
it is listed as technical debt. The pixel stage info carries the new
flag into the cache key, the draw keys and request serialization
version 31.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Image and sampler table capacity came only from the regular descriptor
limits. MoltenVK reports Metal's argument table limits there (256 sampled
images and 16 samplers per stage), below the typed heaps the tables are
reserved on top of, so both capacities were 0 and every table draw or
dispatch was refused as if the device lacked descriptor indexing. Its
update-after-bind limits are 1000000 sampled images and 500000 samplers.
- descriptorBindingSampledImageUpdateAfterBind is queried and enabled, and
the update-after-bind limits are read when either it or the storage
buffer feature is present.
- A table whose regular capacity is 0 takes its capacity from the
update-after-bind limits. Its binding is update-after-bind and its set
layout and pool are update-after-bind ones, in ShaderResources and in
DescribeSetLayouts alike. A table that fits the regular limits is
unchanged.
- An update-after-bind set layout and its allocation are checked against
the update-after-bind sampled image and sampler limits when the device
has descriptorBindingSampledImageUpdateAfterBind. Vulkan counts the
descriptors of such sets against those limits in place of the regular
ones, and requires them to be at least the regular ones only when the
feature is supported, so without it, and for storage images, the
regular limits are kept as before. Storage buffers keep their own
update-after-bind flag.
- Compute pipeline capture and replay accept update-after-bind sampled
image and sampler bindings.
Filled rectangles (VGT_PRIMITIVE_TYPE 7 and 17) use the same single-sample MSAA_ENABLE path as triangles; PPSA03541 stops on a rect-list draw otherwise.
Co-authored-by: Cursor <cursoragent@cursor.com>
Use representable viewport endpoints only when the draw has no depth attachment and its pixel shader does not read PositionZ. Preserve XY coverage, clip-space mode, depth clamping, and validation of non-finite inputs.
Balatro (PPSA21402) reaches rendering on Apple M1 with MoltenVK after this change instead of stopping at VK_EXT_depth_range_unrestricted. Depth-dependent draws retain their original behavior.
Primitive type 19 (DI_PT_QUADLIST, 0x13) is used by Unity and other engines for UI quads, sprites and font glyphs. Because Vulkan lacks native quad-list primitive topology, quad draws are expanded on the CPU into indexed triangle lists with 6 indices per 4-vertex quad, respecting the first/last provoking vertex configuration and discarding incomplete trailing vertices. Adds unit tests and documents the functional debt.
A draw on the mesh path was validated before its pipeline checked for
mesh shader support, so on a device without VK_EXT_mesh_shader (an RDNA1
RX 5700 XT) Sackboy: A Big Adventure (PPSA01289) stopped on "subgroup
capability 61 is unsupported for shader stage 128" instead of the actual
cause. ValidateShaders now takes the device's mesh shader support and
refuses such a draw first with "device does not support mesh shaders".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PPSA08270 (Eternights) stopped after its story intro with "AGC graphics:
CB resolve from a target whose sample count differs from the
rasterizer's". It resolves a 4x 512x512 target into a single-sample one
with PA_SC_MODE_CNTL_0.MSAA_ENABLE off while PA_SC_AA_CONFIG still holds
2x from earlier draws. Without MSAA_ENABLE the scan converter does not
use PA_SC_AA_CONFIG's sample count, so the resolve takes its sample
count from CB0 as it already does when PA_SC_AA_CONFIG is single-sample.
DescriptorCache::AllocateRewritten handed out any recycled set of the requested layout. The
variable descriptor count of an image-table binding is fixed when its set is allocated, and
PrepareDrawBindings writes the table's present elements, up to its current element count, into
the set it gets. A draw whose table had more elements than the table the recycled set was
allocated for could write descriptors past the set's allocation
(VUID-VkWriteDescriptorSet-dstArrayElement-00321).
A set from a chain pool now records the variable count it was allocated with, as a dedicated-pool
set already does, and recycled sets are kept per layout and variable count, so a rewritten draw
reuses a set only for a table of the same size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's sameRange for a failed import now takes the import budget, as the HostImport overload does, so a recorded failure is compared against the run the budget would import again.
Imports, type-3 mirrors and the buffers and textures placed in host memory share the driver's system memory heap. On Windows that heap is half the physical memory, so on a 16 GiB machine the old budget (the heap less 2 GiB) let imports hold about 6 of its 8 GiB, and host buffer allocations then overflowed into the 256 MiB device-local host-visible heap and failed. The budget now reserves the larger of 2 GiB and half the largest host heap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>