Home | History | Annotate | Line # | Download | only in gallivm
      1 /**************************************************************************
      2  *
      3  * Copyright 2009 VMware, Inc.
      4  * All Rights Reserved.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the
      8  * "Software"), to deal in the Software without restriction, including
      9  * without limitation the rights to use, copy, modify, merge, publish,
     10  * distribute, sub license, and/or sell copies of the Software, and to
     11  * permit persons to whom the Software is furnished to do so, subject to
     12  * the following conditions:
     13  *
     14  * The above copyright notice and this permission notice (including the
     15  * next paragraph) shall be included in all copies or substantial portions
     16  * of the Software.
     17  *
     18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
     22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     25  *
     26  **************************************************************************/
     27 
     28 /**
     29  * @file
     30  * Texture sampling.
     31  *
     32  * @author Jose Fonseca <jfonseca (at) vmware.com>
     33  */
     34 
     35 #ifndef LP_BLD_SAMPLE_H
     36 #define LP_BLD_SAMPLE_H
     37 
     38 
     39 #include "pipe/p_format.h"
     40 #include "util/u_debug.h"
     41 #include "gallivm/lp_bld.h"
     42 #include "gallivm/lp_bld_type.h"
     43 #include "gallivm/lp_bld_swizzle.h"
     44 
     45 #ifdef __cplusplus
     46 extern "C" {
     47 #endif
     48 
     49 struct pipe_resource;
     50 struct pipe_sampler_view;
     51 struct pipe_sampler_state;
     52 struct pipe_image_view;
     53 struct util_format_description;
     54 struct lp_type;
     55 struct lp_build_context;
     56 
     57 
     58 /**
     59  * Helper struct holding all derivatives needed for sampling
     60  */
     61 struct lp_derivatives
     62 {
     63    LLVMValueRef ddx[3];
     64    LLVMValueRef ddy[3];
     65 };
     66 
     67 
     68 enum lp_sampler_lod_property {
     69    LP_SAMPLER_LOD_SCALAR,
     70    LP_SAMPLER_LOD_PER_ELEMENT,
     71    LP_SAMPLER_LOD_PER_QUAD
     72 };
     73 
     74 
     75 enum lp_sampler_lod_control {
     76    LP_SAMPLER_LOD_IMPLICIT,
     77    LP_SAMPLER_LOD_BIAS,
     78    LP_SAMPLER_LOD_EXPLICIT,
     79    LP_SAMPLER_LOD_DERIVATIVES,
     80 };
     81 
     82 
     83 enum lp_sampler_op_type {
     84    LP_SAMPLER_OP_TEXTURE,
     85    LP_SAMPLER_OP_FETCH,
     86    LP_SAMPLER_OP_GATHER,
     87    LP_SAMPLER_OP_LODQ
     88 };
     89 
     90 
     91 #define LP_SAMPLER_SHADOW             (1 << 0)
     92 #define LP_SAMPLER_OFFSETS            (1 << 1)
     93 #define LP_SAMPLER_OP_TYPE_SHIFT            2
     94 #define LP_SAMPLER_OP_TYPE_MASK       (3 << 2)
     95 #define LP_SAMPLER_LOD_CONTROL_SHIFT        4
     96 #define LP_SAMPLER_LOD_CONTROL_MASK   (3 << 4)
     97 #define LP_SAMPLER_LOD_PROPERTY_SHIFT       6
     98 #define LP_SAMPLER_LOD_PROPERTY_MASK  (3 << 6)
     99 #define LP_SAMPLER_GATHER_COMP_SHIFT        8
    100 #define LP_SAMPLER_GATHER_COMP_MASK   (3 << 8)
    101 #define LP_SAMPLER_FETCH_MS          (1 << 10)
    102 
    103 struct lp_sampler_params
    104 {
    105    struct lp_type type;
    106    unsigned texture_index;
    107    unsigned sampler_index;
    108    LLVMValueRef texture_index_offset;
    109    unsigned sample_key;
    110    LLVMValueRef context_ptr;
    111    LLVMValueRef thread_data_ptr;
    112    const LLVMValueRef *coords;
    113    const LLVMValueRef *offsets;
    114    LLVMValueRef ms_index;
    115    LLVMValueRef lod;
    116    LLVMValueRef aniso_filter_table;
    117    const struct lp_derivatives *derivs;
    118    LLVMValueRef *texel;
    119 };
    120 
    121 struct lp_sampler_size_query_params
    122 {
    123    struct lp_type int_type;
    124    unsigned texture_unit;
    125    LLVMValueRef texture_unit_offset;
    126    unsigned target;
    127    LLVMValueRef context_ptr;
    128    boolean is_sviewinfo;
    129    bool samples_only;
    130    enum lp_sampler_lod_property lod_property;
    131    LLVMValueRef explicit_lod;
    132    LLVMValueRef *sizes_out;
    133 };
    134 
    135 #define LP_IMG_LOAD 0
    136 #define LP_IMG_STORE 1
    137 #define LP_IMG_ATOMIC 2
    138 #define LP_IMG_ATOMIC_CAS 3
    139 
    140 struct lp_img_params
    141 {
    142    struct lp_type type;
    143    unsigned image_index;
    144    LLVMValueRef image_index_offset;
    145    unsigned img_op;
    146    unsigned target;
    147    LLVMAtomicRMWBinOp op;
    148    LLVMValueRef exec_mask;
    149    LLVMValueRef context_ptr;
    150    LLVMValueRef thread_data_ptr;
    151    const LLVMValueRef *coords;
    152    LLVMValueRef ms_index;
    153    LLVMValueRef indata[4];
    154    LLVMValueRef indata2[4];
    155    LLVMValueRef *outdata;
    156 };
    157 /**
    158  * Texture static state.
    159  *
    160  * These are the bits of state from pipe_resource/pipe_sampler_view that
    161  * are embedded in the generated code.
    162  */
    163 struct lp_static_texture_state
    164 {
    165    /* pipe_sampler_view's state */
    166    enum pipe_format format;
    167    unsigned swizzle_r:3;     /**< PIPE_SWIZZLE_* */
    168    unsigned swizzle_g:3;
    169    unsigned swizzle_b:3;
    170    unsigned swizzle_a:3;
    171 
    172    /* pipe_texture's state */
    173    enum pipe_texture_target target:5;        /**< PIPE_TEXTURE_* */
    174    unsigned pot_width:1;     /**< is the width a power of two? */
    175    unsigned pot_height:1;
    176    unsigned pot_depth:1;
    177    unsigned level_zero_only:1;
    178 };
    179 
    180 
    181 /**
    182  * Sampler static state.
    183  *
    184  * These are the bits of state from pipe_sampler_state that
    185  * are embedded in the generated code.
    186  */
    187 struct lp_static_sampler_state
    188 {
    189    /* pipe_sampler_state's state */
    190    unsigned wrap_s:3;
    191    unsigned wrap_t:3;
    192    unsigned wrap_r:3;
    193    unsigned min_img_filter:2;
    194    unsigned min_mip_filter:2;
    195    unsigned mag_img_filter:2;
    196    unsigned compare_mode:1;
    197    unsigned compare_func:3;
    198    unsigned normalized_coords:1;
    199    unsigned min_max_lod_equal:1;  /**< min_lod == max_lod ? */
    200    unsigned lod_bias_non_zero:1;
    201    unsigned max_lod_pos:1;
    202    unsigned apply_min_lod:1;  /**< min_lod > 0 ? */
    203    unsigned apply_max_lod:1;  /**< max_lod < last_level ? */
    204    unsigned seamless_cube_map:1;
    205    unsigned aniso:1;
    206    unsigned reduction_mode:2;
    207 };
    208 
    209 
    210 /**
    211  * Sampler dynamic state.
    212  *
    213  * These are the bits of state from pipe_resource/pipe_sampler_view
    214  * as well as from sampler state that are computed at runtime.
    215  *
    216  * There are obtained through callbacks, as we don't want to tie the texture
    217  * sampling code generation logic to any particular texture layout or pipe
    218  * driver.
    219  */
    220 struct lp_sampler_dynamic_state
    221 {
    222    /* First callbacks for sampler view state */
    223 
    224    /** Obtain the base texture width (or number of elements) (returns int32) */
    225    LLVMValueRef
    226    (*width)(const struct lp_sampler_dynamic_state *state,
    227             struct gallivm_state *gallivm,
    228             LLVMValueRef context_ptr,
    229             unsigned texture_unit, LLVMValueRef texture_unit_offset);
    230 
    231    /** Obtain the base texture height (returns int32) */
    232    LLVMValueRef
    233    (*height)(const struct lp_sampler_dynamic_state *state,
    234              struct gallivm_state *gallivm,
    235              LLVMValueRef context_ptr,
    236              unsigned texture_unit, LLVMValueRef texture_unit_offset);
    237 
    238    /** Obtain the base texture depth (or array size) (returns int32) */
    239    LLVMValueRef
    240    (*depth)(const struct lp_sampler_dynamic_state *state,
    241             struct gallivm_state *gallivm,
    242             LLVMValueRef context_ptr,
    243             unsigned texture_unit, LLVMValueRef texture_unit_offset);
    244 
    245    /** Obtain the first mipmap level (base level) (returns int32) */
    246    LLVMValueRef
    247    (*first_level)(const struct lp_sampler_dynamic_state *state,
    248                   struct gallivm_state *gallivm,
    249                   LLVMValueRef context_ptr,
    250                   unsigned texture_unit, LLVMValueRef texture_unit_offset);
    251 
    252    /** Obtain the number of mipmap levels minus one (returns int32) */
    253    LLVMValueRef
    254    (*last_level)(const struct lp_sampler_dynamic_state *state,
    255                  struct gallivm_state *gallivm,
    256                  LLVMValueRef context_ptr,
    257                  unsigned texture_unit, LLVMValueRef texture_unit_offset);
    258 
    259    /** Obtain stride in bytes between image rows/blocks (returns int32) */
    260    LLVMValueRef
    261    (*row_stride)(const struct lp_sampler_dynamic_state *state,
    262                  struct gallivm_state *gallivm,
    263                  LLVMValueRef context_ptr,
    264                  unsigned texture_unit, LLVMValueRef texture_unit_offset);
    265 
    266    /** Obtain stride in bytes between image slices (returns int32) */
    267    LLVMValueRef
    268    (*img_stride)(const struct lp_sampler_dynamic_state *state,
    269                  struct gallivm_state *gallivm,
    270                  LLVMValueRef context_ptr,
    271                  unsigned texture_unit, LLVMValueRef texture_unit_offset);
    272 
    273    /** Obtain pointer to base of texture */
    274    LLVMValueRef
    275    (*base_ptr)(const struct lp_sampler_dynamic_state *state,
    276                struct gallivm_state *gallivm,
    277                LLVMValueRef context_ptr,
    278                unsigned texture_unit, LLVMValueRef texture_unit_offset);
    279 
    280    /** Obtain pointer to array of mipmap offsets */
    281    LLVMValueRef
    282    (*mip_offsets)(const struct lp_sampler_dynamic_state *state,
    283                   struct gallivm_state *gallivm,
    284                   LLVMValueRef context_ptr,
    285                   unsigned texture_unit, LLVMValueRef texture_unit_offset);
    286 
    287    /** Obtain number of samples (returns int32) */
    288    LLVMValueRef
    289    (*num_samples)(const struct lp_sampler_dynamic_state *state,
    290                   struct gallivm_state *gallivm,
    291                   LLVMValueRef context_ptr,
    292                   unsigned texture_unit, LLVMValueRef texture_unit_offset);
    293 
    294    /** Obtain multisample stride (returns int32) */
    295    LLVMValueRef
    296    (*sample_stride)(const struct lp_sampler_dynamic_state *state,
    297                     struct gallivm_state *gallivm,
    298                     LLVMValueRef context_ptr,
    299                     unsigned texture_unit, LLVMValueRef texture_unit_offset);
    300 
    301    /* These are callbacks for sampler state */
    302 
    303    /** Obtain texture min lod (returns float) */
    304    LLVMValueRef
    305    (*min_lod)(const struct lp_sampler_dynamic_state *state,
    306               struct gallivm_state *gallivm,
    307               LLVMValueRef context_ptr,
    308               unsigned sampler_unit);
    309 
    310    /** Obtain texture max lod (returns float) */
    311    LLVMValueRef
    312    (*max_lod)(const struct lp_sampler_dynamic_state *state,
    313               struct gallivm_state *gallivm,
    314               LLVMValueRef context_ptr,
    315               unsigned sampler_unit);
    316 
    317    /** Obtain texture lod bias (returns float) */
    318    LLVMValueRef
    319    (*lod_bias)(const struct lp_sampler_dynamic_state *state,
    320                struct gallivm_state *gallivm,
    321                LLVMValueRef context_ptr,
    322                unsigned sampler_unit);
    323 
    324    /** Obtain texture border color (returns ptr to float[4]) */
    325    LLVMValueRef
    326    (*border_color)(const struct lp_sampler_dynamic_state *state,
    327                    struct gallivm_state *gallivm,
    328                    LLVMValueRef context_ptr,
    329                    unsigned sampler_unit);
    330 
    331    /** Obtain maximum anisotropy */
    332    LLVMValueRef
    333    (*max_aniso)(const struct lp_sampler_dynamic_state *state,
    334                 struct gallivm_state *gallivm,
    335                 LLVMValueRef context_ptr,
    336                 unsigned sampler_unit);
    337 
    338    /**
    339     * Obtain texture cache (returns ptr to lp_build_format_cache).
    340     *
    341     * It's optional: no caching will be done if it's NULL.
    342     */
    343    LLVMValueRef
    344    (*cache_ptr)(const struct lp_sampler_dynamic_state *state,
    345                 struct gallivm_state *gallivm,
    346                 LLVMValueRef thread_data_ptr,
    347                 unsigned unit);
    348 };
    349 
    350 
    351 /**
    352  * Keep all information for sampling code generation in a single place.
    353  */
    354 struct lp_build_sample_context
    355 {
    356    struct gallivm_state *gallivm;
    357 
    358    const struct lp_static_texture_state *static_texture_state;
    359    const struct lp_static_sampler_state *static_sampler_state;
    360 
    361    struct lp_sampler_dynamic_state *dynamic_state;
    362 
    363    const struct util_format_description *format_desc;
    364 
    365    /* See texture_dims() */
    366    unsigned dims;
    367 
    368    /** SIMD vector width */
    369    unsigned vector_width;
    370 
    371    /** number of mipmaps (valid are 1, length/4, length) */
    372    unsigned num_mips;
    373 
    374    /** number of lod values (valid are 1, length/4, length) */
    375    unsigned num_lods;
    376 
    377    unsigned gather_comp;
    378    boolean no_quad_lod;
    379    boolean no_brilinear;
    380    boolean no_rho_approx;
    381    boolean fetch_ms;
    382 
    383    /** regular scalar float type */
    384    struct lp_type float_type;
    385    struct lp_build_context float_bld;
    386 
    387    /** float vector type */
    388    struct lp_build_context float_vec_bld;
    389 
    390    /** regular scalar int type */
    391    struct lp_type int_type;
    392    struct lp_build_context int_bld;
    393 
    394    /** Incoming coordinates type and build context */
    395    struct lp_type coord_type;
    396    struct lp_build_context coord_bld;
    397 
    398    /** Signed integer coordinates */
    399    struct lp_type int_coord_type;
    400    struct lp_build_context int_coord_bld;
    401 
    402    /** Unsigned integer texture size */
    403    struct lp_type int_size_in_type;
    404    struct lp_build_context int_size_in_bld;
    405 
    406    /** Float incoming texture size */
    407    struct lp_type float_size_in_type;
    408    struct lp_build_context float_size_in_bld;
    409 
    410    /** Unsigned integer texture size (might be per quad) */
    411    struct lp_type int_size_type;
    412    struct lp_build_context int_size_bld;
    413 
    414    /** Float texture size (might be per quad) */
    415    struct lp_type float_size_type;
    416    struct lp_build_context float_size_bld;
    417 
    418    /** Output texels type and build context */
    419    struct lp_type texel_type;
    420    struct lp_build_context texel_bld;
    421 
    422    /** Float level type */
    423    struct lp_type levelf_type;
    424    struct lp_build_context levelf_bld;
    425 
    426    /** Int level type */
    427    struct lp_type leveli_type;
    428    struct lp_build_context leveli_bld;
    429 
    430    /** Float lod type */
    431    struct lp_type lodf_type;
    432    struct lp_build_context lodf_bld;
    433 
    434    /** Int lod type */
    435    struct lp_type lodi_type;
    436    struct lp_build_context lodi_bld;
    437 
    438    /* Common dynamic state values */
    439    LLVMValueRef row_stride_array;
    440    LLVMValueRef img_stride_array;
    441    LLVMValueRef base_ptr;
    442    LLVMValueRef mip_offsets;
    443    LLVMValueRef cache;
    444    LLVMValueRef sample_stride;
    445 
    446    /** Integer vector with texture width, height, depth */
    447    LLVMValueRef int_size;
    448 
    449    LLVMValueRef border_color_clamped;
    450 
    451    LLVMValueRef context_ptr;
    452 
    453    LLVMValueRef aniso_filter_table;
    454 };
    455 
    456 /*
    457  * Indirect texture access context
    458  *
    459  * This is used to store info across building
    460  * and indirect texture switch statement.
    461  */
    462 struct lp_build_sample_array_switch {
    463    struct gallivm_state *gallivm;
    464    struct lp_sampler_params params;
    465    unsigned base, range;
    466    LLVMValueRef switch_ref;
    467    LLVMBasicBlockRef merge_ref;
    468    LLVMValueRef phi;
    469 };
    470 
    471 struct lp_build_img_op_array_switch {
    472    struct gallivm_state *gallivm;
    473    struct lp_img_params params;
    474    unsigned base, range;
    475    LLVMValueRef switch_ref;
    476    LLVMBasicBlockRef merge_ref;
    477    LLVMValueRef phi[4];
    478 };
    479 
    480 /**
    481  * We only support a few wrap modes in lp_build_sample_wrap_linear_int() at
    482  * this time.  Return whether the given mode is supported by that function.
    483  */
    484 static inline boolean
    485 lp_is_simple_wrap_mode(unsigned mode)
    486 {
    487    switch (mode) {
    488    case PIPE_TEX_WRAP_REPEAT:
    489    case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
    490       return TRUE;
    491    default:
    492       return FALSE;
    493    }
    494 }
    495 
    496 
    497 static inline void
    498 apply_sampler_swizzle(struct lp_build_sample_context *bld,
    499                       LLVMValueRef *texel)
    500 {
    501    unsigned char swizzles[4];
    502 
    503    swizzles[0] = bld->static_texture_state->swizzle_r;
    504    swizzles[1] = bld->static_texture_state->swizzle_g;
    505    swizzles[2] = bld->static_texture_state->swizzle_b;
    506    swizzles[3] = bld->static_texture_state->swizzle_a;
    507 
    508    lp_build_swizzle_soa_inplace(&bld->texel_bld, texel, swizzles);
    509 }
    510 
    511 /*
    512  * not really dimension as such, this indicates the amount of
    513  * "normal" texture coords subject to minification, wrapping etc.
    514  */
    515 static inline unsigned
    516 texture_dims(enum pipe_texture_target tex)
    517 {
    518    switch (tex) {
    519    case PIPE_TEXTURE_1D:
    520    case PIPE_TEXTURE_1D_ARRAY:
    521    case PIPE_BUFFER:
    522       return 1;
    523    case PIPE_TEXTURE_2D:
    524    case PIPE_TEXTURE_2D_ARRAY:
    525    case PIPE_TEXTURE_RECT:
    526    case PIPE_TEXTURE_CUBE:
    527    case PIPE_TEXTURE_CUBE_ARRAY:
    528       return 2;
    529    case PIPE_TEXTURE_3D:
    530       return 3;
    531    default:
    532       assert(0 && "bad texture target in texture_dims()");
    533       return 2;
    534    }
    535 }
    536 
    537 static inline boolean
    538 has_layer_coord(enum pipe_texture_target tex)
    539 {
    540    switch (tex) {
    541    case PIPE_TEXTURE_1D_ARRAY:
    542    case PIPE_TEXTURE_2D_ARRAY:
    543    /* cube is not layered but 3rd coord (after cube mapping) behaves the same */
    544    case PIPE_TEXTURE_CUBE:
    545    case PIPE_TEXTURE_CUBE_ARRAY:
    546       return TRUE;
    547    default:
    548       return FALSE;
    549    }
    550 }
    551 
    552 
    553 boolean
    554 lp_sampler_wrap_mode_uses_border_color(unsigned mode,
    555                                        unsigned min_img_filter,
    556                                        unsigned mag_img_filter);
    557 
    558 /**
    559  * Derive the sampler static state.
    560  */
    561 void
    562 lp_sampler_static_sampler_state(struct lp_static_sampler_state *state,
    563                                 const struct pipe_sampler_state *sampler);
    564 
    565 
    566 void
    567 lp_sampler_static_texture_state(struct lp_static_texture_state *state,
    568                                 const struct pipe_sampler_view *view);
    569 
    570 void
    571 lp_sampler_static_texture_state_image(struct lp_static_texture_state *state,
    572                                       const struct pipe_image_view *view);
    573 
    574 void
    575 lp_build_lod_selector(struct lp_build_sample_context *bld,
    576                       boolean is_lodq,
    577                       unsigned texture_index,
    578                       unsigned sampler_index,
    579                       LLVMValueRef s,
    580                       LLVMValueRef t,
    581                       LLVMValueRef r,
    582                       LLVMValueRef cube_rho,
    583                       const struct lp_derivatives *derivs,
    584                       LLVMValueRef lod_bias, /* optional */
    585                       LLVMValueRef explicit_lod, /* optional */
    586                       unsigned mip_filter,
    587                       LLVMValueRef max_aniso,
    588                       LLVMValueRef *out_lod,
    589                       LLVMValueRef *out_lod_ipart,
    590                       LLVMValueRef *out_lod_fpart,
    591                       LLVMValueRef *out_lod_positive);
    592 
    593 void
    594 lp_build_nearest_mip_level(struct lp_build_sample_context *bld,
    595                            unsigned texture_unit,
    596                            LLVMValueRef lod,
    597                            LLVMValueRef *level_out,
    598                            LLVMValueRef *out_of_bounds);
    599 
    600 void
    601 lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
    602                            unsigned texture_unit,
    603                            LLVMValueRef lod_ipart,
    604                            LLVMValueRef *lod_fpart_inout,
    605                            LLVMValueRef *level0_out,
    606                            LLVMValueRef *level1_out);
    607 
    608 LLVMValueRef
    609 lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
    610                           LLVMValueRef level);
    611 
    612 
    613 LLVMValueRef
    614 lp_build_get_mip_offsets(struct lp_build_sample_context *bld,
    615                          LLVMValueRef level);
    616 
    617 
    618 void
    619 lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
    620                             LLVMValueRef ilevel,
    621                             LLVMValueRef *out_size_vec,
    622                             LLVMValueRef *row_stride_vec,
    623                             LLVMValueRef *img_stride_vec);
    624 
    625 
    626 void
    627 lp_build_extract_image_sizes(struct lp_build_sample_context *bld,
    628                              struct lp_build_context *size_bld,
    629                              struct lp_type coord_type,
    630                              LLVMValueRef size,
    631                              LLVMValueRef *out_width,
    632                              LLVMValueRef *out_height,
    633                              LLVMValueRef *out_depth);
    634 
    635 
    636 void
    637 lp_build_unnormalized_coords(struct lp_build_sample_context *bld,
    638                              LLVMValueRef flt_size,
    639                              LLVMValueRef *s,
    640                              LLVMValueRef *t,
    641                              LLVMValueRef *r);
    642 
    643 
    644 void
    645 lp_build_cube_lookup(struct lp_build_sample_context *bld,
    646                      LLVMValueRef *coords,
    647                      const struct lp_derivatives *derivs_in, /* optional */
    648                      LLVMValueRef *rho,
    649                      struct lp_derivatives *derivs_out, /* optional */
    650                      boolean need_derivs);
    651 
    652 
    653 void
    654 lp_build_cube_new_coords(struct lp_build_context *ivec_bld,
    655                          LLVMValueRef face,
    656                          LLVMValueRef x0,
    657                          LLVMValueRef x1,
    658                          LLVMValueRef y0,
    659                          LLVMValueRef y1,
    660                          LLVMValueRef max_coord,
    661                          LLVMValueRef new_faces[4],
    662                          LLVMValueRef new_xcoords[4][2],
    663                          LLVMValueRef new_ycoords[4][2]);
    664 
    665 
    666 void
    667 lp_build_sample_partial_offset(struct lp_build_context *bld,
    668                                unsigned block_length,
    669                                LLVMValueRef coord,
    670                                LLVMValueRef stride,
    671                                LLVMValueRef *out_offset,
    672                                LLVMValueRef *out_i);
    673 
    674 
    675 void
    676 lp_build_sample_offset(struct lp_build_context *bld,
    677                        const struct util_format_description *format_desc,
    678                        LLVMValueRef x,
    679                        LLVMValueRef y,
    680                        LLVMValueRef z,
    681                        LLVMValueRef y_stride,
    682                        LLVMValueRef z_stride,
    683                        LLVMValueRef *out_offset,
    684                        LLVMValueRef *out_i,
    685                        LLVMValueRef *out_j);
    686 
    687 
    688 void
    689 lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state,
    690                     const struct lp_static_sampler_state *static_sampler_state,
    691                     struct lp_sampler_dynamic_state *dynamic_texture_state,
    692                     struct gallivm_state *gallivm,
    693                     const struct lp_sampler_params *params);
    694 
    695 
    696 void
    697 lp_build_coord_repeat_npot_linear(struct lp_build_sample_context *bld,
    698                                   LLVMValueRef coord_f,
    699                                   LLVMValueRef length_i,
    700                                   LLVMValueRef length_f,
    701                                   LLVMValueRef *coord0_i,
    702                                   LLVMValueRef *weight_f);
    703 
    704 
    705 void
    706 lp_build_size_query_soa(struct gallivm_state *gallivm,
    707                         const struct lp_static_texture_state *static_state,
    708                         struct lp_sampler_dynamic_state *dynamic_state,
    709                         const struct lp_sampler_size_query_params *params);
    710 
    711 void
    712 lp_build_sample_nop(struct gallivm_state *gallivm,
    713                     struct lp_type type,
    714                     const LLVMValueRef *coords,
    715                     LLVMValueRef texel_out[4]);
    716 
    717 
    718 LLVMValueRef
    719 lp_build_minify(struct lp_build_context *bld,
    720                 LLVMValueRef base_size,
    721                 LLVMValueRef level,
    722                 boolean lod_scalar);
    723 
    724 void
    725 lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state,
    726                     struct lp_sampler_dynamic_state *dynamic_state,
    727                     struct gallivm_state *gallivm,
    728                     const struct lp_img_params *params,
    729                     LLVMValueRef outdata[4]);
    730 
    731 void
    732 lp_build_sample_array_init_soa(struct lp_build_sample_array_switch *switch_info,
    733                            struct gallivm_state *gallivm,
    734                            const struct lp_sampler_params *params,
    735                            LLVMValueRef idx,
    736                            unsigned base, unsigned range);
    737 
    738 void
    739 lp_build_sample_array_case_soa(struct lp_build_sample_array_switch *switch_info,
    740                            int idx,
    741                            const struct lp_static_texture_state *static_texture_state,
    742                            const struct lp_static_sampler_state *static_sampler_state,
    743                            struct lp_sampler_dynamic_state *dynamic_texture_state);
    744 
    745 void lp_build_sample_array_fini_soa(struct lp_build_sample_array_switch *switch_info);
    746 
    747 void
    748 lp_build_image_op_switch_soa(struct lp_build_img_op_array_switch *switch_info,
    749                              struct gallivm_state *gallivm,
    750                              const struct lp_img_params *params,
    751                              LLVMValueRef idx,
    752                              unsigned base, unsigned range);
    753 
    754 void
    755 lp_build_image_op_array_case(struct lp_build_img_op_array_switch *switch_info,
    756 			     int idx,
    757 			     const struct lp_static_texture_state *static_texture_state,
    758 			     struct lp_sampler_dynamic_state *dynamic_state);
    759 
    760 void lp_build_image_op_array_fini_soa(struct lp_build_img_op_array_switch *switch_info);
    761 
    762 void
    763 lp_build_reduce_filter(struct lp_build_context *bld,
    764                        enum pipe_tex_reduction_mode mode,
    765                        unsigned flags,
    766                        unsigned num_chan,
    767                        LLVMValueRef x,
    768                        LLVMValueRef *v00,
    769                        LLVMValueRef *v01,
    770                        LLVMValueRef *out);
    771 void
    772 lp_build_reduce_filter_2d(struct lp_build_context *bld,
    773                           enum pipe_tex_reduction_mode mode,
    774                           unsigned flags,
    775                           unsigned num_chan,
    776                           LLVMValueRef x,
    777                           LLVMValueRef y,
    778                           LLVMValueRef *v00,
    779                           LLVMValueRef *v01,
    780                           LLVMValueRef *v10,
    781                           LLVMValueRef *v11,
    782                           LLVMValueRef *out);
    783 
    784 void
    785 lp_build_reduce_filter_3d(struct lp_build_context *bld,
    786                           enum pipe_tex_reduction_mode mode,
    787                           unsigned flags,
    788                           unsigned num_chan,
    789                           LLVMValueRef x,
    790                           LLVMValueRef y,
    791                           LLVMValueRef z,
    792                           LLVMValueRef *v000,
    793                           LLVMValueRef *v001,
    794                           LLVMValueRef *v010,
    795                           LLVMValueRef *v011,
    796                           LLVMValueRef *v100,
    797                           LLVMValueRef *v101,
    798                           LLVMValueRef *v110,
    799                           LLVMValueRef *v111,
    800                           LLVMValueRef *out);
    801 
    802 const float *lp_build_sample_aniso_filter_table(void);
    803 #ifdef __cplusplus
    804 }
    805 #endif
    806 
    807 #endif /* LP_BLD_SAMPLE_H */
    808