mirror of https://github.com/PCSX2/pcsx2.git
gsdx-d3d9: Remove d3dx9 stuff and use d3dcompile
Using D3DX9 requires the end user to install the Direct X redist files. Switch to using D3DCompile.
This commit is contained in:
parent
2ec8d88d80
commit
b243e2532b
|
@ -127,11 +127,6 @@ EXPORT_C_(int) GSinit()
|
|||
|
||||
s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
|
||||
if(!GSUtil::CheckDirectX())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!GSDeviceDX::LoadD3DCompiler())
|
||||
{
|
||||
return -1;
|
||||
|
|
|
@ -292,11 +292,11 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CONVERT_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "convert.fx", "vs_main", nullptr, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il);
|
||||
|
||||
for(size_t i = 0; i < countof(m_convert.ps); i++)
|
||||
{
|
||||
CompileShader((const char *)shader.data(), shader.size(), format("ps_main%d", i), NULL, &m_convert.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "convert.fx", format("ps_main%d", i), nullptr, &m_convert.ps[i]);
|
||||
}
|
||||
|
||||
m_convert.dss.DepthEnable = false;
|
||||
|
@ -328,7 +328,7 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
theApp.LoadResource(IDR_MERGE_FX, shader);
|
||||
for(size_t i = 0; i < countof(m_merge.ps); i++)
|
||||
{
|
||||
CompileShader((const char *)shader.data(), shader.size(), format("ps_main%d", i), NULL, &m_merge.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "merge.fx", format("ps_main%d", i), nullptr, &m_merge.ps[i]);
|
||||
}
|
||||
|
||||
m_merge.bs.BlendEnable = true;
|
||||
|
@ -345,7 +345,7 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
theApp.LoadResource(IDR_INTERLACE_FX, shader);
|
||||
for(size_t i = 0; i < countof(m_interlace.ps); i++)
|
||||
{
|
||||
CompileShader((const char *)shader.data(), shader.size(), format("ps_main%d", i), NULL, &m_interlace.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "interlace.fx", format("ps_main%d", i), nullptr, &m_interlace.ps[i]);
|
||||
}
|
||||
|
||||
// Shade Boost
|
||||
|
@ -360,7 +360,7 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
str[1] = format("%d", ShadeBoost_Brightness);
|
||||
str[2] = format("%d", ShadeBoost_Contrast);
|
||||
|
||||
D3DXMACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"SB_SATURATION", str[0].c_str()},
|
||||
{"SB_BRIGHTNESS", str[1].c_str()},
|
||||
|
@ -369,7 +369,7 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
};
|
||||
|
||||
theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "ps_main", macro, &m_shadeboost.ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "shadeboost.fx", "ps_main", macro, &m_shadeboost.ps);
|
||||
|
||||
// create shader layout
|
||||
|
||||
|
@ -952,7 +952,7 @@ void GSDevice9::InitExternalFX()
|
|||
if (fshader.good())
|
||||
{
|
||||
shader << fshader.rdbuf();
|
||||
CompileShader(shader.str().c_str(), shader.str().length(), "ps_main", NULL, &m_shaderfx.ps);
|
||||
CompileShader(shader.str().c_str(), shader.str().length(), shader_name.c_str(), "ps_main", nullptr, &m_shaderfx.ps);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -991,7 +991,7 @@ void GSDevice9::InitFXAA()
|
|||
try {
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_FXAA_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "ps_main", NULL, &m_fxaa.ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "fxaa.fx", "ps_main", nullptr, &m_fxaa.ps);
|
||||
}
|
||||
catch (GSDXRecoverableError) {
|
||||
printf("GSdx: Failed to compile fxaa shader.\n");
|
||||
|
@ -1447,17 +1447,17 @@ void GSDevice9::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice9::CompileShader(const char *source, size_t size, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il)
|
||||
void GSDevice9::CompileShader(const char *source, size_t size, const char *filename, const string& entry, const D3D_SHADER_MACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il)
|
||||
{
|
||||
vector<D3DXMACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
CComPtr<ID3DXBuffer> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DXCompileShader(source, size, &m[0], NULL, entry.c_str(), m_shader.vs.c_str(), 0, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, nullptr, &m[0], nullptr, entry.c_str(), m_shader.vs.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -1483,27 +1483,27 @@ void GSDevice9::CompileShader(const char *source, size_t size, const string& ent
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice9::CompileShader(const char *source, size_t size, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps)
|
||||
void GSDevice9::CompileShader(const char *source, size_t size, const char *filename, const string& entry, const D3D_SHADER_MACRO* macro, IDirect3DPixelShader9** ps)
|
||||
{
|
||||
uint32 flags = 0;
|
||||
|
||||
if(m_shader.level >= D3D_FEATURE_LEVEL_9_3)
|
||||
{
|
||||
flags |= D3DXSHADER_AVOID_FLOW_CONTROL;
|
||||
flags |= D3DCOMPILE_AVOID_FLOW_CONTROL;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= D3DXSHADER_SKIPVALIDATION;
|
||||
flags |= D3DCOMPILE_SKIP_VALIDATION;
|
||||
}
|
||||
|
||||
vector<D3DXMACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
CComPtr<ID3DXBuffer> shader, error;
|
||||
hr = D3DXCompileShader(source, size, &m[0], NULL, entry.c_str(), m_shader.ps.c_str(), flags, &shader, &error, NULL);
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
hr = s_pD3DCompile(source, size, filename, &m[0], nullptr, entry.c_str(), m_shader.ps.c_str(), flags, 0, &shader, &error);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
|
|
|
@ -237,8 +237,8 @@ public:
|
|||
IDirect3DDevice9* operator->() {return m_dev;}
|
||||
operator IDirect3DDevice9*() {return m_dev;}
|
||||
|
||||
void CompileShader(const char *source, size_t size, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
|
||||
void CompileShader(const char *source, size_t size, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps);
|
||||
void CompileShader(const char *source, size_t size, const char *filename, const string& entry, const D3D_SHADER_MACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
|
||||
void CompileShader(const char *source, size_t size, const char *filename, const string& entry, const D3D_SHADER_MACRO* macro, IDirect3DPixelShader9** ps);
|
||||
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel) {}
|
||||
|
|
|
@ -75,7 +75,7 @@ void GSDevice9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
str[3] = format("%d", sel.logz);
|
||||
str[4] = format("%d", sel.rtcopy);
|
||||
|
||||
D3DXMACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"VS_BPPZ", str[0].c_str()},
|
||||
{"VS_TME", str[1].c_str()},
|
||||
|
@ -98,7 +98,7 @@ void GSDevice9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_TFX_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
|
||||
m_vs[sel] = vs;
|
||||
|
||||
|
@ -157,7 +157,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
|
|||
str[15] = format("%d", sel.tcoffsethack);
|
||||
str[16] = format("%d", sel.point_sampler);
|
||||
|
||||
D3DXMACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"PS_FST", str[0].c_str()},
|
||||
{"PS_WMS", str[1].c_str()},
|
||||
|
@ -183,7 +183,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_TFX_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "ps_main", macro, &ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", "ps_main", macro, &ps);
|
||||
|
||||
m_ps[sel] = ps;
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "xbyak/xbyak_util.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "GSDeviceDX.h"
|
||||
#include <VersionHelpers.h>
|
||||
#include "svnrev.h"
|
||||
#else
|
||||
#define SVN_REV 0
|
||||
|
@ -324,43 +326,22 @@ string GSUtil::GetDeviceUniqueName(cl::Device& device)
|
|||
|
||||
bool GSUtil::CheckDirectX()
|
||||
{
|
||||
OSVERSIONINFOEX version;
|
||||
memset(&version, 0, sizeof(version));
|
||||
version.dwOSVersionInfoSize = sizeof(version);
|
||||
|
||||
if(GetVersionEx((OSVERSIONINFO*)&version))
|
||||
if (GSDeviceDX::LoadD3DCompiler())
|
||||
{
|
||||
printf("Windows %d.%d.%d", version.dwMajorVersion, version.dwMinorVersion, version.dwBuildNumber);
|
||||
GSDeviceDX::FreeD3DCompiler();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(version.wServicePackMajor > 0)
|
||||
// User's system is likely broken if it fails and is Windows 8.1 or greater.
|
||||
if (!IsWindows8Point1OrGreater())
|
||||
{
|
||||
printf("Cannot find d3dcompiler_43.dll\n");
|
||||
if (MessageBox(nullptr, TEXT("You need to update some DirectX libraries, would you like to do it now?"), TEXT("GSdx"), MB_YESNO) == IDYES)
|
||||
{
|
||||
printf(" (%s %d.%d)", version.szCSDVersion, version.wServicePackMajor, version.wServicePackMinor);
|
||||
ShellExecute(nullptr, TEXT("open"), TEXT("https://www.microsoft.com/en-us/download/details.aspx?id=8109"), nullptr, nullptr, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
string d3dx9_dll = format("d3dx9_%d.dll", D3DX_SDK_VERSION);
|
||||
|
||||
if(HINSTANCE hDll = LoadLibrary(d3dx9_dll.c_str()))
|
||||
{
|
||||
FreeLibrary(hDll);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Cannot find %s\n", d3dx9_dll.c_str());
|
||||
|
||||
if(MessageBox(NULL, "You need to update some directx libraries, would you like to do it now?", "GSdx", MB_YESNO) == IDYES)
|
||||
{
|
||||
const char* url = "https://www.microsoft.com/en-us/download/details.aspx?id=8109";
|
||||
|
||||
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <d3dcompiler.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include <comutil.h>
|
||||
#include <atlcomcli.h>
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>d3d11.lib;d3d10_1.lib;d3d9.lib;d3dx9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;opengl32.lib;opencl.lib;comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>d3d9.dll;d3dx9_43.dll;d3d11.dll;dxgi.dll;opengl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>d3d11.lib;d3d10_1.lib;d3d9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;opengl32.lib;opencl.lib;comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>d3d9.dll;d3d11.dll;dxgi.dll;opengl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
|
|
Loading…
Reference in New Issue