From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/d3dx10_43/d3dx10_43_main.c | 8 -------- dlls/d3dx10_43/tests/d3dx10.c | 12 ++++++------ dlls/d3dx10_43/texture.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c index ec7407508d3..ba6de566576 100644 --- a/dlls/d3dx10_43/d3dx10_43_main.c +++ b/dlls/d3dx10_43/d3dx10_43_main.c @@ -168,11 +168,3 @@ D3DX_CPU_OPTIMIZATION WINAPI D3DXCpuOptimizations(BOOL enable) return D3DX_NOT_OPTIMIZED; } - -HRESULT WINAPI D3DX10LoadTextureFromTexture(ID3D10Resource *src_texture, D3DX10_TEXTURE_LOAD_INFO *load_info, - ID3D10Resource *dst_texture) -{ - FIXME("src_texture %p, load_info %p, dst_texture %p stub!\n", src_texture, load_info, dst_texture); - - return E_NOTIMPL; -} diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 0816cc073d7..8bd05c41f35 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -6328,7 +6328,7 @@ static void test_load_texture_from_texture(void) { { NULL, NULL, 0, 0, D3DX10_DEFAULT, 0, 0, D3DX10_DEFAULT, D3DX10_DEFAULT, D3DX10_DEFAULT }, dds_2d_array_4_4, sizeof(dds_2d_array_4_4), { 0 }, FALSE, - { D3D10_RESOURCE_DIMENSION_UNKNOWN }, { 0 }, FALSE, D3DERR_INVALIDCALL, .todo_hr = TRUE + { D3D10_RESOURCE_DIMENSION_UNKNOWN }, { 0 }, FALSE, D3DERR_INVALIDCALL }, /* Invalid pSrcBox dimensions. */ { @@ -6341,7 +6341,7 @@ static void test_load_texture_from_texture(void) 4, 4, 2, 2, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE, 0, 0, } - }, { 0 }, FALSE, D3DERR_INVALIDCALL, .broken_below_version = 40, .todo_hr = TRUE + }, { 0 }, FALSE, D3DERR_INVALIDCALL, .broken_below_version = 40 }, /* Invalid pDstBox dimensions. */ { @@ -6354,7 +6354,7 @@ static void test_load_texture_from_texture(void) 4, 4, 2, 2, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE, 0, 0, } - }, { 0, 1, 0, 0, 0, 0 }, TRUE, D3DERR_INVALIDCALL, .broken_below_version = 40, .todo_hr = TRUE + }, { 0, 1, 0, 0, 0, 0 }, TRUE, D3DERR_INVALIDCALL, .broken_below_version = 40 }, /* * Invalid filter flags. Still validated even if SrcFirstMip is higher @@ -6665,13 +6665,13 @@ static void test_load_texture_from_texture(void) /* Test NULL arguments for source/dest resource. */ hr = D3DX10LoadTextureFromTexture(src_rsrc, NULL, NULL); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); hr = D3DX10LoadTextureFromTexture(NULL, NULL, dst_rsrc); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); hr = D3DX10LoadTextureFromTexture(NULL, NULL, NULL); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); /* NULL load_info argument, gets default load_info values. */ hr = D3DX10LoadTextureFromTexture(src_rsrc, NULL, dst_rsrc); diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 0fd300b66a0..b3787685b10 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -27,6 +27,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); +#define D3DERR_INVALIDCALL 0x8876086c + /* * These are mappings from legacy DDS header formats to DXGI formats. Some * don't map to a DXGI_FORMAT at all, and some only map to the default format. @@ -911,3 +913,34 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s *hresult = hr; return hr; } + +static BOOL d3d10_box_is_valid(const D3D10_BOX *box) +{ + return (box->left <= box->right) && (box->top <= box->bottom) && (box->front <= box->back); +} + +HRESULT WINAPI D3DX10LoadTextureFromTexture(ID3D10Resource *src_texture, D3DX10_TEXTURE_LOAD_INFO *load_info, + ID3D10Resource *dst_texture) +{ + static const D3DX10_TEXTURE_LOAD_INFO default_load_info = { NULL, NULL, 0, 0, D3DX10_DEFAULT, 0, 0, D3DX10_DEFAULT, + D3DX10_DEFAULT, D3DX10_DEFAULT }; + D3DX10_TEXTURE_LOAD_INFO info = (load_info) ? *load_info : default_load_info; + + FIXME("src_texture %p, load_info %p, dst_texture %p stub!\n", src_texture, load_info, dst_texture); + + if (!src_texture || !dst_texture) + return D3DERR_INVALIDCALL; + + if ((info.pSrcBox && !d3d10_box_is_valid(info.pSrcBox)) || (info.pDstBox && !d3d10_box_is_valid(info.pDstBox))) + return D3DERR_INVALIDCALL; + + /* + * If the source and destination texture are the same, we can't load into + * the same subresource. + */ + if (src_texture == dst_texture && info.SrcFirstMip == info.DstFirstMip + && info.SrcFirstElement == info.DstFirstElement) + return D3DERR_INVALIDCALL; + + return E_NOTIMPL; +} -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10887