Skip to content

DEVICE_CSSETSHADERRESOURCES_HAZARD on Direct3D11 #3450

@opengenius

Description

@opengenius

Describe the bug
In a compute shader simulation involving multiple steps and several R32F textures (e.g., water height, water velocity x/y, temp R/RG, foam), a warning is triggered when a texture used as input in one compute step is subsequently bound as output in the next step without the input binding being explicitly overwritten or cleared. This leads to a D3D11 warning indicating a resource hazard. Plus I had connected problem with unbound resources on Open GL ES as well (Adreno 616 ,MI 9 SE) but with actual graphical artifacts, so i have to bind all textures (even unused in current step) so that all slots are beeing reset (the problem seems to be that the texture is bound in different slots as readonly and writeonly even if the slot is not used).

To Reproduce
Steps to reproduce the behavior:

  1. Run a multi-step compute shader simulation where each step reads from and writes to different R32F textures.
  2. In step N, bind a texture as CSSetShaderResources input.
  3. In step N+1, bind the same texture as an UnorderedAccessView output without unbinding it from the previous shader resource slot.
  4. Observe the warning in the debug output.

Expected behavior
The system should not emit a warning if proper binding rules are followed. However, since the shader resource was not explicitly unbound before being rebound as an output, the warning is valid — but could be avoided with correct resource management.

Additional context
API: Direct3D 11
Texture format: R32F
Context: Compute shader (CS) simulation
Warning message:
D3D11 WARNING: ID3D11DeviceContext::CSSetShaderResources: Resource being set to CS shader resource slot 1 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #2097316: DEVICE_CSSETSHADERRESOURCES_HAZARD]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions