microsoft / D3D12TranslationLayer

A library containing utilities for mapping higher-level graphics work to D3D12
MIT License
329 stars 47 forks source link

Dirty bit handling can cause binding of stale descriptors #78

Open jenatali opened 1 year ago

jenatali commented 1 year ago

Reported by ThomasY on Discord.

This app bound a constant buffer to the PS stage, bound a pixel shader that used that constant buffer, and drew. This updated the descriptor table for constant buffers.

It then deleted that constant buffer, flushed the command list, changed the constant buffer bound to the PS, and bound a pixel shader that does not use a constant buffer, and drew.

This combination of events caused us to skip updating the PS CB descriptor table, because the currently-bound pixel shader couldn't use the new one, but then still call SetGraphicsRootDescriptorTable on the command list for the previous PS descriptor table, which now contains a descriptor pointing to a deleted resource.

I'm not sure offhand what the fix here would be. Probably to skip this binding until a PS is bound that can actually reference one of these CBs.