xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/etnaviv/etnaviv_translate.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright (c) 2012-2013 Etnaviv Project
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sub license,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the
12  * next paragraph) shall be included in all copies or substantial portions
13  * of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 /* inlined translation functions between gallium and vivante */
24 #ifndef H_TRANSLATE
25 #define H_TRANSLATE
26 
27 #include "pipe/p_defines.h"
28 #include "util/format/u_formats.h"
29 #include "pipe/p_state.h"
30 
31 #include "etnaviv_debug.h"
32 #include "etnaviv_format.h"
33 #include "etnaviv_util.h"
34 #include "hw/cmdstream.xml.h"
35 #include "hw/common_3d.xml.h"
36 #include "hw/state.xml.h"
37 #include "hw/state_3d.xml.h"
38 #include "hw/state_blt.xml.h"
39 
40 #include "util/format/u_format.h"
41 #include "util/u_math.h"
42 #include "util/u_pack_color.h"
43 
44 /* Returned when there is no match of pipe value to etna value */
45 #define ETNA_NO_MATCH (~0)
46 
47 static inline uint32_t
translate_cull_face(unsigned cull_face,unsigned front_ccw)48 translate_cull_face(unsigned cull_face, unsigned front_ccw)
49 {
50    switch (cull_face) {
51    case PIPE_FACE_NONE:
52    case PIPE_FACE_FRONT_AND_BACK: /* handled in draw_vbo */
53       return VIVS_PA_CONFIG_CULL_FACE_MODE_OFF;
54    case PIPE_FACE_BACK:
55       return front_ccw ? VIVS_PA_CONFIG_CULL_FACE_MODE_CW
56                        : VIVS_PA_CONFIG_CULL_FACE_MODE_CCW;
57    case PIPE_FACE_FRONT:
58       return front_ccw ? VIVS_PA_CONFIG_CULL_FACE_MODE_CCW
59                        : VIVS_PA_CONFIG_CULL_FACE_MODE_CW;
60    default:
61       DBG("Unhandled cull face mode %i", cull_face);
62       return ETNA_NO_MATCH;
63    }
64 }
65 
66 static inline uint32_t
translate_polygon_mode(unsigned polygon_mode)67 translate_polygon_mode(unsigned polygon_mode)
68 {
69    switch (polygon_mode) {
70    case PIPE_POLYGON_MODE_FILL:
71       return VIVS_PA_CONFIG_FILL_MODE_SOLID;
72    case PIPE_POLYGON_MODE_LINE:
73       return VIVS_PA_CONFIG_FILL_MODE_WIREFRAME;
74    case PIPE_POLYGON_MODE_POINT:
75       return VIVS_PA_CONFIG_FILL_MODE_POINT;
76    default:
77       DBG("Unhandled polygon mode %i", polygon_mode);
78       return ETNA_NO_MATCH;
79    }
80 }
81 
82 static inline uint32_t
translate_stencil_mode(bool enable_0,bool enable_1)83 translate_stencil_mode(bool enable_0, bool enable_1)
84 {
85    if (enable_0) {
86       return enable_1 ? VIVS_PE_STENCIL_CONFIG_MODE_TWO_SIDED
87                       : VIVS_PE_STENCIL_CONFIG_MODE_ONE_SIDED;
88    } else {
89       return VIVS_PE_STENCIL_CONFIG_MODE_DISABLED;
90    }
91 }
92 
93 static inline uint32_t
translate_stencil_op(unsigned stencil_op)94 translate_stencil_op(unsigned stencil_op)
95 {
96    switch (stencil_op) {
97    case PIPE_STENCIL_OP_KEEP:
98       return STENCIL_OP_KEEP;
99    case PIPE_STENCIL_OP_ZERO:
100       return STENCIL_OP_ZERO;
101    case PIPE_STENCIL_OP_REPLACE:
102       return STENCIL_OP_REPLACE;
103    case PIPE_STENCIL_OP_INCR:
104       return STENCIL_OP_INCR;
105    case PIPE_STENCIL_OP_DECR:
106       return STENCIL_OP_DECR;
107    case PIPE_STENCIL_OP_INCR_WRAP:
108       return STENCIL_OP_INCR_WRAP;
109    case PIPE_STENCIL_OP_DECR_WRAP:
110       return STENCIL_OP_DECR_WRAP;
111    case PIPE_STENCIL_OP_INVERT:
112       return STENCIL_OP_INVERT;
113    default:
114       DBG("Unhandled stencil op: %i", stencil_op);
115       return ETNA_NO_MATCH;
116    }
117 }
118 
119 static inline uint32_t
translate_blend_factor(unsigned blend_factor)120 translate_blend_factor(unsigned blend_factor)
121 {
122    switch (blend_factor) {
123    case PIPE_BLENDFACTOR_ONE:
124       return BLEND_FUNC_ONE;
125    case PIPE_BLENDFACTOR_SRC_COLOR:
126       return BLEND_FUNC_SRC_COLOR;
127    case PIPE_BLENDFACTOR_SRC_ALPHA:
128       return BLEND_FUNC_SRC_ALPHA;
129    case PIPE_BLENDFACTOR_DST_ALPHA:
130       return BLEND_FUNC_DST_ALPHA;
131    case PIPE_BLENDFACTOR_DST_COLOR:
132       return BLEND_FUNC_DST_COLOR;
133    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
134       return BLEND_FUNC_SRC_ALPHA_SATURATE;
135    case PIPE_BLENDFACTOR_CONST_COLOR:
136       return BLEND_FUNC_CONSTANT_COLOR;
137    case PIPE_BLENDFACTOR_CONST_ALPHA:
138       return BLEND_FUNC_CONSTANT_ALPHA;
139    case PIPE_BLENDFACTOR_ZERO:
140       return BLEND_FUNC_ZERO;
141    case PIPE_BLENDFACTOR_INV_SRC_COLOR:
142       return BLEND_FUNC_ONE_MINUS_SRC_COLOR;
143    case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
144       return BLEND_FUNC_ONE_MINUS_SRC_ALPHA;
145    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
146       return BLEND_FUNC_ONE_MINUS_DST_ALPHA;
147    case PIPE_BLENDFACTOR_INV_DST_COLOR:
148       return BLEND_FUNC_ONE_MINUS_DST_COLOR;
149    case PIPE_BLENDFACTOR_INV_CONST_COLOR:
150       return BLEND_FUNC_ONE_MINUS_CONSTANT_COLOR;
151    case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
152       return BLEND_FUNC_ONE_MINUS_CONSTANT_ALPHA;
153    case PIPE_BLENDFACTOR_SRC1_COLOR:
154    case PIPE_BLENDFACTOR_SRC1_ALPHA:
155    case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
156    case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
157    default:
158       DBG("Unhandled blend factor: %i", blend_factor);
159       return ETNA_NO_MATCH;
160    }
161 }
162 
163 static inline uint32_t
translate_texture_wrapmode(unsigned wrap)164 translate_texture_wrapmode(unsigned wrap)
165 {
166    switch (wrap) {
167    case PIPE_TEX_WRAP_REPEAT:
168       return TEXTURE_WRAPMODE_REPEAT;
169    case PIPE_TEX_WRAP_CLAMP:
170       return TEXTURE_WRAPMODE_CLAMP_TO_EDGE;
171    case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
172       return TEXTURE_WRAPMODE_CLAMP_TO_EDGE;
173    case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
174       return TEXTURE_WRAPMODE_CLAMP_TO_EDGE; /* XXX */
175    case PIPE_TEX_WRAP_MIRROR_REPEAT:
176       return TEXTURE_WRAPMODE_MIRRORED_REPEAT;
177    case PIPE_TEX_WRAP_MIRROR_CLAMP:
178       return TEXTURE_WRAPMODE_MIRRORED_REPEAT; /* XXX */
179    case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
180       return TEXTURE_WRAPMODE_MIRRORED_REPEAT; /* XXX */
181    case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
182       return TEXTURE_WRAPMODE_MIRRORED_REPEAT; /* XXX */
183    default:
184       DBG("Unhandled texture wrapmode: %i", wrap);
185       return ETNA_NO_MATCH;
186    }
187 }
188 
189 static inline uint32_t
translate_texture_mipfilter(unsigned filter)190 translate_texture_mipfilter(unsigned filter)
191 {
192    switch (filter) {
193    case PIPE_TEX_MIPFILTER_NEAREST:
194       return TEXTURE_FILTER_NEAREST;
195    case PIPE_TEX_MIPFILTER_LINEAR:
196       return TEXTURE_FILTER_LINEAR;
197    case PIPE_TEX_MIPFILTER_NONE:
198       return TEXTURE_FILTER_NONE;
199    default:
200       DBG("Unhandled texture mipfilter: %i", filter);
201       return ETNA_NO_MATCH;
202    }
203 }
204 
205 static inline uint32_t
translate_texture_filter(unsigned filter)206 translate_texture_filter(unsigned filter)
207 {
208    switch (filter) {
209    case PIPE_TEX_FILTER_NEAREST:
210       return TEXTURE_FILTER_NEAREST;
211    case PIPE_TEX_FILTER_LINEAR:
212       return TEXTURE_FILTER_LINEAR;
213    default:
214       DBG("Unhandled texture filter: %i", filter);
215       return ETNA_NO_MATCH;
216    }
217 }
218 
219 static inline int
translate_rb_src_dst_swap(enum pipe_format src,enum pipe_format dst)220 translate_rb_src_dst_swap(enum pipe_format src, enum pipe_format dst)
221 {
222    return translate_pe_format_rb_swap(src) ^ translate_pe_format_rb_swap(dst);
223 }
224 
225 static inline uint32_t
translate_depth_format(enum pipe_format fmt)226 translate_depth_format(enum pipe_format fmt)
227 {
228    /* Note: Pipe format convention is LSB to MSB, VIVS is MSB to LSB */
229    switch (fmt) {
230    case PIPE_FORMAT_Z16_UNORM:
231       return VIVS_PE_DEPTH_CONFIG_DEPTH_FORMAT_D16;
232    case PIPE_FORMAT_X8Z24_UNORM:
233       return VIVS_PE_DEPTH_CONFIG_DEPTH_FORMAT_D24S8;
234    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
235       return VIVS_PE_DEPTH_CONFIG_DEPTH_FORMAT_D24S8;
236    default:
237       return ETNA_NO_MATCH;
238    }
239 }
240 
241 /* render target format for MSAA */
242 static inline uint32_t
translate_ts_format(enum pipe_format fmt)243 translate_ts_format(enum pipe_format fmt)
244 {
245    /* Note: Pipe format convention is LSB to MSB, VIVS is MSB to LSB */
246    switch (fmt) {
247    case PIPE_FORMAT_B4G4R4X4_UNORM:
248    case PIPE_FORMAT_B4G4R4A4_UNORM:
249       return COMPRESSION_FORMAT_A4R4G4B4;
250    case PIPE_FORMAT_B5G5R5X1_UNORM:
251       return COMPRESSION_FORMAT_A1R5G5B5;
252    case PIPE_FORMAT_B5G5R5A1_UNORM:
253       return COMPRESSION_FORMAT_A1R5G5B5;
254    case PIPE_FORMAT_B5G6R5_UNORM:
255       return COMPRESSION_FORMAT_R5G6B5;
256    case PIPE_FORMAT_B8G8R8X8_UNORM:
257    case PIPE_FORMAT_B8G8R8X8_SRGB:
258    case PIPE_FORMAT_R8G8B8X8_UNORM:
259       return COMPRESSION_FORMAT_X8R8G8B8;
260    case PIPE_FORMAT_B8G8R8A8_UNORM:
261    case PIPE_FORMAT_B8G8R8A8_SRGB:
262    case PIPE_FORMAT_R8G8B8A8_UNORM:
263       return COMPRESSION_FORMAT_A8R8G8B8;
264    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
265       return COMPRESSION_FORMAT_D24S8;
266    case PIPE_FORMAT_X8Z24_UNORM:
267       return COMPRESSION_FORMAT_D24X8;
268    case PIPE_FORMAT_Z16_UNORM:
269       return COMPRESSION_FORMAT_D16;
270    /* MSAA with YUYV not supported */
271    default:
272       return ETNA_NO_MATCH;
273    }
274 }
275 
276 /* formats directly supported in the RS engine */
277 static inline uint32_t
translate_rs_format(enum pipe_format fmt)278 translate_rs_format(enum pipe_format fmt)
279 {
280    /* Note: Pipe format convention is LSB to MSB, VIVS is MSB to LSB */
281    switch (fmt) {
282    case PIPE_FORMAT_B4G4R4X4_UNORM:
283       return RS_FORMAT_X4R4G4B4;
284    case PIPE_FORMAT_B4G4R4A4_UNORM:
285       return RS_FORMAT_A4R4G4B4;
286    case PIPE_FORMAT_B5G5R5X1_UNORM:
287       return RS_FORMAT_X1R5G5B5;
288    case PIPE_FORMAT_B5G5R5A1_UNORM:
289       return RS_FORMAT_A1R5G5B5;
290    case PIPE_FORMAT_B5G6R5_UNORM:
291       return RS_FORMAT_R5G6B5;
292    case PIPE_FORMAT_B8G8R8X8_UNORM:
293    case PIPE_FORMAT_B8G8R8X8_SRGB:
294    case PIPE_FORMAT_R8G8B8X8_UNORM:
295       return RS_FORMAT_X8R8G8B8;
296    case PIPE_FORMAT_B8G8R8A8_UNORM:
297    case PIPE_FORMAT_B8G8R8A8_SRGB:
298    case PIPE_FORMAT_R8G8B8A8_UNORM:
299       return RS_FORMAT_A8R8G8B8;
300    default:
301       return ETNA_NO_MATCH;
302    }
303 }
304 
305 /* formats directly supported in the BLT engine */
306 static inline uint32_t
translate_blt_format(enum pipe_format fmt)307 translate_blt_format(enum pipe_format fmt)
308 {
309    /* Note: Pipe format convention is LSB to MSB, VIVS is MSB to LSB */
310    switch (fmt) {
311    case PIPE_FORMAT_B4G4R4X4_UNORM:
312       return BLT_FORMAT_X4R4G4B4;
313    case PIPE_FORMAT_B4G4R4A4_UNORM:
314       return BLT_FORMAT_A4R4G4B4;
315    case PIPE_FORMAT_B5G5R5X1_UNORM:
316       return BLT_FORMAT_X1R5G5B5;
317    case PIPE_FORMAT_B5G5R5A1_UNORM:
318       return BLT_FORMAT_A1R5G5B5;
319    case PIPE_FORMAT_B5G6R5_UNORM:
320       return BLT_FORMAT_R5G6B5;
321    case PIPE_FORMAT_B8G8R8X8_UNORM:
322    case PIPE_FORMAT_B8G8R8X8_SRGB:
323    case PIPE_FORMAT_R8G8B8X8_UNORM:
324       return BLT_FORMAT_X8R8G8B8;
325    case PIPE_FORMAT_B8G8R8A8_UNORM:
326    case PIPE_FORMAT_B8G8R8A8_SRGB:
327    case PIPE_FORMAT_R8G8B8A8_UNORM:
328       return BLT_FORMAT_A8R8G8B8;
329    case PIPE_FORMAT_R10G10B10A2_UNORM:
330    case PIPE_FORMAT_R10G10B10X2_UNORM:
331       return BLT_FORMAT_A2R10G10B10;
332    default:
333       return ETNA_NO_MATCH;
334    }
335 }
336 
337 static inline uint32_t
drmfourcc_to_ts_format(uint32_t fourcc)338 drmfourcc_to_ts_format(uint32_t fourcc)
339 {
340    switch (fourcc) {
341    case DRM_FORMAT_ARGB8888:
342       return COMPRESSION_FORMAT_A8R8G8B8;
343    case DRM_FORMAT_XRGB8888:
344       return COMPRESSION_FORMAT_X8R8G8B8;
345    case DRM_FORMAT_RGB565:
346       return COMPRESSION_FORMAT_R5G6B5;
347    case DRM_FORMAT_ARGB4444:
348       return COMPRESSION_FORMAT_A4R4G4B4;
349    case DRM_FORMAT_ARGB1555:
350       return COMPRESSION_FORMAT_A1R5G5B5;
351    default:
352       return ~0;
353    }
354 }
355 
356 static inline uint32_t
ts_format_to_drmfourcc(uint32_t comp_format)357 ts_format_to_drmfourcc(uint32_t comp_format)
358 {
359    switch (comp_format) {
360    case COMPRESSION_FORMAT_A8R8G8B8:
361       return DRM_FORMAT_ARGB8888;
362    case COMPRESSION_FORMAT_X8R8G8B8:
363       return DRM_FORMAT_XRGB8888;
364    case COMPRESSION_FORMAT_R5G6B5:
365       return DRM_FORMAT_RGB565;
366    case COMPRESSION_FORMAT_A4R4G4B4:
367       return DRM_FORMAT_ARGB4444;
368    case COMPRESSION_FORMAT_A1R5G5B5:
369       return DRM_FORMAT_ARGB1555;
370    default:
371       return 0;
372    }
373 }
374 
375 /* Return normalization flag for vertex element format */
376 static inline uint32_t
translate_vertex_format_normalize(enum pipe_format fmt)377 translate_vertex_format_normalize(enum pipe_format fmt)
378 {
379    const struct util_format_description *desc = util_format_description(fmt);
380 
381    /* assumes that normalization of channel 0 holds for all channels;
382     * this holds for all vertex formats that we support */
383    return desc->channel[0].normalized
384              ? VIVS_FE_VERTEX_ELEMENT_CONFIG_NORMALIZE_SIGN_EXTEND
385              : VIVS_FE_VERTEX_ELEMENT_CONFIG_NORMALIZE_OFF;
386 }
387 
388 static inline uint32_t
translate_output_mode(enum pipe_format fmt,bool halti5)389 translate_output_mode(enum pipe_format fmt, bool halti5)
390 {
391    const unsigned bits =
392       util_format_get_component_bits(fmt, UTIL_FORMAT_COLORSPACE_RGB, 0);
393 
394    if (bits == 32)
395       return COLOR_OUTPUT_MODE_UIF32;
396 
397    if (!util_format_is_pure_integer(fmt))
398       return COLOR_OUTPUT_MODE_NORMAL;
399 
400    /* generic integer output mode pre-halti5 (?) */
401    if (bits == 10 || !halti5)
402       return COLOR_OUTPUT_MODE_A2B10G10R10UI;
403 
404    if (util_format_is_pure_sint(fmt))
405       return bits == 8 ? COLOR_OUTPUT_MODE_I8 : COLOR_OUTPUT_MODE_I16;
406 
407    return bits == 8 ? COLOR_OUTPUT_MODE_U8 : COLOR_OUTPUT_MODE_U16;
408 }
409 
410 static inline uint32_t
translate_index_size(unsigned index_size)411 translate_index_size(unsigned index_size)
412 {
413    switch (index_size) {
414    case 1:
415       return VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_CHAR;
416    case 2:
417       return VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_SHORT;
418    case 4:
419       return VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_INT;
420    default:
421       DBG("Unhandled index size %i", index_size);
422       return ETNA_NO_MATCH;
423    }
424 }
425 
426 static inline uint32_t
translate_draw_mode(unsigned mode)427 translate_draw_mode(unsigned mode)
428 {
429    switch (mode) {
430    case MESA_PRIM_POINTS:
431       return PRIMITIVE_TYPE_POINTS;
432    case MESA_PRIM_LINES:
433       return PRIMITIVE_TYPE_LINES;
434    case MESA_PRIM_LINE_LOOP:
435       return PRIMITIVE_TYPE_LINE_LOOP;
436    case MESA_PRIM_LINE_STRIP:
437       return PRIMITIVE_TYPE_LINE_STRIP;
438    case MESA_PRIM_TRIANGLES:
439       return PRIMITIVE_TYPE_TRIANGLES;
440    case MESA_PRIM_TRIANGLE_STRIP:
441       return PRIMITIVE_TYPE_TRIANGLE_STRIP;
442    case MESA_PRIM_TRIANGLE_FAN:
443       return PRIMITIVE_TYPE_TRIANGLE_FAN;
444    case MESA_PRIM_QUADS:
445       return PRIMITIVE_TYPE_QUADS;
446    default:
447       DBG("Unhandled draw mode primitive %i", mode);
448       return ETNA_NO_MATCH;
449    }
450 }
451 
452 static inline uint32_t
translate_clear_depth_stencil(enum pipe_format format,double depth,uint8_t stencil)453 translate_clear_depth_stencil(enum pipe_format format, double depth,
454                               uint8_t stencil)
455 {
456    uint32_t clear_value = util_pack_z_stencil(format, depth, stencil);
457 
458    if (format == PIPE_FORMAT_Z16_UNORM)
459       clear_value |= clear_value << 16;
460 
461    return clear_value;
462 }
463 
464 /* Convert MSAA number of samples to x and y scaling factor.
465  * Return true if supported and false otherwise. */
466 static inline bool
translate_samples_to_xyscale(int num_samples,int * xscale_out,int * yscale_out)467 translate_samples_to_xyscale(int num_samples, int *xscale_out, int *yscale_out)
468 {
469    int xscale, yscale;
470 
471    switch (num_samples) {
472    case 0:
473    case 1:
474       xscale = 1;
475       yscale = 1;
476       break;
477    case 2:
478       xscale = 2;
479       yscale = 1;
480       break;
481    case 4:
482       xscale = 2;
483       yscale = 2;
484       break;
485    default:
486       return false;
487    }
488 
489    if (xscale_out)
490       *xscale_out = xscale;
491    if (yscale_out)
492       *yscale_out = yscale;
493 
494    return true;
495 }
496 
497 static inline uint32_t
translate_texture_target(unsigned target)498 translate_texture_target(unsigned target)
499 {
500    switch (target) {
501    case PIPE_TEXTURE_1D:
502       return TEXTURE_TYPE_1D;
503    case PIPE_TEXTURE_2D:
504    case PIPE_TEXTURE_RECT:
505    case PIPE_TEXTURE_1D_ARRAY:
506       return TEXTURE_TYPE_2D;
507    case PIPE_TEXTURE_CUBE:
508       return TEXTURE_TYPE_CUBE_MAP;
509    case PIPE_TEXTURE_3D:
510    case PIPE_TEXTURE_2D_ARRAY:
511       return TEXTURE_TYPE_3D;
512    default:
513       DBG("Unhandled texture target: %i", target);
514       return ETNA_NO_MATCH;
515    }
516 }
517 
518 static inline uint32_t
translate_texture_compare(enum pipe_compare_func compare_func)519 translate_texture_compare(enum pipe_compare_func compare_func)
520 {
521    switch (compare_func) {
522    case PIPE_FUNC_NEVER:
523       return TEXTURE_COMPARE_FUNC_NEVER;
524    case PIPE_FUNC_LESS:
525       return TEXTURE_COMPARE_FUNC_LESS;
526    case PIPE_FUNC_EQUAL:
527       return TEXTURE_COMPARE_FUNC_EQUAL;
528    case PIPE_FUNC_LEQUAL:
529       return TEXTURE_COMPARE_FUNC_LEQUAL;
530    case PIPE_FUNC_GREATER:
531       return TEXTURE_COMPARE_FUNC_GREATER;
532    case PIPE_FUNC_NOTEQUAL:
533       return TEXTURE_COMPARE_FUNC_NOTEQUAL;
534    case PIPE_FUNC_GEQUAL:
535       return TEXTURE_COMPARE_FUNC_GEQUAL;
536    case PIPE_FUNC_ALWAYS:
537       return TEXTURE_COMPARE_FUNC_ALWAYS;
538    default:
539       unreachable("Invalid compare func");
540    }
541 }
542 
543 #endif
544