pipe_sampler_state::compare_mode is not a boolean enable flag.
[mesa.git] / src / gallium / drivers / llvmpipe / lp_bld_sample_soa.c
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 -- SoA.
31 *
32 * @author Jose Fonseca <jfonseca@vmware.com>
33 */
34
35 #include "pipe/p_defines.h"
36 #include "pipe/p_state.h"
37 #include "util/u_debug.h"
38 #include "util/u_debug_dump.h"
39 #include "util/u_memory.h"
40 #include "util/u_math.h"
41 #include "util/u_format.h"
42 #include "util/u_cpu_detect.h"
43 #include "lp_bld_debug.h"
44 #include "lp_bld_type.h"
45 #include "lp_bld_const.h"
46 #include "lp_bld_conv.h"
47 #include "lp_bld_arit.h"
48 #include "lp_bld_logic.h"
49 #include "lp_bld_swizzle.h"
50 #include "lp_bld_pack.h"
51 #include "lp_bld_format.h"
52 #include "lp_bld_sample.h"
53
54
55 /**
56 * Keep all information for sampling code generation in a single place.
57 */
58 struct lp_build_sample_context
59 {
60 LLVMBuilderRef builder;
61
62 const struct lp_sampler_static_state *static_state;
63
64 struct lp_sampler_dynamic_state *dynamic_state;
65
66 const struct util_format_description *format_desc;
67
68 /** Incoming coordinates type and build context */
69 struct lp_type coord_type;
70 struct lp_build_context coord_bld;
71
72 /** Integer coordinates */
73 struct lp_type int_coord_type;
74 struct lp_build_context int_coord_bld;
75
76 /** Output texels type and build context */
77 struct lp_type texel_type;
78 struct lp_build_context texel_bld;
79 };
80
81
82 static void
83 lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
84 LLVMValueRef x,
85 LLVMValueRef y,
86 LLVMValueRef y_stride,
87 LLVMValueRef data_ptr,
88 LLVMValueRef *texel)
89 {
90 LLVMValueRef offset;
91 LLVMValueRef packed;
92
93 offset = lp_build_sample_offset(&bld->int_coord_bld,
94 bld->format_desc,
95 x, y, y_stride,
96 data_ptr);
97
98 assert(bld->format_desc->block.width == 1);
99 assert(bld->format_desc->block.height == 1);
100 assert(bld->format_desc->block.bits <= bld->texel_type.width);
101
102 packed = lp_build_gather(bld->builder,
103 bld->texel_type.length,
104 bld->format_desc->block.bits,
105 bld->texel_type.width,
106 data_ptr, offset);
107
108 lp_build_unpack_rgba_soa(bld->builder,
109 bld->format_desc,
110 bld->texel_type,
111 packed, texel);
112 }
113
114
115 static LLVMValueRef
116 lp_build_sample_packed(struct lp_build_sample_context *bld,
117 LLVMValueRef x,
118 LLVMValueRef y,
119 LLVMValueRef y_stride,
120 LLVMValueRef data_ptr)
121 {
122 LLVMValueRef offset;
123
124 offset = lp_build_sample_offset(&bld->int_coord_bld,
125 bld->format_desc,
126 x, y, y_stride,
127 data_ptr);
128
129 assert(bld->format_desc->block.width == 1);
130 assert(bld->format_desc->block.height == 1);
131 assert(bld->format_desc->block.bits <= bld->texel_type.width);
132
133 return lp_build_gather(bld->builder,
134 bld->texel_type.length,
135 bld->format_desc->block.bits,
136 bld->texel_type.width,
137 data_ptr, offset);
138 }
139
140
141 static LLVMValueRef
142 lp_build_sample_wrap(struct lp_build_sample_context *bld,
143 LLVMValueRef coord,
144 LLVMValueRef length,
145 boolean is_pot,
146 unsigned wrap_mode)
147 {
148 struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
149 LLVMValueRef length_minus_one;
150
151 length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one);
152
153 switch(wrap_mode) {
154 case PIPE_TEX_WRAP_REPEAT:
155 if(is_pot)
156 coord = LLVMBuildAnd(bld->builder, coord, length_minus_one, "");
157 else
158 /* Signed remainder won't give the right results for negative
159 * dividends but unsigned remainder does.*/
160 coord = LLVMBuildURem(bld->builder, coord, length, "");
161 break;
162
163 case PIPE_TEX_WRAP_CLAMP:
164 coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
165 coord = lp_build_min(int_coord_bld, coord, length_minus_one);
166 break;
167
168 case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
169 case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
170 case PIPE_TEX_WRAP_MIRROR_REPEAT:
171 case PIPE_TEX_WRAP_MIRROR_CLAMP:
172 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
173 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
174 /* FIXME */
175 _debug_printf("warning: failed to translate texture wrap mode %s\n",
176 debug_dump_tex_wrap(wrap_mode, TRUE));
177 coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
178 coord = lp_build_min(int_coord_bld, coord, length_minus_one);
179 break;
180
181 default:
182 assert(0);
183 }
184
185 return coord;
186 }
187
188
189 static void
190 lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld,
191 LLVMValueRef s,
192 LLVMValueRef t,
193 LLVMValueRef width,
194 LLVMValueRef height,
195 LLVMValueRef stride,
196 LLVMValueRef data_ptr,
197 LLVMValueRef *texel)
198 {
199 LLVMValueRef x;
200 LLVMValueRef y;
201
202 x = lp_build_ifloor(&bld->coord_bld, s);
203 y = lp_build_ifloor(&bld->coord_bld, t);
204
205 x = lp_build_sample_wrap(bld, x, width, bld->static_state->pot_width, bld->static_state->wrap_s);
206 y = lp_build_sample_wrap(bld, y, height, bld->static_state->pot_height, bld->static_state->wrap_t);
207
208 lp_build_sample_texel_soa(bld, x, y, stride, data_ptr, texel);
209 }
210
211
212 static void
213 lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld,
214 LLVMValueRef s,
215 LLVMValueRef t,
216 LLVMValueRef width,
217 LLVMValueRef height,
218 LLVMValueRef stride,
219 LLVMValueRef data_ptr,
220 LLVMValueRef *texel)
221 {
222 LLVMValueRef half;
223 LLVMValueRef s_ipart;
224 LLVMValueRef t_ipart;
225 LLVMValueRef s_fpart;
226 LLVMValueRef t_fpart;
227 LLVMValueRef x0, x1;
228 LLVMValueRef y0, y1;
229 LLVMValueRef neighbors[2][2][4];
230 unsigned chan;
231
232 half = lp_build_const_scalar(bld->coord_type, 0.5);
233 s = lp_build_sub(&bld->coord_bld, s, half);
234 t = lp_build_sub(&bld->coord_bld, t, half);
235
236 s_ipart = lp_build_floor(&bld->coord_bld, s);
237 t_ipart = lp_build_floor(&bld->coord_bld, t);
238
239 s_fpart = lp_build_sub(&bld->coord_bld, s, s_ipart);
240 t_fpart = lp_build_sub(&bld->coord_bld, t, t_ipart);
241
242 x0 = lp_build_itrunc(&bld->coord_bld, s_ipart);
243 y0 = lp_build_itrunc(&bld->coord_bld, t_ipart);
244
245 x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s);
246 y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t);
247
248 x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one);
249 y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one);
250
251 x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s);
252 y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
253
254 lp_build_sample_texel_soa(bld, x0, y0, stride, data_ptr, neighbors[0][0]);
255 lp_build_sample_texel_soa(bld, x1, y0, stride, data_ptr, neighbors[0][1]);
256 lp_build_sample_texel_soa(bld, x0, y1, stride, data_ptr, neighbors[1][0]);
257 lp_build_sample_texel_soa(bld, x1, y1, stride, data_ptr, neighbors[1][1]);
258
259 /* TODO: Don't interpolate missing channels */
260 for(chan = 0; chan < 4; ++chan) {
261 texel[chan] = lp_build_lerp_2d(&bld->texel_bld,
262 s_fpart, t_fpart,
263 neighbors[0][0][chan],
264 neighbors[0][1][chan],
265 neighbors[1][0][chan],
266 neighbors[1][1][chan]);
267 }
268 }
269
270
271 static void
272 lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
273 struct lp_type dst_type,
274 LLVMValueRef packed,
275 LLVMValueRef *rgba)
276 {
277 LLVMValueRef mask = lp_build_int_const_scalar(dst_type, 0xff);
278 unsigned chan;
279
280 /* Decode the input vector components */
281 for (chan = 0; chan < 4; ++chan) {
282 unsigned start = chan*8;
283 unsigned stop = start + 8;
284 LLVMValueRef input;
285
286 input = packed;
287
288 if(start)
289 input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(dst_type, start), "");
290
291 if(stop < 32)
292 input = LLVMBuildAnd(builder, input, mask, "");
293
294 input = lp_build_unsigned_norm_to_float(builder, 8, dst_type, input);
295
296 rgba[chan] = input;
297 }
298 }
299
300
301 static void
302 lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
303 LLVMValueRef s,
304 LLVMValueRef t,
305 LLVMValueRef width,
306 LLVMValueRef height,
307 LLVMValueRef stride,
308 LLVMValueRef data_ptr,
309 LLVMValueRef *texel)
310 {
311 LLVMBuilderRef builder = bld->builder;
312 struct lp_build_context i32, h16, u8n;
313 LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
314 LLVMValueRef i32_c8, i32_c128, i32_c255;
315 LLVMValueRef s_ipart, s_fpart, s_fpart_lo, s_fpart_hi;
316 LLVMValueRef t_ipart, t_fpart, t_fpart_lo, t_fpart_hi;
317 LLVMValueRef x0, x1;
318 LLVMValueRef y0, y1;
319 LLVMValueRef neighbors[2][2];
320 LLVMValueRef neighbors_lo[2][2];
321 LLVMValueRef neighbors_hi[2][2];
322 LLVMValueRef packed, packed_lo, packed_hi;
323 LLVMValueRef unswizzled[4];
324
325 lp_build_context_init(&i32, builder, lp_type_int(32));
326 lp_build_context_init(&h16, builder, lp_type_ufixed(16));
327 lp_build_context_init(&u8n, builder, lp_type_unorm(8));
328
329 i32_vec_type = lp_build_vec_type(i32.type);
330 h16_vec_type = lp_build_vec_type(h16.type);
331 u8n_vec_type = lp_build_vec_type(u8n.type);
332
333 s = lp_build_mul_imm(&bld->coord_bld, s, 256);
334 t = lp_build_mul_imm(&bld->coord_bld, t, 256);
335
336 s = LLVMBuildFPToSI(builder, s, i32_vec_type, "");
337 t = LLVMBuildFPToSI(builder, t, i32_vec_type, "");
338
339 i32_c128 = lp_build_int_const_scalar(i32.type, -128);
340 s = LLVMBuildAdd(builder, s, i32_c128, "");
341 t = LLVMBuildAdd(builder, t, i32_c128, "");
342
343 i32_c8 = lp_build_int_const_scalar(i32.type, 8);
344 s_ipart = LLVMBuildAShr(builder, s, i32_c8, "");
345 t_ipart = LLVMBuildAShr(builder, t, i32_c8, "");
346
347 i32_c255 = lp_build_int_const_scalar(i32.type, 255);
348 s_fpart = LLVMBuildAnd(builder, s, i32_c255, "");
349 t_fpart = LLVMBuildAnd(builder, t, i32_c255, "");
350
351 x0 = s_ipart;
352 y0 = t_ipart;
353
354 x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s);
355 y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t);
356
357 x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one);
358 y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one);
359
360 x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s);
361 y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
362
363 /*
364 * Transform 4 x i32 in
365 *
366 * s_fpart = {s0, s1, s2, s3}
367 *
368 * into 8 x i16
369 *
370 * s_fpart = {00, s0, 00, s1, 00, s2, 00, s3}
371 *
372 * into two 8 x i16
373 *
374 * s_fpart_lo = {s0, s0, s0, s0, s1, s1, s1, s1}
375 * s_fpart_hi = {s2, s2, s2, s2, s3, s3, s3, s3}
376 *
377 * and likewise for t_fpart. There is no risk of loosing precision here
378 * since the fractional parts only use the lower 8bits.
379 */
380
381 s_fpart = LLVMBuildBitCast(builder, s_fpart, h16_vec_type, "");
382 t_fpart = LLVMBuildBitCast(builder, t_fpart, h16_vec_type, "");
383
384 {
385 LLVMTypeRef elem_type = LLVMInt32Type();
386 LLVMValueRef shuffles_lo[LP_MAX_VECTOR_LENGTH];
387 LLVMValueRef shuffles_hi[LP_MAX_VECTOR_LENGTH];
388 LLVMValueRef shuffle_lo;
389 LLVMValueRef shuffle_hi;
390 unsigned i, j;
391
392 for(j = 0; j < h16.type.length; j += 4) {
393 unsigned subindex = util_cpu_caps.little_endian ? 0 : 1;
394 LLVMValueRef index;
395
396 index = LLVMConstInt(elem_type, j/2 + subindex, 0);
397 for(i = 0; i < 4; ++i)
398 shuffles_lo[j + i] = index;
399
400 index = LLVMConstInt(elem_type, h16.type.length/2 + j/2 + subindex, 0);
401 for(i = 0; i < 4; ++i)
402 shuffles_hi[j + i] = index;
403 }
404
405 shuffle_lo = LLVMConstVector(shuffles_lo, h16.type.length);
406 shuffle_hi = LLVMConstVector(shuffles_hi, h16.type.length);
407
408 s_fpart_lo = LLVMBuildShuffleVector(builder, s_fpart, h16.undef, shuffle_lo, "");
409 t_fpart_lo = LLVMBuildShuffleVector(builder, t_fpart, h16.undef, shuffle_lo, "");
410 s_fpart_hi = LLVMBuildShuffleVector(builder, s_fpart, h16.undef, shuffle_hi, "");
411 t_fpart_hi = LLVMBuildShuffleVector(builder, t_fpart, h16.undef, shuffle_hi, "");
412 }
413
414 /*
415 * Fetch the pixels as 4 x 32bit (rgba order might differ):
416 *
417 * rgba0 rgba1 rgba2 rgba3
418 *
419 * bit cast them into 16 x u8
420 *
421 * r0 g0 b0 a0 r1 g1 b1 a1 r2 g2 b2 a2 r3 g3 b3 a3
422 *
423 * unpack them into two 8 x i16:
424 *
425 * r0 g0 b0 a0 r1 g1 b1 a1
426 * r2 g2 b2 a2 r3 g3 b3 a3
427 *
428 * The higher 8 bits of the resulting elements will be zero.
429 */
430
431 neighbors[0][0] = lp_build_sample_packed(bld, x0, y0, stride, data_ptr);
432 neighbors[0][1] = lp_build_sample_packed(bld, x1, y0, stride, data_ptr);
433 neighbors[1][0] = lp_build_sample_packed(bld, x0, y1, stride, data_ptr);
434 neighbors[1][1] = lp_build_sample_packed(bld, x1, y1, stride, data_ptr);
435
436 neighbors[0][0] = LLVMBuildBitCast(builder, neighbors[0][0], u8n_vec_type, "");
437 neighbors[0][1] = LLVMBuildBitCast(builder, neighbors[0][1], u8n_vec_type, "");
438 neighbors[1][0] = LLVMBuildBitCast(builder, neighbors[1][0], u8n_vec_type, "");
439 neighbors[1][1] = LLVMBuildBitCast(builder, neighbors[1][1], u8n_vec_type, "");
440
441 lp_build_unpack2(builder, u8n.type, h16.type, neighbors[0][0], &neighbors_lo[0][0], &neighbors_hi[0][0]);
442 lp_build_unpack2(builder, u8n.type, h16.type, neighbors[0][1], &neighbors_lo[0][1], &neighbors_hi[0][1]);
443 lp_build_unpack2(builder, u8n.type, h16.type, neighbors[1][0], &neighbors_lo[1][0], &neighbors_hi[1][0]);
444 lp_build_unpack2(builder, u8n.type, h16.type, neighbors[1][1], &neighbors_lo[1][1], &neighbors_hi[1][1]);
445
446 /*
447 * Linear interpolate with 8.8 fixed point.
448 */
449
450 packed_lo = lp_build_lerp_2d(&h16,
451 s_fpart_lo, t_fpart_lo,
452 neighbors_lo[0][0],
453 neighbors_lo[0][1],
454 neighbors_lo[1][0],
455 neighbors_lo[1][1]);
456
457 packed_hi = lp_build_lerp_2d(&h16,
458 s_fpart_hi, t_fpart_hi,
459 neighbors_hi[0][0],
460 neighbors_hi[0][1],
461 neighbors_hi[1][0],
462 neighbors_hi[1][1]);
463
464 packed = lp_build_pack2(builder, h16.type, u8n.type, packed_lo, packed_hi);
465
466 /*
467 * Convert to SoA and swizzle.
468 */
469
470 packed = LLVMBuildBitCast(builder, packed, i32_vec_type, "");
471
472 lp_build_rgba8_to_f32_soa(bld->builder,
473 bld->texel_type,
474 packed, unswizzled);
475
476 lp_build_format_swizzle_soa(bld->format_desc,
477 bld->texel_type, unswizzled,
478 texel);
479 }
480
481
482 static void
483 lp_build_sample_compare(struct lp_build_sample_context *bld,
484 LLVMValueRef p,
485 LLVMValueRef *texel)
486 {
487 struct lp_build_context *texel_bld = &bld->texel_bld;
488 LLVMValueRef res;
489 unsigned chan;
490
491 if(bld->static_state->compare_mode == PIPE_TEX_COMPARE_NONE)
492 return;
493
494 /* TODO: Compare before swizzling, to avoid redundant computations */
495 res = NULL;
496 for(chan = 0; chan < 4; ++chan) {
497 LLVMValueRef cmp;
498 cmp = lp_build_cmp(texel_bld, bld->static_state->compare_func, p, texel[chan]);
499 cmp = lp_build_select(texel_bld, cmp, texel_bld->one, texel_bld->zero);
500
501 if(res)
502 res = lp_build_add(texel_bld, res, cmp);
503 else
504 res = cmp;
505 }
506
507 assert(res);
508 res = lp_build_mul(texel_bld, res, lp_build_const_scalar(texel_bld->type, 0.25));
509
510 /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */
511 for(chan = 0; chan < 3; ++chan)
512 texel[chan] = res;
513 texel[3] = texel_bld->one;
514 }
515
516
517 void
518 lp_build_sample_soa(LLVMBuilderRef builder,
519 const struct lp_sampler_static_state *static_state,
520 struct lp_sampler_dynamic_state *dynamic_state,
521 struct lp_type type,
522 unsigned unit,
523 unsigned num_coords,
524 const LLVMValueRef *coords,
525 LLVMValueRef lodbias,
526 LLVMValueRef *texel)
527 {
528 struct lp_build_sample_context bld;
529 LLVMValueRef width;
530 LLVMValueRef height;
531 LLVMValueRef stride;
532 LLVMValueRef data_ptr;
533 LLVMValueRef s;
534 LLVMValueRef t;
535 LLVMValueRef p;
536
537 /* Setup our build context */
538 memset(&bld, 0, sizeof bld);
539 bld.builder = builder;
540 bld.static_state = static_state;
541 bld.dynamic_state = dynamic_state;
542 bld.format_desc = util_format_description(static_state->format);
543 bld.coord_type = type;
544 bld.int_coord_type = lp_int_type(type);
545 bld.texel_type = type;
546 lp_build_context_init(&bld.coord_bld, builder, bld.coord_type);
547 lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type);
548 lp_build_context_init(&bld.texel_bld, builder, bld.texel_type);
549
550 /* Get the dynamic state */
551 width = dynamic_state->width(dynamic_state, builder, unit);
552 height = dynamic_state->height(dynamic_state, builder, unit);
553 stride = dynamic_state->stride(dynamic_state, builder, unit);
554 data_ptr = dynamic_state->data_ptr(dynamic_state, builder, unit);
555
556 s = coords[0];
557 t = coords[1];
558 p = coords[2];
559
560 width = lp_build_broadcast_scalar(&bld.int_coord_bld, width);
561 height = lp_build_broadcast_scalar(&bld.int_coord_bld, height);
562 stride = lp_build_broadcast_scalar(&bld.int_coord_bld, stride);
563
564 if(static_state->target == PIPE_TEXTURE_1D)
565 t = bld.coord_bld.zero;
566
567 if(static_state->normalized_coords) {
568 LLVMTypeRef coord_vec_type = lp_build_vec_type(bld.coord_type);
569 LLVMValueRef fp_width = LLVMBuildSIToFP(builder, width, coord_vec_type, "");
570 LLVMValueRef fp_height = LLVMBuildSIToFP(builder, height, coord_vec_type, "");
571 s = lp_build_mul(&bld.coord_bld, s, fp_width);
572 t = lp_build_mul(&bld.coord_bld, t, fp_height);
573 }
574
575 switch (static_state->min_img_filter) {
576 case PIPE_TEX_FILTER_NEAREST:
577 lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, stride, data_ptr, texel);
578 break;
579 case PIPE_TEX_FILTER_LINEAR:
580 if(lp_format_is_rgba8(bld.format_desc))
581 lp_build_sample_2d_linear_aos(&bld, s, t, width, height, stride, data_ptr, texel);
582 else
583 lp_build_sample_2d_linear_soa(&bld, s, t, width, height, stride, data_ptr, texel);
584 break;
585 default:
586 assert(0);
587 }
588
589 /* FIXME: respect static_state->min_mip_filter */;
590 /* FIXME: respect static_state->mag_img_filter */;
591 /* FIXME: respect static_state->prefilter */;
592
593 lp_build_sample_compare(&bld, p, texel);
594 }