SoftRasterizer: Fix Z-depth calculations when compiling on MSVC. Fixes the overworld map in Dragon Quest IV. (Regression from commit d81a75c.)
- Apparently, MSVC has a more strict implementation of IEEE-754 single-precision floats (with 23-bit significands) than Clang and GCC, and so we going to drop 2 LSBs during the calculation so that we're multiplying z by a 22-bit significand. Coincidentally, this now matches what we're doing with the OpenGL renderer, so this tends to better code consistency.
This commit is contained in:
parent
f03a880ef9
commit
d410b5c195
|
@ -517,7 +517,10 @@ FORCEINLINE void RasterizerUnit<RENDERER>::_pixel(const POLYGON_ATTR polyAttr, c
|
|||
// When using z-depth, be sure to test against the following test cases:
|
||||
// - The drawing of the overworld map in Dragon Quest IV
|
||||
// - The drawing of all units on the map in Advance Wars: Days of Ruin
|
||||
const u32 newDepth = (gfx3d.renderState.wbuffer) ? u32floor(w * 4096.0f) : u32floor(z * 16777215.0f);
|
||||
|
||||
// Note that an IEEE-754 single-precision float uses a 23-bit significand. Therefore, we will multiply the
|
||||
// Z-depth by a 22-bit significand for safety.
|
||||
const u32 newDepth = (gfx3d.renderState.wbuffer) ? u32floor(w * 4096.0f) : u32floor(z * 4194303.0f) << 2;
|
||||
|
||||
// run the depth test
|
||||
bool depthFail = false;
|
||||
|
|
Loading…
Reference in New Issue