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