|
7 | 7 | // Uncomment to print additional test information |
8 | 8 | // #define VERBOSE_PRINT |
9 | 9 |
|
| 10 | +#ifdef _WIN32 |
| 11 | +#define NOMINMAX |
| 12 | +#endif |
| 13 | + |
10 | 14 | #include "../helpers/common.hpp" |
11 | 15 | #include "vulkan_common.hpp" |
12 | 16 |
|
@@ -176,11 +180,17 @@ bool run_sycl(InteropHandleT inputInteropMemHandle, |
176 | 180 |
|
177 | 181 | printString("Validating\n"); |
178 | 182 | bool validated = true; |
| 183 | + auto getExpectedValue = [&](int i) -> OutType { |
| 184 | + if (CType == sycl::image_channel_type::unorm_int8) |
| 185 | + return 0.5f; |
| 186 | + if constexpr (std::is_integral_v<OutType>) |
| 187 | + i = i % std::numeric_limits<OutType>::max(); |
| 188 | + return i / 2.f; |
| 189 | + }; |
179 | 190 | for (int i = 0; i < globalSize.size(); i++) { |
180 | 191 | bool mismatch = false; |
181 | 192 | VecType expected = |
182 | | - bindless_helpers::init_vector<OutType, NChannels>(static_cast<OutType>( |
183 | | - CType == sycl::image_channel_type::unorm_int8 ? 0.5f : (i / 2.f))); |
| 193 | + bindless_helpers::init_vector<OutType, NChannels>(getExpectedValue(i)); |
184 | 194 | if (!bindless_helpers::equal_vec<OutType, NChannels>(out[i], expected)) { |
185 | 195 | mismatch = true; |
186 | 196 | validated = false; |
@@ -269,10 +279,16 @@ bool run_test(sycl::range<NDims> dims, sycl::range<NDims> localSize, |
269 | 279 | VK_CHECK_CALL(vkMapMemory(vk_device, inputStagingMemory, 0 /*offset*/, |
270 | 280 | imageSizeBytes, 0 /*flags*/, |
271 | 281 | (void **)&inputStagingData)); |
| 282 | + auto getInputValue = [&](int i) -> DType { |
| 283 | + if (CType == sycl::image_channel_type::unorm_int8) |
| 284 | + return 255; |
| 285 | + if constexpr (std::is_integral_v<DType>) |
| 286 | + i = i % std::numeric_limits<DType>::max(); |
| 287 | + return i; |
| 288 | + }; |
272 | 289 | for (int i = 0; i < numElems; ++i) { |
273 | 290 | inputStagingData[i] = |
274 | | - bindless_helpers::init_vector<DType, NChannels>(static_cast<DType>( |
275 | | - CType == sycl::image_channel_type::unorm_int8 ? 255 : i)); |
| 291 | + bindless_helpers::init_vector<DType, NChannels>(getInputValue(i)); |
276 | 292 | } |
277 | 293 | vkUnmapMemory(vk_device, inputStagingMemory); |
278 | 294 |
|
|
0 commit comments