1428d7b3dSmrg/*
2428d7b3dSmrg * Copyright (c) 2011 Intel Corporation
3428d7b3dSmrg *
4428d7b3dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5428d7b3dSmrg * copy of this software and associated documentation files (the "Software"),
6428d7b3dSmrg * to deal in the Software without restriction, including without limitation
7428d7b3dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8428d7b3dSmrg * and/or sell copies of the Software, and to permit persons to whom the
9428d7b3dSmrg * Software is furnished to do so, subject to the following conditions:
10428d7b3dSmrg *
11428d7b3dSmrg * The above copyright notice and this permission notice (including the next
12428d7b3dSmrg * paragraph) shall be included in all copies or substantial portions of the
13428d7b3dSmrg * Software.
14428d7b3dSmrg *
15428d7b3dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16428d7b3dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17428d7b3dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18428d7b3dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19428d7b3dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20428d7b3dSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21428d7b3dSmrg * SOFTWARE.
22428d7b3dSmrg *
23428d7b3dSmrg * Authors:
24428d7b3dSmrg *    Chris Wilson <chris@chris-wilson.co.uk>
25428d7b3dSmrg *
26428d7b3dSmrg */
27428d7b3dSmrg
28428d7b3dSmrg#include "brw_test.h"
29428d7b3dSmrg
30428d7b3dSmrg#include <string.h>
31428d7b3dSmrg
32428d7b3dSmrgstatic const uint32_t sf_kernel[][4] = {
33428d7b3dSmrg#include "exa_sf.g5b"
34428d7b3dSmrg};
35428d7b3dSmrg
36428d7b3dSmrgstatic const uint32_t sf_kernel_mask[][4] = {
37428d7b3dSmrg#include "exa_sf_mask.g5b"
38428d7b3dSmrg};
39428d7b3dSmrg
40428d7b3dSmrgstatic const uint32_t ps_kernel_nomask_affine[][4] = {
41428d7b3dSmrg#include "exa_wm_xy.g5b"
42428d7b3dSmrg#include "exa_wm_src_affine.g5b"
43428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
44428d7b3dSmrg#include "exa_wm_write.g5b"
45428d7b3dSmrg};
46428d7b3dSmrg
47428d7b3dSmrgstatic const uint32_t ps_kernel_nomask_projective[][4] = {
48428d7b3dSmrg#include "exa_wm_xy.g5b"
49428d7b3dSmrg#include "exa_wm_src_projective.g5b"
50428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
51428d7b3dSmrg#include "exa_wm_write.g5b"
52428d7b3dSmrg};
53428d7b3dSmrg
54428d7b3dSmrgstatic const uint32_t ps_kernel_maskca_affine[][4] = {
55428d7b3dSmrg#include "exa_wm_xy.g5b"
56428d7b3dSmrg#include "exa_wm_src_affine.g5b"
57428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
58428d7b3dSmrg#include "exa_wm_mask_affine.g5b"
59428d7b3dSmrg#include "exa_wm_mask_sample_argb.g5b"
60428d7b3dSmrg#include "exa_wm_ca.g5b"
61428d7b3dSmrg#include "exa_wm_write.g5b"
62428d7b3dSmrg};
63428d7b3dSmrg
64428d7b3dSmrgstatic const uint32_t ps_kernel_maskca_projective[][4] = {
65428d7b3dSmrg#include "exa_wm_xy.g5b"
66428d7b3dSmrg#include "exa_wm_src_projective.g5b"
67428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
68428d7b3dSmrg#include "exa_wm_mask_projective.g5b"
69428d7b3dSmrg#include "exa_wm_mask_sample_argb.g5b"
70428d7b3dSmrg#include "exa_wm_ca.g5b"
71428d7b3dSmrg#include "exa_wm_write.g5b"
72428d7b3dSmrg};
73428d7b3dSmrg
74428d7b3dSmrgstatic const uint32_t ps_kernel_maskca_srcalpha_affine[][4] = {
75428d7b3dSmrg#include "exa_wm_xy.g5b"
76428d7b3dSmrg#include "exa_wm_src_affine.g5b"
77428d7b3dSmrg#include "exa_wm_src_sample_a.g5b"
78428d7b3dSmrg#include "exa_wm_mask_affine.g5b"
79428d7b3dSmrg#include "exa_wm_mask_sample_argb.g5b"
80428d7b3dSmrg#include "exa_wm_ca_srcalpha.g5b"
81428d7b3dSmrg#include "exa_wm_write.g5b"
82428d7b3dSmrg};
83428d7b3dSmrg
84428d7b3dSmrgstatic const uint32_t ps_kernel_maskca_srcalpha_projective[][4] = {
85428d7b3dSmrg#include "exa_wm_xy.g5b"
86428d7b3dSmrg#include "exa_wm_src_projective.g5b"
87428d7b3dSmrg#include "exa_wm_src_sample_a.g5b"
88428d7b3dSmrg#include "exa_wm_mask_projective.g5b"
89428d7b3dSmrg#include "exa_wm_mask_sample_argb.g5b"
90428d7b3dSmrg#include "exa_wm_ca_srcalpha.g5b"
91428d7b3dSmrg#include "exa_wm_write.g5b"
92428d7b3dSmrg};
93428d7b3dSmrg
94428d7b3dSmrgstatic const uint32_t ps_kernel_masknoca_affine[][4] = {
95428d7b3dSmrg#include "exa_wm_xy.g5b"
96428d7b3dSmrg#include "exa_wm_src_affine.g5b"
97428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
98428d7b3dSmrg#include "exa_wm_mask_affine.g5b"
99428d7b3dSmrg#include "exa_wm_mask_sample_a.g5b"
100428d7b3dSmrg#include "exa_wm_noca.g5b"
101428d7b3dSmrg#include "exa_wm_write.g5b"
102428d7b3dSmrg};
103428d7b3dSmrg
104428d7b3dSmrgstatic const uint32_t ps_kernel_masknoca_projective[][4] = {
105428d7b3dSmrg#include "exa_wm_xy.g5b"
106428d7b3dSmrg#include "exa_wm_src_projective.g5b"
107428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
108428d7b3dSmrg#include "exa_wm_mask_projective.g5b"
109428d7b3dSmrg#include "exa_wm_mask_sample_a.g5b"
110428d7b3dSmrg#include "exa_wm_noca.g5b"
111428d7b3dSmrg#include "exa_wm_write.g5b"
112428d7b3dSmrg};
113428d7b3dSmrg
114428d7b3dSmrgstatic const uint32_t ps_kernel_packed_static[][4] = {
115428d7b3dSmrg#include "exa_wm_xy.g5b"
116428d7b3dSmrg#include "exa_wm_src_affine.g5b"
117428d7b3dSmrg#include "exa_wm_src_sample_argb.g5b"
118428d7b3dSmrg#include "exa_wm_yuv_rgb.g5b"
119428d7b3dSmrg#include "exa_wm_write.g5b"
120428d7b3dSmrg};
121428d7b3dSmrg
122428d7b3dSmrgstatic const uint32_t ps_kernel_planar_static[][4] = {
123428d7b3dSmrg#include "exa_wm_xy.g5b"
124428d7b3dSmrg#include "exa_wm_src_affine.g5b"
125428d7b3dSmrg#include "exa_wm_src_sample_planar.g5b"
126428d7b3dSmrg#include "exa_wm_yuv_rgb.g5b"
127428d7b3dSmrg#include "exa_wm_write.g5b"
128428d7b3dSmrg};
129428d7b3dSmrg
130428d7b3dSmrg#define compare(old) brw_test_compare(__FUNCTION__, p.gen, p.store, p.nr_insn, (struct brw_instruction *)old, ARRAY_SIZE(old))
131428d7b3dSmrg
132428d7b3dSmrg#define GEN 050
133428d7b3dSmrg
134428d7b3dSmrgstatic void gen5_sf(void)
135428d7b3dSmrg{
136428d7b3dSmrg	uint32_t store[128];
137428d7b3dSmrg	struct brw_compile p;
138428d7b3dSmrg
139428d7b3dSmrg	brw_compile_init(&p, GEN, store);
140428d7b3dSmrg	brw_sf_kernel__nomask(&p);
141428d7b3dSmrg
142428d7b3dSmrg	compare(sf_kernel);
143428d7b3dSmrg}
144428d7b3dSmrg
145428d7b3dSmrgstatic void gen5_sf_mask(void)
146428d7b3dSmrg{
147428d7b3dSmrg	uint32_t store[128];
148428d7b3dSmrg	struct brw_compile p;
149428d7b3dSmrg
150428d7b3dSmrg	brw_compile_init(&p, GEN, store);
151428d7b3dSmrg	brw_sf_kernel__mask(&p);
152428d7b3dSmrg
153428d7b3dSmrg	compare(sf_kernel_mask);
154428d7b3dSmrg}
155428d7b3dSmrg
156428d7b3dSmrgstatic void gen5_wm_affine_nomask(void)
157428d7b3dSmrg{
158428d7b3dSmrg	uint32_t store[128];
159428d7b3dSmrg	struct brw_compile p;
160428d7b3dSmrg
161428d7b3dSmrg	brw_compile_init(&p, GEN, store);
162428d7b3dSmrg	brw_wm_kernel__affine(&p, 16);
163428d7b3dSmrg
164428d7b3dSmrg	compare(ps_kernel_nomask_affine);
165428d7b3dSmrg}
166428d7b3dSmrg
167428d7b3dSmrgstatic void gen5_wm_affine_mask_noca(void)
168428d7b3dSmrg{
169428d7b3dSmrg	uint32_t store[128];
170428d7b3dSmrg	struct brw_compile p;
171428d7b3dSmrg
172428d7b3dSmrg	brw_compile_init(&p, GEN, store);
173428d7b3dSmrg	brw_wm_kernel__affine_mask(&p, 16);
174428d7b3dSmrg
175428d7b3dSmrg	compare(ps_kernel_masknoca_affine);
176428d7b3dSmrg}
177428d7b3dSmrg
178428d7b3dSmrgstatic void gen5_wm_affine_mask_ca(void)
179428d7b3dSmrg{
180428d7b3dSmrg	uint32_t store[128];
181428d7b3dSmrg	struct brw_compile p;
182428d7b3dSmrg
183428d7b3dSmrg	brw_compile_init(&p, GEN, store);
184428d7b3dSmrg	brw_wm_kernel__affine_mask_ca(&p, 16);
185428d7b3dSmrg
186428d7b3dSmrg	compare(ps_kernel_maskca_affine);
187428d7b3dSmrg}
188428d7b3dSmrg
189428d7b3dSmrgstatic void gen5_wm_projective_nomask(void)
190428d7b3dSmrg{
191428d7b3dSmrg	uint32_t store[128];
192428d7b3dSmrg	struct brw_compile p;
193428d7b3dSmrg
194428d7b3dSmrg	brw_compile_init(&p, GEN, store);
195428d7b3dSmrg	brw_wm_kernel__projective(&p, 16);
196428d7b3dSmrg
197428d7b3dSmrg	compare(ps_kernel_nomask_projective);
198428d7b3dSmrg}
199428d7b3dSmrg
200428d7b3dSmrgvoid brw_test_gen5(void)
201428d7b3dSmrg{
202428d7b3dSmrg	gen5_sf();
203428d7b3dSmrg	gen5_sf_mask();
204428d7b3dSmrg
205428d7b3dSmrg	gen5_wm_affine_nomask();
206428d7b3dSmrg	gen5_wm_affine_mask_noca();
207428d7b3dSmrg	gen5_wm_affine_mask_ca();
208428d7b3dSmrg
209428d7b3dSmrg	gen5_wm_projective_nomask();
210428d7b3dSmrg}
211