Skip to content

GPU: Add SDL_CopyGPUTextureToBuffer and SDL_CopyGPUBufferToTexture - #16249

Draft
thatcosmonaut wants to merge 1 commit into
libsdl-org:mainfrom
thatcosmonaut:gpu_copies
Draft

GPU: Add SDL_CopyGPUTextureToBuffer and SDL_CopyGPUBufferToTexture#16249
thatcosmonaut wants to merge 1 commit into
libsdl-org:mainfrom
thatcosmonaut:gpu_copies

Conversation

@thatcosmonaut

Copy link
Copy Markdown
Collaborator
  • I confirm that I am the author of this code and release it to the SDL project under the zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

GPU-timelined texture-to-buffer and buffer-to-texture copies can be useful, so we should expose that capability.

I still need to investigate what expected behavior would be when copying depth data from depth-stencil textures.

D3D12's horrible design continues to be a delight. We'll need to figure out a workaround for the 256-byte alignment requirement.

Existing Issue(s)

Resolves #16248

TODO

  • How do we want to handle stencil data in depth-stencil textures?
  • Metal implementation
  • NDA implementation
  • Alignment workaround for D3D12

@thatcosmonaut thatcosmonaut added this to the 3.4.18 milestone Sep 4, 2026
@thatcosmonaut

Copy link
Copy Markdown
Collaborator Author

From MSDN...

Note If you use CopyTextureRegion with a depth-stencil buffer or a multisampled resource, you must copy the entire subresource rectangle. In this situation, you must pass 0 to the DstX, DstY, and DstZ parameters and NULL to the pSrcBox parameter. In addition, source and destination resources, which are represented by the pSrcResource and pDstResource parameters, should have identical sample count values.

So you can't copy subregions of a depth texture (or a multisampled resource, though that's less useful in practice.) I guess we can validate this? It's a very annoying restriction.

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.

GPU: GPUBuffer <-> GPUTexture copies?

1 participant