-
Fix back-face culling for vertices near w=0 · eeb81843Nicolas Capens authored
When the homogeneous w coordinate is near 0, the projected x or y coordinates (after viewport and subpixel scaling) may be larger than what's representable by 32-bit signed integers. On x86 this produces the "indefinite" integer value 0x80000000. This negative value is returned even for positive inputs. This causes the back-face culling calculations to reject triangles which are in fact visible. This change addresses that by introducing the rr::RoundIntClamped() function, which guarantees that very large positive floating-point values are converted to a positive integer value near INT_MAX. Note that the Vulkan spec states that "[the determination whether the triangle is back-facing or front-facing] is made based on the sign of the (clipped or unclipped) polygon’s area computed in framebuffer coordinates." Thus the alternative of performing culling using the unprojected coordinates would have to take negative viewport dimensions into account, and may not produce the same results as sub-pixel snapped coordinates. Adjust back-face culling of wireframe triangles to use the same calculations as solid triangles. Bug: b/177382194 Change-Id: Ice8493d4cfd164638f091bf5a39b5396d65458e2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51648Tested-by:
Nicolas Capens <nicolascapens@google.com> Reviewed-by:
Alexis Hétu <sugoi@google.com>
eeb81843
×