Repository navigation
feat(agc): single-sample sample masks as a per-quad-pixel discard - #448
MichonGoddijn231849 wants to merge 9 commits into
Conversation
|
The quad mask decode matches PA_SC_AA_MASK at one sample, and the GPU test is nice. One exactness point: the mask is applied with an OpKill at the top of the shader. On the hardware, a pixel that AA_MASK leaves uncovered still runs as a helper lane of its quad, so derivatives in the covered pixels stay defined. After OpKill, Vulkan no longer keeps that invocation as a helper, so implicit-LOD samples and other derivatives in the remaining pixels are undefined, and with one covered pixel per quad that's every quad. |
|
Good catch, thanks. Done in 7316e3a:
One honest limit: on my RTX 5080 the test passes even with |
7316e3a to
52716a3
Compare
|
Thanks, that's what I meant. Demote is only emitted when the device enabled One small thing for the path without demote, not blocking: a program that runs |
52716a3 to
bed8cb0
Compare
|
Done in bed8cb0: Also rebased onto current |
bed8cb0 to
eecdf09
Compare
|
Rebased onto current
The request version also moved: #423 now uses version 8 ( |
…river; capabilities only where enabled agc_driver_vertex_clip_cull_distances draws with clip planes, a sparse CLIP_DIST_ENA (0x5) and cull enables; agc_driver_vertex_clip_cull_draw (and _no_key) submits the same through PM4. ShaderValidation accepts the ClipDistance/CullDistance capabilities only when the device enabled the features, and names PA_CL_VS_OUT_CNTL when it refuses. A version-12 vertex request reads paClVsOutCntl as 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With one sample, PA_SC_AA_MASK leaves one coverage bit per pixel of the 2x2 quad, so a draw can cover only some pixels of every quad (GTA V renders a target one quarter of the pixels at a time this way). The pixel stage info carries that 4-bit mask; a fragment shader whose mask is not full starts by killing the invocation unless its gl_FragCoord quad position is covered, and runs without early fragment tests. The mask is part of the recompile cache key and the serialized request (version 8). Sample masks of multisampled draws stay refused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With PA_SC_AA_MASK covering only some pixels of a quad, the uncovered pixels run on the hardware as helper lanes, so derivatives of the covered pixels stay defined. OpKill ends those invocations; OpDemoteToHelperInvocation keeps them as helpers. The device enables VK_EXT_shader_demote_to_helper_invocation when available and passes the DemoteToHelperInvocation capability and its SPIR-V extension to the recompiler target and the graphics shader validation. A demoted pixel also reads as a helper, so its initial EXEC bit is clear as on the hardware. Without demote, OpKill stays for pixel programs that read no neighbouring lanes; implicit-LOD sampling, LOD queries and cross-lane reads are refused. The quad pixel mask execution test now also samples a mipmapped texture with implicit LOD under the mask. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ask without demote A program that enables whole-quad mode (s_wqm_b64) and then reads a ballot or readfirstlane sees the helper lanes, which OpKill removes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
31d4763 to
a7faa10
Compare
|
Parked as a draft to keep my rebase load sane after #639. I'll rebase it when someone wants to review it. |
|
I recovered this implementation on current main (18c438b), retaining your three original commits and authorship, and prepared a verified branch at Adversarial verification found that the no-demote guard also needs ReadFirstLane, Ballot and PermuteU32: explicit EXEC can enable uncovered helpers, and a constant WQM instruction can fold away before analysis. The added CPU regression fails on the recovered implementation and passes with those three classifications. Unmasked programs, supported demote paths, and the constant-colour kill fallback are checked as controls. The real DCB test fails at the unsupported-mask runtime path without the implementation. With it, non-skipped GPU readbacks pass for driver mask changes, 1x depth/stencil suppression and fragment stores, 4x uniform/varying coverage, per-sample stores, and implicit-LOD helper preservation. Current-main shader-memory and focused no-demote checks also pass; conventions are clean. GTA gameplay validation is still pending. GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100. AI-assisted: yes. Co-Authored-By: Codex noreply@openai.com |
|
@fdfawef324 the GTA gameplay check for Base:
AI-assisted (Claude Code). |
|
@fdfawef324 thanks for recovering this on current |
|
Opened #6015 with @fdfawef324's |
What
Draws whose
PA_SC_AA_MASKwas not all ones were refused withsample masks are unsupported. At one sample, each pixel of the 2x2 quad keeps a single coverage bit (bit 0 of its 16-bit field). So the mask chooses which pixels of every quad a draw may write. GTA V uses0xffff0000/0x00000000to render a target one quarter of its pixels at a time (pixel (1, 0) of each quad).DecodePixelStageInforeduces the two registers to a 4-bitquadPixelMask(bit(x & 1) | (y & 1) << 1). The state rule and the draw precheck now refuse partial masks only on multisampled draws.ShaderPixelStageInfo::quadPixelMask. A fragment shader whose mask is not full:gl_FragCoordquad position is set (theFragCoordinput is added for it);Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.
ctest: all tests pass. New cases:agc_driver_quad_pixel_maskdraws a full-screen triangle on the GPU with masks 0xf, 0x2 and 0x9, and checks every pixel;PA_SC_AA_MASKdecodes to the quad mask;sample masks are unsupported. They now render, and the scene looks as before. Tested on my branch that combines this change with my other open PRs.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code