1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/*
* Copyright © 2006 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Keith Packard <keithp@keithp.com>
* Eric Anholt <eric@anholt.net>
*
*/
include(`exa_wm.g4i')
define(`YCbCr_base', `g12')
define(`Cr', `g12')
define(`Cr_01', `g12')
define(`Cr_23', `g13')
define(`Y', `g14')
define(`Y_01', `g14')
define(`Y_23', `g15')
define(`Cb', `g16')
define(`Cb_01', `g16')
define(`Cb_23', `g17')
/* The initial payload of the thread is always g0.
* WM_URB (incoming URB entries) is g3
* X0_R is g4
* X1_R is g5
* Y0_R is g6
* Y1_R is g7
*/
/* Set up the X/Y screen coordinates of the pixels in our 4 subspans. Each
* subspan is a 2x2 rectangle, and the screen x/y of the upper left of each
* subspan are given in GRF register 1.2 through 1.5 (which, with the word
* addressing below, are 1.4 through 1.11).
*
* The result is WM_X*_R and WM_Y*R being:
*
* X0: {ss0.x, ss0.x+1, ss0.x, ss0.x+1, ss1.x, ss1.x+1, ss1.x, ss1.x+y}
* Y0: {ss0.y, ss0.y, ss0.y+1, ss0.y+1, ss1.y, ss1.y, ss1.y+1, ss1.y+1}
* X1: {ss2.x, ss2.x+1, ss2.x, ss2.x+1, ss3.x, ss3.x+1, ss3.x, ss3.x+y}
* Y1: {ss2.y, ss2.y, ss2.y+1, ss2.y+1, ss3.y, ss3.y, ss3.y+1, ss3.y+1}
*/
/* Set up ss0.x coordinates*/
mov (1) g4<1>F g1.8<0,1,0>UW { align1 };
add (1) g4.4<1>F g1.8<0,1,0>UW 1UD { align1 };
mov (1) g4.8<1>F g1.8<0,1,0>UW { align1 };
add (1) g4.12<1>F g1.8<0,1,0>UW 1UD { align1 };
/* Set up ss0.y coordinates */
mov (1) g6<1>F g1.10<0,1,0>UW { align1 };
mov (1) g6.4<1>F g1.10<0,1,0>UW { align1 };
add (1) g6.8<1>F g1.10<0,1,0>UW 1UD { align1 };
add (1) g6.12<1>F g1.10<0,1,0>UW 1UD { align1 };
/* set up ss1.x coordinates */
mov (1) g4.16<1>F g1.12<0,1,0>UW { align1 };
add (1) g4.20<1>F g1.12<0,1,0>UW 1UD { align1 };
mov (1) g4.24<1>F g1.12<0,1,0>UW { align1 };
add (1) g4.28<1>F g1.12<0,1,0>UW 1UD { align1 };
/* set up ss1.y coordinates */
mov (1) g6.16<1>F g1.14<0,1,0>UW { align1 };
mov (1) g6.20<1>F g1.14<0,1,0>UW { align1 };
add (1) g6.24<1>F g1.14<0,1,0>UW 1UD { align1 };
add (1) g6.28<1>F g1.14<0,1,0>UW 1UD { align1 };
/* Set up ss2.x coordinates */
mov (1) g5<1>F g1.16<0,1,0>UW { align1 };
add (1) g5.4<1>F g1.16<0,1,0>UW 1UD { align1 };
mov (1) g5.8<1>F g1.16<0,1,0>UW { align1 };
add (1) g5.12<1>F g1.16<0,1,0>UW 1UD { align1 };
/* Set up ss2.y coordinates */
mov (1) g7<1>F g1.18<0,1,0>UW { align1 };
mov (1) g7.4<1>F g1.18<0,1,0>UW { align1 };
add (1) g7.8<1>F g1.18<0,1,0>UW 1UD { align1 };
add (1) g7.12<1>F g1.18<0,1,0>UW 1UD { align1 };
/* Set up ss3.x coordinates */
mov (1) g5.16<1>F g1.20<0,1,0>UW { align1 };
add (1) g5.20<1>F g1.20<0,1,0>UW 1UD { align1 };
mov (1) g5.24<1>F g1.20<0,1,0>UW { align1 };
add (1) g5.28<1>F g1.20<0,1,0>UW 1UD { align1 };
/* Set up ss3.y coordinates */
mov (1) g7.16<1>F g1.22<0,1,0>UW { align1 };
mov (1) g7.20<1>F g1.22<0,1,0>UW { align1 };
add (1) g7.24<1>F g1.22<0,1,0>UW 1UD { align1 };
add (1) g7.28<1>F g1.22<0,1,0>UW 1UD { align1 };
/* Now, map these screen space coordinates into texture coordinates. */
/* subtract screen-space X origin of vertex 0. */
add (8) g4<1>F g4<8,8,1>F -g1<0,1,0>F { align1 };
add (8) g5<1>F g5<8,8,1>F -g1<0,1,0>F { align1 };
/* scale by texture X increment */
mul (8) g4<1>F g4<8,8,1>F g3<0,1,0>F { align1 };
mul (8) g5<1>F g5<8,8,1>F g3<0,1,0>F { align1 };
/* add in texture X offset */
add (8) g4<1>F g4<8,8,1>F g3.12<0,1,0>F { align1 };
add (8) g5<1>F g5<8,8,1>F g3.12<0,1,0>F { align1 };
/* subtract screen-space Y origin of vertex 0. */
add (8) g6<1>F g6<8,8,1>F -g1.4<0,1,0>F { align1 };
add (8) g7<1>F g7<8,8,1>F -g1.4<0,1,0>F { align1 };
/* scale by texture Y increment */
mul (8) g6<1>F g6<8,8,1>F g3.20<0,1,0>F { align1 };
mul (8) g7<1>F g7<8,8,1>F g3.20<0,1,0>F { align1 };
/* add in texture Y offset */
add (8) g6<1>F g6<8,8,1>F g3.28<0,1,0>F { align1 };
add (8) g7<1>F g7<8,8,1>F g3.28<0,1,0>F { align1 };
/* sampler */
mov (8) m1<1>F g4<8,8,1>F { align1 };
mov (8) m2<1>F g5<8,8,1>F { align1 };
mov (8) m3<1>F g6<8,8,1>F { align1 };
mov (8) m4<1>F g7<8,8,1>F { align1 };
/*
* g0 holds the PS thread payload, which (oddly) contains
* precisely what the sampler wants to see in m0
*/
send (16)
0 /* load g0 to m0 */
YCbCr_base<1>UW
g0<8,8,1>UW
sampler (1,0,F)
mlen 5 rlen 8 { align1 };
/* color space conversion function:
* R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
* G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
* B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
*
* Y is g14, g15.
* Cr is g12, g13.
* Cb is g16, g17.
*
* R is g2, g6.
* G is g3, g7.
* B is g4, g8.
*/
/* Normalize Y, Cb and Cr:
*
* Y = (Y - 16/255) * 1.164
* Cr = Cr - 128 / 255
* Cb = Cb - 128 / 255
*/
add (16) Y<1>F Y<8,8,1>F -0.0627451F { compr align1 };
mul (16) Y<1>F Y<8,8,1>F 1.164F { compr align1 };
add (16) Cr<1>F Cr<8,8,1>F -0.501961F { compr align1 };
add (16) Cb<1>F Cb<8,8,1>F -0.501961F { compr align1 };
/*
* R = Y + Cr * 1.596
*/
mul (8) null Cr_01<8,8,1>F 1.596F { align1 };
mac.sat (8) data_port_r_01<1>F Y_01<8,8,1>F 1F { align1 };
mul (8) null Cr_23<8,8,1>F 1.596F { align1 };
mac.sat (8) data_port_r_23<1>F Y_23<8,8,1>F 1F { align1 };
/*
* G = Cr * -0.813 + Cb * -0.392 + Y
*/
mul (8) null Cr_01<8,8,1>F -0.813F { align1 };
mac (8) null Cb_01<8,8,1>F -0.392F { align1 };
mac.sat (8) data_port_g_01<1>F Y_01<8,8,1>F 1F { align1 };
mul (8) null Cr_23<8,8,1>F -0.813F { align1 };
mac (8) null Cb_23<8,8,1>F -0.392F { align1 };
mac.sat (8) data_port_g_23<1>F Y_23<8,8,1>F 1F { align1 };
/*
* B = Cb * 2.017 + Y
*/
mul (8) null Cb_01<8,8,1>F 2.017F { align1 };
mac.sat (8) data_port_b_01<1>F Y_01<8,8,1>F 1F { align1 };
mul (8) null Cb_23<8,8,1>F 2.017F { align1 };
mac.sat (8) data_port_b_23<1>F Y_23<8,8,1>F 1F { align1 };
/*
* A = 1.0
*/
mov (8) data_port_a_01<1>F 1.0F { align1 };
mov (8) data_port_a_23<1>F 1.0F { align1 };
/*
* Pass through control information:
*/
mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable };
/*
* Send framebuffer write message: XXX: acc0?
*/
send (16) 0 acc0<1>UW g0<8,8,1>UW write (
0, /* binding table index 0 */
8, /* pixel scoreboard clear */
4, /* render target write */
0 /* no write commit message */
) mlen 10 rlen 0 { align1 EOT };
/* padding */
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
|