Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Use v141 platform toolset.
Browse files Browse the repository at this point in the history
- Use D3D9 headers from Windows SDK.
- Consistently load d3d9.dll with LoadLibrary().
- Switch to newer d3dcompiler_47.dll.
- Include legacy d3dx9 headers only where necessary.

This change breaks compatibility with Windows XP.
  • Loading branch information
kasper93 committed Jul 29, 2017
1 parent c04cff8 commit 3e5afbc
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 87 deletions.
6 changes: 3 additions & 3 deletions build.bat
Expand Up @@ -333,8 +333,8 @@ EXIT /B
:SubCopyDXDll
IF /I "%BUILDCFG%" == "Debug" EXIT /B
PUSHD "%BIN_DIR%"
EXPAND "%DXSDK_DIR%\Redist\Jun2010_D3DCompiler_43_%~1.cab" -F:D3DCompiler_43.dll "mpc-hc_%~1%~2"
IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Problem when extracting %DXSDK_DIR%\Redist\Jun2010_D3DCompiler_43_%~1.cab" & EXIT /B
COPY /Y /V "%WindowsSdkDir%\Redist\D3D\%~1\d3dcompiler_47.dll" "mpc-hc_%~1%~2" >NUL
IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Problem when copying %WindowsSdkDir%\Redist\D3D\%~1\d3dcompiler_47.dll" & EXIT /B
EXPAND "%DXSDK_DIR%\Redist\Jun2010_d3dx9_43_%~1.cab" -F:d3dx9_43.dll "mpc-hc_%~1%~2"
IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Problem when extracting Jun2010_d3dx9_43_%~1.cab" & EXIT /B
POPD
Expand Down Expand Up @@ -458,7 +458,7 @@ IF /I "%NAME%" == "MPC-HC" (
COPY /Y /V "%VS_OUT_DIR%\%LAVFILTERSDIR%\*.dll" "%PCKG_NAME%\%LAVFILTERSDIR%" >NUL
COPY /Y /V "%VS_OUT_DIR%\%LAVFILTERSDIR%\*.manifest" "%PCKG_NAME%\%LAVFILTERSDIR%" >NUL
)
COPY /Y /V "%VS_OUT_DIR%\D3DCompiler_43.dll" "%PCKG_NAME%\D3DCompiler_43.dll" >NUL
COPY /Y /V "%VS_OUT_DIR%\d3dcompiler_47.dll" "%PCKG_NAME%\d3dcompiler_47.dll" >NUL
COPY /Y /V "%VS_OUT_DIR%\d3dx9_43.dll" "%PCKG_NAME%\d3dx9_43.dll" >NUL
IF NOT EXIST "%PCKG_NAME%\Shaders" MD "%PCKG_NAME%\Shaders"
COPY /Y /V "..\src\mpc-hc\res\shaders\external\*.hlsl" "%PCKG_NAME%\Shaders" >NUL
Expand Down
6 changes: 4 additions & 2 deletions src/DSUtil/DSUtil.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2016 see Authors.txt
* (C) 2006-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -27,7 +27,9 @@
#include "DSUtil.h"
#include "Mpeg2Def.h"
#include <emmintrin.h>
#include <d3d9types.h>
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include "NullRenderers.h"

#include <initguid.h>
Expand Down
7 changes: 1 addition & 6 deletions src/DSUtil/DSUtil.vcxproj
Expand Up @@ -41,14 +41,9 @@
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\include;..\thirdparty;$(DXSDK_DIR)Include;..\thirdparty\VirtualDub\h;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\thirdparty;..\thirdparty\VirtualDub\h;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Lib>
<AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='Win32'">$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='x64'">$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AudioTools.cpp" />
Expand Down
14 changes: 10 additions & 4 deletions src/DSUtil/NullRenderers.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2016 see Authors.txt
* (C) 2006-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -22,12 +22,15 @@
#include "stdafx.h"
#include "NullRenderers.h"
#include "moreuuids.h"
#include "WinapiFunc.h"

#define USE_DXVA

#ifdef USE_DXVA

#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <dxva.h>
#include <dxva2api.h> // DXVA2
#include <evr.h>
Expand Down Expand Up @@ -179,9 +182,12 @@ CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer* pRenderer,

void CNullVideoRendererInputPin::CreateSurface()
{
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
const WinapiFunc<decltype(Direct3DCreate9)> fnDirect3DCreate9 = { _T("d3d9.dll"), "Direct3DCreate9" };
if (fnDirect3DCreate9) {
m_pD3D.Attach(fnDirect3DCreate9(D3D_SDK_VERSION));
if (!m_pD3D) {
m_pD3D.Attach(fnDirect3DCreate9(D3D9b_SDK_VERSION));
}
}

m_hWnd = nullptr; // TODO : put true window
Expand Down
4 changes: 2 additions & 2 deletions src/DSUtil/WinAPIUtils.cpp
@@ -1,5 +1,5 @@
/*
* (C) 2011-2015 see Authors.txt
* (C) 2011-2015, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -19,7 +19,7 @@
*/

#include "stdafx.h"
#include <d3dx9.h>
#include <d3d9.h>
#include <Shlobj.h>
#include "WinAPIUtils.h"
#include "SysVersion.h"
Expand Down
2 changes: 1 addition & 1 deletion src/SubPic/SubPic.vcxproj
Expand Up @@ -41,7 +41,7 @@
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\include;..\thirdparty;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/SubPic/SubPicAllocatorPresenterImpl.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2016 see Authors.txt
* (C) 2006-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand Down Expand Up @@ -28,6 +28,8 @@
#include "XySubPicQueueImpl.h"
#include "XySubPicProvider.h"
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <evr.h>
#include <dxva2api.h>

Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Expand Up @@ -30,7 +30,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>_WINDOWS;WINDOWS;WINVER=0x06010000;_WIN32_WINNT=0x06010000;_WIN32_IE=0x0800;PSAPI_VERSION=1;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINDOWS;WINDOWS;WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_IE=0x0900;PSAPI_VERSION=1;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(NOMINMAX)'!='False'">NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)'=='Debug Filter' Or '$(Configuration)'=='Release Filter'">STANDALONE_FILTER;_USRDLL;_AFX_NO_MFC_CONTROLS_IN_DIALOGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
3 changes: 1 addition & 2 deletions src/filters/renderer/VideoRenderers/AllocatorCommon.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2013 see Authors.txt
* (C) 2006-2013, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -22,7 +22,6 @@
#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include <vmr9.h>
#include "../../../SubPic/ISubPic.h"
#include "PixelShaderCompiler.h"
Expand Down
5 changes: 4 additions & 1 deletion src/filters/renderer/VideoRenderers/D3DFont.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2014 see Authors.txt
* (C) 2006-2014, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -23,6 +23,9 @@
#include <stdio.h>
#include <tchar.h>
#include <algorithm>
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <d3dx9.h>
#include "D3DFont.h"
#include "../../../DSUtil/DSUtil.h"
Expand Down
13 changes: 8 additions & 5 deletions src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2016 see Authors.txt
* (C) 2006-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand Down Expand Up @@ -69,6 +69,7 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
, m_pDwmIsCompositionEnabled(nullptr)
, m_pDwmEnableComposition(nullptr)
, m_pDirect3DCreate9Ex(nullptr)
, m_pDirect3DCreate9(nullptr)
, m_pDirectDraw(nullptr)
, m_LastAdapterCheck(0)
, m_nTearingPos(0)
Expand Down Expand Up @@ -181,11 +182,12 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
}

m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
if (m_hD3D9) {
(FARPROC&)m_pDirect3DCreate9 = GetProcAddress(m_hD3D9, "Direct3DCreate9");
#ifndef DISABLE_USING_D3D9EX
(FARPROC&)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
}
#endif
}

if (m_pDirect3DCreate9Ex) {
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
Expand All @@ -194,9 +196,10 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
}
}
if (!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
ASSERT(m_pDirect3DCreate9);
m_pD3D.Attach(m_pDirect3DCreate9(D3D_SDK_VERSION));
if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
m_pD3D.Attach(m_pDirect3DCreate9(D3D9b_SDK_VERSION));
}
} else {
m_pD3D = m_pD3DEx;
Expand Down
3 changes: 2 additions & 1 deletion src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2015 see Authors.txt
* (C) 2006-2015, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand Down Expand Up @@ -62,6 +62,7 @@ namespace DSObjects
HRESULT(__stdcall* m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
HRESULT(__stdcall* m_pDwmEnableComposition)(UINT uCompositionAction);
HRESULT(__stdcall* m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
decltype(&Direct3DCreate9) m_pDirect3DCreate9;

CCritSec m_RenderLock;
CComPtr<IDirectDraw> m_pDirectDraw;
Expand Down
4 changes: 3 additions & 1 deletion src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
@@ -1,5 +1,5 @@
/*
* (C) 2006-2013, 2016 see Authors.txt
* (C) 2006-2013, 2016-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -23,6 +23,8 @@
#include "AllocatorCommon.h"
#include "RenderersSettings.h"
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <d3dx9.h>
#include "../SubPic/SubPicAllocatorPresenterImpl.h"

Expand Down
6 changes: 4 additions & 2 deletions src/filters/renderer/VideoRenderers/IPinHook.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2015 see Authors.txt
* (C) 2006-2015, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -21,7 +21,9 @@

#include "stdafx.h"

#include <d3dx9.h>
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <dxva.h>
#include <dxva2api.h>
#include "moreuuids.h"
Expand Down
5 changes: 4 additions & 1 deletion src/filters/renderer/VideoRenderers/RenderersSettings.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2016 see Authors.txt
* (C) 2006-2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -24,6 +24,9 @@
#include "../../../mpc-hc/AppSettings.h"
#include "../../../mpc-hc/mplayerc.h"
#include "../../../DSUtil/SysVersion.h"
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <d3dx9.h>

void CRenderersSettings::UpdateData(bool fSave)
Expand Down
13 changes: 10 additions & 3 deletions src/filters/renderer/VideoRenderers/SyncRenderer.cpp
Expand Up @@ -29,6 +29,8 @@
#include <strsafe.h> // Required in CGenlock
#include <videoacc.h>
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <d3dx9.h>
#include <vmr9.h>
#include <evr.h>
Expand Down Expand Up @@ -70,6 +72,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
, m_pDwmEnableComposition(nullptr)
, m_hD3D9(nullptr)
, m_pDirect3DCreate9Ex(nullptr)
, m_pDirect3DCreate9(nullptr)
, m_pOuterEVR(nullptr)
, m_SurfaceType(D3DFMT_UNKNOWN)
, m_BackbufferType(D3DFMT_UNKNOWN)
Expand Down Expand Up @@ -170,10 +173,13 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
}

m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
if (m_hD3D9) {
(FARPROC&)m_pDirect3DCreate9 = GetProcAddress(m_hD3D9, "Direct3DCreate9");
#ifndef DISABLE_USING_D3D9EX
(FARPROC&)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
#endif
}
#ifndef DISABLE_USING_D3D9EX
if (m_pDirect3DCreate9Ex) {
TRACE(_T("m_pDirect3DCreate9Ex\n"));
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
Expand All @@ -184,9 +190,10 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
#endif

if (!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
ASSERT(m_pDirect3DCreate9);
m_pD3D.Attach(m_pDirect3DCreate9(D3D_SDK_VERSION));
if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
m_pD3D.Attach(m_pDirect3DCreate9(D3D9b_SDK_VERSION));
}
if (m_pD3D) {
TRACE(_T("m_pDirect3DCreate9\n"));
Expand Down
9 changes: 7 additions & 2 deletions src/filters/renderer/VideoRenderers/SyncRenderer.h
@@ -1,5 +1,5 @@
/*
* (C) 2010-2015 see Authors.txt
* (C) 2010-2015, 2017 see Authors.txt
*
* This file is part of MPC-HC.
*
Expand All @@ -24,8 +24,12 @@
#include "RenderersSettings.h"
#include "SyncAllocatorPresenter.h"
#include "AllocatorCommon.h"
#include <dxva2api.h>
#include "../../../DSUtil/WinapiFunc.h"
#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <dxva2api.h>
#include <d3dx9.h>

#define VMRBITMAP_UPDATE 0x80000000
#define MAX_PICTURE_SLOTS (60 + 2) // Last 2 for pixels shader!
Expand Down Expand Up @@ -115,6 +119,7 @@ namespace GothSync
HRESULT(__stdcall* m_pDwmEnableComposition)(UINT uCompositionAction);
HMODULE m_hD3D9;
HRESULT(__stdcall* m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
decltype(&Direct3DCreate9) m_pDirect3DCreate9;

CCritSec m_allocatorLock;
CComPtr<IDirect3D9Ex> m_pD3DEx;
Expand Down
10 changes: 4 additions & 6 deletions src/filters/renderer/VideoRenderers/VideoRenderers.vcxproj
Expand Up @@ -39,16 +39,14 @@
<Import Project="..\..\..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;NO_VERSION_REV_NEEDED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Lib>
<AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='Win32'">$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='x64'">$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AllocatorCommon.cpp" />
Expand Down
2 changes: 2 additions & 0 deletions src/filters/transform/VSFilter/DirectVobSubFilter.cpp
Expand Up @@ -35,6 +35,8 @@
#include "../../../Subtitles/PGSSub.h"

#include <d3d9.h>
#include <d3d10.h>
#include <dxgi.h>
#include <dxva2api.h>
#include "moreuuids.h"

Expand Down

0 comments on commit 3e5afbc

Please sign in to comment.