dxvk icon indicating copy to clipboard operation
dxvk copied to clipboard

[d3d8] Improve handling of failed d3d9 calls

Open WinterSnowfall opened this issue 1 year ago • 4 comments

Mostly nits uncovered while I was (yet again) reviewing refcounts...

The only real concern is that in some cases we are creating & reffing objects even after the proxied calls to d3d9 are failing, which of course doesn't make any sense. Probably less of a problem with games that choke on such errors anyway, but as we know there are some that expect calls to error out in order to function properly.

WinterSnowfall avatar Aug 24 '24 12:08 WinterSnowfall

I've added some general robustness to d3d8 device calls - although highly unlikely, there was some potential null pointer dereference going on. Also added additional validations where applicable, especially around CopyRects (we still need to make it more restrictive, but it's a start).

P.S.: Draft for now, since it needs some testing to ensure nothing regresses due to the additional validations.

WinterSnowfall avatar Aug 27 '24 21:08 WinterSnowfall

Looks good after a quick round of random game tests - on the added validation part it now (mostly) mirrors d9vk anyway, so no surprise there.

WinterSnowfall avatar Aug 28 '24 07:08 WinterSnowfall

The ghost of Managed Buffer Placement still haunts us to this day. I've also now removed some remaining sleight of hand (on buffer GetDesc) we were doing to facilitate it.

WinterSnowfall avatar Sep 12 '24 09:09 WinterSnowfall

I've tested this PR with the entire battery of ~140 d3d8 games I have and they're all fine. Should be good to mainline.

WinterSnowfall avatar Sep 13 '24 16:09 WinterSnowfall

Tested it quickly with 12 random games to verify amd radv is fine too and haven't hit any issues

Blisto91 avatar Sep 14 '24 22:09 Blisto91

I generally prefer the if (FAILED(hr)) return hr; kind of pattern over what's done here since it makes the intended code path easier to follow in some cases

Hmmm, fair enough. I sort of went for the "let's not have 5 returns per call" approach where it could be helped, but I'll keep it in mind in the future.

Addressed the rest.

WinterSnowfall avatar Sep 17 '24 14:09 WinterSnowfall