/*
* a = a0 + (x * dadx + y * dady)
*/
- dadx = LLVMBuildFMul(builder, dadx, pixoffx, "");
- dady = LLVMBuildFMul(builder, dady, pixoffy, "");
- a = LLVMBuildFAdd(builder, a, dadx, "");
- a = LLVMBuildFAdd(builder, a, dady, "");
+ a = lp_build_fmuladd(builder, dadx, pixoffx, a);
+ a = lp_build_fmuladd(builder, dady, pixoffy, a);
if (interp == LP_INTERP_PERSPECTIVE) {
if (oow == NULL) {
break;
}
- if ((attrib == 0) && (chan == 2)){
+ if ((attrib == 0) && (chan == 2) && !bld->depth_clamp){
/* FIXME: Depth values can exceed 1.0, due to the fact that
* setup interpolation coefficients refer to (0,0) which causes
- * precision loss. So we must clamp to 1.0 here to avoid artifacts
+ * precision loss. So we must clamp to 1.0 here to avoid artifacts.
+ * Note though values outside [0,1] are perfectly valid with
+ * depth clip disabled.
+ * XXX: If depth clip is disabled but we force depth clamp
+ * we may get values larger than 1.0 in the fs (but not in
+ * depth test). Not sure if that's an issue...
+ * Also, on a similar note, it is not obvious if the depth values
+ * appearing in fs (with depth clip disabled) should be clamped
+ * to [0,1], clamped to near/far or not be clamped at all...
*/
a = lp_build_min(coeff_bld, a, coeff_bld->one);
}
*/
if (interp != LP_INTERP_CONSTANT &&
interp != LP_INTERP_FACING) {
- LLVMValueRef axaos, ayaos;
- axaos = LLVMBuildFMul(builder, lp_build_broadcast_scalar(setup_bld, bld->x),
- dadxaos, "");
- ayaos = LLVMBuildFMul(builder, lp_build_broadcast_scalar(setup_bld, bld->y),
- dadyaos, "");
- a0aos = LLVMBuildFAdd(builder, a0aos, ayaos, "");
- a0aos = LLVMBuildFAdd(builder, a0aos, axaos, "");
+ LLVMValueRef x = lp_build_broadcast_scalar(setup_bld, bld->x);
+ LLVMValueRef y = lp_build_broadcast_scalar(setup_bld, bld->y);
+ a0aos = lp_build_fmuladd(builder, x, dadxaos, a0aos);
+ a0aos = lp_build_fmuladd(builder, y, dadyaos, a0aos);
}
/*
}
#endif
- if (attrib == 0 && chan == 2) {
+ if (attrib == 0 && chan == 2 && !bld->depth_clamp) {
/* FIXME: Depth values can exceed 1.0, due to the fact that
* setup interpolation coefficients refer to (0,0) which causes
- * precision loss. So we must clamp to 1.0 here to avoid artifacts
+ * precision loss. So we must clamp to 1.0 here to avoid artifacts.
+ * Note though values outside [0,1] are perfectly valid with
+ * depth clip disabled..
+ * XXX: If depth clip is disabled but we force depth clamp
+ * we may get values larger than 1.0 in the fs (but not in
+ * depth test). Not sure if that's an issue...
+ * Also, on a similar note, it is not obvious if the depth values
+ * appearing in fs (with depth clip disabled) should be clamped
+ * to [0,1], clamped to near/far or not be clamped at all...
*/
a = lp_build_min(coeff_bld, a, coeff_bld->one);
}
unsigned num_inputs,
const struct lp_shader_input *inputs,
boolean pixel_center_integer,
+ boolean depth_clamp,
LLVMBuilderRef builder,
struct lp_type type,
LLVMValueRef a0_ptr,
} else {
bld->pos_offset = 0.5;
}
+ bld->depth_clamp = depth_clamp;
pos_init(bld, x0, y0);