Rebase against e3c9d3ac76b223073253667e2447e1cbc407ac97.

This commit is contained in:
Elizabeth Figura
2025-09-11 17:44:08 -05:00
parent 3d1b6a4bc0
commit 317665ee20
5 changed files with 12 additions and 314 deletions

View File

@@ -1,245 +0,0 @@
From 0fbce9fe4b69f27b7df82c6517c364aab57de63b Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 30 Jul 2021 15:57:29 +1000
Subject: [PATCH 1/2] d3dx11_43: Implement D3DX11GetImageInfoFromMemory
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=50210
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/d3dx11_42/Makefile.in | 1 +
dlls/d3dx11_43/Makefile.in | 1 +
dlls/d3dx11_43/main.c | 9 --
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
--- a/dlls/d3dx11_42/Makefile.in
+++ b/dlls/d3dx11_42/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX11_SDK_VERSION=42
MODULE = d3dx11_42.dll
IMPORTLIB = d3dx11_42
IMPORTS = d3dcompiler
+DELAYIMPORTS = windowscodecs
PARENTSRC = ../d3dx11_43
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx11_43/Makefile.in b/dlls/d3dx11_43/Makefile.in
index ccd4319ace2..6854c73ebcb 100644
--- a/dlls/d3dx11_43/Makefile.in
+++ b/dlls/d3dx11_43/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX11_SDK_VERSION=43
MODULE = d3dx11_43.dll
IMPORTLIB = d3dx11
IMPORTS = d3dcompiler
+DELAYIMPORTS = windowscodecs
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx11_43/main.c b/dlls/d3dx11_43/main.c
index 5dad027864f..00c1db35e42 100644
--- a/dlls/d3dx11_43/main.c
+++ b/dlls/d3dx11_43/main.c
@@ -66,12 +66,3 @@ HRESULT WINAPI D3DX11GetImageInfoFromFileW(const WCHAR *filename, ID3DX11ThreadP
return E_NOTIMPL;
}
-
-HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump,
- D3DX11_IMAGE_INFO *img_info, HRESULT *hresult)
-{
- FIXME("src_data %p, src_data_size %Iu, pump %p, img_info %p, hresult %p stub!\n",
- src_data, src_data_size, pump, img_info, hresult);
-
- return E_NOTIMPL;
-}
diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c
index 81ac8ee6db7..bbf937cdab0 100644
--- a/dlls/d3dx11_43/texture.c
+++ b/dlls/d3dx11_43/texture.c
@@ -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
*/
+#define COBJMACROS
#include "d3dx11.h"
#include "d3dcompiler.h"
+#include "wincodec.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT sdk_version, IWICImagingFactory **imaging_factory);
+
+static const struct
+{
+ const GUID *wic_container_guid;
+ D3DX11_IMAGE_FILE_FORMAT d3dx_file_format;
+}
+file_formats[] =
+{
+ { &GUID_ContainerFormatBmp, D3DX11_IFF_BMP },
+ { &GUID_ContainerFormatJpeg, D3DX11_IFF_JPG },
+ { &GUID_ContainerFormatPng, D3DX11_IFF_PNG },
+ { &GUID_ContainerFormatDds, D3DX11_IFF_DDS },
+ { &GUID_ContainerFormatTiff, D3DX11_IFF_TIFF },
+ { &GUID_ContainerFormatGif, D3DX11_IFF_GIF },
+ { &GUID_ContainerFormatWmp, D3DX11_IFF_WMP },
+};
+
+static D3DX11_IMAGE_FILE_FORMAT wic_container_guid_to_file_format(GUID *container_format)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(file_formats); ++i)
+ {
+ if (IsEqualGUID(file_formats[i].wic_container_guid, container_format))
+ return file_formats[i].d3dx_file_format;
+ }
+ return D3DX11_IFF_FORCE_DWORD;
+}
+
+static D3D11_RESOURCE_DIMENSION wic_dimension_to_d3dx11_dimension(WICDdsDimension wic_dimension)
+{
+ switch (wic_dimension)
+ {
+ case WICDdsTexture1D:
+ return D3D11_RESOURCE_DIMENSION_TEXTURE1D;
+ case WICDdsTexture2D:
+ case WICDdsTextureCube:
+ return D3D11_RESOURCE_DIMENSION_TEXTURE2D;
+ case WICDdsTexture3D:
+ return D3D11_RESOURCE_DIMENSION_TEXTURE3D;
+ default:
+ return D3D11_RESOURCE_DIMENSION_UNKNOWN;
+ }
+}
+
+static const DXGI_FORMAT to_be_converted_format[] =
+{
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_R8_UNORM,
+ DXGI_FORMAT_R8G8_UNORM,
+ DXGI_FORMAT_B5G6R5_UNORM,
+ DXGI_FORMAT_B4G4R4A4_UNORM,
+ DXGI_FORMAT_B5G5R5A1_UNORM,
+ DXGI_FORMAT_B8G8R8X8_UNORM,
+ DXGI_FORMAT_B8G8R8A8_UNORM
+};
+
+static DXGI_FORMAT get_d3dx11_dds_format(DXGI_FORMAT format)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(to_be_converted_format); ++i)
+ {
+ if (format == to_be_converted_format[i])
+ return DXGI_FORMAT_R8G8B8A8_UNORM;
+ }
+ return format;
+}
+
+HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump,
+ D3DX11_IMAGE_INFO *img_info, HRESULT *hresult)
+{
+ IWICImagingFactory *factory = NULL;
+ IWICDdsDecoder *dds_decoder = NULL;
+ IWICBitmapDecoder *decoder = NULL;
+ WICDdsParameters dds_params;
+ IWICStream *stream = NULL;
+ GUID container_format;
+ HRESULT hr;
+
+ TRACE("src_data %p, src_data_size %Iu, pump %p, img_info %p, hresult %p.\n",
+ src_data, src_data_size, pump, img_info, hresult);
+
+ if (!src_data || !src_data_size || !img_info)
+ return E_FAIL;
+ if (pump)
+ FIXME("Thread pump is not supported yet.\n");
+
+ WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
+ IWICImagingFactory_CreateStream(factory, &stream);
+ hr = IWICStream_InitializeFromMemory(stream, (BYTE *)src_data, src_data_size);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize stream.\n");
+ goto end;
+ }
+ hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream *)stream, NULL, 0, &decoder);
+ if (FAILED(hr))
+ goto end;
+
+ hr = IWICBitmapDecoder_GetContainerFormat(decoder, &container_format);
+ if (FAILED(hr))
+ goto end;
+ img_info->ImageFileFormat = wic_container_guid_to_file_format(&container_format);
+ if (img_info->ImageFileFormat == D3DX11_IFF_FORCE_DWORD)
+ {
+ hr = E_FAIL;
+ WARN("Unsupported image file format %s.\n", debugstr_guid(&container_format));
+ goto end;
+ }
+
+ if (img_info->ImageFileFormat == D3DX11_IFF_DDS)
+ {
+ hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICDdsDecoder, (void **)&dds_decoder);
+ if (FAILED(hr))
+ goto end;
+ 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;
+ img_info->ResourceDimension = wic_dimension_to_d3dx11_dimension(dds_params.Dimension);
+ img_info->Format = get_d3dx11_dds_format(dds_params.DxgiFormat);
+ img_info->MiscFlags = 0;
+ if (dds_params.Dimension == WICDdsTextureCube)
+ {
+ img_info->MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
+ img_info->ArraySize *= 6;
+ }
+ }
+ 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;
+ img_info->ResourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
+ img_info->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ img_info->MiscFlags = 0;
+ }
+
+end:
+ if (dds_decoder)
+ IWICDdsDecoder_Release(dds_decoder);
+ if (decoder)
+ IWICBitmapDecoder_Release(decoder);
+ if (stream)
+ IWICStream_Release(stream);
+ if (factory)
+ IWICImagingFactory_Release(factory);
+
+ if (hr != S_OK)
+ {
+ WARN("Invalid or unsupported image file.\n");
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
HRESULT WINAPI D3DX11CreateShaderResourceViewFromMemory(ID3D11Device *device, const void *data,
SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump,
ID3D11ShaderResourceView **view, HRESULT *hresult)
--
2.40.1

View File

@@ -1,56 +0,0 @@
From 30d677139afe2af3f72c68ba11f1bbaead6f1c11 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 2 Aug 2023 08:24:11 +1000
Subject: [PATCH] d3dx11_43: D3DX11GetImageInfoFromMemory - Only use frame for
non DDS images
---
dlls/d3dx11_43/texture.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c
index 10dedf30c0f..f3f7d350131 100644
--- a/dlls/d3dx11_43/texture.c
+++ b/dlls/d3dx11_43/texture.c
@@ -295,6 +295,7 @@ static const GUID *dxgi_format_to_wic_guid(DXGI_FORMAT format)
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;
@@ -358,9 +359,18 @@ HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_dat
}
else
{
- FIXME("Unsupported image format %d\n", img_info->ImageFileFormat);
- img_info->Width = 1;
- img_info->Height = 1;
+ unsigned int frame_count;
+
+ 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;
+
img_info->ArraySize = 1;
img_info->Depth = 1;
img_info->MipLevels = 1;
@@ -372,6 +382,8 @@ HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_dat
end:
if (dds_decoder)
IWICDdsDecoder_Release(dds_decoder);
+ if (frame)
+ IWICBitmapFrameDecode_Release(frame);
if (decoder)
IWICBitmapDecoder_Release(decoder);
if (stream)
--
2.40.1

View File

@@ -1,4 +1,3 @@
Fixes: [50210] - Implement D3DX11GetImageInfoFromMemory
Fixes: [45533] - Implement D3DX11CreateTextureFromMemory
# This patchset will need to wait until the new wined3dx dll implemented.
Disabled: true

View File

@@ -1,4 +1,4 @@
From 82663e728099ca8f0127dcdf8d62d551eda6902c Mon Sep 17 00:00:00 2001
From 03ed95b629a5d5a9b1a8203e08d7db4ce1ed80d9 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 28 Apr 2016 18:14:36 +0800
Subject: [PATCH] ntdll: Implement NtSetLdtEntries.
@@ -9,10 +9,10 @@ Subject: [PATCH] ntdll: Implement NtSetLdtEntries.
2 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 3cf58d928ae..78f9bbeb493 100644
index c0303b471e8..9025d66fba6 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -102,6 +102,7 @@ static HRESULT (WINAPI *pSetThreadDescription)(HANDLE,const WCHAR *);
@@ -103,6 +103,7 @@ static HRESULT (WINAPI *pSetThreadDescription)(HANDLE,const WCHAR *);
static HRESULT (WINAPI *pGetThreadDescription)(HANDLE,WCHAR **);
static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG,PVECTORED_EXCEPTION_HANDLER);
static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
@@ -20,7 +20,7 @@ index 3cf58d928ae..78f9bbeb493 100644
static HANDLE create_target_process(const char *arg)
{
@@ -1299,6 +1300,82 @@ static void test_GetThreadSelectorEntry(void)
@@ -1319,6 +1320,82 @@ static void test_GetThreadSelectorEntry(void)
ok(entry.HighWord.Bits.Granularity == 1, "expected 1, got %u\n", entry.HighWord.Bits.Granularity);
}
@@ -103,7 +103,7 @@ index 3cf58d928ae..78f9bbeb493 100644
#endif /* __i386__ */
static HANDLE finish_event;
@@ -2617,6 +2694,7 @@ static void init_funcs(void)
@@ -2644,6 +2721,7 @@ static void init_funcs(void)
X(NtSetInformationThread);
X(RtlAddVectoredExceptionHandler);
X(RtlRemoveVectoredExceptionHandler);
@@ -111,7 +111,7 @@ index 3cf58d928ae..78f9bbeb493 100644
}
#undef X
}
@@ -2673,6 +2751,7 @@ START_TEST(thread)
@@ -2700,6 +2778,7 @@ START_TEST(thread)
test_SetThreadContext();
test_GetThreadSelectorEntry();
test_GetThreadContext();
@@ -120,12 +120,12 @@ index 3cf58d928ae..78f9bbeb493 100644
test_QueueUserWorkItem();
test_RegisterWaitForSingleObject();
diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
index f8d8dd9bf28..194e9c3f3e6 100644
index 670a3c25015..b4a2392630f 100644
--- a/dlls/ntdll/unix/signal_i386.c
+++ b/dlls/ntdll/unix/signal_i386.c
@@ -2207,7 +2207,7 @@ NTSTATUS get_thread_ldt_entry( HANDLE handle, void *data, ULONG len, ULONG *ret_
@@ -2271,7 +2271,7 @@ NTSTATUS get_thread_ldt_entry( HANDLE handle, void *data, ULONG len, ULONG *ret_
if (reply->flags)
info->Entry = ldt_make_entry( (void *)reply->base, reply->limit, reply->flags );
info->Entry = ldt_make_entry( reply->base, reply->limit, reply->flags );
else
- status = STATUS_UNSUCCESSFUL;
+ status = STATUS_ACCESS_VIOLATION;
@@ -133,5 +133,5 @@ index f8d8dd9bf28..194e9c3f3e6 100644
}
SERVER_END_REQ;
--
2.34.1
2.50.1