Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spu2-x:windows:Use XAudio2.8+ for Windows 8 and later #1253

Merged
merged 5 commits into from
Jun 4, 2016

Conversation

turtleli
Copy link
Member

Changes:

  • Only use the DirectX SDK for XAudio 2.7 support - everything else will use the Windows SDK.
  • Use XAudio 2.8+ for Windows 8 and later, use XAudio 2.7 for Windows Vista and 7

Combined with my GSdx (#1238) and XInput (#1237) PRs, Windows 8.1 and 10 users should be able to run PCSX2 without requiring the DirectX redists.

@refractionpcsx2
Copy link
Member

Just wanted to put in a 2 cents on this. It's a good idea but could be problematic. I'm running on Windows 10 with Visual Studio 2015 Pro but the windows 8.1 SDK is installed, which uses the old version of the GetVersion API, so windows 10 reports that I'm using windows 7 (or 8, i forget) so it just complains I need 8.1 or higher. So users would need to have the Windows 10 SDK installed, not sure if this will cause problems though, especially when it comes to releases.

@turtleli
Copy link
Member Author

It should build fine against the Windows 8.1 SDK - it does on AppVeyor, and also on my Win10 machine for both VS2013/VS2015. PCSX2 should also be reporting the correct Windows version (it reports 10 for me on Windows 10). Or am I completely misunderstanding you?

Currently I know there are build issues if the include paths are altered to look at the DirectX SDK directories before looking the Windows 8.1 SDK files (see 16ef7ca), which I need to look into properly before I can even merge this PR but I've been too lazy to do so (it's so not my idea of fun).

@refractionpcsx2
Copy link
Member

The problem I have is the SDK which is the Windows 8.1 SDK uses the old GetVersion API call, which Windows 10 spoofs to be an older version of windows unless you use the new call, it's some compatibility bull they came up with, so it thinks I'm using an old version of windows. PCSX2 reports it fine, it's just Visual Studio, so it refuses to compile SPU2-X with the Win 8.1 SDK.

Example explanation: http://www.freebasic.net/forum/viewtopic.php?t=23868

Anyway this isn't your bug, this is in the SDK, actually in xaudio2.h

@turtleli
Copy link
Member Author

What specific errors come up? It compiles fine with the Win 8.1 SDK here (Windows 10, VS2013/VS2015 community)

@refractionpcsx2
Copy link
Member

#if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
#error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
#endif // (_WIN32_WINNT < _WIN32_WINNT_WIN8)

line 19 of xaudio2.h

@turtleli
Copy link
Member Author

That error shouldn't come up unless Visual Studio can't find the DirectX SDK include files. Does SPU2-X compile on master for you? Do you have DXSDK_DIR set anywhere? It's usually set as a system/user environment variable but there's probably other ways (VS macro).

@refractionpcsx2
Copy link
Member

That error shouldn't come up unless Visual Studio can't find the DirectX SDK include files. Does SPU2-X compile on master for you? Do you have DXSDK_DIR set anywhere? It's usually set as a system/user environment variable but there's probably other ways (VS macro).

the DX SDK has never installed properly for me under VS and i have never created a DXSDK_DIR, i have always installed it by manually adding the include/library paths to my microsoft.users.cpp property, which is how people on the web said to do it.

Anyway, I removed those references to see if i could just use the SDK as it didn't matter about compatibility from my side, but that error happened of course.

Just to add strangeness to the mix. If i open xaudio2.h on its own and check it, _WIN32_WINNT returns 0x603, which is right, if i check _WIN32_WINNT inside the PCSX2 solution under SPU2-X or GSDX (didn't try any other), it returns 0x600.

@refractionpcsx2
Copy link
Member

omg, it's wgwidgets, it's defined in there as 0x600! wrapwin.h line 47 is where it's getting it from, it isn't finding the definition anywhere else.

I guess we could define it in the preprocessor list as 0x602, that should sort it.

@turtleli
Copy link
Member Author

My code works on the assumption that you set DXSDK_DIR for the DirectX SDK, so that xaudio2.h from the DX SDK can be used to support XAudio 2.7. Setting the DX SDK include/library paths in microsoft.users.cpp isn't a good idea if you're using the Windows 8.1 SDK or later since you might use the DirectX SDK files when it's unnecessary.

Probably the easiest way to set DXSDK_DIR is to access System Properties -> Advanced -> Environment variables and set it there (final backslash is essential)
dxsdk

@refractionpcsx2
Copy link
Member

Yeah I can do that for now, but aren't your proposed changes going to make it use the SDK and put me back in that position again?

@turtleli
Copy link
Member Author

It shouldn't. I set _WIN32_WINNT to 0x602 when I include xaudio2.h from the 8.1 SDK (plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp):

#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0602
#include <xaudio2.h>

The DX SDK header files should be used for the other xaudio2.h include (plugins/spu2-x/src/Windows/SndOut_XAudio2_27.cpp), and that requires DXSDK_DIR to be set.

@refractionpcsx2
Copy link
Member

That should be okay then :)
I'll assign the DXSDK_DIR macro properly for now :)

@gregory38
Copy link
Contributor

Could the PR be merged? Or is there any remaining stuff to review/update?

@turtleli
Copy link
Member Author

turtleli commented May 2, 2016

Well, it might break compilation on the Orphis buildbot. My last GSdx PR broke it and I had to fix it (7736c90 which isn't actually a Windows 7 compile fix). I suppose I should request access to the buildbot and try to fix the issue so that I can merge this at some point.

@gregory38
Copy link
Contributor

Ok. I have the access. I could post you a log (if is KO and I don't forget)

@turtleli
Copy link
Member Author

turtleli commented May 2, 2016

Well, if you check the log from one of the recent builds and the GSdx warnings are different from AppVeyor's (DXGI_* macro redefinition warnings), then this PR is likely to break the buildbot.

@gregory38
Copy link
Contributor

gregory38 commented May 2, 2016

I pushed your branch into a PCSX2 project branch so the buildbot will eventually built it.

Edit: result in 30 minutes (if there is only a single build in queue)

@gregory38
Copy link
Contributor

Here we go

[18:32:27][CL] SndOut_XAudio2.cpp(246, 0): error C2065: 'XAUDIO2_DLL': undeclared identifier
[18:32:27][CL] SndOut_XAudio2.cpp(248, 0): error C2146: syntax error: missing ')' before identifier 'XAUDIO2_DLL_A'
[18:32:27][CL] SndOut_XAudio2.cpp(247, 0): warning C4390: ';': empty controlled statement found; is this the intent?

Note: you can push a branch directly to PCSX2 (instead of your fork, this way it will trigger a build on the bot and I can copy/past the log)

@turtleli
Copy link
Member Author

turtleli commented May 2, 2016

Yeah, that indicates that it's looking at the DX SDK files before it looks at the Windows SDK files. It's only supposed to do that for Sndout_XAudio2_27.cpp in this PR. The rest of the files shouldn't require the DX SDK at all.

The fix is to set DXSDK_DIR (system/user variable, or VS user macro) to the DX SDK path (backslash at end is essential) and remove any other method of adding the DX SDK directory to the path. I assume that's what needs changed in the buildbot.

@gregory38
Copy link
Contributor

gregory38 commented May 5, 2016

The current config is

env.DXSDK_DIR   C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\

Only in system env.

@gregory38
Copy link
Contributor

And there those parameters (maybe not env variable)

WindowsSDKv7.0A      7.0.30319
WindowsSDKv7.0A_Path     c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A
WindowsSDKv7.1   7.1.7600.0.30514
WindowsSDKv7.1A      7.1.51106
WindowsSDKv7.1A_Path     C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A
WindowsSDKv7.1_Path      C:\Program Files\Microsoft SDKs\Windows\v7.1
WindowsSDKv8.0   6.2..9200
WindowsSDKv8.0A      8.0.50709
WindowsSDKv8.0A_Path     C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A
WindowsSDKv8.0_Path      C:\Program Files (x86)\Windows Kits\8.0
WindowsSDKv8.1   6.3..9600
WindowsSDKv8.1A      8.1.51641
WindowsSDKv8.1A_Path     C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A
WindowsSDKv8.1_Path      C:\Program Files (x86)\Windows Kits\8.1

So what's wrong?

@turtleli
Copy link
Member Author

turtleli commented May 5, 2016

Hmm. No clue. Is there any variable with include/library paths?

@gregory38
Copy link
Contributor

Here the env setup. There are some stuff about cg.

Environment variables that will be included into environment variables list of build processes of a build
=C:      C:\BuildAgent\bin
ALLUSERSPROFILE      C:\ProgramData
APPDATA      C:\Users\buildbot\AppData\Roaming
CG_BIN64_PATH    C:\Program Files (x86)\NVIDIA Corporation\Cg\bin.x64
CG_BIN_PATH      C:\Program Files (x86)\NVIDIA Corporation\Cg\bin
CG_INC_PATH      C:\Program Files (x86)\NVIDIA Corporation\Cg\include
CG_LIB64_PATH    C:\Program Files (x86)\NVIDIA Corporation\Cg\lib.x64
CG_LIB_PATH      C:\Program Files (x86)\NVIDIA Corporation\Cg\lib
CommonProgramFiles   C:\Program Files (x86)\Common Files
CommonProgramFiles(x86)      C:\Program Files (x86)\Common Files
CommonProgramW6432   C:\Program Files\Common Files
COMPUTERNAME     SHAMSHEL
ComSpec      C:\Windows\system32\cmd.exe
DXSDK_DIR    C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\
FP_NO_HOST_CHECK     NO
HOME     C:\Users\Administrator
LOCALAPPDATA     C:\Users\buildbot\AppData\Local
NUMBER_OF_PROCESSORS     4
OS   Windows_NT
Path     C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\NVIDIA Corporation\Cg\bin;C:\Program Files (x86)\NVIDIA Corporation\Cg\bin.x64;C:\cygwin\bin;C:\Program Files\7-Zip;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin;C:\Program Files (x86)\CMake\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
PATHEXT      .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.py;.pyw
PROCESSOR_ARCHITECTURE   x86
PROCESSOR_ARCHITEW6432   AMD64
PROCESSOR_IDENTIFIER     Intel64 Family 6 Model 2 Stepping 3, GenuineIntel
PROCESSOR_LEVEL      6
PROCESSOR_REVISION   0203
ProgramData      C:\ProgramData
ProgramFiles     C:\Program Files (x86)
ProgramFiles(x86)    C:\Program Files (x86)
ProgramW6432     C:\Program Files
PSModulePath     C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC   C:\Users\Public
QT_DIR_5_2_1     C:\Qt\5.2.1
SystemDrive      C:
SystemRoot   C:\Windows
TEAMCITY_CAPTURE_ENV     "C:\BuildAgent\jre\bin\java.exe" -jar "C:\BuildAgent\plugins\environment-fetcher\bin\env-fetcher.jar"
TEAMCITY_GIT_PATH    C:\Program Files (x86)\Git\bin\git.exe
TEAMCITY_JRE     C:\BuildAgent\jre
TEMP     C:\Users\buildbot\AppData\Local\Temp
TMP      C:\Users\buildbot\AppData\Local\Temp
USERDOMAIN   SHAMSHEL
USERNAME     buildbot
USERPROFILE      C:\Users\buildbot
VS100COMNTOOLS   C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
VS110COMNTOOLS   C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
VS120COMNTOOLS   C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
VS140COMNTOOLS   C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
VS90COMNTOOLS    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\
windir   C:\Windows
WRAPPER_ARCH     x86
WRAPPER_BITS     32
WRAPPER_FILE_SEPARATOR   \
WRAPPER_OS   windows
WRAPPER_PATH_SEPARATOR   ;

@Zangetsu38
Copy link

Yes but I have 2.9 With WIndows 10, No 2.7, so it is normal i don't have very old SDK

@turtleli
Copy link
Member Author

turtleli commented Oct 1, 2016

Windows 7 users have XAudio2.7 though.

@Zangetsu38
Copy link

Yes, but, i waiting Spu works with Windows 10 only with Sdk 8.1, and i thinks this PR fixed this problerm but no :(

@turtleli
Copy link
Member Author

turtleli commented Oct 1, 2016

Windows 7 EOL is 14/1/2020. You'll likely be waiting quite a while then.

Your other options are to create and maintain a local branch that doesn't require the DirectX SDK (but which removes the ability for Windows 7 users to use XAudio 2.7), or just install/extract the necessary DirectX SDK files (you only really need the header files, so that's really not going to take up a lot of space).

@mirh
Copy link

mirh commented Oct 2, 2016

Can't you like just simply fallback to windows sdk stuff when directx sdk (files? env var?) isn't found?

And I don't see why whatever microsoft says about support should be relevant to whether we still can support an OS or not.

@jcdenton2k
Copy link

jcdenton2k commented Oct 2, 2016

Newer isn't always better and when it comes to developing on Win10 you are doing dev builds on a dev OS and that isn't always best for stability.

That said, for right now the target minimum OS should remain Win7 and up. I know I plan to use Win7 long after support 'officially' ends because I am not fond of doing gaming or other stuff on an unstable OS like Win10.

In Linux Terms:

Win7 = Long Term Support release = STABLE
Win8.1 = Intermediate Support until X period of time = BETA
Win10 = Dev builds, for testers only = DEV/CANARY

@Zangetsu38
Copy link

Windows 10 Very Best, Windows 7 euuu , very old, no support SSD, no support Dx12 etc, this OS is dead

@mirh
Copy link

mirh commented Oct 2, 2016

@jcdenton2k Windoes 8 just has a shitty UI, aside of that nothing changed since 95. The dev quality paradigm shift happened with W10 and its "special updates policies".

@Zangetsu38 Even windows 95 can run on an ssd. If you are talking about TRIM that was indeed introduced in Windows 7.

I'd stop the OT here.

@Zangetsu38
Copy link

Zangetsu38 commented Oct 2, 2016

@mirh Yes, Trim support start by Windows 8, so yes, ssd install and use works, but Fail with no support trim
I Request just, for spu2 compile, use Only SDK 8.1 in VS 2015 and add file requiere in project in 3dparty minidx9 for compile spu2 for Xaudio 2.7 in Windows 7.
Same you change for separate SDK dx june 2010 with compile Xaudio, Ximput etc

@mirh
Copy link

mirh commented Oct 2, 2016

I think __has_include directive is what we really would need here.

I haven't tested myself, but a guy says VS15 update 2 supports it (part of the c++17 N4567 work I guess?)
For keeping vs13 support, I guess this could be used too.

@jcdenton2k
Copy link

jcdenton2k commented Oct 3, 2016

@Zangetsu38;

I'm not sure where you got your faulty information, but Win7 SP1 supports SSDs and TRIM without issues:

http://www.ghacks.net/2010/09/14/verify-that-trim-is-enabled-in-windows-7/

Even though I'm using mechanical drives, TRIM is still enabled by default for me just in case I update to SSDs.

Having a dual-architecture structure for the Win7/Win8.1 side and the Win10 side might be useful to do but we should be careful not to deprecate the most widely-used OS's on the market. Win10 is a tiny minority in the grand scheme of things even after M$ pushed out Win10 like a virus on everyone forcing them to update without notice or consent.

@Zangetsu38
Copy link

Zangetsu38 commented Oct 3, 2016

No, Sorry, it is officiel By Microsoft, Windows 7 Not support Trim :)
And euu ? Win7 = Long Term Support release = STABLE hmm lol, Windows 7 totaly Obselled, extremly slow, and support very Soon Stoped by MS, This OS is already DEAD

@Zangetsu38
Copy link

Zangetsu38 commented Oct 3, 2016

I juste Request, separate SDK Dx June 2010 for other OS, and actually, This emulator only Run Xaudio 2.7, Xaudio 2.8+ requierement Sdk Windows kit 8.1 minimum.
You have already make that for Gsdx and xinput etc, Now just need make same with Xaudio, and add Xaudio 2.7 support with minidx9

@refractionpcsx2
Copy link
Member

refractionpcsx2 commented Oct 3, 2016

Windows 7 does support TRIM from Service Pack 1. Microsoft officially said Windows 7 doesn't support TRIM, meaning WITHOUT the service pack, it won't support it.

@Zangetsu38
Copy link

hmm I see

@mirh
Copy link

mirh commented Oct 4, 2016

#if defined(__has_include)
#if __has_include("dxsdkver.h")
<care about SndOut_XAudio2_27.cpp>
#else <warn user he hasn't dx sdk and he's compiling with 2.8 in mind>
#endif
#endif

Profit ?

@Zangetsu38
Copy link

Zangetsu38 commented Oct 4, 2016

@mirh I have this error now
Change file detail here https://gist.github.com/Zangetsu38/1c14ba57dcb3cb52ee1cff95a18c34f3

1>------ Début de la génération : Projet : Spu2-X, Configuration : Release Win32 ------
1> PS2E-spu2.cpp
1> AboutBox.cpp
1> SndOut_XAudio2_27.cpp
1> Création de la bibliothèque G:\GIT\pcsx2\bin\plugins\Spu2-X.lib et de l'objet G:\GIT\pcsx2\bin\plugins\Spu2-X.exp
1>spu2replay.obj : error LNK2001: symbole externe non résolu "class SndOutModule * XAudio2_27_Out" (?XAudio2_27_Out@@3PAVSndOutModule@@A)
1>G:\GIT\pcsx2\bin\plugins\Spu2-X.dll : fatal error LNK1120: 1 externes non résolus
========== Génération : 0 a réussi, 1 a échoué, 26 mis à jour, 0 a été ignoré ==========

@mirh
Copy link

mirh commented Oct 4, 2016

Lol what?
Of course stuff between <> is just a comment of mine. It's meaningless for compiler.
@turtleli will know better than me how to complete that.

@Zangetsu38
Copy link

Zangetsu38 commented Oct 4, 2016

@mirh oh ok, but that's not important then ^^ so, but I was well placed otherwise?
oh I see, I waiting @turtleli :)

@mirh
Copy link

mirh commented Oct 4, 2016

Or.. now that I think.. Should it be put the other way?

Like: use updated stuff if you aren't targeting older systems?
Of course for simplicity I guess we could just use the dx sdk presence instead of env variables or something.

#if defined(__has_include)
#if !__has_include("dxsdkver.h")
<warn people they are using that>
<use updated headers>
#else 
<warn user dx sdk was detected and he's compling with also Vista/7 in mind>
#endif
#endif

@jcdenton2k
Copy link

jcdenton2k commented Oct 4, 2016

Just a quick thing. Depending on environmental variables in Windows may be unreliable depending on the OS version and other installed software. When building in a testing environment there may be multiple variations of those environmental variables depending on what order things were installed in.

Certain variables are relatively certain like the main Windows system directory and the TEMP directory. Other variables are not as reliable.

There should be a way to query the OS to determine the installed DirectX SDK version and then have branching decisions made based upon that result.

@mirh
Copy link

mirh commented Oct 5, 2016

I'd use dxsdk env var presence to detect dxsdk installation (easy sherlock), but I really dunno how could you check the presence of an external variables.

And.. Cmon, if you have an environment with another "dxsdkver.h" file (or older dx sdks) you deserve problems.

@mirh
Copy link

mirh commented Nov 2, 2016

I think __has_include directive is what we really would need here.

Up.

@turtleli
Copy link
Member Author

turtleli commented Nov 2, 2016

I don't actually understand what is wanted. I'll just randomly pick stuff

Yes, but, i waiting Spu works with Windows 10 only with Sdk 8.1

I Request just, for spu2 compile, use Only SDK 8.1 in VS 2015 and add file requiere in project in 3dparty minidx9 for compile spu2 for Xaudio 2.7 in Windows 7.

Conflicting statements - adding to 3rdparty is just pretending that we're not using an old SDK.

This emulator only Run Xaudio 2.7, Xaudio 2.8+ requierement Sdk Windows kit 8.1 minimum.

Wrong. Windows 7 uses XAudio 2.7, Windows 8.1 uses XAudio 2.8, Windows 10 uses XAudio 2.9 (it loads the XAudio 2.8 dll, but that loads XAudio 2.9). Otherwise this PR would have been completely pointless.

I'd use dxsdk env var presence to detect dxsdk installation (easy sherlock), but I really dunno how could you check the presence of an external variables.

You're probably looking to use Exists (https://msdn.microsoft.com/en-us/library/7szfhaft.aspx) as a condition in the project file and use it to add a preprocessor definition and then conditionally compile stuff and throw a bunch of ifdefs in the code. Dolphin used to have conditional compilation depending on whether the DX SDK was detected or not so there's probably an example in their history.

I'm not interested in doing this by the way.

@mirh
Copy link

mirh commented Nov 2, 2016

Nice to know.
TL;DR anyway, the point would be that those too lazy to install/care of DX SDK and XAudio 2.7 not having to require it.

@mirh mirh mentioned this pull request Jan 26, 2017
@mirh mirh mentioned this pull request Apr 24, 2017
blueclouds8666 added a commit to blueclouds8666/pcsx2_XP that referenced this pull request Oct 12, 2020
This reverts commit e6bf77d, reversing
changes made to c794085.

# Conflicts:
#	plugins/spu2-x/src/PS2E-spu2.cpp
#	plugins/spu2-x/src/SndOut.cpp
#	plugins/spu2-x/src/SndOut.h
#	plugins/spu2-x/src/Spu2replay.cpp
#	plugins/spu2-x/src/Windows/Config.cpp
#	plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp
#	plugins/spu2-x/src/Windows/SndOut_XAudio2_27.cpp
#	plugins/spu2-x/src/Windows/Spu2-X.vcxproj
blueclouds8666 added a commit to blueclouds8666/pcsx2_XP that referenced this pull request Oct 12, 2020
This reverts commit e6bf77d, reversing
changes made to c794085.

# Conflicts:
#	plugins/spu2-x/src/PS2E-spu2.cpp
#	plugins/spu2-x/src/SndOut.cpp
#	plugins/spu2-x/src/SndOut.h
#	plugins/spu2-x/src/Spu2replay.cpp
#	plugins/spu2-x/src/Windows/Config.cpp
#	plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp
#	plugins/spu2-x/src/Windows/SndOut_XAudio2_27.cpp
#	plugins/spu2-x/src/Windows/Spu2-X.vcxproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants