From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 3 -- dlls/d3dx9_36/surface.c | 18 ----------- dlls/d3dx9_36/tests/volume.c | 56 ++++++++++++++++------------------- dlls/d3dx9_36/volume.c | 38 +++++++++++------------- 4 files changed, 42 insertions(+), 73 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 701afffd046..26e4a1560d6 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -174,9 +174,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info); -HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, - const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, - const D3DXIMAGE_INFO *src_info); HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info); HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 3e0b880eec4..a97112a3562 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -566,24 +566,6 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; }
-HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, - const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, - const D3DXIMAGE_INFO *src_info) -{ - UINT row_pitch, slice_pitch; - const struct dds_header *header = src_data; - const BYTE *pixels = (BYTE *)(header + 1); - - if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE) - return D3DXERR_INVALIDDATA; - - if (FAILED(d3dx_calculate_pixels_size(src_info->Format, src_info->Width, src_info->Height, &row_pitch, &slice_pitch))) - return E_NOTIMPL; - - return D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels, src_info->Format, - row_pitch, slice_pitch, NULL, src_box, filter, color_key); -} - HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) { diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index 83d832b08c7..9ffc487078c 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -362,25 +362,22 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, dds_24bit_8_8, sizeof(dds_24bit_8_8), NULL, D3DX_FILTER_POINT, 0, &img_info); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE);
- IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); - get_texture_volume_readback(device, volume_texture, 0, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) + for (x = 0; x < desc.Width; ++x) { - for (x = 0; x < desc.Width; ++x) - { - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE); - } + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE); } } - release_volume_readback(&volume_rb); } + release_volume_readback(&volume_rb);
IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); @@ -393,30 +390,27 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb), NULL, D3DX_FILTER_POINT, 0, &img_info); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE);
- IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); - get_texture_volume_readback(device, volume_texture, 0, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) + const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; + + for (x = 0; x < desc.Width; ++x) { - const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; - - for (x = 0; x < desc.Width; ++x) - { - if (x < (desc.Width / 2)) - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); - else - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); - } + if (x < (desc.Width / 2)) + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); + else + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); } } - release_volume_readback(&volume_rb); } + release_volume_readback(&volume_rb);
IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); diff --git a/dlls/d3dx9_36/volume.c b/dlls/d3dx9_36/volume.c index 0006a521532..10073fb31e0 100644 --- a/dlls/d3dx9_36/volume.c +++ b/dlls/d3dx9_36/volume.c @@ -168,6 +168,8 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons { HRESULT hr; D3DBOX box; + struct d3dx_image image; + struct d3dx_pixels pixels; D3DXIMAGE_INFO image_info;
TRACE("dst_volume %p, dst_palette %p, dst_box %p, src_data %p, src_data_size %u, src_box %p, " @@ -175,12 +177,14 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons dst_volume, dst_palette, dst_box, src_data, src_data_size, src_box, filter, color_key, src_info);
- if (!dst_volume || !src_data) + if (!dst_volume || !src_data || !src_data_size) return D3DERR_INVALIDCALL;
- if (FAILED(hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info))) - return hr; + hr = d3dx_image_init(src_data, src_data_size, &image, 0, 0); + if (FAILED(hr)) + return D3DXERR_INVALIDDATA;
+ d3dximage_info_from_d3dx_image(&image_info, &image); if (src_box) { if (src_box->Right > image_info.Width @@ -192,29 +196,21 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons } else { - box.Left = 0; - box.Top = 0; - box.Right = image_info.Width; - box.Bottom = image_info.Height; - box.Front = 0; - box.Back = image_info.Depth; - + set_d3dbox(&box, 0, 0, image_info.Width, image_info.Height, 0, image_info.Depth); }
- if (image_info.ImageFileFormat != D3DXIFF_DDS) - { - FIXME("File format %#x is not supported yet\n", image_info.ImageFileFormat); - return E_NOTIMPL; - } - - hr = load_volume_from_dds(dst_volume, dst_palette, dst_box, src_data, &box, - filter, color_key, &image_info); - if (FAILED(hr)) return hr; + hr = d3dx_image_get_pixels(&image, 0, &pixels); + if (FAILED(hr)) + goto exit;
- if (src_info) + hr = D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels.data, image_info.Format, + pixels.row_pitch, pixels.slice_pitch, pixels.palette, &box, filter, color_key); + if (SUCCEEDED(hr) && src_info) *src_info = image_info;
- return D3D_OK; +exit: + d3dx_image_cleanup(&image); + return FAILED(hr) ? hr : D3D_OK; }
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,