protonscr

Port the DXIL structuriser from upstream vkd3d as a fallback?

vkd3dclosed
HansKristian-Work/vkd3d-proton#2500 · opened 2025-06-10 by conor42 · updated 2025-06-23 · 2 comments · github
Cconor42 2025-06-10 github

Upstream vkd3d has a relatively simple structuriser which uses control flow virtualisation for difficult cases. Performance may not always match the vkd3d-proton structuriser, but it's been tested on a large shader database without failures, and would probably be useful as a fallback. Is that needed and worth doing? If so I can port it over.

HHansKristian-Work maintainer 2025-06-10 github

Performance may not always match the vkd3d-proton structuriser

Surely that is an understatement. loop + switch is not fun. At least that was the state of things when I saw it last.

would probably be useful as a fallback

I don't see where you'd use a fallback. You'd have to run spirv-val after every shader and if validation error, redo the whole thing which seems not super helpful, and it's too big/slow to ship SPIRV-Tools inside vkd3d-proton.

Is that needed and worth doing?

I don't think so. If there are known failures with the existing structurizer, those should be fixed. I'm also interested if there are general algorithmic improvements that can be made to the structurizes that maintains the requirements of performance + debugability (retains intent of original shader as much as possible).

Cconor42 2025-06-11 github

It has optimisations to minimise the use of virtualisation, but I don't remember the exact details; it's been a while since I reviewed it for Giovanni who wrote it. It's in vsir_program_structurize() in https://gitlab.winehq.org/wine/vkd3d/-/blob/master/libs/vkd3d-shader/ir.c if you want to see it.

At the time I only tested HZD and Cyberpunk and saw no performance difference vs my port of your structuriser. There may be some games where it's quite slow. Upstream vkd3d is still very much not optimised generally so there's no way to compare the structurisers now.

Nothing extracted yet.