pcsx2 icon indicating copy to clipboard operation
pcsx2 copied to clipboard

GS/DX12: Use aliasing resources for feedback

Open TheLastRar opened this issue 3 weeks ago • 10 comments

Description of Changes

Use aliased resources to bind a single texture as both a shader resource and render target, and use barriers instead of copies.

Rationale behind Changes

Copies are slow on DX12, barriers are faster (seemingly even on AMD).

Aliasing resources like this, as far as I can tell, is valid under the Data inheritance rules. Side note: the validation the debug device does is noticeably less strict then documentation.

This requires Resource Heap tier 1, but that appears to be mandatory for DX12.

The Need For Speed Carbon dump goes from 1697 down to 3 copies (but gains 1695 barriers).

I've done a dump run during development, there are a lot of changed dumps and I've not looked at all of them in detail, but here are a few hand picked examples that appear improved.

Deus Ex In Game DX12 Master Deus Ex_SLES-50804_In_Game_frame00001

DX12 PR Deus Ex_SLES-50804_In_Game_frame00001

Okage - Shadow King DX12 Master Okage - Shadow King_SCUS-97129_20230704073925_frame00001

DX12 PR Okage - Shadow King_SCUS-97129_20230704073925_frame00001-1

Suggested Testing Steps

Test the DX12 backend on AMD and Nvidia

Do dump runs and properly compare them.

Did you use AI to help find, test, or implement this issue or feature?

No

TheLastRar avatar Dec 04 '25 01:12 TheLastRar

This is great, I didn’t realize feedback was possible in DX12 in this way. Do you think the same approach would work for feedback loops with a DSV as well?

TJnotJT avatar Dec 05 '25 22:12 TJnotJT

This is great, I didn’t realize feedback was possible in DX12 in this way. Do you think the same approach would work for feedback loops with a DSV as well?

According to the spec, depth/stencil resources aren't compatible with the simultaneous access flag, so I don't think there is a spec legal way for DSV.

That being said, I've found that hardware is significantly less strict then the spec. if you are willing to ignore the spec, you may be able to run without the simultaneous access or ~~(as is the case with this PR's AMD hackfix)~~ use the same resource as both the SRV and DSV. If any of those methods work then they need to be verified on all relevant HW.

TheLastRar avatar Dec 06 '25 20:12 TheLastRar

The problem you face ignoring the spec, is that you're then dependent on the lenience of the implementations, so your chance of something breaking goes up dramatically.

refractionpcsx2 avatar Dec 06 '25 20:12 refractionpcsx2

@TheLastRar Got it, thanks for the clarification. Thankfully DSV feedback is much less needed than color feedback, so that makes sense.

@refractionpcsx2 Agreed. Probably safest to stick to the spec until/unless it becomes standardized in an extension or similar.

TJnotJT avatar Dec 07 '25 00:12 TJnotJT

If we want to stay in spec then we could fallback to old copy method for rdna2. We could just detect if gpu supports feature level 12.2 or higher then prefer old method, drawback is rdna3 and 4 will also be included but at least older will work and we default to Vulkan anyway. Maybe if/when amd fixes the issue we can remove the fallback.

Edit: Jordan suggested we could just cherry pick rdna2 like this https://github.com/RPCS3/rpcs3/blob/3f6529fecbacdf90aa556ae0fd39b478ae28c27f/rpcs3/Emu/RSX/VK/vkutils/chip_class.cpp#L22

lightningterror avatar Dec 07 '25 01:12 lightningterror

That sounds like a good idea for future work, as long as it's guaranteed to work with all supported hardware.

TJnotJT avatar Dec 07 '25 03:12 TJnotJT

I've replaced the AMD hack with the original copy method

I've also now checking the device ID to match known RDNA1/2 hardware, allowing other AMD generations to use the new method.

TheLastRar avatar Dec 07 '25 20:12 TheLastRar

The biggest thing I notice is the clouds in Deus Ex on this PR they look worse to me? Not really sure how to explain it but look at the comparison you put Master v.s. PR for Deus Ex. Unless that's the artists intent? I can't really tell based on footage on real hardware.

SternXD avatar Dec 07 '25 21:12 SternXD

The biggest thing I notice is the clouds in Deus Ex on this PR they look worse to me? Not really sure how to explain it but look at the comparison you put Master v.s. PR for Deus Ex. Unless that's the artists intent? I can't really tell based on footage on real hardware.

Of the pictures in the op, the PR picture better matched SW iirc

TheLastRar avatar Dec 07 '25 22:12 TheLastRar

Confirmed working correctly on an RX 7600XT and RX 9060XT.

image image

JordanTheToaster avatar Dec 09 '25 12:12 JordanTheToaster