winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
June 2024
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
613 discussions
Start a n
N
ew thread
Rémi Bernon : winex11: Don't use the vulkan driver interface for xrandr.
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 96d294aa123497d3c5b0611d9de4787e3eb7fc6a URL:
https://gitlab.winehq.org/wine/wine/-/commit/96d294aa123497d3c5b0611d9de478…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Jun 4 16:45:45 2024 +0200 winex11: Don't use the vulkan driver interface for xrandr. --- dlls/winex11.drv/xrandr.c | 56 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 74b975e8671..edad0712927 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -49,6 +49,8 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag); #include "wine/vulkan_driver.h" static void *xrandr_handle; +static void *vulkan_handle; +static void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *); #define MAKE_FUNCPTR(f) static typeof(f) * p##f; MAKE_FUNCPTR(XRRConfigCurrentConfiguration) @@ -136,6 +138,45 @@ sym_not_found: return r; } +#ifdef SONAME_LIBVULKAN + +static void vulkan_init_once(void) +{ + if (!(vulkan_handle = dlopen( SONAME_LIBVULKAN, RTLD_NOW ))) + { + ERR( "Failed to load %s\n", SONAME_LIBVULKAN ); + return; + } + +#define LOAD_FUNCPTR( f ) \ + if (!(p_##f = dlsym( vulkan_handle, #f ))) \ + { \ + ERR( "Failed to find " #f "\n" ); \ + dlclose( vulkan_handle ); \ + vulkan_handle = NULL; \ + return; \ + } + + LOAD_FUNCPTR( vkGetInstanceProcAddr ); +#undef LOAD_FUNCPTR +} + +#else /* SONAME_LIBVULKAN */ + +static void vulkan_init_once(void) +{ + ERR( "Wine was built without Vulkan support.\n" ); +} + +#endif /* SONAME_LIBVULKAN */ + +static BOOL vulkan_init(void) +{ + static pthread_once_t init_once = PTHREAD_ONCE_INIT; + pthread_once( &init_once, vulkan_init_once ); + return !!vulkan_handle; +} + static int XRandRErrorHandler(Display *dpy, XErrorEvent *event, void *arg) { return 1; @@ -641,11 +682,11 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro "VK_KHR_display", VK_KHR_SURFACE_EXTENSION_NAME, }; - const struct vulkan_funcs *vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ); VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * ); PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR; PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices; uint32_t device_count, device_idx, output_idx, i; + PFN_vkDestroyInstance pvkDestroyInstance = NULL; VkPhysicalDevice *vk_physical_devices = NULL; VkPhysicalDeviceProperties2 properties2; PFN_vkCreateInstance pvkCreateInstance; @@ -656,8 +697,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro BOOL ret = FALSE; VkResult vr; - if (!vulkan_funcs) - goto done; + if (!vulkan_init()) goto done; memset( &create_info, 0, sizeof(create_info) ); create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; @@ -665,7 +705,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro create_info.ppEnabledExtensionNames = extensions; #define LOAD_VK_FUNC(f) \ - if (!(p##f = (void *)vulkan_funcs->p_vkGetInstanceProcAddr( vk_instance, #f ))) \ + if (!(p##f = (void *)p_vkGetInstanceProcAddr( vk_instance, #f ))) \ { \ WARN("Failed to load " #f ".\n"); \ goto done; \ @@ -683,6 +723,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro LOAD_VK_FUNC(vkEnumeratePhysicalDevices) LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2KHR) LOAD_VK_FUNC(vkGetRandROutputDisplayEXT) + LOAD_VK_FUNC(vkDestroyInstance) #undef LOAD_VK_FUNC vr = pvkEnumeratePhysicalDevices( vk_instance, &device_count, NULL ); @@ -747,12 +788,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro done: free( vk_physical_devices ); - if (vk_instance) - { - PFN_vkDestroyInstance p_vkDestroyInstance; - p_vkDestroyInstance = vulkan_funcs->p_vkGetInstanceProcAddr( vk_instance, "vkDestroyInstance" ); - p_vkDestroyInstance( vk_instance, NULL ); - } + if (vk_instance && pvkDestroyInstance) pvkDestroyInstance( vk_instance, NULL ); return ret; }
1
0
0
0
Rémi Bernon : win32u: Use the vulkan functions directly from d3dkmt.
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 2c4db92151030ed00b780b51bfb367b8c122285d URL:
https://gitlab.winehq.org/wine/wine/-/commit/2c4db92151030ed00b780b51bfb367…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Wed Jun 12 10:49:54 2024 +0200 win32u: Use the vulkan functions directly from d3dkmt. --- dlls/win32u/d3dkmt.c | 9 ++++---- dlls/win32u/ntuser_private.h | 5 +++++ dlls/win32u/vulkan.c | 51 +++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/dlls/win32u/d3dkmt.c b/dlls/win32u/d3dkmt.c index 5f3804c165d..a97ab5d3c33 100644 --- a/dlls/win32u/d3dkmt.c +++ b/dlls/win32u/d3dkmt.c @@ -28,6 +28,7 @@ #define WIN32_NO_STATUS #include "ntgdi_private.h" #include "win32u_private.h" +#include "ntuser_private.h" #include "wine/vulkan.h" #include "wine/vulkan_driver.h" @@ -83,13 +84,13 @@ static void d3dkmt_init_vulkan(void) PFN_vkCreateInstance p_vkCreateInstance; VkResult vr; - if (!(vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ))) + if (!vulkan_init()) { WARN( "Failed to open the Vulkan driver\n" ); return; } - p_vkCreateInstance = vulkan_funcs->p_vkGetInstanceProcAddr( NULL, "vkCreateInstance" ); + p_vkCreateInstance = p_vkGetInstanceProcAddr( NULL, "vkCreateInstance" ); if ((vr = p_vkCreateInstance( &create_info, NULL, &d3dkmt_vk_instance ))) { WARN( "Failed to create a Vulkan instance, vr %d.\n", vr ); @@ -97,9 +98,9 @@ static void d3dkmt_init_vulkan(void) return; } - p_vkDestroyInstance = vulkan_funcs->p_vkGetInstanceProcAddr( d3dkmt_vk_instance, "vkDestroyInstance" ); + p_vkDestroyInstance = p_vkGetInstanceProcAddr( d3dkmt_vk_instance, "vkDestroyInstance" ); #define LOAD_VK_FUNC( f ) \ - if (!(p##f = (void *)vulkan_funcs->p_vkGetInstanceProcAddr( d3dkmt_vk_instance, #f ))) \ + if (!(p##f = (void *)p_vkGetInstanceProcAddr( d3dkmt_vk_instance, #f ))) \ { \ WARN( "Failed to load " #f ".\n" ); \ p_vkDestroyInstance( d3dkmt_vk_instance, NULL ); \ diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 020c98005df..62e65d71d31 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -25,6 +25,7 @@ #include "ntuser.h" #include "shellapi.h" #include "wine/list.h" +#include "wine/vulkan.h" #define WM_POPUPSYSTEMMENU 0x0313 @@ -250,6 +251,10 @@ extern int peek_message( MSG *msg, const struct peek_message_filter *filter ); extern LRESULT system_tray_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, void *data ); /* vulkan.c */ +extern void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *); +extern void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *); + +extern BOOL vulkan_init(void); extern void vulkan_detach_surfaces( struct list *surfaces ); /* window.c */ diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 5b128afe3cb..471a4459ec3 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -39,16 +39,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); -#ifdef SONAME_LIBVULKAN +void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *) = NULL; +void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *) = NULL; static void *vulkan_handle; -static const struct vulkan_driver_funcs *driver_funcs; static struct vulkan_funcs vulkan_funcs; +#ifdef SONAME_LIBVULKAN + +static const struct vulkan_driver_funcs *driver_funcs; + static void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *); static VkResult (*p_vkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *); -static void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *); -static void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *); struct surface { @@ -283,7 +285,7 @@ static const struct vulkan_driver_funcs lazydrv_funcs = .p_vulkan_surface_presented = lazydrv_vulkan_surface_presented, }; -static void vulkan_init(void) +static void vulkan_init_once(void) { if (!(vulkan_handle = dlopen( SONAME_LIBVULKAN, RTLD_NOW ))) { @@ -323,27 +325,24 @@ void vulkan_detach_surfaces( struct list *surfaces ) } } -/*********************************************************************** - * __wine_get_vulkan_driver (win32u.so) - */ -const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version ) -{ - static pthread_once_t init_once = PTHREAD_ONCE_INIT; +#else /* SONAME_LIBVULKAN */ - if (version != WINE_VULKAN_DRIVER_VERSION) - { - ERR( "version mismatch, vulkan wants %u but win32u has %u\n", version, WINE_VULKAN_DRIVER_VERSION ); - return NULL; - } +void vulkan_detach_surfaces( struct list *surfaces ) +{ +} - pthread_once( &init_once, vulkan_init ); - return vulkan_handle ? &vulkan_funcs : NULL; +static void vulkan_init_once(void) +{ + ERR( "Wine was built without Vulkan support.\n" ); } -#else /* SONAME_LIBVULKAN */ +#endif /* SONAME_LIBVULKAN */ -void vulkan_detach_surfaces( struct list *surfaces ) +BOOL vulkan_init(void) { + static pthread_once_t init_once = PTHREAD_ONCE_INIT; + pthread_once( &init_once, vulkan_init_once ); + return !!vulkan_handle; } /*********************************************************************** @@ -351,8 +350,12 @@ void vulkan_detach_surfaces( struct list *surfaces ) */ const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version ) { - ERR("Wine was built without Vulkan support.\n"); - return NULL; -} + if (version != WINE_VULKAN_DRIVER_VERSION) + { + ERR( "version mismatch, vulkan wants %u but win32u has %u\n", version, WINE_VULKAN_DRIVER_VERSION ); + return NULL; + } -#endif /* SONAME_LIBVULKAN */ + if (!vulkan_init()) return NULL; + return &vulkan_funcs; +}
1
0
0
0
Connor McAdams : d3dx9: Add support for specifying which mip level to get pixel data from to d3dx_image_get_pixels().
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 1215ee024148952525317cc104ce91e650f21ca3 URL:
https://gitlab.winehq.org/wine/wine/-/commit/1215ee024148952525317cc104ce91…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Wed Jun 5 11:11:59 2024 -0400 d3dx9: Add support for specifying which mip level to get pixel data from to d3dx_image_get_pixels(). Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/d3dx9_private.h | 4 +-- dlls/d3dx9_36/surface.c | 72 ++++++++++++++++--------------------------- dlls/d3dx9_36/tests/texture.c | 20 ++++++------ dlls/d3dx9_36/texture.c | 48 +++++++++++++++-------------- 4 files changed, 62 insertions(+), 82 deletions(-)
1
0
0
0
Connor McAdams : d3dx9: Cleanup texture value argument handling in D3DXCreateTextureFromFileInMemoryEx().
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: be746bee64b76931240429ad64b6fdbf79ec9733 URL:
https://gitlab.winehq.org/wine/wine/-/commit/be746bee64b76931240429ad64b6fd…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Wed Jun 5 11:29:31 2024 -0400 d3dx9: Cleanup texture value argument handling in D3DXCreateTextureFromFileInMemoryEx(). Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/texture.c | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 12702c0ca49..f8b4a7795f7 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -598,43 +598,15 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi d3dximage_info_from_d3dx_image(&imginfo, &image); /* handle default values */ - if (width == 0 || width == D3DX_DEFAULT_NONPOW2) - width = imginfo.Width; - - if (height == 0 || height == D3DX_DEFAULT_NONPOW2) - height = imginfo.Height; - - if (width == D3DX_DEFAULT) - width = make_pow2(imginfo.Width); - - if (height == D3DX_DEFAULT) - height = make_pow2(imginfo.Height); - - if (format == D3DFMT_UNKNOWN || format == D3DX_DEFAULT) - format = imginfo.Format; - else - format_specified = TRUE; - - if (width == D3DX_FROM_FILE) - { - width = imginfo.Width; - } + if (!width || width == D3DX_DEFAULT_NONPOW2 || width == D3DX_FROM_FILE || width == D3DX_DEFAULT) + width = (width == D3DX_DEFAULT) ? make_pow2(imginfo.Width) : imginfo.Width; + if (!height || height == D3DX_DEFAULT_NONPOW2 || height == D3DX_FROM_FILE || height == D3DX_DEFAULT) + height = (height == D3DX_DEFAULT) ? make_pow2(imginfo.Height) : imginfo.Height; - if (height == D3DX_FROM_FILE) - { - height = imginfo.Height; - } - - if (format == D3DFMT_FROM_FILE) - { + format_specified = (format != D3DFMT_UNKNOWN && format != D3DX_DEFAULT); + if (format == D3DFMT_FROM_FILE || format == D3DFMT_UNKNOWN || format == D3DX_DEFAULT) format = imginfo.Format; - } - - if (miplevels == D3DX_FROM_FILE) - { - miplevels = imginfo.MipLevels; - } - + miplevels = (miplevels == D3DX_FROM_FILE) ? imginfo.MipLevels : miplevels; /* Fix up texture creation parameters. */ hr = D3DXCheckTextureRequirements(device, &width, &height, &miplevels, usage, &format, pool);
1
0
0
0
Connor McAdams : d3dx9: Add support for specifying a starting mip level when initializing a d3dx_image structure.
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 86a87b040344593503ba993f3fa15e9a2d08360a URL:
https://gitlab.winehq.org/wine/wine/-/commit/86a87b040344593503ba993f3fa15e…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Wed Jun 5 10:03:18 2024 -0400 d3dx9: Add support for specifying a starting mip level when initializing a d3dx_image structure. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/d3dx9_private.h | 8 ++-- dlls/d3dx9_36/surface.c | 101 ++++++++++++++++++++++++------------------ dlls/d3dx9_36/tests/texture.c | 11 +++-- dlls/d3dx9_36/texture.c | 20 ++------- 4 files changed, 70 insertions(+), 70 deletions(-)
1
0
0
0
Connor McAdams : d3dx9: Use struct volume inside of struct d3dx_image for storing dimensions.
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 8d4024ca7e5358c1d6fcdb3f6d4b432d048232e9 URL:
https://gitlab.winehq.org/wine/wine/-/commit/8d4024ca7e5358c1d6fcdb3f6d4b43…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Wed Jun 5 13:13:44 2024 -0400 d3dx9: Use struct volume inside of struct d3dx_image for storing dimensions. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/d3dx9_private.h | 4 +--- dlls/d3dx9_36/surface.c | 36 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 5c9d1a0ddad..52475aa3025 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -104,9 +104,7 @@ struct d3dx_image D3DRESOURCETYPE resource_type; D3DFORMAT format; - uint32_t width; - uint32_t height; - uint32_t depth; + struct volume size; uint32_t mip_levels; BYTE *pixels; diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 69eb9d3058b..5fe0d0416c1 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -743,9 +743,7 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src return D3DXERR_INVALIDDATA; TRACE("File type is DDS.\n"); - image->width = header->width; - image->height = header->height; - image->depth = 1; + set_volume_struct(&image->size, header->width, header->height, 1); image->mip_levels = header->miplevels ? header->miplevels : 1; image->format = dds_pixel_format_to_d3dformat(&header->pixel_format); @@ -755,7 +753,7 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src TRACE("Pixel format is %#x.\n", image->format); if (header->caps2 & DDS_CAPS2_VOLUME) { - image->depth = header->depth; + image->size.depth = header->depth; image->resource_type = D3DRTYPE_VOLUMETEXTURE; } else if (header->caps2 & DDS_CAPS2_CUBEMAP) @@ -773,8 +771,8 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src else image->resource_type = D3DRTYPE_TEXTURE; - expected_src_data_size = calculate_dds_file_size(image->format, image->width, image->height, - image->depth, image->mip_levels, faces); + expected_src_data_size = calculate_dds_file_size(image->format, image->size.width, image->size.height, + image->size.depth, image->mip_levels, faces); if (src_data_size < expected_src_data_size) { WARN("File is too short %u, expected at least %u bytes.\n", src_data_size, expected_src_data_size); @@ -863,18 +861,18 @@ static BOOL image_is_argb(IWICBitmapFrameDecode *frame, struct d3dx_image *image && image->image_file_format != D3DXIFF_TGA)) return FALSE; - size = image->width * image->height * 4; + size = image->size.width * image->size.height * 4; if (!(buffer = malloc(size))) return FALSE; - if (FAILED(hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, image->width * 4, size, buffer))) + if (FAILED(hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, image->size.width * 4, size, buffer))) { ERR("Failed to copy pixels, hr %#lx.\n", hr); free(buffer); return FALSE; } - for (i = 0; i < image->width * image->height; ++i) + for (i = 0; i < image->size.width * image->size.height; ++i) { if (buffer[i * 4 + 3]) { @@ -952,7 +950,7 @@ static HRESULT d3dx_image_wic_frame_decode(struct d3dx_image *image, HRESULT hr; fmt_desc = get_format_info(image->format); - hr = d3dx_calculate_pixels_size(image->format, image->width, image->height, &row_pitch, &slice_pitch); + hr = d3dx_calculate_pixels_size(image->format, image->size.width, image->size.height, &row_pitch, &slice_pitch); if (FAILED(hr)) return hr; @@ -1088,7 +1086,7 @@ static HRESULT d3dx_initialize_image_from_wic(const void *src_data, uint32_t src if (FAILED(hr)) goto exit; - hr = IWICBitmapFrameDecode_GetSize(bitmap_frame, &image->width, &image->height); + hr = IWICBitmapFrameDecode_GetSize(bitmap_frame, &image->size.width, &image->size.height); if (FAILED(hr)) goto exit; @@ -1113,7 +1111,7 @@ static HRESULT d3dx_initialize_image_from_wic(const void *src_data, uint32_t src goto exit; } - image->depth = 1; + image->size.depth = 1; image->mip_levels = 1; image->resource_type = D3DRTYPE_TEXTURE; @@ -1156,13 +1154,13 @@ HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixels *pixe RECT unaligned_rect; HRESULT hr = S_OK; - hr = d3dx_calculate_pixels_size(image->format, image->width, image->height, &row_pitch, &slice_pitch); + hr = d3dx_calculate_pixels_size(image->format, image->size.width, image->size.height, &row_pitch, &slice_pitch); if (FAILED(hr)) return hr; - SetRect(&unaligned_rect, 0, 0, image->width, image->height); - set_d3dx_pixels(pixels, image->pixels, row_pitch, slice_pitch, image->palette, image->width, image->height, - image->depth, &unaligned_rect); + SetRect(&unaligned_rect, 0, 0, image->size.width, image->size.height); + set_d3dx_pixels(pixels, image->pixels, row_pitch, slice_pitch, image->palette, image->size.width, image->size.height, + image->size.depth, &unaligned_rect); return D3D_OK; } @@ -1170,9 +1168,9 @@ HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixels *pixe void d3dximage_info_from_d3dx_image(D3DXIMAGE_INFO *info, struct d3dx_image *image) { info->ImageFileFormat = image->image_file_format; - info->Width = image->width; - info->Height = image->height; - info->Depth = image->depth; + info->Width = image->size.width; + info->Height = image->size.height; + info->Depth = image->size.depth; info->MipLevels = image->mip_levels; info->Format = image->format; info->ResourceType = image->resource_type;
1
0
0
0
Connor McAdams : d3dx9: Use d3dx_image structure inside of D3DXCreateTextureFromFileInMemoryEx().
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: f89b00c8785c60caa0fea23277d9384461e44b05 URL:
https://gitlab.winehq.org/wine/wine/-/commit/f89b00c8785c60caa0fea23277d938…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Mon Jun 3 13:21:25 2024 -0400 d3dx9: Use d3dx_image structure inside of D3DXCreateTextureFromFileInMemoryEx(). Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/d3dx9_private.h | 5 +++++ dlls/d3dx9_36/surface.c | 9 ++++----- dlls/d3dx9_36/texture.c | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 001a7f26f4f..5c9d1a0ddad 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -122,6 +122,11 @@ struct d3dx_image D3DXIMAGE_FILEFORMAT image_file_format; }; +HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, struct d3dx_image *image, uint32_t flags); +void d3dx_image_cleanup(struct d3dx_image *image); +HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixels *pixels); +void d3dximage_info_from_d3dx_image(D3DXIMAGE_INFO *info, struct d3dx_image *image); + struct d3dx_include_from_file { ID3DXInclude ID3DXInclude_iface; diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index dd84528a0d5..69eb9d3058b 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1132,8 +1132,7 @@ exit: return hr; } -static HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, - struct d3dx_image *image, uint32_t flags) +HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, struct d3dx_image *image, uint32_t flags) { if (!src_data || !src_data_size || !image) return D3DERR_INVALIDCALL; @@ -1145,13 +1144,13 @@ static HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, return d3dx_initialize_image_from_wic(src_data, src_data_size, image, flags); } -static void d3dx_image_cleanup(struct d3dx_image *image) +void d3dx_image_cleanup(struct d3dx_image *image) { free(image->image_buf); free(image->palette); } -static HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixels *pixels) +HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixels *pixels) { uint32_t row_pitch, slice_pitch; RECT unaligned_rect; @@ -1168,7 +1167,7 @@ static HRESULT d3dx_image_get_pixels(struct d3dx_image *image, struct d3dx_pixel return D3D_OK; } -static void d3dximage_info_from_d3dx_image(D3DXIMAGE_INFO *info, struct d3dx_image *image) +void d3dximage_info_from_d3dx_image(D3DXIMAGE_INFO *info, struct d3dx_image *image) { info->ImageFileFormat = image->image_file_format; info->Width = image->width; diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 3cae679e0dd..29358a92fd8 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -571,6 +571,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi unsigned int loaded_miplevels, skip_levels; IDirect3DTexture9 *staging_tex, *tex; IDirect3DSurface9 *surface; + struct d3dx_image image; D3DXIMAGE_INFO imginfo; D3DCAPS9 caps; HRESULT hr; @@ -586,13 +587,15 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi return D3DERR_INVALIDCALL; staging_tex = tex = *texture = NULL; - hr = D3DXGetImageInfoFromFileInMemory(srcdata, srcdatasize, &imginfo); + hr = d3dx_image_init(srcdata, srcdatasize, &image, 0); if (FAILED(hr)) { FIXME("Unrecognized file format, returning failure.\n"); return hr; } + d3dximage_info_from_d3dx_image(&imginfo, &image); + /* handle default values */ if (width == 0 || width == D3DX_DEFAULT_NONPOW2) width = imginfo.Width; @@ -692,8 +695,16 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi TRACE("Texture created correctly. Now loading the texture data into it.\n"); if (imginfo.ImageFileFormat != D3DXIFF_DDS) { + const RECT src_rect = { 0, 0, imginfo.Width, imginfo.Height }; + struct d3dx_pixels pixels; + + hr = d3dx_image_get_pixels(&image, &pixels); + if (FAILED(hr)) + goto err; + IDirect3DTexture9_GetSurfaceLevel(tex, 0, &surface); - hr = D3DXLoadSurfaceFromFileInMemory(surface, palette, NULL, srcdata, srcdatasize, NULL, filter, colorkey, NULL); + hr = D3DXLoadSurfaceFromMemory(surface, palette, NULL, pixels.data, imginfo.Format, + pixels.row_pitch, pixels.palette, &src_rect, filter, colorkey); IDirect3DSurface9_Release(surface); loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(tex), imginfo.MipLevels); } @@ -731,12 +742,14 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi *texture = tex; } + d3dx_image_cleanup(&image); if (srcinfo) *srcinfo = imginfo; return hr; err: + d3dx_image_cleanup(&image); if (tex) IDirect3DTexture9_Release(tex);
1
0
0
0
Connor McAdams : d3dx9: Refactor texture creation and cleanup in D3DXCreateTextureFromFileInMemoryEx().
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: fd2861252ce486e50fc7a8a965f35ccb3b4a4f08 URL:
https://gitlab.winehq.org/wine/wine/-/commit/fd2861252ce486e50fc7a8a965f35c…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Mon Jun 3 13:06:33 2024 -0400 d3dx9: Refactor texture creation and cleanup in D3DXCreateTextureFromFileInMemoryEx(). Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/texture.c | 65 +++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 52cfb1e8c34..3cae679e0dd 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -569,9 +569,8 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi { BOOL dynamic_texture, format_specified = FALSE; unsigned int loaded_miplevels, skip_levels; + IDirect3DTexture9 *staging_tex, *tex; IDirect3DSurface9 *surface; - IDirect3DTexture9 **texptr; - IDirect3DTexture9 *buftex; D3DXIMAGE_INFO imginfo; D3DCAPS9 caps; HRESULT hr; @@ -586,11 +585,11 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi if (!device || !texture || !srcdata || !srcdatasize) return D3DERR_INVALIDCALL; + staging_tex = tex = *texture = NULL; hr = D3DXGetImageInfoFromFileInMemory(srcdata, srcdatasize, &imginfo); if (FAILED(hr)) { FIXME("Unrecognized file format, returning failure.\n"); - *texture = NULL; return hr; } @@ -652,8 +651,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi if (FAILED(hr)) { FIXME("Couldn't find suitable texture parameters.\n"); - *texture = NULL; - return hr; + goto err; } if (colorkey && !format_specified) @@ -667,79 +665,82 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi } if (FAILED(IDirect3DDevice9_GetDeviceCaps(device, &caps))) - return D3DERR_INVALIDCALL; + { + hr = D3DERR_INVALIDCALL; + goto err; + } /* Create the to-be-filled texture */ dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC); if (pool == D3DPOOL_DEFAULT && !dynamic_texture) { - hr = D3DXCreateTexture(device, width, height, miplevels, 0, format, D3DPOOL_SYSTEMMEM, &buftex); - texptr = &buftex; + TRACE("Creating staging texture.\n"); + hr = D3DXCreateTexture(device, width, height, miplevels, 0, format, D3DPOOL_SYSTEMMEM, &staging_tex); + tex = staging_tex; } else { - hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, texture); - texptr = texture; + hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, &tex); } if (FAILED(hr)) { FIXME("Texture creation failed.\n"); - *texture = NULL; - return hr; + goto err; } TRACE("Texture created correctly. Now loading the texture data into it.\n"); if (imginfo.ImageFileFormat != D3DXIFF_DDS) { - IDirect3DTexture9_GetSurfaceLevel(*texptr, 0, &surface); + IDirect3DTexture9_GetSurfaceLevel(tex, 0, &surface); hr = D3DXLoadSurfaceFromFileInMemory(surface, palette, NULL, srcdata, srcdatasize, NULL, filter, colorkey, NULL); IDirect3DSurface9_Release(surface); - loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(*texptr), imginfo.MipLevels); + loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(tex), imginfo.MipLevels); } else { - hr = load_texture_from_dds(*texptr, srcdata, palette, filter, colorkey, &imginfo, skip_levels, + hr = load_texture_from_dds(tex, srcdata, palette, filter, colorkey, &imginfo, skip_levels, &loaded_miplevels); } if (FAILED(hr)) { FIXME("Texture loading failed.\n"); - IDirect3DTexture9_Release(*texptr); - *texture = NULL; - return hr; + goto err; } - hr = D3DXFilterTexture((IDirect3DBaseTexture9*) *texptr, palette, loaded_miplevels - 1, mipfilter); + hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, palette, loaded_miplevels - 1, mipfilter); if (FAILED(hr)) { FIXME("Texture filtering failed.\n"); - IDirect3DTexture9_Release(*texptr); - *texture = NULL; - return hr; + goto err; } /* Move the data to the actual texture if necessary */ - if (texptr == &buftex) + if (staging_tex) { hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, texture); - if (FAILED(hr)) - { - IDirect3DTexture9_Release(buftex); - *texture = NULL; - return hr; - } + goto err; - IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9*)buftex, (IDirect3DBaseTexture9*)(*texture)); - IDirect3DTexture9_Release(buftex); + IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)staging_tex, (IDirect3DBaseTexture9 *)(*texture)); + IDirect3DTexture9_Release(staging_tex); + } + else + { + *texture = tex; } if (srcinfo) *srcinfo = imginfo; - return D3D_OK; + return hr; + +err: + if (tex) + IDirect3DTexture9_Release(tex); + + return hr; } HRESULT WINAPI D3DXCreateTextureFromFileInMemory(struct IDirect3DDevice9 *device,
1
0
0
0
Connor McAdams : d3dx9/tests: Add more tests for loading files with multiple mip levels into textures.
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: acf797f669e63aef3683de6069b467792736237d URL:
https://gitlab.winehq.org/wine/wine/-/commit/acf797f669e63aef3683de6069b467…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Mon Jun 3 09:45:11 2024 -0400 d3dx9/tests: Add more tests for loading files with multiple mip levels into textures. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/tests/texture.c | 336 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 333 insertions(+), 3 deletions(-)
1
0
0
0
Connor McAdams : d3dx9/tests: Add tests for the source info argument of D3DXCreateTextureFromFileInMemoryEx().
by Alexandre Julliard
18 Jun '24
18 Jun '24
Module: wine Branch: master Commit: 52e71f3e07ac5c3c43c37a14c87974ffdf7d9b0b URL:
https://gitlab.winehq.org/wine/wine/-/commit/52e71f3e07ac5c3c43c37a14c87974…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Mon Jun 3 09:20:09 2024 -0400 d3dx9/tests: Add tests for the source info argument of D3DXCreateTextureFromFileInMemoryEx(). Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/d3dx9_36/tests/texture.c | 132 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index b0dd3c0c6c3..463f0190bb6 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -24,6 +24,7 @@ #include "wine/test.h" #include "d3dx9tex.h" #include "resources.h" +#include <stdint.h> static int has_2d_dxt1, has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3; @@ -146,6 +147,92 @@ static inline void expect_vec4_(unsigned int line, const D3DXVECTOR4 *expected, got->x, got->y, got->z, got->w); } +#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo) \ + check_image_info_(__LINE__, info, width, height, depth, mip_levels, format, resource_type, image_file_format, \ + wine_todo) +static inline void check_image_info_(uint32_t line, const D3DXIMAGE_INFO *info, uint32_t width, uint32_t height, + uint32_t depth, uint32_t mip_levels, D3DFORMAT format, D3DRESOURCETYPE resource_type, + D3DXIMAGE_FILEFORMAT image_file_format, BOOL wine_todo) +{ + const D3DXIMAGE_INFO expected_info = { width, height, depth, mip_levels, format, resource_type, image_file_format }; + BOOL matched; + + matched = !memcmp(&expected_info, info, sizeof(*info)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected image info values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && info->Width != width) + ok_(__FILE__, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width); + todo_wine_if(wine_todo && info->Height != height) + ok_(__FILE__, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height); + todo_wine_if(wine_todo && info->Depth != depth) + ok_(__FILE__, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth); + todo_wine_if(wine_todo && info->MipLevels != mip_levels) + ok_(__FILE__, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels, + info->MipLevels); + ok_(__FILE__, line)(info->Format == format, "Expected texture format %d, got %d.\n", format, info->Format); + ok_(__FILE__, line)(info->ResourceType == resource_type, "Expected resource_type %d, got %d.\n", resource_type, + info->ResourceType); + ok_(__FILE__, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", + image_file_format, info->ImageFileFormat); +} + +#define check_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, width, \ + height, wine_todo) \ + check_texture_level_desc_(__LINE__, tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, \ + width, height, wine_todo) +static inline void check_texture_level_desc_(uint32_t line, IDirect3DTexture9 *tex, uint32_t level, D3DFORMAT format, + uint32_t usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multi_sample_type, + uint32_t multi_sample_quality, uint32_t width, uint32_t height, BOOL wine_todo) +{ + const D3DSURFACE_DESC expected_desc = { format, D3DRTYPE_SURFACE, usage, pool, multi_sample_type, + multi_sample_quality, width, height }; + D3DSURFACE_DESC desc; + BOOL matched; + HRESULT hr; + + hr = IDirect3DTexture9_GetLevelDesc(tex, level, &desc); + todo_wine_if(wine_todo && FAILED(hr)) + ok_(__FILE__, line)(hr == S_OK, "Failed to get texture level desc with hr %#lx.\n", hr); + if (FAILED(hr)) + return; + + matched = !memcmp(&expected_desc, &desc, sizeof(desc)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected surface desc values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && desc.Format != format) + ok_(__FILE__, line)(desc.Format == format, "Expected surface format %d, got %d.\n", format, desc.Format); + ok_(__FILE__, line)(desc.Type == D3DRTYPE_SURFACE, "Expected D3DRTYPE_SURFACE, got %d.\n", desc.Type); + todo_wine_if(wine_todo && desc.Usage != usage) + ok_(__FILE__, line)(desc.Usage == usage, "Expected usage %u, got %lu.\n", usage, desc.Usage); + todo_wine_if(wine_todo && desc.Pool != pool) + ok_(__FILE__, line)(desc.Pool == pool, "Expected pool %d, got %d.\n", pool, desc.Pool); + todo_wine_if(wine_todo && desc.MultiSampleType != multi_sample_type) + ok_(__FILE__, line)(desc.MultiSampleType == multi_sample_type, "Expected multi sample type %d, got %d.\n", + multi_sample_type, desc.MultiSampleType); + todo_wine_if(wine_todo && desc.MultiSampleQuality != multi_sample_quality) + ok_(__FILE__, line)(desc.MultiSampleQuality == multi_sample_quality, "Expected multi sample quality %u, got %lu.\n", + multi_sample_quality, desc.MultiSampleQuality); + todo_wine_if(wine_todo && desc.Width != width) + ok_(__FILE__, line)(desc.Width == width, "Expected width %u, got %u.\n", width, desc.Width); + todo_wine_if(wine_todo && desc.Height != height) + ok_(__FILE__, line)(desc.Height == height, "Expected height %u, got %u.\n", height, desc.Height); +} + +#define check_texture_mip_levels(tex, expected_mip_levels, wine_todo) \ + check_texture_mip_levels_(__LINE__, ((IDirect3DBaseTexture9 *)tex), expected_mip_levels, wine_todo) +static inline void check_texture_mip_levels_(uint32_t line, IDirect3DBaseTexture9 *tex, uint32_t expected_mip_levels, + BOOL wine_todo) +{ + uint32_t mip_levels = IDirect3DBaseTexture9_GetLevelCount(tex); + + todo_wine_if(wine_todo) ok_(__FILE__, line)(mip_levels == expected_mip_levels, "Got miplevels %u, expected %u.\n", + mip_levels, expected_mip_levels); +} + static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) { unsigned int diff = x > y ? x - y : y - x; @@ -1936,6 +2023,7 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) IDirect3DTexture9 *texture; unsigned int miplevels; IDirect3DSurface9 *surface; + D3DXIMAGE_INFO img_info; D3DSURFACE_DESC desc; hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, @@ -2056,6 +2144,50 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u.\n", desc.Format, D3DFMT_L8); IDirect3DSurface9_Release(surface); IDirect3DTexture9_Release(texture); + + /* Test values returned in the D3DXIMAGE_INFO structure. */ + hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit), D3DX_DEFAULT, + D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, + D3DX_DEFAULT, D3DX_SKIP_DDS_MIP_LEVELS(0, D3DX_FILTER_POINT), 0, &img_info, NULL, &texture); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + check_texture_mip_levels(texture, 2, FALSE); + check_image_info(&img_info, 2, 2, 1, 2, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 2, 2, FALSE); + check_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, FALSE); + + IDirect3DTexture9_Release(texture); + + /* + * The values returned in the D3DXIMAGE_INFO structure represent the mip + * level the texture data was retrieved from, i.e if we skip the first mip + * level, we will get the values of the second mip level. + */ + hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit), D3DX_DEFAULT, + D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, + D3DX_DEFAULT, D3DX_SKIP_DDS_MIP_LEVELS(1, D3DX_FILTER_POINT), 0, &img_info, NULL, &texture); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + check_texture_mip_levels(texture, 1, FALSE); + check_image_info(&img_info, 1, 1, 1, 1, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, TRUE); + check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, FALSE); + + IDirect3DTexture9_Release(texture); + + /* + * Request skipping 3 mip levels in a file that only has 2 mip levels. In this + * case, it stops at the final mip level. + */ + hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit), D3DX_DEFAULT, + D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, + D3DX_DEFAULT, D3DX_SKIP_DDS_MIP_LEVELS(3, D3DX_FILTER_POINT), 0, &img_info, NULL, &texture); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + check_texture_mip_levels(texture, 1, TRUE); + check_image_info(&img_info, 1, 1, 1, 1, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, TRUE); + check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, TRUE); + + IDirect3DTexture9_Release(texture); } static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
1
0
0
0
← Newer
1
...
26
27
28
29
30
31
32
...
62
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Results per page:
10
25
50
100
200