void lp_sampler_static_state(struct lp_sampler_static_state *state, const struct pipe_texture *texture, const struct pipe_sampler_state *sampler) { memset(state, 0, sizeof *state); if(!texture) return; if(!sampler) return; state->format = texture->format; state->target = texture->target; state->pot_width = util_is_pot(texture->width[0]); state->pot_height = util_is_pot(texture->height[0]); state->pot_depth = util_is_pot(texture->depth[0]); state->wrap_s = sampler->wrap_s; state->wrap_t = sampler->wrap_t; state->wrap_r = sampler->wrap_r; state->min_img_filter = sampler->min_img_filter; state->min_mip_filter = sampler->min_mip_filter; state->mag_img_filter = sampler->mag_img_filter; if(sampler->compare_mode) { state->compare_mode = sampler->compare_mode; state->compare_func = sampler->compare_func; } state->normalized_coords = sampler->normalized_coords; state->prefilter = sampler->prefilter; }
/** * Initialize lp_sampler_static_state object with the gallium sampler * and texture state. * The former is considered to be static and the later dynamic. */ void lp_sampler_static_state(struct lp_sampler_static_state *state, const struct pipe_texture *texture, const struct pipe_sampler_state *sampler) { memset(state, 0, sizeof *state); if(!texture) return; if(!sampler) return; state->format = texture->format; state->target = texture->target; state->pot_width = util_is_pot(texture->width0); state->pot_height = util_is_pot(texture->height0); state->pot_depth = util_is_pot(texture->depth0); state->wrap_s = sampler->wrap_s; state->wrap_t = sampler->wrap_t; state->wrap_r = sampler->wrap_r; state->min_img_filter = sampler->min_img_filter; state->min_mip_filter = sampler->min_mip_filter; state->mag_img_filter = sampler->mag_img_filter; state->compare_mode = sampler->compare_mode; state->compare_func = sampler->compare_func; state->normalized_coords = sampler->normalized_coords; state->lod_bias = sampler->lod_bias; state->min_lod = sampler->min_lod; state->max_lod = sampler->max_lod; state->border_color[0] = sampler->border_color[0]; state->border_color[1] = sampler->border_color[1]; state->border_color[2] = sampler->border_color[2]; state->border_color[3] = sampler->border_color[3]; }
/** * Small vector x scale multiplication optimization. */ LLVMValueRef lp_build_mul_imm(struct lp_build_context *bld, LLVMValueRef a, int b) { LLVMValueRef factor; if(b == 0) return bld->zero; if(b == 1) return a; if(b == -1) return LLVMBuildNeg(bld->builder, a, ""); if(b == 2 && bld->type.floating) return lp_build_add(bld, a, a); if(util_is_pot(b)) { unsigned shift = ffs(b) - 1; if(bld->type.floating) { #if 0 /* * Power of two multiplication by directly manipulating the mantissa. * * XXX: This might not be always faster, it will introduce a small error * for multiplication by zero, and it will produce wrong results * for Inf and NaN. */ unsigned mantissa = lp_mantissa(bld->type); factor = lp_build_int_const_scalar(bld->type, (unsigned long long)shift << mantissa); a = LLVMBuildBitCast(bld->builder, a, lp_build_int_vec_type(bld->type), ""); a = LLVMBuildAdd(bld->builder, a, factor, ""); a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->type), ""); return a; #endif } else { factor = lp_build_const_scalar(bld->type, shift); return LLVMBuildShl(bld->builder, a, factor, ""); } } factor = lp_build_const_scalar(bld->type, (double)b); return lp_build_mul(bld, a, factor); }