#define DDS_PF_RGB 0x40
#define DDS_PF_YUV 0x200
#define DDS_PF_LUMINANCE 0x20000
+#define DDS_PF_BUMPLUMINANCE 0x40000
#define DDS_PF_BUMPDUDV 0x80000
struct dds_pixel_format
return D3DFMT_UNKNOWN;
}
+static D3DFORMAT dds_bump_luminance_to_d3dformat(const struct dds_pixel_format *pixel_format)
+{
+ if (pixel_format->bpp == 32 && pixel_format->rmask == 0x000000ff && pixel_format->gmask == 0x0000ff00
+ && pixel_format->bmask == 0x00ff0000)
+ return D3DFMT_X8L8V8U8;
+
+ WARN("Unknown bump pixel format (%u, %#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)
{
TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size,
return dds_alpha_to_d3dformat(pixel_format);
if (pixel_format->flags & DDS_PF_BUMPDUDV)
return dds_bump_to_d3dformat(pixel_format);
+ if (pixel_format->flags & DDS_PF_BUMPLUMINANCE)
+ return dds_bump_luminance_to_d3dformat(pixel_format);
WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %u, r %#x, g %#x, b %#x, a %#x)\n",
pixel_format->flags, pixel_format->fourcc, pixel_format->bpp,
}
}
+ /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while
+ * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */
+ if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) {
+ DWORD size = sizeof(DWORD) * info->Width * info->Height;
+ BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size);
+ hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer);
+ if (SUCCEEDED(hr)) {
+ DWORD i;
+ for (i = 0; i < info->Width * info->Height; i++) {
+ if (buffer[i*4+3]) {
+ info->Format = D3DFMT_A8R8G8B8;
+ break;
+ }
+ }
+ }
+ HeapFree(GetProcessHeap(), 0, buffer);
+ }
+
if (frame)
IWICBitmapFrameDecode_Release(frame);
pre_convert = get_dxtn_conversion_func(srcformatdesc->format, FALSE);
post_convert = get_dxtn_conversion_func(destformatdesc->format, TRUE);
- if ((!pre_convert && (srcformatdesc->type != FORMAT_ARGB) && (srcformatdesc->type != FORMAT_INDEX)) ||
- (!post_convert && (destformatdesc->type != FORMAT_ARGB)))
+ if ((!pre_convert && !is_conversion_from_supported(srcformatdesc)) ||
+ (!post_convert && !is_conversion_to_supported(destformatdesc)))
{
- FIXME("Format conversion missing %#x -> %#x\n", src_format, surfdesc.Format);
+ FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format);
return E_NOTIMPL;
}
src_format_desc = get_format_info(src_surface_desc.Format);
dst_format_desc = get_format_info(d3d_pixel_format);
- if (src_format_desc->type != FORMAT_ARGB || dst_format_desc->type != FORMAT_ARGB)
+ if (!is_conversion_from_supported(src_format_desc)
+ || !is_conversion_to_supported(dst_format_desc))
{
- FIXME("Unsupported pixel format conversion %#x -> %#x\n",
+ FIXME("Unsupported format conversion %#x -> %#x.\n",
src_surface_desc.Format, d3d_pixel_format);
hr = E_NOTIMPL;
goto cleanup;