freedreno/a4xx: frag-depth fixes
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_format.h
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 #ifndef LP_BLD_FORMAT_H
29 #define LP_BLD_FORMAT_H
30
31
32 /**
33 * @file
34 * Pixel format helpers.
35 */
36
37 #include "gallivm/lp_bld.h"
38 #include "gallivm/lp_bld_init.h"
39
40 #include "pipe/p_format.h"
41
42 struct util_format_description;
43 struct lp_type;
44 struct lp_build_context;
45
46
47 /*
48 * AoS
49 */
50
51 LLVMValueRef
52 lp_build_format_swizzle_aos(const struct util_format_description *desc,
53 struct lp_build_context *bld,
54 LLVMValueRef unswizzled);
55
56 LLVMValueRef
57 lp_build_pack_rgba_aos(struct gallivm_state *gallivm,
58 const struct util_format_description *desc,
59 LLVMValueRef rgba);
60
61 LLVMValueRef
62 lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
63 const struct util_format_description *format_desc,
64 struct lp_type type,
65 boolean aligned,
66 LLVMValueRef base_ptr,
67 LLVMValueRef offset,
68 LLVMValueRef i,
69 LLVMValueRef j);
70
71 LLVMValueRef
72 lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,
73 const struct util_format_description *format_desc,
74 struct lp_type type,
75 LLVMValueRef base_ptr,
76 LLVMValueRef offset);
77
78
79 /*
80 * SoA
81 */
82
83 void
84 lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
85 struct lp_build_context *bld,
86 const LLVMValueRef unswizzled[4],
87 LLVMValueRef swizzled_out[4]);
88
89 void
90 lp_build_unpack_rgba_soa(struct gallivm_state *gallivm,
91 const struct util_format_description *format_desc,
92 struct lp_type type,
93 LLVMValueRef packed,
94 LLVMValueRef rgba_out[4]);
95
96 void
97 lp_build_rgba8_to_fi32_soa(struct gallivm_state *gallivm,
98 struct lp_type dst_type,
99 LLVMValueRef packed,
100 LLVMValueRef *rgba);
101
102 void
103 lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
104 const struct util_format_description *format_desc,
105 struct lp_type type,
106 LLVMValueRef base_ptr,
107 LLVMValueRef offsets,
108 LLVMValueRef i,
109 LLVMValueRef j,
110 LLVMValueRef rgba_out[4]);
111
112 /*
113 * YUV
114 */
115
116
117 LLVMValueRef
118 lp_build_fetch_subsampled_rgba_aos(struct gallivm_state *gallivm,
119 const struct util_format_description *format_desc,
120 unsigned n,
121 LLVMValueRef base_ptr,
122 LLVMValueRef offset,
123 LLVMValueRef i,
124 LLVMValueRef j);
125
126 /*
127 * special float formats
128 */
129
130 LLVMValueRef
131 lp_build_float_to_smallfloat(struct gallivm_state *gallivm,
132 struct lp_type i32_type,
133 LLVMValueRef src,
134 unsigned mantissa_bits,
135 unsigned exponent_bits,
136 unsigned mantissa_start,
137 boolean has_sign);
138
139 LLVMValueRef
140 lp_build_smallfloat_to_float(struct gallivm_state *gallivm,
141 struct lp_type f32_type,
142 LLVMValueRef src,
143 unsigned mantissa_bits,
144 unsigned exponent_bits,
145 unsigned mantissa_start,
146 boolean has_sign);
147
148 LLVMValueRef
149 lp_build_float_to_r11g11b10(struct gallivm_state *gallivm,
150 LLVMValueRef *src);
151
152 void
153 lp_build_r11g11b10_to_float(struct gallivm_state *gallivm,
154 LLVMValueRef src,
155 LLVMValueRef *dst);
156
157 void
158 lp_build_rgb9e5_to_float(struct gallivm_state *gallivm,
159 LLVMValueRef src,
160 LLVMValueRef *dst);
161
162 LLVMValueRef
163 lp_build_float_to_srgb_packed(struct gallivm_state *gallivm,
164 const struct util_format_description *dst_fmt,
165 struct lp_type src_type,
166 LLVMValueRef *src);
167
168 LLVMValueRef
169 lp_build_srgb_to_linear(struct gallivm_state *gallivm,
170 struct lp_type src_type,
171 unsigned chan_bits,
172 LLVMValueRef src);
173
174
175 #endif /* !LP_BLD_FORMAT_H */