HansKristian-Work / vkd3d-proton

Fork of VKD3D. Development branches for Proton's Direct3D 12 implementation.
GNU Lesser General Public License v2.1
1.76k stars 184 forks source link

Prevent out of in-shader declared bounds access to uniform arrays in order to prevent undefined behavior #1913

Closed werman closed 4 months ago

werman commented 4 months ago

There was a discussion in https://github.com/doitsujin/dxvk/issues/3861 how to deal with indirect OOB access to uniforms in D3D. And I was told that D3D12 is the same as D3D11 in this regard and games could access constant buffer arrays out of declared in the shader bounds. Such behavior is undefined per Vulkan spec but desktop GPUs don't care about it, however Turnip does care.

The proposed solution in DXVK is to declare all dynamically indexed UBOs with upper size bound of 4096. I see that D3D12 has the same upper bound, so I propose to implement the same solution here. Thoughts?

For now in Turnip we'd have our own workaround for current and old DXVK and for vkd3d-proton.

werman commented 4 months ago

Discussed this elsewhere, vkd3d-proton already does the right thing.