D3D9: Implement float sources for Image9::copyFromRTInternal

Bug: angleproject:5038
Bug: angleproject:6257
Change-Id: I4f21fb1e37a985e2179d9c06101fa5bd2fedb100
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3738143
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
This commit is contained in:
Alexey Knyazev 2022-05-02 00:00:00 +00:00 коммит произвёл Angle LUCI CQ
Родитель 925ec6b5ac
Коммит 9931dfd51e
1 изменённых файлов: 113 добавлений и 0 удалений

Просмотреть файл

@ -755,6 +755,119 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
UNREACHABLE();
}
break;
case D3DFMT_A16B16G16R16F:
switch (getD3DFormat())
{
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
{
const uint16_t *sourcePixels16F =
reinterpret_cast<uint16_t *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = gl::float16ToFloat32(sourcePixels16F[x * 4 + 0]);
float g = gl::float16ToFloat32(sourcePixels16F[x * 4 + 1]);
float b = gl::float16ToFloat32(sourcePixels16F[x * 4 + 2]);
float a = gl::float16ToFloat32(sourcePixels16F[x * 4 + 3]);
destPixels[x * 4 + 0] = gl::floatToNormalized<uint8_t>(b);
destPixels[x * 4 + 1] = gl::floatToNormalized<uint8_t>(g);
destPixels[x * 4 + 2] = gl::floatToNormalized<uint8_t>(r);
destPixels[x * 4 + 3] = gl::floatToNormalized<uint8_t>(a);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
const uint16_t *sourcePixels16F =
reinterpret_cast<uint16_t *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = gl::float16ToFloat32(sourcePixels16F[x * 4]);
destPixels[x] = gl::floatToNormalized<uint8_t>(r);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
const uint16_t *sourcePixels16F =
reinterpret_cast<uint16_t *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = gl::float16ToFloat32(sourcePixels16F[x * 4 + 0]);
float a = gl::float16ToFloat32(sourcePixels16F[x * 4 + 3]);
destPixels[x * 2 + 0] = gl::floatToNormalized<uint8_t>(r);
destPixels[x * 2 + 1] = gl::floatToNormalized<uint8_t>(a);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
case D3DFMT_A32B32G32R32F:
switch (getD3DFormat())
{
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
{
const float *sourcePixels32F = reinterpret_cast<float *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = sourcePixels32F[x * 4 + 0];
float g = sourcePixels32F[x * 4 + 1];
float b = sourcePixels32F[x * 4 + 2];
float a = sourcePixels32F[x * 4 + 3];
destPixels[x * 4 + 0] = gl::floatToNormalized<uint8_t>(b);
destPixels[x * 4 + 1] = gl::floatToNormalized<uint8_t>(g);
destPixels[x * 4 + 2] = gl::floatToNormalized<uint8_t>(r);
destPixels[x * 4 + 3] = gl::floatToNormalized<uint8_t>(a);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
const float *sourcePixels32F = reinterpret_cast<float *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = sourcePixels32F[x * 4];
destPixels[x] = gl::floatToNormalized<uint8_t>(r);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
const float *sourcePixels32F = reinterpret_cast<float *>(sourcePixels);
for (int x = 0; x < width; x++)
{
float r = sourcePixels32F[x * 4 + 0];
float a = sourcePixels32F[x * 4 + 3];
destPixels[x * 2 + 0] = gl::floatToNormalized<uint8_t>(r);
destPixels[x * 2 + 1] = gl::floatToNormalized<uint8_t>(a);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
default:
UNREACHABLE();
}