1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2010 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17bf215546Sopenharmony_ci * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
21bf215546Sopenharmony_ci *
22bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
23bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
24bf215546Sopenharmony_ci * of the Software.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci#ifndef LP_BLD_QUAD_H_
30bf215546Sopenharmony_ci#define LP_BLD_QUAD_H_
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "gallivm/lp_bld.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_cistruct lp_build_context;
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci/*
40bf215546Sopenharmony_ci * Each quad is composed of four elements.
41bf215546Sopenharmony_ci *
42bf215546Sopenharmony_ci * #########
43bf215546Sopenharmony_ci * # 0 | 1 #
44bf215546Sopenharmony_ci * #---+---#
45bf215546Sopenharmony_ci * # 2 | 3 #
46bf215546Sopenharmony_ci * #########
47bf215546Sopenharmony_ci */
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_cienum lp_bld_quad {
50bf215546Sopenharmony_ci   LP_BLD_QUAD_TOP_LEFT     = 0,
51bf215546Sopenharmony_ci   LP_BLD_QUAD_TOP_RIGHT    = 1,
52bf215546Sopenharmony_ci   LP_BLD_QUAD_BOTTOM_LEFT  = 2,
53bf215546Sopenharmony_ci   LP_BLD_QUAD_BOTTOM_RIGHT = 3
54bf215546Sopenharmony_ci};
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_ci/*
58bf215546Sopenharmony_ci * (Vector) derivates.
59bf215546Sopenharmony_ci *
60bf215546Sopenharmony_ci * More than one quad is supported. The only requirement is that the vector
61bf215546Sopenharmony_ci * contains a whole number of quads:
62bf215546Sopenharmony_ci *
63bf215546Sopenharmony_ci * ######### ######### ...
64bf215546Sopenharmony_ci * # 0 | 1 # # 4 | 5 #
65bf215546Sopenharmony_ci * #---+---# #---+---# ...
66bf215546Sopenharmony_ci * # 2 | 3 # # 6 | 7 #
67bf215546Sopenharmony_ci * ######### ######### ...
68bf215546Sopenharmony_ci */
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_ciLLVMValueRef
71bf215546Sopenharmony_cilp_build_ddx(struct lp_build_context *bld,
72bf215546Sopenharmony_ci             LLVMValueRef a);
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ciLLVMValueRef
76bf215546Sopenharmony_cilp_build_ddy(struct lp_build_context *bld,
77bf215546Sopenharmony_ci             LLVMValueRef a);
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci/*
81bf215546Sopenharmony_ci * Packed derivatives (one derivative for each direction per quad)
82bf215546Sopenharmony_ci */
83bf215546Sopenharmony_ciLLVMValueRef
84bf215546Sopenharmony_cilp_build_packed_ddx_ddy_twocoord(struct lp_build_context *bld,
85bf215546Sopenharmony_ci                                 LLVMValueRef a, LLVMValueRef b);
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ciLLVMValueRef
88bf215546Sopenharmony_cilp_build_packed_ddx_ddy_onecoord(struct lp_build_context *bld,
89bf215546Sopenharmony_ci                                 LLVMValueRef a);
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci/*
92bf215546Sopenharmony_ci * Twiddle from quad format to row format
93bf215546Sopenharmony_ci */
94bf215546Sopenharmony_civoid
95bf215546Sopenharmony_cilp_bld_quad_twiddle(struct gallivm_state *gallivm,
96bf215546Sopenharmony_ci                    struct lp_type lp_dst_type,
97bf215546Sopenharmony_ci                    const LLVMValueRef* src,
98bf215546Sopenharmony_ci                    unsigned src_count,
99bf215546Sopenharmony_ci                    LLVMValueRef* dst);
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci#endif /* LP_BLD_QUAD_H_ */
102