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