// // Copyright 2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint8_t *source =
priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest = priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch,
outputDepthPitch);
size_t x = 0;
// Make output writes aligned for (; ((reinterpret_cast<intptr_t>(&dest[x]) & 0xF) != 0 && x < width); x++)
{
dest[x] = static_cast<uint32_t>(source[x]) << 24;
}
for (; x + 7 < width; x += 8)
{
__m128i sourceData =
_mm_loadl_epi64(reinterpret_cast<const __m128i *>(&source[x])); // Interleave each byte to 16bit, make the lower byte to zero
sourceData = _mm_unpacklo_epi8(zeroWide, sourceData); // Interleave each 16bit to 32bit, make the lower 16bit to zero
__m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData);
__m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData);
void LoadLA32FToRGBA32F(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ constfloat *source =
priv::OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch); float *dest =
priv::OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[2 * x + 0];
dest[4 * x + 1] = source[2 * x + 0];
dest[4 * x + 2] = source[2 * x + 0];
dest[4 * x + 3] = source[2 * x + 1];
}
}
}
}
void LoadLA16FToRGBA16F(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint16_t *source =
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest =
priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[2 * x + 0];
dest[4 * x + 1] = source[2 * x + 0];
dest[4 * x + 2] = source[2 * x + 0];
dest[4 * x + 3] = source[2 * x + 1];
}
}
}
}
void LoadRGB8ToBGR565(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint8_t *source =
priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest =
priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
uint8_t r8 = source[x * 3 + 0];
uint8_t g8 = source[x * 3 + 1];
uint8_t b8 = source[x * 3 + 2]; auto r5 = static_cast<uint16_t>(r8 >> 3); auto g6 = static_cast<uint16_t>(g8 >> 2); auto b5 = static_cast<uint16_t>(b8 >> 3);
dest[x] = (r5 << 11) | (g6 << 5) | b5;
}
}
}
}
void LoadRGB565ToBGR565(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint16_t *source =
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest =
priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{ // The GL type RGB is packed with with red in the MSB, while the D3D11 type BGR // is packed with red in the LSB auto rgb = source[x];
uint16_t r5 = gl::getShiftedData<5, 11>(rgb);
uint16_t g6 = gl::getShiftedData<6, 5>(rgb);
uint16_t b5 = gl::getShiftedData<5, 0>(rgb);
dest[x] = (r5 << 11) | (g6 << 5) | b5;
}
}
}
}
void LoadRGB8ToBGRX8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint8_t *source =
priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest =
priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x * 3 + 2];
dest[4 * x + 1] = source[x * 3 + 1];
dest[4 * x + 2] = source[x * 3 + 0];
dest[4 * x + 3] = 0xFF;
}
}
}
}
void LoadRG8ToBGRX8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint8_t *source =
priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest =
priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = 0x00;
dest[4 * x + 1] = source[x * 2 + 1];
dest[4 * x + 2] = source[x * 2 + 0];
dest[4 * x + 3] = 0xFF;
}
}
}
}
void LoadR8ToBGRX8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint8_t *source =
priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest =
priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = 0x00;
dest[4 * x + 1] = 0x00;
dest[4 * x + 2] = source[x];
dest[4 * x + 3] = 0xFF;
}
}
}
}
void LoadR5G6B5ToBGRA8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint16_t *source =
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest =
priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
uint16_t rgb = source[x];
dest[4 * x + 0] = static_cast<uint8_t>(((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2));
dest[4 * x + 1] = static_cast<uint8_t>(((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9));
dest[4 * x + 2] = static_cast<uint8_t>(((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13));
dest[4 * x + 3] = 0xFF;
}
}
}
}
void LoadR5G6B5ToRGBA8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint16_t *source =
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest =
priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
uint16_t rgb = source[x];
dest[4 * x + 0] = static_cast<uint8_t>(((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13));
dest[4 * x + 1] = static_cast<uint8_t>(((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9));
dest[4 * x + 2] = static_cast<uint8_t>(((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2));
dest[4 * x + 3] = 0xFF;
}
}
}
}
for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint32_t *source =
priv::OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest = priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch,
outputDepthPitch);
for (; x + 3 < width; x += 4)
{
__m128i sourceData =
_mm_loadu_si128(reinterpret_cast<const __m128i *>(&source[x])); // Mask out g and a, which don't change
__m128i gaComponents = _mm_andnot_si128(brMask, sourceData); // Mask out b and r
__m128i brComponents = _mm_and_si128(sourceData, brMask); // Swap b and r
__m128i brSwapped = _mm_shufflehi_epi16(
_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)),
_MM_SHUFFLE(2, 3, 0, 1));
__m128i result = _mm_or_si128(gaComponents, brSwapped);
_mm_store_si128(reinterpret_cast<__m128i *>(&dest[x]), result);
}
void LoadRGB32FToRGB16F(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ constfloat *source =
priv::OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest =
priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[x * 3 + 0] = gl::float32ToFloat16(source[x * 3 + 0]);
dest[x * 3 + 1] = gl::float32ToFloat16(source[x * 3 + 1]);
dest[x * 3 + 2] = gl::float32ToFloat16(source[x * 3 + 2]);
}
}
}
}
void LoadR32ToR16(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint32_t *source =
priv::OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest =
priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[x] = source[x] >> 16;
}
}
}
}
void LoadR32ToR24G8(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint32_t *source =
priv::OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest =
priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++)
{
dest[x] = source[x] >> 8;
}
}
}
}
// This conversion was added to support using a 32F depth buffer // as emulation for 16unorm depth buffer in Metal. // See angleproject:6597 void LoadUNorm16To32F(size_t width,
size_t height,
size_t depth, const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ for (size_t z = 0; z < depth; z++)
{ for (size_t y = 0; y < height; y++)
{ const uint16_t *source =
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch); float *dest =
priv::OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch); for (size_t x = 0; x < width; x++)
{
dest[x] = static_cast<float>(source[x]) / 0xFFFF;
}
}
}
}
// This conversion was added to support using a 32F depth buffer // as emulation for 16unorm depth buffer in Metal. In OpenGL ES 3.0 // you're allowed to pass UNSIGNED_INT as input to texImage2D and // so this conversion is neccasary. // // See angleproject:6597
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.