2 * Copyright 2015 Intel Corporation
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:
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
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
21 * DEALINGS IN THE SOFTWARE.
29 #include "brw_device_info.h"
32 #define BDW_GT2_DEVID 0x161a
34 // An asssert that works regardless of NDEBUG.
35 #define t_assert(cond) \
38 fprintf(stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
44 t_assert_extent4d(const struct isl_extent4d
*e
, uint32_t width
,
45 uint32_t height
, uint32_t depth
, uint32_t array_len
)
47 t_assert(e
->width
== width
);
48 t_assert(e
->height
== height
);
49 t_assert(e
->depth
== depth
);
50 t_assert(e
->array_len
== array_len
);
54 t_assert_image_alignment_el(const struct isl_surf
*surf
,
55 uint32_t w
, uint32_t h
, uint32_t d
)
57 struct isl_extent3d align_el
;
59 align_el
= isl_surf_get_image_alignment_el(surf
);
60 t_assert(align_el
.w
== w
);
61 t_assert(align_el
.h
== h
);
62 t_assert(align_el
.d
== d
);
67 t_assert_image_alignment_sa(const struct isl_surf
*surf
,
68 uint32_t w
, uint32_t h
, uint32_t d
)
70 struct isl_extent3d align_sa
;
72 align_sa
= isl_surf_get_image_alignment_sa(surf
);
73 t_assert(align_sa
.w
== w
);
74 t_assert(align_sa
.h
== h
);
75 t_assert(align_sa
.d
== d
);
80 t_assert_offset(const struct isl_surf
*surf
,
82 uint32_t logical_array_layer
,
83 uint32_t logical_z_offset_px
,
84 uint32_t expected_x_offset_sa
,
85 uint32_t expected_y_offset_sa
)
88 isl_surf_get_image_offset_sa(surf
, level
, logical_array_layer
,
89 logical_z_offset_px
, &x
, &y
);
91 t_assert(x
== expected_x_offset_sa
);
92 t_assert(y
== expected_y_offset_sa
);
96 t_assert_phys_level0_sa(const struct isl_surf
*surf
, uint32_t width
,
97 uint32_t height
, uint32_t depth
, uint32_t array_len
)
99 t_assert_extent4d(&surf
->phys_level0_sa
, width
, height
, depth
, array_len
);
103 test_bdw_2d_r8g8b8a8_unorm_512x512_a1_s1_noaux_y0(void)
107 struct isl_device dev
;
108 isl_device_init(&dev
, brw_get_device_info(BDW_GT2_DEVID
),
109 /*bit6_swizzle*/ false);
111 struct isl_surf surf
;
112 ok
= isl_surf_init(&dev
, &surf
,
113 .dim
= ISL_SURF_DIM_2D
,
114 .format
= ISL_FORMAT_R8G8B8A8_UNORM
,
121 .usage
= ISL_SURF_USAGE_TEXTURE_BIT
|
122 ISL_SURF_USAGE_DISABLE_AUX_BIT
,
123 .tiling_flags
= ISL_TILING_Y0_BIT
);
126 t_assert_image_alignment_el(&surf
, 4, 4, 1);
127 t_assert_image_alignment_sa(&surf
, 4, 4, 1);
128 t_assert_phys_level0_sa(&surf
, 512, 512, 1, 1);
129 t_assert(isl_surf_get_array_pitch_el_rows(&surf
) >= 772);
130 t_assert(isl_surf_get_array_pitch_sa_rows(&surf
) >= 772);
132 t_assert_offset(&surf
, 0, 0, 0, 0, 0); // +0, +0
133 t_assert_offset(&surf
, 1, 0, 0, 0, 512); // +0, +512
134 t_assert_offset(&surf
, 2, 0, 0, 256, 512); // +256, +0
135 t_assert_offset(&surf
, 3, 0, 0, 256, 640); // +0, +128
136 t_assert_offset(&surf
, 4, 0, 0, 256, 704); // +0, +64
137 t_assert_offset(&surf
, 5, 0, 0, 256, 736); // +0, +32
138 t_assert_offset(&surf
, 6, 0, 0, 256, 752); // +0, +16
139 t_assert_offset(&surf
, 7, 0, 0, 256, 760); // +0, +8
140 t_assert_offset(&surf
, 8, 0, 0, 256, 764); // +0, +4
141 t_assert_offset(&surf
, 9, 0, 0, 256, 768); // +0, +4
145 test_bdw_2d_r8g8b8a8_unorm_1024x1024_a6_s1_noaux_y0(void)
149 struct isl_device dev
;
150 isl_device_init(&dev
, brw_get_device_info(BDW_GT2_DEVID
),
151 /*bit6_swizzle*/ false);
153 struct isl_surf surf
;
154 ok
= isl_surf_init(&dev
, &surf
,
155 .dim
= ISL_SURF_DIM_2D
,
156 .format
= ISL_FORMAT_R8G8B8A8_UNORM
,
163 .usage
= ISL_SURF_USAGE_TEXTURE_BIT
|
164 ISL_SURF_USAGE_DISABLE_AUX_BIT
,
165 .tiling_flags
= ISL_TILING_Y0_BIT
);
168 t_assert_image_alignment_el(&surf
, 4, 4, 1);
169 t_assert_image_alignment_sa(&surf
, 4, 4, 1);
170 t_assert_image_alignment_sa(&surf
, 4, 4, 1);
171 t_assert(isl_surf_get_array_pitch_el_rows(&surf
) >= 1540);
172 t_assert(isl_surf_get_array_pitch_sa_rows(&surf
) >= 1540);
174 for (uint32_t a
= 0; a
< 6; ++a
) {
175 uint32_t b
= a
* isl_surf_get_array_pitch_sa_rows(&surf
);
177 t_assert_offset(&surf
, 0, a
, 0, 0, b
+ 0); // +0, +0
178 t_assert_offset(&surf
, 1, a
, 0, 0, b
+ 1024); // +0, +1024
179 t_assert_offset(&surf
, 2, a
, 0, 512, b
+ 1024); // +512, +0
180 t_assert_offset(&surf
, 3, a
, 0, 512, b
+ 1280); // +0, +256
181 t_assert_offset(&surf
, 4, a
, 0, 512, b
+ 1408); // +0, +128
182 t_assert_offset(&surf
, 5, a
, 0, 512, b
+ 1472); // +0, +64
183 t_assert_offset(&surf
, 6, a
, 0, 512, b
+ 1504); // +0, +32
184 t_assert_offset(&surf
, 7, a
, 0, 512, b
+ 1520); // +0, +16
185 t_assert_offset(&surf
, 8, a
, 0, 512, b
+ 1528); // +0, +8
186 t_assert_offset(&surf
, 9, a
, 0, 512, b
+ 1532); // +0, +4
187 t_assert_offset(&surf
, 10, a
, 0, 512, b
+ 1536); // +0, +4
193 /* FINISHME: Add tests for npot sizes */
194 /* FINISHME: Add tests for 1D surfaces */
195 /* FINISHME: Add tests for 3D surfaces */
197 test_bdw_2d_r8g8b8a8_unorm_512x512_a1_s1_noaux_y0();
198 test_bdw_2d_r8g8b8a8_unorm_1024x1024_a6_s1_noaux_y0();