xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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  * Helper functions for swizzling/shuffling.
31  *
32  * @author Jose Fonseca <[email protected]>
33  */
34 
35 
36 #ifndef LP_BLD_SWIZZLE_H
37 #define LP_BLD_SWIZZLE_H
38 
39 
40 #include "gallivm/lp_bld.h"
41 #include "pipe/p_defines.h"
42 #include "util/format/u_formats.h"
43 
44 
45 struct lp_type;
46 struct lp_build_context;
47 
48 
49 #define LP_BLD_SWIZZLE_DONTCARE 0xFF
50 
51 
52 LLVMValueRef
53 lp_build_broadcast(struct gallivm_state *gallivm,
54                    LLVMTypeRef vec_type,
55                    LLVMValueRef scalar);
56 
57 
58 LLVMValueRef
59 lp_build_broadcast_scalar(struct lp_build_context *bld,
60                           LLVMValueRef scalar);
61 
62 
63 LLVMValueRef
64 lp_build_extract_broadcast(struct gallivm_state *gallivm,
65                            struct lp_type src_type,
66                            struct lp_type dst_type,
67                            LLVMValueRef vector,
68                            LLVMValueRef index);
69 
70 
71 /**
72  * Broadcast one channel of a vector composed of arrays of XYZ.. structures into
73  * all channels XXX...
74  */
75 LLVMValueRef
76 lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
77                             LLVMValueRef a,
78                             unsigned channel,
79                             unsigned num_channels);
80 
81 
82 /**
83  * Swizzle a vector consisting of an array of XYZW structs.
84  *
85  * @param swizzles is the in [0,4[ range.
86  */
87 LLVMValueRef
88 lp_build_swizzle_aos(struct lp_build_context *bld,
89                      LLVMValueRef a,
90                      const unsigned char swizzles[4]);
91 
92 
93 LLVMValueRef
94 lp_build_swizzle_aos_n(struct gallivm_state* gallivm,
95                        LLVMValueRef src,
96                        const unsigned char* swizzles,
97                        unsigned num_swizzles,
98                        unsigned dst_len);
99 
100 
101 LLVMValueRef
102 lp_build_swizzle_soa_channel(struct lp_build_context *bld,
103                              const LLVMValueRef *unswizzled,
104                              enum pipe_swizzle swizzle);
105 
106 
107 void
108 lp_build_swizzle_soa(struct lp_build_context *bld,
109                      const LLVMValueRef *unswizzled,
110                      const unsigned char swizzles[4],
111                      LLVMValueRef *swizzled);
112 
113 
114 void
115 lp_build_swizzle_soa_inplace(struct lp_build_context *bld,
116                              LLVMValueRef *values,
117                              const unsigned char swizzles[4]);
118 
119 
120 void
121 lp_build_transpose_aos(struct gallivm_state *gallivm,
122                        struct lp_type type,
123                        const LLVMValueRef src[4],
124                        LLVMValueRef dst[4]);
125 
126 
127 void
128 lp_build_transpose_aos_n(struct gallivm_state *gallivm,
129                          struct lp_type type,
130                          const LLVMValueRef* src,
131                          unsigned num_srcs,
132                          LLVMValueRef* dst);
133 
134 
135 LLVMValueRef
136 lp_build_pack_aos_scalars(struct gallivm_state *gallivm,
137                           struct lp_type src_type,
138                           struct lp_type dst_type,
139                           const LLVMValueRef src,
140                           unsigned channel);
141 
142 
143 LLVMValueRef
144 lp_build_unpack_broadcast_aos_scalars(struct gallivm_state *gallivm,
145                                       struct lp_type src_type,
146                                       struct lp_type dst_type,
147                                       const LLVMValueRef src);
148 
149 
150 #endif /* !LP_BLD_SWIZZLE_H */
151