| 76 | |
| 77 | template<OCIO::BitDepth inBD, OCIO::BitDepth outBD> |
| 78 | void testConvert_OutBitDepth() |
| 79 | { |
| 80 | typedef typename OCIO::BitDepthInfo<inBD>::Type InType; |
| 81 | typedef typename OCIO::BitDepthInfo<outBD>::Type OutType; |
| 82 | |
| 83 | size_t maxValue = OCIO::BitDepthInfo<inBD>::maxValue + 1; |
| 84 | |
| 85 | if (OCIO::BitDepthInfo<inBD>::isFloat) |
| 86 | maxValue = 65536; |
| 87 | |
| 88 | std::vector<InType> inImage(maxValue); |
| 89 | std::vector<OutType> outImage(maxValue); |
| 90 | |
| 91 | for (unsigned i = 0; i < maxValue; i++) |
| 92 | { |
| 93 | inImage[i] = scale_unsigned<inBD>(i); |
| 94 | } |
| 95 | |
| 96 | float scale = (float)OCIO::BitDepthInfo<outBD>::maxValue / (float)OCIO::BitDepthInfo<inBD>::maxValue; |
| 97 | __m512 s = _mm512_set1_ps(scale); |
| 98 | |
| 99 | for (unsigned i = 0; i < inImage.size(); i += 64) |
| 100 | { |
| 101 | __m512 r, g, b, a; |
| 102 | OCIO::AVX512RGBAPack<inBD>::Load(&inImage[i], r, g, b, a); |
| 103 | r = _mm512_mul_ps(r, s); |
| 104 | g = _mm512_mul_ps(g, s); |
| 105 | b = _mm512_mul_ps(b, s); |
| 106 | a = _mm512_mul_ps(a, s); |
| 107 | OCIO::AVX512RGBAPack<outBD>::Store(&outImage[i], r, g, b, a); |
| 108 | } |
| 109 | for (unsigned i = 0; i < outImage.size(); i++) |
| 110 | { |
| 111 | float v = (float)inImage[i] * scale; |
| 112 | |
| 113 | if (OCIO::BitDepthInfo<outBD>::isFloat) |
| 114 | v = (OutType)v; // casts to half if format is half |
| 115 | else |
| 116 | v = rintf(v); |
| 117 | |
| 118 | OCIO_CHECK_ASSERT_MESSAGE(!OCIO::FloatsDiffer(v, (float)outImage[i], 0, false), |
| 119 | GetErrorMessage(v, (float)outImage[i], inBD, outBD)); |
| 120 | } |
| 121 | |
| 122 | // Test Load/Store Masked |
| 123 | for (unsigned pixel_count = 0; pixel_count <= 16; pixel_count++) |
| 124 | { |
| 125 | __m512 r, g, b, a; |
| 126 | // reset all values to zero |
| 127 | for (unsigned i = 0; i < outImage.size(); i++) |
| 128 | { |
| 129 | outImage[i] = 0; |
| 130 | } |
| 131 | |
| 132 | OCIO::AVX512RGBAPack<inBD>::LoadMasked(&inImage[0], r, g, b, a, pixel_count); |
| 133 | r = _mm512_mul_ps(r, s); |
| 134 | g = _mm512_mul_ps(g, s); |
| 135 | b = _mm512_mul_ps(b, s); |
nothing calls this directly
no test coverage detected