feat(gpu): implement GPU texture copies for CopyResource and CopyTextureRegion #183

Manually merged
github merged 1 commit from gh-pr/183/head into gh-pr/183/base 2026-11-27 00:53:20 +00:00
Owner

@⁠Sheffy007 on GitHub · 2026-11-26 23:15 UTC · original
Sheffy007:feat/native-texture-copies → main · +979 −13 · 9 files · 1 commits · merged 2026-11-26 23:58 UTC

Summary

CopyResource between textures and CopyTextureRegion on macOS previously logged "a texture copy or resolve" and dropped all operations (texture_copies counter). This implements GPU-side texture copies in Pass::Blit via MTLBlitCommandEncoder:

  • crates/victory-backend/src/resources.rs: add BlitOp::CopyTexture, BlitOp::CopyBufferToTexture, and BlitOp::CopyTextureToBuffer.
  • crates/victory-metal/src/gfx.rs: encode MTLBlitCommandEncoder texture-to-texture, buffer-to-texture, and texture-to-buffer copies with bounds, pitch/offset alignment, castable format view casting (newTextureViewWithPixelFormat), and depth-buffer transfer guards.
  • crates/victory-gpu/src/native/list.rs, host.rs, glue.rs, crates/victory-gpu/src/list.rs: record and schedule CopyResource (texture-to-texture) and CopyTextureRegion (subresource-to-subresource and placed footprint <-> subresource) on macOS, falling back to dropped_op only for unsupported transfers (B4G4R4A4_UNORM/depth buffer transfers or out-of-range subresources/planes).
  • crates/victory-metal/tests/resources.rs, crates/victory-gpu/src/native/texture_tests.rs: add Metal API validation tests covering buffer <-> texture and castable format texture-to-texture copies through both the backend and D3D12 list vtable.
  • docs/native-host.md: document native texture copy behavior.

Verification

  • MTL_DEBUG_LAYER=1 cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtask
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
**@⁠Sheffy007** on GitHub · 2026-11-26 23:15 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/183) `Sheffy007:feat/native-texture-copies` → `main` · +979 −13 · 9 files · 1 commits · merged 2026-11-26 23:58 UTC ## Summary `CopyResource` between textures and `CopyTextureRegion` on macOS previously logged `"a texture copy or resolve"` and dropped all operations (`texture_copies` counter). This implements GPU-side texture copies in `Pass::Blit` via `MTLBlitCommandEncoder`: - `crates/victory-backend/src/resources.rs`: add `BlitOp::CopyTexture`, `BlitOp::CopyBufferToTexture`, and `BlitOp::CopyTextureToBuffer`. - `crates/victory-metal/src/gfx.rs`: encode `MTLBlitCommandEncoder` texture-to-texture, buffer-to-texture, and texture-to-buffer copies with bounds, pitch/offset alignment, castable format view casting (`newTextureViewWithPixelFormat`), and depth-buffer transfer guards. - `crates/victory-gpu/src/native/list.rs`, `host.rs`, `glue.rs`, `crates/victory-gpu/src/list.rs`: record and schedule `CopyResource` (texture-to-texture) and `CopyTextureRegion` (subresource-to-subresource and placed footprint <-> subresource) on macOS, falling back to `dropped_op` only for unsupported transfers (`B4G4R4A4_UNORM`/depth buffer transfers or out-of-range subresources/planes). - `crates/victory-metal/tests/resources.rs`, `crates/victory-gpu/src/native/texture_tests.rs`: add Metal API validation tests covering buffer <-> texture and castable format texture-to-texture copies through both the backend and D3D12 list vtable. - `docs/native-host.md`: document native texture copy behavior. ## Verification - `MTL_DEBUG_LAYER=1 cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtask` - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:53:17 +00:00
github manually merged commit 5961cbf6fb into gh-pr/183/base 2026-11-27 00:53:20 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 23:58 UTC · original · approved these changes

Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 23:58 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/183#pullrequestreview-6081772741) · **approved these changes** Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.