diff --git a/.pick_status.json b/.pick_status.json index ae46ae32899..6129189cd2f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -544,7 +544,7 @@ "description": "gallivm: avoid division by zero when computing cube face", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 0c9a41aeb26..19bd8463d44 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -1726,7 +1726,10 @@ lp_build_cube_imapos(struct lp_build_context *coord_bld, LLVMValueRef coord) /* ima = +0.5 / abs(coord); */ LLVMValueRef posHalf = lp_build_const_vec(coord_bld->gallivm, coord_bld->type, 0.5); LLVMValueRef absCoord = lp_build_abs(coord_bld, coord); - LLVMValueRef ima = lp_build_div(coord_bld, posHalf, absCoord); + /* avoid div by zero */ + LLVMValueRef sel = lp_build_cmp(coord_bld, PIPE_FUNC_GREATER, absCoord, coord_bld->zero); + LLVMValueRef div = lp_build_div(coord_bld, posHalf, absCoord); + LLVMValueRef ima = lp_build_select(coord_bld, sel, div, coord_bld->zero); return ima; }