From 2b16926188e2e485f43b3d6d08c107ae3b0faecc Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 1 Aug 2023 14:38:44 +1000 Subject: [PATCH] Updated d3dx11_43-D3DX11CreateTextureFromMemory patchset --- ...plement-D3DX11GetImageInfoFromMemory.patch | 33 +++++--------- ...lement-D3DX11CreateTextureFromMemory.patch | 44 ++++++++++++------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0001-d3dx11_43-Implement-D3DX11GetImageInfoFromMemory.patch b/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0001-d3dx11_43-Implement-D3DX11GetImageInfoFromMemory.patch index 8a33821d..7b4f8e9c 100644 --- a/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0001-d3dx11_43-Implement-D3DX11GetImageInfoFromMemory.patch +++ b/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0001-d3dx11_43-Implement-D3DX11GetImageInfoFromMemory.patch @@ -1,7 +1,7 @@ -From ea3579b5b3d701647f5c7f16de658f1cd7fe876d Mon Sep 17 00:00:00 2001 +From 0fbce9fe4b69f27b7df82c6517c364aab57de63b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 30 Jul 2021 15:57:29 +1000 -Subject: [PATCH] d3dx11_43: Implement D3DX11GetImageInfoFromMemory +Subject: [PATCH 1/2] d3dx11_43: Implement D3DX11GetImageInfoFromMemory Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=50210 @@ -10,8 +10,8 @@ Signed-off-by: Alistair Leslie-Hughes dlls/d3dx11_42/Makefile.in | 1 + dlls/d3dx11_43/Makefile.in | 1 + dlls/d3dx11_43/main.c | 9 -- - dlls/d3dx11_43/texture.c | 176 +++++++++++++++++++++++++++++++++++++ - 4 files changed, 178 insertions(+), 9 deletions(-) + dlls/d3dx11_43/texture.c | 167 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 169 insertions(+), 9 deletions(-) diff --git a/dlls/d3dx11_42/Makefile.in b/dlls/d3dx11_42/Makefile.in index 7fcce18a8e1..78ca5f707a7 100644 @@ -55,10 +55,10 @@ index 5dad027864f..00c1db35e42 100644 - return E_NOTIMPL; -} diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c -index 81ac8ee6db7..6881eec107d 100644 +index 81ac8ee6db7..bbf937cdab0 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c -@@ -15,14 +15,190 @@ +@@ -15,14 +15,181 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ @@ -145,13 +145,11 @@ index 81ac8ee6db7..6881eec107d 100644 +HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump, + D3DX11_IMAGE_INFO *img_info, HRESULT *hresult) +{ -+ IWICBitmapFrameDecode *frame = NULL; + IWICImagingFactory *factory = NULL; + IWICDdsDecoder *dds_decoder = NULL; + IWICBitmapDecoder *decoder = NULL; + WICDdsParameters dds_params; + IWICStream *stream = NULL; -+ unsigned int frame_count; + GUID container_format; + HRESULT hr; + @@ -186,16 +184,6 @@ index 81ac8ee6db7..6881eec107d 100644 + goto end; + } + -+ hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); -+ if (FAILED(hr) || !frame_count) -+ goto end; -+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); -+ if (FAILED(hr)) -+ goto end; -+ hr = IWICBitmapFrameDecode_GetSize(frame, &img_info->Width, &img_info->Height); -+ if (FAILED(hr)) -+ goto end; -+ + if (img_info->ImageFileFormat == D3DX11_IFF_DDS) + { + hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICDdsDecoder, (void **)&dds_decoder); @@ -204,6 +192,8 @@ index 81ac8ee6db7..6881eec107d 100644 + hr = IWICDdsDecoder_GetParameters(dds_decoder, &dds_params); + if (FAILED(hr)) + goto end; ++ img_info->Width = dds_params.Width; ++ img_info->Height = dds_params.Height; + img_info->ArraySize = dds_params.ArraySize; + img_info->Depth = dds_params.Depth; + img_info->MipLevels = dds_params.MipLevels; @@ -218,6 +208,9 @@ index 81ac8ee6db7..6881eec107d 100644 + } + else + { ++ FIXME("Unsupported image format %d\n", img_info->ImageFileFormat); ++ img_info->Width = 1; ++ img_info->Height = 1; + img_info->ArraySize = 1; + img_info->Depth = 1; + img_info->MipLevels = 1; @@ -229,8 +222,6 @@ index 81ac8ee6db7..6881eec107d 100644 +end: + if (dds_decoder) + IWICDdsDecoder_Release(dds_decoder); -+ if (frame) -+ IWICBitmapFrameDecode_Release(frame); + if (decoder) + IWICBitmapDecoder_Release(decoder); + if (stream) @@ -250,5 +241,5 @@ index 81ac8ee6db7..6881eec107d 100644 SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11ShaderResourceView **view, HRESULT *hresult) -- -2.34.1 +2.40.1 diff --git a/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0002-d3dx11_42-Implement-D3DX11CreateTextureFromMemory.patch b/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0002-d3dx11_42-Implement-D3DX11CreateTextureFromMemory.patch index 5861e406..061c5adb 100644 --- a/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0002-d3dx11_42-Implement-D3DX11CreateTextureFromMemory.patch +++ b/patches/d3dx11_43-D3DX11CreateTextureFromMemory/0002-d3dx11_42-Implement-D3DX11CreateTextureFromMemory.patch @@ -1,15 +1,15 @@ -From 5be34c9e347d4379179eeba742b25986152d4e4f Mon Sep 17 00:00:00 2001 +From 7285c2c90f43cd46d873a2ddb65e9c6c9d63f750 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 3 Aug 2021 11:13:18 +1000 -Subject: [PATCH] d3dx11_42: Implement D3DX11CreateTextureFromMemory +Subject: [PATCH 2/2] d3dx11_42: Implement D3DX11CreateTextureFromMemory Signed-off-by: Alistair Leslie-Hughes --- - dlls/d3dx11_43/texture.c | 347 ++++++++++++++++++++++++++++++++++++++- - 1 file changed, 342 insertions(+), 5 deletions(-) + dlls/d3dx11_43/texture.c | 359 ++++++++++++++++++++++++++++++++++++++- + 1 file changed, 354 insertions(+), 5 deletions(-) diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c -index 6881eec107d..b91bd8d881a 100644 +index bbf937cdab0..10dedf30c0f 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -22,6 +22,7 @@ @@ -20,7 +20,7 @@ index 6881eec107d..b91bd8d881a 100644 WINE_DEFAULT_DEBUG_CHANNEL(d3dx); -@@ -43,6 +44,32 @@ file_formats[] = +@@ -43,6 +44,33 @@ file_formats[] = { &GUID_ContainerFormatWmp, D3DX11_IFF_WMP }, }; @@ -42,6 +42,7 @@ index 6881eec107d..b91bd8d881a 100644 + { &GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM }, + { &GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM }, + { &GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM }, ++ { &GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB }, + { &GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM }, + { &GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM }, + { &GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM }, @@ -53,7 +54,7 @@ index 6881eec107d..b91bd8d881a 100644 static D3DX11_IMAGE_FILE_FORMAT wic_container_guid_to_file_format(GUID *container_format) { unsigned int i; -@@ -95,6 +122,175 @@ static DXGI_FORMAT get_d3dx11_dds_format(DXGI_FORMAT format) +@@ -95,6 +123,175 @@ static DXGI_FORMAT get_d3dx11_dds_format(DXGI_FORMAT format) return format; } @@ -229,7 +230,7 @@ index 6881eec107d..b91bd8d881a 100644 HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump, D3DX11_IMAGE_INFO *img_info, HRESULT *hresult) { -@@ -229,14 +425,155 @@ HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *f +@@ -220,14 +417,166 @@ HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *f return E_NOTIMPL; } @@ -264,17 +265,28 @@ index 6881eec107d..b91bd8d881a 100644 + + if (!src_data || !src_data_size || !texture) + return E_FAIL; -+ if (load_info) -+ FIXME("load_info is ignored.\n"); + if (pump) + FIXME("Thread pump is not supported yet.\n"); + -+ if (FAILED(D3DX11GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL))) -+ return E_FAIL; -+ if (img_info.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) ++ if (load_info) + { -+ FIXME("Cube map is not supported.\n"); -+ return E_FAIL; ++ img_info.Width = load_info->Width; ++ img_info.Height = load_info->Height; ++ img_info.Depth = load_info->Depth; ++ img_info.ArraySize = 1; ++ img_info.MipLevels = load_info->MipLevels; ++ img_info.MiscFlags = load_info->MiscFlags; ++ img_info.Format = load_info->Format; ++ } ++ else ++ { ++ if (FAILED(D3DX11GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL))) ++ return E_FAIL; ++ if (img_info.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) ++ { ++ FIXME("Cube map is not supported.\n"); ++ return E_FAIL; ++ } + } + + if (FAILED(hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory))) @@ -391,5 +403,5 @@ index 6881eec107d..b91bd8d881a 100644 HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture, -- -2.34.1 +2.40.1