Revert "D3D: Reintroduce depencency on D3DX11 because it's the most straightforward way to bring back some broken features."
This reverts commit a83c239765
.
This commit is contained in:
parent
f96e9e1ae4
commit
abc3bddb54
|
@ -17,13 +17,6 @@ D3DREFLECT PD3DReflect = NULL;
|
||||||
pD3DCompile PD3DCompile = NULL;
|
pD3DCompile PD3DCompile = NULL;
|
||||||
int d3dcompiler_dll_ref = 0;
|
int d3dcompiler_dll_ref = 0;
|
||||||
|
|
||||||
HINSTANCE hD3DXDll = NULL;
|
|
||||||
D3DX11COMPILEFROMMEMORYTYPE PD3DX11CompileFromMemory = NULL;
|
|
||||||
D3DX11FILTERTEXTURETYPE PD3DX11FilterTexture = NULL;
|
|
||||||
D3DX11SAVETEXTURETOFILEATYPE PD3DX11SaveTextureToFileA = NULL;
|
|
||||||
D3DX11SAVETEXTURETOFILEWTYPE PD3DX11SaveTextureToFileW = NULL;
|
|
||||||
int d3dx_dll_ref = 0;
|
|
||||||
|
|
||||||
CREATEDXGIFACTORY PCreateDXGIFactory = NULL;
|
CREATEDXGIFACTORY PCreateDXGIFactory = NULL;
|
||||||
HINSTANCE hDXGIDll = NULL;
|
HINSTANCE hDXGIDll = NULL;
|
||||||
int dxgi_dll_ref = 0;
|
int dxgi_dll_ref = 0;
|
||||||
|
@ -98,44 +91,6 @@ HRESULT LoadD3D()
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT LoadD3DX()
|
|
||||||
{
|
|
||||||
if (d3dx_dll_ref++ > 0) return S_OK;
|
|
||||||
if (hD3DXDll) return S_OK;
|
|
||||||
|
|
||||||
// try to load D3DX11 first to check whether we have proper runtime support
|
|
||||||
// try to use the dll the backend was compiled against first - don't bother about debug runtimes
|
|
||||||
hD3DXDll = LoadLibraryA(D3DX11_DLL_A);
|
|
||||||
if (!hD3DXDll)
|
|
||||||
{
|
|
||||||
// if that fails, use the dll which should be available in every SDK which officially supports DX11.
|
|
||||||
hD3DXDll = LoadLibraryA("d3dx11_42.dll");
|
|
||||||
if (!hD3DXDll)
|
|
||||||
{
|
|
||||||
MessageBoxA(NULL, "Failed to load d3dx11_42.dll, update your DX11 runtime, please", "Critical error", MB_OK | MB_ICONERROR);
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NOTICE_LOG(VIDEO, "Successfully loaded d3dx11_42.dll. If you're having trouble, try updating your DX runtime first.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PD3DX11CompileFromMemory = (D3DX11COMPILEFROMMEMORYTYPE)GetProcAddress(hD3DXDll, "D3DX11CompileFromMemory");
|
|
||||||
if (PD3DX11CompileFromMemory == NULL) MessageBoxA(NULL, "GetProcAddress failed for D3DX11CompileFromMemory!", "Critical error", MB_OK | MB_ICONERROR);
|
|
||||||
|
|
||||||
PD3DX11FilterTexture = (D3DX11FILTERTEXTURETYPE)GetProcAddress(hD3DXDll, "D3DX11FilterTexture");
|
|
||||||
if (PD3DX11FilterTexture == NULL) MessageBoxA(NULL, "GetProcAddress failed for D3DX11FilterTexture!", "Critical error", MB_OK | MB_ICONERROR);
|
|
||||||
|
|
||||||
PD3DX11SaveTextureToFileA = (D3DX11SAVETEXTURETOFILEATYPE)GetProcAddress(hD3DXDll, "D3DX11SaveTextureToFileA");
|
|
||||||
if (PD3DX11SaveTextureToFileA == NULL) MessageBoxA(NULL, "GetProcAddress failed for D3DX11SaveTextureToFileA!", "Critical error", MB_OK | MB_ICONERROR);
|
|
||||||
|
|
||||||
PD3DX11SaveTextureToFileW = (D3DX11SAVETEXTURETOFILEWTYPE)GetProcAddress(hD3DXDll, "D3DX11SaveTextureToFileW");
|
|
||||||
if (PD3DX11SaveTextureToFileW == NULL) MessageBoxA(NULL, "GetProcAddress failed for D3DX11SaveTextureToFileW!", "Critical error", MB_OK | MB_ICONERROR);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT LoadD3DCompiler()
|
HRESULT LoadD3DCompiler()
|
||||||
{
|
{
|
||||||
if (d3dcompiler_dll_ref++ > 0) return S_OK;
|
if (d3dcompiler_dll_ref++ > 0) return S_OK;
|
||||||
|
@ -177,18 +132,6 @@ void UnloadDXGI()
|
||||||
PCreateDXGIFactory = NULL;
|
PCreateDXGIFactory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnloadD3DX()
|
|
||||||
{
|
|
||||||
if (!d3dx_dll_ref) return;
|
|
||||||
if (--d3dx_dll_ref != 0) return;
|
|
||||||
|
|
||||||
if (hD3DXDll) FreeLibrary(hD3DXDll);
|
|
||||||
hD3DXDll = NULL;
|
|
||||||
PD3DX11FilterTexture = NULL;
|
|
||||||
PD3DX11SaveTextureToFileA = NULL;
|
|
||||||
PD3DX11SaveTextureToFileW = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnloadD3D()
|
void UnloadD3D()
|
||||||
{
|
{
|
||||||
if (!d3d_dll_ref) return;
|
if (!d3d_dll_ref) return;
|
||||||
|
@ -272,13 +215,11 @@ HRESULT Create(HWND wnd)
|
||||||
|
|
||||||
hr = LoadDXGI();
|
hr = LoadDXGI();
|
||||||
if (SUCCEEDED(hr)) hr = LoadD3D();
|
if (SUCCEEDED(hr)) hr = LoadD3D();
|
||||||
if (SUCCEEDED(hr)) hr = LoadD3DX();
|
|
||||||
if (SUCCEEDED(hr)) hr = LoadD3DCompiler();
|
if (SUCCEEDED(hr)) hr = LoadD3DCompiler();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
UnloadDXGI();
|
UnloadDXGI();
|
||||||
UnloadD3D();
|
UnloadD3D();
|
||||||
UnloadD3DX();
|
|
||||||
UnloadD3DCompiler();
|
UnloadD3DCompiler();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +361,6 @@ void Close()
|
||||||
|
|
||||||
// unload DLLs
|
// unload DLLs
|
||||||
UnloadD3D();
|
UnloadD3D();
|
||||||
UnloadD3DX();
|
|
||||||
UnloadDXGI();
|
UnloadDXGI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dxgi.h>
|
#include <dxgi.h>
|
||||||
#include <d3dx11.h>
|
#include <d3d11.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -25,11 +25,9 @@ namespace D3D
|
||||||
|
|
||||||
HRESULT LoadDXGI();
|
HRESULT LoadDXGI();
|
||||||
HRESULT LoadD3D();
|
HRESULT LoadD3D();
|
||||||
HRESULT LoadD3DX();
|
|
||||||
HRESULT LoadD3DCompiler();
|
HRESULT LoadD3DCompiler();
|
||||||
void UnloadDXGI();
|
void UnloadDXGI();
|
||||||
void UnloadD3D();
|
void UnloadD3D();
|
||||||
void UnloadD3DX();
|
|
||||||
void UnloadD3DCompiler();
|
void UnloadD3DCompiler();
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL GetFeatureLevel(IDXGIAdapter* adapter);
|
D3D_FEATURE_LEVEL GetFeatureLevel(IDXGIAdapter* adapter);
|
||||||
|
@ -74,27 +72,6 @@ void SetDebugObjectName(T resource, const char* name)
|
||||||
|
|
||||||
} // namespace D3D
|
} // namespace D3D
|
||||||
|
|
||||||
// Used to not require the SDK and runtime versions to match:
|
|
||||||
// Linking with d3dx11.lib makes the most recent d3dx11_xx.dll of the
|
|
||||||
// compiler's SDK a requirement, but this backend works with DX11 runtimes
|
|
||||||
// back to August 2009 even if the backend was built with June 2010.
|
|
||||||
// Add any d3dx11 functions which you want to use here and load them in Create()
|
|
||||||
typedef HRESULT(WINAPI* D3DX11COMPILEFROMMEMORYTYPE)(LPCSTR, SIZE_T, LPCSTR, const D3D10_SHADER_MACRO*, LPD3D10INCLUDE, LPCSTR, LPCSTR, UINT, UINT, ID3DX11ThreadPump*, ID3D10Blob**, ID3D10Blob**, HRESULT*);
|
|
||||||
typedef HRESULT(WINAPI* D3DX11FILTERTEXTURETYPE)(ID3D11DeviceContext*, ID3D11Resource*, UINT, UINT);
|
|
||||||
typedef HRESULT(WINAPI* D3DX11SAVETEXTURETOFILEATYPE)(ID3D11DeviceContext*, ID3D11Resource*, D3DX11_IMAGE_FILE_FORMAT, LPCSTR);
|
|
||||||
typedef HRESULT(WINAPI* D3DX11SAVETEXTURETOFILEWTYPE)(ID3D11DeviceContext*, ID3D11Resource*, D3DX11_IMAGE_FILE_FORMAT, LPCWSTR);
|
|
||||||
|
|
||||||
extern D3DX11COMPILEFROMMEMORYTYPE PD3DX11CompileFromMemory;
|
|
||||||
extern D3DX11FILTERTEXTURETYPE PD3DX11FilterTexture;
|
|
||||||
extern D3DX11SAVETEXTURETOFILEATYPE PD3DX11SaveTextureToFileA;
|
|
||||||
extern D3DX11SAVETEXTURETOFILEWTYPE PD3DX11SaveTextureToFileW;
|
|
||||||
|
|
||||||
#ifdef UNICODE
|
|
||||||
#define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileW
|
|
||||||
#else
|
|
||||||
#define PD3DX11SaveTextureToFile PD3DX11SaveTextureToFileA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef HRESULT (WINAPI *CREATEDXGIFACTORY)(REFIID, void**);
|
typedef HRESULT (WINAPI *CREATEDXGIFACTORY)(REFIID, void**);
|
||||||
extern CREATEDXGIFACTORY PCreateDXGIFactory;
|
extern CREATEDXGIFACTORY PCreateDXGIFactory;
|
||||||
typedef HRESULT (WINAPI *D3D11CREATEDEVICE)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT, CONST D3D_FEATURE_LEVEL*, UINT, UINT, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**);
|
typedef HRESULT (WINAPI *D3D11CREATEDEVICE)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT, CONST D3D_FEATURE_LEVEL*, UINT, UINT, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**);
|
||||||
|
|
Loading…
Reference in New Issue