X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fgallivm%2Flp_bld_sample.h;h=eba758da6aeadd6ec2bffa077ea6e7e29f8c4e37;hb=114cc18b98b6e016ab1986577aa3df12acc22cca;hp=067a995a2be3839bc3370d8e6561a827f12a5fe0;hpb=fe92d7fab4ee8293fc93ea97680db52342b3b464;p=mesa.git diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 067a995a2be..eba758da6ae 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -68,6 +68,45 @@ enum lp_sampler_lod_property { }; +enum lp_sampler_lod_control { + LP_SAMPLER_LOD_IMPLICIT, + LP_SAMPLER_LOD_BIAS, + LP_SAMPLER_LOD_EXPLICIT, + LP_SAMPLER_LOD_DERIVATIVES, +}; + + +enum lp_sampler_op_type { + LP_SAMPLER_OP_TEXTURE, + LP_SAMPLER_OP_FETCH, + LP_SAMPLER_OP_GATHER +}; + + +#define LP_SAMPLER_SHADOW (1 << 0) +#define LP_SAMPLER_OFFSETS (1 << 1) +#define LP_SAMPLER_OP_TYPE_SHIFT 2 +#define LP_SAMPLER_OP_TYPE_MASK (3 << 2) +#define LP_SAMPLER_LOD_CONTROL_SHIFT 4 +#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 4) +#define LP_SAMPLER_LOD_PROPERTY_SHIFT 6 +#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 6) + +struct lp_sampler_params +{ + struct lp_type type; + unsigned texture_index; + unsigned sampler_index; + unsigned sample_key; + LLVMValueRef context_ptr; + const LLVMValueRef *coords; + const LLVMValueRef *offsets; + LLVMValueRef lod; + const struct lp_derivatives *derivs; + LLVMValueRef *texel; +}; + + /** * Texture static state. * @@ -114,6 +153,7 @@ struct lp_static_sampler_state unsigned lod_bias_non_zero:1; unsigned apply_min_lod:1; /**< min_lod > 0 ? */ unsigned apply_max_lod:1; /**< max_lod < last_level ? */ + unsigned seamless_cube_map:1; /* Hacks */ unsigned force_nearest_s:1; @@ -137,79 +177,96 @@ struct lp_sampler_dynamic_state /** Obtain the base texture width (or number of elements) (returns int32) */ LLVMValueRef - (*width)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*width)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the base texture height (returns int32) */ LLVMValueRef - (*height)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*height)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the base texture depth (or array size) (returns int32) */ LLVMValueRef - (*depth)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*depth)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the first mipmap level (base level) (returns int32) */ LLVMValueRef - (*first_level)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*first_level)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the number of mipmap levels minus one (returns int32) */ LLVMValueRef - (*last_level)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*last_level)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain stride in bytes between image rows/blocks (returns int32) */ LLVMValueRef - (*row_stride)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*row_stride)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain stride in bytes between image slices (returns int32) */ LLVMValueRef - (*img_stride)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*img_stride)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain pointer to base of texture */ LLVMValueRef - (*base_ptr)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*base_ptr)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain pointer to array of mipmap offsets */ LLVMValueRef - (*mip_offsets)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*mip_offsets)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /* These are callbacks for sampler state */ /** Obtain texture min lod (returns float) */ LLVMValueRef (*min_lod)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture max lod (returns float) */ LLVMValueRef (*max_lod)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture lod bias (returns float) */ LLVMValueRef (*lod_bias)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture border color (returns ptr to float[4]) */ LLVMValueRef (*border_color)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); }; @@ -233,7 +290,10 @@ struct lp_build_sample_context /** SIMD vector width */ unsigned vector_width; - /** number of lod values (valid are 1, length/4, length) */ + /** number of mipmaps (valid are 1, length/4, length) */ + unsigned num_mips; + + /** number of lod values (valid are 1, length/4, length) */ unsigned num_lods; /** regular scalar float type */ @@ -283,6 +343,14 @@ struct lp_build_sample_context struct lp_type leveli_type; struct lp_build_context leveli_bld; + /** Float lod type */ + struct lp_type lodf_type; + struct lp_build_context lodf_bld; + + /** Int lod type */ + struct lp_type lodi_type; + struct lp_build_context lodi_bld; + /* Common dynamic state values */ LLVMValueRef row_stride_array; LLVMValueRef img_stride_array; @@ -293,6 +361,8 @@ struct lp_build_sample_context LLVMValueRef int_size; LLVMValueRef border_color_clamped; + + LLVMValueRef context_ptr; }; @@ -301,7 +371,7 @@ struct lp_build_sample_context * We only support a few wrap modes in lp_build_sample_wrap_linear_int() at * this time. Return whether the given mode is supported by that function. */ -static INLINE boolean +static inline boolean lp_is_simple_wrap_mode(unsigned mode) { switch (mode) { @@ -314,7 +384,7 @@ lp_is_simple_wrap_mode(unsigned mode) } -static INLINE void +static inline void apply_sampler_swizzle(struct lp_build_sample_context *bld, LLVMValueRef *texel) { @@ -332,7 +402,7 @@ apply_sampler_swizzle(struct lp_build_sample_context *bld, * not really dimension as such, this indicates the amount of * "normal" texture coords subject to minification, wrapping etc. */ -static INLINE unsigned +static inline unsigned texture_dims(enum pipe_texture_target tex) { switch (tex) { @@ -344,9 +414,7 @@ texture_dims(enum pipe_texture_target tex) case PIPE_TEXTURE_2D_ARRAY: case PIPE_TEXTURE_RECT: case PIPE_TEXTURE_CUBE: - return 2; case PIPE_TEXTURE_CUBE_ARRAY: - assert(0); return 2; case PIPE_TEXTURE_3D: return 3; @@ -356,6 +424,21 @@ texture_dims(enum pipe_texture_target tex) } } +static inline boolean +has_layer_coord(enum pipe_texture_target tex) +{ + switch (tex) { + case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + /* cube is not layered but 3rd coord (after cube mapping) behaves the same */ + case PIPE_TEXTURE_CUBE: + case PIPE_TEXTURE_CUBE_ARRAY: + return TRUE; + default: + return FALSE; + } +} + boolean lp_sampler_wrap_mode_uses_border_color(unsigned mode, @@ -388,7 +471,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, LLVMValueRef explicit_lod, /* optional */ unsigned mip_filter, LLVMValueRef *out_lod_ipart, - LLVMValueRef *out_lod_fpart); + LLVMValueRef *out_lod_fpart, + LLVMValueRef *out_lod_positive); void lp_build_nearest_mip_level(struct lp_build_sample_context *bld, @@ -444,11 +528,25 @@ lp_build_unnormalized_coords(struct lp_build_sample_context *bld, void lp_build_cube_lookup(struct lp_build_sample_context *bld, LLVMValueRef *coords, - const struct lp_derivatives *derivs, /* optional */ + const struct lp_derivatives *derivs_in, /* optional */ LLVMValueRef *rho, + struct lp_derivatives *derivs_out, /* optional */ boolean need_derivs); +void +lp_build_cube_new_coords(struct lp_build_context *ivec_bld, + LLVMValueRef face, + LLVMValueRef x0, + LLVMValueRef x1, + LLVMValueRef y0, + LLVMValueRef y1, + LLVMValueRef max_coord, + LLVMValueRef new_faces[4], + LLVMValueRef new_xcoords[4][2], + LLVMValueRef new_ycoords[4][2]); + + void lp_build_sample_partial_offset(struct lp_build_context *bld, unsigned block_length, @@ -472,21 +570,11 @@ lp_build_sample_offset(struct lp_build_context *bld, void -lp_build_sample_soa(struct gallivm_state *gallivm, - const struct lp_static_texture_state *static_texture_state, +lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_texture_state, - struct lp_type fp_type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, - LLVMValueRef explicit_lod, - enum lp_sampler_lod_property lod_property, - LLVMValueRef texel_out[4]); + struct gallivm_state *gallivm, + const struct lp_sampler_params *params); void @@ -505,6 +593,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, struct lp_type int_type, unsigned texture_unit, unsigned target, + LLVMValueRef context_ptr, boolean is_sviewinfo, enum lp_sampler_lod_property lod_property, LLVMValueRef explicit_lod, @@ -520,7 +609,8 @@ lp_build_sample_nop(struct gallivm_state *gallivm, LLVMValueRef lp_build_minify(struct lp_build_context *bld, LLVMValueRef base_size, - LLVMValueRef level); + LLVMValueRef level, + boolean lod_scalar); #endif /* LP_BLD_SAMPLE_H */