1 /*
2  * Copyright © 2016 Intel Corporation
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, sublicense,
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 next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * 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 NONINFRINGEMENT.  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 DEALINGS
21  * IN THE SOFTWARE.
22  */
23 #ifndef GEN_SAMPLE_POSITIONS_H
24 #define GEN_SAMPLE_POSITIONS_H
25 
26 /*
27  * This file defines the standard multisample positions used by both GL and
28  * Vulkan.  These correspond to the Vulkan "standard sample locations".
29  */
30 
31 /**
32  * 1x MSAA has a single sample at the center: (0.5, 0.5) -> (0x8, 0x8).
33  */
34 #define GEN_SAMPLE_POS_1X(prefix) \
35 prefix##0XOffset   = 0.5; \
36 prefix##0YOffset   = 0.5;
37 
38 /**
39  * 2x MSAA sample positions are (0.25, 0.25) and (0.75, 0.75):
40  *   4 c
41  * 4 0
42  * c   1
43  */
44 #define GEN_SAMPLE_POS_2X(prefix) \
45 prefix##0XOffset   = 0.75; \
46 prefix##0YOffset   = 0.75; \
47 prefix##1XOffset   = 0.25; \
48 prefix##1YOffset   = 0.25;
49 
50 /**
51  * Sample positions:
52  *   2 6 a e
53  * 2   0
54  * 6       1
55  * a 2
56  * e     3
57  */
58 #define GEN_SAMPLE_POS_4X(prefix) \
59 prefix##0XOffset   = 0.375; \
60 prefix##0YOffset   = 0.125; \
61 prefix##1XOffset   = 0.875; \
62 prefix##1YOffset   = 0.375; \
63 prefix##2XOffset   = 0.125; \
64 prefix##2YOffset   = 0.625; \
65 prefix##3XOffset   = 0.625; \
66 prefix##3YOffset   = 0.875;
67 
68 /**
69  * Sample positions:
70  *
71  * From the Ivy Bridge PRM, Vol2 Part1 p304 (3DSTATE_MULTISAMPLE:
72  * Programming Notes):
73  *     "When programming the sample offsets (for NUMSAMPLES_4 or _8 and
74  *     MSRASTMODE_xxx_PATTERN), the order of the samples 0 to 3 (or 7
75  *     for 8X) must have monotonically increasing distance from the
76  *     pixel center. This is required to get the correct centroid
77  *     computation in the device."
78  *
79  * Sample positions:
80  *   1 3 5 7 9 b d f
81  * 1               7
82  * 3     3
83  * 5         0
84  * 7 5
85  * 9             2
86  * b       1
87  * d   4
88  * f           6
89  */
90 #define GEN_SAMPLE_POS_8X(prefix) \
91 prefix##0XOffset   = 0.5625; \
92 prefix##0YOffset   = 0.3125; \
93 prefix##1XOffset   = 0.4375; \
94 prefix##1YOffset   = 0.6875; \
95 prefix##2XOffset   = 0.8125; \
96 prefix##2YOffset   = 0.5625; \
97 prefix##3XOffset   = 0.3125; \
98 prefix##3YOffset   = 0.1875; \
99 prefix##4XOffset   = 0.1875; \
100 prefix##4YOffset   = 0.8125; \
101 prefix##5XOffset   = 0.0625; \
102 prefix##5YOffset   = 0.4375; \
103 prefix##6XOffset   = 0.6875; \
104 prefix##6YOffset   = 0.9375; \
105 prefix##7XOffset   = 0.9375; \
106 prefix##7YOffset   = 0.0625;
107 
108 /**
109  * Sample positions:
110  *
111  *    0 1 2 3 4 5 6 7 8 9 a b c d e f
112  * 0   15
113  * 1                  9
114  * 2         10
115  * 3                        7
116  * 4                               13
117  * 5                1
118  * 6        4
119  * 7                          3
120  * 8 12
121  * 9                    0
122  * a            2
123  * b                            6
124  * c     11
125  * d                      5
126  * e              8
127  * f                             14
128  */
129 #define GEN_SAMPLE_POS_16X(prefix) \
130 prefix##0XOffset   = 0.5625; \
131 prefix##0YOffset   = 0.5625; \
132 prefix##1XOffset   = 0.4375; \
133 prefix##1YOffset   = 0.3125; \
134 prefix##2XOffset   = 0.3125; \
135 prefix##2YOffset   = 0.6250; \
136 prefix##3XOffset   = 0.7500; \
137 prefix##3YOffset   = 0.4375; \
138 prefix##4XOffset   = 0.1875; \
139 prefix##4YOffset   = 0.3750; \
140 prefix##5XOffset   = 0.6250; \
141 prefix##5YOffset   = 0.8125; \
142 prefix##6XOffset   = 0.8125; \
143 prefix##6YOffset   = 0.6875; \
144 prefix##7XOffset   = 0.6875; \
145 prefix##7YOffset   = 0.1875; \
146 prefix##8XOffset   = 0.3750; \
147 prefix##8YOffset   = 0.8750; \
148 prefix##9XOffset   = 0.5000; \
149 prefix##9YOffset   = 0.0625; \
150 prefix##10XOffset  = 0.2500; \
151 prefix##10YOffset  = 0.1250; \
152 prefix##11XOffset  = 0.1250; \
153 prefix##11YOffset  = 0.7500; \
154 prefix##12XOffset  = 0.0000; \
155 prefix##12YOffset  = 0.5000; \
156 prefix##13XOffset  = 0.9375; \
157 prefix##13YOffset  = 0.2500; \
158 prefix##14XOffset  = 0.8750; \
159 prefix##14YOffset  = 0.9375; \
160 prefix##15XOffset  = 0.0625; \
161 prefix##15YOffset  = 0.0000;
162 
163 #endif /* GEN_SAMPLE_POSITIONS_H */
164