It works better for depth readback on modern Radeon GPUs.
Signed-off-by: Stefan Dösinger stefan@codeweavers.com
---
Also compare to the readback mess that is test_depth_readback. On Nvidia cards test_depth_readback is broken for D24S8, but works for some cards with D16 or D24X8. That's not necessarily contradictory: test_depth_readback draws actual geometry, whereas test_color_fill just uses DDBLT_DEPTHFILL.
If any Nvidia GPU I did not test now fails test_color_fill we can make the chosen format card dependent. I'll avoid that for now though. --- dlls/ddraw/tests/ddraw4.c | 12 ++++++++++++ dlls/ddraw/tests/ddraw7.c | 12 ++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index a8b68b8a20b..451dabff20a 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -432,8 +432,20 @@ static HRESULT CALLBACK enum_z_fmt(DDPIXELFORMAT *format, void *ctx) { DDPIXELFORMAT *z_fmt = ctx;
+ /* Prefer higher Z precision over lower, and prefer D24S8 over + * D24X8. See also test_depth_readback for some GPU specific + * limitations. Note that test_depth_readback reads back depth + * values from draws, while users of this functions usually do + * not. */ if (U1(*format).dwZBufferBitDepth > U1(*z_fmt).dwZBufferBitDepth) + { *z_fmt = *format; + } + else if (U1(*format).dwZBufferBitDepth == U1(*z_fmt).dwZBufferBitDepth + && U2(*format).dwStencilBitDepth > U2(*z_fmt).dwStencilBitDepth) + { + *z_fmt = *format; + }
return DDENUMRET_OK; } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index c7a38ab7701..fe09766eddb 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -455,8 +455,20 @@ static HRESULT CALLBACK enum_z_fmt(DDPIXELFORMAT *format, void *ctx) { DDPIXELFORMAT *z_fmt = ctx;
+ /* Prefer higher Z precision over lower, and prefer D24S8 over + * D24X8. See also test_depth_readback for some GPU specific + * limitations. Note that test_depth_readback reads back depth + * values from draws, while users of this functions usually do + * not. */ if (U1(*format).dwZBufferBitDepth > U1(*z_fmt).dwZBufferBitDepth) + { *z_fmt = *format; + } + else if (U1(*format).dwZBufferBitDepth == U1(*z_fmt).dwZBufferBitDepth + && U2(*format).dwStencilBitDepth > U2(*z_fmt).dwStencilBitDepth) + { + *z_fmt = *format; + }
return DDENUMRET_OK; }