LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
- LLVMValueRef cube_rho,
const struct lp_derivatives *derivs)
{
struct gallivm_state *gallivm = bld->gallivm;
int_size = lp_build_minify(int_size_bld, bld->int_size, first_level_vec, TRUE);
float_size = lp_build_int_to_float(float_size_bld, int_size);
- if (cube_rho) {
- LLVMValueRef cubesize;
- LLVMValueRef index0 = lp_build_const_int32(gallivm, 0);
-
- /*
- * Cube map code did already everything except size mul and per-quad extraction.
- * Luckily cube maps are always quadratic!
- */
- if (rho_per_quad) {
- rho = lp_build_pack_aos_scalars(bld->gallivm, coord_bld->type,
- rho_bld->type, cube_rho, 0);
- }
- else {
- rho = lp_build_swizzle_scalar_aos(coord_bld, cube_rho, 0, 4);
- }
- /* Could optimize this for single quad just skip the broadcast */
- cubesize = lp_build_extract_broadcast(gallivm, bld->float_size_in_type,
- rho_bld->type, float_size, index0);
- /* skipping sqrt hence returning rho squared */
- cubesize = lp_build_mul(rho_bld, cubesize, cubesize);
- rho = lp_build_mul(rho_bld, cubesize, rho);
- }
- else if (derivs) {
+ if (derivs) {
LLVMValueRef ddmax[3] = { NULL }, ddx[3] = { NULL }, ddy[3] = { NULL };
for (i = 0; i < dims; i++) {
LLVMValueRef floatdim;
* \param derivs partial derivatives of (s, t, r, q) with respect to X and Y
* \param lod_bias optional float vector with the shader lod bias
* \param explicit_lod optional float vector with the explicit lod
- * \param cube_rho rho calculated by cube coord mapping (optional)
* \param out_lod_ipart integer part of lod
* \param out_lod_fpart float part of lod (never larger than 1 but may be negative)
* \param out_lod_positive (mask) if lod is positive (i.e. texture is minified)
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
- LLVMValueRef cube_rho,
const struct lp_derivatives *derivs,
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
}
else {
LLVMValueRef rho;
- boolean rho_squared = (bld->no_rho_approx &&
- (bld->dims > 1)) || cube_rho;
+ boolean rho_squared = bld->no_rho_approx && (bld->dims > 1);
if (bld->static_sampler_state->aniso &&
!explicit_lod) {
rho = lp_build_pmin(bld, texture_unit, s, t, max_aniso);
rho_squared = true;
} else
- rho = lp_build_rho(bld, texture_unit, s, t, r, cube_rho, derivs);
+ rho = lp_build_rho(bld, texture_unit, s, t, r, derivs);
/*
* Compute lod = log2(rho)
lp_build_cube_lookup(struct lp_build_sample_context *bld,
LLVMValueRef *coords,
const struct lp_derivatives *derivs_in, /* optional */
- LLVMValueRef *rho,
struct lp_derivatives *derivs_out, /* optional */
boolean need_derivs)
{
* Do per-pixel face selection. We cannot however (as we used to do)
* simply calculate the derivs afterwards (which is very bogus for
* explicit derivs btw) because the values would be "random" when
- * not all pixels lie on the same face. So what we do here is just
- * calculate the derivatives after scaling the coords by the absolute
- * value of the inverse major axis, and essentially do rho calculation
- * steps as if it were a 3d texture. This is perfect if all pixels hit
- * the same face, but not so great at edges, I believe the max error
- * should be sqrt(2) with no_rho_approx or 2 otherwise (essentially measuring
- * the 3d distance between 2 points on the cube instead of measuring up/down
- * the edge). Still this is possibly a win over just selecting the same face
- * for all pixels. Unfortunately, something like that doesn't work for
- * explicit derivatives.
+ * not all pixels lie on the same face.
*/
struct lp_build_context *cint_bld = &bld->int_coord_bld;
struct lp_type intctype = cint_bld->type;
coords[2] = LLVMBuildOr(builder, face, signma, "face");
/* project coords */
- if (!need_derivs) {
- imahalfpos = lp_build_cube_imapos(coord_bld, ma);
- face_s = lp_build_mul(coord_bld, face_s, imahalfpos);
- face_t = lp_build_mul(coord_bld, face_t, imahalfpos);
- }
+ imahalfpos = lp_build_cube_imapos(coord_bld, ma);
+ face_s = lp_build_mul(coord_bld, face_s, imahalfpos);
+ face_t = lp_build_mul(coord_bld, face_t, imahalfpos);
coords[0] = lp_build_add(coord_bld, face_s, posHalf);
coords[1] = lp_build_add(coord_bld, face_t, posHalf);
const unsigned mag_filter = bld->static_sampler_state->mag_img_filter;
const unsigned target = bld->static_texture_state->target;
const bool aniso = bld->static_sampler_state->aniso;
- LLVMValueRef first_level, cube_rho = NULL;
+ LLVMValueRef first_level = NULL;
LLVMValueRef lod_ipart = NULL;
struct lp_derivatives cube_derivs;
/*
* Choose cube face, recompute texcoords for the chosen face and
- * compute rho here too (as it requires transform of derivatives).
+ * calculate / transform derivatives.
*/
if (target == PIPE_TEXTURE_CUBE || target == PIPE_TEXTURE_CUBE_ARRAY) {
boolean need_derivs;
mip_filter != PIPE_TEX_MIPFILTER_NONE) &&
!bld->static_sampler_state->min_max_lod_equal &&
!explicit_lod);
- lp_build_cube_lookup(bld, coords, derivs, &cube_rho, &cube_derivs, need_derivs);
+ lp_build_cube_lookup(bld, coords, derivs, &cube_derivs, need_derivs);
if (need_derivs)
derivs = &cube_derivs;
* distinguish between minification/magnification with one mipmap level.
*/
lp_build_lod_selector(bld, is_lodq, texture_index, sampler_index,
- coords[0], coords[1], coords[2], cube_rho,
+ coords[0], coords[1], coords[2],
derivs, lod_bias, explicit_lod,
mip_filter, max_aniso, lod,
&lod_ipart, lod_fpart, lod_pos_or_zero);