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.g4b"
34};
35
36static const uint32_t sf_kernel_mask[][4] = {
37#include "exa_sf_mask.g4b"
38};
39
40static const uint32_t ps_kernel_nomask_affine[][4] = {
41#include "exa_wm_xy.g4b"
42#include "exa_wm_src_affine.g4b"
43#include "exa_wm_src_sample_argb.g4b"
44#include "exa_wm_write.g4b"
45};
46
47static const uint32_t ps_kernel_nomask_projective[][4] = {
48#include "exa_wm_xy.g4b"
49#include "exa_wm_src_projective.g4b"
50#include "exa_wm_src_sample_argb.g4b"
51#include "exa_wm_write.g4b"
52};
53
54static const uint32_t ps_kernel_maskca_affine[][4] = {
55#include "exa_wm_xy.g4b"
56#include "exa_wm_src_affine.g4b"
57#include "exa_wm_src_sample_argb.g4b"
58#include "exa_wm_mask_affine.g4b"
59#include "exa_wm_mask_sample_argb.g4b"
60#include "exa_wm_ca.g4b"
61#include "exa_wm_write.g4b"
62};
63
64static const uint32_t ps_kernel_maskca_projective[][4] = {
65#include "exa_wm_xy.g4b"
66#include "exa_wm_src_projective.g4b"
67#include "exa_wm_src_sample_argb.g4b"
68#include "exa_wm_mask_projective.g4b"
69#include "exa_wm_mask_sample_argb.g4b"
70#include "exa_wm_ca.g4b"
71#include "exa_wm_write.g4b"
72};
73
74static const uint32_t ps_kernel_maskca_srcalpha_affine[][4] = {
75#include "exa_wm_xy.g4b"
76#include "exa_wm_src_affine.g4b"
77#include "exa_wm_src_sample_a.g4b"
78#include "exa_wm_mask_affine.g4b"
79#include "exa_wm_mask_sample_argb.g4b"
80#include "exa_wm_ca_srcalpha.g4b"
81#include "exa_wm_write.g4b"
82};
83
84static const uint32_t ps_kernel_maskca_srcalpha_projective[][4] = {
85#include "exa_wm_xy.g4b"
86#include "exa_wm_src_projective.g4b"
87#include "exa_wm_src_sample_a.g4b"
88#include "exa_wm_mask_projective.g4b"
89#include "exa_wm_mask_sample_argb.g4b"
90#include "exa_wm_ca_srcalpha.g4b"
91#include "exa_wm_write.g4b"
92};
93
94static const uint32_t ps_kernel_masknoca_affine[][4] = {
95#include "exa_wm_xy.g4b"
96#include "exa_wm_src_affine.g4b"
97#include "exa_wm_src_sample_argb.g4b"
98#include "exa_wm_mask_affine.g4b"
99#include "exa_wm_mask_sample_a.g4b"
100#include "exa_wm_noca.g4b"
101#include "exa_wm_write.g4b"
102};
103
104static const uint32_t ps_kernel_masknoca_projective[][4] = {
105#include "exa_wm_xy.g4b"
106#include "exa_wm_src_projective.g4b"
107#include "exa_wm_src_sample_argb.g4b"
108#include "exa_wm_mask_projective.g4b"
109#include "exa_wm_mask_sample_a.g4b"
110#include "exa_wm_noca.g4b"
111#include "exa_wm_write.g4b"
112};
113
114static const uint32_t ps_kernel_packed_static[][4] = {
115#include "exa_wm_xy.g4b"
116#include "exa_wm_src_affine.g4b"
117#include "exa_wm_src_sample_argb.g4b"
118#include "exa_wm_yuv_rgb_bt601.g4b"
119#include "exa_wm_write.g4b"
120};
121
122static const uint32_t ps_kernel_planar_static[][4] = {
123#include "exa_wm_xy.g4b"
124#include "exa_wm_src_affine.g4b"
125#include "exa_wm_src_sample_planar.g4b"
126#include "exa_wm_yuv_rgb_bt601.g4b"
127#include "exa_wm_write.g4b"
128};
129
130#define GEN 040
131
132#define compare(old) brw_test_compare(__FUNCTION__, p.gen, p.store, p.nr_insn, (struct brw_instruction *)old, ARRAY_SIZE(old)-8)
133
134static void gen4_sf__nomask(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 gen4_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
157gen4_wm_kernel__affine_nomask(void)
158{
159	uint32_t store[128];
160	struct brw_compile p;
161
162	brw_compile_init(&p, GEN, store);
163	brw_wm_kernel__affine(&p, 16);
164
165	compare(ps_kernel_nomask_affine);
166}
167
168static void
169gen4_wm_kernel__affine_mask_noca(void)
170{
171	uint32_t store[128];
172	struct brw_compile p;
173
174	brw_compile_init(&p, GEN, store);
175	brw_wm_kernel__affine_mask(&p, 16);
176
177	compare(ps_kernel_masknoca_affine);
178}
179
180static void
181gen4_wm_kernel__projective_nomask(void)
182{
183	uint32_t store[128];
184	struct brw_compile p;
185
186	brw_compile_init(&p, GEN, store);
187	brw_wm_kernel__projective(&p, 16);
188
189	compare(ps_kernel_nomask_projective);
190}
191
192void brw_test_gen4(void)
193{
194	gen4_sf__nomask();
195	gen4_sf__mask();
196
197	gen4_wm_kernel__affine_nomask();
198	gen4_wm_kernel__affine_mask_noca();
199
200	gen4_wm_kernel__projective_nomask();
201}
202