Repository navigation
fix(agc): sample 10_10_10_2 SNorm and SInt textures - #5149
Conversation
Guest texture formats 51 (SNorm) and 55 (SInt) of the 10-bit packed group were missing from the texture lookup and the descriptor format table, so a descriptor using them threw 'unsupported guest texture format' while the UNorm (50) and UInt (54) siblings worked. Map them to A2B10G10R10_SNORM_PACK32 / A2B10G10R10_SINT_PACK32, classify them for sampling (float / signed integer), and list SINT among the integer formats. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with c6a4223 merged into main 9d0a41d:
AI-assisted: yes (Claude Code) |
|
Thank you for the Linux test, @coltken95. It matches the Windows result in the description: with AI-assisted (Claude Code). |
CnRJay
left a comment
There was a problem hiding this comment.
The table entries look right. One thing a host-only test can't catch: Vulkan doesn't require sampled-image support for these two host formats. In the spec's mandatory format support table for packed 32-bit formats, VK_FORMAT_A2B10G10R10_UNORM_PACK32 and VK_FORMAT_A2B10G10R10_UINT_PACK32 must support SAMPLED_IMAGE, but A2B10G10R10_SNORM_PACK32 and A2B10G10R10_SINT_PACK32 are optional. They are missing on some drivers; vulkan.gpuinfo.org lists which devices expose them.
On such a device, the first texture with format 51 or 55 reaches vkCreateImage / vkCreateImageView with a format the device doesn't support for sampling. That is undefined behaviour or a driver error, not a clean "unsupported" throw. The storage path already checks per physical device (StorageFormatOrUndefined in Texture.cpp). For the sampled path, I'd suggest either:
- checking
optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BITfor these two formats (cached the same way) and throwingunsupported guest texture format 51 on this devicewhen it's missing; or - decoding them in the shader from an
R32_UINTview (sign-extend each 10/2-bit field, then scale for SNORM). That works everywhere but costs ALU per sample, so I'd only do it as a fallback.
A GPU run that samples format 51 on NVIDIA and AMD would also confirm the SNORM edge case: -512 and -511 both map to -1.0, and the 2-bit alpha -2 maps to -1.0. The console and Vulkan should agree there, but nothing currently tests it.
#484) * fix(agc): sample 10_10_10_2 SNorm and SInt textures Guest texture formats 51 (SNorm) and 55 (SInt) of the 10-bit packed group were missing from the texture lookup and the descriptor format table, so a descriptor using them threw 'unsupported guest texture format' while the UNorm (50) and UInt (54) siblings worked. Map them to A2B10G10R10_SNORM_PACK32 / A2B10G10R10_SINT_PACK32, classify them for sampling (float / signed integer), and list SINT among the integer formats. TextureFormat.cpp and RdnaDescriptorFormat.cpp are shared with our Metal path. Metal has no signed RGB10A2 pixel format, so MetalTexture still refuses these two formats, now by name ("no supported pixel format for guest format 51") instead of failing the shared lookup. Recorded in TechnicalDebt. Test: metal_utility_tests (TextureResource.mm) checks that 51 and 55 resolve to the signed packings, are four bytes and not block compressed, and that a native texture refuses them by name. The upstream RunTextureFormatTests cases (tests/TextureFormat.cpp) are carried too; they build in the Vulkan graphics tests, not on macOS. Ported from upstream PR boykopovar#5149 (cherry picked from commit c6a4223) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj * fix(agc): share a depth plane's contents across its stencil pairings on Metal A title can bind one depth plane with several stencil planes (or one stencil plane with several depth planes). MetalDepthSurfaceCache keys a surface by both plane addresses, so each pairing got its own textures, cleared on creation: depth written through one pairing never reached the others, and later draws tested against stale depth. The cache now records, per depth and per stencil plane address, the surface that bound it last. Binding a single-sample surface without DB_DEPTH_VIEW slices takes each of its planes from that surface when both have the same format and extent: a blit copies the texture layer, or, for a combined Depth32Float_Stencil8 texture, only that plane's aspect through a buffer. The blit is committed on the backend's queue, after the passes that wrote the other surface and before the draw that binds this one. Multisampled surfaces and depth-array slices keep their own planes, as before. Clear() forgets the owners. Upstream does this in the Vulkan DepthSurface.cpp (vkCmdCopyImage, plus a pending fast clear carried over); our Metal path has no HTILE fast-clear state, so only the copy applies. Test: metal_utility_tests (DepthResource.mm, sharedPlanes) binds a depth plane with a second stencil plane, binds the same pairing again, goes back to the first pairing, binds the stencil plane with another depth plane and binds a pairing of another extent, for D16S8 and D32S8. It fails without this change ("Sampled depth plane returned incorrect GPU values"). Ported from upstream PR boykopovar#4683 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj * fix(agc): retire a Metal depth surface once another writer covers its memory A depth surface lives only in its Metal textures: nothing writes it back to guest memory. When a color target or another depth target is later bound over its memory, the surface still answered every view of that address, so a texture of another layout there threw ("resident depth view is incompatible") and a matching one read the dead depth. The surface is now retired by the last writer: - binding a color target drops the depth surfaces whose depth or stencil plane it overlaps from the draw's resident surfaces (the ones views and depth-array gathers search); - binding a depth target moves its surface last and retires the other surfaces its planes overlap: another stencil pairing of its depth plane, or a surface of another extent at its address. The lookup then finds the surface bound last, not the one bound first. The cache keeps a retired surface; binding its target again brings it back with the texels it held (with boykopovar#4683's change, a plane another pairing wrote since is copied over first). Not ported: upstream also retires a surface on a written storage image over its planes and, with write watching, on CPU or driver stores. Our Metal path has no storage view of a depth plane (a storage image at its address throws) and no write tracking for this cache, so those cases keep throwing. Recorded in TechnicalDebt. Test: metal_utility_tests (DepthResource.mm, retiredDepth): writes next to the planes retire nothing; the surface being bound is kept; a writer inside the depth or stencil plane retires it; the cache still returns it; binding a depth target of another extent at the address retires the other surface. Ported from upstream PR #454 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj * docs(agc): record the Metal depth-plane views and storage writes not modeled Upstream boykopovar#4722, boykopovar#4873, boykopovar#5054, boykopovar#5113 and boykopovar#5446 fix the Vulkan depth-plane copy (padded detiled rows and slices, a cube with a mip chain) and the storage writes over a depth plane. Our Metal path has neither: a resident depth surface is served only as a single-level 2D view or a 2D array of its extent, and a storage image over its plane is bound to guest memory. Record that in TechnicalDebt instead of porting the fixes. Refs upstream-pr-batch-1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj --------- Co-authored-by: xXPBSXx <20614131+xXPBSXx@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
What
Guest texture formats 51 (10_10_10_2 SNorm) and 55 (10_10_10_2 SInt) were missing from
kFormatLookup(TextureFormat.cpp) and from the sampled-format table inRdnaDescriptorFormat.cpp, so a texture descriptor using them threwunsupported guest texture format 51(or 55), while UNorm (50) and UInt (54) of the same group worked. The buffer-format path (SpirvBufferFormat.cpp) and the vertex-input table (VertexInput.hpp, which already maps 50 to 55 toA2B10G10R10_*) already knew them.VK_FORMAT_A2B10G10R10_SNORM_PACK32, 55 toVK_FORMAT_A2B10G10R10_SINT_PACK32(4 bytes, not block compressed).IntegerFormatinTexture.cpplists the SINT packing next to the UINT one.RunTextureFormatTestscases intests/TextureFormat.cppcheck the mappings, the element size and the numeric class of 51, 54 and 55.Why the codes are right: the numbers are the GFX10 unified texture format values. Mesa's register database (
src/amd/registers/gfx10-rsrc.json, enumGFX10_FORMAT; older Mesa trees call the enumIMG_FORMAT) listsGFX10_FORMAT_2_10_10_10_{UNORM,SNORM,USCALED,SSCALED,UINT,SINT}as 50 to 55. The repo'sIrBufferFormatcalls the same codes10_10_10_2(the name runs in the other direction), and 50 and 54 were already mapped toA2B10G10R10the same way. This is a spec-based fix; no title is named as evidence.Not covered: no GPU test of sampling 51/55 (no existing execution test creates such a texture); the clear-layout table (
ClearKindinTexture.cpp) has no entry for the new packings (it returns false for them, as before); the scaled variants 52 and 53 stay unmapped (Vulkan has no sampled USCALED/SSCALED images). Code 135 (5_5_5_1) is also missing from the table; that is left for a separate change.Tested
Windows 10, MinGW-w64 GCC 15.2.0, Release, on
main14036cb0eplus this commit (rebased afterwards ontomain0f2683cb7without a conflict, not rebuilt there):agc_driver_graphics(it runsRunTextureFormatTests): 5 of 5 runs pass (about 7 s each).TextureFormat.cpp,RdnaDescriptorFormat.cppandTexture.cpptaken back tomainand the new test kept, it fails 2 of 2 runs withAGC graphics: unsupported guest texture format 51.python tools/check_conventions.py --base upstream/mainpasses.git merge-treeof the current headc6a422342againstmain068ab2aba(13 October) is clean.c6a422342merged intomain9d0a41d5a): the five tests in this PR's targets (agc_driver_graphics,agc_sparse_buffer_holes,agc_descriptor_pool_reset_failure,agc_compute_descriptor_layout_flags,agc_driver_covered_centroid_state) pass with the PR; withmain's sources and this PR's tests onlyagc_driver_graphicsfails.agc_*tests on this branch, a GPU draw that samples 51/55, a title run.Checklist
main; no other open PR implements the same functions (searched open PRs forA2B10G10R10and the format codes: none)NotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositoryagc_driver_graphics,RunTextureFormatTests) is a host test that selects no GPU (it gives the same result withANYPS5_GPUset to a name no GPU has). Machine: Windows 10 (19045), NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1074) and AMD Radeon RX 6400 present, neither selected by this test. Not tested: a draw that samples 51/55 on any GPU.AI-assisted (Claude Code).
🤖 Generated with Claude Code