Cxbx-reloaded: Soon, no more YUV textures - then what?

Created on 3 May 2018  路  5Comments  路  Source: Cxbx-Reloaded/Cxbx-Reloaded

Since we use d3d8to9 to let our (currently Direct3D 8-using) code-base render using Direct3D 9, this recent pull request might become a problem for us : https://github.com/crosire/d3d8to9/pull/77
With this PR, d3d8to9 will make CheckDeviceFormat deny YUV textures - something Xbox code might do, so that has to be researched;

For this, we need to dive into these subjects:

  • which test-cases (titles) create textures with YUV (or one of the other denied) format?
  • is this behaviour correct? (it might need to be updated to surface creation anyway)
  • how should we handle this? (for example, use our libyuv-based pixel-row conversion code)
HLE graphics

All 5 comments

Base on the links' PR code, only D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, and D3DRTYPE_CUBETEXTURE are planned not to be support for a reason. Though, it's possible other texture still support it? That's another question to think about.
If the Xbox's doc do state YUV texture are supported on hardware. Then yeah, we have to make the conversion on our side. If not, then one less big work for graphic conversion necessary. :wink:

EDIT: Let's try not to be very passive to xbox's title. Something like HLE DSound is doing atm. 馃槈

EDIT2: ALL of YUV formats will not be supported anymore. Now my first paragraph is no longer valid. 馃槈

These three resource types (texture, volume texture and cube texture) are the only three texture formats that Direct3D 8 (and 9) support. Besides converting to another format, there's only one other alternative : using surface resources, which keep supporting YUV formats. But I'm not sure if that will suffice in practice (hence this issue).

Warning : with https://github.com/crosire/d3d8to9/pull/77/commits/e4a0e3230301c425c68c9d5f5289edd1f0652142 not even surfaces will accept YUV formats anymore !

Note to other viewers - I'm no expert. But to see why this could become a big problem, just click on that link in Patrick's OP above and see the list of 2000's PC games. A very large number of them do have Xbox and other console ports.

We already convert YUV textures to ARGB when the CreateTexture call fails.

This was done because it was causing a crash on NVIDIA hardware because the driver reported YUV support, but then actually calling CreateTexture with YUV format failed.

See this fallback:
https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/blob/master/src/CxbxKrnl/EmuD3D8.cpp#L5071

Additionally, YUV overlays are converted to the host back-buffer format via D3DXLoadSurfaceFromMemory and related functions, so they are not a problem in this format too.

We could avoid the risk of attempting to use a YUV surface/texture altogether by simply setting YUV2 to unsupported within g_bSupportsFormatSurface and g_bSupportsFormatTexture, etc.

But even in the current form, this is a non-issue: Otherwise we'd still be insanely crash-heavy on NVIDIA hardware, which we aren't ;)

Was this page helpful?
0 / 5 - 0 ratings