};
+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;
+ LLVMValueRef thread_data_ptr;
+ const LLVMValueRef *coords;
+ const LLVMValueRef *offsets;
+ LLVMValueRef lod;
+ const struct lp_derivatives *derivs;
+ LLVMValueRef *texel;
+};
+
+
/**
* Texture static 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);
+
+ /**
+ * Obtain texture cache (returns ptr to lp_build_format_cache).
+ *
+ * It's optional: no caching will be done if it's NULL.
+ */
+ LLVMValueRef
+ (*cache_ptr)(const struct lp_sampler_dynamic_state *state,
+ struct gallivm_state *gallivm,
+ LLVMValueRef thread_data_ptr,
+ unsigned unit);
};
LLVMValueRef img_stride_array;
LLVMValueRef base_ptr;
LLVMValueRef mip_offsets;
+ LLVMValueRef cache;
/** Integer vector with texture width, height, depth */
LLVMValueRef int_size;
LLVMValueRef border_color_clamped;
+
+ LLVMValueRef context_ptr;
};
* 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) {
}
-static INLINE void
+static inline void
apply_sampler_swizzle(struct lp_build_sample_context *bld,
LLVMValueRef *texel)
{
* 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) {
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;
}
}
+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,
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
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,
LLVMValueRef
lp_build_minify(struct lp_build_context *bld,
LLVMValueRef base_size,
- LLVMValueRef level);
+ LLVMValueRef level,
+ boolean lod_scalar);
#endif /* LP_BLD_SAMPLE_H */