|
1 | 1 | /*
|
2 |
| - * Copyright (C) 2018-2021 Intel Corporation |
| 2 | + * Copyright (C) 2018-2022 Intel Corporation |
3 | 3 | *
|
4 | 4 | * SPDX-License-Identifier: MIT
|
5 | 5 | *
|
@@ -31,29 +31,30 @@ struct WriteBufferRectHw
|
31 | 31 | }
|
32 | 32 | };
|
33 | 33 |
|
34 |
| -typedef WriteBufferRectHw AUBWriteBufferRect; |
35 |
| -static const size_t width = 10; |
| 34 | +using AUBWriteBufferRect = WriteBufferRectHw; |
36 | 35 |
|
37 | 36 | HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) {
|
| 37 | + |
38 | 38 | MockContext context(this->pClDevice);
|
| 39 | + const size_t width = 10; |
39 | 40 | size_t rowPitch = width;
|
40 | 41 | size_t slicePitch = rowPitch * rowPitch;
|
41 | 42 |
|
42 | 43 | size_t bufferSizeBuff = rowPitch * rowPitch * rowPitch;
|
43 | 44 | size_t bufferSize = alignUp(bufferSizeBuff, 4096);
|
44 | 45 |
|
45 |
| - size_t zHostOffs; |
46 |
| - size_t zBuffOffs; |
47 |
| - std::tie(zBuffOffs, zHostOffs) = GetParam(); |
| 46 | + auto [zBuffOffs, zHostOffs] = GetParam(); |
48 | 47 |
|
49 | 48 | ASSERT_LT(zBuffOffs, width);
|
50 | 49 | ASSERT_LT(zHostOffs, width);
|
51 | 50 |
|
52 |
| - uint8_t *srcMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096); |
53 |
| - uint8_t *destMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096); |
| 51 | + auto srcMemory = static_cast<uint8_t *>(::alignedMalloc(bufferSize, 4096)); |
| 52 | + auto destMemory = static_cast<uint8_t *>(::alignedMalloc(bufferSize, 4096)); |
54 | 53 |
|
55 |
| - for (unsigned int i = 0; i < bufferSize; i++) |
56 |
| - srcMemory[i] = i; |
| 54 | + for (unsigned int i = 0; i < bufferSize; i++) { |
| 55 | + auto oneBytePattern = static_cast<uint8_t>(i & 0xff); |
| 56 | + srcMemory[i] = oneBytePattern; |
| 57 | + } |
57 | 58 |
|
58 | 59 | memset(destMemory, 0x00, bufferSize);
|
59 | 60 |
|
@@ -91,26 +92,24 @@ HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) {
|
91 | 92 |
|
92 | 93 | EXPECT_EQ(CL_SUCCESS, retVal);
|
93 | 94 |
|
94 |
| - char *ptr = new char[slicePitch]; |
95 |
| - memset(ptr, 0, slicePitch); |
| 95 | + std::vector<uint8_t> ptr(slicePitch, 0); |
96 | 96 | for (unsigned int i = 0; i < rowPitch; i++) {
|
97 |
| - //one slice will be copied from src. all others should be zeros |
| 97 | + // one slice will be copied from src. all others should be zeros |
98 | 98 | if (i == zBuffOffs) {
|
99 | 99 | AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, srcMemory + slicePitch * zHostOffs, slicePitch);
|
100 | 100 | } else {
|
101 |
| - AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, ptr, slicePitch); |
| 101 | + AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, ptr.data(), slicePitch); |
102 | 102 | }
|
103 | 103 | }
|
104 |
| - delete[] ptr; |
105 | 104 |
|
106 | 105 | ::alignedFree(srcMemory);
|
107 | 106 | ::alignedFree(destMemory);
|
108 | 107 | }
|
109 | 108 | INSTANTIATE_TEST_CASE_P(AUBWriteBufferRect_simple,
|
110 | 109 | AUBWriteBufferRect,
|
111 | 110 | ::testing::Combine(
|
112 |
| - ::testing::Values(0, 1, 2, 3, 4), |
113 |
| - ::testing::Values(0, 1, 2, 3, 4))); |
| 111 | + ::testing::Values(0u, 1u, 2u, 3u, 4u), |
| 112 | + ::testing::Values(0u, 1u, 2u, 3u, 4u))); |
114 | 113 |
|
115 | 114 | struct AUBWriteBufferRectUnaligned
|
116 | 115 | : public CommandEnqueueAUBFixture,
|
|
0 commit comments