ReactOS.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
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
List overview
Download
Ros-diffs
March 2018
----- 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
ros-diffs@reactos.org
25 participants
436 discussions
Start a n
N
ew thread
01/01: [DINPUT] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7016dd6d65ebc7357fc34…
commit 7016dd6d65ebc7357fc34ccbf6288dd1869104eb Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:33:13 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:33:13 2018 +0100 [DINPUT] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/dinput/CMakeLists.txt | 4 +- dll/directx/wine/dinput/config.c | 9 +++-- dll/directx/wine/dinput/data_formats.c | 11 +++--- dll/directx/wine/dinput/device.c | 24 +++++++++--- dll/directx/wine/dinput/device_private.h | 8 ++++ dll/directx/wine/dinput/dinput.rc | 5 +-- dll/directx/wine/dinput/dinput_main.c | 56 +++++++++++++++++++-------- dll/directx/wine/dinput/dinput_private.h | 30 +++----------- dll/directx/wine/dinput/joystick.c | 6 ++- dll/directx/wine/dinput/joystick_linux.c | 22 ++++++++++- dll/directx/wine/dinput/joystick_linuxinput.c | 23 ++++++++++- dll/directx/wine/dinput/joystick_osx.c | 22 +++++------ dll/directx/wine/dinput/joystick_private.h | 10 +++++ dll/directx/wine/dinput/keyboard.c | 16 ++++++++ dll/directx/wine/dinput/mouse.c | 19 +++++++++ dll/directx/wine/dinput/precomp.h | 24 ++++++++++++ dll/directx/wine/dinput/resource.h | 2 + media/doc/README.WINE | 2 +- 18 files changed, 215 insertions(+), 78 deletions(-) diff --git a/dll/directx/wine/dinput/CMakeLists.txt b/dll/directx/wine/dinput/CMakeLists.txt index 7292e15d25..fc215eae90 100644 --- a/dll/directx/wine/dinput/CMakeLists.txt +++ b/dll/directx/wine/dinput/CMakeLists.txt @@ -14,7 +14,7 @@ list(APPEND SOURCE joystick_osx.c keyboard.c mouse.c - dinput_private.h) + precomp.h) add_library(dinput SHARED ${SOURCE} @@ -27,5 +27,5 @@ add_dependencies(dinput_data_formats psdk) set_module_type(dinput win32dll) target_link_libraries(dinput dxguid uuid wine) add_importlibs(dinput comctl32 ole32 user32 advapi32 msvcrt kernel32 ntdll) -add_pch(dinput dinput_private.h SOURCE) +add_pch(dinput precomp.h SOURCE) add_cd_file(TARGET dinput DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/dinput/config.c b/dll/directx/wine/dinput/config.c index 52a950a943..708f406375 100644 --- a/dll/directx/wine/dinput/config.c +++ b/dll/directx/wine/dinput/config.c @@ -16,11 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "dinput_private.h" - -#include <winuser.h> -#include <commctrl.h> +#define NONAMELESSUNION +#include "wine/unicode.h" +#include "objbase.h" +#include "dinput_private.h" +#include "device_private.h" #include "resource.h" typedef struct { diff --git a/dll/directx/wine/dinput/data_formats.c b/dll/directx/wine/dinput/data_formats.c index e1582c0e53..5fac7b7a08 100644 --- a/dll/directx/wine/dinput/data_formats.c +++ b/dll/directx/wine/dinput/data_formats.c @@ -16,15 +16,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H +#if 0 +#pragma makedep implib +#endif #include <stdarg.h> -#include <windef.h> -#include <winbase.h> -#include <dinput.h> +#include "windef.h" +#include "dinput.h" #define numObjects(x) (sizeof(x) / sizeof(x[0])) diff --git a/dll/directx/wine/dinput/device.c b/dll/directx/wine/dinput/device.c index d9f95b913b..bb2a641719 100644 --- a/dll/directx/wine/dinput/device.c +++ b/dll/directx/wine/dinput/device.c @@ -24,9 +24,23 @@ It also contains all the helper functions. */ - +#include "config.h" + +#include <stdarg.h> +#include <string.h> +#include "wine/debug.h" +#include "wine/unicode.h" +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "winuser.h" +#include "winerror.h" +#include "dinput.h" +#include "device_private.h" #include "dinput_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(dinput); + static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) { return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface); @@ -976,9 +990,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = This->acquired ? S_FALSE : DI_OK; This->acquired = 1; - if (res == DI_OK) - check_dinput_hooks(iface); LeaveCriticalSection(&This->crit); + if (res == DI_OK) + check_dinput_hooks(iface, TRUE); return res; } @@ -1004,9 +1018,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = !This->acquired ? DI_NOEFFECT : DI_OK; This->acquired = 0; - if (res == DI_OK) - check_dinput_hooks(iface); LeaveCriticalSection(&This->crit); + if (res == DI_OK) + check_dinput_hooks(iface, FALSE); return res; } diff --git a/dll/directx/wine/dinput/device_private.h b/dll/directx/wine/dinput/device_private.h index bf227fd7f2..52bbec4490 100644 --- a/dll/directx/wine/dinput/device_private.h +++ b/dll/directx/wine/dinput/device_private.h @@ -20,6 +20,14 @@ #ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H #define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "dinput.h" +#include "wine/list.h" +#include "dinput_private.h" + typedef struct { int size; diff --git a/dll/directx/wine/dinput/dinput.rc b/dll/directx/wine/dinput/dinput.rc index 0c5dae0110..d2641f31ea 100644 --- a/dll/directx/wine/dinput/dinput.rc +++ b/dll/directx/wine/dinput/dinput.rc @@ -16,9 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <winuser.h> -#include <commctrl.h> - #include "resource.h" 1 WINE_REGISTRY dinput_classes.rgs @@ -30,7 +27,7 @@ #define WINE_PRODUCTVERSION 5,1,2600,881 #define WINE_PRODUCTVERSION_STR "5.1" -#include <wine/wine_common_ver.rc> +#include "wine/wine_common_ver.rc" #pragma makedep po diff --git a/dll/directx/wine/dinput/dinput_main.c b/dll/directx/wine/dinput/dinput_main.c index 8b106808c5..69b9ff0a44 100644 --- a/dll/directx/wine/dinput/dinput_main.c +++ b/dll/directx/wine/dinput/dinput_main.c @@ -30,9 +30,28 @@ * - Fallout : works great in X and DGA mode */ +#include "config.h" +#include <assert.h> +#include <stdarg.h> +#include <string.h> + +#define COBJMACROS +#define NONAMELESSUNION + +#include "wine/debug.h" +#include "wine/unicode.h" +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winerror.h" +#include "objbase.h" +#include "rpcproxy.h" +#include "initguid.h" #include "dinput_private.h" +#include "device_private.h" +#include "dinputd.h" -#include <rpcproxy.h> +WINE_DEFAULT_DEBUG_CHANNEL(dinput); static const IDirectInput7AVtbl ddi7avt; static const IDirectInput7WVtbl ddi7wvt; @@ -1637,7 +1656,7 @@ static DWORD WINAPI hook_thread_proc(void *param) /* Force creation of the message queue */ PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); - SetEvent(*(LPHANDLE)param); + SetEvent(param); while (GetMessageW( &msg, 0, 0, 0 )) { @@ -1705,6 +1724,7 @@ static DWORD WINAPI hook_thread_proc(void *param) } static DWORD hook_thread_id; +static HANDLE hook_thread_event; static CRITICAL_SECTION_DEBUG dinput_critsect_debug = { @@ -1723,24 +1743,21 @@ static BOOL check_hook_thread(void) TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list)); if (!list_empty(&direct_input_list) && !hook_thread) { - HANDLE event; - - event = CreateEventW(NULL, FALSE, FALSE, NULL); - hook_thread = CreateThread(NULL, 0, hook_thread_proc, &event, 0, &hook_thread_id); - if (event && hook_thread) - { - HANDLE handles[2]; - handles[0] = event; - handles[1] = hook_thread; - WaitForMultipleObjects(2, handles, FALSE, INFINITE); - } + hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL); + hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id); LeaveCriticalSection(&dinput_hook_crit); - CloseHandle(event); } else if (list_empty(&direct_input_list) && hook_thread) { DWORD tid = hook_thread_id; + if (hook_thread_event) /* if thread is not started yet */ + { + WaitForSingleObject(hook_thread_event, INFINITE); + CloseHandle(hook_thread_event); + hook_thread_event = NULL; + } + hook_thread_id = 0; PostThreadMessageW(tid, WM_USER+0x10, 0, 0); LeaveCriticalSection(&dinput_hook_crit); @@ -1756,7 +1773,7 @@ static BOOL check_hook_thread(void) return hook_thread_id != 0; } -void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) +void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired) { static HHOOK callwndproc_hook; static ULONG foreground_cnt; @@ -1766,7 +1783,7 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) if (dev->dwCoopLevel & DISCL_FOREGROUND) { - if (dev->acquired) + if (acquired) foreground_cnt++; else foreground_cnt--; @@ -1781,6 +1798,13 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) callwndproc_hook = NULL; } + if (hook_thread_event) /* if thread is not started yet */ + { + WaitForSingleObject(hook_thread_event, INFINITE); + CloseHandle(hook_thread_event); + hook_thread_event = NULL; + } + PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 ); LeaveCriticalSection(&dinput_hook_crit); diff --git a/dll/directx/wine/dinput/dinput_private.h b/dll/directx/wine/dinput/dinput_private.h index fb8c32ef17..3ed68f2264 100644 --- a/dll/directx/wine/dinput/dinput_private.h +++ b/dll/directx/wine/dinput/dinput_private.h @@ -19,29 +19,13 @@ #ifndef __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H #define __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H -#include <wine/config.h> - #include <stdarg.h> -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS -#define NONAMELESSUNION - -#include <windef.h> -#include <winbase.h> -#include <winreg.h> -#include <winuser.h> -#include <dinput.h> -#include <dinputd.h> - -#include <wine/debug.h> -#include <wine/list.h> -#include <wine/unicode.h> - -WINE_DEFAULT_DEBUG_CHANNEL(dinput); +#include "windef.h" +#include "winbase.h" +#include "dinput.h" +#include "dinputd.h" +#include "wine/list.h" /* Implementation specification */ typedef struct IDirectInputImpl IDirectInputImpl; @@ -85,7 +69,7 @@ extern const struct dinput_device joystick_linux_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_linuxinput_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN; -extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN; +extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN; extern void check_dinput_events(void) DECLSPEC_HIDDEN; typedef int (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM); @@ -102,6 +86,4 @@ extern WCHAR* get_mapping_path(const WCHAR *device, const WCHAR *username) DECLS #define DIMOUSE_MASK 0x82000000 #define DIGENRE_ANY 0xFF000000 -#include "device_private.h" - #endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */ diff --git a/dll/directx/wine/dinput/joystick.c b/dll/directx/wine/dinput/joystick.c index ef21faf809..45c361809e 100644 --- a/dll/directx/wine/dinput/joystick.c +++ b/dll/directx/wine/dinput/joystick.c @@ -26,11 +26,13 @@ * force feedback */ -#include "dinput_private.h" - #include <stdio.h> #include "joystick_private.h" +#include "wine/debug.h" +#include "winreg.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dinput); static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) { diff --git a/dll/directx/wine/dinput/joystick_linux.c b/dll/directx/wine/dinput/joystick_linux.c index 673fb1b19e..963e62f017 100644 --- a/dll/directx/wine/dinput/joystick_linux.c +++ b/dll/directx/wine/dinput/joystick_linux.c @@ -25,17 +25,24 @@ * force feedback */ -#include "dinput_private.h" +#include "config.h" +#include "wine/port.h" +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <time.h> #ifdef HAVE_UNISTD_H # include <unistd.h> #endif #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #endif +#include <fcntl.h> #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif +#include <errno.h> #ifdef HAVE_LINUX_IOCTL_H # include <linux/ioctl.h> #endif @@ -47,8 +54,21 @@ # include <sys/poll.h> #endif +#include "wine/debug.h" +#include "wine/unicode.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "dinput.h" + +#include "dinput_private.h" +#include "device_private.h" +#include "joystick_private.h" + #ifdef HAVE_LINUX_22_JOYSTICK_API +WINE_DEFAULT_DEBUG_CHANNEL(dinput); + #define JOYDEV_NEW "/dev/input/js" #define JOYDEV_OLD "/dev/js" #define JOYDEVDRIVER " (js)" diff --git a/dll/directx/wine/dinput/joystick_linuxinput.c b/dll/directx/wine/dinput/joystick_linuxinput.c index 2cd01e831a..910e755d3e 100644 --- a/dll/directx/wine/dinput/joystick_linuxinput.c +++ b/dll/directx/wine/dinput/joystick_linuxinput.c @@ -20,8 +20,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "dinput_private.h" - +#include "config.h" +#include "wine/port.h" + +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <time.h> #ifdef HAVE_UNISTD_H # include <unistd.h> #endif @@ -44,10 +50,23 @@ # include <sys/poll.h> #endif +#include "wine/debug.h" +#include "wine/unicode.h" +#include "wine/list.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "winreg.h" +#include "dinput.h" + +#include "dinput_private.h" #include "device_private.h" +#include "joystick_private.h" #ifdef HAS_PROPER_HEADER +WINE_DEFAULT_DEBUG_CHANNEL(dinput); + #define EVDEVPREFIX "/dev/input/event" #define EVDEVDRIVER " (event)" diff --git a/dll/directx/wine/dinput/joystick_osx.c b/dll/directx/wine/dinput/joystick_osx.c index 67b1d63320..b0dcdd99d5 100644 --- a/dll/directx/wine/dinput/joystick_osx.c +++ b/dll/directx/wine/dinput/joystick_osx.c @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <config.h> -//#include "wine/port.h" +#include "config.h" +#include "wine/port.h" #if defined(HAVE_IOKIT_HID_IOHIDLIB_H) #define DWORD UInt32 @@ -79,17 +79,17 @@ #undef E_PENDING #endif /* HAVE_IOKIT_HID_IOHIDLIB_H */ -//#include "wine/debug.h" -//#include "wine/unicode.h" -//#include "windef.h" -//#include "winbase.h" -//#include "winerror.h" -//#include "winreg.h" -//#include "dinput.h" +#include "wine/debug.h" +#include "wine/unicode.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "winreg.h" +#include "dinput.h" #include "dinput_private.h" -//#include "device_private.h" -//#include "joystick_private.h" +#include "device_private.h" +#include "joystick_private.h" #ifdef HAVE_IOHIDMANAGERCREATE diff --git a/dll/directx/wine/dinput/joystick_private.h b/dll/directx/wine/dinput/joystick_private.h index 3e24dee5de..e758cacf6d 100644 --- a/dll/directx/wine/dinput/joystick_private.h +++ b/dll/directx/wine/dinput/joystick_private.h @@ -19,6 +19,16 @@ #ifndef __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H #define __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "dinput.h" +#include "wine/list.h" +#include "wine/unicode.h" +#include "dinput_private.h" +#include "device_private.h" + /* Number of objects in the default data format */ #define MAX_PROPS 164 struct JoystickGenericImpl; diff --git a/dll/directx/wine/dinput/keyboard.c b/dll/directx/wine/dinput/keyboard.c index ec7a58ade7..4c3c38e7fc 100644 --- a/dll/directx/wine/dinput/keyboard.c +++ b/dll/directx/wine/dinput/keyboard.c @@ -20,7 +20,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> +#include <string.h> +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winerror.h" +#include "dinput.h" + #include "dinput_private.h" +#include "device_private.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dinput); #define WINE_DINPUT_KEYBOARD_MAX_KEYS 256 diff --git a/dll/directx/wine/dinput/mouse.c b/dll/directx/wine/dinput/mouse.c index bcf9e13be5..eaec6b17dc 100644 --- a/dll/directx/wine/dinput/mouse.c +++ b/dll/directx/wine/dinput/mouse.c @@ -19,7 +19,26 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> +#include <string.h> + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winerror.h" +#include "winreg.h" +#include "dinput.h" + #include "dinput_private.h" +#include "device_private.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dinput); /* Wine mouse driver object instances */ #define WINE_MOUSE_X_AXIS_INSTANCE 0 diff --git a/dll/directx/wine/dinput/precomp.h b/dll/directx/wine/dinput/precomp.h new file mode 100644 index 0000000000..9504beb696 --- /dev/null +++ b/dll/directx/wine/dinput/precomp.h @@ -0,0 +1,24 @@ + +#ifndef __WINE_DINPUT_PRECOMP_H +#define __WINE_DINPUT_PRECOMP_H + +#include <wine/config.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS +#define NONAMELESSUNION + +#include "dinput_private.h" + +#include <winreg.h> +#include <winuser.h> + +#include <wine/debug.h> +#include <wine/unicode.h> + +#include "device_private.h" + +#endif /* !__WINE_DINPUT_PRECOMP_H */ diff --git a/dll/directx/wine/dinput/resource.h b/dll/directx/wine/dinput/resource.h index fa0376fa7e..1f28fc51ef 100644 --- a/dll/directx/wine/dinput/resource.h +++ b/dll/directx/wine/dinput/resource.h @@ -18,6 +18,8 @@ #pragma once +#include "shlobj.h" + #define IDD_CONFIGUREDEVICES 1 #define IDC_DEVICETEXT 20 diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f41e4884d8..ef1c4aca21 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-3.3 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.3 reactos/dll/directx/wine/devenum # Synced to WineStaging-3.3 -reactos/dll/directx/wine/dinput # Synced to Wine-3.0 +reactos/dll/directx/wine/dinput # Synced to WineStaging-3.3 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-2.9 reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9 reactos/dll/directx/wine/dplay # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
01/01: [DEVENUM_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d9b4957fdd065e275cb63…
commit d9b4957fdd065e275cb63de5b7b10e6c09515833 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:31:41 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:31:41 2018 +0100 [DEVENUM_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/devenum/devenum.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/rostests/winetests/devenum/devenum.c b/modules/rostests/winetests/devenum/devenum.c index fc6759da84..5a41183655 100644 --- a/modules/rostests/winetests/devenum/devenum.c +++ b/modules/rostests/winetests/devenum/devenum.c @@ -18,20 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - #define COBJMACROS -//#include <stdio.h> +#include <stdio.h> -#include <wine/test.h> -#include <wingdi.h> -#include <initguid.h> -#include <ole2.h> -#include <strmif.h> -#include <uuids.h> +#include "wine/test.h" +#include "initguid.h" +#include "ole2.h" +#include "strmif.h" +#include "uuids.h" static const WCHAR friendly_name[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0}; static const WCHAR fcc_handlerW[] = {'F','c','c','H','a','n','d','l','e','r',0};
6 years, 9 months
1
0
0
0
01/01: [DEVENUM] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dbcbc1cda146e60537665…
commit dbcbc1cda146e605376657467ac858be5bd16ee7 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:30:52 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:30:52 2018 +0100 [DEVENUM] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/devenum/CMakeLists.txt | 4 +- dll/directx/wine/devenum/createdevenum.c | 83 +++++++++++++++++++++++++++-- dll/directx/wine/devenum/devenum.rc | 11 ++-- dll/directx/wine/devenum/devenum_main.c | 4 +- dll/directx/wine/devenum/devenum_private.h | 41 +++++++------- dll/directx/wine/devenum/factory.c | 4 ++ dll/directx/wine/devenum/mediacatenum.c | 7 ++- dll/directx/wine/devenum/parsedisplayname.c | 5 +- dll/directx/wine/devenum/precomp.h | 16 ++++++ dll/directx/wine/devenum/resource.h | 8 --- media/doc/README.WINE | 2 +- 11 files changed, 141 insertions(+), 44 deletions(-) diff --git a/dll/directx/wine/devenum/CMakeLists.txt b/dll/directx/wine/devenum/CMakeLists.txt index 3992202e2e..d8af794b86 100644 --- a/dll/directx/wine/devenum/CMakeLists.txt +++ b/dll/directx/wine/devenum/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND SOURCE factory.c mediacatenum.c parsedisplayname.c - devenum_private.h) + precomp.h) add_library(devenum SHARED ${SOURCE} @@ -24,5 +24,5 @@ set_module_type(devenum win32dll UNICODE) target_link_libraries(devenum strmiids uuid wine) add_delay_importlibs(devenum msvfw32) add_importlibs(devenum advapi32 advapi32_vista ole32 oleaut32 winmm user32 avicap32 msacm32 msvcrt kernel32 ntdll) -add_pch(devenum devenum_private.h SOURCE) +add_pch(devenum precomp.h SOURCE) add_cd_file(TARGET devenum DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/devenum/createdevenum.c b/dll/directx/wine/devenum/createdevenum.c index a4d0df5a34..002ffbc876 100644 --- a/dll/directx/wine/devenum/createdevenum.c +++ b/dll/directx/wine/devenum/createdevenum.c @@ -23,13 +23,18 @@ * - Also creates the special registry keys created at run-time */ +#define NONAMELESSSTRUCT +#define NONAMELESSUNION + #include "devenum_private.h" +#include "vfw.h" +#include "aviriff.h" -#include <vfw.h> -#include <aviriff.h> -#include <shlwapi.h> +#include "wine/debug.h" +#include "wine/unicode.h" +#include "mmddk.h" -#include "resource.h" +WINE_DEFAULT_DEBUG_CHANNEL(devenum); extern HINSTANCE DEVENUM_hInstance; @@ -109,6 +114,7 @@ static BOOL IsSpecialCategory(const CLSID *clsid) IsEqualGUID(clsid, &CLSID_AudioInputDeviceCategory) || IsEqualGUID(clsid, &CLSID_VideoInputDeviceCategory) || IsEqualGUID(clsid, &CLSID_VideoCompressorCategory) || + IsEqualGUID(clsid, &CLSID_AudioCompressorCategory) || IsEqualGUID(clsid, &CLSID_MidiRendererCategory); } @@ -633,6 +639,72 @@ static void register_vfw_codecs(void) RegCloseKey(basekey); } +static BOOL WINAPI acm_driver_callback(HACMDRIVERID hadid, DWORD_PTR user, DWORD support) +{ + static const WCHAR CLSIDW[] = {'C','L','S','I','D',0}; + static const WCHAR AcmIdW[] = {'A','c','m','I','d',0}; + static const WCHAR FriendlyNameW[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0}; + static const WCHAR fmtW[] = {'%','u','%','s',0}; + + WCHAR acmwrapper_clsid_str[CHARS_IN_GUID], buffer[MAX_PATH]; + HKEY key, basekey = (HKEY) user; + ACMFORMATTAGDETAILSW format; + ACMDRIVERDETAILSW driver; + HACMDRIVER had; + DWORD i, res; + + StringFromGUID2(&CLSID_ACMWrapper, acmwrapper_clsid_str, sizeof(acmwrapper_clsid_str)/sizeof(WCHAR)); + + driver.cbStruct = sizeof(driver); + if (acmDriverDetailsW(hadid, &driver, 0) != MMSYSERR_NOERROR) + return TRUE; + + if (acmDriverOpen(&had, hadid, 0) != MMSYSERR_NOERROR) + return TRUE; + + for (i = 0; i < driver.cFormatTags; i++) + { + memset(&format, 0, sizeof(format)); + format.cbStruct = sizeof(format); + format.dwFormatTagIndex = i; + + if (acmFormatTagDetailsW(had, &format, ACM_FORMATTAGDETAILSF_INDEX) != MMSYSERR_NOERROR) + continue; + + snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), fmtW, format.dwFormatTag, format.szFormatTag); + + res = RegCreateKeyW(basekey, buffer, &key); + if (res != ERROR_SUCCESS) continue; + + RegSetValueExW(key, CLSIDW, 0, REG_SZ, (BYTE*)acmwrapper_clsid_str, sizeof(acmwrapper_clsid_str)); + RegSetValueExW(key, AcmIdW, 0, REG_DWORD, (BYTE*)&format.dwFormatTag, sizeof(DWORD)); + RegSetValueExW(key, FriendlyNameW, 0, REG_SZ, (BYTE*)format.szFormatTag, (strlenW(format.szFormatTag)+1)*sizeof(WCHAR)); + /* FIXME: Set FilterData values */ + + RegCloseKey(key); + } + + acmDriverClose(had, 0); + + return TRUE; +} + +static void register_acm_codecs(void) +{ + HKEY basekey; + + basekey = open_special_category_key(&CLSID_AudioCompressorCategory, TRUE); + if (!basekey) + { + ERR("Could not create key\n"); + return; + } + + acmDriverEnum(acm_driver_callback, (DWORD_PTR)basekey, 0); + + RegCloseKey(basekey); +} + static HANDLE DEVENUM_populate_handle; static const WCHAR DEVENUM_populate_handle_nameW[] = {'_','_','W','I','N','E','_', @@ -685,6 +757,8 @@ static HRESULT DEVENUM_CreateSpecialCategories(void) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_VideoCompressorCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); + if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioCompressorCategory, &basekey, path, MAX_PATH))) + RegDeleteTreeW(basekey, path); rf2.dwVersion = 2; rf2.dwMerit = MERIT_PREFERRED; @@ -966,6 +1040,7 @@ static HRESULT DEVENUM_CreateSpecialCategories(void) IFilterMapper2_Release(pMapper); register_vfw_codecs(); + register_acm_codecs(); SetEvent(DEVENUM_populate_handle); return res; diff --git a/dll/directx/wine/devenum/devenum.rc b/dll/directx/wine/devenum/devenum.rc index fcb0a0217b..294d41ff23 100644 --- a/dll/directx/wine/devenum/devenum.rc +++ b/dll/directx/wine/devenum/devenum.rc @@ -18,11 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windef.h> +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "devenum_private.h" -#include "resource.h" - -#pragma code_page(65001) +#pragma makedep po LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT @@ -43,6 +44,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #define WINE_PRODUCTVERSION 6,5,1,902 #define WINE_PRODUCTVERSION_STR "6.5" -#include <wine/wine_common_ver.rc> +#include "wine/wine_common_ver.rc" 1 WINE_REGISTRY devenum_classes.rgs diff --git a/dll/directx/wine/devenum/devenum_main.c b/dll/directx/wine/devenum/devenum_main.c index 005dc957da..5596358117 100644 --- a/dll/directx/wine/devenum/devenum_main.c +++ b/dll/directx/wine/devenum/devenum_main.c @@ -20,8 +20,10 @@ */ #include "devenum_private.h" +#include "rpcproxy.h" +#include "wine/debug.h" -#include <rpcproxy.h> +WINE_DEFAULT_DEBUG_CHANNEL(devenum); DECLSPEC_HIDDEN LONG dll_refs; DECLSPEC_HIDDEN HINSTANCE DEVENUM_hInstance; diff --git a/dll/directx/wine/devenum/devenum_private.h b/dll/directx/wine/devenum/devenum_private.h index 088cc4c909..72c285d422 100644 --- a/dll/directx/wine/devenum/devenum_private.h +++ b/dll/directx/wine/devenum/devenum_private.h @@ -22,35 +22,28 @@ * - Private file where devenum globals are declared */ -#ifndef __WINE_DEVENUM_H -#define __WINE_DEVENUM_H +#pragma once #ifndef RC_INVOKED #include <stdarg.h> #endif -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winreg.h" +#include "winerror.h" #define COBJMACROS -#define NONAMELESSSTRUCT -#define NONAMELESSUNION -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> -#include <winreg.h> -#include <objbase.h> -#include <oleidl.h> -#include <strmif.h> -#include <uuids.h> - -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(devenum); +#include "ole2.h" +#include "strmif.h" +#include "olectl.h" +#include "uuids.h" #ifndef RC_INVOKED -#include <wine/unicode.h> +#include "wine/unicode.h" #endif /********************************************************************** @@ -95,4 +88,12 @@ extern const WCHAR clsid_keyname[6] DECLSPEC_HIDDEN; extern const WCHAR wszInstanceKeyName[] DECLSPEC_HIDDEN; #define CLSID_STR_LEN (sizeof(clsid_keyname) / sizeof(WCHAR)) -#endif /* __WINE_DEVENUM_H */ +/********************************************************************** + * Resource IDs + */ +#define IDS_DEVENUM_DSDEFAULT 7 +#define IDS_DEVENUM_DS 8 +#define IDS_DEVENUM_WODEFAULT 9 +#define IDS_DEVENUM_MIDEFAULT 10 +#define IDS_DEVENUM_KSDEFAULT 11 +#define IDS_DEVENUM_KS 12 diff --git a/dll/directx/wine/devenum/factory.c b/dll/directx/wine/devenum/factory.c index e31944ad50..c808fa532d 100644 --- a/dll/directx/wine/devenum/factory.c +++ b/dll/directx/wine/devenum/factory.c @@ -21,6 +21,10 @@ #include "devenum_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(devenum); + /********************************************************************** * DEVENUM_IClassFactory_QueryInterface (also IUnknown) */ diff --git a/dll/directx/wine/devenum/mediacatenum.c b/dll/directx/wine/devenum/mediacatenum.c index fb4e561dc7..4edc4e9622 100644 --- a/dll/directx/wine/devenum/mediacatenum.c +++ b/dll/directx/wine/devenum/mediacatenum.c @@ -23,9 +23,12 @@ */ #include "devenum_private.h" +#include "oleauto.h" +#include "ocidl.h" -#include <ocidl.h> -#include <oleauto.h> +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(devenum); typedef struct { diff --git a/dll/directx/wine/devenum/parsedisplayname.c b/dll/directx/wine/devenum/parsedisplayname.c index 5c8b67680f..77ea1ecdcb 100644 --- a/dll/directx/wine/devenum/parsedisplayname.c +++ b/dll/directx/wine/devenum/parsedisplayname.c @@ -21,9 +21,12 @@ * - Implements IParseDisplayName interface which creates a moniker * from a string in a special format */ - #include "devenum_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(devenum); + static HRESULT WINAPI DEVENUM_IParseDisplayName_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv) { diff --git a/dll/directx/wine/devenum/precomp.h b/dll/directx/wine/devenum/precomp.h new file mode 100644 index 0000000000..071deb3f19 --- /dev/null +++ b/dll/directx/wine/devenum/precomp.h @@ -0,0 +1,16 @@ + +#ifndef _WINE_DEVENUM_PRECOMP_H +#define _WINE_DEVENUM_PRECOMP_H + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSSTRUCT +#define NONAMELESSUNION + +#include "devenum_private.h" + +#include <wine/debug.h> + +#endif /* !_WINE_DEVENUM_PRECOMP_H */ diff --git a/dll/directx/wine/devenum/resource.h b/dll/directx/wine/devenum/resource.h deleted file mode 100644 index 3cc562ba4c..0000000000 --- a/dll/directx/wine/devenum/resource.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#define IDS_DEVENUM_DSDEFAULT 7 -#define IDS_DEVENUM_DS 8 -#define IDS_DEVENUM_WODEFAULT 9 -#define IDS_DEVENUM_MIDEFAULT 10 -#define IDS_DEVENUM_KSDEFAULT 11 -#define IDS_DEVENUM_KS 12 diff --git a/media/doc/README.WINE b/media/doc/README.WINE index fd64d09a2e..f41e4884d8 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -29,7 +29,7 @@ reactos/dll/directx/wine/d3drm # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-3.3 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.3 -reactos/dll/directx/wine/devenum # Synced to Wine-3.0 +reactos/dll/directx/wine/devenum # Synced to WineStaging-3.3 reactos/dll/directx/wine/dinput # Synced to Wine-3.0 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-2.9 reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
01/01: [D3DXOF] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1bb40cffc07a165e0b35d…
commit 1bb40cffc07a165e0b35db48aa252bfe04a8cae9 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:28:23 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:28:23 2018 +0100 [D3DXOF] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/d3dxof/CMakeLists.txt | 4 ++-- dll/directx/wine/d3dxof/d3dxof.c | 11 +++++++++++ dll/directx/wine/d3dxof/d3dxof_private.h | 23 ++++++++--------------- dll/directx/wine/d3dxof/main.c | 18 +++++++++++++++++- dll/directx/wine/d3dxof/mszip.c | 8 ++++---- dll/directx/wine/d3dxof/parsing.c | 12 ++++++++++++ dll/directx/wine/d3dxof/precomp.h | 19 +++++++++++++++++++ media/doc/README.WINE | 2 +- 8 files changed, 74 insertions(+), 23 deletions(-) diff --git a/dll/directx/wine/d3dxof/CMakeLists.txt b/dll/directx/wine/d3dxof/CMakeLists.txt index eb95b11cc3..a4fff47f23 100644 --- a/dll/directx/wine/d3dxof/CMakeLists.txt +++ b/dll/directx/wine/d3dxof/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCE d3dxof.c main.c parsing.c - d3dxof_private.h) + precomp.h) add_library(d3dxof SHARED ${SOURCE} @@ -18,5 +18,5 @@ add_library(d3dxof SHARED set_module_type(d3dxof win32dll) target_link_libraries(d3dxof dxguid uuid wine) add_importlibs(d3dxof msvcrt kernel32 ntdll) -add_pch(d3dxof d3dxof_private.h SOURCE) +add_pch(d3dxof precomp.h SOURCE) add_cd_file(TARGET d3dxof DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3dxof/d3dxof.c b/dll/directx/wine/d3dxof/d3dxof.c index 9388fe8bc5..549955193a 100644 --- a/dll/directx/wine/d3dxof/d3dxof.c +++ b/dll/directx/wine/d3dxof/d3dxof.c @@ -18,7 +18,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/debug.h" + +#define COBJMACROS + +#include "winbase.h" +#include "wingdi.h" + #include "d3dxof_private.h" +#include "dxfile.h" + +#include <stdio.h> WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); WINE_DECLARE_DEBUG_CHANNEL(d3dxof_dump); diff --git a/dll/directx/wine/d3dxof/d3dxof_private.h b/dll/directx/wine/d3dxof/d3dxof_private.h index efe990ab2a..cf33ed21ce 100644 --- a/dll/directx/wine/d3dxof/d3dxof_private.h +++ b/dll/directx/wine/d3dxof/d3dxof_private.h @@ -21,21 +21,14 @@ #ifndef __D3DXOF_PRIVATE_INCLUDED__ #define __D3DXOF_PRIVATE_INCLUDED__ -#include <config.h> - -#include <stdio.h> - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS - -#include <windef.h> -#include <winbase.h> -#include <dxfile.h> - -#include <wine/debug.h> +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" +#include "wingdi.h" +#include "winuser.h" +#include "dxfile.h" #define MAX_NAME_LEN 40 #define MAX_ARRAY_DIM 4 diff --git a/dll/directx/wine/d3dxof/main.c b/dll/directx/wine/d3dxof/main.c index 5da77f992a..572f38831f 100644 --- a/dll/directx/wine/d3dxof/main.c +++ b/dll/directx/wine/d3dxof/main.c @@ -18,9 +18,25 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdarg.h> +#include <string.h> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winreg.h" +#include "winerror.h" + +#include "ole2.h" +#include "rpcproxy.h" +#include "uuids.h" + #include "d3dxof_private.h" +#include "dxfile.h" -#include <rpcproxy.h> +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); diff --git a/dll/directx/wine/d3dxof/mszip.c b/dll/directx/wine/d3dxof/mszip.c index a16e6af468..179661634f 100644 --- a/dll/directx/wine/d3dxof/mszip.c +++ b/dll/directx/wine/d3dxof/mszip.c @@ -23,12 +23,12 @@ #include <stdarg.h> -#include <windef.h> -#include <winbase.h> +#include "windef.h" +#include "winbase.h" -#include "mszip.h" +#include "wine/debug.h" -#include <wine/debug.h> +#include "mszip.h" WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); diff --git a/dll/directx/wine/d3dxof/parsing.c b/dll/directx/wine/d3dxof/parsing.c index 6c56914953..f7724ec191 100644 --- a/dll/directx/wine/d3dxof/parsing.c +++ b/dll/directx/wine/d3dxof/parsing.c @@ -18,7 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" +#include "wine/debug.h" + +#define COBJMACROS + +#include "winbase.h" +#include "wingdi.h" + #include "d3dxof_private.h" +#include "dxfile.h" + +#include <stdio.h> WINE_DEFAULT_DEBUG_CHANNEL(d3dxof_parsing); diff --git a/dll/directx/wine/d3dxof/precomp.h b/dll/directx/wine/d3dxof/precomp.h new file mode 100644 index 0000000000..a7878468b9 --- /dev/null +++ b/dll/directx/wine/d3dxof/precomp.h @@ -0,0 +1,19 @@ + +#ifndef _D3DXOF_PRECOMP_H_ +#define _D3DXOF_PRECOMP_H_ + +#include <wine/config.h> + +#include <stdio.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS + +#include "d3dxof_private.h" + +#include <wine/debug.h> + +#endif /* _D3DXOF_PRECOMP_H_ */ diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 1f00297ce1..fd64d09a2e 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -27,7 +27,7 @@ reactos/dll/directx/wine/d3d9 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3drm # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.3 -reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 +reactos/dll/directx/wine/d3dxof # Synced to WineStaging-3.3 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.3 reactos/dll/directx/wine/devenum # Synced to Wine-3.0 reactos/dll/directx/wine/dinput # Synced to Wine-3.0
6 years, 9 months
1
0
0
0
01/01: [D3DX9_*] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e5c42da45cb306ee8294d…
commit e5c42da45cb306ee8294de6074927c05c8b6dac4 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:26:47 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:26:47 2018 +0100 [D3DX9_*] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/d3dx9_36/CMakeLists.txt | 8 +- dll/directx/wine/d3dx9_36/animation.c | 21 +- dll/directx/wine/d3dx9_36/core.c | 7 +- dll/directx/wine/d3dx9_36/d3dx9_36.spec | 8 +- .../{d3dx9_36_private.h => d3dx9_private.h} | 31 +- dll/directx/wine/d3dx9_36/effect.c | 57 +++- dll/directx/wine/d3dx9_36/font.c | 254 ++++++++++++-- dll/directx/wine/d3dx9_36/line.c | 7 +- .../wine/d3dx9_36/{d3dx9_36_main.c => main.c} | 28 +- dll/directx/wine/d3dx9_36/math.c | 41 ++- dll/directx/wine/d3dx9_36/mesh.c | 83 ++++- dll/directx/wine/d3dx9_36/precomp.h | 28 ++ dll/directx/wine/d3dx9_36/preshader.c | 10 +- dll/directx/wine/d3dx9_36/render.c | 7 +- dll/directx/wine/d3dx9_36/shader.c | 372 ++++++++++++++++++++- dll/directx/wine/d3dx9_36/skin.c | 115 ++++++- dll/directx/wine/d3dx9_36/sprite.c | 7 +- dll/directx/wine/d3dx9_36/surface.c | 229 ++++++++++++- dll/directx/wine/d3dx9_36/texture.c | 24 +- dll/directx/wine/d3dx9_36/util.c | 10 +- dll/directx/wine/d3dx9_36/volume.c | 7 +- dll/directx/wine/d3dx9_36/xfile.c | 10 +- media/doc/README.WINE | 2 +- 23 files changed, 1218 insertions(+), 148 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/CMakeLists.txt b/dll/directx/wine/d3dx9_36/CMakeLists.txt index 1b56e547d4..836ee9c743 100644 --- a/dll/directx/wine/d3dx9_36/CMakeLists.txt +++ b/dll/directx/wine/d3dx9_36/CMakeLists.txt @@ -1,15 +1,15 @@ -add_definitions(-D__WINESRC__ -Dcopysignf=_copysignf -D_D3DX9_VER=36) +add_definitions(-D__WINESRC__ -Dcopysignf=_copysignf -DD3DX_SDK_VERSION=36 -D_D3DX9_VER=36) include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) spec2def(d3dx9_36.dll d3dx9_36.spec ADD_IMPORTLIB) list(APPEND SOURCE animation.c core.c - d3dx9_36_main.c effect.c font.c line.c + main.c math.c mesh.c preshader.c @@ -22,7 +22,7 @@ list(APPEND SOURCE util.c volume.c xfile.c - d3dx9_36_private.h) + precomp.h) add_library(d3dx9_36 SHARED ${SOURCE} @@ -35,5 +35,5 @@ set_module_type(d3dx9_36 win32dll) add_dependencies(d3dx9_36 d3d_idl_headers) target_link_libraries(d3dx9_36 dxguid wine) add_importlibs(d3dx9_36 d3dcompiler_43 d3dxof d3dwine user32 ole32 gdi32 msvcrt kernel32 ntdll) -add_pch(d3dx9_36 d3dx9_36_private.h SOURCE) +add_pch(d3dx9_36 precomp.h SOURCE) add_cd_file(TARGET d3dx9_36 DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3dx9_36/animation.c b/dll/directx/wine/d3dx9_36/animation.c index e1e895f630..6be2dd6b5a 100644 --- a/dll/directx/wine/d3dx9_36/animation.c +++ b/dll/directx/wine/d3dx9_36/animation.c @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct d3dx9_animation_controller { @@ -392,7 +397,7 @@ static HRESULT WINAPI d3dx9_animation_controller_CloneAnimationController(ID3DXA return E_NOTIMPL; } -static /* const */ struct ID3DXAnimationControllerVtbl d3dx9_animation_controller_vtbl = +static const struct ID3DXAnimationControllerVtbl d3dx9_animation_controller_vtbl = { d3dx9_animation_controller_QueryInterface, d3dx9_animation_controller_AddRef, @@ -464,3 +469,15 @@ HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets, return D3D_OK; } + +HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_per_second, + D3DXPLAYBACK_TYPE playback_type, UINT animation_count, UINT callback_key_count, + const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set) +{ + FIXME("name %s, ticks_per_second %.16e, playback_type %u, animation_count %u, " + "callback_key_count %u, callback_keys %p, animation_set %p stub.\n", + debugstr_a(name), ticks_per_second, playback_type, animation_count, + callback_key_count, callback_keys, animation_set); + + return E_NOTIMPL; +} diff --git a/dll/directx/wine/d3dx9_36/core.c b/dll/directx/wine/d3dx9_36/core.c index e7624f2a21..1eb289ece6 100644 --- a/dll/directx/wine/d3dx9_36/core.c +++ b/dll/directx/wine/d3dx9_36/core.c @@ -17,7 +17,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct ID3DXBufferImpl { diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/dll/directx/wine/d3dx9_36/d3dx9_36.spec index e487aa12ec..1e035f76c1 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -22,9 +22,9 @@ @ stdcall -stub D3DXComputeIMTFromPerVertexSignal(ptr ptr long long long ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromSignal(ptr long long long long ptr ptr ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) -@ stdcall -stub D3DXComputeNormalMap(ptr ptr ptr long long float) +@ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) +@ stdcall D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -68,7 +68,7 @@ @ stdcall D3DXCreateFontW(ptr long long long long long long long long long wstr ptr) @ stdcall D3DXCreateFragmentLinker(ptr long ptr) @ stdcall D3DXCreateFragmentLinkerEx(ptr long long ptr) -@ stdcall -stub D3DXCreateKeyframedAnimationSet(ptr long long long long ptr ptr) +@ stdcall D3DXCreateKeyframedAnimationSet(str double long long long ptr ptr) @ stdcall D3DXCreateLine(ptr ptr) @ stdcall D3DXCreateMatrixStack(long ptr) @ stdcall D3DXCreateMesh(long long long ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h b/dll/directx/wine/d3dx9_36/d3dx9_private.h similarity index 96% rename from dll/directx/wine/d3dx9_36/d3dx9_36_private.h rename to dll/directx/wine/d3dx9_36/d3dx9_private.h index ddc38225e0..edb7455a5f 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h +++ b/dll/directx/wine/d3dx9_36/d3dx9_private.h @@ -19,33 +19,14 @@ * */ -#ifndef __WINE_D3DX9_36_PRIVATE_H -#define __WINE_D3DX9_36_PRIVATE_H +#ifndef __WINE_D3DX9_PRIVATE_H +#define __WINE_D3DX9_PRIVATE_H -#include <config.h> -#include <wine/port.h> - -#include <assert.h> -#include <stdarg.h> - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS #define NONAMELESSUNION -#define NONAMELESSSTRUCT +#include "wine/debug.h" -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> -#include <winuser.h> -#include <d3dx9.h> - -#include <wine/unicode.h> - -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(d3dx); +#define COBJMACROS +#include "d3dx9.h" #define ULONG64_MAX (~(ULONG64)0) @@ -409,4 +390,4 @@ const struct ctab_constant *d3dx_shader_get_ctab_constant(ID3DXConstantTable *if HRESULT create_dummy_skin(ID3DXSkinInfo **iface) DECLSPEC_HIDDEN; -#endif /* __WINE_D3DX9_36_PRIVATE_H */ +#endif /* __WINE_D3DX9_PRIVATE_H */ diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c index 7a5975a706..e2c0ce3728 100644 --- a/dll/directx/wine/d3dx9_36/effect.c +++ b/dll/directx/wine/d3dx9_36/effect.c @@ -17,9 +17,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" -#include <d3dcompiler.h> +#include "d3dx9_private.h" +#include "d3dcompiler.h" /* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f @@ -31,6 +33,8 @@ static const char parameter_magic_string[4] = {'@', '!', '#', '\xFF'}; #define INITIAL_POOL_SIZE 16 +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + enum STATE_CLASS { SC_LIGHTENABLE, @@ -3980,13 +3984,41 @@ done: return ret; } -static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique) +static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect *iface, + D3DXHANDLE technique, D3DXHANDLE *next_technique) { struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); + struct d3dx9_base_effect *base_effect = &This->base_effect; + UINT i = 0; - FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique); + TRACE("iface %p, technique %p, next_technique %p\n", iface, technique, next_technique); - return E_NOTIMPL; + if (!next_technique) + return D3DERR_INVALIDCALL; + + if (technique) + { + for (; i < base_effect->technique_count; i++) + { + if (technique == get_technique_handle(&base_effect->techniques[i])) + { + i++; /* Go to next technique */ + break; + } + } + } + + for (; i < base_effect->technique_count; i++) + { + if (SUCCEEDED(iface->lpVtbl->ValidateTechnique(iface, get_technique_handle(&base_effect->techniques[i])))) + { + *next_technique = get_technique_handle(&base_effect->techniques[i]); + return D3D_OK; + } + } + + *next_technique = NULL; + return S_FALSE; } static BOOL walk_parameter_dep(struct d3dx_parameter *param, walk_parameter_dep_func param_func, @@ -4347,6 +4379,7 @@ static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3 return E_NOTIMPL; } +#if _D3DX9_VER >= 26 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block) { struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); @@ -4355,6 +4388,7 @@ static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D return E_NOTIMPL; } +#endif static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, struct IDirect3DDevice9 *device, struct ID3DXEffect **effect) @@ -4363,9 +4397,15 @@ static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, FIXME("(%p)->(%p, %p): stub\n", This, device, effect); - return E_NOTIMPL; + if (!effect) + return D3DXERR_INVALIDDATA; + + iface->lpVtbl->AddRef(iface); + *effect = iface; + return S_OK; } +#if _D3DX9_VER >= 27 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, D3DXHANDLE parameter, const void *data, UINT byte_offset, UINT bytes) { @@ -4374,6 +4414,7 @@ static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, return E_NOTIMPL; } +#endif static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = { @@ -4456,9 +4497,13 @@ static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = ID3DXEffectImpl_BeginParameterBlock, ID3DXEffectImpl_EndParameterBlock, ID3DXEffectImpl_ApplyParameterBlock, +#if _D3DX9_VER >= 26 ID3DXEffectImpl_DeleteParameterBlock, +#endif ID3DXEffectImpl_CloneEffect, +#if _D3DX9_VER >= 27 ID3DXEffectImpl_SetRawValue +#endif }; static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 575e80d0bb..b4b9600320 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -17,7 +17,13 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct d3dx_font { @@ -29,8 +35,29 @@ struct d3dx_font HDC hdc; HFONT hfont; + + UINT tex_width; + UINT tex_height; + IDirect3DTexture9 *texture; + HBITMAP bitmap; + BYTE *bits; }; +/* Returns the smallest power of 2 which is greater than or equal to num */ +static UINT make_pow2(UINT num) +{ + UINT result = 1; + + /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */ + if (num >= 0x80000000) + return 0x80000000; + + while (result < num) + result <<= 1; + + return result; +} + static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface) { return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface); @@ -57,19 +84,27 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedIncrement(&This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("%p increasing refcount to %u\n", iface, ref); + return ref; } static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedDecrement(&This->ref); + ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u\n", iface, ref); - if(ref==0) { + if (!ref) + { + if (This->texture) + { + IDirect3DTexture9_Release(This->texture); + DeleteObject(This->bitmap); + } DeleteObject(This->hfont); DeleteDC(This->hdc); IDirect3DDevice9_Release(This->device); @@ -172,17 +207,187 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", + LPWSTR stringW; + INT countW, ret = 0; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + + if (!string || count == 0) + return 0; + + if (count < 0) + count = -1; + + countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0); + stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)); + if (stringW) + { + MultiByteToWideChar(CP_ACP, 0, string, count, stringW, countW); + ret = ID3DXFont_DrawTextW(iface, sprite, stringW, countW, rect, format, color); + HeapFree(GetProcessHeap(), 0, stringW); + } + + return ret; } static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", + struct d3dx_font *This = impl_from_ID3DXFont(iface); + RECT calc_rect; + INT height; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + + if (!string || count == 0) + return 0; + + if (count < 0) + count = lstrlenW(string); + + /* Strip terminating NULL characters */ + while (count > 0 && !string[count-1]) + count--; + + if (rect) + calc_rect = *rect; + + height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT); + + if (format & DT_CALCRECT) + { + if (rect) + *rect = calc_rect; + return height; + } + + if (format & DT_CENTER) + { + UINT new_width = calc_rect.right - calc_rect.left; + calc_rect.left = (rect->right + rect->left - new_width) / 2; + calc_rect.right = calc_rect.left + new_width; + } + + if (height && (calc_rect.left < calc_rect.right)) + { + D3DLOCKED_RECT locked_rect; + D3DXVECTOR3 position; + UINT text_width, text_height; + RECT text_rect; + ID3DXSprite *target = sprite; + HRESULT hr; + int i, j; + + /* Get rect position and dimensions */ + position.x = calc_rect.left; + position.y = calc_rect.top; + position.z = 0; + text_width = calc_rect.right - calc_rect.left; + text_height = calc_rect.bottom - calc_rect.top; + text_rect.left = 0; + text_rect.top = 0; + text_rect.right = text_width; + text_rect.bottom = text_height; + + /* We need to flush as it seems all draws in the begin/end sequence use only the latest updated texture */ + if (sprite) + ID3DXSprite_Flush(sprite); + + /* Extend texture and DIB section to contain text */ + if ((text_width > This->tex_width) || (text_height > This->tex_height)) + { + BITMAPINFOHEADER header; + + if (text_width > This->tex_width) + This->tex_width = make_pow2(text_width); + if (text_height > This->tex_height) + This->tex_height = make_pow2(text_height); + + if (This->texture) + { + IDirect3DTexture9_Release(This->texture); + DeleteObject(This->bitmap); + } + + hr = D3DXCreateTexture(This->device, This->tex_width, This->tex_height, 1, 0, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &This->texture); + if (FAILED(hr)) + { + This->texture = NULL; + return 0; + } + + header.biSize = sizeof(header); + header.biWidth = This->tex_width; + header.biHeight = -This->tex_height; + header.biPlanes = 1; + header.biBitCount = 32; + header.biCompression = BI_RGB; + header.biSizeImage = sizeof(DWORD) * This->tex_width * This->tex_height; + header.biXPelsPerMeter = 0; + header.biYPelsPerMeter = 0; + header.biClrUsed = 0; + header.biClrImportant = 0; + + This->bitmap = CreateDIBSection(This->hdc, (const BITMAPINFO*)&header, + DIB_RGB_COLORS, (void**)&This->bits, NULL, 0); + if (!This->bitmap) + { + IDirect3DTexture9_Release(This->texture); + This->texture = NULL; + return 0; + } + + SelectObject(This->hdc, This->bitmap); + } + + if (FAILED(IDirect3DTexture9_LockRect(This->texture, 0, &locked_rect, &text_rect, D3DLOCK_DISCARD))) + return 0; + + /* Clear rect */ + for (i = 0; i < text_height; i++) + memset(This->bits + i * This->tex_width * sizeof(DWORD), 0, + text_width * sizeof(DWORD)); + + DrawTextW(This->hdc, string, count, &text_rect, format); + + /* All RGB components are equal so take one as alpha and set RGB + * color to white, so it can be modulated with color parameter */ + for (i = 0; i < text_height; i++) + { + DWORD *src = (DWORD *)This->bits + i * This->tex_width; + DWORD *dst = (DWORD *)((BYTE *)locked_rect.pBits + i * locked_rect.Pitch); + for (j = 0; j < text_width; j++) + { + *dst++ = (*src++ << 24) | 0xFFFFFF; + } + } + + IDirect3DTexture9_UnlockRect(This->texture, 0); + + if (!sprite) + { + hr = D3DXCreateSprite(This->device, &target); + if (FAILED(hr)) + return 0; + ID3DXSprite_Begin(target, 0); + } + + hr = target->lpVtbl->Draw(target, This->texture, &text_rect, NULL, &position, color); + + if (!sprite) + { + ID3DXSprite_End(target); + ID3DXSprite_Release(target); + } + + if (FAILED(hr)) + return 0; + } + + return height; } static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) @@ -296,46 +501,55 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_ TRACE("(%p, %p, %p)\n", device, desc, font); - if( !device || !desc || !font ) return D3DERR_INVALIDCALL; + if (!device || !desc || !font) return D3DERR_INVALIDCALL; - /* the device MUST support D3DFMT_A8R8G8B8 */ + TRACE("desc: %d %d %d %d %d %d %d %d %d %s\n", desc->Height, desc->Width, desc->Weight, desc->MipLevels, desc->Italic, + desc->CharSet, desc->OutputPrecision, desc->Quality, desc->PitchAndFamily, debugstr_w(desc->FaceName)); + + /* The device MUST support D3DFMT_A8R8G8B8 */ IDirect3DDevice9_GetDirect3D(device, &d3d); IDirect3DDevice9_GetCreationParameters(device, &cpars); IDirect3DDevice9_GetDisplayMode(device, 0, &mode); hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); - if(FAILED(hr)) { + if (FAILED(hr)) + { IDirect3D9_Release(d3d); return D3DXERR_INVALIDDATA; } IDirect3D9_Release(d3d); - object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font)); - if(object==NULL) { - *font=NULL; + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct d3dx_font)); + if (!object) + { + *font = NULL; return E_OUTOFMEMORY; } object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; - object->ref=1; - object->device=device; - object->desc=*desc; + object->ref = 1; + object->device = device; + object->desc = *desc; object->hdc = CreateCompatibleDC(NULL); - if( !object->hdc ) { + if (!object->hdc) + { HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); - if( !object->hfont ) { + if (!object->hfont) + { DeleteDC(object->hdc); HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } SelectObject(object->hdc, object->hfont); + SetTextColor(object->hdc, 0x00ffffff); + SetBkColor(object->hdc, 0x00000000); IDirect3DDevice9_AddRef(device); - *font=&object->ID3DXFont_iface; + *font = &object->ID3DXFont_iface; return D3D_OK; } diff --git a/dll/directx/wine/d3dx9_36/line.c b/dll/directx/wine/d3dx9_36/line.c index e1b691a07b..356d54fbd0 100644 --- a/dll/directx/wine/d3dx9_36/line.c +++ b/dll/directx/wine/d3dx9_36/line.c @@ -17,7 +17,12 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct d3dx9_line { diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36_main.c b/dll/directx/wine/d3dx9_36/main.c similarity index 71% rename from dll/directx/wine/d3dx9_36/d3dx9_36_main.c rename to dll/directx/wine/d3dx9_36/main.c index 01c5219bf0..a256d42526 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36_main.c +++ b/dll/directx/wine/d3dx9_36/main.c @@ -20,11 +20,14 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "initguid.h" +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); -/*********************************************************************** - * DllMain. - */ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) { switch(reason) @@ -38,14 +41,13 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) return TRUE; } -/*********************************************************************** - * D3DXCheckVersion - * Checks whether we are compiling against the correct d3d and d3dx library. - */ -BOOL WINAPI D3DXCheckVersion(UINT d3dsdkvers, UINT d3dxsdkvers) +BOOL WINAPI D3DXCheckVersion(UINT d3d_sdk_ver, UINT d3dx_sdk_ver) +{ + return d3d_sdk_ver == D3D_SDK_VERSION && d3dx_sdk_ver == D3DX_SDK_VERSION; +} + +DWORD WINAPI D3DXCpuOptimizations(BOOL enable) { - if(d3dsdkvers==D3D_SDK_VERSION && d3dxsdkvers==36) - return TRUE; - else - return FALSE; + FIXME("%#x - stub\n", enable); + return 0; } diff --git a/dll/directx/wine/d3dx9_36/math.c b/dll/directx/wine/d3dx9_36/math.c index 2f5a473081..856e987cb9 100644 --- a/dll/directx/wine/d3dx9_36/math.c +++ b/dll/directx/wine/d3dx9_36/math.c @@ -22,7 +22,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct ID3DXMatrixStackImpl { @@ -2568,27 +2573,27 @@ FLOAT * WINAPI D3DXSHMultiply3(FLOAT *out, const FLOAT *a, const FLOAT *b) out[0] = 0.28209479f * a[0] * b[0]; - ta = 0.28209479f * a[0] - 0.12615662f * a[6] - 0.21850968f * a[8]; - tb = 0.28209479f * b[0] - 0.12615662f * b[6] - 0.21850968f * b[8]; + ta = 0.28209479f * a[0] - 0.12615663f * a[6] - 0.21850969f * a[8]; + tb = 0.28209479f * b[0] - 0.12615663f * b[6] - 0.21850969f * b[8]; out[1] = ta * b[1] + tb * a[1]; t = a[1] * b[1]; out[0] += 0.28209479f * t; - out[6] = -0.12615662f * t; - out[8] = -0.21850968f * t; + out[6] = -0.12615663f * t; + out[8] = -0.21850969f * t; - ta = 0.21850968f * a[5]; - tb = 0.21850968f * b[5]; + ta = 0.21850969f * a[5]; + tb = 0.21850969f * b[5]; out[1] += ta * b[2] + tb * a[2]; out[2] = ta * b[1] + tb * a[1]; t = a[1] * b[2] +a[2] * b[1]; - out[5] = 0.21850968f * t; + out[5] = 0.21850969f * t; - ta = 0.21850968f * a[4]; - tb = 0.21850968f * b[4]; + ta = 0.21850969f * a[4]; + tb = 0.21850969f * b[4]; out[1] += ta * b[3] + tb * a[3]; out[3] = ta * b[1] + tb * a[1]; t = a[1] * b[3] + a[3] * b[1]; - out[4] = 0.21850968f * t; + out[4] = 0.21850969f * t; ta = 0.28209480f * a[0] + 0.25231326f * a[6]; tb = 0.28209480f * b[0] + 0.25231326f * b[6]; @@ -2624,14 +2629,14 @@ FLOAT * WINAPI D3DXSHMultiply3(FLOAT *out, const FLOAT *a, const FLOAT *b) out[4] += ta * b[5] + tb * a[5]; out[5] += ta * b[4] + tb * a[4]; t = a[4] * b[5] + a[5] * b[4]; - out[7] += 0.15607834f * t; + out[7] += 0.15607835f * t; - ta = 0.28209479f * a[0] + 0.09011186f * a[6] - 0.15607835f * a[8]; - tb = 0.28209479f * b[0] + 0.09011186f * b[6] - 0.15607835f * b[8]; + ta = 0.28209479f * a[0] + 0.09011188f * a[6] - 0.15607835f * a[8]; + tb = 0.28209479f * b[0] + 0.09011188f * b[6] - 0.15607835f * b[8]; out[5] += ta * b[5] + tb * a[5]; t = a[5] * b[5]; out[0] += 0.28209479f * t; - out[6] += 0.09011186f * t; + out[6] += 0.09011188f * t; out[8] -= 0.15607835f * t; ta = 0.28209480f * a[0]; @@ -2641,12 +2646,12 @@ FLOAT * WINAPI D3DXSHMultiply3(FLOAT *out, const FLOAT *a, const FLOAT *b) out[0] += 0.28209480f * t; out[6] += 0.18022376f * t; - ta = 0.28209479f * a[0] + 0.09011186f * a[6] + 0.15607835f * a[8]; - tb = 0.28209479f * b[0] + 0.09011186f * b[6] + 0.15607835f * b[8]; + ta = 0.28209479f * a[0] + 0.09011188f * a[6] + 0.15607835f * a[8]; + tb = 0.28209479f * b[0] + 0.09011188f * b[6] + 0.15607835f * b[8]; out[7] += ta * b[7] + tb * a[7]; t = a[7] * b[7]; out[0] += 0.28209479f * t; - out[6] += 0.09011186f * t; + out[6] += 0.09011188f * t; out[8] += 0.15607835f * t; ta = 0.28209479f * a[0] - 0.18022375f * a[6]; diff --git a/dll/directx/wine/d3dx9_36/mesh.c b/dll/directx/wine/d3dx9_36/mesh.c index 57b2aeb1a1..3dd881ee1c 100644 --- a/dll/directx/wine/d3dx9_36/mesh.c +++ b/dll/directx/wine/d3dx9_36/mesh.c @@ -24,17 +24,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" +#include <assert.h> #ifdef HAVE_FLOAT_H # include <float.h> #endif +#include "d3dx9_private.h" +#undef MAKE_DDHRESULT +#include "dxfile.h" #include "rmxfguid.h" #include "rmxftmpl.h" - +#include "wine/unicode.h" #include "wine/list.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + struct d3dx9_mesh { ID3DXMesh ID3DXMesh_iface; @@ -1688,11 +1695,7 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags, if (FAILED(hr)) goto cleanup; } else if (flags & D3DXMESHOPT_ATTRSORT) { if (!(flags & D3DXMESHOPT_IGNOREVERTS)) - { FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not implemented.\n"); - hr = E_NOTIMPL; - goto cleanup; - } hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer); if (FAILED(hr)) goto cleanup; @@ -2333,7 +2336,7 @@ UINT WINAPI D3DXGetDeclVertexSize(const D3DVERTEXELEMENT9 *decl, DWORD stream_id if (element->Stream != stream_idx) continue; - if (element->Type >= sizeof(d3dx_decltype_size) / sizeof(*d3dx_decltype_size)) + if (element->Type >= ARRAY_SIZE(d3dx_decltype_size)) { FIXME("Unhandled element type %#x, size will be incorrect.\n", element->Type); continue; @@ -3325,6 +3328,13 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data, goto end; } + if ((provide_flags & PROVIDE_SKININFO) && !mesh_data->skin_info) + { + hr = create_dummy_skin(&mesh_data->skin_info); + if (FAILED(hr)) + goto end; + } + hr = D3D_OK; end: @@ -5159,7 +5169,7 @@ HRESULT WINAPI D3DXCreateTeapot(struct IDirect3DDevice9 *device, { FIXME("(%p, %p, %p): stub\n", device, mesh, adjacency); - return E_NOTIMPL; + return D3DXCreateSphere(device, 1.0f, 4, 4, mesh, adjacency); } HRESULT WINAPI D3DXCreateTextA(struct IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, @@ -7177,6 +7187,33 @@ cleanup: return hr; } + +/************************************************************************* + * D3DXOptimizeVertices (D3DX9_36.@) + */ +HRESULT WINAPI D3DXOptimizeVertices(const void *indices, UINT num_faces, + UINT num_vertices, BOOL indices_are_32bit, DWORD *vertex_remap) +{ + UINT i; + + FIXME("indices %p, num_faces %u, num_vertices %u, indices_are_32bit %#x, vertex_remap %p semi-stub.\n", + indices, num_faces, num_vertices, indices_are_32bit, vertex_remap); + + if (!vertex_remap) + { + WARN("vertex remap pointer is NULL.\n"); + return D3DERR_INVALIDCALL; + } + + for (i = 0; i < num_vertices; i++) + { + vertex_remap[i] = i; + } + + return D3D_OK; +} + + /************************************************************************* * D3DXOptimizeFaces (D3DX9_36.@) * @@ -7500,6 +7537,24 @@ done: return hr; } +/************************************************************************* + * D3DXComputeTangent (D3DX9_36.@) + */ +HRESULT WINAPI D3DXComputeTangent(ID3DXMesh *mesh, DWORD stage_idx, DWORD tangent_idx, + DWORD binorm_idx, DWORD wrap, const DWORD *adjacency) +{ + TRACE("mesh %p, stage_idx %d, tangent_idx %d, binorm_idx %d, wrap %d, adjacency %p.\n", + mesh, stage_idx, tangent_idx, binorm_idx, wrap, adjacency); + + return D3DXComputeTangentFrameEx( mesh, D3DDECLUSAGE_TEXCOORD, stage_idx, + ( binorm_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_BINORMAL, + binorm_idx, + ( tangent_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_TANGENT, + tangent_idx, D3DX_DEFAULT, 0, + ( wrap ? D3DXTANGENT_WRAP_UV : 0 ) | D3DXTANGENT_GENERATE_IN_PLACE | D3DXTANGENT_ORTHOGONALIZE_FROM_U, + adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); +} + /************************************************************************* * D3DXComputeNormals (D3DX9_36.@) */ @@ -7519,6 +7574,18 @@ HRESULT WINAPI D3DXComputeNormals(struct ID3DXBaseMesh *mesh, const DWORD *adjac adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); } +/************************************************************************* + * D3DXComputeNormalMap (D3DX9_36.@) + */ +HRESULT WINAPI D3DXComputeNormalMap(IDirect3DTexture9 *texture, IDirect3DTexture9 *src_texture, + const PALETTEENTRY *src_palette, DWORD flags, DWORD channel, FLOAT amplitude) +{ + FIXME("texture %p, src_texture %p, src_palette %p, flags %#x, channel %u, amplitude %f stub.\n", + texture, src_texture, src_palette, flags, channel, amplitude); + + return D3D_OK; +} + /************************************************************************* * D3DXIntersect (D3DX9_36.@) */ diff --git a/dll/directx/wine/d3dx9_36/precomp.h b/dll/directx/wine/d3dx9_36/precomp.h new file mode 100644 index 0000000000..30ad1cf918 --- /dev/null +++ b/dll/directx/wine/d3dx9_36/precomp.h @@ -0,0 +1,28 @@ + +#ifndef __WINE_D3DX9_36_PRECOMP_H +#define __WINE_D3DX9_36_PRECOMP_H + +#include <config.h> +#include <wine/port.h> + +#include <assert.h> +#include <stdarg.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#define COBJMACROS + +#include <windef.h> +#include <winbase.h> +#include <wingdi.h> +#include <winuser.h> + +#include <wine/unicode.h> + +#include "d3dx9_private.h" + +#endif /* __WINE_D3DX9_36_PRECOMP_H */ diff --git a/dll/directx/wine/d3dx9_36/preshader.c b/dll/directx/wine/d3dx9_36/preshader.c index 416f05b15a..ef27149d82 100644 --- a/dll/directx/wine/d3dx9_36/preshader.c +++ b/dll/directx/wine/d3dx9_36/preshader.c @@ -16,7 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +#include <float.h> +#include <assert.h> + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); /* ReactOS FIXME: Insect */ #define fmin min diff --git a/dll/directx/wine/d3dx9_36/render.c b/dll/directx/wine/d3dx9_36/render.c index 02e6caa8eb..ad8330784d 100644 --- a/dll/directx/wine/d3dx9_36/render.c +++ b/dll/directx/wine/d3dx9_36/render.c @@ -17,7 +17,12 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct device_state { diff --git a/dll/directx/wine/d3dx9_36/shader.c b/dll/directx/wine/d3dx9_36/shader.c index 48e49a2982..2bbc6b79e0 100644 --- a/dll/directx/wine/d3dx9_36/shader.c +++ b/dll/directx/wine/d3dx9_36/shader.c @@ -1,6 +1,7 @@ /* * Copyright 2008 Luis Busquets * Copyright 2009 Matteo Bruni + * Copyright 2010, 2013, 2016 Christian Costa * Copyright 2011 Travis Athougies * * This library is free software; you can redistribute it and/or @@ -18,12 +19,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" - +#include "config.h" +#include "wine/port.h" #include <stdio.h> +#include "d3dx9_private.h" +#include "d3dcommon.h" #include "d3dcompiler.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + /* This function is not declared in the SDK headers yet. */ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags, @@ -440,6 +445,41 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO } } + /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */ + if (SUCCEEDED(hr) && error_msgs && *error_msgs) + { + char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs); + DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs); + + /* Ensure messages are null terminated for safe processing */ + if (size) messages[size - 1] = 0; + + while (size > 1) + { + char *prev, *next; + + /* Warning has the form "warning X3206: ... implicit truncation of vector type" + but we only search for "X3206:" in case d3dcompiler_43 has localization */ + prev = next = strstr(messages, "X3206:"); + if (!prev) break; + + /* get pointer to beginning and end of current line */ + while (prev > messages && *(prev - 1) != '\n') prev--; + while (next < messages + size - 1 && *next != '\n') next++; + if (next < messages + size - 1 && *next == '\n') next++; + + memmove(prev, next, messages + size - next); + size -= (next - prev); + } + + /* Only return a buffer if the resulting string is not empty as some apps depend on that */ + if (size <= 1) + { + ID3DXBuffer_Release(*error_msgs); + *error_msgs = NULL; + } + } + return hr; } @@ -2141,10 +2181,334 @@ HRESULT WINAPI D3DXGetShaderSamplers(const DWORD *byte_code, const char **sample return D3D_OK; } + +static const char *decl_usage[] = { "position", "blendweight", "blendindices", "normal", "psize", "texcoord", + "tangent", "binormal", "tessfactor", "positiont", "color" }; + +static const char *tex_type[] = { "", "1d", "2d", "cube", "volume" }; + +static int add_modifier(char *buffer, DWORD param) +{ + char *buf = buffer; + DWORD dst_mod = param & D3DSP_DSTMOD_MASK; + + if (dst_mod & D3DSPDM_SATURATE) + buf += sprintf(buf, "_sat"); + if (dst_mod & D3DSPDM_PARTIALPRECISION) + buf += sprintf(buf, "_pp"); + if (dst_mod & D3DSPDM_MSAMPCENTROID) + buf += sprintf(buf, "_centroid"); + + return buf - buffer; +} + +static int add_register(char *buffer, DWORD param, BOOL dst, BOOL ps) +{ + char *buf = buffer; + DWORD reg_type = ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) + | ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); + DWORD reg_num = param & D3DSP_REGNUM_MASK; + + if (reg_type == D3DSPR_INPUT) + buf += sprintf(buf, "v%d", reg_num); + else if (reg_type == D3DSPR_CONST) + buf += sprintf(buf, "c%d", reg_num); + else if (reg_type == D3DSPR_TEMP) + buf += sprintf(buf, "r%d", reg_num); + else if (reg_type == D3DSPR_ADDR) + buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num); + else if (reg_type == D3DSPR_SAMPLER) + buf += sprintf(buf, "s%d", reg_num); + else if (reg_type == D3DSPR_RASTOUT) + buf += sprintf(buf, "oPos"); + else if (reg_type == D3DSPR_COLOROUT) + buf += sprintf(buf, "oC%d", reg_num); + else if (reg_type == D3DSPR_TEXCRDOUT) + buf += sprintf(buf, "oT%d", reg_num); + else if (reg_type == D3DSPR_ATTROUT) + buf += sprintf(buf, "oD%d", reg_num); + else + buf += sprintf(buf, "? (%d)", reg_type); + + if (dst) + { + if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) + { + buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "", + param & D3DSP_WRITEMASK_1 ? "y" : "", + param & D3DSP_WRITEMASK_2 ? "z" : "", + param & D3DSP_WRITEMASK_3 ? "w" : ""); + } + } + else + { + if ((param & D3DVS_SWIZZLE_MASK) != D3DVS_NOSWIZZLE) + { + if ( ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_X | D3DVS_Y_X | D3DVS_Z_X | D3DVS_W_X)) || + ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Y | D3DVS_Y_Y | D3DVS_Z_Y | D3DVS_W_Y)) || + ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Z | D3DVS_Y_Z | D3DVS_Z_Z | D3DVS_W_Z)) || + ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_W | D3DVS_Y_W | D3DVS_Z_W | D3DVS_W_W)) ) + buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3)); + else + buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3), + 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3), + 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3), + 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3)); + } + } + + return buf - buffer; +} + +struct instr_info +{ + DWORD opcode; + const char *name; + int length; + int (*function)(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps); + WORD min_version; + WORD max_version; +}; + +static int instr_comment(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) +{ + *ptr += 1 + ((**ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); + return 0; +} + +static int instr_def(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) +{ + int len = sprintf(buffer, " def c%d, %g, %g, %g, %g\n", *(*ptr+1) & D3DSP_REGNUM_MASK, + (double)*(float*)(*ptr+2), (double)*(float*)(*ptr+3), + (double)*(float*)(*ptr+4), (double)*(float*)(*ptr+5)); + *ptr += 6; + return len; +} + +static int instr_dcl(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) +{ + DWORD param1 = *++*ptr; + DWORD param2 = *++*ptr; + DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; + DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; + char *buf = buffer; + + buf += sprintf(buf, " dcl"); + if (ps) + { + if (param1 & D3DSP_TEXTURETYPE_MASK) + buf += sprintf(buf, "_%s", (usage <= D3DSTT_VOLUME) ? + tex_type[(param1 & D3DSP_TEXTURETYPE_MASK) >> D3DSP_TEXTURETYPE_SHIFT] : "???"); + } + else + { + buf += sprintf(buf, "_%s", (usage <= D3DDECLUSAGE_COLOR) ? decl_usage[usage] : "???"); + if (usage_index) + buf += sprintf(buf, "%d", usage_index); + } + + buf += add_modifier(buf, param2); + buf += sprintf(buf, " "); + buf += add_register(buf, param2, TRUE, TRUE); + buf += sprintf(buf, "\n"); + (*ptr)++; + return buf - buffer; +} + +static int instr_generic(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) +{ + char *buf = buffer; + int j; + + buf += sprintf(buf, " %s", info->name); + (*ptr)++; + + if (info->length) + { + buf += add_modifier(buf, **ptr); + + for (j = 0; j < info->length; j++) + { + buf += sprintf(buf, "%s ", j ? "," : ""); + + if ((j != 0) && ((**ptr & D3DSP_SRCMOD_MASK) != D3DSPSM_NONE)) + { + if ((**ptr & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) + buf += sprintf(buf, "-"); + else + buf += sprintf(buf, "*"); + } + + buf += add_register(buf, **ptr, j == 0, ps); + + if (*(*ptr)++ & D3DVS_ADDRESSMODE_MASK) + { + buf += sprintf(buf, "["); + buf += add_register(buf, **ptr, FALSE, FALSE); + buf += sprintf(buf, "]"); + (*ptr)++; + } + } + } + buf += sprintf(buf, "\n"); + return buf - buffer; +} + +const struct instr_info instructions[] = +{ + { D3DSIO_NOP, "nop", 0, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_MOV, "mov", 2, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_ADD, "add", 3, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_SUB, "sub", 3, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_MAD, "mad", 4, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_MUL, "mul", 3, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_RCP, "rcp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_RSQ, "rsq", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_DP3, "dp3", 3, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_DP4, "dp4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 1.2 for PS */ + { D3DSIO_MIN, "min", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_MAX, "max", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_SLT, "slt", 3, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_SGE, "sge", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ + { D3DSIO_EXP, "exp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_LOG, "log", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_LIT, "lit", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ + { D3DSIO_DST, "dst", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ + { D3DSIO_LRP, "lrp", 4, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for VS */ + { D3DSIO_FRC, "frc", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_M4x4, "m4x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_M4x3, "m4x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_M3x4, "m3x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_M3x3, "m3x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_M3x2, "m3x2", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ + { D3DSIO_CALL, "call", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_CALLNZ, "callnz", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_LOOP, "loop", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ + { D3DSIO_RET, "ret", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_ENDLOOP, "endloop", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ + { D3DSIO_LABEL, "label", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_DCL, "dcl", 1, instr_dcl, 0x0100, 0xFFFF }, + { D3DSIO_POW, "pow", 3, instr_generic, 0x0200, 0xFFFF }, + { D3DSIO_CRS, "crs", 3, instr_generic, 0x0200, 0xFFFF }, + { D3DSIO_SGN, "sgn", 4, instr_generic, 0x0200, 0xFFFF }, /* VS only */ + { D3DSIO_ABS, "abs", 2, instr_generic, 0x0200, 0xFFFF }, + { D3DSIO_NRM, "nrm", 2, instr_generic, 0x0200, 0xFFFF }, + { D3DSIO_SINCOS, "sincos", 4, instr_generic, 0x0200, 0x02FF }, + { D3DSIO_SINCOS, "sincos", 2, instr_generic, 0x0300, 0xFFFF }, + { D3DSIO_REP, "rep", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_ENDREP, "endrep", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_IF, "if", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_IFC, "if_comp", 2, instr_generic, 0x0200, 0xFFFF }, + { D3DSIO_ELSE, "else", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_ENDIF, "endif", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ + { D3DSIO_BREAK, "break", 0, instr_generic, 0x0201, 0xFFFF }, + { D3DSIO_BREAKC, "break_comp", 2, instr_generic, 0x0201, 0xFFFF }, + { D3DSIO_MOVA, "mova", 2, instr_generic, 0x0200, 0xFFFF }, /* VS only */ + { D3DSIO_DEFB, "defb", 2, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_DEFI, "defi", 2, instr_generic, 0x0100, 0xFFFF }, + { D3DSIO_TEXCOORD, "texcoord", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXCOORD, "texcrd", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ + { D3DSIO_TEXKILL, "texkill", 1, instr_generic, 0x0100, 0xFFFF }, /* PS only */ + { D3DSIO_TEX, "tex", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEX, "texld", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ + { D3DSIO_TEX, "texld", 3, instr_generic, 0x0200, 0xFFFF }, /* PS only */ + { D3DSIO_TEXBEM, "texbem", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXBEML, "texbeml", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXREG2AR, "texreg2ar", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXREG2GB, "texreg2gb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x2PAD, "texm3x2pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x2TEX, "texm3x2tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x3PAD, "texm3x3pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x3TEX, "texm3x3tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x3DIFF, "texm3x3diff", 2, instr_generic, 0x0100, 0xFFFF }, /* PS only - Not documented */ + { D3DSIO_TEXM3x3SPEC, "texm3x3spec", 3, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x3VSPEC, "texm3x3vspec", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ + { D3DSIO_EXPP, "expp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ + { D3DSIO_LOGP, "logp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ + { D3DSIO_CND, "cnd", 4, instr_generic, 0x0100, 0x0104 }, /* PS only */ + { D3DSIO_DEF, "def", 5, instr_def, 0x0100, 0xFFFF }, + { D3DSIO_TEXREG2RGB, "texreg2rgb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ + { D3DSIO_TEXDP3TEX, "texdp3tex", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x2DEPTH, "texm3x2depth", 2, instr_generic, 0x0103, 0x0103 }, /* PS only */ + { D3DSIO_TEXDP3, "texdp3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ + { D3DSIO_TEXM3x3, "texm3x3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ + { D3DSIO_TEXDEPTH, "texdepth", 1, instr_generic, 0x0104, 0x0104 }, /* PS only */ + { D3DSIO_CMP, "cmp", 4, instr_generic, 0x0102, 0xFFFF }, /* PS only */ + { D3DSIO_BEM, "bem", 3, instr_generic, 0x0104, 0x0104 }, /* PS only */ + { D3DSIO_DP2ADD, "dp2add", 4, instr_generic, 0x0200, 0xFFFF }, /* PS only */ + { D3DSIO_DSX, "dsx", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ + { D3DSIO_DSY, "dsy", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ + { D3DSIO_TEXLDD, "texldd", 5, instr_generic, 0x0201, 0xFFFF }, /* PS only - not existing for 2.b */ + { D3DSIO_SETP, "setp_comp", 3, instr_generic, 0x0201, 0xFFFF }, + { D3DSIO_TEXLDL, "texldl", 3, instr_generic, 0x0300, 0xFFFF }, + { D3DSIO_BREAKP, "breakp", 1, instr_generic, 0x0201, 0xFFFF }, + { D3DSIO_PHASE, "phase", 0, instr_generic, 0x0104, 0x0104 }, /* PS only */ + { D3DSIO_COMMENT, "", 0, instr_comment, 0x0100, 0xFFFF } +}; + HRESULT WINAPI D3DXDisassembleShader(const DWORD *shader, BOOL colorcode, const char *comments, ID3DXBuffer **disassembly) { - FIXME("%p %d %s %p: stub\n", shader, colorcode, debugstr_a(comments), disassembly); - return E_OUTOFMEMORY; + DWORD *ptr = (DWORD *)shader; + char *buffer, *buf; + UINT capacity = 4096; + BOOL ps; + WORD version; + HRESULT hr; + + TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly); + + if (!shader || !disassembly) + return D3DERR_INVALIDCALL; + + buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity); + if (!buffer) + return E_OUTOFMEMORY; + + ps = (*ptr >> 16) & 1; + version = *ptr & 0xFFFF; + buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr)); + ptr++; + + while (*ptr != D3DSIO_END) + { + DWORD index; + + if ((buf - buffer + 128) > capacity) + { + UINT count = buf - buffer; + char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2); + if (!new_buffer) + { + HeapFree(GetProcessHeap(), 0, buffer); + return E_OUTOFMEMORY; + } + capacity *= 2; + buffer = new_buffer; + buf = buffer + count; + } + + for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++) + if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) && + (version >= instructions[index].min_version) && (version <= instructions[index].max_version)) + break; + + if (index != sizeof(instructions)/sizeof(instructions[0])) + { + buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps); + } + else + { + buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr); + while (*++ptr & (1u << 31)); + } + } + + hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly); + if (SUCCEEDED(hr)) + strcpy(ID3DXBuffer_GetBufferPointer(*disassembly), buffer); + HeapFree(GetProcessHeap(), 0, buffer); + + return hr; } struct d3dx9_texture_shader diff --git a/dll/directx/wine/d3dx9_36/skin.c b/dll/directx/wine/d3dx9_36/skin.c index 309241ccc0..0a305a9923 100644 --- a/dll/directx/wine/d3dx9_36/skin.c +++ b/dll/directx/wine/d3dx9_36/skin.c @@ -2,6 +2,7 @@ * Skin Info operations specific to D3DX9. * * Copyright (C) 2011 Dylan Smith + * Copyright (C) 2013 Christian Costa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,7 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); struct bone { @@ -89,7 +95,7 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface) HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices); HeapFree(GetProcessHeap(), 0, skin->bones[i].weights); } - HeapFree(GetProcessHeap(), 0, skin->bones); + if (skin->bones) HeapFree(GetProcessHeap(), 0, skin->bones); HeapFree(GetProcessHeap(), 0, skin); } @@ -372,10 +378,89 @@ static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface, static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms, const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices) { - FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n", - iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); + struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface); + DWORD size = D3DXGetFVFVertexSize(skin->fvf); + DWORD i, j; - return E_NOTIMPL; + TRACE("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p\n", + skin, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); + + if (bone_inv_transpose_transforms) + FIXME("Skinning vertices with two position elements not supported\n"); + + if ((skin->fvf & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) { + FIXME("Vertex type %#x not supported\n", skin->fvf & D3DFVF_POSITION_MASK); + return E_FAIL; + } + + /* Reset all positions */ + for (i = 0; i < skin->num_vertices; i++) { + D3DXVECTOR3 *position = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i); + position->x = 0.0f; + position->y = 0.0f; + position->z = 0.0f; + } + + /* Update positions that are influenced by bones */ + for (i = 0; i < skin->num_bones; i++) { + D3DXMATRIX bone_inverse, matrix; + + D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); + D3DXMatrixMultiply(&matrix, &bone_transforms[i], &bone_inverse); + D3DXMatrixMultiply(&matrix, &matrix, &skin->bones[i].transform); + + for (j = 0; j < skin->bones[i].num_influences; j++) { + D3DXVECTOR3 position; + D3DXVECTOR3 *position_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j]); + D3DXVECTOR3 *position_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j]); + FLOAT weight = skin->bones[i].weights[j]; + + D3DXVec3TransformCoord(&position, position_src, &matrix); + position_dest->x += weight * position.x; + position_dest->y += weight * position.y; + position_dest->z += weight * position.z; + } + } + + if (skin->fvf & D3DFVF_NORMAL) { + /* Reset all normals */ + for (i = 0; i < skin->num_vertices; i++) { + D3DXVECTOR3 *normal = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i + sizeof(D3DXVECTOR3)); + normal->x = 0.0f; + normal->y = 0.0f; + normal->z = 0.0f; + } + + /* Update normals that are influenced by bones */ + for (i = 0; i < skin->num_bones; i++) { + D3DXMATRIX bone_inverse, matrix; + + D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); + D3DXMatrixMultiply(&matrix, &skin->bones[i].transform, &bone_transforms[i]); + + for (j = 0; j < skin->bones[i].num_influences; j++) { + D3DXVECTOR3 normal; + D3DXVECTOR3 *normal_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); + D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); + FLOAT weight = skin->bones[i].weights[j]; + + D3DXVec3TransformNormal(&normal, normal_src, &bone_inverse); + D3DXVec3TransformNormal(&normal, &normal, &matrix); + normal_dest->x += weight * normal.x; + normal_dest->y += weight * normal.y; + normal_dest->z += weight * normal.z; + } + } + + /* Normalize all normals that are influenced by bones*/ + for (i = 0; i < skin->num_vertices; i++) { + D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + (i * size) + sizeof(D3DXVECTOR3)); + if ((normal_dest->x != 0.0f) && (normal_dest->y != 0.0f) && (normal_dest->z != 0.0f)) + D3DXVec3Normalize(normal_dest, normal_dest); + } + } + + return D3D_OK; } static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in, @@ -490,3 +575,23 @@ HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD num_vertices, DWORD fvf, DWORD num_bo return D3DXCreateSkinInfo(num_vertices, declaration, num_bones, skin_info); } + +HRESULT create_dummy_skin(ID3DXSkinInfo **iface) +{ + static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END(); + struct d3dx9_skin_info *object = NULL; + + object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); + if (!object) return E_OUTOFMEMORY; + + object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl; + object->ref = 1; + object->num_vertices = 0; + object->num_bones = 0; + object->vertex_declaration[0] = empty_declaration; + object->fvf = 0; + object->bones = NULL; + + *iface = &object->ID3DXSkinInfo_iface; + return D3D_OK; +} diff --git a/dll/directx/wine/d3dx9_36/sprite.c b/dll/directx/wine/d3dx9_36/sprite.c index ba7181b42e..2ff2b415c8 100644 --- a/dll/directx/wine/d3dx9_36/sprite.c +++ b/dll/directx/wine/d3dx9_36/sprite.c @@ -17,7 +17,12 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); /* the combination of all possible D3DXSPRITE flags */ #define D3DXSPRITE_FLAGLIMIT 511 diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index 321265fbaa..a1e56bda6d 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -18,13 +18,19 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" -#include <ole2.h> -#include <wine/wined3d.h> +#include "d3dx9_private.h" + +#include "initguid.h" +#include "ole2.h" +#include "wincodec.h" + +#include "wine/wined3d.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); -#include <initguid.h> -#include <wincodec.h> /* Wine-specific WIC GUIDs */ DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22); @@ -49,7 +55,7 @@ static D3DFORMAT wic_guid_to_d3dformat(const GUID *guid) { unsigned int i; - for (i = 0; i < sizeof(wic_pixel_formats) / sizeof(wic_pixel_formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(wic_pixel_formats); i++) { if (IsEqualGUID(wic_pixel_formats[i].wic_guid, guid)) return wic_pixel_formats[i].d3dformat; @@ -62,7 +68,7 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format) { unsigned int i; - for (i = 0; i < sizeof(wic_pixel_formats) / sizeof(wic_pixel_formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(wic_pixel_formats); i++) { if (wic_pixel_formats[i].d3dformat == format) return wic_pixel_formats[i].wic_guid; @@ -106,6 +112,7 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format) #define DDS_PF_RGB 0x40 #define DDS_PF_YUV 0x200 #define DDS_PF_LUMINANCE 0x20000 +#define DDS_PF_BUMPLUMINANCE 0x40000 #define DDS_PF_BUMPDUDV 0x80000 struct dds_pixel_format @@ -160,7 +167,7 @@ static D3DFORMAT dds_fourcc_to_d3dformat(DWORD fourcc) D3DFMT_A32B32G32R32F, }; - for (i = 0; i < sizeof(known_fourcc) / sizeof(known_fourcc[0]); i++) + for (i = 0; i < ARRAY_SIZE(known_fourcc); i++) { if (known_fourcc[i] == fourcc) return fourcc; @@ -199,7 +206,7 @@ static D3DFORMAT dds_rgb_to_d3dformat(const struct dds_pixel_format *pixel_forma { unsigned int i; - for (i = 0; i < sizeof(rgb_pixel_formats) / sizeof(rgb_pixel_formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(rgb_pixel_formats); i++) { if (rgb_pixel_formats[i].bpp == pixel_format->bpp && rgb_pixel_formats[i].rmask == pixel_format->rmask @@ -261,6 +268,17 @@ static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_form return D3DFMT_UNKNOWN; } +static D3DFORMAT dds_bump_luminance_to_d3dformat(const struct dds_pixel_format *pixel_format) +{ + if (pixel_format->bpp == 32 && pixel_format->rmask == 0x000000ff && pixel_format->gmask == 0x0000ff00 + && pixel_format->bmask == 0x00ff0000) + return D3DFMT_X8L8V8U8; + + WARN("Unknown bump pixel format (%u, %#x, %#x, %#x, %#x)\n", pixel_format->bpp, + pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask); + return D3DFMT_UNKNOWN; +} + static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format) { TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size, @@ -278,6 +296,8 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return dds_alpha_to_d3dformat(pixel_format); if (pixel_format->flags & DDS_PF_BUMPDUDV) return dds_bump_to_d3dformat(pixel_format); + if (pixel_format->flags & DDS_PF_BUMPLUMINANCE) + return dds_bump_luminance_to_d3dformat(pixel_format); WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %u, r %#x, g %#x, b %#x, a %#x)\n", pixel_format->flags, pixel_format->fourcc, pixel_format->bpp, @@ -293,7 +313,7 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form pixel_format->size = sizeof(*pixel_format); - for (i = 0; i < sizeof(rgb_pixel_formats) / sizeof(rgb_pixel_formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(rgb_pixel_formats); i++) { if (rgb_pixel_formats[i].format == d3dformat) { @@ -308,6 +328,14 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form } } + /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */ + if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN) + { + pixel_format->flags |= DDS_PF_FOURCC; + pixel_format->fourcc = d3dformat; + return D3D_OK; + } + WARN("Unknown pixel format %#x\n", d3dformat); return E_NOTIMPL; } @@ -516,6 +544,68 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; } +static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, + int face, UINT level, struct IDirect3DSurface9 **surf) +{ + switch (type) + { + case D3DRTYPE_TEXTURE: + return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf); + case D3DRTYPE_CUBETEXTURE: + return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf); + default: + ERR("Unexpected texture type\n"); + return E_NOTIMPL; + } +} + +HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) +{ + HRESULT hr; + D3DRESOURCETYPE type; + UINT mip_levels; + IDirect3DSurface9 *surface; + + type = IDirect3DBaseTexture9_GetType(src_texture); + + if ((type != D3DRTYPE_TEXTURE) && (type != D3DRTYPE_CUBETEXTURE) && (type != D3DRTYPE_VOLUMETEXTURE)) + return D3DERR_INVALIDCALL; + + if (type == D3DRTYPE_CUBETEXTURE) + { + FIXME("Cube texture not supported yet\n"); + return E_NOTIMPL; + } + else if (type == D3DRTYPE_VOLUMETEXTURE) + { + FIXME("Volume texture not supported yet\n"); + return E_NOTIMPL; + } + + mip_levels = IDirect3DTexture9_GetLevelCount(src_texture); + + if (mip_levels > 1) + { + FIXME("Mipmap not supported yet\n"); + return E_NOTIMPL; + } + + if (src_palette) + { + FIXME("Saving surfaces with palettized pixel formats not implemented yet\n"); + return E_NOTIMPL; + } + + hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface); + + if (SUCCEEDED(hr)) + { + hr = save_dds_surface_to_memory(dst_buffer, surface, NULL); + IDirect3DSurface9_Release(surface); + } + + return hr; +} HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) @@ -883,6 +973,24 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, } } + /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while + * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */ + if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) { + DWORD size = sizeof(DWORD) * info->Width * info->Height; + BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size); + hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer); + if (SUCCEEDED(hr)) { + DWORD i; + for (i = 0; i < info->Width * info->Height; i++) { + if (buffer[i*4+3]) { + info->Format = D3DFMT_A8R8G8B8; + break; + } + } + } + HeapFree(GetProcessHeap(), 0, buffer); + } + if (frame) IWICBitmapFrameDecode_Release(frame); @@ -1711,6 +1819,27 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic } } +typedef BOOL (*dxtn_conversion_func)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, + enum wined3d_format_id format, unsigned int w, unsigned int h); + +static dxtn_conversion_func get_dxtn_conversion_func(D3DFORMAT format, BOOL encode) +{ + switch (format) + { + case D3DFMT_DXT1: + if (!wined3d_dxtn_supported()) return NULL; + return encode ? wined3d_dxt1_encode : wined3d_dxt1_decode; + case D3DFMT_DXT3: + if (!wined3d_dxtn_supported()) return NULL; + return encode ? wined3d_dxt3_encode : wined3d_dxt3_decode; + case D3DFMT_DXT5: + if (!wined3d_dxtn_supported()) return NULL; + return encode ? wined3d_dxt5_encode : wined3d_dxt5_decode; + default: + return NULL; + } +} + /************************************************************ * D3DXLoadSurfaceFromMemory * @@ -1752,6 +1881,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; struct volume src_size, dst_size; + HRESULT ret = D3D_OK; TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format, @@ -1833,8 +1963,15 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, } else /* Stretching or format conversion. */ { - if (!is_conversion_from_supported(srcformatdesc) - || !is_conversion_to_supported(destformatdesc)) + dxtn_conversion_func pre_convert, post_convert; + void *tmp_src_memory = NULL, *tmp_dst_memory = NULL; + UINT tmp_src_pitch, tmp_dst_pitch; + + pre_convert = get_dxtn_conversion_func(srcformatdesc->format, FALSE); + post_convert = get_dxtn_conversion_func(destformatdesc->format, TRUE); + + if ((!pre_convert && !is_conversion_from_supported(srcformatdesc)) || + (!post_convert && !is_conversion_to_supported(destformatdesc))) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); return E_NOTIMPL; @@ -1843,10 +1980,52 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0))) return D3DXERR_INVALIDDATA; + /* handle pre-conversion */ + if (pre_convert) + { + tmp_src_memory = HeapAlloc(GetProcessHeap(), 0, src_size.width * src_size.height * sizeof(DWORD)); + if (!tmp_src_memory) + { + ret = E_OUTOFMEMORY; + goto error; + } + tmp_src_pitch = src_size.width * sizeof(DWORD); + if (!pre_convert(src_memory, tmp_src_memory, src_pitch, tmp_src_pitch, + WINED3DFMT_B8G8R8A8_UNORM, src_size.width, src_size.height)) + { + ret = E_FAIL; + goto error; + } + srcformatdesc = get_format_info(D3DFMT_A8R8G8B8); + } + else + { + tmp_src_memory = (void *)src_memory; + tmp_src_pitch = src_pitch; + } + + /* handle post-conversion */ + if (post_convert) + { + tmp_dst_memory = HeapAlloc(GetProcessHeap(), 0, dst_size.width * dst_size.height * sizeof(DWORD)); + if (!tmp_dst_memory) + { + ret = E_OUTOFMEMORY; + goto error; + } + tmp_dst_pitch = dst_size.width * sizeof(DWORD); + destformatdesc = get_format_info(D3DFMT_A8R8G8B8); + } + else + { + tmp_dst_memory = lockrect.pBits; + tmp_dst_pitch = lockrect.Pitch; + } + if ((filter & 0xf) == D3DX_FILTER_NONE) { - convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, - lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + convert_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, + tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */ { @@ -1855,14 +2034,30 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, /* Always apply a point filter until D3DX_FILTER_LINEAR, * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */ - point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, - lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + point_filter_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, + tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } + /* handle post-conversion */ + if (post_convert) + { + if (!post_convert(tmp_dst_memory, lockrect.pBits, tmp_dst_pitch, lockrect.Pitch, + WINED3DFMT_B8G8R8A8_UNORM, dst_size.width, dst_size.height)) + { + ret = E_FAIL; + goto error; + } + } + +error: + if (pre_convert) + HeapFree(GetProcessHeap(), 0, tmp_src_memory); + if (post_convert) + HeapFree(GetProcessHeap(), 0, tmp_dst_memory); IDirect3DSurface9_UnlockRect(dst_surface); } - return D3D_OK; + return ret; } /************************************************************ diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index f4e3231483..fa5ccfc66e 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -19,7 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); /* Returns TRUE if num is a power of 2, FALSE if not, or if 0 */ static BOOL is_pow2(UINT num) @@ -195,7 +200,7 @@ static D3DFORMAT get_luminance_replacement_format(D3DFORMAT format) }; unsigned int i; - for (i = 0; i < sizeof(luminance_replacements) / sizeof(luminance_replacements[0]); ++i) + for (i = 0; i < ARRAY_SIZE(luminance_replacements); ++i) if (format == luminance_replacements[i].luminance_format) return luminance_replacements[i].replacement_format; return format; @@ -330,10 +335,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN if (fmt->block_width != 1 || fmt->block_height != 1) { - if (w < fmt->block_width) - w = fmt->block_width; - if (h < fmt->block_height) - h = fmt->block_height; + if (w % fmt->block_width) + w += fmt->block_width - w % fmt->block_width; + if (h % fmt->block_height) + h += fmt->block_height - h % fmt->block_height; } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w))) @@ -552,7 +557,7 @@ static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format) }; unsigned int i; - for (i = 0; i < sizeof(replacement_formats) / sizeof(replacement_formats[0]); ++i) + for (i = 0; i < ARRAY_SIZE(replacement_formats); ++i) if (replacement_formats[i].orig_format == format) return replacement_formats[i].replacement_format; return format; @@ -1887,10 +1892,7 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL; if (file_format == D3DXIFF_DDS) - { - FIXME("DDS file format isn't supported yet\n"); - return E_NOTIMPL; - } + return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette); type = IDirect3DBaseTexture9_GetType(src_texture); switch (type) diff --git a/dll/directx/wine/d3dx9_36/util.c b/dll/directx/wine/d3dx9_36/util.c index 47f9637d83..029e50073c 100644 --- a/dll/directx/wine/d3dx9_36/util.c +++ b/dll/directx/wine/d3dx9_36/util.c @@ -17,7 +17,12 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); static void la_from_rgba(const struct vec4 *rgba, struct vec4 *la) { @@ -85,6 +90,7 @@ static const struct pixel_format_desc formats[] = {D3DFMT_G32R32F, { 0, 32, 32, 0}, { 0, 0, 32, 0}, 8, 1, 1, 8, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_A32B32G32R32F, {32, 32, 32, 32}, {96, 0, 32, 64}, 16, 1, 1, 16, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_INDEX, NULL, index_to_rgba}, + {D3DFMT_X8L8V8U8, { 0, 8, 8, 8}, { 0, 0, 8, 16}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL }, /* marks last element */ {D3DFMT_UNKNOWN, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 0, 1, 1, 0, FORMAT_UNKNOWN, NULL, NULL }, }; @@ -215,7 +221,7 @@ const struct pixel_format_desc *get_format_info(D3DFORMAT format) const struct pixel_format_desc *get_format_info_idx(int idx) { - if(idx >= sizeof(formats) / sizeof(formats[0])) + if(idx >= ARRAY_SIZE(formats)) return NULL; if(formats[idx].format == D3DFMT_UNKNOWN) return NULL; diff --git a/dll/directx/wine/d3dx9_36/volume.c b/dll/directx/wine/d3dx9_36/volume.c index c72dfc5708..f07e552dbe 100644 --- a/dll/directx/wine/d3dx9_36/volume.c +++ b/dll/directx/wine/d3dx9_36/volume.c @@ -16,7 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" + +#include "d3dx9_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); HRESULT WINAPI D3DXLoadVolumeFromFileA(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, diff --git a/dll/directx/wine/d3dx9_36/xfile.c b/dll/directx/wine/d3dx9_36/xfile.c index 795b7bc3ff..157545482b 100644 --- a/dll/directx/wine/d3dx9_36/xfile.c +++ b/dll/directx/wine/d3dx9_36/xfile.c @@ -17,9 +17,15 @@ * */ -#include "d3dx9_36_private.h" +#include "config.h" +#include "wine/port.h" -#include <dxfile.h> +#include "d3dx9_private.h" +#include "d3dx9xof.h" +#undef MAKE_DDHRESULT +#include "dxfile.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); static HRESULT error_dxfile_to_d3dxfile(HRESULT error) { diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 5e789914d8..1f00297ce1 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -26,7 +26,7 @@ reactos/dll/directx/wine/d3d8 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3d9 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3drm # Synced to WineStaging-3.3 -reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 +reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.3 reactos/dll/directx/wine/devenum # Synced to Wine-3.0
6 years, 9 months
1
0
0
0
01/01: [D3DRM] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e792c304fe4110f0d20ca…
commit e792c304fe4110f0d20ca80917e0a706b8db4d34 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:17:38 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:17:38 2018 +0100 [D3DRM] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/d3drm/CMakeLists.txt | 4 +- dll/directx/wine/d3drm/d3drm.c | 9 ++- dll/directx/wine/d3drm/d3drm_main.c | 17 +++--- dll/directx/wine/d3drm/d3drm_private.h | 27 +++------ dll/directx/wine/d3drm/device.c | 9 ++- dll/directx/wine/d3drm/face.c | 9 ++- dll/directx/wine/d3drm/frame.c | 57 +++++++++-------- dll/directx/wine/d3drm/light.c | 9 ++- dll/directx/wine/d3drm/material.c | 9 ++- dll/directx/wine/d3drm/math.c | 5 +- dll/directx/wine/d3drm/meshbuilder.c | 108 ++++++++++++++++----------------- dll/directx/wine/d3drm/precomp.h | 19 ++++++ dll/directx/wine/d3drm/texture.c | 9 ++- dll/directx/wine/d3drm/viewport.c | 9 ++- media/doc/README.WINE | 2 +- 15 files changed, 175 insertions(+), 127 deletions(-) diff --git a/dll/directx/wine/d3drm/CMakeLists.txt b/dll/directx/wine/d3drm/CMakeLists.txt index 7247444ed2..f2ff1f204e 100644 --- a/dll/directx/wine/d3drm/CMakeLists.txt +++ b/dll/directx/wine/d3drm/CMakeLists.txt @@ -15,7 +15,7 @@ list(APPEND SOURCE meshbuilder.c texture.c viewport.c - d3drm_private.h) + precomp.h) add_library(d3drm SHARED ${SOURCE} @@ -26,5 +26,5 @@ add_library(d3drm SHARED set_module_type(d3drm win32dll UNICODE) target_link_libraries(d3drm dxguid uuid wine) add_importlibs(d3drm ddraw d3dxof msvcrt kernel32 ntdll) -add_pch(d3drm d3drm_private.h SOURCE) +add_pch(d3drm precomp.h SOURCE) add_cd_file(TARGET d3drm DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3drm/d3drm.c b/dll/directx/wine/d3drm/d3drm.c index 8c46751f6e..3ea16327bf 100644 --- a/dll/directx/wine/d3drm/d3drm.c +++ b/dll/directx/wine/d3drm/d3drm.c @@ -20,8 +20,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static const char* get_IID_string(const GUID* guid) { if (IsEqualGUID(guid, &IID_IDirect3DRMFrame)) @@ -208,7 +213,7 @@ static inline struct d3drm *impl_from_IDirect3DRM3(IDirect3DRM3 *iface) static void d3drm_destroy(struct d3drm *d3drm) { - HeapFree(GetProcessHeap(), 0, d3drm); + heap_free(d3drm); TRACE("d3drm object %p is being destroyed.\n", d3drm); } @@ -2303,7 +2308,7 @@ HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm) TRACE("d3drm %p.\n", d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRM_iface.lpVtbl = &d3drm1_vtbl; diff --git a/dll/directx/wine/d3drm/d3drm_main.c b/dll/directx/wine/d3drm/d3drm_main.c index 5071671879..1abfe6f46e 100644 --- a/dll/directx/wine/d3drm/d3drm_main.c +++ b/dll/directx/wine/d3drm/d3drm_main.c @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include "initguid.h" #include "d3drm_private.h" /*********************************************************************** @@ -58,8 +62,7 @@ HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJE if (!cb) return D3DRMERR_BADVALUE; - callback = HeapAlloc(GetProcessHeap(), 0, sizeof(*callback)); - if (!callback) + if (!(callback = heap_alloc(sizeof(*callback)))) return E_OUTOFMEMORY; callback->cb = cb; @@ -81,7 +84,7 @@ HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMO if (callback->cb == cb && callback->ctx == ctx) { list_remove(&callback->entry); - HeapFree(GetProcessHeap(), 0, callback); + heap_free(callback); break; } } @@ -136,13 +139,13 @@ HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name) { DWORD req_size; - HeapFree(GetProcessHeap(), 0, object->name); + heap_free(object->name); object->name = NULL; if (name) { req_size = strlen(name) + 1; - if (!(object->name = HeapAlloc(GetProcessHeap(), 0, req_size))) + if (!(object->name = heap_alloc(req_size))) return E_OUTOFMEMORY; memcpy(object->name, name, req_size); } @@ -158,9 +161,9 @@ void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) { callback->cb(iface, callback->ctx); list_remove(&callback->entry); - HeapFree(GetProcessHeap(), 0, callback); + heap_free(callback); } - HeapFree(GetProcessHeap(), 0, object->name); + heap_free(object->name); object->name = NULL; } diff --git a/dll/directx/wine/d3drm/d3drm_private.h b/dll/directx/wine/d3drm/d3drm_private.h index f6391a9b97..0f24f80d24 100644 --- a/dll/directx/wine/d3drm/d3drm_private.h +++ b/dll/directx/wine/d3drm/d3drm_private.h @@ -21,28 +21,17 @@ #ifndef __D3DRM_PRIVATE_INCLUDED__ #define __D3DRM_PRIVATE_INCLUDED__ -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS #define NONAMELESSUNION - +#define NONAMELESSSTRUCT +#define COBJMACROS #include <assert.h> #include <math.h> - -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> -#include <d3drm.h> -#include <dxfile.h> -#include <d3drmwin.h> -#include <rmxfguid.h> - -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(d3drm); - -#include <wine/list.h> +#include "dxfile.h" +#include "d3drmwin.h" +#include "rmxfguid.h" +#include "wine/debug.h" +#include "wine/heap.h" +#include "wine/list.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) diff --git a/dll/directx/wine/d3drm/device.c b/dll/directx/wine/d3drm/device.c index 865e372289..2aa7e48086 100644 --- a/dll/directx/wine/d3drm/device.c +++ b/dll/directx/wine/d3drm/device.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_device *impl_from_IDirect3DRMDevice(IDirect3DRMDevice *iface) { return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice_iface); @@ -56,7 +61,7 @@ void d3drm_device_destroy(struct d3drm_device *device) IDirectDraw_Release(device->ddraw); IDirect3DRM_Release(device->d3drm); } - HeapFree(GetProcessHeap(), 0, device); + heap_free(device); } static inline struct d3drm_device *impl_from_IDirect3DRMWinDevice(IDirect3DRMWinDevice *iface) @@ -1636,7 +1641,7 @@ HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) TRACE("device %p, d3drm %p.\n", device, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMDevice_iface.lpVtbl = &d3drm_device1_vtbl; diff --git a/dll/directx/wine/d3drm/face.c b/dll/directx/wine/d3drm/face.c index ff492d0e09..324b1de1bc 100644 --- a/dll/directx/wine/d3drm/face.c +++ b/dll/directx/wine/d3drm/face.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_face *impl_from_IDirect3DRMFace(IDirect3DRMFace *iface) { return CONTAINING_RECORD(iface, struct d3drm_face, IDirect3DRMFace_iface); @@ -77,7 +82,7 @@ static ULONG WINAPI d3drm_face1_Release(IDirect3DRMFace *iface) if (!refcount) { d3drm_object_cleanup((IDirect3DRMObject *)iface, &face->obj); - HeapFree(GetProcessHeap(), 0, face); + heap_free(face); } return refcount; @@ -622,7 +627,7 @@ HRESULT d3drm_face_create(struct d3drm_face **face) TRACE("face %p.\n", face); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMFace_iface.lpVtbl = &d3drm_face1_vtbl; diff --git a/dll/directx/wine/d3drm/frame.c b/dll/directx/wine/d3drm/frame.c index 1f1fcdbd85..11105db403 100644 --- a/dll/directx/wine/d3drm/frame.c +++ b/dll/directx/wine/d3drm/frame.c @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static D3DRMMATRIX4D identity = { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -136,8 +141,8 @@ static ULONG WINAPI d3drm_frame_array_Release(IDirect3DRMFrameArray *iface) { IDirect3DRMFrame_Release(array->frames[i]); } - HeapFree(GetProcessHeap(), 0, array->frames); - HeapFree(GetProcessHeap(), 0, array); + heap_free(array->frames); + heap_free(array); } return refcount; @@ -188,7 +193,7 @@ static struct d3drm_frame_array *d3drm_frame_array_create(unsigned int frame_cou struct d3drm_frame_array *array; unsigned int i; - if (!(array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*array)))) + if (!(array = heap_alloc_zero(sizeof(*array)))) return NULL; array->IDirect3DRMFrameArray_iface.lpVtbl = &d3drm_frame_array_vtbl; @@ -197,9 +202,9 @@ static struct d3drm_frame_array *d3drm_frame_array_create(unsigned int frame_cou if (frame_count) { - if (!(array->frames = HeapAlloc(GetProcessHeap(), 0, frame_count * sizeof(*array->frames)))) + if (!(array->frames = heap_calloc(frame_count, sizeof(*array->frames)))) { - HeapFree(GetProcessHeap(), 0, array); + heap_free(array); return NULL; } @@ -254,8 +259,8 @@ static ULONG WINAPI d3drm_visual_array_Release(IDirect3DRMVisualArray *iface) { IDirect3DRMVisual_Release(array->visuals[i]); } - HeapFree(GetProcessHeap(), 0, array->visuals); - HeapFree(GetProcessHeap(), 0, array); + heap_free(array->visuals); + heap_free(array); } return refcount; @@ -306,7 +311,7 @@ static struct d3drm_visual_array *d3drm_visual_array_create(unsigned int visual_ struct d3drm_visual_array *array; unsigned int i; - if (!(array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*array)))) + if (!(array = heap_alloc_zero(sizeof(*array)))) return NULL; array->IDirect3DRMVisualArray_iface.lpVtbl = &d3drm_visual_array_vtbl; @@ -315,9 +320,9 @@ static struct d3drm_visual_array *d3drm_visual_array_create(unsigned int visual_ if (visual_count) { - if (!(array->visuals = HeapAlloc(GetProcessHeap(), 0, visual_count * sizeof(*array->visuals)))) + if (!(array->visuals = heap_calloc(visual_count, sizeof(*array->visuals)))) { - HeapFree(GetProcessHeap(), 0, array); + heap_free(array); return NULL; } @@ -373,8 +378,8 @@ static ULONG WINAPI d3drm_light_array_Release(IDirect3DRMLightArray *iface) { IDirect3DRMLight_Release(array->lights[i]); } - HeapFree(GetProcessHeap(), 0, array->lights); - HeapFree(GetProcessHeap(), 0, array); + heap_free(array->lights); + heap_free(array); } return refcount; @@ -425,7 +430,7 @@ static struct d3drm_light_array *d3drm_light_array_create(unsigned int light_cou struct d3drm_light_array *array; unsigned int i; - if (!(array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*array)))) + if (!(array = heap_alloc_zero(sizeof(*array)))) return NULL; array->IDirect3DRMLightArray_iface.lpVtbl = &d3drm_light_array_vtbl; @@ -434,9 +439,9 @@ static struct d3drm_light_array *d3drm_light_array_create(unsigned int light_cou if (light_count) { - if (!(array->lights = HeapAlloc(GetProcessHeap(), 0, light_count * sizeof(*array->lights)))) + if (!(array->lights = heap_calloc(light_count, sizeof(*array->lights)))) { - HeapFree(GetProcessHeap(), 0, array); + heap_free(array); return NULL; } @@ -543,19 +548,19 @@ static ULONG WINAPI d3drm_frame3_Release(IDirect3DRMFrame3 *iface) { IDirect3DRMFrame3_Release(frame->children[i]); } - HeapFree(GetProcessHeap(), 0, frame->children); + heap_free(frame->children); for (i = 0; i < frame->nb_visuals; ++i) { IDirect3DRMVisual_Release(frame->visuals[i]); } - HeapFree(GetProcessHeap(), 0, frame->visuals); + heap_free(frame->visuals); for (i = 0; i < frame->nb_lights; ++i) { IDirect3DRMLight_Release(frame->lights[i]); } - HeapFree(GetProcessHeap(), 0, frame->lights); + heap_free(frame->lights); IDirect3DRM_Release(frame->d3drm); - HeapFree(GetProcessHeap(), 0, frame); + heap_free(frame); } return refcount; @@ -2935,7 +2940,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I TRACE("frame %p, parent_frame %p, d3drm %p.\n", frame, parent_frame, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMFrame_iface.lpVtbl = &d3drm_frame1_vtbl; @@ -2956,7 +2961,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I if (FAILED(hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&p))) { - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } IDirect3DRMFrame_Release(parent_frame); @@ -3033,10 +3038,10 @@ static ULONG WINAPI d3drm_animation2_Release(IDirect3DRMAnimation2 *iface) { d3drm_object_cleanup((IDirect3DRMObject *)&animation->IDirect3DRMAnimation_iface, &animation->obj); IDirect3DRM_Release(animation->d3drm); - HeapFree(GetProcessHeap(), 0, animation->rotate.keys); - HeapFree(GetProcessHeap(), 0, animation->scale.keys); - HeapFree(GetProcessHeap(), 0, animation->position.keys); - HeapFree(GetProcessHeap(), 0, animation); + heap_free(animation->rotate.keys); + heap_free(animation->scale.keys); + heap_free(animation->position.keys); + heap_free(animation); } return refcount; @@ -3687,7 +3692,7 @@ HRESULT d3drm_animation_create(struct d3drm_animation **animation, IDirect3DRM * TRACE("animation %p, d3drm %p.\n", animation, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMAnimation_iface.lpVtbl = &d3drm_animation1_vtbl; diff --git a/dll/directx/wine/d3drm/light.c b/dll/directx/wine/d3drm/light.c index b266956ed9..e31c02675a 100644 --- a/dll/directx/wine/d3drm/light.c +++ b/dll/directx/wine/d3drm/light.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface) { return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface); @@ -65,7 +70,7 @@ static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface) { d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj); IDirect3DRM_Release(light->d3drm); - HeapFree(GetProcessHeap(), 0, light); + heap_free(light); } return refcount; @@ -373,7 +378,7 @@ HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) TRACE("light %p.\n", light); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl; diff --git a/dll/directx/wine/d3drm/material.c b/dll/directx/wine/d3drm/material.c index 4b56148b28..62acb5a8d4 100644 --- a/dll/directx/wine/d3drm/material.c +++ b/dll/directx/wine/d3drm/material.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_material *impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2 *iface) { return CONTAINING_RECORD(iface, struct d3drm_material, IDirect3DRMMaterial2_iface); @@ -66,7 +71,7 @@ static ULONG WINAPI d3drm_material_Release(IDirect3DRMMaterial2 *iface) { d3drm_object_cleanup((IDirect3DRMObject *)iface, &material->obj); IDirect3DRM_Release(material->d3drm); - HeapFree(GetProcessHeap(), 0, material); + heap_free(material); } return refcount; @@ -281,7 +286,7 @@ HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3d TRACE("material %p, d3drm %p.\n", material, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMMaterial2_iface.lpVtbl = &d3drm_material_vtbl; diff --git a/dll/directx/wine/d3drm/math.c b/dll/directx/wine/d3drm/math.c index 94d87710f6..a6c0c85812 100644 --- a/dll/directx/wine/d3drm/math.c +++ b/dll/directx/wine/d3drm/math.c @@ -17,9 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "d3drm_private.h" +#include "config.h" +#include "wine/port.h" -#include <math.h> +#include "d3drm_private.h" /* Create a RGB color from its components */ D3DCOLOR WINAPI D3DRMCreateColorRGB(D3DVALUE red, D3DVALUE green, D3DVALUE blue) diff --git a/dll/directx/wine/d3drm/meshbuilder.c b/dll/directx/wine/d3drm/meshbuilder.c index 962d8f6059..009055593c 100644 --- a/dll/directx/wine/d3drm/meshbuilder.c +++ b/dll/directx/wine/d3drm/meshbuilder.c @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + struct coords_2d { D3DVALUE u; @@ -274,12 +279,7 @@ BOOL d3drm_array_reserve(void **elements, SIZE_T *capacity, SIZE_T element_count if (new_capacity < element_count) new_capacity = max_capacity; - if (*elements) - new_elements = HeapReAlloc(GetProcessHeap(), 0, *elements, new_capacity * element_size); - else - new_elements = HeapAlloc(GetProcessHeap(), 0, new_capacity * element_size); - - if (!new_elements) + if (!(new_elements = heap_realloc(*elements, new_capacity * element_size))) return FALSE; *elements = new_elements; @@ -312,19 +312,19 @@ static void clean_mesh_builder_data(struct d3drm_mesh_builder *mesh_builder) DWORD i; IDirect3DRMMeshBuilder3_SetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, NULL); - HeapFree(GetProcessHeap(), 0, mesh_builder->vertices); + heap_free(mesh_builder->vertices); mesh_builder->vertices = NULL; mesh_builder->nb_vertices = 0; mesh_builder->vertices_size = 0; - HeapFree(GetProcessHeap(), 0, mesh_builder->normals); + heap_free(mesh_builder->normals); mesh_builder->normals = NULL; mesh_builder->nb_normals = 0; mesh_builder->normals_size = 0; - HeapFree(GetProcessHeap(), 0, mesh_builder->pFaceData); + heap_free(mesh_builder->pFaceData); mesh_builder->pFaceData = NULL; mesh_builder->face_data_size = 0; mesh_builder->nb_faces = 0; - HeapFree(GetProcessHeap(), 0, mesh_builder->pCoords2d); + heap_free(mesh_builder->pCoords2d); mesh_builder->pCoords2d = NULL; mesh_builder->nb_coords2d = 0; for (i = 0; i < mesh_builder->nb_materials; i++) @@ -335,9 +335,9 @@ static void clean_mesh_builder_data(struct d3drm_mesh_builder *mesh_builder) IDirect3DRMTexture3_Release(mesh_builder->materials[i].texture); } mesh_builder->nb_materials = 0; - HeapFree(GetProcessHeap(), 0, mesh_builder->materials); + heap_free(mesh_builder->materials); mesh_builder->materials = NULL; - HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices); + heap_free(mesh_builder->material_indices); mesh_builder->material_indices = NULL; } @@ -396,7 +396,7 @@ static ULONG WINAPI d3drm_mesh_builder2_Release(IDirect3DRMMeshBuilder2 *iface) if (mesh_builder->texture) IDirect3DRMTexture3_Release(mesh_builder->texture); IDirect3DRM_Release(mesh_builder->d3drm); - HeapFree(GetProcessHeap(), 0, mesh_builder); + heap_free(mesh_builder); } return refcount; @@ -1045,13 +1045,14 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, return hr; if (size) { - char *name = HeapAlloc(GetProcessHeap(), 0, size); - if (!name) + char *name; + + if (!(name = heap_alloc(size))) return E_OUTOFMEMORY; if (SUCCEEDED(hr = IDirectXFileData_GetName(pData, name, &size))) IDirect3DRMMeshBuilder3_SetName(iface, name); - HeapFree(GetProcessHeap(), 0, name); + heap_free(name); if (hr != DXFILE_OK) return hr; } @@ -1079,12 +1080,12 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, } memcpy(mesh_builder->vertices, ptr + sizeof(DWORD), mesh_builder->nb_vertices * sizeof(D3DVECTOR)); - faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size); + faces_vertex_idx_ptr = faces_vertex_idx_data = heap_alloc(faces_vertex_idx_size); memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + mesh_builder->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size); /* Each vertex index will have its normal index counterpart so just allocate twice the size */ - mesh_builder->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2); + mesh_builder->pFaceData = heap_alloc(faces_vertex_idx_size * 2); faces_data_ptr = (DWORD*)mesh_builder->pFaceData; while (1) @@ -1136,8 +1137,9 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, memcpy(mesh_builder->normals, ptr + sizeof(DWORD), mesh_builder->nb_normals * sizeof(D3DVECTOR)); faces_normal_idx_size = size - (2 * sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR)); - faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size); - memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size); + faces_normal_idx_ptr = faces_normal_idx_data = heap_alloc(faces_normal_idx_size); + memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR) + + sizeof(DWORD), faces_normal_idx_size); } else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords)) { @@ -1149,7 +1151,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, TRACE("MeshTextureCoords: nb_coords2d = %d\n", mesh_builder->nb_coords2d); - mesh_builder->pCoords2d = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d)); + mesh_builder->pCoords2d = heap_calloc(mesh_builder->nb_coords2d, sizeof(*mesh_builder->pCoords2d)); memcpy(mesh_builder->pCoords2d, ptr + sizeof(DWORD), mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d)); } else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList)) @@ -1177,15 +1179,15 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, if (size != data_size) WARN("Returned size %u does not match expected one %u\n", size, data_size); - mesh_builder->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*mesh_builder->material_indices) * nb_face_indices); - if (!mesh_builder->material_indices) + if (!(mesh_builder->material_indices = heap_calloc(nb_face_indices, + sizeof(*mesh_builder->material_indices)))) goto end; - memcpy(mesh_builder->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*mesh_builder->material_indices) * nb_face_indices), + memcpy(mesh_builder->material_indices, ptr + 2 * sizeof(DWORD), + nb_face_indices * sizeof(*mesh_builder->material_indices)); - mesh_builder->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*mesh_builder->materials) * nb_materials); - if (!mesh_builder->materials) + if (!(mesh_builder->materials = heap_calloc(nb_materials, sizeof(*mesh_builder->materials)))) { - HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices); + heap_free(mesh_builder->material_indices); goto end; } mesh_builder->nb_materials = nb_materials; @@ -1437,8 +1439,8 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, if (!mesh_builder->pCoords2d) { mesh_builder->nb_coords2d = mesh_builder->nb_vertices; - mesh_builder->pCoords2d = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d)); - for (i = 0; i < mesh_builder->nb_coords2d; i++) + mesh_builder->pCoords2d = heap_calloc(mesh_builder->nb_coords2d, sizeof(*mesh_builder->pCoords2d)); + for (i = 0; i < mesh_builder->nb_coords2d; ++i) { mesh_builder->pCoords2d[i].u = 0.0f; mesh_builder->pCoords2d[i].v = 0.0f; @@ -1451,8 +1453,8 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, end: - HeapFree(GetProcessHeap(), 0, faces_normal_idx_data); - HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data); + heap_free(faces_normal_idx_data); + heap_free(faces_vertex_idx_data); return ret; } @@ -1965,8 +1967,7 @@ static HRESULT WINAPI d3drm_mesh_builder3_CreateMesh(IDirect3DRMMeshBuilder3 *if int k; D3DRMVERTEX* vertices; - vertices = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_vertices * sizeof(D3DRMVERTEX)); - if (!vertices) + if (!(vertices = heap_calloc(mesh_builder->nb_vertices, sizeof(*vertices)))) { IDirect3DRMMesh_Release(*mesh); return E_OUTOFMEMORY; @@ -1974,7 +1975,7 @@ static HRESULT WINAPI d3drm_mesh_builder3_CreateMesh(IDirect3DRMMeshBuilder3 *if for (i = 0; i < mesh_builder->nb_vertices; i++) vertices[i].position = mesh_builder->vertices[i]; hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, mesh_builder->nb_vertices, vertices); - HeapFree(GetProcessHeap(), 0, vertices); + heap_free(vertices); /* Groups are in reverse order compared to materials list in X file */ for (k = mesh_builder->nb_materials - 1; k >= 0; k--) @@ -1987,17 +1988,15 @@ static HRESULT WINAPI d3drm_mesh_builder3_CreateMesh(IDirect3DRMMeshBuilder3 *if unsigned nb_vertices = 0; unsigned nb_faces = 0; - used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mesh_builder->face_data_size * sizeof(*used_vertices)); - if (!used_vertices) + if (!(used_vertices = heap_calloc(mesh_builder->face_data_size, sizeof(*used_vertices)))) { IDirect3DRMMesh_Release(*mesh); return E_OUTOFMEMORY; } - face_data = HeapAlloc(GetProcessHeap(), 0, mesh_builder->face_data_size * sizeof(*face_data)); - if (!face_data) + if (!(face_data = heap_calloc(mesh_builder->face_data_size, sizeof(*face_data)))) { - HeapFree(GetProcessHeap(), 0, used_vertices); + heap_free(used_vertices); IDirect3DRMMesh_Release(*mesh); return E_OUTOFMEMORY; } @@ -2051,8 +2050,8 @@ static HRESULT WINAPI d3drm_mesh_builder3_CreateMesh(IDirect3DRMMeshBuilder3 *if nb_vertices++; hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group); - HeapFree(GetProcessHeap(), 0, used_vertices); - HeapFree(GetProcessHeap(), 0, face_data); + heap_free(used_vertices); + heap_free(face_data); if (SUCCEEDED(hr)) hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, mesh_builder->materials[k].color); if (SUCCEEDED(hr)) @@ -2342,7 +2341,7 @@ HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDir TRACE("mesh_builder %p.\n", mesh_builder); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &d3drm_mesh_builder2_vtbl; @@ -2403,15 +2402,15 @@ static ULONG WINAPI d3drm_mesh_Release(IDirect3DRMMesh *iface) IDirect3DRM_Release(mesh->d3drm); for (i = 0; i < mesh->nb_groups; ++i) { - HeapFree(GetProcessHeap(), 0, mesh->groups[i].vertices); - HeapFree(GetProcessHeap(), 0, mesh->groups[i].face_data); + heap_free(mesh->groups[i].vertices); + heap_free(mesh->groups[i].face_data); if (mesh->groups[i].material) IDirect3DRMMaterial2_Release(mesh->groups[i].material); if (mesh->groups[i].texture) IDirect3DRMTexture3_Release(mesh->groups[i].texture); } - HeapFree(GetProcessHeap(), 0, mesh->groups); - HeapFree(GetProcessHeap(), 0, mesh); + heap_free(mesh->groups); + heap_free(mesh); } return refcount; @@ -2532,8 +2531,7 @@ static HRESULT WINAPI d3drm_mesh_AddGroup(IDirect3DRMMesh *iface, unsigned verte group = mesh->groups + mesh->nb_groups; - group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX)); - if (!group->vertices) + if (!(group->vertices = heap_calloc(vertex_count, sizeof(*group->vertices)))) return E_OUTOFMEMORY; group->nb_vertices = vertex_count; group->nb_faces = face_count; @@ -2558,14 +2556,12 @@ static HRESULT WINAPI d3drm_mesh_AddGroup(IDirect3DRMMesh *iface, unsigned verte } } - group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned)); - if (!group->face_data) + if (!(group->face_data = heap_calloc(group->face_data_size, sizeof(*group->face_data)))) { - HeapFree(GetProcessHeap(), 0 , group->vertices); + heap_free(group->vertices); return E_OUTOFMEMORY; } - - memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned)); + memcpy(group->face_data, face_data, group->face_data_size * sizeof(*face_data)); group->material = NULL; group->texture = NULL; @@ -2844,7 +2840,7 @@ HRESULT d3drm_mesh_create(struct d3drm_mesh **mesh, IDirect3DRM *d3drm) TRACE("mesh %p, d3drm %p.\n", mesh, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMMesh_iface.lpVtbl = &d3drm_mesh_vtbl; @@ -2898,7 +2894,7 @@ static ULONG WINAPI d3drm_wrap_Release(IDirect3DRMWrap *iface) if (!refcount) { d3drm_object_cleanup((IDirect3DRMObject *)iface, &wrap->obj); - HeapFree(GetProcessHeap(), 0, wrap); + heap_free(wrap); } return refcount; @@ -3030,7 +3026,7 @@ HRESULT d3drm_wrap_create(struct d3drm_wrap **wrap, IDirect3DRM *d3drm) TRACE("wrap %p, d3drm %p.\n", wrap, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMWrap_iface.lpVtbl = &d3drm_wrap_vtbl; diff --git a/dll/directx/wine/d3drm/precomp.h b/dll/directx/wine/d3drm/precomp.h new file mode 100644 index 0000000000..7b48c5c3a5 --- /dev/null +++ b/dll/directx/wine/d3drm/precomp.h @@ -0,0 +1,19 @@ + +#ifndef _D3DRM_PRECOMP_H_ +#define _D3DRM_PRECOMP_H_ + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#define COBJMACROS + +#include <windef.h> +#include <winbase.h> +#include <wingdi.h> + +#include "d3drm_private.h" + +#endif /* _D3DRM_PRECOMP_H_ */ diff --git a/dll/directx/wine/d3drm/texture.c b/dll/directx/wine/d3drm/texture.c index 8631320656..fd56e76ff9 100644 --- a/dll/directx/wine/d3drm/texture.c +++ b/dll/directx/wine/d3drm/texture.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_texture *impl_from_IDirect3DRMTexture(IDirect3DRMTexture *iface) { return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture_iface); @@ -44,7 +49,7 @@ static void d3drm_texture_destroy(struct d3drm_texture *texture) IDirect3DRM_Release(texture->d3drm); if (texture->surface) IDirectDrawSurface_Release(texture->surface); - HeapFree(GetProcessHeap(), 0, texture); + heap_free(texture); } static BOOL d3drm_validate_image(D3DRMIMAGE *image) @@ -1114,7 +1119,7 @@ HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) TRACE("texture %p.\n", texture); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMTexture_iface.lpVtbl = &d3drm_texture1_vtbl; diff --git a/dll/directx/wine/d3drm/viewport.c b/dll/directx/wine/d3drm/viewport.c index 247e0776a8..37c70c8db2 100644 --- a/dll/directx/wine/d3drm/viewport.c +++ b/dll/directx/wine/d3drm/viewport.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "d3drm_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3drm); + static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport(IDirect3DRMViewport *iface) { return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport_iface); @@ -70,7 +75,7 @@ static void d3drm_viewport_destroy(struct d3drm_viewport *viewport) IDirect3DRM_Release(viewport->d3drm); } - HeapFree(GetProcessHeap(), 0, viewport); + heap_free(viewport); } static HRESULT WINAPI d3drm_viewport2_QueryInterface(IDirect3DRMViewport2 *iface, REFIID riid, void **out) @@ -1017,7 +1022,7 @@ HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3d TRACE("viewport %p, d3drm %p.\n", viewport, d3drm); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; object->IDirect3DRMViewport_iface.lpVtbl = &d3drm_viewport1_vtbl; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 083be5fd7d..5e789914d8 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -25,7 +25,7 @@ reactos/dll/directx/wine/amstream # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3d8 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3d9 # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-3.3 -reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16 +reactos/dll/directx/wine/d3drm # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.3
6 years, 9 months
1
0
0
0
01/01: [D3D8][D3D9][DDRAW][WINED3D] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9987f02917539e05268ba…
commit 9987f02917539e05268ba2ad11e62d24a3636972 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:15:18 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:15:18 2018 +0100 [D3D8][D3D9][DDRAW][WINED3D] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/d3d8/CMakeLists.txt | 4 +- dll/directx/wine/d3d8/buffer.c | 55 +- dll/directx/wine/d3d8/d3d8_main.c | 89 +- dll/directx/wine/d3d8/d3d8_private.h | 63 +- dll/directx/wine/d3d8/device.c | 202 ++- dll/directx/wine/d3d8/directx.c | 22 +- dll/directx/wine/d3d8/precomp.h | 13 + dll/directx/wine/d3d8/shader.c | 12 +- dll/directx/wine/d3d8/surface.c | 11 +- dll/directx/wine/d3d8/swapchain.c | 11 +- dll/directx/wine/d3d8/texture.c | 37 +- dll/directx/wine/d3d8/vertexdeclaration.c | 18 +- dll/directx/wine/d3d8/volume.c | 14 +- dll/directx/wine/d3d9/CMakeLists.txt | 4 +- dll/directx/wine/d3d9/buffer.c | 57 +- dll/directx/wine/d3d9/d3d9_main.c | 12 +- dll/directx/wine/d3d9/d3d9_private.h | 86 +- dll/directx/wine/d3d9/device.c | 310 +++-- dll/directx/wine/d3d9/directx.c | 17 +- dll/directx/wine/d3d9/precomp.h | 13 + dll/directx/wine/d3d9/query.c | 5 +- dll/directx/wine/d3d9/shader.c | 7 +- dll/directx/wine/d3d9/stateblock.c | 5 +- dll/directx/wine/d3d9/surface.c | 15 +- dll/directx/wine/d3d9/swapchain.c | 11 +- dll/directx/wine/d3d9/texture.c | 359 ++++-- dll/directx/wine/d3d9/vertexdeclaration.c | 33 +- dll/directx/wine/d3d9/volume.c | 14 +- dll/directx/wine/ddraw/CMakeLists.txt | 4 +- dll/directx/wine/ddraw/clipper.c | 7 +- dll/directx/wine/ddraw/ddraw.c | 244 +++- dll/directx/wine/ddraw/ddraw_private.h | 38 +- dll/directx/wine/ddraw/device.c | 104 +- dll/directx/wine/ddraw/executebuffer.c | 70 +- dll/directx/wine/ddraw/light.c | 7 +- dll/directx/wine/ddraw/main.c | 36 +- dll/directx/wine/ddraw/material.c | 10 +- dll/directx/wine/ddraw/palette.c | 7 +- dll/directx/wine/ddraw/precomp.h | 15 + dll/directx/wine/ddraw/surface.c | 277 +++-- dll/directx/wine/ddraw/utils.c | 55 +- dll/directx/wine/ddraw/vertexbuffer.c | 52 +- dll/directx/wine/ddraw/viewport.c | 11 +- dll/directx/wine/wined3d/CMakeLists.txt | 5 +- dll/directx/wine/wined3d/arb_program_shader.c | 182 +-- dll/directx/wine/wined3d/ati_fragment_shader.c | 23 +- dll/directx/wine/wined3d/buffer.c | 149 +-- dll/directx/wine/wined3d/context.c | 1436 ++++++++++++++++++---- dll/directx/wine/wined3d/cs.c | 209 +++- dll/directx/wine/wined3d/device.c | 543 +++++--- dll/directx/wine/wined3d/directx.c | 417 ++++--- dll/directx/wine/wined3d/drawprim.c | 785 ------------ dll/directx/wine/wined3d/dxtn.c | 5 +- dll/directx/wine/wined3d/gl_compat.c | 8 + dll/directx/wine/wined3d/glsl_shader.c | 796 +++++------- dll/directx/wine/wined3d/nvidia_texture_shader.c | 4 + dll/directx/wine/wined3d/palette.c | 10 +- dll/directx/wine/wined3d/precomp.h | 44 + dll/directx/wine/wined3d/query.c | 134 +- dll/directx/wine/wined3d/resource.c | 227 +++- dll/directx/wine/wined3d/sampler.c | 7 +- dll/directx/wine/wined3d/shader.c | 165 +-- dll/directx/wine/wined3d/shader_sm1.c | 9 +- dll/directx/wine/wined3d/shader_sm4.c | 11 +- dll/directx/wine/wined3d/state.c | 324 +++-- dll/directx/wine/wined3d/stateblock.c | 27 +- dll/directx/wine/wined3d/surface.c | 684 +++++++---- dll/directx/wine/wined3d/swapchain.c | 64 +- dll/directx/wine/wined3d/texture.c | 1263 ++++++++++++++----- dll/directx/wine/wined3d/utils.c | 494 +++++++- dll/directx/wine/wined3d/vertexdeclaration.c | 30 +- dll/directx/wine/wined3d/view.c | 64 +- dll/directx/wine/wined3d/wined3d.spec | 26 +- dll/directx/wine/wined3d/wined3d_gl.h | 8 +- dll/directx/wine/wined3d/wined3d_main.c | 37 +- dll/directx/wine/wined3d/wined3d_private.h | 275 +++-- media/doc/README.WINE | 8 +- sdk/include/reactos/wine/wined3d.h | 163 ++- 78 files changed, 7134 insertions(+), 3938 deletions(-) diff --git a/dll/directx/wine/d3d8/CMakeLists.txt b/dll/directx/wine/d3d8/CMakeLists.txt index bad1641fea..09d7a6c659 100644 --- a/dll/directx/wine/d3d8/CMakeLists.txt +++ b/dll/directx/wine/d3d8/CMakeLists.txt @@ -17,7 +17,7 @@ list(APPEND SOURCE texture.c vertexdeclaration.c volume.c - d3d8_private.h) + precomp.h) add_library(d3d8 SHARED ${SOURCE} @@ -28,5 +28,5 @@ add_library(d3d8 SHARED set_module_type(d3d8 win32dll UNICODE) target_link_libraries(d3d8 uuid wine) add_importlibs(d3d8 d3dwine msvcrt kernel32 ntdll) -add_pch(d3d8 d3d8_private.h SOURCE) +add_pch(d3d8 precomp.h SOURCE) add_cd_file(TARGET d3d8 DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3d8/buffer.c b/dll/directx/wine/d3d8/buffer.c index d778e58360..fb6b7bc1e9 100644 --- a/dll/directx/wine/d3d8/buffer.c +++ b/dll/directx/wine/d3d8/buffer.c @@ -16,8 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8_vertexbuffer *impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface) { return CONTAINING_RECORD(iface, struct d3d8_vertexbuffer, IDirect3DVertexBuffer8_iface); @@ -190,7 +193,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface, UINT wined3d_box.right = offset + size; wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer), - 0, &wined3d_map_desc, &wined3d_box, flags); + 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); *data = wined3d_map_desc.data; @@ -224,12 +227,12 @@ static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_mutex_unlock(); + desc->Format = D3DFMT_VERTEXDATA; desc->Type = D3DRTYPE_VERTEXBUFFER; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; - desc->Format = D3DFMT_VERTEXDATA; return D3D_OK; } @@ -259,7 +262,7 @@ static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *p { struct d3d8_vertexbuffer *buffer = parent; d3d8_resource_cleanup(&buffer->resource); - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops = @@ -270,15 +273,30 @@ static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops = HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, DWORD fvf, D3DPOOL pool) { + struct wined3d_buffer_desc desc; HRESULT hr; + if (pool == D3DPOOL_SCRATCH) + { + WARN("Vertex buffer with D3DPOOL_SCRATCH requested.\n"); + return D3DERR_INVALIDCALL; + } + buffer->IDirect3DVertexBuffer8_iface.lpVtbl = &Direct3DVertexBuffer8_Vtbl; d3d8_resource_init(&buffer->resource); buffer->fvf = fvf; + desc.byte_width = size; + desc.usage = usage & WINED3DUSAGE_MASK; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + wined3d_mutex_lock(); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer, + &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { @@ -473,7 +491,7 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface, UINT o wined3d_box.right = offset + size; wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer), - 0, &wined3d_map_desc, &wined3d_box, flags); + 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); *data = wined3d_map_desc.data; @@ -509,8 +527,8 @@ static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, desc->Format = d3dformat_from_wined3dformat(buffer->format); desc->Type = D3DRTYPE_INDEXBUFFER; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; return D3D_OK; @@ -541,7 +559,7 @@ static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *pa { struct d3d8_indexbuffer *buffer = parent; d3d8_resource_cleanup(&buffer->resource); - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops = @@ -552,15 +570,26 @@ static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops = HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) { + struct wined3d_buffer_desc desc; HRESULT hr; + desc.byte_width = size; + desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl; d3d8_resource_init(&buffer->resource); buffer->format = wined3dformat_from_d3dformat(format); wined3d_mutex_lock(); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer, + &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { diff --git a/dll/directx/wine/d3d8/d3d8_main.c b/dll/directx/wine/d3d8/d3d8_main.c index 144817a545..0e686308f0 100644 --- a/dll/directx/wine/d3d8/d3d8_main.c +++ b/dll/directx/wine/d3d8/d3d8_main.c @@ -19,7 +19,12 @@ * */ +#include "config.h" +#include "initguid.h" #include "d3d8_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); HRESULT WINAPI D3D8GetSWInfo(void) { FIXME("(void): stub\n"); @@ -36,13 +41,13 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) TRACE("sdk_version %#x.\n", sdk_version); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return NULL; if (!d3d8_init(object)) { WARN("Failed to initialize d3d8.\n"); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return NULL; } @@ -53,75 +58,73 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) /*********************************************************************** * ValidateVertexShader (D3D8.@) - * - * I've seen reserved1 and reserved2 always passed as 0's - * bool seems always passed as 0 or 1, but other values work as well... - * toto result? */ -HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto) +HRESULT WINAPI ValidateVertexShader(DWORD *vertexshader, DWORD *reserved1, DWORD *reserved2, + BOOL return_error, char **errors) { - HRESULT ret; - static BOOL warned; - - if (TRACE_ON(d3d8) || !warned) { - FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); - warned = TRUE; - } + const char *message = ""; + HRESULT hr = E_FAIL; - if (!vertexshader) - return E_FAIL; + TRACE("(%p %p %p %d %p): semi-stub\n", vertexshader, reserved1, reserved2, return_error, errors); - if (reserved1 || reserved2) - return E_FAIL; + if (!vertexshader) + { + message = "(Global Validation Error) Version Token: Code pointer cannot be NULL.\n"; + goto done; + } - switch(*vertexshader) { + switch (*vertexshader) + { case 0xFFFE0101: case 0xFFFE0100: - ret=S_OK; + hr = S_OK; break; + default: WARN("Invalid shader version token %#x.\n", *vertexshader); - ret=E_FAIL; - } + message = "(Global Validation Error) Version Token: Unsupported vertex shader version.\n"; + } - return ret; +done: + if (!return_error) message = ""; + if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) + 1))) + strcpy(*errors, message); + + return hr; } /*********************************************************************** * ValidatePixelShader (D3D8.@) - * - * PARAMS - * toto result? */ -HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bool, DWORD* toto) +HRESULT WINAPI ValidatePixelShader(DWORD *pixelshader, DWORD *reserved1, BOOL return_error, char **errors) { - HRESULT ret; - static BOOL warned; - - if (TRACE_ON(d3d8) || !warned) { - FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); - warned = TRUE; - } + const char *message = ""; + HRESULT hr = E_FAIL; - if (!pixelshader) - return E_FAIL; + TRACE("(%p %p %d %p): semi-stub\n", pixelshader, reserved1, return_error, errors); - if (reserved1) - return E_FAIL; + if (!pixelshader) + return E_FAIL; - switch(*pixelshader) { + switch (*pixelshader) + { case 0xFFFF0100: case 0xFFFF0101: case 0xFFFF0102: case 0xFFFF0103: case 0xFFFF0104: - ret=S_OK; + hr = S_OK; break; default: WARN("Invalid shader version token %#x.\n", *pixelshader); - ret=E_FAIL; - } - return ret; + message = "(Global Validation Error) Version Token: Unsupported pixel shader version.\n"; + } + + if (!return_error) message = ""; + if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) + 1))) + strcpy(*errors, message); + + return hr; } void d3d8_resource_cleanup(struct d3d8_resource *resource) diff --git a/dll/directx/wine/d3d8/d3d8_private.h b/dll/directx/wine/d3d8/d3d8_private.h index a85e2995cb..cba5dd647b 100644 --- a/dll/directx/wine/d3d8/d3d8_private.h +++ b/dll/directx/wine/d3d8/d3d8_private.h @@ -23,27 +23,19 @@ #ifndef __WINE_D3D8_PRIVATE_H #define __WINE_D3D8_PRIVATE_H -#include <config.h> - #include <assert.h> #include <stdarg.h> -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - #define NONAMELESSUNION #define NONAMELESSSTRUCT #define COBJMACROS -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> - -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(d3d8); - -#include <d3d8.h> -#include <wine/wined3d.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/debug.h" +#include "wine/heap.h" +#include "d3d8.h" +#include "wine/wined3d.h" #define D3DPRESENTFLAGS_MASK 0x00000fffu @@ -281,7 +273,48 @@ HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader, struct d3d8_dev D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN; void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader) DECLSPEC_HIDDEN; size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN; +static inline DWORD d3dusage_from_wined3dusage(unsigned int usage) +{ + return usage & WINED3DUSAGE_MASK; +} + +static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage) +{ + switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) + { + default: + case WINED3D_RESOURCE_ACCESS_GPU: + return D3DPOOL_DEFAULT; + case WINED3D_RESOURCE_ACCESS_CPU: + if (usage & WINED3DUSAGE_SCRATCH) + return D3DPOOL_SCRATCH; + return D3DPOOL_SYSTEMMEM; + case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: + return D3DPOOL_MANAGED; + } +} + +static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage) +{ + switch (pool) + { + case D3DPOOL_DEFAULT: + if (usage & D3DUSAGE_DYNAMIC) + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + return WINED3D_RESOURCE_ACCESS_GPU; + case D3DPOOL_MANAGED: + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + case D3DPOOL_SYSTEMMEM: + case D3DPOOL_SCRATCH: + return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + default: + return 0; + } +} + #endif /* __WINE_D3DX8_PRIVATE_H */ diff --git a/dll/directx/wine/d3d8/device.c b/dll/directx/wine/d3d8/device.c index 6573baa355..5daf6f46c2 100644 --- a/dll/directx/wine/d3d8/device.c +++ b/dll/directx/wine/d3d8/device.c @@ -19,8 +19,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" + +#include <math.h> +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#include "wine/debug.h" + #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static void STDMETHODCALLTYPE d3d8_null_wined3d_object_destroyed(void *parent) {} static const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops = @@ -128,6 +141,29 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) } } +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) +{ + static const unsigned int handled = D3DLOCK_NOSYSLOCK + | D3DLOCK_NOOVERWRITE + | D3DLOCK_DISCARD + | D3DLOCK_NO_DIRTY_UPDATE; + unsigned int wined3d_flags; + + wined3d_flags = flags & handled; + if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD))) + wined3d_flags |= WINED3D_MAP_READ; + if (!(flags & D3DLOCK_READONLY)) + wined3d_flags |= WINED3D_MAP_WRITE; + if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE))) + wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE; + flags &= ~(handled | D3DLOCK_READONLY); + + if (flags) + FIXME("Unhandled flags %#x.\n", flags); + + return wined3d_flags; +} + static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count) { switch (primitive_type) @@ -154,6 +190,24 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U } } +static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effect effect) +{ + switch (effect) + { + case WINED3D_SWAP_EFFECT_DISCARD: + return D3DSWAPEFFECT_DISCARD; + case WINED3D_SWAP_EFFECT_SEQUENTIAL: + return D3DSWAPEFFECT_FLIP; + case WINED3D_SWAP_EFFECT_COPY: + return D3DSWAPEFFECT_COPY; + case WINED3D_SWAP_EFFECT_COPY_VSYNC: + return D3DSWAPEFFECT_COPY_VSYNC; + default: + FIXME("Unhandled swap effect %#x.\n", effect); + return D3DSWAPEFFECT_FLIP; + } +} + static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters, const struct wined3d_swapchain_desc *swapchain_desc) { @@ -162,7 +216,7 @@ static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc->backbuffer_format); present_parameters->BackBufferCount = swapchain_desc->backbuffer_count; present_parameters->MultiSampleType = swapchain_desc->multisample_type; - present_parameters->SwapEffect = swapchain_desc->swap_effect; + present_parameters->SwapEffect = d3dswapeffect_from_wined3dswapeffect(swapchain_desc->swap_effect); present_parameters->hDeviceWindow = swapchain_desc->device_window; present_parameters->Windowed = swapchain_desc->windowed; present_parameters->EnableAutoDepthStencil = swapchain_desc->enable_auto_depth_stencil; @@ -173,6 +227,24 @@ static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS present_parameters->FullScreen_PresentationInterval = swapchain_desc->swap_interval; } +static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT effect) +{ + switch (effect) + { + case D3DSWAPEFFECT_DISCARD: + return WINED3D_SWAP_EFFECT_DISCARD; + case D3DSWAPEFFECT_FLIP: + return WINED3D_SWAP_EFFECT_SEQUENTIAL; + case D3DSWAPEFFECT_COPY: + return WINED3D_SWAP_EFFECT_COPY; + case D3DSWAPEFFECT_COPY_VSYNC: + return WINED3D_SWAP_EFFECT_COPY_VSYNC; + default: + FIXME("Unhandled swap effect %#x.\n", effect); + return WINED3D_SWAP_EFFECT_SEQUENTIAL; + } +} + static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc, const D3DPRESENT_PARAMETERS *present_parameters) { @@ -194,9 +266,10 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight; swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat); swapchain_desc->backbuffer_count = max(1, present_parameters->BackBufferCount); + swapchain_desc->backbuffer_usage = WINED3DUSAGE_RENDERTARGET; swapchain_desc->multisample_type = present_parameters->MultiSampleType; swapchain_desc->multisample_quality = 0; /* d3d9 only */ - swapchain_desc->swap_effect = present_parameters->SwapEffect; + swapchain_desc->swap_effect = wined3dswapeffect_from_d3dswapeffect(present_parameters->SwapEffect); swapchain_desc->device_window = present_parameters->hDeviceWindow; swapchain_desc->windowed = present_parameters->Windowed; swapchain_desc->enable_auto_depth_stencil = present_parameters->EnableAutoDepthStencil; @@ -310,9 +383,9 @@ static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void *object, enu { /* Grow the table */ UINT new_size = t->table_size + (t->table_size >> 1); - struct d3d8_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(), - 0, t->entries, new_size * sizeof(*t->entries)); - if (!new_entries) + struct d3d8_handle_entry *new_entries; + + if (!(new_entries = heap_realloc(t->entries, new_size * sizeof(*t->entries)))) { ERR("Failed to grow the handle table.\n"); return D3D8_INVALID_HANDLE; @@ -430,7 +503,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface) { d3d8_vertex_declaration_destroy(device->decls[i].declaration); } - HeapFree(GetProcessHeap(), 0, device->decls); + heap_free(device->decls); if (device->vertex_buffer) wined3d_buffer_decref(device->vertex_buffer); @@ -440,8 +513,8 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface) wined3d_device_uninit_3d(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); - HeapFree(GetProcessHeap(), 0, device); + heap_free(device->handle_table.entries); + heap_free(device); wined3d_mutex_unlock(); @@ -672,7 +745,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource) IUnknown *parent; wined3d_resource_get_desc(resource, &desc); - if (desc.pool != WINED3D_POOL_DEFAULT) + if (desc.access & WINED3D_RESOURCE_ACCESS_CPU) return D3D_OK; if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D) @@ -849,15 +922,14 @@ static HRESULT WINAPI d3d8_device_CreateTexture(IDirect3DDevice8 *iface, return D3DERR_INVALIDCALL; *texture = NULL; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = texture_init(object, device, width, height, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -882,15 +954,14 @@ static HRESULT WINAPI d3d8_device_CreateVolumeTexture(IDirect3DDevice8 *iface, return D3DERR_INVALIDCALL; *texture = NULL; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = volumetexture_init(object, device, width, height, depth, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize volume texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -914,15 +985,14 @@ static HRESULT WINAPI d3d8_device_CreateCubeTexture(IDirect3DDevice8 *iface, UIN return D3DERR_INVALIDCALL; *texture = NULL; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize cube texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -942,15 +1012,14 @@ static HRESULT WINAPI d3d8_device_CreateVertexBuffer(IDirect3DDevice8 *iface, UI TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n", iface, size, usage, fvf, pool, buffer); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = vertexbuffer_init(object, device, size, usage, fvf, pool); if (FAILED(hr)) { WARN("Failed to initialize vertex buffer, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -970,15 +1039,14 @@ static HRESULT WINAPI d3d8_device_CreateIndexBuffer(IDirect3DDevice8 *iface, UIN TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n", iface, size, usage, format, pool, buffer); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = indexbuffer_init(object, device, size, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize index buffer, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1007,7 +1075,10 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width desc.multisample_type = multisample_type; desc.multisample_quality = multisample_quality; desc.usage = usage & WINED3DUSAGE_MASK; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; desc.depth = 1; @@ -2092,15 +2163,22 @@ static HRESULT d3d8_device_prepare_vertex_buffer(struct d3d8_device *device, UIN if (device->vertex_buffer_size < min_size || !device->vertex_buffer) { UINT size = max(device->vertex_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing vertex buffer to %u bytes\n", size); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &d3d8_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &d3d8_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x\n", device, hr); + ERR("Failed to create vertex buffer, hr %#x.\n", hr); return hr; } @@ -2153,7 +2231,7 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface, wined3d_box.right = vb_pos + size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, data, size); wined3d_resource_unmap(vb, 0); @@ -2180,15 +2258,22 @@ static HRESULT d3d8_device_prepare_index_buffer(struct d3d8_device *device, UINT if (device->index_buffer_size < min_size || !device->index_buffer) { UINT size = max(device->index_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing index buffer to %u bytes\n", size); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &d3d8_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_STATICDECL; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &d3d8_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x\n", device, hr); + ERR("Failed to create index buffer, hr %#x.\n", hr); return hr; } @@ -2247,7 +2332,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface wined3d_box.right = vb_pos + vtx_size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride, vtx_size); wined3d_resource_unmap(vb, 0); @@ -2269,7 +2354,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface wined3d_box.right = ib_pos + idx_size; ib = wined3d_buffer_get_resource(device->index_buffer); if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box, - ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, index_data, idx_size); wined3d_resource_unmap(ib, 0); @@ -2325,8 +2410,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface, TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n", iface, declaration, byte_code, shader, usage); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { *shader = 0; return E_OUTOFMEMORY; @@ -2338,7 +2422,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface, if (handle == D3D8_INVALID_HANDLE) { ERR("Failed to allocate vertex shader handle.\n"); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); *shader = 0; return E_OUTOFMEMORY; } @@ -2352,7 +2436,7 @@ static HRESULT WINAPI d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface, wined3d_mutex_lock(); d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_VS); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); *shader = 0; return hr; } @@ -2392,13 +2476,13 @@ static struct d3d8_vertex_declaration *d3d8_device_get_fvf_declaration(struct d3 } TRACE("not found. Creating and inserting at position %d.\n", low); - if (!(d3d8_declaration = HeapAlloc(GetProcessHeap(), 0, sizeof(*d3d8_declaration)))) + if (!(d3d8_declaration = heap_alloc(sizeof(*d3d8_declaration)))) return NULL; if (FAILED(hr = d3d8_vertex_declaration_init_fvf(d3d8_declaration, device, fvf))) { WARN("Failed to initialize vertex declaration, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, d3d8_declaration); + heap_free(d3d8_declaration); return NULL; } @@ -2406,9 +2490,8 @@ static struct d3d8_vertex_declaration *d3d8_device_get_fvf_declaration(struct d3 { UINT grow = device->declArraySize / 2; - convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls, - sizeof(*convertedDecls) * (device->numConvertedDecls + grow)); - if (!convertedDecls) + if (!(convertedDecls = heap_realloc(convertedDecls, + sizeof(*convertedDecls) * (device->numConvertedDecls + grow)))) { d3d8_vertex_declaration_destroy(d3d8_declaration); return NULL; @@ -2703,8 +2786,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface, if (!shader) return D3DERR_INVALIDCALL; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; wined3d_mutex_lock(); @@ -2713,7 +2795,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface, if (handle == D3D8_INVALID_HANDLE) { ERR("Failed to allocate pixel shader handle.\n"); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return E_OUTOFMEMORY; } @@ -2726,7 +2808,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface, wined3d_mutex_lock(); d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_PS); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); *shader = 0; return hr; } @@ -3089,7 +3171,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops); - if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) + if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface)))) return E_OUTOFMEMORY; surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops); @@ -3108,7 +3190,7 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent * TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops); - if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) + if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume)))) return E_OUTOFMEMORY; volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops); @@ -3204,9 +3286,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine device->IDirect3DDevice8_iface.lpVtbl = &d3d8_device_vtbl; device->device_parent.ops = &d3d8_wined3d_device_parent_ops; device->ref = 1; - device->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*device->handle_table.entries)); - if (!device->handle_table.entries) + if (!(device->handle_table.entries = heap_alloc_zero(D3D8_INITIAL_HANDLE_TABLE_SIZE + * sizeof(*device->handle_table.entries)))) { ERR("Failed to allocate handle table memory.\n"); return E_OUTOFMEMORY; @@ -3222,7 +3303,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine { WARN("Failed to create wined3d device, hr %#x.\n", hr); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); + heap_free(device->handle_table.entries); return hr; } @@ -3237,7 +3318,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine ERR("Failed to acquire focus window, hr %#x.\n", hr); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); + heap_free(device->handle_table.entries); return hr; } @@ -3256,7 +3337,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); + heap_free(device->handle_table.entries); return D3DERR_INVALIDCALL; } @@ -3266,7 +3347,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); + heap_free(device->handle_table.entries); return hr; } @@ -3278,8 +3359,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine present_parameters_from_wined3d_swapchain_desc(parameters, &swapchain_desc); device->declArraySize = 16; - device->decls = HeapAlloc(GetProcessHeap(), 0, device->declArraySize * sizeof(*device->decls)); - if (!device->decls) + if (!(device->decls = heap_alloc(device->declArraySize * sizeof(*device->decls)))) { ERR("Failed to allocate FVF vertex declaration map memory.\n"); hr = E_OUTOFMEMORY; @@ -3300,6 +3380,6 @@ err: wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, device->handle_table.entries); + heap_free(device->handle_table.entries); return hr; } diff --git a/dll/directx/wine/d3d8/directx.c b/dll/directx/wine/d3d8/directx.c index ffb8ddefb4..6e8f93a25c 100644 --- a/dll/directx/wine/d3d8/directx.c +++ b/dll/directx/wine/d3d8/directx.c @@ -20,8 +20,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "wine/debug.h" +#include "wine/unicode.h" + #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8 *impl_from_IDirect3D8(IDirect3D8 *iface) { return CONTAINING_RECORD(iface, struct d3d8, IDirect3D8_iface); @@ -68,7 +81,7 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface) wined3d_decref(d3d8->wined3d); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, d3d8); + heap_free(d3d8); } return refcount; @@ -360,15 +373,14 @@ static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter, TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n", iface, adapter, device_type, focus_window, flags, parameters, device); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = device_init(object, d3d8, d3d8->wined3d, adapter, device_type, focus_window, flags, parameters); if (FAILED(hr)) { WARN("Failed to initialize device, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -405,7 +417,7 @@ BOOL d3d8_init(struct d3d8 *d3d8) DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART - | WINED3D_LEGACY_CUBEMAP_FILTERING; + | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT; d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl; d3d8->refcount = 1; diff --git a/dll/directx/wine/d3d8/precomp.h b/dll/directx/wine/d3d8/precomp.h new file mode 100644 index 0000000000..17c27cb718 --- /dev/null +++ b/dll/directx/wine/d3d8/precomp.h @@ -0,0 +1,13 @@ + +#ifndef __WINE_D3D8_PRECOMP_H +#define __WINE_D3D8_PRECOMP_H + +#include <wine/config.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#include "d3d8_private.h" + +#endif /* __WINE_D3D8_PRECOMP_H */ diff --git a/dll/directx/wine/d3d8/shader.c b/dll/directx/wine/d3d8/shader.c index d0361a9e83..8192b238eb 100644 --- a/dll/directx/wine/d3d8/shader.c +++ b/dll/directx/wine/d3d8/shader.c @@ -17,13 +17,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent) { struct d3d8_vertex_shader *shader = parent; d3d8_vertex_declaration_destroy(shader->vertex_declaration); - HeapFree(GetProcessHeap(), 0, shader); + heap_free(shader); } void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader) @@ -56,15 +59,14 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct d3d8_device *de TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n", device, declaration, shader_handle, decl_ptr); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = d3d8_vertex_declaration_init(object, device, declaration, shader_handle); if (FAILED(hr)) { WARN("Failed to initialize vertex declaration, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -140,7 +142,7 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, struct d3d8_d static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent) { - HeapFree(GetProcessHeap(), 0, parent); + heap_free(parent); } void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader) diff --git a/dll/directx/wine/d3d8/surface.c b/dll/directx/wine/d3d8/surface.c index 545361644b..fff47f5ca1 100644 --- a/dll/directx/wine/d3d8/surface.c +++ b/dll/directx/wine/d3d8/surface.c @@ -18,8 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8_surface *impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) { return CONTAINING_RECORD(iface, struct d3d8_surface, IDirect3DSurface8_iface); @@ -188,8 +191,8 @@ static HRESULT WINAPI d3d8_surface_GetDesc(IDirect3DSurface8 *iface, D3DSURFACE_ desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; @@ -241,7 +244,7 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, } hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx, - &map_desc, rect ? &box : NULL, flags); + &map_desc, rect ? &box : NULL, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); if (SUCCEEDED(hr)) @@ -303,7 +306,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent) { struct d3d8_surface *surface = parent; d3d8_resource_cleanup(&surface->resource); - HeapFree(GetProcessHeap(), 0, surface); + heap_free(surface); } static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = diff --git a/dll/directx/wine/d3d8/swapchain.c b/dll/directx/wine/d3d8/swapchain.c index d82a8ed657..3a588b5e8c 100644 --- a/dll/directx/wine/d3d8/swapchain.c +++ b/dll/directx/wine/d3d8/swapchain.c @@ -18,8 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8_swapchain *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface) { return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface); @@ -102,7 +105,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present(IDirect3DSwapChai wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, 0); + src_rect, dst_rect, dst_window_override, 0, 0); wined3d_mutex_unlock(); return hr; @@ -155,7 +158,7 @@ static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl = static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent) { - HeapFree(GetProcessHeap(), 0, parent); + heap_free(parent); } static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops = @@ -194,13 +197,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapcha struct d3d8_swapchain *object; HRESULT hr; - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; if (FAILED(hr = swapchain_init(object, device, desc))) { WARN("Failed to initialize swapchain, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } diff --git a/dll/directx/wine/d3d8/texture.c b/dll/directx/wine/d3d8/texture.c index b860859987..87a2575cb1 100644 --- a/dll/directx/wine/d3d8/texture.c +++ b/dll/directx/wine/d3d8/texture.c @@ -16,21 +16,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8_texture *impl_from_IDirect3DTexture8(IDirect3DTexture8 *iface) { - return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); } static inline struct d3d8_texture *impl_from_IDirect3DCubeTexture8(IDirect3DCubeTexture8 *iface) { - return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); } static inline struct d3d8_texture *impl_from_IDirect3DVolumeTexture8(IDirect3DVolumeTexture8 *iface) { - return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture, IDirect3DBaseTexture8_iface); } static HRESULT WINAPI d3d8_texture_2d_QueryInterface(IDirect3DTexture8 *iface, REFIID riid, void **out) @@ -250,8 +253,8 @@ static HRESULT WINAPI d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8 *iface, UIN { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; @@ -597,8 +600,8 @@ static HRESULT WINAPI d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; @@ -942,8 +945,8 @@ static HRESULT WINAPI d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; @@ -1080,7 +1083,7 @@ static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent { struct d3d8_texture *texture = parent; d3d8_resource_cleanup(&texture->resource); - HeapFree(GetProcessHeap(), 0, texture); + heap_free(texture); } static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops = @@ -1105,7 +1108,10 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; desc.depth = 1; @@ -1150,7 +1156,10 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; desc.height = edge_length; desc.depth = 1; @@ -1194,7 +1203,9 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; desc.depth = depth; diff --git a/dll/directx/wine/d3d8/vertexdeclaration.c b/dll/directx/wine/d3d8/vertexdeclaration.c index e01230e5ae..0cae3cd8c6 100644 --- a/dll/directx/wine/d3d8/vertexdeclaration.c +++ b/dll/directx/wine/d3d8/vertexdeclaration.c @@ -21,8 +21,11 @@ /* IDirect3DVertexDeclaration8 is internal to our implementation. * It's not visible in the API. */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static const char *debug_d3dvsdt_type(D3DVSDT_TYPE d3dvsdt_type) { switch (d3dvsdt_type) @@ -263,7 +266,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3 TRACE("d3d8_elements %p, d3d8_elements_size %p, wined3d_elements %p\n", d3d8_elements, d3d8_elements_size, wined3d_elements); /* 128 should be enough for anyone... */ - *wined3d_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * sizeof(**wined3d_elements)); + *wined3d_elements = heap_alloc_zero(128 * sizeof(**wined3d_elements)); while (D3DVSD_END() != *token) { token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); @@ -311,8 +314,8 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3 static void STDMETHODCALLTYPE d3d8_vertexdeclaration_wined3d_object_destroyed(void *parent) { struct d3d8_vertex_declaration *declaration = parent; - HeapFree(GetProcessHeap(), 0, declaration->elements); - HeapFree(GetProcessHeap(), 0, declaration); + heap_free(declaration->elements); + heap_free(declaration); } void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) @@ -339,11 +342,10 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration declaration->shader_handle = shader_handle; wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size, &wined3d_elements); - declaration->elements = HeapAlloc(GetProcessHeap(), 0, declaration->elements_size); - if (!declaration->elements) + if (!(declaration->elements = heap_alloc(declaration->elements_size))) { ERR("Failed to allocate vertex declaration elements memory.\n"); - HeapFree(GetProcessHeap(), 0, wined3d_elements); + heap_free(wined3d_elements); return E_OUTOFMEMORY; } @@ -353,11 +355,11 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count, declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, wined3d_elements); + heap_free(wined3d_elements); if (FAILED(hr)) { WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, declaration->elements); + heap_free(declaration->elements); return hr; } diff --git a/dll/directx/wine/d3d8/volume.c b/dll/directx/wine/d3d8/volume.c index 0e1e904e2f..89aa84fdb5 100644 --- a/dll/directx/wine/d3d8/volume.c +++ b/dll/directx/wine/d3d8/volume.c @@ -18,8 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d8_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d8); + static inline struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface) { return CONTAINING_RECORD(iface, struct d3d8_volume, IDirect3DVolume8_iface); @@ -122,8 +125,8 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DES desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; @@ -144,7 +147,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, wined3d_mutex_lock(); if (FAILED(hr = wined3d_resource_map(wined3d_texture_get_resource(volume->wined3d_texture), - volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box, flags))) + volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box, + wined3dmapflags_from_d3dmapflags(flags)))) map_desc.data = NULL; wined3d_mutex_unlock(); @@ -152,6 +156,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, locked_box->SlicePitch = map_desc.slice_pitch; locked_box->pBits = map_desc.data; + if (hr == E_INVALIDARG) + return D3DERR_INVALIDCALL; return hr; } @@ -192,7 +198,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) { struct d3d8_volume *volume = parent; d3d8_resource_cleanup(&volume->resource); - HeapFree(GetProcessHeap(), 0, volume); + heap_free(volume); } static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = diff --git a/dll/directx/wine/d3d9/CMakeLists.txt b/dll/directx/wine/d3d9/CMakeLists.txt index 9dd8b4aa6a..223606b87e 100644 --- a/dll/directx/wine/d3d9/CMakeLists.txt +++ b/dll/directx/wine/d3d9/CMakeLists.txt @@ -19,7 +19,7 @@ list(APPEND SOURCE texture.c vertexdeclaration.c volume.c - d3d9_private.h) + precomp.h) add_library(d3d9 SHARED ${SOURCE} @@ -31,5 +31,5 @@ add_library(d3d9 SHARED set_module_type(d3d9 win32dll UNICODE) target_link_libraries(d3d9 wine) add_importlibs(d3d9 d3dwine user32 msvcrt kernel32 ntdll) -add_pch(d3d9 d3d9_private.h SOURCE) +add_pch(d3d9 precomp.h SOURCE) add_cd_file(TARGET d3d9 DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3d9/buffer.c b/dll/directx/wine/d3d9/buffer.c index 462ef3bb97..36a6ae3f90 100644 --- a/dll/directx/wine/d3d9/buffer.c +++ b/dll/directx/wine/d3d9/buffer.c @@ -18,8 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_vertexbuffer *impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_vertexbuffer, IDirect3DVertexBuffer9_iface); @@ -191,7 +194,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface, UINT wined3d_box.right = offset + size; wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer), - 0, &wined3d_map_desc, &wined3d_box, flags); + 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); *data = wined3d_map_desc.data; @@ -226,10 +229,10 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, wined3d_mutex_unlock(); desc->Format = D3DFMT_VERTEXDATA; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; - desc->Size = wined3d_desc.size; desc->Type = D3DRTYPE_VERTEXBUFFER; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); + desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; return D3D_OK; @@ -260,7 +263,7 @@ static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *p { struct d3d9_vertexbuffer *buffer = parent; d3d9_resource_cleanup(&buffer->resource); - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops = @@ -271,15 +274,30 @@ static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops = HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *device, UINT size, UINT usage, DWORD fvf, D3DPOOL pool) { + struct wined3d_buffer_desc desc; HRESULT hr; + if (pool == D3DPOOL_SCRATCH) + { + WARN("Vertex buffer with D3DPOOL_SCRATCH requested.\n"); + return D3DERR_INVALIDCALL; + } + buffer->IDirect3DVertexBuffer9_iface.lpVtbl = &d3d9_vertexbuffer_vtbl; buffer->fvf = fvf; d3d9_resource_init(&buffer->resource); + desc.byte_width = size; + desc.usage = usage & WINED3DUSAGE_MASK; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + wined3d_mutex_lock(); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer, + &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { @@ -473,7 +491,7 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface, wined3d_box.right = offset + size; wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer), - 0, &wined3d_map_desc, &wined3d_box, flags); + 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); *data = wined3d_map_desc.data; @@ -507,10 +525,10 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3D wined3d_mutex_unlock(); desc->Format = d3dformat_from_wined3dformat(buffer->format); - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; - desc->Size = wined3d_desc.size; desc->Type = D3DRTYPE_INDEXBUFFER; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); + desc->Size = wined3d_desc.size; return D3D_OK; } @@ -540,7 +558,7 @@ static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *pa { struct d3d9_indexbuffer *buffer = parent; d3d9_resource_cleanup(&buffer->resource); - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops = @@ -551,15 +569,26 @@ static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops = HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device, UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) { + struct wined3d_buffer_desc desc; HRESULT hr; + desc.byte_width = size; + desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + buffer->IDirect3DIndexBuffer9_iface.lpVtbl = &d3d9_indexbuffer_vtbl; buffer->format = wined3dformat_from_d3dformat(format); d3d9_resource_init(&buffer->resource); wined3d_mutex_lock(); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer, + &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { diff --git a/dll/directx/wine/d3d9/d3d9_main.c b/dll/directx/wine/d3d9/d3d9_main.c index 4bd80e1b91..c23fa54d99 100644 --- a/dll/directx/wine/d3d9/d3d9_main.c +++ b/dll/directx/wine/d3d9/d3d9_main.c @@ -21,8 +21,12 @@ * */ +#include "config.h" +#include "initguid.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static int D3DPERF_event_level = 0; void WINAPI DebugSetMute(void) { @@ -35,13 +39,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version) TRACE("sdk_version %#x.\n", sdk_version); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return NULL; if (!d3d9_init(object, FALSE)) { WARN("Failed to initialize d3d9.\n"); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return NULL; } @@ -56,13 +60,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9E TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; if (!d3d9_init(object, TRUE)) { WARN("Failed to initialize d3d9.\n"); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return D3DERR_NOTAVAILABLE; } diff --git a/dll/directx/wine/d3d9/d3d9_private.h b/dll/directx/wine/d3d9/d3d9_private.h index d34dd73137..ba19e5fb08 100644 --- a/dll/directx/wine/d3d9/d3d9_private.h +++ b/dll/directx/wine/d3d9/d3d9_private.h @@ -23,36 +23,39 @@ #ifndef __WINE_D3D9_PRIVATE_H #define __WINE_D3D9_PRIVATE_H -#include <config.h> - #include <assert.h> #include <stdarg.h> -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - #define NONAMELESSUNION #define NONAMELESSSTRUCT #define COBJMACROS -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "wine/debug.h" +#include "wine/heap.h" +#include "wine/unicode.h" -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(d3d9); +#include "d3d9.h" +#include "wine/wined3d.h" -#include <d3d9.h> -#include <wine/wined3d.h> +#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256 +#define D3D9_MAX_TEXTURE_UNITS 20 #define D3DPRESENTFLAGS_MASK 0x00000fffu +#define D3D9_TEXTURE_MIPMAP_DIRTY 0x1 + +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + extern const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops DECLSPEC_HIDDEN; HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN; void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters, const struct wined3d_swapchain_desc *swapchain_desc) DECLSPEC_HIDDEN; void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const WINED3DCAPS *wined3d_caps) DECLSPEC_HIDDEN; @@ -98,6 +101,9 @@ struct d3d9_device UINT index_buffer_size; UINT index_buffer_pos; + struct d3d9_texture *textures[D3D9_MAX_TEXTURE_UNITS]; + struct d3d9_surface *render_targets[D3D_MAX_SIMULTANEOUS_RENDERTARGETS]; + LONG device_state; BOOL in_destruction; BOOL in_scene; @@ -204,6 +210,10 @@ struct d3d9_texture struct wined3d_texture *wined3d_texture; IDirect3DDevice9Ex *parent_device; struct list rtv_list; + DWORD usage; + BOOL flags; + struct wined3d_shader_resource_view *wined3d_srv; + D3DTEXTUREFILTERTYPE autogen_filter_type; }; HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *device, @@ -213,6 +223,8 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *device, UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface) DECLSPEC_HIDDEN; +void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN; +void d3d9_texture_gen_auto_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN; struct d3d9_stateblock { @@ -253,9 +265,6 @@ HRESULT vertexshader_init(struct d3d9_vertexshader *shader, struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN; struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVertexShader9 *iface) DECLSPEC_HIDDEN; -#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256 -#define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4 - struct d3d9_pixelshader { IDirect3DPixelShader9 IDirect3DPixelShader9_iface; @@ -284,4 +293,49 @@ static inline struct d3d9_device *impl_from_IDirect3DDevice9Ex(IDirect3DDevice9E return CONTAINING_RECORD(iface, struct d3d9_device, IDirect3DDevice9Ex_iface); } +static inline DWORD d3dusage_from_wined3dusage(unsigned int usage) +{ + return usage & WINED3DUSAGE_MASK; +} + +static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage) +{ + switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) + { + default: + case WINED3D_RESOURCE_ACCESS_GPU: + return D3DPOOL_DEFAULT; + case WINED3D_RESOURCE_ACCESS_CPU: + if (usage & WINED3DUSAGE_SCRATCH) + return D3DPOOL_SCRATCH; + return D3DPOOL_SYSTEMMEM; + case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: + return D3DPOOL_MANAGED; + } +} + +static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage) +{ + switch (pool) + { + case D3DPOOL_DEFAULT: + if (usage & D3DUSAGE_DYNAMIC) + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + return WINED3D_RESOURCE_ACCESS_GPU; + case D3DPOOL_MANAGED: + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + case D3DPOOL_SYSTEMMEM: + case D3DPOOL_SCRATCH: + return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + default: + return 0; + } +} + +static inline DWORD wined3dusage_from_d3dusage(unsigned int usage) +{ + return usage & WINED3DUSAGE_MASK; +} + #endif /* __WINE_D3D9_PRIVATE_H */ diff --git a/dll/directx/wine/d3d9/device.c b/dll/directx/wine/d3d9/device.c index b3e085f34d..bc73699e52 100644 --- a/dll/directx/wine/d3d9/device.c +++ b/dll/directx/wine/d3d9/device.c @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" -#include <winuser.h> +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); static void STDMETHODCALLTYPE d3d9_null_wined3d_object_destroyed(void *parent) {} @@ -159,6 +160,30 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) } } +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) +{ + static const unsigned int handled = D3DLOCK_NOSYSLOCK + | D3DLOCK_NOOVERWRITE + | D3DLOCK_DISCARD + | D3DLOCK_DONOTWAIT + | D3DLOCK_NO_DIRTY_UPDATE; + unsigned int wined3d_flags; + + wined3d_flags = flags & handled; + if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD))) + wined3d_flags |= WINED3D_MAP_READ; + if (!(flags & D3DLOCK_READONLY)) + wined3d_flags |= WINED3D_MAP_WRITE; + if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE))) + wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE; + flags &= ~(handled | D3DLOCK_READONLY); + + if (flags) + FIXME("Unhandled flags %#x.\n", flags); + + return wined3d_flags; +} + static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count) { switch (primitive_type) @@ -185,6 +210,26 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U } } +static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effect effect) +{ + switch (effect) + { + case WINED3D_SWAP_EFFECT_DISCARD: + return D3DSWAPEFFECT_DISCARD; + case WINED3D_SWAP_EFFECT_SEQUENTIAL: + return D3DSWAPEFFECT_FLIP; + case WINED3D_SWAP_EFFECT_COPY: + return D3DSWAPEFFECT_COPY; + case WINED3D_SWAP_EFFECT_OVERLAY: + return D3DSWAPEFFECT_OVERLAY; + case WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL: + return D3DSWAPEFFECT_FLIPEX; + default: + FIXME("Unhandled swap effect %#x.\n", effect); + return D3DSWAPEFFECT_FLIP; + } +} + void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters, const struct wined3d_swapchain_desc *swapchain_desc) { @@ -194,7 +239,7 @@ void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *prese present_parameters->BackBufferCount = swapchain_desc->backbuffer_count; present_parameters->MultiSampleType = swapchain_desc->multisample_type; present_parameters->MultiSampleQuality = swapchain_desc->multisample_quality; - present_parameters->SwapEffect = swapchain_desc->swap_effect; + present_parameters->SwapEffect = d3dswapeffect_from_wined3dswapeffect(swapchain_desc->swap_effect); present_parameters->hDeviceWindow = swapchain_desc->device_window; present_parameters->Windowed = swapchain_desc->windowed; present_parameters->EnableAutoDepthStencil = swapchain_desc->enable_auto_depth_stencil; @@ -205,6 +250,26 @@ void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *prese present_parameters->PresentationInterval = swapchain_desc->swap_interval; } +static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT effect) +{ + switch (effect) + { + case D3DSWAPEFFECT_DISCARD: + return WINED3D_SWAP_EFFECT_DISCARD; + case D3DSWAPEFFECT_FLIP: + return WINED3D_SWAP_EFFECT_SEQUENTIAL; + case D3DSWAPEFFECT_COPY: + return WINED3D_SWAP_EFFECT_COPY; + case D3DSWAPEFFECT_OVERLAY: + return WINED3D_SWAP_EFFECT_OVERLAY; + case D3DSWAPEFFECT_FLIPEX: + return WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL; + default: + FIXME("Unhandled swap effect %#x.\n", effect); + return WINED3D_SWAP_EFFECT_SEQUENTIAL; + } +} + static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc, const D3DPRESENT_PARAMETERS *present_parameters, BOOL extended) { @@ -228,9 +293,10 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight; swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat); swapchain_desc->backbuffer_count = max(1, present_parameters->BackBufferCount); + swapchain_desc->backbuffer_usage = WINED3DUSAGE_RENDERTARGET; swapchain_desc->multisample_type = present_parameters->MultiSampleType; swapchain_desc->multisample_quality = present_parameters->MultiSampleQuality; - swapchain_desc->swap_effect = present_parameters->SwapEffect; + swapchain_desc->swap_effect = wined3dswapeffect_from_d3dswapeffect(present_parameters->SwapEffect); swapchain_desc->device_window = present_parameters->hDeviceWindow; swapchain_desc->windowed = present_parameters->Windowed; swapchain_desc->enable_auto_depth_stencil = present_parameters->EnableAutoDepthStencil; @@ -387,7 +453,7 @@ void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const WINED3DCAPS *wined3d_caps) D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV; caps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst); - caps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, caps->NumSimultaneousRTs); + caps->NumSimultaneousRTs = min(D3D_MAX_SIMULTANEOUS_RENDERTARGETS, caps->NumSimultaneousRTs); if (caps->PixelShaderVersion > 3) { @@ -478,14 +544,14 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if { wined3d_vertex_declaration_decref(device->fvf_decls[i].decl); } - HeapFree(GetProcessHeap(), 0, device->fvf_decls); + heap_free(device->fvf_decls); if (device->vertex_buffer) wined3d_buffer_decref(device->vertex_buffer); if (device->index_buffer) wined3d_buffer_decref(device->index_buffer); - HeapFree(GetProcessHeap(), 0, device->implicit_swapchains); + heap_free(device->implicit_swapchains); wined3d_device_uninit_3d(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device); @@ -494,7 +560,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface); - HeapFree(GetProcessHeap(), 0, device); + heap_free(device); } return refcount; @@ -764,7 +830,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource) IUnknown *parent; wined3d_resource_get_desc(resource, &desc); - if (desc.pool != WINED3D_POOL_DEFAULT) + if (desc.access & WINED3D_RESOURCE_ACCESS_CPU) return D3D_OK; if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D) @@ -794,8 +860,7 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device) UINT i, new_swapchain_count = wined3d_device_get_swapchain_count(device->wined3d_device); struct wined3d_swapchain *wined3d_swapchain; - if (!(device->implicit_swapchains = HeapAlloc(GetProcessHeap(), 0, - new_swapchain_count * sizeof(*device->implicit_swapchains)))) + if (!(device->implicit_swapchains = heap_alloc(new_swapchain_count * sizeof(*device->implicit_swapchains)))) return E_OUTOFMEMORY; for (i = 0; i < new_swapchain_count; ++i) @@ -814,9 +879,10 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, BOOL extended = device->d3d_parent->extended; struct wined3d_swapchain_desc swapchain_desc; struct wined3d_display_mode wined3d_mode; + struct wined3d_rendertarget_view *rtv; + unsigned int i; HRESULT hr; - if (!extended && device->device_state == D3D9_DEVICE_STATE_LOST) { WARN("App not active, returning D3DERR_DEVICELOST.\n"); @@ -854,7 +920,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, mode ? &wined3d_mode : NULL, reset_enum_callback, !extended))) { - HeapFree(GetProcessHeap(), 0, device->implicit_swapchains); + heap_free(device->implicit_swapchains); if (!extended) { @@ -876,6 +942,15 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, device->device_state = D3D9_DEVICE_STATE_OK; } + + if (!device->d3d_parent->extended) + for (i = 0; i < ARRAY_SIZE(device->textures); ++i) + device->textures[i] = NULL; + + rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0); + device->render_targets[0] = wined3d_rendertarget_view_get_sub_resource_parent(rtv); + for (i = 1; i < ARRAY_SIZE(device->render_targets); ++i) + device->render_targets[i] = NULL; } else if (!extended) { @@ -917,7 +992,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex * for (i = 0; i < device->implicit_swapchain_count; ++i) { if (FAILED(hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, 0))) + src_rect, dst_rect, dst_window_override, 0, 0))) { wined3d_mutex_unlock(); return hr; @@ -1050,15 +1125,14 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface, } } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = texture_init(object, device, width, height, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1103,15 +1177,14 @@ static HRESULT WINAPI d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface, FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = volumetexture_init(object, device, width, height, depth, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize volume texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1149,15 +1222,14 @@ static HRESULT WINAPI d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface, FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize cube texture, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1194,15 +1266,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface, FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = vertexbuffer_init(object, device, size, usage, fvf, pool); if (FAILED(hr)) { WARN("Failed to initialize vertex buffer, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1239,15 +1310,14 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return D3DERR_OUTOFVIDEOMEMORY; hr = indexbuffer_init(object, device, size, usage, format, pool); if (FAILED(hr)) { WARN("Failed to initialize index buffer, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1276,7 +1346,10 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width desc.multisample_type = multisample_type; desc.multisample_quality = multisample_quality; desc.usage = usage & WINED3DUSAGE_MASK; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; desc.depth = 1; @@ -1428,6 +1501,9 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface, wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0, dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture), src->sub_resource_idx, &src_box); + if (SUCCEEDED(hr) && dst->texture) + d3d9_texture_flag_auto_gen_mipmap(dst->texture); + wined3d_mutex_unlock(); if (FAILED(hr)) @@ -1451,6 +1527,8 @@ static HRESULT WINAPI d3d9_device_UpdateTexture(IDirect3DDevice9Ex *iface, wined3d_mutex_lock(); hr = wined3d_device_update_texture(device->wined3d_device, src_impl->wined3d_texture, dst_impl->wined3d_texture); + if (SUCCEEDED(hr)) + d3d9_texture_flag_auto_gen_mipmap(dst_impl); wined3d_mutex_unlock(); return hr; @@ -1534,6 +1612,23 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect src_rect = &s; } + if (dst_desc.access & WINED3D_RESOURCE_ACCESS_CPU) + { + WARN("Destination resource is not in DEFAULT pool.\n"); + goto done; + } + if (src_desc.access & WINED3D_RESOURCE_ACCESS_CPU) + { + WARN("Source resource is not in DEFAULT pool.\n"); + goto done; + } + + if (dst->texture && !(dst_desc.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) + { + WARN("Destination is a regular texture.\n"); + goto done; + } + if (src_desc.usage & WINED3DUSAGE_DEPTHSTENCIL) { if (device->in_scene) @@ -1569,6 +1664,8 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect src->wined3d_texture, src->sub_resource_idx, src_rect, 0, NULL, filter); if (hr == WINEDDERR_INVALIDRECT) hr = D3DERR_INVALIDCALL; + if (SUCCEEDED(hr) && dst->texture) + d3d9_texture_flag_auto_gen_mipmap(dst->texture); done: wined3d_mutex_unlock(); @@ -1602,10 +1699,10 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; } - if (desc.pool != WINED3D_POOL_DEFAULT) + if (desc.access & WINED3D_RESOURCE_ACCESS_CPU) { wined3d_mutex_unlock(); - WARN("Colorfill is not allowed on surfaces in pool %#x, returning D3DERR_INVALIDCALL.\n", desc.pool); + WARN("Colour fills are not allowed on surfaces with resource access %#x.\n", desc.access); return D3DERR_INVALIDCALL; } if ((desc.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_TEXTURE)) == WINED3DUSAGE_TEXTURE) @@ -1625,6 +1722,8 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface, hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, rtv, rect, WINED3DCLEAR_TARGET, &c, 0.0f, 0); d3d9_surface_release_rendertarget_view(surface_impl, rtv); + if (SUCCEEDED(hr) && surface_impl->texture) + d3d9_texture_flag_auto_gen_mipmap(surface_impl->texture); wined3d_mutex_unlock(); @@ -1685,7 +1784,7 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface); - if (idx >= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS) + if (idx >= D3D_MAX_SIMULTANEOUS_RENDERTARGETS) { WARN("Invalid index %u specified.\n", idx); return D3DERR_INVALIDCALL; @@ -1707,6 +1806,8 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO rtv = surface_impl ? d3d9_surface_acquire_rendertarget_view(surface_impl) : NULL; hr = wined3d_device_set_rendertarget_view(device->wined3d_device, idx, rtv, TRUE); d3d9_surface_release_rendertarget_view(surface_impl, rtv); + if (SUCCEEDED(hr)) + device->render_targets[idx] = surface_impl; wined3d_mutex_unlock(); return hr; @@ -1724,7 +1825,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO if (!surface) return D3DERR_INVALIDCALL; - if (idx >= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS) + if (idx >= D3D_MAX_SIMULTANEOUS_RENDERTARGETS) { WARN("Invalid index %u specified.\n", idx); return D3DERR_INVALIDCALL; @@ -1827,6 +1928,19 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_EndScene(IDirect3DDevice9Ex return hr; } +static void d3d9_rts_flag_auto_gen_mipmap(struct d3d9_device *device) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(device->render_targets); ++i) + { + struct d3d9_surface *surface = device->render_targets[i]; + + if (surface && surface->texture) + d3d9_texture_flag_auto_gen_mipmap(surface->texture); + } +} + static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_count, const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil) { @@ -1851,6 +1965,8 @@ static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_co wined3d_mutex_lock(); hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil); + if (SUCCEEDED(hr)) + d3d9_rts_flag_auto_gen_mipmap(device); wined3d_mutex_unlock(); return hr; @@ -2104,15 +2220,14 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = stateblock_init(object, device, type, NULL); if (FAILED(hr)) { WARN("Failed to initialize stateblock, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -2154,8 +2269,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire return hr; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { wined3d_mutex_lock(); wined3d_stateblock_decref(wined3d_stateblock); @@ -2170,7 +2284,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire wined3d_mutex_lock(); wined3d_stateblock_decref(wined3d_stateblock); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -2248,6 +2362,13 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st wined3d_mutex_lock(); hr = wined3d_device_set_texture(device->wined3d_device, stage, texture_impl ? texture_impl->wined3d_texture : NULL); + if (SUCCEEDED(hr)) + { + unsigned int i = stage >= D3DVERTEXTEXTURESAMPLER0 ? stage - D3DVERTEXTEXTURESAMPLER0 + 16 : stage; + + if (stage < ARRAY_SIZE(device->textures)) + device->textures[i] = texture_impl; + } wined3d_mutex_unlock(); return hr; @@ -2297,7 +2418,7 @@ static HRESULT WINAPI d3d9_device_GetTextureStageState(IDirect3DDevice9Ex *iface TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, state, value); - if (state >= sizeof(tss_lookup) / sizeof(*tss_lookup)) + if (state >= ARRAY_SIZE(tss_lookup)) { WARN("Invalid state %#x passed.\n", state); return D3D_OK; @@ -2317,7 +2438,7 @@ static HRESULT WINAPI d3d9_device_SetTextureStageState(IDirect3DDevice9Ex *iface TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, stage, state, value); - if (state >= sizeof(tss_lookup) / sizeof(*tss_lookup)) + if (state >= ARRAY_SIZE(tss_lookup)) { WARN("Invalid state %#x passed.\n", state); return D3D_OK; @@ -2488,6 +2609,16 @@ static float WINAPI d3d9_device_GetNPatchMode(IDirect3DDevice9Ex *iface) return ret; } +/* wined3d critical section must be taken by the caller. */ +static void d3d9_generate_auto_mipmaps(struct d3d9_device *device) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(device->textures); ++i) + if (device->textures[i]) + d3d9_texture_gen_auto_mipmap(device->textures[i]); +} + static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface, D3DPRIMITIVETYPE primitive_type, UINT start_vertex, UINT primitive_count) { @@ -2504,9 +2635,12 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface, WARN("Called without a valid vertex declaration set.\n"); return D3DERR_INVALIDCALL; } + d3d9_generate_auto_mipmaps(device); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex, vertex_count_from_primitive_count(primitive_type, primitive_count)); + if (SUCCEEDED(hr)) + d3d9_rts_flag_auto_gen_mipmap(device); wined3d_mutex_unlock(); return hr; @@ -2531,10 +2665,13 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface WARN("Called without a valid vertex declaration set.\n"); return D3DERR_INVALIDCALL; } + d3d9_generate_auto_mipmaps(device); wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_idx); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, start_idx, vertex_count_from_primitive_count(primitive_type, primitive_count)); + if (SUCCEEDED(hr)) + d3d9_rts_flag_auto_gen_mipmap(device); wined3d_mutex_unlock(); return hr; @@ -2548,15 +2685,22 @@ static HRESULT d3d9_device_prepare_vertex_buffer(struct d3d9_device *device, UIN if (device->vertex_buffer_size < min_size || !device->vertex_buffer) { UINT size = max(device->vertex_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing vertex buffer to %u bytes.\n", size); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &d3d9_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &d3d9_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x.\n", device, hr); + ERR("Failed to create vertex buffer, hr %#x.\n", hr); return hr; } @@ -2616,7 +2760,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface, wined3d_box.right = vb_pos + size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, data, size); wined3d_resource_unmap(vb, 0); @@ -2626,9 +2770,12 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface, if (FAILED(hr)) goto done; + d3d9_generate_auto_mipmaps(device); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / stride, vtx_count); wined3d_device_set_stream_source(device->wined3d_device, 0, NULL, 0, 0); + if (SUCCEEDED(hr)) + d3d9_rts_flag_auto_gen_mipmap(device); done: wined3d_mutex_unlock(); @@ -2643,15 +2790,22 @@ static HRESULT d3d9_device_prepare_index_buffer(struct d3d9_device *device, UINT if (device->index_buffer_size < min_size || !device->index_buffer) { UINT size = max(device->index_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing index buffer to %u bytes.\n", size); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &d3d9_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_STATICDECL; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &d3d9_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x.\n", device, hr); + ERR("Failed to create index buffer, hr %#x.\n", hr); return hr; } @@ -2717,7 +2871,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa wined3d_box.right = vb_pos + vtx_size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride, vtx_size); wined3d_resource_unmap(vb, 0); @@ -2739,7 +2893,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa wined3d_box.right = ib_pos + idx_size; ib = wined3d_buffer_get_resource(device->index_buffer); if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box, - ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, index_data, idx_size); wined3d_resource_unmap(ib, 0); @@ -2749,6 +2903,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa if (FAILED(hr)) goto done; + d3d9_generate_auto_mipmaps(device); wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer, wined3dformat_from_d3dformat(index_format), 0); wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos / vertex_stride - min_vertex_idx); @@ -2760,6 +2915,9 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN, 0); wined3d_device_set_base_vertex_index(device->wined3d_device, 0); + if (SUCCEEDED(hr)) + d3d9_rts_flag_auto_gen_mipmap(device); + done: wined3d_mutex_unlock(); return hr; @@ -2887,7 +3045,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 return NULL; hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration); - HeapFree(GetProcessHeap(), 0, elements); + heap_free(elements); if (FAILED(hr)) return NULL; @@ -2895,8 +3053,7 @@ static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9 { UINT grow = max(device->fvf_decl_size / 2, 8); - fvf_decls = HeapReAlloc(GetProcessHeap(), 0, fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow)); - if (!fvf_decls) + if (!(fvf_decls = heap_realloc(fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow)))) { IDirect3DVertexDeclaration9_Release(&d3d9_declaration->IDirect3DVertexDeclaration9_iface); return NULL; @@ -2982,15 +3139,14 @@ static HRESULT WINAPI d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface, TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = vertexshader_init(object, device, byte_code); if (FAILED(hr)) { WARN("Failed to initialize vertex shader, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -3280,8 +3436,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { FIXME("Failed to allocate pixel shader memory.\n"); return E_OUTOFMEMORY; @@ -3291,7 +3446,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, if (FAILED(hr)) { WARN("Failed to initialize pixel shader, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -3468,15 +3623,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUER TRACE("iface %p, type %#x, query %p.\n", iface, type, query); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = query_init(object, device, type); if (FAILED(hr)) { WARN("Failed to initialize query, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -3530,7 +3684,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_PresentEx(IDirect3DDevice9Ex for (i = 0; i < device->implicit_swapchain_count; ++i) { if (FAILED(hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, flags))) + src_rect, dst_rect, dst_window_override, 0, flags))) { wined3d_mutex_unlock(); return hr; @@ -3905,7 +4059,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops); - if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) + if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface)))) return E_OUTOFMEMORY; surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops); @@ -3924,7 +4078,7 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent * TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops); - if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) + if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume)))) return E_OUTOFMEMORY; volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops); @@ -4075,8 +4229,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine } } - swapchain_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain_desc) * count); - if (!swapchain_desc) + if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count))) { ERR("Failed to allocate wined3d parameters.\n"); wined3d_device_release_focus_window(device->wined3d_device); @@ -4092,7 +4245,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine { wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); - HeapFree(GetProcessHeap(), 0, swapchain_desc); + heap_free(swapchain_desc); wined3d_mutex_unlock(); return D3DERR_INVALIDCALL; } @@ -4102,7 +4255,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine { WARN("Failed to initialize 3D, hr %#x.\n", hr); wined3d_device_release_focus_window(device->wined3d_device); - HeapFree(GetProcessHeap(), 0, swapchain_desc); + heap_free(swapchain_desc); wined3d_device_decref(device->wined3d_device); wined3d_mutex_unlock(); return hr; @@ -4127,16 +4280,15 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, swapchain_desc); + heap_free(swapchain_desc); /* Initialize the converted declaration array. This creates a valid pointer * and when adding decls HeapReAlloc() can be used without further checking. */ - device->fvf_decls = HeapAlloc(GetProcessHeap(), 0, 0); - if (!device->fvf_decls) + if (!(device->fvf_decls = heap_alloc(0))) { ERR("Failed to allocate FVF vertex declaration map memory.\n"); wined3d_mutex_lock(); - HeapFree(GetProcessHeap(), 0, device->implicit_swapchains); + heap_free(device->implicit_swapchains); wined3d_device_uninit_3d(device->wined3d_device); wined3d_device_release_focus_window(device->wined3d_device); wined3d_device_decref(device->wined3d_device); @@ -4144,6 +4296,14 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine return E_OUTOFMEMORY; } + /* We could also simply ignore the initial rendertarget since it's known + * not to be a texture (we currently use these only for automatic mipmap + * generation). */ + wined3d_mutex_lock(); + device->render_targets[0] = wined3d_rendertarget_view_get_sub_resource_parent( + wined3d_device_get_rendertarget_view(device->wined3d_device, 0)); + wined3d_mutex_unlock(); + IDirect3D9Ex_AddRef(&parent->IDirect3D9Ex_iface); device->d3d_parent = parent; diff --git a/dll/directx/wine/d3d9/directx.c b/dll/directx/wine/d3d9/directx.c index ab153a9030..644766c2e9 100644 --- a/dll/directx/wine/d3d9/directx.c +++ b/dll/directx/wine/d3d9/directx.c @@ -19,8 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9 *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface) { return CONTAINING_RECORD(iface, struct d3d9, IDirect3D9Ex_iface); @@ -83,7 +86,7 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface) wined3d_decref(d3d9->wined3d); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, d3d9); + heap_free(d3d9); } return refcount; @@ -397,15 +400,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, U TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n", iface, adapter, device_type, focus_window, flags, parameters, device); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL); if (FAILED(hr)) { WARN("Failed to initialize device, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -505,15 +507,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface, TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n", iface, adapter, device_type, focus_window, flags, parameters, mode, device); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode); if (FAILED(hr)) { WARN("Failed to initialize device, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -578,7 +579,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER | WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING - | WINED3D_NORMALIZED_DEPTH_BIAS; + | WINED3D_NORMALIZED_DEPTH_BIAS | WINED3D_LIMIT_VIEWPORT; if (!extended) flags |= WINED3D_VIDMEM_ACCOUNTING; diff --git a/dll/directx/wine/d3d9/precomp.h b/dll/directx/wine/d3d9/precomp.h new file mode 100644 index 0000000000..3d1e183794 --- /dev/null +++ b/dll/directx/wine/d3d9/precomp.h @@ -0,0 +1,13 @@ + +#ifndef __WINE_D3D9_PRECOMP_H +#define __WINE_D3D9_PRECOMP_H + +#include <wine/config.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#include "d3d9_private.h" + +#endif /* __WINE_D3D9_PRECOMP_H */ diff --git a/dll/directx/wine/d3d9/query.c b/dll/directx/wine/d3d9/query.c index 8681502c49..12ff95b5a0 100644 --- a/dll/directx/wine/d3d9/query.c +++ b/dll/directx/wine/d3d9/query.c @@ -20,8 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_query *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_query, IDirect3DQuery9_iface); @@ -69,7 +72,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface) wined3d_mutex_unlock(); IDirect3DDevice9Ex_Release(query->parent_device); - HeapFree(GetProcessHeap(), 0, query); + heap_free(query); } return refcount; } diff --git a/dll/directx/wine/d3d9/shader.c b/dll/directx/wine/d3d9/shader.c index 75dfc0f394..9cb398388b 100644 --- a/dll/directx/wine/d3d9/shader.c +++ b/dll/directx/wine/d3d9/shader.c @@ -17,8 +17,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_vertexshader *impl_from_IDirect3DVertexShader9(IDirect3DVertexShader9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_vertexshader, IDirect3DVertexShader9_iface); @@ -123,7 +126,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl = static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent) { - HeapFree(GetProcessHeap(), 0, parent); + heap_free(parent); } static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops = @@ -277,7 +280,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl = static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent) { - HeapFree(GetProcessHeap(), 0, parent); + heap_free(parent); } static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops = diff --git a/dll/directx/wine/d3d9/stateblock.c b/dll/directx/wine/d3d9/stateblock.c index 9355d9d51e..62b3bacb28 100644 --- a/dll/directx/wine/d3d9/stateblock.c +++ b/dll/directx/wine/d3d9/stateblock.c @@ -20,8 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_stateblock *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_stateblock, IDirect3DStateBlock9_iface); @@ -69,7 +72,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface) wined3d_mutex_unlock(); IDirect3DDevice9Ex_Release(stateblock->parent_device); - HeapFree(GetProcessHeap(), 0, stateblock); + heap_free(stateblock); } return refcount; diff --git a/dll/directx/wine/d3d9/surface.c b/dll/directx/wine/d3d9/surface.c index 47b5267910..0605e7142a 100644 --- a/dll/directx/wine/d3d9/surface.c +++ b/dll/directx/wine/d3d9/surface.c @@ -19,8 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_surface *impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_surface, IDirect3DSurface9_iface); @@ -220,8 +223,8 @@ static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_ desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; @@ -246,7 +249,7 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx, - &map_desc, rect ? &box : NULL, flags); + &map_desc, rect ? &box : NULL, wined3dmapflags_from_d3dmapflags(flags)); wined3d_mutex_unlock(); if (SUCCEEDED(hr)) @@ -267,6 +270,8 @@ static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface) wined3d_mutex_lock(); hr = wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx); + if (SUCCEEDED(hr) && surface->texture) + d3d9_texture_flag_auto_gen_mipmap(surface->texture); wined3d_mutex_unlock(); if (hr == WINEDDERR_NOTLOCKED) @@ -304,6 +309,8 @@ static HRESULT WINAPI d3d9_surface_ReleaseDC(IDirect3DSurface9 *iface, HDC dc) wined3d_mutex_lock(); hr = wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, dc); + if (SUCCEEDED(hr) && surface->texture) + d3d9_texture_flag_auto_gen_mipmap(surface->texture); wined3d_mutex_unlock(); return hr; @@ -337,7 +344,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent) { struct d3d9_surface *surface = parent; d3d9_resource_cleanup(&surface->resource); - HeapFree(GetProcessHeap(), 0, surface); + heap_free(surface); } static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = diff --git a/dll/directx/wine/d3d9/swapchain.c b/dll/directx/wine/d3d9/swapchain.c index 7b2dc7ea4f..dbb3f45b91 100644 --- a/dll/directx/wine/d3d9/swapchain.c +++ b/dll/directx/wine/d3d9/swapchain.c @@ -20,8 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_swapchain *impl_from_IDirect3DSwapChain9Ex(IDirect3DSwapChain9Ex *iface) { return CONTAINING_RECORD(iface, struct d3d9_swapchain, IDirect3DSwapChain9Ex_iface); @@ -134,7 +137,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_swapchain_Present(IDirect3DSwapChai wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, flags); + src_rect, dst_rect, dst_window_override, 0, flags); wined3d_mutex_unlock(); return hr; @@ -332,7 +335,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl = static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent) { - HeapFree(GetProcessHeap(), 0, parent); + heap_free(parent); } static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops = @@ -371,13 +374,13 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapcha struct d3d9_swapchain *object; HRESULT hr; - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; if (FAILED(hr = swapchain_init(object, device, desc))) { WARN("Failed to initialize swapchain, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } diff --git a/dll/directx/wine/d3d9/texture.c b/dll/directx/wine/d3d9/texture.c index 16909d6888..c97fa6b021 100644 --- a/dll/directx/wine/d3d9/texture.c +++ b/dll/directx/wine/d3d9/texture.c @@ -18,21 +18,97 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_texture *impl_from_IDirect3DTexture9(IDirect3DTexture9 *iface) { - return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); } static inline struct d3d9_texture *impl_from_IDirect3DCubeTexture9(IDirect3DCubeTexture9 *iface) { - return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); } static inline struct d3d9_texture *impl_from_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 *iface) { - return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); +} + +static void STDMETHODCALLTYPE srv_wined3d_object_destroyed(void *parent) +{ + struct d3d9_texture *texture = parent; + + texture->wined3d_srv = NULL; +} + +static const struct wined3d_parent_ops d3d9_srv_wined3d_parent_ops = +{ + srv_wined3d_object_destroyed, +}; + +/* wined3d critical section must be taken by the caller. */ +static struct wined3d_shader_resource_view *d3d9_texture_acquire_shader_resource_view(struct d3d9_texture *texture) +{ + struct wined3d_sub_resource_desc sr_desc; + struct wined3d_view_desc desc; + HRESULT hr; + + if (texture->wined3d_srv) + return texture->wined3d_srv; + + wined3d_texture_get_sub_resource_desc(texture->wined3d_texture, 0, &sr_desc); + desc.format_id = sr_desc.format; + desc.flags = 0; + desc.u.texture.level_idx = 0; + desc.u.texture.level_count = wined3d_texture_get_level_count(texture->wined3d_texture); + desc.u.texture.layer_idx = 0; + desc.u.texture.layer_count = sr_desc.usage & WINED3DUSAGE_LEGACY_CUBEMAP ? 6 : 1; + if (FAILED(hr = wined3d_shader_resource_view_create(&desc, + wined3d_texture_get_resource(texture->wined3d_texture), texture, + &d3d9_srv_wined3d_parent_ops, &texture->wined3d_srv))) + { + ERR("Failed to create shader resource view, hr %#x.\n", hr); + return NULL; + } + + return texture->wined3d_srv; +} + +static void d3d9_texture_cleanup(struct d3d9_texture *texture) +{ + IDirect3DDevice9Ex *parent_device = texture->parent_device; + struct d3d9_surface *surface; + + wined3d_mutex_lock(); + if (texture->wined3d_srv) + wined3d_shader_resource_view_decref(texture->wined3d_srv); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) + wined3d_rendertarget_view_decref(surface->wined3d_rtv); + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + + /* Release the device last, as it may cause the device to be destroyed. */ + IDirect3DDevice9Ex_Release(parent_device); +} + +/* wined3d critical section must be taken by the caller. */ +void d3d9_texture_gen_auto_mipmap(struct d3d9_texture *texture) +{ + if (!(texture->flags & D3D9_TEXTURE_MIPMAP_DIRTY)) + return; + d3d9_texture_acquire_shader_resource_view(texture); + wined3d_shader_resource_view_generate_mipmaps(texture->wined3d_srv); + texture->flags &= ~D3D9_TEXTURE_MIPMAP_DIRTY; +} + +void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture) +{ + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP) + texture->flags |= D3D9_TEXTURE_MIPMAP_DIRTY; } static HRESULT WINAPI d3d9_texture_2d_QueryInterface(IDirect3DTexture9 *iface, REFIID riid, void **out) @@ -87,21 +163,7 @@ static ULONG WINAPI d3d9_texture_2d_Release(IDirect3DTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref); if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - struct d3d9_surface *surface; - - wined3d_mutex_lock(); - LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) - { - wined3d_rendertarget_view_decref(surface->wined3d_rtv); - } - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; } @@ -232,6 +294,9 @@ static DWORD WINAPI d3d9_texture_2d_GetLevelCount(IDirect3DTexture9 *iface) TRACE("iface %p.\n", iface); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP) + return 1; + wined3d_mutex_lock(); ret = wined3d_texture_get_level_count(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -242,35 +307,44 @@ static DWORD WINAPI d3d9_texture_2d_GetLevelCount(IDirect3DTexture9 *iface) static HRESULT WINAPI d3d9_texture_2d_SetAutoGenFilterType(IDirect3DTexture9 *iface, D3DTEXTUREFILTERTYPE filter_type) { struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); - HRESULT hr; TRACE("iface %p, filter_type %#x.\n", iface, filter_type); - wined3d_mutex_lock(); - hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture, - (enum wined3d_texture_filter_type)filter_type); - wined3d_mutex_unlock(); + if (filter_type == D3DTEXF_NONE) + { + WARN("Invalid filter type D3DTEXF_NONE specified.\n"); + return D3DERR_INVALIDCALL; + } + if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP)) + WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP flag.\n"); + else if (filter_type != D3DTEXF_LINEAR) + FIXME("Unsupported filter type %u.\n", filter_type); - return hr; + texture->autogen_filter_type = filter_type; + return D3D_OK; } static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_2d_GetAutoGenFilterType(IDirect3DTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); - D3DTEXTUREFILTERTYPE ret; TRACE("iface %p.\n", iface); - wined3d_mutex_lock(); - ret = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture); - wined3d_mutex_unlock(); + if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP)) + WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP flag.\n"); - return ret; + return texture->autogen_filter_type; } static void WINAPI d3d9_texture_2d_GenerateMipSubLevels(IDirect3DTexture9 *iface) { + struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); + TRACE("iface %p.\n", iface); + + wined3d_mutex_lock(); + d3d9_texture_gen_auto_mipmap(texture); + wined3d_mutex_unlock(); } static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) @@ -281,13 +355,19 @@ static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UIN TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); if (SUCCEEDED(hr = wined3d_texture_get_sub_resource_desc(texture->wined3d_texture, level, &wined3d_desc))) { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = texture->usage; + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; @@ -306,6 +386,12 @@ static HRESULT WINAPI d3d9_texture_2d_GetSurfaceLevel(IDirect3DTexture9 *iface, TRACE("iface %p, level %u, surface %p.\n", iface, level, surface); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); if (!(surface_impl = wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level))) { @@ -330,6 +416,12 @@ static HRESULT WINAPI d3d9_texture_2d_LockRect(IDirect3DTexture9 *iface, TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n", iface, level, locked_rect, rect, flags); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); if (!(surface_impl = wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level))) hr = D3DERR_INVALIDCALL; @@ -348,6 +440,12 @@ static HRESULT WINAPI d3d9_texture_2d_UnlockRect(IDirect3DTexture9 *iface, UINT TRACE("iface %p, level %u.\n", iface, level); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); if (!(surface_impl = wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level))) hr = D3DERR_INVALIDCALL; @@ -463,23 +561,7 @@ static ULONG WINAPI d3d9_texture_cube_Release(IDirect3DCubeTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref); if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - struct d3d9_surface *surface; - - TRACE("Releasing child %p.\n", texture->wined3d_texture); - - wined3d_mutex_lock(); - LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) - { - wined3d_rendertarget_view_decref(surface->wined3d_rtv); - } - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; } @@ -610,6 +692,9 @@ static DWORD WINAPI d3d9_texture_cube_GetLevelCount(IDirect3DCubeTexture9 *iface TRACE("iface %p.\n", iface); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP) + return 1; + wined3d_mutex_lock(); ret = wined3d_texture_get_level_count(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -621,35 +706,44 @@ static HRESULT WINAPI d3d9_texture_cube_SetAutoGenFilterType(IDirect3DCubeTextur D3DTEXTUREFILTERTYPE filter_type) { struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); - HRESULT hr; TRACE("iface %p, filter_type %#x.\n", iface, filter_type); - wined3d_mutex_lock(); - hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture, - (enum wined3d_texture_filter_type)filter_type); - wined3d_mutex_unlock(); + if (filter_type == D3DTEXF_NONE) + { + WARN("Invalid filter type D3DTEXF_NONE specified.\n"); + return D3DERR_INVALIDCALL; + } + if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP)) + WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP flag.\n"); + else if (filter_type != D3DTEXF_LINEAR) + FIXME("Unsupported filter type %u.\n", filter_type); - return hr; + texture->autogen_filter_type = filter_type; + return D3D_OK; } static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_cube_GetAutoGenFilterType(IDirect3DCubeTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); - D3DTEXTUREFILTERTYPE ret; TRACE("iface %p.\n", iface); - wined3d_mutex_lock(); - ret = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture); - wined3d_mutex_unlock(); + if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP)) + WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP flag.\n"); - return ret; + return texture->autogen_filter_type; } static void WINAPI d3d9_texture_cube_GenerateMipSubLevels(IDirect3DCubeTexture9 *iface) { + struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); + TRACE("iface %p.\n", iface); + + wined3d_mutex_lock(); + d3d9_texture_gen_auto_mipmap(texture); + wined3d_mutex_unlock(); } static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) @@ -661,6 +755,12 @@ static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *ifac TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); level_count = wined3d_texture_get_level_count(texture->wined3d_texture); if (level >= level_count) @@ -673,8 +773,8 @@ static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = texture->usage; + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; @@ -695,6 +795,12 @@ static HRESULT WINAPI d3d9_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture9 TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, face, level, surface); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); level_count = wined3d_texture_get_level_count(texture->wined3d_texture); if (level >= level_count) @@ -729,6 +835,12 @@ static HRESULT WINAPI d3d9_texture_cube_LockRect(IDirect3DCubeTexture9 *iface, TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n", iface, face, level, locked_rect, rect, flags); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level; if (!(surface_impl = wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, sub_resource_idx))) @@ -750,6 +862,12 @@ static HRESULT WINAPI d3d9_texture_cube_UnlockRect(IDirect3DCubeTexture9 *iface, TRACE("iface %p, face %#x, level %u.\n", iface, face, level); + if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level) + { + WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible level.\n"); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level; if (!(surface_impl = wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, sub_resource_idx))) @@ -861,16 +979,7 @@ static ULONG WINAPI d3d9_texture_3d_Release(IDirect3DVolumeTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref); if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - - wined3d_mutex_lock(); - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; } @@ -1011,31 +1120,16 @@ static DWORD WINAPI d3d9_texture_3d_GetLevelCount(IDirect3DVolumeTexture9 *iface static HRESULT WINAPI d3d9_texture_3d_SetAutoGenFilterType(IDirect3DVolumeTexture9 *iface, D3DTEXTUREFILTERTYPE filter_type) { - struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); - HRESULT hr; - TRACE("iface %p, filter_type %#x.\n", iface, filter_type); - wined3d_mutex_lock(); - hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture, - (enum wined3d_texture_filter_type)filter_type); - wined3d_mutex_unlock(); - - return hr; + return D3DERR_INVALIDCALL; } static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_3d_GetAutoGenFilterType(IDirect3DVolumeTexture9 *iface) { - struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); - D3DTEXTUREFILTERTYPE filter_type; - TRACE("iface %p.\n", iface); - wined3d_mutex_lock(); - filter_type = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture); - wined3d_mutex_unlock(); - - return filter_type; + return D3DTEXF_NONE; } static void WINAPI d3d9_texture_3d_GenerateMipSubLevels(IDirect3DVolumeTexture9 *iface) @@ -1056,8 +1150,8 @@ static HRESULT WINAPI d3d9_texture_3d_GetLevelDesc(IDirect3DVolumeTexture9 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = texture->usage; + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; @@ -1192,7 +1286,7 @@ static void STDMETHODCALLTYPE d3d9_texture_wined3d_object_destroyed(void *parent { struct d3d9_texture *texture = parent; d3d9_resource_cleanup(&texture->resource); - HeapFree(GetProcessHeap(), 0, texture); + heap_free(texture); } static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops = @@ -1210,14 +1304,18 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_2d_vtbl; d3d9_resource_init(&texture->resource); list_init(&texture->rtv_list); + texture->usage = usage; desc.resource_type = WINED3D_RTYPE_TEXTURE_2D; desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = usage & WINED3DUSAGE_MASK; + desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; desc.depth = 1; @@ -1229,13 +1327,28 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, if (is_gdi_compat_wined3dformat(desc.format)) flags |= WINED3D_TEXTURE_CREATE_GET_DC; - if (!levels) + if (usage & D3DUSAGE_AUTOGENMIPMAP) { - if (usage & D3DUSAGE_AUTOGENMIPMAP) - levels = 1; - else - levels = wined3d_log2i(max(width, height)) + 1; + if (pool == D3DPOOL_SYSTEMMEM) + { + WARN("D3DUSAGE_AUTOGENMIPMAP texture can't be in D3DPOOL_SYSTEMMEM, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + if (levels && levels != 1) + { + WARN("D3DUSAGE_AUTOGENMIPMAP texture with %u levels, returning D3DERR_INVALIDCALL.\n", levels); + return D3DERR_INVALIDCALL; + } + flags |= WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS; + texture->autogen_filter_type = D3DTEXF_LINEAR; + levels = 0; + } + else + { + texture->autogen_filter_type = D3DTEXF_NONE; } + if (!levels) + levels = wined3d_log2i(max(width, height)) + 1; wined3d_mutex_lock(); hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, flags, @@ -1263,14 +1376,18 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_cube_vtbl; d3d9_resource_init(&texture->resource); list_init(&texture->rtv_list); + texture->usage = usage; desc.resource_type = WINED3D_RTYPE_TEXTURE_2D; desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = usage & WINED3DUSAGE_MASK; + desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage) + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; desc.height = edge_length; desc.depth = 1; @@ -1282,13 +1399,28 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic if (is_gdi_compat_wined3dformat(desc.format)) flags |= WINED3D_TEXTURE_CREATE_GET_DC; - if (!levels) + if (usage & D3DUSAGE_AUTOGENMIPMAP) + { + if (pool == D3DPOOL_SYSTEMMEM) + { + WARN("D3DUSAGE_AUTOGENMIPMAP texture can't be in D3DPOOL_SYSTEMMEM, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + if (levels && levels != 1) + { + WARN("D3DUSAGE_AUTOGENMIPMAP texture with %u levels, returning D3DERR_INVALIDCALL.\n", levels); + return D3DERR_INVALIDCALL; + } + flags |= WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS; + texture->autogen_filter_type = D3DTEXF_LINEAR; + levels = 0; + } + else { - if (usage & D3DUSAGE_AUTOGENMIPMAP) - levels = 1; - else - levels = wined3d_log2i(edge_length) + 1; + texture->autogen_filter_type = D3DTEXF_NONE; } + if (!levels) + levels = wined3d_log2i(edge_length) + 1; wined3d_mutex_lock(); hr = wined3d_texture_create(device->wined3d_device, &desc, 6, levels, flags, @@ -1315,26 +1447,29 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_3d_vtbl; d3d9_resource_init(&texture->resource); list_init(&texture->rtv_list); + texture->usage = usage; desc.resource_type = WINED3D_RTYPE_TEXTURE_3D; desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = usage & WINED3DUSAGE_MASK; + desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_TEXTURE; - desc.pool = pool; + if (pool == D3DPOOL_SCRATCH) + desc.usage |= WINED3DUSAGE_SCRATCH; + desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; desc.depth = depth; desc.size = 0; - if (!levels) + if (usage & D3DUSAGE_AUTOGENMIPMAP) { - if (usage & D3DUSAGE_AUTOGENMIPMAP) - levels = 1; - else - levels = wined3d_log2i(max(max(width, height), depth)) + 1; + WARN("D3DUSAGE_AUTOGENMIPMAP volume texture is not supported, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; } + if (!levels) + levels = wined3d_log2i(max(max(width, height), depth)) + 1; wined3d_mutex_lock(); hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, 0, diff --git a/dll/directx/wine/d3d9/vertexdeclaration.c b/dll/directx/wine/d3d9/vertexdeclaration.c index e9248be5ea..5075309638 100644 --- a/dll/directx/wine/d3d9/vertexdeclaration.c +++ b/dll/directx/wine/d3d9/vertexdeclaration.c @@ -19,8 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static const struct { enum wined3d_format_id format; @@ -86,8 +89,8 @@ HRESULT vdecl_convert_fvf( has_psize + has_diffuse + has_specular + num_textures + 1; /* convert the declaration */ - elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9)); - if (!elements) return D3DERR_OUTOFVIDEOMEMORY; + if (!(elements = heap_alloc(size * sizeof(*elements)))) + return D3DERR_OUTOFVIDEOMEMORY; elements[size-1] = end_element; idx = 0; @@ -307,8 +310,8 @@ struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9(IDi static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void *parent) { struct d3d9_vertex_declaration *declaration = parent; - HeapFree(GetProcessHeap(), 0, declaration->elements); - HeapFree(GetProcessHeap(), 0, declaration); + heap_free(declaration->elements); + heap_free(declaration); } static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops = @@ -333,18 +336,18 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem /* Skip the END element */ --count; - *wined3d_elements = HeapAlloc(GetProcessHeap(), 0, count * sizeof(**wined3d_elements)); - if (!*wined3d_elements) { + if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements)))) + { FIXME("Memory allocation failed\n"); return D3DERR_OUTOFVIDEOMEMORY; } for (i = 0; i < count; ++i) { - if (d3d9_elements[i].Type >= (sizeof(d3d_dtype_lookup) / sizeof(*d3d_dtype_lookup))) + if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup)) { WARN("Invalid element type %#x.\n", d3d9_elements[i].Type); - HeapFree(GetProcessHeap(), 0, *wined3d_elements); + heap_free(*wined3d_elements); return E_FAIL; } (*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format; @@ -382,10 +385,9 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio declaration->refcount = 1; element_count = wined3d_element_count + 1; - declaration->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(*declaration->elements)); - if (!declaration->elements) + if (!(declaration->elements = heap_alloc(element_count * sizeof(*declaration->elements)))) { - HeapFree(GetProcessHeap(), 0, wined3d_elements); + heap_free(wined3d_elements); ERR("Failed to allocate vertex declaration elements memory.\n"); return D3DERR_OUTOFVIDEOMEMORY; } @@ -396,10 +398,10 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count, declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_declaration); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, wined3d_elements); + heap_free(wined3d_elements); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, declaration->elements); + heap_free(declaration->elements); WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr); return hr; } @@ -416,15 +418,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device, struct d3d9_vertex_declaration *object; HRESULT hr; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; hr = vertexdeclaration_init(object, device, elements); if (FAILED(hr)) { WARN("Failed to initialize vertex declaration, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } diff --git a/dll/directx/wine/d3d9/volume.c b/dll/directx/wine/d3d9/volume.c index 5c6a068811..f4c43bc589 100644 --- a/dll/directx/wine/d3d9/volume.c +++ b/dll/directx/wine/d3d9/volume.c @@ -19,8 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include "d3d9_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); + static inline struct d3d9_volume *impl_from_IDirect3DVolume9(IDirect3DVolume9 *iface) { return CONTAINING_RECORD(iface, struct d3d9_volume, IDirect3DVolume9_iface); @@ -123,8 +126,8 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DES desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; @@ -144,7 +147,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, wined3d_mutex_lock(); if (FAILED(hr = wined3d_resource_map(wined3d_texture_get_resource(volume->wined3d_texture), - volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box, flags))) + volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box, + wined3dmapflags_from_d3dmapflags(flags)))) map_desc.data = NULL; wined3d_mutex_unlock(); @@ -152,6 +156,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, locked_box->SlicePitch = map_desc.slice_pitch; locked_box->pBits = map_desc.data; + if (hr == E_INVALIDARG) + return D3DERR_INVALIDCALL; return hr; } @@ -192,7 +198,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) { struct d3d9_volume *volume = parent; d3d9_resource_cleanup(&volume->resource); - HeapFree(GetProcessHeap(), 0, volume); + heap_free(volume); } static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = diff --git a/dll/directx/wine/ddraw/CMakeLists.txt b/dll/directx/wine/ddraw/CMakeLists.txt index ed7801e4ce..6141d630f3 100644 --- a/dll/directx/wine/ddraw/CMakeLists.txt +++ b/dll/directx/wine/ddraw/CMakeLists.txt @@ -20,7 +20,7 @@ list(APPEND SOURCE utils.c vertexbuffer.c viewport.c - ddraw_private.h + precomp.h ${CMAKE_CURRENT_BINARY_DIR}/ddraw_stubs.c) if(MSVC) @@ -38,5 +38,5 @@ set_module_type(ddraw win32dll) target_link_libraries(ddraw wine uuid dxguid ${PSEH_LIB}) add_importlibs(ddraw advapi32 gdi32 user32 d3dwine msvcrt kernel32 ntdll) add_dependencies(ddraw wineheaders) -add_pch(ddraw ddraw_private.h SOURCE) +add_pch(ddraw precomp.h SOURCE) add_cd_file(TARGET ddraw DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/ddraw/clipper.c b/dll/directx/wine/ddraw/clipper.c index f1fadd429a..01cac40ec6 100644 --- a/dll/directx/wine/ddraw/clipper.c +++ b/dll/directx/wine/ddraw/clipper.c @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "ddraw_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); + static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) { return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface); @@ -67,7 +72,7 @@ static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface) { if (clipper->region) DeleteObject(clipper->region); - HeapFree(GetProcessHeap(), 0, clipper); + heap_free(clipper); } return refcount; diff --git a/dll/directx/wine/ddraw/ddraw.c b/dll/directx/wine/ddraw/ddraw.c index 2ab9edd015..e5205c0d00 100644 --- a/dll/directx/wine/ddraw/ddraw.c +++ b/dll/directx/wine/ddraw/ddraw.c @@ -21,9 +21,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "ddraw_private.h" -#include <wine/exception.h> +#include "wine/exception.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); static const struct ddraw *exclusive_ddraw; static HWND exclusive_window; @@ -45,6 +50,7 @@ static struct enum_device_entry char interface_name[100]; char device_name[100]; const GUID *device_guid; + DWORD remove_caps; } device_list7[] = { /* T&L HAL device */ @@ -52,6 +58,7 @@ static struct enum_device_entry "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D", "Wine D3D7 T&L HAL", &IID_IDirect3DTnLHalDevice, + 0, }, /* HAL device */ @@ -59,6 +66,7 @@ static struct enum_device_entry "WINE Direct3D7 Hardware acceleration using WineD3D", "Direct3D HAL", &IID_IDirect3DHALDevice, + 0, }, /* RGB device */ @@ -66,6 +74,7 @@ static struct enum_device_entry "WINE Direct3D7 RGB Software Emulation using WineD3D", "Wine D3D7 RGB", &IID_IDirect3DRGBDevice, + D3DDEVCAPS_HWTRANSFORMANDLIGHT, }, }; @@ -371,7 +380,7 @@ static void ddraw_destroy_swapchain(struct ddraw *ddraw) { wined3d_vertex_declaration_decref(ddraw->decls[i].decl); } - HeapFree(GetProcessHeap(), 0, ddraw->decls); + heap_free(ddraw->decls); ddraw->numConvertedDecls = 0; if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device))) @@ -437,7 +446,7 @@ static void ddraw_destroy(struct ddraw *This) This->d3ddevice->ddraw = NULL; /* Now free the object */ - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); } /***************************************************************************** @@ -595,8 +604,7 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw, } ddraw->declArraySize = 2; - ddraw->decls = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw->decls) * ddraw->declArraySize); - if (!ddraw->decls) + if (!(ddraw->decls = heap_alloc_zero(ddraw->declArraySize * sizeof(*ddraw->decls)))) { ERR("Error allocating an array for the converted vertex decls.\n"); ddraw->declArraySize = 0; @@ -625,6 +633,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win swapchain_desc.backbuffer_width = mode.width; swapchain_desc.backbuffer_height = mode.height; swapchain_desc.backbuffer_format = mode.format_id; + swapchain_desc.backbuffer_usage = WINED3DUSAGE_RENDERTARGET; swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_COPY; swapchain_desc.device_window = window; swapchain_desc.windowed = windowed; @@ -1430,6 +1439,28 @@ HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps) return DD_OK; } +HRESULT CALLBACK enum_zbuffer(DDPIXELFORMAT *format, void *ctx) +{ + DDCAPS *caps = ctx; + + switch (format->u1.dwZBufferBitDepth) + { + case 8: + caps->dwZBufferBitDepths |= DDBD_8; + break; + case 16: + caps->dwZBufferBitDepths |= DDBD_16; + break; + case 24: + caps->dwZBufferBitDepths |= DDBD_24; + break; + case 32: + caps->dwZBufferBitDepths |= DDBD_32; + break; + } + return D3DENUMRET_OK; +} + /***************************************************************************** * IDirectDraw7::GetCaps * @@ -1510,6 +1541,10 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD caps.dwCaps |= DDCAPS_ALIGNSTRIDE; caps.dwAlignStrideAlign = DDRAW_STRIDE_ALIGNMENT; + caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps; + + IDirect3D7_EnumZBufferFormats(&ddraw->IDirect3D7_iface, &IID_IDirect3DHALDevice, enum_zbuffer, &caps); + if(DriverCaps) { DD_STRUCT_COPY_BYSIZE(DriverCaps, &caps); @@ -1733,7 +1768,7 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes outsize = NumCodes && Codes ? *NumCodes : 0; - for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); ++i) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL, mode.format_id, 0, WINED3D_RTYPE_TEXTURE_2D, formats[i]))) @@ -2057,7 +2092,14 @@ static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid) *****************************************************************************/ static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface) { - FIXME("iface %p stub!\n", iface); + struct ddraw *ddraw = impl_from_IDirectDraw7(iface); + + TRACE("iface %p.\n", iface); + + ddraw->flags |= DDRAW_GDI_FLIP; + + if (ddraw->primary) + ddraw_surface_update_frontbuffer(ddraw->primary, NULL, FALSE); return DD_OK; } @@ -2384,13 +2426,13 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, if (!cb) return DDERR_INVALIDPARAMS; - enum_modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_modes) * enum_mode_array_size); - if (!enum_modes) return DDERR_OUTOFMEMORY; + if (!(enum_modes = heap_alloc(enum_mode_array_size * sizeof(*enum_modes)))) + return DDERR_OUTOFMEMORY; wined3d_mutex_lock(); pixelformat.dwSize = sizeof(pixelformat); - for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++) + for(fmt = 0; fmt < ARRAY_SIZE(checkFormatList); fmt++) { modenum = 0; while (wined3d_enum_adapter_modes(ddraw->wined3d, WINED3DADAPTER_DEFAULT, checkFormatList[fmt], @@ -2449,7 +2491,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, if(cb(&callback_sd, Context) == DDENUMRET_CANCEL) { TRACE("Application asked to terminate the enumeration\n"); - HeapFree(GetProcessHeap(), 0, enum_modes); + heap_free(enum_modes); wined3d_mutex_unlock(); return DD_OK; } @@ -2459,11 +2501,9 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, struct wined3d_display_mode *new_enum_modes; enum_mode_array_size *= 2; - new_enum_modes = HeapReAlloc(GetProcessHeap(), 0, enum_modes, - sizeof(*new_enum_modes) * enum_mode_array_size); - if (!new_enum_modes) + if (!(new_enum_modes = heap_realloc(enum_modes, enum_mode_array_size * sizeof(*new_enum_modes)))) { - HeapFree(GetProcessHeap(), 0, enum_modes); + heap_free(enum_modes); wined3d_mutex_unlock(); return DDERR_OUTOFMEMORY; } @@ -2475,7 +2515,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, } TRACE("End of enumeration\n"); - HeapFree(GetProcessHeap(), 0, enum_modes); + heap_free(enum_modes); wined3d_mutex_unlock(); return DD_OK; @@ -3108,7 +3148,7 @@ static BOOL ddraw_match_surface_desc(const DDSURFACEDESC2 *requested, const DDSU if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags) return FALSE; - for (i=0; i < sizeof(compare)/sizeof(compare[0]); i++) + for (i=0; i < ARRAY_SIZE(compare); i++) { if (requested->dwFlags & compare[i].flag && memcmp((const char *)provided + compare[i].offset, @@ -3189,46 +3229,97 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags, { struct ddraw *ddraw = impl_from_IDirectDraw7(iface); struct ddraw_surface *surf; - BOOL all, nomatch; - DDSURFACEDESC2 desc; - struct list *entry, *entry2; + DWORD match_flags = Flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH | DDENUMSURFACES_MATCH); TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n", iface, Flags, DDSD, Context, Callback); - all = Flags & DDENUMSURFACES_ALL; - nomatch = Flags & DDENUMSURFACES_NOMATCH; - if (!Callback) return DDERR_INVALIDPARAMS; - wined3d_mutex_lock(); - - /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ - LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list) + if (Flags & DDENUMSURFACES_CANBECREATED) { - surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry); + IDirectDrawSurface7 *surface; + DDSURFACEDESC2 testdesc; + HRESULT hr; + + if (match_flags != DDENUMSURFACES_MATCH) + return DDERR_INVALIDPARAMS; - if (!surf->iface_count) + if (!DDSD) + return DDERR_INVALIDPARAMS; + + memcpy(&testdesc, DDSD, sizeof(testdesc)); + if (!(testdesc.dwFlags & DDSD_WIDTH)) { - WARN("Not enumerating surface %p because it doesn't have any references.\n", surf); - continue; + testdesc.dwFlags |= DDSD_WIDTH; + testdesc.dwWidth = 512; } + if (!(testdesc.dwFlags & DDSD_HEIGHT)) + { + testdesc.dwFlags |= DDSD_HEIGHT; + testdesc.dwHeight = 512; + } + + hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface, NULL); + if (SUCCEEDED(hr)) + { + surf = unsafe_impl_from_IDirectDrawSurface7(surface); + Callback(NULL, &surf->surface_desc, Context); + IDirectDrawSurface7_Release(surface); + } + else + ERR("Failed to create surface, hr %#x.\n", hr); + } + else if (Flags & DDENUMSURFACES_DOESEXIST) + { + BOOL all, nomatch; + DDSURFACEDESC2 desc; + struct list *entry, *entry2; + + /* a combination of match flags is not allowed */ + if (match_flags != 0 && + match_flags != DDENUMSURFACES_ALL && + match_flags != DDENUMSURFACES_MATCH && + match_flags != DDENUMSURFACES_NOMATCH) + return DDERR_INVALIDPARAMS; + + all = (Flags & DDENUMSURFACES_ALL) != 0; + nomatch = (Flags & DDENUMSURFACES_NOMATCH) != 0; + + if (!all && !DDSD) + return DDERR_INVALIDPARAMS; + + wined3d_mutex_lock(); - if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc))) + /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ + LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list) { - TRACE("Enumerating surface %p.\n", surf); - desc = surf->surface_desc; - IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface); - if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK) + surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry); + + if (!surf->iface_count) { - wined3d_mutex_unlock(); - return DD_OK; + WARN("Not enumerating surface %p because it doesn't have any references.\n", surf); + continue; + } + + if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc))) + { + TRACE("Enumerating surface %p.\n", surf); + desc = surf->surface_desc; + IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface); + if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK) + { + wined3d_mutex_unlock(); + return DD_OK; + } } } - } - wined3d_mutex_unlock(); + wined3d_mutex_unlock(); + } + else + return DDERR_INVALIDPARAMS; return DD_OK; } @@ -3313,8 +3404,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper wined3d_mutex_lock(); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { wined3d_mutex_unlock(); return E_OUTOFMEMORY; @@ -3324,7 +3414,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper if (FAILED(hr)) { WARN("Failed to initialize clipper, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); wined3d_mutex_unlock(); return hr; } @@ -3424,8 +3514,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags, return DDERR_NOCOOPERATIVELEVELSET; } - object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); - if (!object) + if (!(object = heap_alloc(sizeof(*object)))) { ERR("Out of memory when allocating memory for a palette implementation\n"); wined3d_mutex_unlock(); @@ -3436,7 +3525,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags, if (FAILED(hr)) { WARN("Failed to initialize palette, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); wined3d_mutex_unlock(); return hr; } @@ -3626,6 +3715,7 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA { struct ddraw *ddraw = impl_from_IDirect3D7(iface); D3DDEVICEDESC7 device_desc7; + DWORD dev_caps; HRESULT hr; size_t i; @@ -3642,11 +3732,15 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA return hr; } - for (i = 0; i < sizeof(device_list7)/sizeof(device_list7[0]); i++) + dev_caps = device_desc7.dwDevCaps; + + for (i = 0; i < ARRAY_SIZE(device_list7); i++) { HRESULT ret; device_desc7.deviceGUID = *device_list7[i].device_guid; + device_desc7.dwDevCaps = dev_caps & ~device_list7[i].remove_caps; + ret = callback(device_list7[i].interface_name, device_list7[i].device_name, &device_desc7, context); if (ret != DDENUMRET_OK) { @@ -3832,10 +3926,10 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown); - if (outer_unknown) return CLASS_E_NOAGGREGATION; + if (outer_unknown) + return CLASS_E_NOAGGREGATION; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { ERR("Failed to allocate light memory.\n"); return DDERR_OUTOFMEMORY; @@ -3982,8 +4076,7 @@ static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3 if (outer_unknown) return CLASS_E_NOAGGREGATION; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { ERR("Failed to allocate viewport memory.\n"); return DDERR_OUTOFMEMORY; @@ -4044,8 +4137,8 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd if (!fds || !fdr) return DDERR_INVALIDPARAMS; - if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) - || fdr->dwSize != sizeof(D3DFINDDEVICERESULT)) + if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) || (fdr->dwSize != sizeof(D3DFINDDEVICERESULT1) && + fdr->dwSize != sizeof(D3DFINDDEVICERESULT2) && fdr->dwSize != sizeof(D3DFINDDEVICERESULT))) return DDERR_INVALIDPARAMS; if ((fds->dwFlags & D3DFDS_COLORMODEL) @@ -4074,8 +4167,24 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd /* Now return our own GUID */ ddraw_d3dcaps1_from_7(&desc1, &desc7); fdr->guid = IID_D3DDEVICE_WineD3D; - fdr->ddHwDesc = desc1; - fdr->ddSwDesc = desc1; + + if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT1)) + { + D3DFINDDEVICERESULT1 *fdr1 = (D3DFINDDEVICERESULT1 *)fdr; + memcpy(&fdr1->ddHwDesc, &desc1, sizeof(fdr1->ddHwDesc)); + memcpy(&fdr1->ddSwDesc, &desc1, sizeof(fdr1->ddSwDesc)); + } + else if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT2)) + { + D3DFINDDEVICERESULT2 *fdr2 = (D3DFINDDEVICERESULT2 *)fdr; + memcpy(&fdr2->ddHwDesc, &desc1, sizeof(fdr2->ddHwDesc)); + memcpy(&fdr2->ddSwDesc, &desc1, sizeof(fdr2->ddSwDesc)); + } + else + { + fdr->ddHwDesc = desc1; + fdr->ddSwDesc = desc1; + } TRACE("Returning Wine's wined3d device with (undumped) capabilities.\n"); @@ -4132,7 +4241,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid, TRACE("iface %p, riid %s, surface %p, device %p.\n", iface, debugstr_guid(riid), surface, device); wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, target, (IUnknown *)surface, 7, &object, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, target, (IUnknown *)surface, 7, &object, NULL))) { *device = &object->IDirect3DDevice7_iface; } @@ -4161,7 +4270,7 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid, return CLASS_E_NOAGGREGATION; wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 3, &device_impl, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface, 3, &device_impl, NULL))) { *device = &device_impl->IDirect3DDevice3_iface; } @@ -4187,7 +4296,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid, iface, debugstr_guid(riid), surface, device); wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 2, &device_impl, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface, 2, &device_impl, NULL))) { *device = &device_impl->IDirect3DDevice2_iface; } @@ -4357,7 +4466,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device return hr; } - for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, type, mode.format_id, WINED3DUSAGE_DEPTHSTENCIL, WINED3D_RTYPE_TEXTURE_2D, formats[i]))) @@ -4559,7 +4668,7 @@ static const struct IDirectDraw2Vtbl ddraw2_vtbl = ddraw2_GetAvailableVidMem, }; -static const struct IDirectDrawVtbl ddraw1_vtbl = +static struct IDirectDrawVtbl ddraw1_vtbl = { /* IUnknown */ ddraw1_QueryInterface, @@ -4698,11 +4807,12 @@ struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *This, DWORD fvf fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl); if (hr != S_OK) return NULL; - if(This->declArraySize == This->numConvertedDecls) { - int grow = max(This->declArraySize / 2, 8); - convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls, - sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow)); - if (!convertedDecls) + if (This->declArraySize == This->numConvertedDecls) + { + unsigned int grow = max(This->declArraySize / 2, 8); + + if (!(convertedDecls = heap_realloc(convertedDecls, + (This->numConvertedDecls + grow) * sizeof(*convertedDecls)))) { wined3d_vertex_declaration_decref(pDecl); return NULL; @@ -4818,7 +4928,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent return DD_OK; } - if (!(ddraw_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw_surface)))) + if (!(ddraw_surface = heap_alloc_zero(sizeof(*ddraw_surface)))) { ERR("Failed to allocate surface memory.\n"); return DDERR_OUTOFVIDEOMEMORY; diff --git a/dll/directx/wine/ddraw/ddraw_private.h b/dll/directx/wine/ddraw/ddraw_private.h index 04ee59c05f..1454e8012a 100644 --- a/dll/directx/wine/ddraw/ddraw_private.h +++ b/dll/directx/wine/ddraw/ddraw_private.h @@ -19,30 +19,25 @@ #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H -#include <config.h> -#include <wine/port.h> - #include <assert.h> -#include <stdarg.h> - -#define _INC_WINDOWS -#define COM_NO_WINDOW_H - +#include <limits.h> #define COBJMACROS #define NONAMELESSSTRUCT #define NONAMELESSUNION +#include "wine/debug.h" +#include "wine/heap.h" -#include <windef.h> -#include <winbase.h> -#include <wingdi.h> -#include <winuser.h> -#include <d3d.h> +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" -#include <wine/debug.h> -#include <wine/list.h> -#include <wine/wined3d.h> - -WINE_DEFAULT_DEBUG_CHANNEL(ddraw); +#include "d3d.h" +#include "ddraw.h" +#ifdef DDRAW_INIT_GUID +#include "initguid.h" +#endif +#include "wine/list.h" +#include "wine/wined3d.h" #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) @@ -64,13 +59,14 @@ struct FvfToDecl #define DDRAW_NO3D 0x00000008 #define DDRAW_SCL_DDRAW1 0x00000010 #define DDRAW_SCL_RECURSIVE 0x00000020 +#define DDRAW_GDI_FLIP 0x00000040 #define DDRAW_STRIDE_ALIGNMENT 8 #define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING \ | WINED3D_RESTORE_MODE_ON_ACTIVATE | WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER \ | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART \ - | WINED3D_LEGACY_CUBEMAP_FILTERING) + | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT) enum ddraw_device_state { @@ -309,6 +305,7 @@ struct d3d_device IUnknown IUnknown_inner; LONG ref; UINT version; + BOOL hw; IUnknown *outer_unknown; struct wined3d_device *wined3d_device; @@ -353,7 +350,7 @@ struct d3d_device struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES]; }; -HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, +HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, struct d3d_device **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN; enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device) DECLSPEC_HIDDEN; @@ -592,6 +589,7 @@ void ddrawformat_from_wined3dformat(DDPIXELFORMAT *ddraw_format, BOOL wined3d_colour_from_ddraw_colour(const DDPIXELFORMAT *pf, const struct ddraw_palette *palette, DWORD colour, struct wined3d_color *wined3d_colour) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_ddrawformat(const DDPIXELFORMAT *format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_ddrawmapflags(unsigned int flags) DECLSPEC_HIDDEN; void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN; void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN; void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN; diff --git a/dll/directx/wine/ddraw/device.c b/dll/directx/wine/ddraw/device.c index fe48ad3b36..24dbd3be50 100644 --- a/dll/directx/wine/ddraw/device.c +++ b/dll/directx/wine/ddraw/device.c @@ -27,8 +27,12 @@ * */ +#include "config.h" +#include "wine/port.h" + #include "ddraw_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); WINE_DECLARE_DEBUG_CHANNEL(winediag); /* The device ID */ @@ -318,7 +322,7 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface) This->ddraw->d3ddevice = NULL; /* Now free the structure */ - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); wined3d_mutex_unlock(); } @@ -659,8 +663,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface, return CLASS_E_NOAGGREGATION; /* Allocate the new Execute Buffer */ - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if(!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { ERR("Failed to allocate execute buffer memory.\n"); return DDERR_OUTOFMEMORY; @@ -670,7 +673,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface, if (FAILED(hr)) { WARN("Failed to initialize execute buffer, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } @@ -1083,7 +1086,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface, return hr; } - for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i) + for (i = 0; i < ARRAY_SIZE(FormatList); ++i) { if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_TEXTURE, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK) @@ -1105,7 +1108,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface, } } - for (i = 0; i < sizeof(BumpFormatList) / sizeof(*BumpFormatList); ++i) + for (i = 0; i < ARRAY_SIZE(BumpFormatList); ++i) { if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_TEXTURE | WINED3DUSAGE_QUERY_LEGACYBUMPMAP, @@ -1211,7 +1214,7 @@ static HRESULT WINAPI d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface, return hr; } - for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i) + for (i = 0; i < ARRAY_SIZE(FormatList); ++i) { if (wined3d_check_device_format(device->ddraw->wined3d, 0, WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_TEXTURE, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK) @@ -1270,7 +1273,7 @@ static HRESULT WINAPI d3d_device1_EnumTextureFormats(IDirect3DDevice *iface, static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DMatHandle) { struct d3d_device *device = impl_from_IDirect3DDevice(iface); - D3DMATRIX *Matrix; + D3DMATRIX *matrix; DWORD h; TRACE("iface %p, matrix_handle %p.\n", iface, D3DMatHandle); @@ -1278,8 +1281,7 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIX if(!D3DMatHandle) return DDERR_INVALIDPARAMS; - Matrix = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DMATRIX)); - if(!Matrix) + if (!(matrix = heap_alloc_zero(sizeof(*matrix)))) { ERR("Out of memory when allocating a D3DMATRIX\n"); return DDERR_OUTOFMEMORY; @@ -1287,11 +1289,11 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIX wined3d_mutex_lock(); - h = ddraw_allocate_handle(&device->handle_table, Matrix, DDRAW_HANDLE_MATRIX); + h = ddraw_allocate_handle(&device->handle_table, matrix, DDRAW_HANDLE_MATRIX); if (h == DDRAW_INVALID_HANDLE) { ERR("Failed to allocate a matrix handle.\n"); - HeapFree(GetProcessHeap(), 0, Matrix); + heap_free(matrix); wined3d_mutex_unlock(); return DDERR_OUTOFMEMORY; } @@ -1442,7 +1444,7 @@ static HRESULT WINAPI d3d_device1_DeleteMatrix(IDirect3DDevice *iface, D3DMATRIX wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, m); + heap_free(m); return D3D_OK; } @@ -1852,7 +1854,7 @@ static HRESULT d3d_device7_SetRenderTarget(IDirect3DDevice7 *iface, return DDERR_INVALIDCAPS; } - if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) { WARN("Surface %p is not in video memory.\n", target_impl); wined3d_mutex_unlock(); @@ -1928,7 +1930,7 @@ static HRESULT WINAPI d3d_device3_SetRenderTarget(IDirect3DDevice3 *iface, return DDERR_INVALIDPIXELFORMAT; } - if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) { WARN("Surface %p is not in video memory.\n", target_impl); IDirectDrawSurface4_AddRef(target); @@ -1977,7 +1979,7 @@ static HRESULT WINAPI d3d_device2_SetRenderTarget(IDirect3DDevice2 *iface, return DDERR_INVALIDPIXELFORMAT; } - if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) { WARN("Surface %p is not in video memory.\n", target_impl); IDirectDrawSurface_AddRef(target); @@ -2214,11 +2216,11 @@ static HRESULT WINAPI d3d_device3_Vertex(IDirect3DDevice3 *iface, void *vertex) device->buffer_size = device->buffer_size ? device->buffer_size * 2 : device->vertex_size * 3; old_buffer = device->sysmem_vertex_buffer; - device->sysmem_vertex_buffer = HeapAlloc(GetProcessHeap(), 0, device->buffer_size); + device->sysmem_vertex_buffer = heap_alloc(device->buffer_size); if (old_buffer) { memcpy(device->sysmem_vertex_buffer, old_buffer, device->nb_vertices * device->vertex_size); - HeapFree(GetProcessHeap(), 0, old_buffer); + heap_free(old_buffer); } } @@ -3461,15 +3463,22 @@ static HRESULT d3d_device_prepare_vertex_buffer(struct d3d_device *device, UINT if (device->vertex_buffer_size < min_size || !device->vertex_buffer) { UINT size = max(device->vertex_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing vertex buffer to %u bytes\n", size); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &ddraw_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x\n", device, hr); + ERR("Failed to create vertex buffer, hr %#x.\n", hr); return hr; } @@ -3524,7 +3533,7 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface, wined3d_box.right = vb_pos + size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, vertices, size); wined3d_resource_unmap(vb, 0); @@ -3646,15 +3655,22 @@ static HRESULT d3d_device_prepare_index_buffer(struct d3d_device *device, UINT m if (device->index_buffer_size < min_size || !device->index_buffer) { UINT size = max(device->index_buffer_size * 2, min_size); + struct wined3d_buffer_desc desc; struct wined3d_buffer *buffer; TRACE("Growing index buffer to %u bytes\n", size); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, - WINED3D_POOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops, &buffer); - if (FAILED(hr)) + desc.byte_width = size; + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_STATICDECL; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &ddraw_null_wined3d_parent_ops, &buffer))) { - ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x\n", device, hr); + ERR("Failed to create index buffer, hr %#x.\n", hr); return hr; } @@ -3709,7 +3725,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, wined3d_box.right = vb_pos + vtx_size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, vertices, vtx_size); wined3d_resource_unmap(vb, 0); @@ -3726,7 +3742,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, wined3d_box.right = ib_pos + idx_size; ib = wined3d_buffer_get_resource(device->index_buffer); if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box, - ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, indices, idx_size); wined3d_resource_unmap(ib, 0); @@ -4040,7 +4056,7 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM wined3d_box.right = vb_pos + dst_size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf); wined3d_resource_unmap(vb, 0); @@ -4156,7 +4172,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, wined3d_box.right = vb_pos + vtx_dst_size; vb = wined3d_buffer_get_resource(device->vertex_buffer); if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, - vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf); wined3d_resource_unmap(vb, 0); @@ -4173,7 +4189,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, wined3d_box.right = ib_pos + idx_size; ib = wined3d_buffer_get_resource(device->index_buffer); if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box, - ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) goto done; memcpy(wined3d_map_desc.data, indices, idx_size); wined3d_resource_unmap(ib, 0); @@ -4393,7 +4409,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, wined3d_box.right = ib_pos + index_count * sizeof(WORD); ib = wined3d_buffer_get_resource(device->index_buffer); if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box, - ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) + WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) { ERR("Failed to map buffer, hr %#x.\n", hr); wined3d_mutex_unlock(); @@ -6887,7 +6903,7 @@ enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device return WINED3D_ZB_TRUE; } -static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, +static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, BOOL hw, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, IUnknown *outer_unknown) { static const D3DMATRIX ident = @@ -6910,6 +6926,7 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, device->IUnknown_inner.lpVtbl = &d3d_device_inner_vtbl; device->ref = 1; device->version = version; + device->hw = hw; if (outer_unknown) device->outer_unknown = outer_unknown; @@ -6960,14 +6977,18 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, return D3D_OK; } -HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, +HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, struct d3d_device **device, IUnknown *outer_unknown) { struct d3d_device *object; + BOOL hw = TRUE; HRESULT hr; - TRACE("ddraw %p, target %p, version %u, device %p, outer_unknown %p.\n", - ddraw, target, version, device, outer_unknown); + TRACE("ddraw %p, guid %s, target %p, version %u, device %p, outer_unknown %p.\n", + ddraw, debugstr_guid(guid), target, version, device, outer_unknown); + + if (IsEqualGUID(guid, &IID_IDirect3DRGBDevice)) + hw = FALSE; if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) || (target->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)) @@ -6982,7 +7003,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUn return DDERR_NOPALETTEATTACHED; } - if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + if (hw && !(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) { WARN("Surface %p is not in video memory.\n", target); return D3DERR_SURFACENOTINVIDMEM; @@ -7002,17 +7023,16 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUn return DDERR_INVALIDPARAMS; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = heap_alloc_zero(sizeof(*object)))) { ERR("Failed to allocate device memory.\n"); return DDERR_OUTOFMEMORY; } - if (FAILED(hr = d3d_device_init(object, ddraw, target, rt_iface, version, outer_unknown))) + if (FAILED(hr = d3d_device_init(object, ddraw, hw, target, rt_iface, version, outer_unknown))) { WARN("Failed to initialize device, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return hr; } diff --git a/dll/directx/wine/ddraw/executebuffer.c b/dll/directx/wine/ddraw/executebuffer.c index 7b68bd70b5..17bea2764c 100644 --- a/dll/directx/wine/ddraw/executebuffer.c +++ b/dll/directx/wine/ddraw/executebuffer.c @@ -18,8 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "ddraw_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); + /***************************************************************************** * _dump_executedata * _dump_D3DEXECUTEBUFFERDESC @@ -119,13 +124,20 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, if (buffer->index_size < index_count) { - struct wined3d_buffer *new_buffer; unsigned int new_size = max(buffer->index_size * 2, index_count); - - hr = wined3d_buffer_create_ib(device->wined3d_device, new_size * sizeof(*indices), - WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, WINED3D_POOL_DEFAULT, - NULL, &ddraw_null_wined3d_parent_ops, &new_buffer); - if (FAILED(hr)) + struct wined3d_buffer *new_buffer; + struct wined3d_buffer_desc desc; + + desc.byte_width = new_size * sizeof(*indices); + desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_STATICDECL; + desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_GPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc, + NULL, NULL, &ddraw_null_wined3d_parent_ops, &new_buffer))) return hr; buffer->index_size = new_size; @@ -141,9 +153,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, box.left = index_pos * sizeof(*indices); box.right = (index_pos + index_count) * sizeof(*indices); - hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0, - &map_desc, &box, index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD); - if (FAILED(hr)) + if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0, &map_desc, + &box, WINED3D_MAP_WRITE | (index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))) return hr; indices = map_desc.data; @@ -297,7 +308,10 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, ci->wStart, ci->wDest, ci->dwCount, ci->dwFlags); if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS) - FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n"); + { + static int once; + if (!once++) FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n"); + } if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR) FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n"); @@ -497,7 +511,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer *iface) if (!ref) { if (buffer->need_free) - HeapFree(GetProcessHeap(), 0, buffer->desc.lpData); + heap_free(buffer->desc.lpData); if (buffer->index_buffer) wined3d_buffer_decref(buffer->index_buffer); if (buffer->dst_vertex_buffer) @@ -505,7 +519,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer *iface) wined3d_buffer_decref(buffer->src_vertex_buffer); wined3d_buffer_decref(buffer->dst_vertex_buffer); } - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } return ref; @@ -606,17 +620,25 @@ static HRESULT WINAPI d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer * { unsigned int new_size = max(data->dwVertexCount, buffer->vertex_size * 2); struct wined3d_buffer *src_buffer, *dst_buffer; + struct wined3d_buffer_desc desc; - hr = wined3d_buffer_create_vb(buffer->d3ddev->wined3d_device, new_size * sizeof(D3DVERTEX), - WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, WINED3D_POOL_SYSTEM_MEM, - NULL, &ddraw_null_wined3d_parent_ops, &src_buffer); - if (FAILED(hr)) + desc.byte_width = new_size * sizeof(D3DVERTEX); + desc.usage = 0; + desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; + desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.misc_flags = 0; + desc.structure_byte_stride = 0; + + if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device, &desc, + NULL, NULL, &ddraw_null_wined3d_parent_ops, &src_buffer))) return hr; - hr = wined3d_buffer_create_vb(buffer->d3ddev->wined3d_device, new_size * sizeof(D3DTLVERTEX), - WINED3DUSAGE_STATICDECL, WINED3D_POOL_DEFAULT, - NULL, &ddraw_null_wined3d_parent_ops, &dst_buffer); - if (FAILED(hr)) + desc.byte_width = new_size * sizeof(D3DTLVERTEX); + desc.usage = WINED3DUSAGE_STATICDECL; + desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + + if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device, &desc, + NULL, NULL, &ddraw_null_wined3d_parent_ops, &dst_buffer))) { wined3d_buffer_decref(src_buffer); return hr; @@ -641,9 +663,8 @@ static HRESULT WINAPI d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer * { box.left = buffer->src_vertex_pos * sizeof(D3DVERTEX); box.right = box.left + data->dwVertexCount * sizeof(D3DVERTEX); - hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0, - &map_desc, &box, buffer->src_vertex_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD); - if (FAILED(hr)) + if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer), + 0, &map_desc, &box, WINED3D_MAP_WRITE))) return hr; memcpy(map_desc.data, ((BYTE *)buffer->desc.lpData) + data->dwVertexOffset, @@ -773,8 +794,7 @@ HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer *execute_buffer, if (!execute_buffer->desc.lpData && execute_buffer->desc.dwBufferSize) { execute_buffer->need_free = TRUE; - execute_buffer->desc.lpData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, execute_buffer->desc.dwBufferSize); - if (!execute_buffer->desc.lpData) + if (!(execute_buffer->desc.lpData = heap_alloc_zero(execute_buffer->desc.dwBufferSize))) { ERR("Failed to allocate execute buffer data.\n"); return DDERR_OUTOFMEMORY; diff --git a/dll/directx/wine/ddraw/light.c b/dll/directx/wine/ddraw/light.c index d20c132c37..9d0bb6028f 100644 --- a/dll/directx/wine/ddraw/light.c +++ b/dll/directx/wine/ddraw/light.c @@ -17,8 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include "ddraw_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); + /***************************************************************************** * light_update * @@ -128,7 +133,7 @@ static ULONG WINAPI d3d_light_Release(IDirect3DLight *iface) if (!ref) { - HeapFree(GetProcessHeap(), 0, light); + heap_free(light); return 0; } return ref; diff --git a/dll/directx/wine/ddraw/main.c b/dll/directx/wine/ddraw/main.c index ea3cbbe42d..9c0a81ca18 100644 --- a/dll/directx/wine/ddraw/main.c +++ b/dll/directx/wine/ddraw/main.c @@ -21,11 +21,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#define DDRAW_INIT_GUID #include "ddraw_private.h" -#include <winreg.h> -#include <rpcproxy.h> +#include "rpcproxy.h" #include "wine/exception.h" +#include "winreg.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); static struct list global_ddraw_list = LIST_INIT(global_ddraw_list); @@ -86,8 +92,7 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC /* Handle table functions */ BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) { - t->entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, initial_size * sizeof(*t->entries)); - if (!t->entries) + if (!(t->entries = heap_alloc_zero(initial_size * sizeof(*t->entries)))) { ERR("Failed to allocate handle table memory.\n"); return FALSE; @@ -101,7 +106,7 @@ BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) void ddraw_handle_table_destroy(struct ddraw_handle_table *t) { - HeapFree(GetProcessHeap(), 0, t->entries); + heap_free(t->entries); memset(t, 0, sizeof(*t)); } @@ -130,9 +135,9 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddr { /* Grow the table */ UINT new_size = t->table_size + (t->table_size >> 1); - struct ddraw_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(), - 0, t->entries, new_size * sizeof(*t->entries)); - if (!new_entries) + struct ddraw_handle_entry *new_entries; + + if (!(new_entries = heap_realloc(t->entries, new_size * sizeof(*t->entries)))) { ERR("Failed to grow the handle table.\n"); return DDRAW_INVALID_HANDLE; @@ -292,8 +297,7 @@ DDRAW_Create(const GUID *guid, flags = WINED3D_LEGACY_FFP_LIGHTING; /* DirectDraw creation comes here */ - ddraw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw)); - if (!ddraw) + if (!(ddraw = heap_alloc_zero(sizeof(*ddraw)))) { ERR("Out of memory when creating DirectDraw\n"); return E_OUTOFMEMORY; @@ -303,7 +307,7 @@ DDRAW_Create(const GUID *guid, if (FAILED(hr)) { WARN("Failed to initialize ddraw object, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, ddraw); + heap_free(ddraw); return hr; } @@ -664,7 +668,7 @@ static ULONG WINAPI ddraw_class_factory_Release(IClassFactory *iface) TRACE("%p decreasing refcount to %u.\n", factory, ref); if (!ref) - HeapFree(GetProcessHeap(), 0, factory); + heap_free(factory); return ref; } @@ -736,20 +740,20 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out) && !IsEqualGUID(&IID_IUnknown, riid)) return E_NOINTERFACE; - for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) + for (i=0; i < ARRAY_SIZE(object_creation); i++) { ... 16675 lines suppressed ...
6 years, 9 months
1
0
0
0
01/01: [AMSTREAM_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=595b846dae22041ba4bc9…
commit 595b846dae22041ba4bc9a573561cfc5a9951ff1 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:11:06 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:11:06 2018 +0100 [AMSTREAM_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/amstream/amstream.c | 39 ++++++++++++++++---------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/rostests/winetests/amstream/amstream.c b/modules/rostests/winetests/amstream/amstream.c index c343a04aa7..70cd18de1b 100644 --- a/modules/rostests/winetests/amstream/amstream.c +++ b/modules/rostests/winetests/amstream/amstream.c @@ -18,23 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - #define COBJMACROS -#include <wine/test.h> -#include <wingdi.h> -#include <winnls.h> -#include <vfwmsgs.h> -#include <objbase.h> -#include <mmreg.h> -#include <ks.h> -#include <ksmedia.h> -#include <initguid.h> -#include <amstream.h> -#include <dxsdk/uuids.h> +#include "wine/test.h" +#include "initguid.h" +#include "uuids.h" +#include "amstream.h" +#include "vfwmsgs.h" +#include "mmreg.h" +#include "ks.h" +#include "ksmedia.h" #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) static void _expect_ref(IUnknown* obj, ULONG ref, int line) @@ -265,6 +258,7 @@ static void test_media_streams(void) { IAMMediaStream* am_media_stream; IMultiMediaStream *multi_media_stream; + IPin *pin = NULL; IAudioMediaStream* audio_media_stream; IDirectDrawMediaStream *ddraw_stream = NULL; IDirectDrawStreamSample *ddraw_sample = NULL; @@ -284,6 +278,11 @@ static void test_media_streams(void) IAMMediaStream_Release(am_media_stream); + hr = IMediaStream_QueryInterface(video_stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr); + + IPin_Release(pin); + hr = IMediaStream_QueryInterface(video_stream, &IID_IAudioMediaStream, (LPVOID*)&audio_media_stream); ok(hr == E_NOINTERFACE, "IMediaStream_QueryInterface returned: %x\n", hr); @@ -375,6 +374,7 @@ static void test_media_streams(void) { IAMMediaStream* am_media_stream; IMultiMediaStream *multi_media_stream; + IPin *pin = NULL; IDirectDrawMediaStream* ddraw_stream = NULL; IAudioMediaStream* audio_media_stream = NULL; IAudioStreamSample *audio_sample = NULL; @@ -394,6 +394,11 @@ static void test_media_streams(void) IAMMediaStream_Release(am_media_stream); + hr = IMediaStream_QueryInterface(audio_stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr); + + IPin_Release(pin); + hr = IMediaStream_QueryInterface(audio_stream, &IID_IDirectDrawMediaStream, (LPVOID*)&ddraw_stream); ok(hr == E_NOINTERFACE, "IMediaStream_QueryInterface returned: %x\n", hr); @@ -478,6 +483,10 @@ static void test_media_streams(void) ok(SUCCEEDED(hr), "IEnumMediaTypes_Next returned: %x\n", hr); ok(nb_media_types > 0, "nb_media_types should be >0\n"); IEnumMediaTypes_Release(enum_media_types); + hr = IMediaStream_QueryInterface(i ? audio_stream : video_stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr); + ok(pin == pins[i], "Pin is %p instead of %p\n", pins[i], pin); + IPin_Release(pin); IPin_Release(pins[i]); } IEnumPins_Release(enum_pins);
6 years, 9 months
1
0
0
0
01/01: [AMSTREAM] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7401c74a40a8061047503…
commit 7401c74a40a80610475037bf3e92a667a9855646 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:10:17 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:10:17 2018 +0100 [AMSTREAM] Sync with Wine Staging 3.3. CORE-14434 --- dll/directx/wine/amstream/CMakeLists.txt | 4 +- dll/directx/wine/amstream/amstream.c | 9 + dll/directx/wine/amstream/amstream_private.h | 18 +- dll/directx/wine/amstream/audiodata.c | 7 + dll/directx/wine/amstream/main.c | 17 +- dll/directx/wine/amstream/mediastream.c | 372 +++++++++++++++++++++++++- dll/directx/wine/amstream/mediastreamfilter.c | 213 ++------------- dll/directx/wine/amstream/precomp.h | 16 ++ media/doc/README.WINE | 2 +- 9 files changed, 454 insertions(+), 204 deletions(-) diff --git a/dll/directx/wine/amstream/CMakeLists.txt b/dll/directx/wine/amstream/CMakeLists.txt index b6e6b869aa..85ee1a45e3 100644 --- a/dll/directx/wine/amstream/CMakeLists.txt +++ b/dll/directx/wine/amstream/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE main.c mediastream.c mediastreamfilter.c - amstream_private.h) + precomp.h) add_library(amstream SHARED ${SOURCE} @@ -20,5 +20,5 @@ add_library(amstream SHARED set_module_type(amstream win32dll) target_link_libraries(amstream strmbase strmiids uuid wine) add_importlibs(amstream ole32 ddraw user32 msvcrt kernel32 ntdll) -add_pch(amstream amstream_private.h SOURCE) +add_pch(amstream precomp.h SOURCE) add_cd_file(TARGET amstream DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/amstream/amstream.c b/dll/directx/wine/amstream/amstream.c index 13be22fbc5..463cba690b 100644 --- a/dll/directx/wine/amstream/amstream.c +++ b/dll/directx/wine/amstream/amstream.c @@ -19,8 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "wine/debug.h" + +#define COBJMACROS + +#include "winbase.h" +#include "wingdi.h" + #include "amstream_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(amstream); + typedef struct { IAMMultiMediaStream IAMMultiMediaStream_iface; LONG ref; diff --git a/dll/directx/wine/amstream/amstream_private.h b/dll/directx/wine/amstream/amstream_private.h index f85b84328a..64a376f058 100644 --- a/dll/directx/wine/amstream/amstream_private.h +++ b/dll/directx/wine/amstream/amstream_private.h @@ -21,15 +21,17 @@ #ifndef __AMSTREAM_PRIVATE_INCLUDED__ #define __AMSTREAM_PRIVATE_INCLUDED__ -#define WIN32_NO_STATUS -#define WIN32_LEAN_AND_MEAN -#define COBJMACROS +#include <stdarg.h> -#include <dshow.h> -#include <amstream.h> - -#include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(amstream); +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" +#include "wingdi.h" +#include "winuser.h" +#include "dshow.h" +#include "mmstream.h" +#include "austream.h" +#include "amstream.h" HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; diff --git a/dll/directx/wine/amstream/audiodata.c b/dll/directx/wine/amstream/audiodata.c index b50f7b58e1..06ed932401 100644 --- a/dll/directx/wine/amstream/audiodata.c +++ b/dll/directx/wine/amstream/audiodata.c @@ -18,8 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "wine/debug.h" + +#define COBJMACROS + +#include "winbase.h" #include "amstream_private.h" +WINE_DEFAULT_DEBUG_CHANNEL(amstream); + typedef struct { IAudioData IAudioData_iface; LONG ref; diff --git a/dll/directx/wine/amstream/main.c b/dll/directx/wine/amstream/main.c index 7a1f7d888d..2cadf9c32f 100644 --- a/dll/directx/wine/amstream/main.c +++ b/dll/directx/wine/amstream/main.c @@ -18,9 +18,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdarg.h> +#include <string.h> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winerror.h" + +#include "ole2.h" +#include "rpcproxy.h" + #include "amstream_private.h" -#include <rpcproxy.h> +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(amstream); static HINSTANCE instance; diff --git a/dll/directx/wine/amstream/mediastream.c b/dll/directx/wine/amstream/mediastream.c index c44eaad895..4c14b631d1 100644 --- a/dll/directx/wine/amstream/mediastream.c +++ b/dll/directx/wine/amstream/mediastream.c @@ -18,8 +18,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#ifndef __REACTOS__ +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#endif +#define COBJMACROS + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "dshow.h" + +#include "wine/strmbase.h" + #include "amstream_private.h" +#include "ddstream.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(amstream); + #include <initguid.h> DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b); @@ -27,7 +46,14 @@ static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectD const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample); static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample); +struct DirectDrawMediaStreamImpl; + typedef struct { + BaseInputPin pin; + struct DirectDrawMediaStreamImpl *parent; +} DirectDrawMediaStreamInputPin; + +typedef struct DirectDrawMediaStreamImpl { IAMMediaStream IAMMediaStream_iface; IDirectDrawMediaStream IDirectDrawMediaStream_iface; LONG ref; @@ -35,6 +61,8 @@ typedef struct { MSPID purpose_id; STREAM_TYPE stream_type; IDirectDraw7 *ddraw; + DirectDrawMediaStreamInputPin *input_pin; + CRITICAL_SECTION critical_section; } DirectDrawMediaStreamImpl; static inline DirectDrawMediaStreamImpl *impl_from_DirectDrawMediaStream_IAMMediaStream(IAMMediaStream *iface) @@ -64,6 +92,18 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_QueryInterface(IA *ret_iface = &This->IDirectDrawMediaStream_iface; return S_OK; } + else if (IsEqualGUID(riid, &IID_IPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.pin.IPin_iface; + return S_OK; + } + else if (IsEqualGUID(riid, &IID_IMemInputPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.IMemInputPin_iface; + return S_OK; + } ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ret_iface); return E_NOINTERFACE; @@ -88,6 +128,8 @@ static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Release(IAMMediaStr if (!ref) { + BaseInputPin_Destroy((BaseInputPin *)This->input_pin); + DeleteCriticalSection(&This->critical_section); if (This->ddraw) IDirectDraw7_Release(This->ddraw); HeapFree(GetProcessHeap(), 0, This); @@ -200,9 +242,11 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMed { DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); - FIXME("(%p/%p)->(%p) stub!\n", This, iface, media_stream_filter); + TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter); - return S_FALSE; + This->input_pin->pin.pin.pinInfo.pFilter = (IBaseFilter *)media_stream_filter; + + return S_OK; } static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) @@ -421,10 +465,151 @@ static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStreamImpl_IDirect DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetTimePerFrame }; +static inline DirectDrawMediaStreamInputPin *impl_from_DirectDrawMediaStreamInputPin_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, DirectDrawMediaStreamInputPin, pin.pin.IPin_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI DirectDrawMediaStreamInputPin_IPin_QueryInterface(IPin *iface, REFIID riid, void **ret_iface) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_QueryInterface(&This->parent->IAMMediaStream_iface, riid, ret_iface); +} + +static ULONG WINAPI DirectDrawMediaStreamInputPin_IPin_AddRef(IPin *iface) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_AddRef(&This->parent->IAMMediaStream_iface); +} + +static ULONG WINAPI DirectDrawMediaStreamInputPin_IPin_Release(IPin *iface) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); +} + +static const IPinVtbl DirectDrawMediaStreamInputPin_IPin_Vtbl = +{ + DirectDrawMediaStreamInputPin_IPin_QueryInterface, + DirectDrawMediaStreamInputPin_IPin_AddRef, + DirectDrawMediaStreamInputPin_IPin_Release, + BaseInputPinImpl_Connect, + BaseInputPinImpl_ReceiveConnection, + BasePinImpl_Disconnect, + BasePinImpl_ConnectedTo, + BasePinImpl_ConnectionMediaType, + BasePinImpl_QueryPinInfo, + BasePinImpl_QueryDirection, + BasePinImpl_QueryId, + BaseInputPinImpl_QueryAccept, + BasePinImpl_EnumMediaTypes, + BasePinImpl_QueryInternalConnections, + BaseInputPinImpl_EndOfStream, + BaseInputPinImpl_BeginFlush, + BaseInputPinImpl_EndFlush, + BaseInputPinImpl_NewSegment, +}; + +static HRESULT WINAPI DirectDrawMediaStreamInputPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *media_type) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%p)\n", This, media_type); + + if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Video)) + { + if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB1) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB4) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB8) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB565) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB555) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB24) || + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB32)) + { + TRACE("Video sub-type %s matches\n", debugstr_guid(&media_type->subtype)); + return S_OK; + } + } + + return S_FALSE; +} + +static LONG WINAPI DirectDrawMediaStreamInputPin_GetMediaTypeVersion(BasePin *base) +{ + return 0; +} + +static HRESULT WINAPI DirectDrawMediaStreamInputPin_GetMediaType(BasePin *base, int index, AM_MEDIA_TYPE *media_type) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%d,%p)\n", This, index, media_type); + + /* FIXME: Reset structure as we only fill majortype and minortype for now */ + ZeroMemory(media_type, sizeof(*media_type)); + + media_type->majortype = MEDIATYPE_Video; + + switch (index) + { + case 0: + media_type->subtype = MEDIASUBTYPE_RGB1; + break; + case 1: + media_type->subtype = MEDIASUBTYPE_RGB4; + break; + case 2: + media_type->subtype = MEDIASUBTYPE_RGB8; + break; + case 3: + media_type->subtype = MEDIASUBTYPE_RGB565; + break; + case 4: + media_type->subtype = MEDIASUBTYPE_RGB555; + break; + case 5: + media_type->subtype = MEDIASUBTYPE_RGB24; + break; + case 6: + media_type->subtype = MEDIASUBTYPE_RGB32; + break; + default: + return S_FALSE; + } + + return S_OK; +} + +static HRESULT WINAPI DirectDrawMediaStreamInputPin_Receive(BaseInputPin *base, IMediaSample *sample) +{ + DirectDrawMediaStreamInputPin *This = impl_from_DirectDrawMediaStreamInputPin_IPin(&base->pin.IPin_iface); + + FIXME("(%p)->(%p) stub!\n", This, sample); + + return E_NOTIMPL; +} + +static const BaseInputPinFuncTable DirectDrawMediaStreamInputPin_FuncTable = +{ + { + DirectDrawMediaStreamInputPin_CheckMediaType, + NULL, + DirectDrawMediaStreamInputPin_GetMediaTypeVersion, + DirectDrawMediaStreamInputPin_GetMediaType, + }, + DirectDrawMediaStreamInputPin_Receive, +}; + HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { DirectDrawMediaStreamImpl *object; + PIN_INFO pin_info; + HRESULT hr; TRACE("(%p,%s,%p)\n", parent, debugstr_guid(purpose_id), media_stream); @@ -436,6 +621,20 @@ HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ object->IDirectDrawMediaStream_iface.lpVtbl = &DirectDrawMediaStreamImpl_IDirectDrawMediaStream_Vtbl; object->ref = 1; + InitializeCriticalSection(&object->critical_section); + + pin_info.pFilter = NULL; + pin_info.dir = PINDIR_INPUT; + pin_info.achName[0] = 'I'; + StringFromGUID2(purpose_id, pin_info.achName + 1, MAX_PIN_NAME - 1); + hr = BaseInputPin_Construct(&DirectDrawMediaStreamInputPin_IPin_Vtbl, + sizeof(DirectDrawMediaStreamInputPin), &pin_info, &DirectDrawMediaStreamInputPin_FuncTable, + &object->critical_section, NULL, (IPin **)&object->input_pin); + if (FAILED(hr)) + goto out_object; + + object->input_pin->parent = object; + object->parent = parent; object->purpose_id = *purpose_id; object->stream_type = stream_type; @@ -443,15 +642,29 @@ HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ *media_stream = &object->IAMMediaStream_iface; return S_OK; + +out_object: + HeapFree(GetProcessHeap(), 0, object); + + return hr; } +struct AudioMediaStreamImpl; + typedef struct { + BaseInputPin pin; + struct AudioMediaStreamImpl *parent; +} AudioMediaStreamInputPin; + +typedef struct AudioMediaStreamImpl { IAMMediaStream IAMMediaStream_iface; IAudioMediaStream IAudioMediaStream_iface; LONG ref; IMultiMediaStream* parent; MSPID purpose_id; STREAM_TYPE stream_type; + AudioMediaStreamInputPin *input_pin; + CRITICAL_SECTION critical_section; } AudioMediaStreamImpl; static inline AudioMediaStreamImpl *impl_from_AudioMediaStream_IAMMediaStream(IAMMediaStream *iface) @@ -481,6 +694,18 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMedi *ret_iface = &This->IAudioMediaStream_iface; return S_OK; } + else if (IsEqualGUID(riid, &IID_IPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.pin.IPin_iface; + return S_OK; + } + else if (IsEqualGUID(riid, &IID_IMemInputPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.IMemInputPin_iface; + return S_OK; + } ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ret_iface); return E_NOINTERFACE; @@ -504,7 +729,11 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream * TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); if (!ref) + { + BaseInputPin_Destroy((BaseInputPin *)This->input_pin); + DeleteCriticalSection(&This->critical_section); HeapFree(GetProcessHeap(), 0, This); + } return ref; } @@ -613,9 +842,11 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStr { AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - FIXME("(%p/%p)->(%p) stub!\n", This, iface, media_stream_filter); + TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter); - return S_FALSE; + This->input_pin->pin.pin.pinInfo.pFilter = (IBaseFilter *)media_stream_filter; + + return S_OK; } static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) @@ -803,10 +1034,122 @@ static const struct IAudioMediaStreamVtbl AudioMediaStreamImpl_IAudioMediaStream AudioMediaStreamImpl_IAudioMediaStream_CreateSample }; +static inline AudioMediaStreamInputPin *impl_from_AudioMediaStreamInputPin_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, AudioMediaStreamInputPin, pin.pin.IPin_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI AudioMediaStreamInputPin_IPin_QueryInterface(IPin *iface, REFIID riid, void **ret_iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_QueryInterface(&This->parent->IAMMediaStream_iface, riid, ret_iface); +} + +static ULONG WINAPI AudioMediaStreamInputPin_IPin_AddRef(IPin *iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_AddRef(&This->parent->IAMMediaStream_iface); +} + +static ULONG WINAPI AudioMediaStreamInputPin_IPin_Release(IPin *iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); +} + +static const IPinVtbl AudioMediaStreamInputPin_IPin_Vtbl = +{ + AudioMediaStreamInputPin_IPin_QueryInterface, + AudioMediaStreamInputPin_IPin_AddRef, + AudioMediaStreamInputPin_IPin_Release, + BaseInputPinImpl_Connect, + BaseInputPinImpl_ReceiveConnection, + BasePinImpl_Disconnect, + BasePinImpl_ConnectedTo, + BasePinImpl_ConnectionMediaType, + BasePinImpl_QueryPinInfo, + BasePinImpl_QueryDirection, + BasePinImpl_QueryId, + BaseInputPinImpl_QueryAccept, + BasePinImpl_EnumMediaTypes, + BasePinImpl_QueryInternalConnections, + BaseInputPinImpl_EndOfStream, + BaseInputPinImpl_BeginFlush, + BaseInputPinImpl_EndFlush, + BaseInputPinImpl_NewSegment, +}; + +static HRESULT WINAPI AudioMediaStreamInputPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *media_type) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%p)\n", This, media_type); + + if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Audio)) + { + if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_PCM)) + { + TRACE("Audio sub-type %s matches\n", debugstr_guid(&media_type->subtype)); + return S_OK; + } + } + + return S_OK; +} + +static LONG WINAPI AudioMediaStreamInputPin_GetMediaTypeVersion(BasePin *base) +{ + return 0; +} + +static HRESULT WINAPI AudioMediaStreamInputPin_GetMediaType(BasePin *base, int index, AM_MEDIA_TYPE *media_type) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%d,%p)\n", This, index, media_type); + + /* FIXME: Reset structure as we only fill majortype and minortype for now */ + ZeroMemory(media_type, sizeof(*media_type)); + + if (index) + return S_FALSE; + + media_type->majortype = MEDIATYPE_Audio; + media_type->subtype = MEDIASUBTYPE_PCM; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamInputPin_Receive(BaseInputPin *base, IMediaSample *sample) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->pin.IPin_iface); + + FIXME("(%p)->(%p) stub!\n", This, sample); + + return E_NOTIMPL; +} + +static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = +{ + { + AudioMediaStreamInputPin_CheckMediaType, + NULL, + AudioMediaStreamInputPin_GetMediaTypeVersion, + AudioMediaStreamInputPin_GetMediaType, + }, + AudioMediaStreamInputPin_Receive, +}; + HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { AudioMediaStreamImpl *object; + PIN_INFO pin_info; + HRESULT hr; TRACE("(%p,%s,%p)\n", parent, debugstr_guid(purpose_id), media_stream); @@ -818,6 +1161,20 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; object->ref = 1; + InitializeCriticalSection(&object->critical_section); + + pin_info.pFilter = NULL; + pin_info.dir = PINDIR_INPUT; + pin_info.achName[0] = 'I'; + StringFromGUID2(purpose_id, pin_info.achName + 1, MAX_PIN_NAME - 1); + hr = BaseInputPin_Construct(&AudioMediaStreamInputPin_IPin_Vtbl, + sizeof(AudioMediaStreamInputPin), &pin_info, &AudioMediaStreamInputPin_FuncTable, + &object->critical_section, NULL, (IPin **)&object->input_pin); + if (FAILED(hr)) + goto out_object; + + object->input_pin->parent = object; + object->parent = parent; object->purpose_id = *purpose_id; object->stream_type = stream_type; @@ -825,6 +1182,11 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ *media_stream = &object->IAMMediaStream_iface; return S_OK; + +out_object: + HeapFree(GetProcessHeap(), 0, object); + + return hr; } typedef struct { @@ -918,7 +1280,7 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_Update(IDirectDrawStreamSample { FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data); - return E_NOTIMPL; + return S_OK; } static HRESULT WINAPI IDirectDrawStreamSampleImpl_CompletionStatus(IDirectDrawStreamSample *iface, DWORD flags, DWORD milliseconds) diff --git a/dll/directx/wine/amstream/mediastreamfilter.c b/dll/directx/wine/amstream/mediastreamfilter.c index 39c3a5eddb..a7ff6e87fc 100644 --- a/dll/directx/wine/amstream/mediastreamfilter.c +++ b/dll/directx/wine/amstream/mediastreamfilter.c @@ -18,176 +18,33 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "amstream_private.h" +#include "wine/debug.h" -#include <wine/strmbase.h> +#define COBJMACROS -typedef struct MediaStreamFilter_InputPin -{ - BaseInputPin pin; -} MediaStreamFilter_InputPin; +#include "winbase.h" +#include "wingdi.h" +#include "dshow.h" -static const IPinVtbl MediaStreamFilter_InputPin_Vtbl = -{ - BaseInputPinImpl_QueryInterface, - BasePinImpl_AddRef, - BaseInputPinImpl_Release, - BaseInputPinImpl_Connect, - BaseInputPinImpl_ReceiveConnection, - BasePinImpl_Disconnect, - BasePinImpl_ConnectedTo, - BasePinImpl_ConnectionMediaType, - BasePinImpl_QueryPinInfo, - BasePinImpl_QueryDirection, - BasePinImpl_QueryId, - BasePinImpl_QueryAccept, - BasePinImpl_EnumMediaTypes, - BasePinImpl_QueryInternalConnections, - BaseInputPinImpl_EndOfStream, - BaseInputPinImpl_BeginFlush, - BaseInputPinImpl_EndFlush, - BasePinImpl_NewSegment -}; +#include "wine/strmbase.h" + +#include "amstream_private.h" + +#include "ddstream.h" + +WINE_DEFAULT_DEBUG_CHANNEL(amstream); typedef struct { BaseFilter filter; ULONG nb_streams; - IMediaStream** streams; - IPin** pins; + IAMMediaStream** streams; } IMediaStreamFilterImpl; static inline IMediaStreamFilterImpl *impl_from_IMediaStreamFilter(IMediaStreamFilter *iface) { - return CONTAINING_RECORD(iface, IMediaStreamFilterImpl, filter); -} - -static HRESULT WINAPI BasePinImpl_CheckMediaType(BasePin *This, const AM_MEDIA_TYPE *pmt) -{ - IMediaStreamFilterImpl *filter = impl_from_IMediaStreamFilter((IMediaStreamFilter*)This->pinInfo.pFilter); - MSPID purpose_id; - ULONG i; - - TRACE("Checking media type %s - %s\n", debugstr_guid(&pmt->majortype), debugstr_guid(&pmt->subtype)); - - /* Find which stream is associated with the pin */ - for (i = 0; i < filter->nb_streams; i++) - if (&This->IPin_iface == filter->pins[i]) - break; - - if (i == filter->nb_streams) - return S_FALSE; - - if (FAILED(IMediaStream_GetInformation(filter->streams[i], &purpose_id, NULL))) - return S_FALSE; - - TRACE("Checking stream with purpose id %s\n", debugstr_guid(&purpose_id)); - - if (IsEqualGUID(&purpose_id, &MSPID_PrimaryVideo) && IsEqualGUID(&pmt->majortype, &MEDIATYPE_Video)) - { - if (IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB1) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB4) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB8) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB565) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB555) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB24) || - IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB32)) - { - TRACE("Video sub-type %s matches\n", debugstr_guid(&pmt->subtype)); - return S_OK; - } - } - else if (IsEqualGUID(&purpose_id, &MSPID_PrimaryAudio) && IsEqualGUID(&pmt->majortype, &MEDIATYPE_Audio)) - { - if (IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_PCM)) - { - TRACE("Audio sub-type %s matches\n", debugstr_guid(&pmt->subtype)); - return S_OK; - } - } - - return S_FALSE; -} - -static LONG WINAPI BasePinImp_GetMediaTypeVersion(BasePin *This) -{ - return 0; -} - -static HRESULT WINAPI BasePinImp_GetMediaType(BasePin *This, int index, AM_MEDIA_TYPE *amt) -{ - IMediaStreamFilterImpl *filter = (IMediaStreamFilterImpl*)This->pinInfo.pFilter; - MSPID purpose_id; - ULONG i; - - /* FIXME: Reset structure as we only fill majortype and minortype for now */ - ZeroMemory(amt, sizeof(*amt)); - - /* Find which stream is associated with the pin */ - for (i = 0; i < filter->nb_streams; i++) - if (&This->IPin_iface == filter->pins[i]) - break; - - if (i == filter->nb_streams) - return S_FALSE; - - if (FAILED(IMediaStream_GetInformation(filter->streams[i], &purpose_id, NULL))) - return S_FALSE; - - TRACE("Processing stream with purpose id %s\n", debugstr_guid(&purpose_id)); - - if (IsEqualGUID(&purpose_id, &MSPID_PrimaryVideo)) - { - amt->majortype = MEDIATYPE_Video; - - switch (index) - { - case 0: - amt->subtype = MEDIASUBTYPE_RGB1; - break; - case 1: - amt->subtype = MEDIASUBTYPE_RGB4; - break; - case 2: - amt->subtype = MEDIASUBTYPE_RGB8; - break; - case 3: - amt->subtype = MEDIASUBTYPE_RGB565; - break; - case 4: - amt->subtype = MEDIASUBTYPE_RGB555; - break; - case 5: - amt->subtype = MEDIASUBTYPE_RGB24; - break; - case 6: - amt->subtype = MEDIASUBTYPE_RGB32; - break; - default: - return S_FALSE; - } - } - else if (IsEqualGUID(&purpose_id, &MSPID_PrimaryAudio)) - { - if (index) - return S_FALSE; - - amt->majortype = MEDIATYPE_Audio; - amt->subtype = MEDIASUBTYPE_PCM; - } - - return S_OK; + return CONTAINING_RECORD((IBaseFilter *)iface, IMediaStreamFilterImpl, filter.IBaseFilter_iface); } -static const BaseInputPinFuncTable input_BaseInputFuncTable = { - { - BasePinImpl_CheckMediaType, - NULL, - BasePinImp_GetMediaTypeVersion, - BasePinImp_GetMediaType - }, - NULL -}; - /*** IUnknown methods ***/ static HRESULT WINAPI MediaStreamFilterImpl_QueryInterface(IMediaStreamFilter *iface, REFIID riid, void **ret_iface) @@ -234,11 +91,10 @@ static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter *iface) ULONG i; for (i = 0; i < This->nb_streams; i++) { - IMediaStream_Release(This->streams[i]); - IPin_Release(This->pins[i]); + IAMMediaStream_JoinFilter(This->streams[i], NULL); + IAMMediaStream_Release(This->streams[i]); } CoTaskMemFree(This->streams); - CoTaskMemFree(This->pins); BaseFilter_Destroy(&This->filter); HeapFree(GetProcessHeap(), 0, This); } @@ -331,39 +187,21 @@ static HRESULT WINAPI MediaStreamFilterImpl_QueryVendorInfo(IMediaStreamFilter * static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter* iface, IAMMediaStream *pAMMediaStream) { IMediaStreamFilterImpl *This = impl_from_IMediaStreamFilter(iface); - IMediaStream** streams; - IPin** pins; - MediaStreamFilter_InputPin* pin; + IAMMediaStream** streams; HRESULT hr; - PIN_INFO info; - MSPID purpose_id; TRACE("(%p)->(%p)\n", iface, pAMMediaStream); - streams = CoTaskMemRealloc(This->streams, (This->nb_streams + 1) * sizeof(IMediaStream*)); + streams = CoTaskMemRealloc(This->streams, (This->nb_streams + 1) * sizeof(IAMMediaStream*)); if (!streams) return E_OUTOFMEMORY; This->streams = streams; - pins = CoTaskMemRealloc(This->pins, (This->nb_streams + 1) * sizeof(IPin*)); - if (!pins) - return E_OUTOFMEMORY; - This->pins = pins; - info.pFilter = &This->filter.IBaseFilter_iface; - info.dir = PINDIR_INPUT; - hr = IAMMediaStream_GetInformation(pAMMediaStream, &purpose_id, NULL); - if (FAILED(hr)) - return hr; - /* Pin name is "I{guid MSPID_PrimaryVideo or MSPID_PrimaryAudio}" */ - info.achName[0] = 'I'; - StringFromGUID2(&purpose_id, info.achName + 1, 40); - hr = BaseInputPin_Construct(&MediaStreamFilter_InputPin_Vtbl, sizeof(BaseInputPin), &info, - &input_BaseInputFuncTable, &This->filter.csFilter, NULL, &This->pins[This->nb_streams]); + + hr = IAMMediaStream_JoinFilter(pAMMediaStream, iface); if (FAILED(hr)) return hr; - pin = (MediaStreamFilter_InputPin*)This->pins[This->nb_streams]; - pin->pin.pin.pinInfo.pFilter = &This->filter.IBaseFilter_iface; - This->streams[This->nb_streams] = (IMediaStream*)pAMMediaStream; + This->streams[This->nb_streams] = pAMMediaStream; This->nb_streams++; IAMMediaStream_AddRef(pAMMediaStream); @@ -381,10 +219,10 @@ static HRESULT WINAPI MediaStreamFilterImpl_GetMediaStream(IMediaStreamFilter* i for (i = 0; i < This->nb_streams; i++) { - IMediaStream_GetInformation(This->streams[i], &purpose_id, NULL); + IAMMediaStream_GetInformation(This->streams[i], &purpose_id, NULL); if (IsEqualIID(&purpose_id, idPurpose)) { - *ppMediaStream = This->streams[i]; + *ppMediaStream = (IMediaStream *)This->streams[i]; IMediaStream_AddRef(*ppMediaStream); return S_OK; } @@ -476,8 +314,9 @@ static IPin* WINAPI MediaStreamFilterImpl_GetPin(BaseFilter *iface, int pos) if (pos < This->nb_streams) { - IPin_AddRef(This->pins[pos]); - return This->pins[pos]; + IPin *pin = NULL; + IAMMediaStream_QueryInterface(This->streams[pos], &IID_IPin, (void **)&pin); + return pin; } return NULL; diff --git a/dll/directx/wine/amstream/precomp.h b/dll/directx/wine/amstream/precomp.h new file mode 100644 index 0000000000..0f2bf3fabe --- /dev/null +++ b/dll/directx/wine/amstream/precomp.h @@ -0,0 +1,16 @@ + +#ifndef _AMSTREAM_PRECOMP_H_ +#define _AMSTREAM_PRECOMP_H_ + +#define WIN32_NO_STATUS +#define WIN32_LEAN_AND_MEAN + +#define COBJMACROS + +#include "amstream_private.h" + +#include <ddstream.h> +#include <wine/strmbase.h> +#include <wine/debug.h> + +#endif /* _AMSTREAM_PRECOMP_H_ */ diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 8694f27ce6..6b33d671de 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -21,7 +21,7 @@ reactos/sdk/tools/wpp # Synced to WineStaging-2.9 The following libraries are shared with Wine. -reactos/dll/directx/wine/amstream # Synced to Wine-3.0 +reactos/dll/directx/wine/amstream # Synced to WineStaging-3.3 reactos/dll/directx/wine/d3d8 # Synced to Wine-3.0 reactos/dll/directx/wine/d3d9 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-3.3
6 years, 9 months
1
0
0
0
01/01: [INCLUDE/WINE] Add a header guard to strmbase.h.
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fbbe3b385641f1fd47e60…
commit fbbe3b385641f1fd47e60704c840531478a732e3 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Thu Mar 8 13:07:26 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Thu Mar 8 13:07:57 2018 +0100 [INCLUDE/WINE] Add a header guard to strmbase.h. --- sdk/include/reactos/wine/strmbase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/include/reactos/wine/strmbase.h b/sdk/include/reactos/wine/strmbase.h index abe92aea86..1f757401b4 100644 --- a/sdk/include/reactos/wine/strmbase.h +++ b/sdk/include/reactos/wine/strmbase.h @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#pragma once + #include "wine/list.h" HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc);
6 years, 9 months
1
0
0
0
← Newer
1
...
36
37
38
39
40
41
42
43
44
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
Results per page:
10
25
50
100
200