-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
sprintf(register_name, "(%s + %u >= 0 &&
%s + %u < %u ? %s_c[%s + %u] : vec4(0.0))",
Did you do any testing on the performance impact of this? This seems like something where it's convenient to sacrifice performance everywhere for a corner case, but later on we wonder why games are unplayably slow. Keep in mind that currently it's pretty difficult to be GPU limited. With the CSMT patches you'll have a higher chance of being GPU limited, but there's no guarantee of course.
dx10+ GPUs don't return 0.0 reliably on Windows here. My Geforce GPUs returned the int constants at c[-32] to c[-48].
I think there are additional options of increasing our odds of behaving like Windows. E.g. with constant buffers we could create a buffer that matches the hardware page size (which we can't query, I know) and fill everything except the 256 d3d9 constants with zeroes. If the out of bounds read falls into the buffer we get a zero. If not, the hardware should detect the invalid read and I'd expect it to return zero due to exactly this d3d requirement.
Also I think d3d9 HW should "just work" in this regard because only 256 registers exist.
Yes, I am aware that there are more games than just The Witcher that are affected by this problem.