Skip to content

Commit a2265a6

Browse files
[SYCL][Bindless] Fix Mipmap Tests (#10713)
# Fix Mipmap Tests Fixing the computation of expected output values so that the tests also work with input sizes that are not powers of 2. --------- Co-authored-by: Dmitry Vodopyanov <[email protected]>
1 parent 4b44182 commit a2265a6

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

sycl/test-e2e/bindless_images/mipmap/mipmap_read_1D.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,25 @@ int main() {
1919
auto ctxt = q.get_context();
2020

2121
// declare image data
22-
constexpr size_t N = 16;
22+
constexpr size_t N = 15;
2323
std::vector<float> out(N);
2424
std::vector<float> expected(N);
2525
std::vector<sycl::float4> dataIn1(N);
2626
std::vector<sycl::float4> dataIn2(N / 2);
2727
std::vector<sycl::float4> copyOut(N / 2);
28-
int j = 0;
28+
2929
for (int i = 0; i < N; i++) {
30-
expected[i] = i + (j + 10);
31-
if (i % 2)
32-
j++;
30+
// Populate input data (to-be mipmap image layers)
3331
dataIn1[i] = sycl::float4(i, i, i, i);
3432
if (i < (N / 2)) {
3533
dataIn2[i] = sycl::float4(i + 10, i + 10, i + 10, i + 10);
3634
copyOut[i] = sycl::float4{0, 0, 0, 0};
3735
}
36+
37+
// Calculate expected output data
38+
float norm_coord = ((i + 0.5f) / (float)N);
39+
int x = norm_coord * (N >> 1);
40+
expected[i] = dataIn1[i][0] + dataIn2[x][0];
3841
}
3942

4043
try {
@@ -85,8 +88,8 @@ int main() {
8588
// Extension: read mipmap level 0 with anisotropic filtering and level 1
8689
// with LOD
8790
sycl::float4 px1 =
88-
sycl::ext::oneapi::experimental::read_image<sycl::float4>(
89-
mipHandle, x, 0.0f, 0.0f);
91+
sycl::ext::oneapi::experimental::read_image<sycl::float4>(mipHandle,
92+
x, 0.0f);
9093
sycl::float4 px2 =
9194
sycl::ext::oneapi::experimental::read_image<sycl::float4>(mipHandle,
9295
x, 1.0f);

sycl/test-e2e/bindless_images/mipmap/mipmap_read_2D.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ int main() {
4040
}
4141
// Expected each x and y will repeat twice
4242
// since mipmap level 1 is half in size
43-
int jj = 0;
44-
for (int i = 0; i < width - 1; i += 2) {
45-
for (int j = 0; j < height - 1; j += 2, jj++) {
46-
expected[j + (width * i)] = jj;
47-
expected[j + (width * (i + 1))] = jj;
48-
expected[(j + 1) + (width * i)] = jj;
49-
expected[(j + 1) + (width * (i + 1))] = jj;
43+
for (int i = 0; i < width; i++) {
44+
for (int j = 0; j < height; j++) {
45+
float norm_coord_x = ((i + 0.5f) / (float)width);
46+
int x = norm_coord_x * (width >> 1);
47+
float norm_coord_y = ((j + 0.5f) / (float)height);
48+
int y = norm_coord_y * (height >> 1);
49+
expected[j + (width * i)] = dataIn2[y + (width / 2 * x)][0];
5050
}
5151
}
5252

sycl/test-e2e/bindless_images/mipmap/mipmap_read_3D.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ int main() {
1919
auto ctxt = q.get_context();
2020

2121
// declare image data
22-
size_t width = 4;
23-
size_t height = 4;
24-
size_t depth = 4;
22+
size_t width = 5;
23+
size_t height = 5;
24+
size_t depth = 5;
2525
size_t N = width * height * depth;
2626
std::vector<float> out(N);
2727
std::vector<float> expected(N);

0 commit comments

Comments
 (0)