0

I am trying to map a offscreen D2D render target to memory.

  • The render target is created as a ID3D12Resource with D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET
  • Then passed through ID3D11On12Device::CreateWrappedResource()
  • Then made into a ID2D1Bitmap1 with ID2D1DeviceContext2::CreateBitmapFromDxgiSurface

The app draws on it with D2D, then it is used as a pixel shader resource in a D3D12 shader and I can verify that the content of the texture is correct this way.

However, if I copy it to a D3D12_HEAP_TYPE_READBACK resource through CopyTextureRegion, it comes back as fully set to 0. The code I use works for other textures. I tried after the D3D11DeviceContext is flushed, and also after the Present to screen is done.

I also tried to copy and map it in the D2D realm, but I have the same result. I feel this resource is special in some way and I'm missing something.

Olivia Stork
  • 4,660
  • 5
  • 27
  • 40
joelr
  • 356
  • 1
  • 2
  • 11

1 Answers1

0

I fixed this issue. The problem was that I was outputting to a bitmap without alpha support, in combination with bad BlendDesc parameters. I confirm that D3D11On12 offscreen render targets work the same as any other resources when it comes to copying to a readback resource.

joelr
  • 356
  • 1
  • 2
  • 11