Commit 84a290c1 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Don't forbid supported format conversions.

parent 69006a7c
......@@ -65,6 +65,22 @@ struct pixel_format_desc {
void (*to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette);
};
static inline BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
{
if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
|| format->type == FORMAT_ARGBF)
return TRUE;
return !!format->to_rgba;
}
static inline BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
{
if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
|| format->type == FORMAT_ARGBF)
return TRUE;
return !!format->from_rgba;
}
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
......
......@@ -1837,10 +1837,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
}
else /* Stretching or format conversion. */
{
if (((srcformatdesc->type != FORMAT_ARGB) && (srcformatdesc->type != FORMAT_INDEX)) ||
(destformatdesc->type != FORMAT_ARGB))
if (!is_conversion_from_supported(srcformatdesc)
|| !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;
}
......@@ -2112,9 +2112,10 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
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;
......
......@@ -188,8 +188,8 @@ HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume,
const BYTE *src_addr;
if (((src_format_desc->type != FORMAT_ARGB) && (src_format_desc->type != FORMAT_INDEX)) ||
(dst_format_desc->type != FORMAT_ARGB))
if (!is_conversion_from_supported(src_format_desc)
|| !is_conversion_to_supported(dst_format_desc))
{
FIXME("Pixel format conversion is not implemented %#x -> %#x\n",
src_format_desc->format, dst_format_desc->format);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment