1/*
2 * Copyright (c) 2011 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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Authors:
24 *    Chris Wilson <chris@chris-wilson.co.uk>
25 *
26 */
27
28#include "brw_test.h"
29
30#include <string.h>
31
32static const uint32_t sf_kernel[][4] = {
33#include "exa_sf.g5b"
34};
35
36static const uint32_t sf_kernel_mask[][4] = {
37#include "exa_sf_mask.g5b"
38};
39
40static const uint32_t ps_kernel_nomask_affine[][4] = {
41#include "exa_wm_xy.g5b"
42#include "exa_wm_src_affine.g5b"
43#include "exa_wm_src_sample_argb.g5b"
44#include "exa_wm_write.g5b"
45};
46
47static const uint32_t ps_kernel_nomask_projective[][4] = {
48#include "exa_wm_xy.g5b"
49#include "exa_wm_src_projective.g5b"
50#include "exa_wm_src_sample_argb.g5b"
51#include "exa_wm_write.g5b"
52};
53
54static const uint32_t ps_kernel_maskca_affine[][4] = {
55#include "exa_wm_xy.g5b"
56#include "exa_wm_src_affine.g5b"
57#include "exa_wm_src_sample_argb.g5b"
58#include "exa_wm_mask_affine.g5b"
59#include "exa_wm_mask_sample_argb.g5b"
60#include "exa_wm_ca.g5b"
61#include "exa_wm_write.g5b"
62};
63
64static const uint32_t ps_kernel_maskca_projective[][4] = {
65#include "exa_wm_xy.g5b"
66#include "exa_wm_src_projective.g5b"
67#include "exa_wm_src_sample_argb.g5b"
68#include "exa_wm_mask_projective.g5b"
69#include "exa_wm_mask_sample_argb.g5b"
70#include "exa_wm_ca.g5b"
71#include "exa_wm_write.g5b"
72};
73
74static const uint32_t ps_kernel_maskca_srcalpha_affine[][4] = {
75#include "exa_wm_xy.g5b"
76#include "exa_wm_src_affine.g5b"
77#include "exa_wm_src_sample_a.g5b"
78#include "exa_wm_mask_affine.g5b"
79#include "exa_wm_mask_sample_argb.g5b"
80#include "exa_wm_ca_srcalpha.g5b"
81#include "exa_wm_write.g5b"
82};
83
84static const uint32_t ps_kernel_maskca_srcalpha_projective[][4] = {
85#include "exa_wm_xy.g5b"
86#include "exa_wm_src_projective.g5b"
87#include "exa_wm_src_sample_a.g5b"
88#include "exa_wm_mask_projective.g5b"
89#include "exa_wm_mask_sample_argb.g5b"
90#include "exa_wm_ca_srcalpha.g5b"
91#include "exa_wm_write.g5b"
92};
93
94static const uint32_t ps_kernel_masknoca_affine[][4] = {
95#include "exa_wm_xy.g5b"
96#include "exa_wm_src_affine.g5b"
97#include "exa_wm_src_sample_argb.g5b"
98#include "exa_wm_mask_affine.g5b"
99#include "exa_wm_mask_sample_a.g5b"
100#include "exa_wm_noca.g5b"
101#include "exa_wm_write.g5b"
102};
103
104static const uint32_t ps_kernel_masknoca_projective[][4] = {
105#include "exa_wm_xy.g5b"
106#include "exa_wm_src_projective.g5b"
107#include "exa_wm_src_sample_argb.g5b"
108#include "exa_wm_mask_projective.g5b"
109#include "exa_wm_mask_sample_a.g5b"
110#include "exa_wm_noca.g5b"
111#include "exa_wm_write.g5b"
112};
113
114static const uint32_t ps_kernel_packed_static[][4] = {
115#include "exa_wm_xy.g5b"
116#include "exa_wm_src_affine.g5b"
117#include "exa_wm_src_sample_argb.g5b"
118#include "exa_wm_yuv_rgb.g5b"
119#include "exa_wm_write.g5b"
120};
121
122static const uint32_t ps_kernel_planar_static[][4] = {
123#include "exa_wm_xy.g5b"
124#include "exa_wm_src_affine.g5b"
125#include "exa_wm_src_sample_planar.g5b"
126#include "exa_wm_yuv_rgb.g5b"
127#include "exa_wm_write.g5b"
128};
129
130#define compare(old) brw_test_compare(__FUNCTION__, p.gen, p.store, p.nr_insn, (struct brw_instruction *)old, ARRAY_SIZE(old))
131
132#define GEN 050
133
134static void gen5_sf(void)
135{
136	uint32_t store[128];
137	struct brw_compile p;
138
139	brw_compile_init(&p, GEN, store);
140	brw_sf_kernel__nomask(&p);
141
142	compare(sf_kernel);
143}
144
145static void gen5_sf_mask(void)
146{
147	uint32_t store[128];
148	struct brw_compile p;
149
150	brw_compile_init(&p, GEN, store);
151	brw_sf_kernel__mask(&p);
152
153	compare(sf_kernel_mask);
154}
155
156static void gen5_wm_affine_nomask(void)
157{
158	uint32_t store[128];
159	struct brw_compile p;
160
161	brw_compile_init(&p, GEN, store);
162	brw_wm_kernel__affine(&p, 16);
163
164	compare(ps_kernel_nomask_affine);
165}
166
167static void gen5_wm_affine_mask_noca(void)
168{
169	uint32_t store[128];
170	struct brw_compile p;
171
172	brw_compile_init(&p, GEN, store);
173	brw_wm_kernel__affine_mask(&p, 16);
174
175	compare(ps_kernel_masknoca_affine);
176}
177
178static void gen5_wm_affine_mask_ca(void)
179{
180	uint32_t store[128];
181	struct brw_compile p;
182
183	brw_compile_init(&p, GEN, store);
184	brw_wm_kernel__affine_mask_ca(&p, 16);
185
186	compare(ps_kernel_maskca_affine);
187}
188
189static void gen5_wm_projective_nomask(void)
190{
191	uint32_t store[128];
192	struct brw_compile p;
193
194	brw_compile_init(&p, GEN, store);
195	brw_wm_kernel__projective(&p, 16);
196
197	compare(ps_kernel_nomask_projective);
198}
199
200void brw_test_gen5(void)
201{
202	gen5_sf();
203	gen5_sf_mask();
204
205	gen5_wm_affine_nomask();
206	gen5_wm_affine_mask_noca();
207	gen5_wm_affine_mask_ca();
208
209	gen5_wm_projective_nomask();
210}
211