Module: Mesa Branch: master Commit: b0a647f284b24ca4e0ee1f70c4839d8ec3d1a4e6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0a647f284b24ca4e0ee1f70c4839d8ec3d1a4e6
Author: Roland Scheidegger <[email protected]> Date: Mon Aug 15 05:22:30 2016 +0200 llvmpipe: fix depth clamping wrt reversed near/far values This wasn't handled before (the result was that no matter what value got clamped, it always ended up as the near value in this case) (if clamping actually happened). Fix this by using the util helper for that (the math is otherwise "mostly" the same, mostly because there could actually be differences due to float rounding, but I don't even know which one would be more correct). Reviewed-by: Jose Fonseca <[email protected]> --- src/gallium/drivers/llvmpipe/lp_setup.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index f622b19..768775b 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -39,6 +39,7 @@ #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_pack_color.h" +#include "util/u_viewport.h" #include "draw/draw_pipe.h" #include "os/os_time.h" #include "lp_context.h" @@ -771,15 +772,8 @@ lp_setup_set_viewports(struct lp_setup_context *setup, for (i = 0; i < num_viewports; i++) { float min_depth; float max_depth; - - if (lp->rasterizer->clip_halfz == 0) { - float half_depth = viewports[i].scale[2]; - min_depth = viewports[i].translate[2] - half_depth; - max_depth = min_depth + half_depth * 2.0f; - } else { - min_depth = viewports[i].translate[2]; - max_depth = min_depth + viewports[i].scale[2]; - } + util_viewport_zmin_zmax(&viewports[i], lp->rasterizer->clip_halfz, + &min_depth, &max_depth); if (setup->viewports[i].min_depth != min_depth || setup->viewports[i].max_depth != max_depth) { _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
