From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx10_43/async.c | 11 +++++- dlls/d3dx10_43/tests/d3dx10.c | 35 +++++++++++------- dlls/d3dx10_43/texture.c | 67 ++++++++++++++++++++++++++--------- 3 files changed, 84 insertions(+), 29 deletions(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c index 62627886804..e2cd14a7736 100644 --- a/dlls/d3dx10_43/async.c +++ b/dlls/d3dx10_43/async.c @@ -322,6 +322,8 @@ struct texture_processor { ID3DX10DataProcessor ID3DX10DataProcessor_iface; ID3D10Device *device; + D3DX10_IMAGE_INFO img_info; + D3DX10_IMAGE_INFO *img_info_out; D3DX10_IMAGE_LOAD_INFO load_info; D3D10_SUBRESOURCE_DATA *resource_data; }; @@ -334,6 +336,7 @@ static inline struct texture_processor *texture_processor_from_ID3DX10DataProces static HRESULT WINAPI texture_processor_Process(ID3DX10DataProcessor *iface, void *data, SIZE_T size) { struct texture_processor *processor = texture_processor_from_ID3DX10DataProcessor(iface); + HRESULT hr;
TRACE("iface %p, data %p, size %Iu.\n", iface, data, size);
@@ -343,7 +346,10 @@ static HRESULT WINAPI texture_processor_Process(ID3DX10DataProcessor *iface, voi free(processor->resource_data); processor->resource_data = NULL; } - return load_texture_data(data, size, &processor->load_info, &processor->resource_data); + hr = load_texture_data(data, size, &processor->load_info, &processor->resource_data); + if (SUCCEEDED(hr) && processor->img_info_out) + *processor->img_info_out = processor->img_info; + return hr; }
static HRESULT WINAPI texture_processor_CreateDeviceObject(ID3DX10DataProcessor *iface, void **object) @@ -594,7 +600,10 @@ HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *device, object->ID3DX10DataProcessor_iface.lpVtbl = &texture_processor_vtbl; object->device = device; ID3D10Device_AddRef(device); + if (load_info) + object->img_info_out = load_info->pSrcInfo; init_load_info(load_info, &object->load_info); + object->load_info.pSrcInfo = &object->img_info;
*processor = &object->ID3DX10DataProcessor_iface; return S_OK; diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 45220a51f27..0e200f64f36 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -20,6 +20,7 @@ #include "initguid.h" #include "d3d10_1.h" #include "d3dx10.h" +#include "wine/wined3d.h" #include "wine/test.h" #include <stdint.h>
@@ -69,6 +70,8 @@ #define DDS_PF_BUMPLUMINANCE 0x00040000 #define DDS_PF_BUMPDUDV 0x00080000
+static bool wined3d_opengl; + struct dds_pixel_format { DWORD size; @@ -1812,13 +1815,8 @@ static void check_test_image_load_info_resource_(uint32_t line, ID3D10Resource * HRESULT hr;
ID3D10Resource_GetType(resource, &resource_dimension); - todo_wine_if(image_load_info->expected_type == D3D10_RESOURCE_DIMENSION_TEXTURE3D) - ok(resource_dimension == image_load_info->expected_type, "Got unexpected ResourceDimension %u, expected %u.\n", - resource_dimension, image_load_info->expected_type); - - if (resource_dimension != image_load_info->expected_type) - return; - + ok(resource_dimension == image_load_info->expected_type, "Got unexpected ResourceDimension %u, expected %u.\n", + resource_dimension, image_load_info->expected_type); switch (resource_dimension) { case D3D10_RESOURCE_DIMENSION_TEXTURE2D: @@ -1887,10 +1885,9 @@ static void check_resource_info(ID3D10Resource *resource, const struct test_imag }
ID3D10Resource_GetType(resource, &resource_dimension); - todo_wine_if (image->expected_info.ResourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D) - ok(resource_dimension == image->expected_info.ResourceDimension, - "Got unexpected ResourceDimension %u, expected %u.\n", - resource_dimension, image->expected_info.ResourceDimension); + ok(resource_dimension == image->expected_info.ResourceDimension, + "Got unexpected ResourceDimension %u, expected %u.\n", + resource_dimension, image->expected_info.ResourceDimension);
switch (resource_dimension) { @@ -2083,7 +2080,10 @@ static void check_resource_data(ID3D10Resource *resource, const struct test_imag
if (SUCCEEDED(ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture3d))) { - check_texture3d_data(texture3d, image, line); + if (wined3d_opengl && is_block_compressed(image->expected_info.Format)) + skip("Skipping compressed format 3D texture readback test.\n"); + else + check_texture3d_data(texture3d, image, line); ID3D10Texture3D_Release(texture3d); } else if (SUCCEEDED(ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture2d))) @@ -6107,6 +6107,17 @@ static void test_preprocess_shader(void)
START_TEST(d3dx10) { + HMODULE wined3d; + + if ((wined3d = GetModuleHandleA("wined3d.dll"))) + { + enum wined3d_renderer (CDECL *p_wined3d_get_renderer)(void); + + if ((p_wined3d_get_renderer = (void *)GetProcAddress(wined3d, "wined3d_get_renderer")) + && p_wined3d_get_renderer() == WINED3D_RENDERER_OPENGL) + wined3d_opengl = true; + } + test_D3DX10UnsetAllDeviceObjects(); test_D3DX10CreateAsyncMemoryLoader(); test_D3DX10CreateAsyncFileLoader(); diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 46dd323239e..4e048726310 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -440,9 +440,12 @@ static HRESULT create_texture(ID3D10Device *device, const void *data, SIZE_T siz { D3D10_SUBRESOURCE_DATA *resource_data; D3DX10_IMAGE_LOAD_INFO load_info_copy; + D3DX10_IMAGE_INFO img_info; HRESULT hr;
init_load_info(load_info, &load_info_copy); + if (!load_info_copy.pSrcInfo) + load_info_copy.pSrcInfo = &img_info;
if (FAILED((hr = load_texture_data(data, size, &load_info_copy, &resource_data)))) return hr; @@ -776,25 +779,57 @@ end: HRESULT create_d3d_texture(ID3D10Device *device, D3DX10_IMAGE_LOAD_INFO *load_info, D3D10_SUBRESOURCE_DATA *resource_data, ID3D10Resource **texture) { - D3D10_TEXTURE2D_DESC texture_2d_desc; - ID3D10Texture2D *texture_2d; HRESULT hr;
- memset(&texture_2d_desc, 0, sizeof(texture_2d_desc)); - texture_2d_desc.Width = load_info->Width; - texture_2d_desc.Height = load_info->Height; - texture_2d_desc.MipLevels = load_info->MipLevels; - texture_2d_desc.ArraySize = load_info->MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE ? 6 : 1; - texture_2d_desc.Format = load_info->Format; - texture_2d_desc.SampleDesc.Count = 1; - texture_2d_desc.Usage = load_info->Usage; - texture_2d_desc.BindFlags = load_info->BindFlags; - texture_2d_desc.MiscFlags = load_info->MiscFlags; - - if (FAILED(hr = ID3D10Device_CreateTexture2D(device, &texture_2d_desc, resource_data, &texture_2d))) - return hr; + *texture = NULL; + switch (load_info->pSrcInfo->ResourceDimension) + { + case D3D10_RESOURCE_DIMENSION_TEXTURE2D: + { + D3D10_TEXTURE2D_DESC texture_2d_desc = { 0 }; + ID3D10Texture2D *texture_2d; + + texture_2d_desc.Width = load_info->Width; + texture_2d_desc.Height = load_info->Height; + texture_2d_desc.MipLevels = load_info->MipLevels; + texture_2d_desc.ArraySize = load_info->MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE ? 6 : 1; + texture_2d_desc.Format = load_info->Format; + texture_2d_desc.SampleDesc.Count = 1; + texture_2d_desc.Usage = load_info->Usage; + texture_2d_desc.BindFlags = load_info->BindFlags; + texture_2d_desc.MiscFlags = load_info->MiscFlags; + + if (FAILED(hr = ID3D10Device_CreateTexture2D(device, &texture_2d_desc, resource_data, &texture_2d))) + return hr; + *texture = (ID3D10Resource *)texture_2d; + break; + } + + case D3D10_RESOURCE_DIMENSION_TEXTURE3D: + { + D3D10_TEXTURE3D_DESC texture_3d_desc = { 0 }; + ID3D10Texture3D *texture_3d; + + texture_3d_desc.Width = load_info->Width; + texture_3d_desc.Height = load_info->Height; + texture_3d_desc.Depth = load_info->Depth; + texture_3d_desc.MipLevels = load_info->MipLevels; + texture_3d_desc.Format = load_info->Format; + texture_3d_desc.Usage = load_info->Usage; + texture_3d_desc.BindFlags = load_info->BindFlags; + texture_3d_desc.MiscFlags = load_info->MiscFlags; + + if (FAILED(hr = ID3D10Device_CreateTexture3D(device, &texture_3d_desc, resource_data, &texture_3d))) + return hr; + *texture = (ID3D10Resource *)texture_3d; + break; + } + + default: + FIXME("Unhandled resource dimension %d.\n", load_info->pSrcInfo->ResourceDimension); + return E_NOTIMPL; + }
- *texture = (ID3D10Resource *)texture_2d; return S_OK; }