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

Merged
Sheffy007 merged 1 commit from upstream-pr/183 into main 2026-11-26 23:58:10 +00:00
Sheffy007 commented 2026-11-26 23:15:23 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-26T23:15:23Z.


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
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5518430123 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/183). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-26T23:15:23Z. --- ## 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`
LakshanSivakumar commented 2026-11-26 23:58:06 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T23:58:06Z.

Review: APPROVED


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6081772741 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/183#pullrequestreview-6081772741). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T23:58:06Z. **Review:** APPROVED --- Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!183
No description provided.