Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d9] Tweak VCache query results #4020

Merged
merged 1 commit into from
May 27, 2024

Conversation

WinterSnowfall
Copy link
Contributor

@WinterSnowfall WinterSnowfall commented May 22, 2024

I'm not entirely sure which games relied on this being exposed anyway, but here's a bit more insight into how this obscure query is supposed to work: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3d9types/ns-d3d9types-_d3ddevinfo_vcache

Also this is what you get with native 45.23 Nvidia drivers, on Windows XP, with a GeForce 4:

Listing VCache query result:
  ~ vCache Pattern: CACH
  ~ vCache OptMethod: 1
  ~ vCache CacheSize: 16
  ~ vCache MagicNumber: 7

dxvk currently does:

Listing VCache query result:
  ~ vCache Pattern: HCAC
  ~ vCache OptMethod: 1
  ~ vCache CacheSize: 24
  ~ vCache MagicNumber: 20

Since I'm guessing CacheSize refers to the number of internal cached buffers the driver holds, it's probably safe to assume a d3d9-era card reported somewhat higher numbers (hence the doubling in this PR).

As for the 🪄 number, allegedly:

Typically, the best values are near CacheSize/2

... whatever that means. So copied over native behavior of CacheSize/2 - 1 here.

As far as I can tell, at least with d3d8, the results are entirely static, so this should be good enough. WineD3D actually just returns a bunch of gibberish.

I'll undraft this once I figure out what native drivers report these days.

Copy link
Collaborator

@K0bin K0bin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully agree with the comment we had in the code until now, so I don't really care.

// Don't know what the hell any of this means.
// Nor do I care. This just makes games work.

@WinterSnowfall
Copy link
Contributor Author

WinterSnowfall commented May 24, 2024

The ATI/AMD results are in:

Native 8.65 ATI drivers, on Windows XP, with a HD 4650:

Listing VCache query result:
  ~ vCache Pattern: 0
  ~ vCache OptMethod: 0
  ~ vCache CacheSize: 0
  ~ vCache MagicNumber: 0

Native modern AMD, thanks to @Blisto91:

Listing VCache query result:
  ~ vCache Pattern: 0
  ~ vCache OptMethod: 0
  ~ vCache CacheSize: 0
  ~ vCache MagicNumber: 0

Glad to see some consistency. This would indicate the call succeeds, but the d3d8 specs are a bit wonky, in that the call should return S_FALSE if the query is not available (which is NOT a failure code), so d3d9 is probably right to report it as unsupported.

I'll wait until @Blisto91 can test native Nvidia, just to be sure we're not too far off the mark with my assumptions.

@WinterSnowfall
Copy link
Contributor Author

Interestingly (thanks to @K0bin for the results), modern Nvidia also 0s things out, at least in d3d8:

Listing VCache query result:
  ~ Response: S_FALSE
  ~ Pattern: 0
  ~ OptMethod: 0
  ~ CacheSize: 0
  ~ MagicNumber: 0

Guess I'll check with my Nvidia FX 5500 and more recent drivers to see if the XP numbers change in any way.

@WinterSnowfall
Copy link
Contributor Author

WinterSnowfall commented May 27, 2024

I've checked on the FX 5500 (the most modern Nvidia AGP card I have), with the latest drivers that released for XP before Vista came into the picture (namely 93.71), then checked a bunch of other intermediate drivers, and the query always returns:

Listing VCache query result:
  ~ vCache Pattern: CACH
  ~ vCache OptMethod: 1
  ~ vCache CacheSize: 16
  ~ vCache MagicNumber: 7

Seems to be a general default, so let's stick to that.

P.S.: A bunch of collected outputs can be found here: https://drive.google.com/drive/folders/1i0eTgX5IbcFdbZT1iPris9l1mqrpeSRf

@WinterSnowfall WinterSnowfall marked this pull request as ready for review May 27, 2024 09:45
@doitsujin doitsujin merged commit c981526 into doitsujin:master May 27, 2024
3 checks passed
@WinterSnowfall WinterSnowfall deleted the d3d9-vcache branch May 27, 2024 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants