freedreno/ir3: array rework
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_sample.h
index be41ca02ae84263ece0982732574c3fc07be5f14..a6f0eff42f684c7f05218a0fea4327293e7dd694 100644 (file)
@@ -68,6 +68,46 @@ 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;
+   LLVMValueRef thread_data_ptr;
+   const LLVMValueRef *coords;
+   const LLVMValueRef *offsets;
+   LLVMValueRef lod;
+   const struct lp_derivatives *derivs;
+   LLVMValueRef *texel;
+};
+
+
 /**
  * Texture static state.
  *
@@ -228,6 +268,17 @@ struct lp_sampler_dynamic_state
                    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);
 };
 
 
@@ -317,6 +368,7 @@ struct lp_build_sample_context
    LLVMValueRef img_stride_array;
    LLVMValueRef base_ptr;
    LLVMValueRef mip_offsets;
+   LLVMValueRef cache;
 
    /** Integer vector with texture width, height, depth */
    LLVMValueRef int_size;
@@ -332,7 +384,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) {
@@ -345,7 +397,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)
 {
@@ -363,7 +415,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) {
@@ -385,7 +437,7 @@ texture_dims(enum pipe_texture_target tex)
    }
 }
 
-static INLINE boolean
+static inline boolean
 has_layer_coord(enum pipe_texture_target tex)
 {
    switch (tex) {
@@ -531,22 +583,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,
-                    LLVMValueRef context_ptr,
-                    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