Skip to content

Textures are read back through NVRHI's staging textures - #64

Merged
ASDAlexander77 merged 1 commit into
mainfrom
nvrhi-staging-texture
Oct 13, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
nvrhi-staging-texture

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

The next NVRHI step: nvrhi_direct no longer reads its texture back through Donut. It goes through NVRHI's interfaces end to end.

  • core/nvrhi.ts:
    • entireTexture() (nvrhi::TextureSlice's defaults)
    • createStagingTexture()
    • mapStagingTexture() (returns the mapped rows; the row pitch comes back through a Ref<index>)
    • copyTexture() (texture to texture) and copyTextureToStaging()
    • layoutMatches() also compares TextureSlice (the size comes from donut_interop.cpp)
  • nvrhi_direct:
    • copies the drawn texture into a second texture, then that into a staging texture
    • maps the staging texture and reads the pixels row by row (rows are 256 bytes apart on D3D12)
    • checks IStagingTexture::getDesc
    • app.readTextureLevel is no longer used
  • The two copyTexture overload calls pass their textures through | null locals: until a tslang release includes @cpp overloads take a class for T | null and for its base class, in a partial resolve too TypeScriptCompiler#577 (TSLANG_ISSUES.md Add bundles (D3D12Bundles) #19), a class argument fits no overload.

Verified on tslang pre-alpha101:

  • Windows CTest 61/61
  • nvrhi_direct with -dx12 -debug and -vk -debug
  • JIT (run_jit.bat, donut_interop_shared rebuilt): nvrhi_direct (dx12 and vk, -debug) and headless
  • Android emulator: headless and nvrhi_direct pass on x86_64 and on arm64 (translated), with fresh binaries
  • Negative check: with the texture-to-texture copy left out, the readback is all zeros and the test fails

🤖 Generated with Claude Code

nvrhi.entireTexture() (nvrhi::TextureSlice's defaults), createStagingTexture(),
mapStagingTexture() (the mapped rows and their pitch), copyTexture() between textures and
copyTextureToStaging(). nvrhi_direct copies its drawn texture into another texture, that into a
staging texture it maps, and checks the pixels read row by row (256 bytes apart on D3D12) instead
of reading the texture through Donut; it checks IStagingTexture::getDesc too. layoutMatches()
compares TextureSlice.

The two copyTexture overloads take their textures through `| null` locals: a class argument fits
no overload until a tslang release has TypeScriptCompiler#577 (TSLANG_ISSUES.md #19).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 3a0dc2c into main Oct 13, 2026
@ASDAlexander77
ASDAlexander77 deleted the nvrhi-staging-texture branch October 13, 2026 21:39
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