Preserve fractional viewport coverage in attachmentless draws #2271

Open
github-bot wants to merge 1 commit from github-bot/gh-2271 into main AGit
Owner

@⁠Bonchaloo on GitHub · 2026-11-26 11:57 UTC · original
Bonchaloo:fix/attachmentless-fractional-area → main · +25 −6 · 2 files · 1 commits · draft

Claimed in #1608 as RT-ATTACHMENTLESS-FRACTIONAL-AREA.

Fix

With no color or depth attachment, Vulkan replay derives the render area from the viewports. Converting their right and bottom edges directly to integers could clip a row or column that contains covered samples. Round the maximum right and bottom edges outward after considering all viewports.

Tests

  • The replay regression fails on the parent commit for a viewport ending at (3.75, 2.75). With this change the recorded render area is 4×3. A second viewport extending to y = 5.75 produces 4×6, and the integer 8×8 control retains its extent.
  • Five focused CTests passed: state map, bounded index view, quad-list replay, and both pipeline compile replay modes. The changed files passed the no-game-data check.
  • GPU tested: Apple M5 Max, Apple Metal driver, macOS 27.3. A separate synthetic attachmentless Metal draw with the same fractional viewport wrote six pixel positions with a 3×2 render area and twelve with a 4×3 area. The regression test captures the Vulkan command; the Metal probe measures raster coverage.

Full native runtime CTest suite on Apple M5 Max with MoltenVK 1.4.2: 105 passed, 0 failed, 3 skipped (shader_library_corpus, vk_device_markers, vk_sync_validation).

AI-assisted: yes.

**@⁠Bonchaloo** on GitHub · 2026-11-26 11:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2271) `Bonchaloo:fix/attachmentless-fractional-area` → `main` · +25 −6 · 2 files · 1 commits · draft Claimed in [#1608 as RT-ATTACHMENTLESS-FRACTIONAL-AREA](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). ### Fix With no color or depth attachment, Vulkan replay derives the render area from the viewports. Converting their right and bottom edges directly to integers could clip a row or column that contains covered samples. Round the maximum right and bottom edges outward after considering all viewports. ### Tests - The replay regression fails on the parent commit for a viewport ending at (3.75, 2.75). With this change the recorded render area is 4×3. A second viewport extending to y = 5.75 produces 4×6, and the integer 8×8 control retains its extent. - Five focused CTests passed: state map, bounded index view, quad-list replay, and both pipeline compile replay modes. The changed files passed the no-game-data check. - GPU tested: Apple M5 Max, Apple Metal driver, macOS 27.3. A separate synthetic attachmentless Metal draw with the same fractional viewport wrote six pixel positions with a 3×2 render area and twelve with a 4×3 area. The regression test captures the Vulkan command; the Metal probe measures raster coverage. Full native runtime CTest suite on Apple M5 Max with MoltenVK 1.4.2: 105 passed, 0 failed, 3 skipped (shader_library_corpus, vk_device_markers, vk_sync_validation). AI-assisted: yes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:58:36 +00:00
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 12:24 UTC · original

Verified on main a73a57e1 (Ubuntu 24.04 x86-64, GCC 13.3, CMake 3.28, Ninja, no GPU). Merges cleanly. ctest -R '^d3d12_state_map$' passes with this PR; the PR's runtime/test/d3d12_state_map_test.cpp built against main's vulkan_replay.h fails, so the new case fails on main and passes with the change.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 12:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2271#issuecomment-7191951647) Verified on main a73a57e1 (Ubuntu 24.04 x86-64, GCC 13.3, CMake 3.28, Ninja, no GPU). Merges cleanly. ctest -R '^d3d12_state_map$' passes with this PR; the PR's runtime/test/d3d12_state_map_test.cpp built against main's vulkan_replay.h fails, so the new case fails on main and passes with the change. AI-assisted: yes (Claude Code)
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 14:20 UTC · original

On an RTX 4090, the fractional viewport in the PR covered six samples with the parent’s render area and twelve with the PR’s. The six recovered samples are exactly the missing right column and bottom row.

I captured the Vulkan viewport, scissor and attachmentless render area emitted by replay at parent a73a57e13 and head 39434d439. I then applied those states in a separate Vulkan dynamic-rendering probe. It drew two triangles forming a viewport-sized quad, at one sample per pixel, with a fixed 8×8 scissor. A precise occlusion query counted the samples. Per-pixel queries located them on an 8×8 grid.

Synthetic case Parent samples PR samples Expected from pixel centers
PR example, right/bottom edges at (3.75, 2.75) 6 12 12
Fractional right edge only 12 16 16
Fractional bottom edge only 8 12 12
Shifted viewport with two fractional edges 6 12 12
Edges at (3.25, 2.25) 6 6 6
Integer 8×8 viewport 64 64 64
Integer viewport at an offset 6 6 6

All seven head coverage masks matched the pixel-center reference, including the quarter-pixel case where outward rounding adds no covered sample. The 30 distinct GPU configurations included a full 8×8 render-area control and an explicit scissor control. Zero Vulkan validation errors. Windows 11, NVIDIA 616.64, synthetic inputs.

AI-assisted verification by OpenAI Codex (GPT-6).

**@⁠ecox982745** on GitHub · 2026-11-26 14:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2271#issuecomment-7194653579) On an RTX 4090, the fractional viewport in the PR covered six samples with the parent’s render area and twelve with the PR’s. The six recovered samples are exactly the missing right column and bottom row. I captured the Vulkan viewport, scissor and attachmentless render area emitted by replay at parent `a73a57e13` and head `39434d439`. I then applied those states in a separate Vulkan dynamic-rendering probe. It drew two triangles forming a viewport-sized quad, at one sample per pixel, with a fixed 8×8 scissor. A precise occlusion query counted the samples. Per-pixel queries located them on an 8×8 grid. | Synthetic case | Parent samples | PR samples | Expected from pixel centers | | --- | ---: | ---: | ---: | | PR example, right/bottom edges at (3.75, 2.75) | 6 | 12 | 12 | | Fractional right edge only | 12 | 16 | 16 | | Fractional bottom edge only | 8 | 12 | 12 | | Shifted viewport with two fractional edges | 6 | 12 | 12 | | Edges at (3.25, 2.25) | 6 | 6 | 6 | | Integer 8×8 viewport | 64 | 64 | 64 | | Integer viewport at an offset | 6 | 6 | 6 | All seven head coverage masks matched the pixel-center reference, including the quarter-pixel case where outward rounding adds no covered sample. The 30 distinct GPU configurations included a full 8×8 render-area control and an explicit scissor control. Zero Vulkan validation errors. Windows 11, NVIDIA 616.64, synthetic inputs. AI-assisted verification by OpenAI Codex (GPT-6).
Author
Owner

@⁠Bonchaloo on GitHub · 2026-11-26 14:50 UTC · original

Confirmed the seven coverage cases above in an independent native Metal probe on Apple M5 Max (macOS 27.3). Two triangles formed a viewport-sized quad in an attachmentless, single-sample pass. Compared every pixel in an 8×8 mask to a pixel-center reference with the truncated and outward-rounded extents.

Covered samples (truncated → outward): original 6 → 12, fractional right edge 12 → 16, fractional bottom edge 8 → 12, shifted viewport 6 → 12, quarter-pixel edges 6 → 6, integer viewport 64 → 64, offset integer viewport 6 → 6. All 14 masks matched. This tests raster coverage directly in Metal; the PR’s replay regression separately checks the Vulkan render area.

AI-assisted: yes.

**@⁠Bonchaloo** on GitHub · 2026-11-26 14:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2271#issuecomment-7195411487) Confirmed the seven coverage cases above in an independent native Metal probe on Apple M5 Max (macOS 27.3). Two triangles formed a viewport-sized quad in an attachmentless, single-sample pass. Compared every pixel in an 8×8 mask to a pixel-center reference with the truncated and outward-rounded extents. Covered samples (truncated → outward): original 6 → 12, fractional right edge 12 → 16, fractional bottom edge 8 → 12, shifted viewport 6 → 12, quarter-pixel edges 6 → 6, integer viewport 64 → 64, offset integer viewport 6 → 6. All 14 masks matched. This tests raster coverage directly in Metal; the PR’s replay regression separately checks the Vulkan render area. AI-assisted: yes.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2271/head:github-bot/gh-2271'
git switch 'github-bot/gh-2271'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2271'
git switch 'github-bot/gh-2271'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2271'
git switch 'github-bot/gh-2271'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2271'
git switch 'main'
git merge --squash 'github-bot/gh-2271'
git switch 'main'
git merge --ff-only 'github-bot/gh-2271'
git switch 'main'
git merge 'github-bot/gh-2271'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.