baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.
https://renderdoc.org
MIT License
8.88k stars 1.33k forks source link

D3D12 + enhanced barriers + renderpasses: Some texture resources are marked with "undefinedimg" #3450

Closed godlikepanos closed 6 days ago

godlikepanos commented 6 days ago

Description

I have an application that uses D3D12's enhanced barriers and renderpasses. In my captures and in the texture viewer I see a lot of "undefinedimg" and I'm not sure these come from. For example I have a depth texture that is used like this:

  1. A renderpass renders to it: BeginRenderPass has this texture as preserve and EndRenderPass has it as preserve as well
  2. A barrier that transitions it: AccessBefore D3D12_BARRIER_ACCESS_DEPTH_STENCIL_WRITE, AccessAfter D3D12_BARRIER_ACCESS_SHADER_RESOURCE and LayoutBefore D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE, LayoutAfter D3D12_BARRIER_LAYOUT_SHADER_RESOURCE
  3. A dispatch that uses it as SRV

When I click on the dispatch and try to view the inputs this texture appears full of undefinedimg which I don't think it's correct.

Steps to reproduce

This is a capture that exhibits the problem: https://drive.google.com/file/d/1bccfKskWqvhSAORcgmHal6-uEdFlLbIl/view?usp=sharing (Captured on nVidia 4080)

If you search for a resource named "ShadowAtlas" you will see the case I described above.

Environment

baldurk commented 6 days ago

This looks to be working as intended.

At EID 659 you have a Barrier call which transitions ShadowAtlas and passes the D3D12_TEXTURE_BARRIER_FLAG_DISCARD flag which discards the texture contents. RenderDoc highlights this by filling the texture with a pattern exactly to show you that this bug exists so that you can fix it instead of relying on undefined textures contents. It use UNDEFINED IMG to distinguish from a call to DiscardResource.

Barrier(...)
  pCommandList           RenderGraph cmdb 5-6 🔗
  NumBarrierGroups       2
  pBarrierGroups         D3D12_BARRIER_GROUP[2]
    [0]                  D3D12_BARRIER_GROUP()
      Type               D3D12_BARRIER_TYPE_TEXTURE
      NumBarriers        12
      pTextureBarriers   D3D12_TEXTURE_BARRIER[12]
        [0]              D3D12_TEXTURE_BARRIER()
        [1]              D3D12_TEXTURE_BARRIER()
        [2]              D3D12_TEXTURE_BARRIER()
          SyncBefore     D3D12_BARRIER_SYNC_DEPTH_STENCIL
          SyncAfter      D3D12_BARRIER_SYNC_COMPUTE_SHADING
          AccessBefore   D3D12_BARRIER_ACCESS_DEPTH_STENCIL_WRITE
          AccessAfter    D3D12_BARRIER_ACCESS_SHADER_RESOURCE
          LayoutBefore   D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE
          LayoutAfter    D3D12_BARRIER_LAYOUT_SHADER_RESOURCE
          pResource      ShadowAtlas 🔗
          Subresources   D3D12_BARRIER_SUBRESOURCE_RANGE()
          Flags          D3D12_TEXTURE_BARRIER_FLAG_DISCARD <--
godlikepanos commented 6 days ago

oops. You are right. One structure wasn't properly initialized.