d3dx10: Implement D3DX10CreateTextureFromResource{A,W}.

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2021-11-04 19:28:48 +08:00 committed by Alexandre Julliard
parent 81bc256685
commit 94f8a077bb
2 changed files with 44 additions and 9 deletions

View File

@ -2076,8 +2076,6 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromResource tests */
todo_wine
{
hr = D3DX10CreateTextureFromResourceW(device, NULL, NULL, NULL, NULL, &resource, NULL);
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
hr = D3DX10CreateTextureFromResourceW(device, NULL, L"deadbeef", NULL, NULL, &resource, NULL);
@ -2086,7 +2084,6 @@ static void test_create_texture(void)
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
hr = D3DX10CreateTextureFromResourceA(device, NULL, "deadbeef", NULL, NULL, &resource, NULL);
ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr);
}
for (i = 0; i < ARRAY_SIZE(test_image); ++i)
{
@ -2095,7 +2092,7 @@ static void test_create_texture(void)
hr = D3DX10CreateTextureFromResourceW(device, resource_module,
test_resource_name, NULL, NULL, &resource, NULL);
todo_wine
todo_wine_if(test_image[i].expected_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE)
ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX10_IFF_WMP),
"Got unexpected hr %#x.\n", hr);
if (hr == S_OK)
@ -2107,7 +2104,7 @@ static void test_create_texture(void)
hr = D3DX10CreateTextureFromResourceA(device, resource_module,
get_str_a(test_resource_name), NULL, NULL, &resource, NULL);
todo_wine
todo_wine_if(test_image[i].expected_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE)
ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX10_IFF_WMP),
"Got unexpected hr %#x.\n", hr);
if (hr == S_OK)

View File

@ -626,17 +626,55 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s
HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE module, const char *resource,
D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
{
FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n",
HRSRC res_info;
void *buffer;
DWORD size;
HRESULT hr;
TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n",
device, module, debugstr_a(resource), load_info, pump, texture, hresult);
return E_NOTIMPL;
if (!resource || !texture)
return D3DX10_ERR_INVALID_DATA;
if (!(res_info = FindResourceA(module, resource, (const char *)RT_RCDATA)))
{
/* Try loading the resource as bitmap data */
if (!(res_info = FindResourceA(module, resource, (const char *)RT_BITMAP)))
return D3DX10_ERR_INVALID_DATA;
}
if (FAILED(hr = load_resource(module, res_info, &buffer, &size)))
return D3DX10_ERR_INVALID_DATA;
return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
}
HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE module, const WCHAR *resource,
D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
{
FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n",
HRSRC res_info;
void *buffer;
DWORD size;
HRESULT hr;
TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n",
device, module, debugstr_w(resource), load_info, pump, texture, hresult);
return E_NOTIMPL;
if (!resource || !texture)
return D3DX10_ERR_INVALID_DATA;
if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
{
/* Try loading the resource as bitmap data */
if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP)))
return D3DX10_ERR_INVALID_DATA;
}
if (FAILED(hr = load_resource(module, res_info, &buffer, &size)))
return D3DX10_ERR_INVALID_DATA;
return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
}
HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data, SIZE_T src_data_size,