mirror of
https://github.com/xemu-project/nxdk_pgraph_tests.git
synced 2024-11-23 10:09:40 +00:00
Adds tests for Y16 formats.
This commit is contained in:
parent
c8cbe89b08
commit
59028a1c30
@ -33,6 +33,10 @@ constexpr TextureFormatInfo kTextureFormats[] = {
|
||||
{SDL_PIXELFORMAT_RGBA8888, NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_G8B8, 16, false, true, true, "G8B8"},
|
||||
// {SDL_PIXELFORMAT_RGBA8888, NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_R8B8, 16, false, true, true, "R8B8"},
|
||||
|
||||
{SDL_PIXELFORMAT_RGBA8888, NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_Y16_FIXED, 16, false, true, true,
|
||||
"D_Y16_FIXED"},
|
||||
{SDL_PIXELFORMAT_RGBA8888, NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_Y16, 16, false, true, true, "Y16"},
|
||||
|
||||
// yuv color space
|
||||
// Each 4 bytes represent the color for 2 neighboring pixels:
|
||||
// [ U0 | Y0 | V0 | Y1 ]
|
||||
|
@ -229,6 +229,22 @@ int TextureStage::SetTexture(const SDL_Surface *surface, uint8_t *memory_base) c
|
||||
}
|
||||
} break;
|
||||
|
||||
case NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_Y16:
|
||||
case NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_Y16_FIXED: {
|
||||
// Treat the source as a 32-bit depth value and remap to 16 bit.
|
||||
uint32_t *source = pixels;
|
||||
for (int y = 0; y < surface->h; ++y) {
|
||||
for (int x = 0; x < surface->w; ++x, ++source) {
|
||||
uint8_t red, green, blue;
|
||||
SDL_GetRGB(source[0], surface->format, &red, &green, &blue);
|
||||
uint32_t y_value = static_cast<uint8_t>(0.299f * red + 0.587f * green + 0.114f * blue);
|
||||
y_value = static_cast<uint32_t>(static_cast<float>(y_value) / 255.0f * 65535.0f);
|
||||
*dest++ = y_value & 0xFF;
|
||||
*dest++ = (y_value >> 8) & 0xFF;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_G8B8: {
|
||||
uint32_t *source = pixels;
|
||||
for (int y = 0; y < surface->h; ++y) {
|
||||
|
Loading…
Reference in New Issue
Block a user