Skip to content

feat(mesh): add vs-in stage for input-assembler mesh export (#224)#227

Merged
BANANASJIM merged 4 commits into
masterfrom
feat/224-vsin-mesh
May 16, 2026
Merged

feat(mesh): add vs-in stage for input-assembler mesh export (#224)#227
BANANASJIM merged 4 commits into
masterfrom
feat/224-vsin-mesh

Conversation

@BANANASJIM
Copy link
Copy Markdown
Owner

@BANANASJIM BANANASJIM commented May 15, 2026

Part 1 of #224.

What

Exposes the VS input (input-assembler) mesh through rdc mesh --stage vs-in. Previously only post-transform geometry (vs-out/gs-out) was reachable; debugging original model geometry, vertex layout, skinning inputs, or index ranges required a custom RenderDoc Python script.

Changes

  • handlers/buffer.py: add "vs-in": 0 (MeshDataStage.VSIn) to _MESH_STAGE_MAP; invalid-stage error string now lists vs-in, vs-out, gs-out.
  • commands/mesh.py: --stage Click Choice accepts vs-in.
  • Non-draw events: vs-in inherits the existing -32001 "no PostVS data at this event" contract unchanged (same as vs-out/gs-out) — no silent-empty path was added.

Tests

  • Handler: vs-in geometry decode (via the set_mesh_data mock helper), non-draw -32001, invalid-stage message.
  • CLI: --stage vs-in accepted & forwarded; unknown stage rejected.
  • @pytest.mark.gpu Vulkan integration test (vkcube).
  • Full suite: 2851 passed, 6 skipped, 92.66% coverage; ruff + mypy strict clean.

Verification

Verified end-to-end on Linux/Vulkan. D3D12-specific behavior cannot be verified on the dev box (Linux replay is Vulkan-only) — reporter verification on a real D3D12 capture is requested before merge.

OpenSpec: openspec/changes/2026-05-15-issue-224-vsin-mesh/. Completes part of the unshipped CLI plan from the archived 2026-02-19-phase2-buffer-decode change.

Summary by CodeRabbit

  • New Features

    • The mesh command now accepts a new vs-in stage option to retrieve VS-In mesh output.
  • Bug Fixes

    • Corrected mesh decoding so exported geometry and indices match expected post-VS results.
    • CLI now warns when a non-triangle topology yields no OBJ faces.
  • Tests

    • Added unit and real integration tests for vs-in, decoding, error cases, and CLI behavior.
  • Documentation

    • Added proposal, spec, tasks, and test plan describing vs-in behavior and error contracts.

Review Change Stack

Expose vertex shader input (VS-In, MeshDataStage.VSIn=0) geometry through
the rdc mesh command and the daemon mesh_data handler:

- buffer.py: add "vs-in": 0 to _MESH_STAGE_MAP; update invalid-stage
  error string to list vs-in, vs-out, gs-out
- mesh.py: add "vs-in" to the --stage Click Choice
- mock_renderdoc.py: add set_mesh_data helper to key GetPostVSData by
  stage int; unconfigured stages keep the -32001 non-draw contract

Non-draw events inherit the existing -32001 "no PostVS data at this
event" contract unchanged. Includes unit tests for handler decode,
non-draw error, invalid-stage message, CLI forwarding, plus a gpu-marked
Vulkan integration test.
…ref (#224)

- Rewrite test_vs_in_decodes_geometry to use MockReplayController +
  set_mesh_data(0, MeshFormat(...)) instead of monkeypatching GetPostVSData
  directly, so the real helper is exercised by the test suite.
- Correct tasks.md Phase A verification path from tests/mocks/test_mock_api_sync.py
  to tests/integration/test_mock_api_sync.py (the file exists there).
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 650bfdb2-2b81-454d-a126-67cb5be4d964

📥 Commits

Reviewing files that changed from the base of the PR and between 09b5081 and 21ba08d.

📒 Files selected for processing (5)
  • openspec/changes/2026-05-15-issue-224-vsin-mesh/proposal.md
  • src/rdc/commands/mesh.py
  • src/rdc/handlers/buffer.py
  • tests/unit/test_buffer_decode.py
  • tests/unit/test_mesh_commands.py

📝 Walkthrough

Walkthrough

This PR extends the rdc mesh command to support the vs-in (vertex shader input) mesh stage. Changes include OpenSpec updates, daemon stage mapping and decoder fixes, mock test utilities, CLI --stage acceptance and warnings, unit tests for decoding and CLI behavior, and a real-capture integration test.

Changes

VS-In Mesh Stage Support

Layer / File(s) Summary
Requirements and Specification
openspec/changes/2026-05-15-issue-224-vsin-mesh/proposal.md, openspec/changes/2026-05-15-issue-224-vsin-mesh/specs/daemon/spec.md, openspec/changes/2026-05-15-issue-224-vsin-mesh/tasks.md, openspec/changes/2026-05-15-issue-224-vsin-mesh/test-plan.md
OpenSpec proposal and daemon specification define vs-in as a valid mesh stage calling GetPostVSData with stage integer 0, returning decoded OBJ output, and returning JSON-RPC error -32001 when no PostVS data exists; invalid-stage error must list vs-in, vs-out, and gs-out. Tasks and test plan enumerate implementation phases and test matrix.
Mock Infrastructure for Testing
tests/mocks/mock_renderdoc.py
MockReplayController.set_mesh_data allows tests to configure MeshFormat return values per stage; GetPostVSData docstring updated to describe default empty MeshFormat for unconfigured stages.
Daemon Handler Stage Mapping and Decoding
src/rdc/handlers/buffer.py
_MESH_STAGE_MAP now includes vs-in; invalid-stage error text expanded. Vertex decoding reads vertex buffer from offset 0 and applies vertexByteOffset when computing per-vertex positions; index decoding applies baseVertex and respects indexByteStride.
CLI Implementation and Warnings
src/rdc/commands/mesh.py
--stage Click choices expanded to include vs-in; warning emitted to stderr when topology yields zero OBJ faces (emitted for both JSON and OBJ outputs).
Unit Tests: buffer decode (vs-in)
tests/unit/test_buffer_decode.py
New tests exercise stage="vs-in" decoding on draw events, verify JSON-RPC -32001 for non-draw events, assert invalid-stage error lists all supported stages, and validate baseVertex/index/vertexByteOffset/indexByteStride behaviors.
Unit Tests: CLI behavior & topology warnings
tests/unit/test_mesh_commands.py
Tests verify --stage vs-in is forwarded to the daemon call, unknown --stage is rejected with Click exit code 2, and non-triangle topology emits the no-face warning across JSON/OBJ modes.
Integration: real capture test
tests/integration/test_daemon_handlers_real.py
test_mesh_data_vs_in_real calls mesh_data with stage="vs-in" on a real capture and asserts returned stage, vertex_count > 0, and len(vertices) == vertex_count.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit peers at meshes thin and fine,
VS-In whispers vertices in line,
Mocked and real, the tests hop through the gate,
CLI, daemon, decoder — every check in state,
I nibble bugs and celebrate the crate. 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes the main change: adding support for the vs-in stage to export input-assembler mesh data. It is concise, specific, and directly matches the primary objective of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/224-vsin-mesh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openspec/changes/2026-05-15-issue-224-vsin-mesh/proposal.md`:
- Around line 48-49: The markdown at the proposal mentions "Triangle*
topologies" which treats the asterisk as emphasis; update the text in
proposal.md to prevent MD037 by either escaping the star (Triangle\*) or
wrapping the term in a code span (`Triangle*`), e.g., change the phrase near the
OBJ face generator reference to use Triangle\* or `Triangle*` so the markdown
linter no longer flags malformed emphasis; keep the surrounding sentence intact
and ensure other occurrences of "Triangle*" in the paragraph are updated
similarly.

In `@openspec/changes/2026-05-15-issue-224-vsin-mesh/test-plan.md`:
- Line 58: The code span "`v `" in the test-plan assertion includes a trailing
space and triggers markdownlint MD038; update the sentence to remove the space
inside the code span and rephrase to something like “Assert OBJ contains lines
starting with `v`; count matches reported vertex count from `MeshFormat`” so the
code span is just `v` and the meaning remains clear. Ensure the change touches
the test-plan.md assertion that mentions `MeshFormat` and replaces the
backticked `v ` with a non-space code span or descriptive wording such as "lines
starting with `v`".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a99286fd-d7a4-4d4e-be73-d1cabdac9b82

📥 Commits

Reviewing files that changed from the base of the PR and between 9ac831b and 09b5081.

📒 Files selected for processing (10)
  • openspec/changes/2026-05-15-issue-224-vsin-mesh/proposal.md
  • openspec/changes/2026-05-15-issue-224-vsin-mesh/specs/daemon/spec.md
  • openspec/changes/2026-05-15-issue-224-vsin-mesh/tasks.md
  • openspec/changes/2026-05-15-issue-224-vsin-mesh/test-plan.md
  • src/rdc/commands/mesh.py
  • src/rdc/handlers/buffer.py
  • tests/integration/test_daemon_handlers_real.py
  • tests/mocks/mock_renderdoc.py
  • tests/unit/test_buffer_decode.py
  • tests/unit/test_mesh_commands.py

Comment thread openspec/changes/2026-05-15-issue-224-vsin-mesh/proposal.md Outdated
- Analogous to `test_mesh_data_real` (~line 1573 in `test_daemon_handlers_real.py`).
- Open a vkcube Vulkan capture; pick a draw eid known to have vertex data.
- Call handler with `stage=vs-in`; assert OBJ output is non-empty and vertex count > 0.
- Assert OBJ contains `v ` lines; count matches reported vertex count from `MeshFormat`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix code-span whitespace at Line 58.

v inside backticks includes a trailing space and can trigger markdownlint MD038. Rephrase to avoid space inside the code span (e.g., “lines starting with v”).

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 58-58: Spaces inside code span elements

(MD038, no-space-in-code)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openspec/changes/2026-05-15-issue-224-vsin-mesh/test-plan.md` at line 58, The
code span "`v `" in the test-plan assertion includes a trailing space and
triggers markdownlint MD038; update the sentence to remove the space inside the
code span and rephrase to something like “Assert OBJ contains lines starting
with `v`; count matches reported vertex count from `MeshFormat`” so the code
span is just `v` and the meaning remains clear. Ensure the change touches the
test-plan.md assertion that mentions `MeshFormat` and replaces the backticked `v
` with a non-space code span or descriptive wording such as "lines starting with
`v`".

…tri topology (#224)

Cross-check against RenderDoc decode_mesh.py reference revealed the
OpenSpec premise 'no changes needed below the map' was invalid for vs-in:

- Apply mesh.baseVertex to decoded indices uniformly (no-op for
  vs-out/gs-out where baseVertex==0), matching the reference.
- Read the position attribute at i*stride + mesh.vertexByteOffset
  instead of i*stride, so vs-in positions are correct when POSITION
  is not the first interleaved element.
- Index width follows mesh.indexByteStride (16/32-bit); regression
  tested explicitly.
- mesh CLI now emits a clear stderr warning naming the topology when
  a non-triangle topology produces 0 OBJ faces (no silent loss).
- Retract the invalid premise in the OpenSpec proposal and document
  vs-in support and limitations.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@BANANASJIM BANANASJIM merged commit 072cc49 into master May 16, 2026
17 checks passed
@BANANASJIM BANANASJIM deleted the feat/224-vsin-mesh branch May 19, 2026 00:10
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.

1 participant