- support HRESULT parameter in D3DX10CreateTextureFrom* - implement D3DX10CreateAsyncTextureProcessor
From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 5 +++++ dlls/d3dx10_43/texture.c | 32 +++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 0c6c4e5c8ce..560bc7a8f17 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2172,6 +2172,11 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromMemory tests */
+ resource = (ID3D10Resource *)0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(NULL, test_bmp_1bpp, sizeof(test_bmp_1bpp), NULL, NULL, &resource, NULL); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + resource = (ID3D10Resource *)0xdeadbeef; hr = D3DX10CreateTextureFromMemory(device, NULL, 0, NULL, NULL, &resource, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 9c7762bc617..d5066b9793b 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -581,7 +581,9 @@ HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *sr TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, debugstr_a(src_file), load_info, pump, texture, hresult);
- if (!src_file || !texture) + if (!device) + return E_INVALIDARG; + if (!src_file) return E_FAIL;
if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0))) @@ -608,11 +610,17 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, debugstr_w(src_file), load_info, pump, texture, hresult);
- if (!src_file || !texture) + if (!device) + return E_INVALIDARG; + if (!src_file) return E_FAIL;
if (FAILED((hr = load_file(src_file, &buffer, &size)))) + { + if (hresult) + *hresult = hr; return hr; + }
hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
@@ -631,8 +639,8 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE mo 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);
- if (!resource || !texture) - return D3DX10_ERR_INVALID_DATA; + if (!device) + return E_INVALIDARG;
hr = load_resourceA(module, resource, &buffer, &size); if (FAILED(hr)) @@ -651,8 +659,8 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE mo 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);
- if (!resource || !texture) - return D3DX10_ERR_INVALID_DATA; + if (!device) + return E_INVALIDARG;
hr = load_resourceW(module, resource, &buffer, &size); if (FAILED(hr)) @@ -684,7 +692,9 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s TRACE("device %p, src_data %p, src_data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n", device, src_data, src_data_size, load_info, pump, texture, hresult);
- if (!src_data || !src_data_size || !texture) + if (!device) + return E_INVALIDARG; + if (!src_data) return E_FAIL; if (load_info) FIXME("load_info is ignored.\n"); @@ -692,10 +702,16 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s FIXME("Thread pump is not supported yet.\n");
if (FAILED(D3DX10GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL))) + { + if (hresult) + *hresult = E_FAIL; return E_FAIL; + } if (img_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) { FIXME("Cube map is not supported.\n"); + if (hresult) + *hresult = E_FAIL; return E_FAIL; }
@@ -807,5 +823,7 @@ end: if (factory) IWICImagingFactory_Release(factory);
+ if (hresult) + *hresult = hr; return hr; }
From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 74 ++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 560bc7a8f17..54533f5c738 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2158,8 +2158,8 @@ static void test_create_texture(void) HMODULE resource_module; ID3D10Device *device; WCHAR path[MAX_PATH]; + HRESULT hr, hr2; unsigned int i; - HRESULT hr;
device = create_device(); if (!device) @@ -2173,35 +2173,47 @@ static void test_create_texture(void) /* D3DX10CreateTextureFromMemory tests */
resource = (ID3D10Resource *)0xdeadbeef; - hr = D3DX10CreateTextureFromMemory(NULL, test_bmp_1bpp, sizeof(test_bmp_1bpp), NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(NULL, test_bmp_1bpp, sizeof(test_bmp_1bpp), NULL, NULL, &resource, &hr2); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource);
resource = (ID3D10Resource *)0xdeadbeef; - hr = D3DX10CreateTextureFromMemory(device, NULL, 0, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(device, NULL, 0, NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource);
resource = (ID3D10Resource *)0xdeadbeef; - hr = D3DX10CreateTextureFromMemory(device, NULL, sizeof(test_bmp_1bpp), NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(device, NULL, sizeof(test_bmp_1bpp), NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource);
resource = (ID3D10Resource *)0xdeadbeef; - hr = D3DX10CreateTextureFromMemory(device, test_bmp_1bpp, 0, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(device, test_bmp_1bpp, 0, NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource);
resource = (ID3D10Resource *)0xdeadbeef; - hr = D3DX10CreateTextureFromMemory(device, test_bmp_1bpp, sizeof(test_bmp_1bpp) - 1, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(device, test_bmp_1bpp, sizeof(test_bmp_1bpp) - 1, NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource);
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { winetest_push_context("Test %u", i);
- hr = D3DX10CreateTextureFromMemory(device, test_image[i].data, test_image[i].size, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(device, test_image[i].data, test_image[i].size, NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); 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); @@ -2217,21 +2229,31 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromFile tests */
- hr = D3DX10CreateTextureFromFileW(device, NULL, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileW(device, NULL, NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromFileW(device, L"deadbeef", NULL, NULL, &resource, NULL); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileW(device, L"deadbeef", NULL, NULL, &resource, &hr2); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromFileA(device, NULL, NULL, NULL, &resource, NULL); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileA(device, NULL, NULL, NULL, &resource, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromFileA(device, "deadbeef", NULL, NULL, &resource, NULL); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileA(device, "deadbeef", NULL, NULL, &resource, &hr2); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2);
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { winetest_push_context("Test %u", i); create_file(test_filename, test_image[i].data, test_image[i].size, path);
- hr = D3DX10CreateTextureFromFileW(device, path, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileW(device, path, NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); 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); @@ -2242,7 +2264,9 @@ static void test_create_texture(void) ID3D10Resource_Release(resource); }
- hr = D3DX10CreateTextureFromFileA(device, get_str_a(path), NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromFileA(device, get_str_a(path), NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); 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); @@ -2259,25 +2283,35 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromResource tests */
- hr = D3DX10CreateTextureFromResourceW(device, NULL, NULL, NULL, NULL, &resource, NULL); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromResourceW(device, NULL, NULL, NULL, NULL, &resource, &hr2); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromResourceW(device, NULL, L"deadbeef", NULL, NULL, &resource, NULL); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromResourceW(device, NULL, L"deadbeef", NULL, NULL, &resource, &hr2); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromResourceA(device, NULL, NULL, NULL, NULL, &resource, NULL); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromResourceA(device, NULL, NULL, NULL, NULL, &resource, &hr2); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); - hr = D3DX10CreateTextureFromResourceA(device, NULL, "deadbeef", NULL, NULL, &resource, NULL); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX10CreateTextureFromResourceA(device, NULL, "deadbeef", NULL, NULL, &resource, &hr2); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#x.\n", hr2);
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { winetest_push_context("Test %u", i); resource_module = create_resource_module(test_resource_name, test_image[i].data, test_image[i].size);
+ hr2 = 0xdeadbeef; hr = D3DX10CreateTextureFromResourceW(device, resource_module, - test_resource_name, NULL, NULL, &resource, NULL); + test_resource_name, NULL, NULL, &resource, &hr2); 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); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); if (hr == S_OK) { check_resource_info(resource, test_image + i, __LINE__); @@ -2285,11 +2319,13 @@ static void test_create_texture(void) ID3D10Resource_Release(resource); }
+ hr2 = 0xdeadbeef; hr = D3DX10CreateTextureFromResourceA(device, resource_module, - get_str_a(test_resource_name), NULL, NULL, &resource, NULL); + get_str_a(test_resource_name), NULL, NULL, &resource, &hr2); 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); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); if (hr == S_OK) { check_resource_info(resource, test_image + i, __LINE__);
From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/async.c | 7 +++++++ dlls/d3dx10_43/d3dx10_43.spec | 2 +- include/d3dx10async.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c index 0d75a64ff9e..f0c726944c0 100644 --- a/dlls/d3dx10_43/async.c +++ b/dlls/d3dx10_43/async.c @@ -514,6 +514,13 @@ HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *info, ID return S_OK; }
+HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *device, + D3DX10_IMAGE_LOAD_INFO *info, ID3DX10DataProcessor **processor) +{ + FIXME("device %p, info %p, processor %p stub!\n", device, info, processor); + return E_NOTIMPL; +} + HRESULT WINAPI D3DX10PreprocessShaderFromMemory(const char *data, SIZE_T data_size, const char *filename, const D3D10_SHADER_MACRO *defines, ID3DInclude *include, ID3DX10ThreadPump *pump, ID3D10Blob **shader_text, ID3D10Blob **errors, HRESULT *hresult) diff --git a/dlls/d3dx10_43/d3dx10_43.spec b/dlls/d3dx10_43/d3dx10_43.spec index c0a2c9fa56c..95160a067c5 100644 --- a/dlls/d3dx10_43/d3dx10_43.spec +++ b/dlls/d3dx10_43/d3dx10_43.spec @@ -17,7 +17,7 @@ @ stub D3DX10CreateAsyncShaderPreprocessProcessor(str ptr ptr ptr ptr ptr) @ stub D3DX10CreateAsyncShaderResourceViewProcessor(ptr ptr ptr) @ stdcall D3DX10CreateAsyncTextureInfoProcessor(ptr ptr) -@ stub D3DX10CreateAsyncTextureProcessor(ptr ptr ptr) +@ stdcall D3DX10CreateAsyncTextureProcessor(ptr ptr ptr) @ stdcall D3DX10CreateDevice(ptr long long long ptr) @ stdcall D3DX10CreateDeviceAndSwapChain(ptr long long long ptr ptr ptr) @ stdcall D3DX10CreateEffectFromFileA(str ptr ptr str long long ptr ptr ptr ptr ptr ptr) diff --git a/include/d3dx10async.h b/include/d3dx10async.h index c932be91b01..931458f4813 100644 --- a/include/d3dx10async.h +++ b/include/d3dx10async.h @@ -76,6 +76,8 @@ HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(const void *data, SIZE_T datasize, HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *resource, ID3DX10DataLoader **loader); HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *resource, ID3DX10DataLoader **loader);
+HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *device, + D3DX10_IMAGE_LOAD_INFO *info, ID3DX10DataProcessor **processor); HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *info, ID3DX10DataProcessor **processor);
#endif
From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/async.c | 83 +++++++++++++++++++++++++++++++++++++- dlls/d3dx10_43/dxhelpers.h | 2 + dlls/d3dx10_43/texture.c | 41 ++++++++++--------- 3 files changed, 105 insertions(+), 21 deletions(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c index f0c726944c0..9efe52f0792 100644 --- a/dlls/d3dx10_43/async.c +++ b/dlls/d3dx10_43/async.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define COBJMACROS #include "d3d10_1.h" #include "d3dx10.h" #include "d3dcompiler.h" @@ -315,6 +316,68 @@ static ID3DX10DataProcessorVtbl texture_info_processor_vtbl = texture_info_processor_Destroy };
+struct texture_processor +{ + ID3DX10DataProcessor ID3DX10DataProcessor_iface; + ID3D10Device *device; + D3DX10_IMAGE_LOAD_INFO *info; + ID3D10Resource *texture; +}; + +static inline struct texture_processor *texture_processor_from_ID3DX10DataProcessor(ID3DX10DataProcessor *iface) +{ + return CONTAINING_RECORD(iface, struct texture_processor, ID3DX10DataProcessor_iface); +} + +static HRESULT WINAPI texture_processor_Process(ID3DX10DataProcessor *iface, void *data, SIZE_T size) +{ + struct texture_processor *processor = texture_processor_from_ID3DX10DataProcessor(iface); + + TRACE("iface %p, data %p, size %Iu.\n", iface, data, size); + + if (processor->texture) + { + FIXME("called multiple times\n"); + ID3D10Resource_Release(processor->texture); + processor->texture = NULL; + } + return create_texture(processor->device, data, size, processor->info, &processor->texture); +} + +static HRESULT WINAPI texture_processor_CreateDeviceObject(ID3DX10DataProcessor *iface, void **object) +{ + struct texture_processor *processor = texture_processor_from_ID3DX10DataProcessor(iface); + + TRACE("iface %p, object %p.\n", iface, object); + + if (!processor->texture) + return E_FAIL; + + *object = processor->texture; + ID3D10Resource_AddRef(processor->texture); + return S_OK; +} + +static HRESULT WINAPI texture_processor_Destroy(ID3DX10DataProcessor *iface) +{ + struct texture_processor *processor = texture_processor_from_ID3DX10DataProcessor(iface); + + TRACE("iface %p.\n", iface); + + if (processor->texture) + ID3D10Resource_Release(processor->texture); + ID3D10Device_Release(processor->device); + free(processor); + return S_OK; +} + +static ID3DX10DataProcessorVtbl texture_processor_vtbl = +{ + texture_processor_Process, + texture_processor_CreateDeviceObject, + texture_processor_Destroy +}; + HRESULT WINAPI D3DX10CompileFromMemory(const char *data, SIZE_T data_size, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *entry_point, const char *target, UINT sflags, UINT eflags, ID3DX10ThreadPump *pump, ID3D10Blob **shader, @@ -517,8 +580,24 @@ HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *info, ID HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *device, D3DX10_IMAGE_LOAD_INFO *info, ID3DX10DataProcessor **processor) { - FIXME("device %p, info %p, processor %p stub!\n", device, info, processor); - return E_NOTIMPL; + struct texture_processor *object; + + TRACE("device %p, info %p, processor %p.\n", device, info, processor); + + if (!device || !processor) + return E_INVALIDARG; + + object = calloc(1, sizeof(*object)); + if (!object) + return E_OUTOFMEMORY; + + object->ID3DX10DataProcessor_iface.lpVtbl = &texture_processor_vtbl; + object->device = device; + ID3D10Device_AddRef(device); + object->info = info; + + *processor = &object->ID3DX10DataProcessor_iface; + return S_OK; }
HRESULT WINAPI D3DX10PreprocessShaderFromMemory(const char *data, SIZE_T data_size, const char *filename, diff --git a/dlls/d3dx10_43/dxhelpers.h b/dlls/d3dx10_43/dxhelpers.h index 82fe639c2ea..1ecbd9f7866 100644 --- a/dlls/d3dx10_43/dxhelpers.h +++ b/dlls/d3dx10_43/dxhelpers.h @@ -23,3 +23,5 @@ extern HRESULT load_resourceW(HMODULE module, const WCHAR *resource, void **data, DWORD *size) DECLSPEC_HIDDEN;
extern HRESULT get_image_info(const void *data, SIZE_T size, D3DX10_IMAGE_INFO *img_info) DECLSPEC_HIDDEN; +extern HRESULT create_texture(ID3D10Device *device, const void *data, SIZE_T size, + D3DX10_IMAGE_LOAD_INFO *load_info, ID3D10Resource **texture) DECLSPEC_HIDDEN; diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index d5066b9793b..0f4212b97ef 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -669,8 +669,8 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE mo return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult); }
-HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data, SIZE_T src_data_size, - D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult) +HRESULT create_texture(ID3D10Device *device, const void *data, SIZE_T size, + D3DX10_IMAGE_LOAD_INFO *load_info, ID3D10Resource **texture) { unsigned int frame_count, width, height, stride, frame_size; IWICFormatConverter *converter = NULL; @@ -689,29 +689,14 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s GUID src_format; HRESULT hr;
- TRACE("device %p, src_data %p, src_data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n", - device, src_data, src_data_size, load_info, pump, texture, hresult); - - if (!device) - return E_INVALIDARG; - if (!src_data) - return E_FAIL; if (load_info) FIXME("load_info is ignored.\n"); - if (pump) - FIXME("Thread pump is not supported yet.\n");
- if (FAILED(D3DX10GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL))) - { - if (hresult) - *hresult = E_FAIL; + if (FAILED(D3DX10GetImageInfoFromMemory(data, size, NULL, &img_info, NULL))) return E_FAIL; - } if (img_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) { FIXME("Cube map is not supported.\n"); - if (hresult) - *hresult = E_FAIL; return E_FAIL; }
@@ -719,7 +704,7 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s goto end; if (FAILED(hr = IWICImagingFactory_CreateStream(factory, &stream))) goto end; - if (FAILED(hr = IWICStream_InitializeFromMemory(stream, (BYTE *)src_data, src_data_size))) + if (FAILED(hr = IWICStream_InitializeFromMemory(stream, (BYTE *)data, size))) goto end; if (FAILED(hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream *)stream, NULL, 0, &decoder))) goto end; @@ -822,7 +807,25 @@ end: IWICStream_Release(stream); if (factory) IWICImagingFactory_Release(factory); + return hr; +} + +HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data, SIZE_T src_data_size, + D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult) +{ + HRESULT hr; + + TRACE("device %p, src_data %p, src_data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n", + device, src_data, src_data_size, load_info, pump, texture, hresult); + + if (!device) + return E_INVALIDARG; + if (!src_data) + return E_FAIL; + if (pump) + FIXME("Thread pump is not supported yet.\n");
+ hr = create_texture(device, src_data, src_data_size, load_info, texture); if (hresult) *hresult = hr; return hr;
From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 54533f5c738..a0a2b4fc32b 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2003,6 +2003,69 @@ static void test_D3DX10CreateAsyncTextureInfoProcessor(void) CoUninitialize(); }
+static void test_D3DX10CreateAsyncTextureProcessor(void) +{ + ID3DX10DataProcessor *dp; + ID3D10Resource *resource; + ID3D10Device *device; + HRESULT hr; + int i; + + device = create_device(); + if (!device) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + CoInitialize(NULL); + + hr = D3DX10CreateAsyncTextureProcessor(device, NULL, NULL); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + hr = D3DX10CreateAsyncTextureProcessor(NULL, NULL, &dp); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + hr = D3DX10CreateAsyncTextureProcessor(device, NULL, &dp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_Process(dp, (void *)test_image[0].data, 0); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_Process(dp, NULL, test_image[0].size); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_Destroy(dp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + + hr = D3DX10CreateAsyncTextureProcessor(device, NULL, &dp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10DataProcessor_Process(dp, (void *)test_image[i].data, test_image[i].size); + 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) + { + hr = ID3DX10DataProcessor_CreateDeviceObject(dp, (void **)&resource); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D10Resource_Release(resource); + } + + hr = ID3DX10DataProcessor_Destroy(dp); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + winetest_pop_context(); + } + + CoUninitialize(); + + ID3D10Device_Release(device); +} + static void test_get_image_info(void) { static const WCHAR test_resource_name[] = L"resource.data"; @@ -3493,6 +3556,7 @@ START_TEST(d3dx10) test_D3DX10CreateAsyncFileLoader(); test_D3DX10CreateAsyncResourceLoader(); test_D3DX10CreateAsyncTextureInfoProcessor(); + test_D3DX10CreateAsyncTextureProcessor(); test_get_image_info(); test_create_texture(); test_font();
Patch 4 (d3dx10: Add D3DX10CreateAsyncTextureProcessor implementation) needs some work (the texture should be created in CreateDeviceObject). I'll prepare better version.