d3dx9: Add missing pixel formats.

This commit is contained in:
Józef Kucia 2012-05-13 23:00:03 +02:00 committed by Alexandre Julliard
parent 5e4d64d18e
commit 42dd957c50
3 changed files with 25 additions and 3 deletions

View File

@ -104,6 +104,7 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format)
#define DDS_PF_RGB 0x40 #define DDS_PF_RGB 0x40
#define DDS_PF_YUV 0x200 #define DDS_PF_YUV 0x200
#define DDS_PF_LUMINANCE 0x20000 #define DDS_PF_LUMINANCE 0x20000
#define DDS_PF_BUMPDUDV 0x80000
struct dds_pixel_format struct dds_pixel_format
{ {
@ -217,6 +218,8 @@ static D3DFORMAT dds_luminance_to_d3dformat(const struct dds_pixel_format *pixel
} }
if (pixel_format->bpp == 16) if (pixel_format->bpp == 16)
{ {
if (pixel_format->rmask == 0xffff)
return D3DFMT_L16;
if ((pixel_format->flags & DDS_PF_ALPHA) && pixel_format->rmask == 0x00ff && pixel_format->amask == 0xff00) if ((pixel_format->flags & DDS_PF_ALPHA) && pixel_format->rmask == 0x00ff && pixel_format->amask == 0xff00)
return D3DFMT_A8L8; return D3DFMT_A8L8;
} }
@ -235,6 +238,18 @@ static D3DFORMAT dds_alpha_to_d3dformat(const struct dds_pixel_format *pixel_for
return D3DFMT_UNKNOWN; return D3DFMT_UNKNOWN;
} }
static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_format)
{
if (pixel_format->bpp == 16 && pixel_format->rmask == 0x00ff && pixel_format->gmask == 0xff00)
return D3DFMT_V8U8;
if (pixel_format->bpp == 32 && pixel_format->rmask == 0x0000ffff && pixel_format->gmask == 0xffff0000)
return D3DFMT_V16U16;
WARN("Unknown bump pixel format (%#x, %#x, %#x, %#x, %#x)\n", pixel_format->bpp,
pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask);
return D3DFMT_UNKNOWN;
}
static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format) static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format)
{ {
if (pixel_format->flags & DDS_PF_FOURCC) if (pixel_format->flags & DDS_PF_FOURCC)
@ -245,10 +260,12 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi
return dds_luminance_to_d3dformat(pixel_format); return dds_luminance_to_d3dformat(pixel_format);
if (pixel_format->flags & DDS_PF_ALPHA_ONLY) if (pixel_format->flags & DDS_PF_ALPHA_ONLY)
return dds_alpha_to_d3dformat(pixel_format); return dds_alpha_to_d3dformat(pixel_format);
if (pixel_format->flags & DDS_PF_BUMPDUDV)
return dds_bump_to_d3dformat(pixel_format);
WARN("Unknown pixel format (fourcc %#x, bpp %#x, r %#x, g %#x, b %#x, a %#x)\n", WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %#x, r %#x, g %#x, b %#x, a %#x)\n",
pixel_format->fourcc, pixel_format->bpp, pixel_format->rmask, pixel_format->gmask, pixel_format->flags, pixel_format->fourcc, pixel_format->bpp,
pixel_format->bmask, pixel_format->amask); pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask);
return D3DFMT_UNKNOWN; return D3DFMT_UNKNOWN;
} }

View File

@ -150,6 +150,7 @@ static HRESULT create_file(const char *filename, const unsigned char *data, cons
#define DDS_PF_FOURCC 0x00000004 #define DDS_PF_FOURCC 0x00000004
#define DDS_PF_RGB 0x00000040 #define DDS_PF_RGB 0x00000040
#define DDS_PF_LUMINANCE 0x00020000 #define DDS_PF_LUMINANCE 0x00020000
#define DDS_PF_BUMPDUDV 0x00080000
static void check_dds_pixel_format(DWORD flags, DWORD fourcc, DWORD bpp, static void check_dds_pixel_format(DWORD flags, DWORD fourcc, DWORD bpp,
DWORD rmask, DWORD gmask, DWORD bmask, DWORD amask, DWORD rmask, DWORD gmask, DWORD bmask, DWORD amask,
@ -397,8 +398,11 @@ static void test_D3DXGetImageInfo(void)
check_dds_pixel_format(DDS_PF_RGB, 0, 32, 0xff0000, 0x00ff00, 0x0000ff, 0, D3DFMT_X8R8G8B8); check_dds_pixel_format(DDS_PF_RGB, 0, 32, 0xff0000, 0x00ff00, 0x0000ff, 0, D3DFMT_X8R8G8B8);
check_dds_pixel_format(DDS_PF_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_G16R16); check_dds_pixel_format(DDS_PF_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_G16R16);
check_dds_pixel_format(DDS_PF_LUMINANCE, 0, 8, 0xff, 0, 0, 0, D3DFMT_L8); check_dds_pixel_format(DDS_PF_LUMINANCE, 0, 8, 0xff, 0, 0, 0, D3DFMT_L8);
check_dds_pixel_format(DDS_PF_LUMINANCE, 0, 16, 0xffff, 0, 0, 0, D3DFMT_L16);
check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 16, 0x00ff, 0, 0, 0xff00, D3DFMT_A8L8); check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 16, 0x00ff, 0, 0, 0xff00, D3DFMT_A8L8);
check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 8, 0x0f, 0, 0, 0xf0, D3DFMT_A4L4); check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 8, 0x0f, 0, 0, 0xf0, D3DFMT_A4L4);
check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0, D3DFMT_V8U8);
check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16);
todo_wine { todo_wine {
hr = D3DXGetImageInfoFromFileInMemory(dds_16bit, sizeof(dds_16bit) - 1, &info); hr = D3DXGetImageInfoFromFileInMemory(dds_16bit, sizeof(dds_16bit) - 1, &info);

View File

@ -62,6 +62,7 @@ static const PixelFormatDesc formats[] =
{D3DFMT_G16R16, {0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL }, {D3DFMT_G16R16, {0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL },
{D3DFMT_A8, {8, 0, 0, 0}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_ARGB, NULL, NULL }, {D3DFMT_A8, {8, 0, 0, 0}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_ARGB, NULL, NULL },
{D3DFMT_A8L8, {8, 8, 0, 0}, { 8, 0, 0, 0}, 2, 1, 1, 2, FORMAT_ARGB, la_from_rgba, la_to_rgba}, {D3DFMT_A8L8, {8, 8, 0, 0}, { 8, 0, 0, 0}, 2, 1, 1, 2, FORMAT_ARGB, la_from_rgba, la_to_rgba},
{D3DFMT_A4L4, {4, 4, 0, 0}, { 4, 0, 0, 0}, 1, 1, 1, 1, FORMAT_ARGB, la_from_rgba, la_to_rgba},
{D3DFMT_DXT1, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 8, FORMAT_ARGB, NULL, NULL }, {D3DFMT_DXT1, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 8, FORMAT_ARGB, NULL, NULL },
{D3DFMT_DXT2, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_ARGB, NULL, NULL }, {D3DFMT_DXT2, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_ARGB, NULL, NULL },
{D3DFMT_DXT3, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_ARGB, NULL, NULL }, {D3DFMT_DXT3, {0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_ARGB, NULL, NULL },