Skip to content

Texture.GetData fails on a depth-stencil texture on Direct3D 12 and Vulkan #4014

Open

Description

@sasvdw

Release Type: Built from source

Version: master

Platform(s): Windows, Direct3D 12 and Vulkan. Direct3D 11 works.

Describe the bug

GetData on a texture with a depth-stencil format, for example D24_UNorm_S8_UInt, copies the depth and the stencil to the staging resource in one copy. Direct3D 12 and Vulkan copy only one plane (D3D12) or one aspect (Vulkan) at a time.

  • Direct3D 12: CopyTextureToStagingTexture (CommandList.Direct3D12.cs, around line 1613) gives the depth-stencil format to the footprint. The debug layer says: CopyTextureRegion: D3D12_SUBRESOURCE_FOOTPRINT::Format may not be a ...R24G8_TYPELESS family format. These formats are planar. Then CommandList.Close() throws a COMException.
  • Vulkan: the copy (CommandList.Vulkan.cs, around line 1539) uses NativeImageAspect, which is depth and stencil together. The validation layer says: vkCmdCopyImageToBuffer(): imageSubresource.aspectMask is DEPTH|STENCIL (only one bit allowed) (VUID-VkBufferImageCopy-aspectMask-09103). Then the test host crashes.

To Reproduce

  1. Make a game with GraphicsDeviceManager.PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt.
  2. After a frame, call GraphicsDevice.Presenter.DepthStencilBuffer.GetData<uint>(commandList).
  3. Run it on Direct3D 12 or Vulkan.

Expected behavior

GetData returns the depth (and stencil) data, as on Direct3D 11. Or, if Stride does not support this readback, it throws a clear exception before it records the copy.

Log and callstacks

Direct3D 12:

System.Runtime.InteropServices.COMException : Unexpected HRESULT has been returned from a call to a COM component.
   at Stride.Graphics.CommandList.Close() in ...\Direct3D12\CommandList.Direct3D12.cs:line 233
   at Stride.Graphics.CommandList.Flush() in ...\Direct3D12\CommandList.Direct3D12.cs:line 211
   at Stride.Games.GameBase.EndDraw(Boolean present)

Additional context

Found while writing a test for #3252. That test now reads the depth through a shader.

Activity

  1. added
    bug
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Graphicsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions