Skip to content

compute: lower the depth sample CL variants - #3617

Open
lambirou wants to merge 7 commits into
R0Y00:mainfrom
lambirou:compute/sample-depth-cl
Open

lambirou wants to merge 7 commits into
R0Y00:mainfrom
lambirou:compute/sample-depth-cl

Conversation

@lambirou

Copy link
Copy Markdown
Contributor

Stacked on #3604 and #3614 (compute/gather4-variants → compute/sample-cl): the diff includes those commits until they land. Rebase after they merge.

Part of the MIMG slice (P6). This adds the twenty depth/gradient sample CL forms: image_sample_c_cd*, image_sample_c_d_cl*, image_sample_cd_cl* and image_sample_d_cl*, with the _cl, _o and _g16 suffixes.

The RDNA 2 operand order is respected: packed offset, comparison reference, gradients, U, V, LOD clamp. The LOD is computed at translation time from the static slopes and the base view size declared by --sample-gradient-view WIDTH HEIGHT MIPS: the larger axis length, nearest mip, then the minimum-LOD clamp. _g16 packs U in the low half and V in the high half. Comparison forms use dmask:0x1, a single VGPR destination and a finite reference in [0, 1]; non-comparison forms use dmask:0xf and four VGPRs. Descriptors, the constant sampler, an unguarded lane, a single view and static operands are validated; dynamic or out-of-view cases are refused. The other sample suffixes fall through to the generic refusal.

Tests

  • compute_store_aot_gfx1013_sample_depth_cl_warp and _hardware pass: 26 cases and 5 mutants detected on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).
  • gather4_l, gather4_variants and sample_cl still pass on both adapters (8/8 in the combined run), and compute_store_aot_gfx1013_image_store_warp passes.
  • form_coverage_check.py pins exactly the twenty forms; docs_links_check.py passes; compute_mimg_float_store_check.py passes after restoring the generic refusal for image_sample_l.
  • Expected delta: +20 forms on gfx1013 and +20 on gfx1030. On top of the stack's 1,640/1,594, the three PRs reach 1,660/1,614.

Limits

The model loads a texel at an explicit mip; it does not prove the console's native derived LOD. Slopes, coordinates, offsets, references and clamps must be static and lane-uniform; coarse forms assume uniform slopes. No llvm-mc round-trip, debug layer or console measurement was run. The sample_cl base/bias/compare forms keep their own record, and the BVH forms stay uncovered.

AI-assisted.

@lambirou lambirou left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed a8db8d69 against #3614 (ac19d70d), focusing on the depth/gradient delta; not built or run.

Verdict: approve for this delta; merge after #3614. The twenty _d_cl/_cd_cl forms and their _g16/_o variants use the explicit gradient path, not the bias path that #3614 must fix. The sampler checks, operand order, g16 unpacking, comparison direction and offset clamp match the existing sample-CL model.

  • SHOULD The fixture computes its expected mip with aot.sample_gradient_level, the same function as the translator, so a wrong gradient model would pass the draw. The cases use exact one/two-octave slopes; add one row whose expected level is hand-computed or comes from a desktop sampler, especially at a rounding boundary.
  • NIT sample_gradient_level uses Python double intermediates for hypot/log2; the hardware path is float32. The exact slopes avoid the difference today, but a boundary row would either justify the double path or expose a float32 rounding difference.
  • Checked, no finding: _g16 packs U/V in the low/high halves and refuses subnormal components; the _c_cd/_c_d comparison forms take red DMASK 0x1 and a static reference; the descriptor/sampler checks match the sample-CL path; out-of-range gradients are refused rather than silently clamped.
  • The inherited CL bias branch from #3614 remains in the diff; it will be fixed there before this PR is rebased.

@R0Y00

R0Y00 commented Dec 3, 2026

Copy link
Copy Markdown
Owner

At 2dfa8d4 the gather4, sample-cl and sample-depth-cl fixtures passed on WARP and RTX 4060 Laptop, including their mutation controls, with the D3D12 debug layer enabled. The offset correction matches #3604. Please leave this stacked behind #3604 and #3614 while the base bias question is open, then refresh against the landed commits so the PR diff can be reviewed as a depth-sample delta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants