mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #1238 from turtleli/gsdx-use-windows-sdk
gsdx: Remove DirectX SDK dependency
This commit is contained in:
commit
16ef7ca5fd
|
@ -127,11 +127,10 @@ EXPORT_C_(int) GSinit()
|
|||
|
||||
s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
|
||||
if(!GSUtil::CheckDirectX())
|
||||
if (!GSDeviceDX::LoadD3DCompiler())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -156,6 +155,8 @@ EXPORT_C GSshutdown()
|
|||
s_hr = E_FAIL;
|
||||
}
|
||||
|
||||
GSDeviceDX::FreeD3DCompiler();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -175,11 +175,11 @@ bool GSDevice11::Create(GSWnd* wnd)
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CONVERT_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "convert.fx", "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "convert.fx", nullptr, "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(), "convert.fx", format("ps_main%d", i).c_str(), NULL, &m_convert.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "convert.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_convert.ps[i]);
|
||||
}
|
||||
|
||||
memset(&dsd, 0, sizeof(dsd));
|
||||
|
@ -208,7 +208,7 @@ bool GSDevice11::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(), "merge.fx", format("ps_main%d", i).c_str(), NULL, &m_merge.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "merge.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_merge.ps[i]);
|
||||
}
|
||||
|
||||
memset(&bsd, 0, sizeof(bsd));
|
||||
|
@ -237,7 +237,7 @@ bool GSDevice11::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(), "interlace.fx", format("ps_main%d", i).c_str(), NULL, &m_interlace.ps[i]);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "interlace.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_interlace.ps[i]);
|
||||
}
|
||||
|
||||
// Shade Boost
|
||||
|
@ -252,7 +252,7 @@ bool GSDevice11::Create(GSWnd* wnd)
|
|||
str[1] = format("%d", ShadeBoost_Brightness);
|
||||
str[2] = format("%d", ShadeBoost_Contrast);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"SB_SATURATION", str[0].c_str()},
|
||||
{"SB_BRIGHTNESS", str[1].c_str()},
|
||||
|
@ -269,7 +269,7 @@ bool GSDevice11::Create(GSWnd* wnd)
|
|||
hr = m_dev->CreateBuffer(&bd, NULL, &m_shadeboost.cb);
|
||||
|
||||
theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "shadeboost.fx", "ps_main", macro, &m_shadeboost.ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "shadeboost.fx", nullptr, "ps_main", macro, &m_shadeboost.ps);
|
||||
|
||||
// External fx shader
|
||||
|
||||
|
@ -768,7 +768,7 @@ void GSDevice11::InitExternalFX()
|
|||
if (fshader.good())
|
||||
{
|
||||
shader << fshader.rdbuf();
|
||||
CompileShader(shader.str().c_str(), shader.str().length(), shader_name.c_str(), "ps_main", NULL, &m_shaderfx.ps);
|
||||
CompileShader(shader.str().c_str(), shader.str().length(), shader_name.c_str(), D3D_COMPILE_STANDARD_FILE_INCLUDE, "ps_main", nullptr, &m_shaderfx.ps);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -811,7 +811,7 @@ void GSDevice11::InitFXAA()
|
|||
try {
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_FXAA_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "fxaa.fx", "ps_main", NULL, &m_fxaa.ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "fxaa.fx", nullptr, "ps_main", nullptr, &m_fxaa.ps);
|
||||
}
|
||||
catch (GSDXRecoverableError) {
|
||||
printf("GSdx: failed to compile fxaa shader.\n");
|
||||
|
@ -1324,17 +1324,17 @@ void GSDevice11::OMSetRenderTargets(const GSVector2i& rtsize, int count, ID3D11U
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11VertexShader** vs, D3D11_INPUT_ELEMENT_DESC* layout, int count, ID3D11InputLayout** il)
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11VertexShader** vs, D3D11_INPUT_ELEMENT_DESC* layout, int count, ID3D11InputLayout** il)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
vector<D3D11_SHADER_MACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
CComPtr<ID3D11Blob> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DX11CompileFromMemory(source, size, fn, &m[0], NULL, entry, m_shader.vs.c_str(), 0, 0, NULL, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, fn, &m[0], s_old_d3d_compiler_dll? nullptr : include, entry, m_shader.vs.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(error)
|
||||
{
|
||||
|
@ -1361,17 +1361,17 @@ void GSDevice11::CompileShader(const char* source, size_t size, const char* fn,
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11GeometryShader** gs)
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11GeometryShader** gs)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
vector<D3D11_SHADER_MACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
CComPtr<ID3D11Blob> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DX11CompileFromMemory(source, size, fn, &m[0], NULL, entry, m_shader.gs.c_str(), 0, 0, NULL, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, fn, &m[0], s_old_d3d_compiler_dll ? nullptr : include, entry, m_shader.gs.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(error)
|
||||
{
|
||||
|
@ -1391,17 +1391,17 @@ void GSDevice11::CompileShader(const char* source, size_t size, const char* fn,
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11GeometryShader** gs, D3D11_SO_DECLARATION_ENTRY* layout, int count)
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11GeometryShader** gs, D3D11_SO_DECLARATION_ENTRY* layout, int count)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
vector<D3D11_SHADER_MACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
CComPtr<ID3D11Blob> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DX11CompileFromMemory(source, size, fn, &m[0], NULL, entry, m_shader.gs.c_str(), 0, 0, NULL, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, fn, &m[0], s_old_d3d_compiler_dll ? nullptr : include, entry, m_shader.gs.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(error)
|
||||
{
|
||||
|
@ -1421,17 +1421,17 @@ void GSDevice11::CompileShader(const char* source, size_t size, const char* fn,
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11PixelShader** ps)
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11PixelShader** ps)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
vector<D3D11_SHADER_MACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
CComPtr<ID3D11Blob> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DX11CompileFromMemory(source, size, fn, &m[0], NULL, entry, m_shader.ps.c_str(), 0, 0, NULL, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, fn, &m[0], s_old_d3d_compiler_dll ? nullptr : include, entry, m_shader.ps.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(error)
|
||||
{
|
||||
|
@ -1451,17 +1451,17 @@ void GSDevice11::CompileShader(const char* source, size_t size, const char* fn,
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char *fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11ComputeShader** cs)
|
||||
void GSDevice11::CompileShader(const char* source, size_t size, const char *fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11ComputeShader** cs)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
vector<D3D11_SHADER_MACRO> m;
|
||||
vector<D3D_SHADER_MACRO> m;
|
||||
|
||||
PrepareShaderMacro(m, macro);
|
||||
|
||||
CComPtr<ID3D11Blob> shader, error;
|
||||
CComPtr<ID3DBlob> shader, error;
|
||||
|
||||
hr = D3DX11CompileFromMemory(source, size, fn, &m[0], NULL, entry, m_shader.cs.c_str(), 0, 0, NULL, &shader, &error, NULL);
|
||||
hr = s_pD3DCompile(source, size, fn, &m[0], s_old_d3d_compiler_dll ? nullptr : include, entry, m_shader.cs.c_str(), 0, 0, &shader, &error);
|
||||
|
||||
if(error)
|
||||
{
|
||||
|
@ -1480,4 +1480,3 @@ void GSDevice11::CompileShader(const char* source, size_t size, const char *fn,
|
|||
throw GSDXRecoverableError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -227,10 +227,10 @@ public:
|
|||
operator ID3D11Device*() {return m_dev;}
|
||||
operator ID3D11DeviceContext*() {return m_ctx;}
|
||||
|
||||
void CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11VertexShader** vs, D3D11_INPUT_ELEMENT_DESC* layout, int count, ID3D11InputLayout** il);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11GeometryShader** gs);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11GeometryShader** gs, D3D11_SO_DECLARATION_ENTRY* layout, int count);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11PixelShader** ps);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11ComputeShader** cs);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11VertexShader** vs, D3D11_INPUT_ELEMENT_DESC* layout, int count, ID3D11InputLayout** il);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11GeometryShader** gs);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11GeometryShader** gs, D3D11_SO_DECLARATION_ENTRY* layout, int count);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11PixelShader** ps);
|
||||
void CompileShader(const char* source, size_t size, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11ComputeShader** cs);
|
||||
};
|
||||
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
#include "stdafx.h"
|
||||
#include "GSdx.h"
|
||||
#include "GSDeviceDX.h"
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
HMODULE GSDeviceDX::s_d3d_compiler_dll = nullptr;
|
||||
decltype(&D3DCompile) GSDeviceDX::s_pD3DCompile = nullptr;
|
||||
bool GSDeviceDX::s_old_d3d_compiler_dll;
|
||||
|
||||
GSDeviceDX::GSDeviceDX()
|
||||
{
|
||||
|
@ -35,6 +40,48 @@ GSDeviceDX::~GSDeviceDX()
|
|||
{
|
||||
}
|
||||
|
||||
bool GSDeviceDX::LoadD3DCompiler()
|
||||
{
|
||||
// Windows 8.1 and later come with the latest d3dcompiler_47.dll, but
|
||||
// Windows 7 devs might also have the dll available for use (which will
|
||||
// have to be placed in the application directory)
|
||||
s_d3d_compiler_dll = LoadLibraryEx(D3DCOMPILER_DLL, nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
|
||||
// Windows Vista and 7 can use the older version. If the previous LoadLibrary
|
||||
// call fails on Windows 8.1 and later, then the user's system is likely
|
||||
// broken.
|
||||
if (s_d3d_compiler_dll)
|
||||
{
|
||||
s_old_d3d_compiler_dll = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsWindows8Point1OrGreater())
|
||||
s_d3d_compiler_dll = LoadLibraryEx("D3DCompiler_43.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
|
||||
if (s_d3d_compiler_dll == nullptr)
|
||||
return false;
|
||||
|
||||
s_old_d3d_compiler_dll = true;
|
||||
}
|
||||
|
||||
s_pD3DCompile = reinterpret_cast<decltype(&D3DCompile)>(GetProcAddress(s_d3d_compiler_dll, "D3DCompile"));
|
||||
if (s_pD3DCompile)
|
||||
return true;
|
||||
|
||||
FreeLibrary(s_d3d_compiler_dll);
|
||||
s_d3d_compiler_dll = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GSDeviceDX::FreeD3DCompiler()
|
||||
{
|
||||
s_pD3DCompile = nullptr;
|
||||
if (s_d3d_compiler_dll)
|
||||
FreeLibrary(s_d3d_compiler_dll);
|
||||
s_d3d_compiler_dll = nullptr;
|
||||
}
|
||||
|
||||
GSTexture* GSDeviceDX::FetchSurface(int type, int w, int h, bool msaa, int format)
|
||||
{
|
||||
if(m_msaa < 2)
|
||||
|
|
|
@ -278,6 +278,12 @@ protected:
|
|||
uint32 m_msaa;
|
||||
DXGI_SAMPLE_DESC m_msaa_desc;
|
||||
|
||||
static HMODULE s_d3d_compiler_dll;
|
||||
static decltype(&D3DCompile) s_pD3DCompile;
|
||||
// Older version doesn't support D3D_COMPILE_STANDARD_FILE_INCLUDE, which
|
||||
// could be useful for external shaders.
|
||||
static bool s_old_d3d_compiler_dll;
|
||||
|
||||
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
|
||||
|
||||
public:
|
||||
|
@ -297,6 +303,9 @@ public:
|
|||
virtual bool HasStencil() = 0;
|
||||
virtual bool HasDepth32() = 0;
|
||||
|
||||
static bool LoadD3DCompiler();
|
||||
static void FreeD3DCompiler();
|
||||
|
||||
template<class T> void PrepareShaderMacro(vector<T>& dst, const T* src)
|
||||
{
|
||||
dst.clear();
|
||||
|
|
|
@ -288,7 +288,7 @@ bool GSRendererCS::CreateDevice(GSDevice* dev_unk)
|
|||
|
||||
// PS
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -297,7 +297,7 @@ bool GSRendererCS::CreateDevice(GSDevice* dev_unk)
|
|||
{
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CS_FX, shader);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", "ps_main0", macro, &m_ps0);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", nullptr, "ps_main0", macro, &m_ps0);
|
||||
}
|
||||
catch (GSDXRecoverableError)
|
||||
{
|
||||
|
@ -514,7 +514,7 @@ void GSRendererCS::Draw()
|
|||
str[0] = format("%d", vs_sel.tme);
|
||||
str[1] = format("%d", vs_sel.fst);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"VS_TME", str[0].c_str()},
|
||||
{"VS_FST", str[1].c_str()},
|
||||
|
@ -534,7 +534,7 @@ void GSRendererCS::Draw()
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CS_FX, shader);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", nullptr, "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
|
||||
m_vs[vs_sel] = vs;
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ void GSRendererCS::Draw()
|
|||
str[0] = format("%d", gs_sel.iip);
|
||||
str[1] = format("%d", j == 0 ? gs_sel.prim : GS_SPRITE_CLASS);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"GS_IIP", str[0].c_str()},
|
||||
{"GS_PRIM", str[1].c_str()},
|
||||
|
@ -580,7 +580,7 @@ void GSRendererCS::Draw()
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CS_FX, shader);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", "gs_main", macro, &gs[j]);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", nullptr, "gs_main", macro, &gs[j]);
|
||||
|
||||
m_gs[gs_sel] = gs[j];
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ void GSRendererCS::Draw()
|
|||
str[1] = format("%d", context->FRAME.PSM);
|
||||
str[2] = format("%d", context->ZBUF.PSM);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"PS_BATCH_SIZE", str[0].c_str()},
|
||||
{"PS_FPSM", str[1].c_str()},
|
||||
|
@ -621,7 +621,7 @@ void GSRendererCS::Draw()
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_CS_FX, shader);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", "ps_main1", macro, &ps[1]);
|
||||
dev->CompileShader((const char *)shader.data(), shader.size(), "cs.fx", nullptr, "ps_main1", macro, &ps[1]);
|
||||
|
||||
m_ps1[ps_sel] = ps[1];
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
str[2] = format("%d", sel.fst);
|
||||
str[3] = format("%d", sel.rtcopy);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"VS_BPPZ", str[0].c_str()},
|
||||
{"VS_TME", str[1].c_str()},
|
||||
|
@ -120,7 +120,7 @@ void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_TFX_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", nullptr, "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
|
||||
|
||||
m_vs[sel] = vs;
|
||||
|
||||
|
@ -158,7 +158,7 @@ void GSDevice11::SetupGS(GSSelector sel)
|
|||
str[0] = format("%d", sel.iip);
|
||||
str[1] = format("%d", sel.prim);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"GS_IIP", str[0].c_str()},
|
||||
{"GS_PRIM", str[1].c_str()},
|
||||
|
@ -167,7 +167,7 @@ void GSDevice11::SetupGS(GSSelector sel)
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_TFX_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", "gs_main", macro, &gs);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", nullptr, "gs_main", macro, &gs);
|
||||
|
||||
m_gs[sel] = gs;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
|
|||
str[18] = format("%d", sel.shuffle);
|
||||
str[19] = format("%d", sel.read_ba);
|
||||
|
||||
D3D11_SHADER_MACRO macro[] =
|
||||
D3D_SHADER_MACRO macro[] =
|
||||
{
|
||||
{"PS_FST", str[0].c_str()},
|
||||
{"PS_WMS", str[1].c_str()},
|
||||
|
@ -234,7 +234,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
|
|||
|
||||
vector<unsigned char> shader;
|
||||
theApp.LoadResource(IDR_TFX_FX, shader);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", "ps_main", macro, &ps);
|
||||
CompileShader((const char *)shader.data(), shader.size(), "tfx.fx", nullptr, "ps_main", macro, &ps);
|
||||
|
||||
m_ps[sel] = ps;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
|
|
@ -37,16 +37,13 @@
|
|||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <shellapi.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3dx11.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include <comutil.h>
|
||||
#include <atlcomcli.h>
|
||||
|
||||
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA)
|
||||
#define D3D11_SHADER_MACRO D3D10_SHADER_MACRO
|
||||
#define ID3D11Blob ID3D10Blob
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4456;4458;4996;4995;4324;4100;4101;4201;4556;4127;4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(DXSDK_DIR)include;$(VTUNE_AMPLIFIER_XE_2015_DIR)include;$(SolutionDir)3rdparty;$(SolutionDir)3rdparty\libpng;$(SolutionDir)3rdparty\opencl;$(SolutionDir)3rdparty\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(VTUNE_AMPLIFIER_XE_2015_DIR)include;$(SolutionDir)3rdparty;$(SolutionDir)3rdparty\libpng;$(SolutionDir)3rdparty\opencl;$(SolutionDir)3rdparty\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>d3d11.lib;d3dx11.lib;d3d10_1.lib;d3dx10.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;d3dx11_43.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>
|
||||
|
@ -28,4 +28,4 @@
|
|||
<Command>"$(SvnCommonDir)\vsprops\preBuild.cmd" "$(ProjectRootDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;$(ProjectDir)vtune\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vtune\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;$(ProjectDir)vtune\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vtune\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile />
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue