(D3D10/11/12) Cleanup non-HAVE_DYNAMIC codepaths

This commit is contained in:
twinaphex 2018-01-30 17:06:57 +01:00
parent b5a1111e07
commit 80bdcd89a6
4 changed files with 38 additions and 69 deletions

View File

@ -13,12 +13,13 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <gfx/scaler/pixconv.h>
#include "d3d10_common.h"
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
static dylib_t d3d10_dll;
typedef HRESULT(WINAPI* PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN)(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
@ -40,9 +41,9 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(
ID3D10Device** ppDevice)
{
static dylib_t d3d10_dll;
static PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN fp;
#ifdef HAVE_DYNAMIC
if (!d3d10_dll)
d3d10_dll = dylib_load("d3d10.dll");
@ -52,16 +53,15 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(
if (!fp)
fp = (PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN)dylib_proc(
d3d10_dll, "D3D10CreateDeviceAndSwapChain");
#else
fp = D3D10CreateDeviceAndSwapChain;
#endif
if (!fp)
return TYPE_E_CANTLOADLIBRARY;
return fp(
pAdapter, DriverType, Software, Flags, SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice);
pAdapter, DriverType, Software, Flags, SDKVersion,
pSwapChainDesc, ppSwapChain, ppDevice);
}
#endif
void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture)
{
@ -88,7 +88,8 @@ void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture)
view_desc.Texture2D.MostDetailedMip = 0;
view_desc.Texture2D.MipLevels = -1;
D3D10CreateTexture2DShaderResourceView(device, texture->handle, &view_desc, &texture->view);
D3D10CreateTexture2DShaderResourceView(device,
texture->handle, &view_desc, &texture->view);
}
{
@ -100,7 +101,6 @@ void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture)
}
}
#include <gfx/scaler/pixconv.h>
void d3d10_update_texture(
int width,
int height,
@ -111,15 +111,18 @@ void d3d10_update_texture(
{
D3D10_MAPPED_TEXTURE2D mapped_texture;
D3D10MapTexture2D(texture->staging, 0, D3D10_MAP_WRITE, 0, &mapped_texture);
D3D10MapTexture2D(texture->staging, 0, D3D10_MAP_WRITE, 0,
&mapped_texture);
#if 0
PERF_START();
conv_rgb565_argb8888(mapped_texture.pData, data, width, height, mapped_texture.RowPitch, pitch);
conv_rgb565_argb8888(mapped_texture.pData, data, width, height,
mapped_texture.RowPitch, pitch);
PERF_STOP();
#else
dxgi_copy(
width, height, format, pitch, data, texture->desc.Format, mapped_texture.RowPitch,
width, height, format, pitch, data, texture->desc.Format,
mapped_texture.RowPitch,
mapped_texture.pData);
#endif
@ -130,14 +133,16 @@ void d3d10_update_texture(
}
DXGI_FORMAT
d3d10_get_closest_match(D3D10Device device, DXGI_FORMAT desired_format, UINT desired_format_support)
d3d10_get_closest_match(D3D10Device device,
DXGI_FORMAT desired_format, UINT desired_format_support)
{
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
UINT format_support;
while (*format != DXGI_FORMAT_UNKNOWN)
{
if (SUCCEEDED(D3D10CheckFormatSupport(device, *format, &format_support)) &&
if (SUCCEEDED(D3D10CheckFormatSupport(device, *format,
&format_support)) &&
((format_support & desired_format_support) == desired_format_support))
break;
format++;

View File

@ -15,11 +15,10 @@
#include "d3d11_common.h"
#include "d3dcompiler_common.h"
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
static dylib_t d3d11_dll;
#endif
HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
@ -35,9 +34,9 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext)
{
static dylib_t d3d11_dll;
static PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN fp;
#ifdef HAVE_DYNAMIC
if (!d3d11_dll)
d3d11_dll = dylib_load("d3d11.dll");
@ -47,9 +46,6 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
if (!fp)
fp = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)dylib_proc(
d3d11_dll, "D3D11CreateDeviceAndSwapChain");
#else
fp = D3D11CreateDeviceAndSwapChain;
#endif
if (!fp)
return TYPE_E_CANTLOADLIBRARY;
@ -58,6 +54,7 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion,
pSwapChainDesc, ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext);
}
#endif
void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture)
{

View File

@ -13,14 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <dynamic/dylib.h>
#include "d3d12_common.h"
#include "dxgi_common.h"
#include "d3dcompiler_common.h"
#include "../verbosity.h"
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
#endif
#ifdef __MINGW32__
/* clang-format off */
#define DEFINE_GUIDW(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
@ -55,6 +57,7 @@ DEFINE_GUIDW(IID_ID3D12DebugCommandList, 0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47,
/* clang-format on */
#endif
#ifdef HAVE_DYNAMIC
static dylib_t d3d12_dll;
static const char* d3d12_dll_name = "d3d12.dll";
@ -62,7 +65,6 @@ HRESULT WINAPI D3D12CreateDevice(
IUnknown* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void** ppDevice)
{
static PFN_D3D12_CREATE_DEVICE fp;
#ifdef HAVE_DYNAMIC
if (!d3d12_dll)
d3d12_dll = dylib_load(d3d12_dll_name);
@ -71,23 +73,17 @@ HRESULT WINAPI D3D12CreateDevice(
if (!fp)
fp = (PFN_D3D12_CREATE_DEVICE)dylib_proc(d3d12_dll, "D3D12CreateDevice");
#else
fp = D3D12CreateDevice;
#endif
if (fp)
return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void** ppvDebug)
{
static PFN_D3D12_GET_DEBUG_INTERFACE fp;
#ifdef HAVE_DYNAMIC
if (!d3d12_dll)
d3d12_dll = dylib_load(d3d12_dll_name);
@ -96,16 +92,11 @@ HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void** ppvDebug)
if (!fp)
fp = (PFN_D3D12_GET_DEBUG_INTERFACE)dylib_proc(d3d12_dll, "D3D12GetDebugInterface");
#else
fp = D3D12GetDebugInterface;
#endif
if (fp)
return fp(riid, ppvDebug);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
@ -116,7 +107,6 @@ HRESULT WINAPI D3D12SerializeRootSignature(
ID3DBlob** ppErrorBlob)
{
static PFN_D3D12_SERIALIZE_ROOT_SIGNATURE fp;
#ifdef HAVE_DYNAMIC
if (!d3d12_dll)
d3d12_dll = dylib_load(d3d12_dll_name);
@ -126,16 +116,11 @@ HRESULT WINAPI D3D12SerializeRootSignature(
if (!fp)
fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc(
d3d12_dll, "D3D12SerializeRootSignature");
#else
fp = D3D12SerializeRootSignature;
#endif
if (fp)
return fp(pRootSignature, Version, ppBlob, ppErrorBlob);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
@ -145,7 +130,6 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature(
ID3DBlob** ppErrorBlob)
{
static PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE fp;
#ifdef HAVE_DYNAMIC
if (!d3d12_dll)
d3d12_dll = dylib_load(d3d12_dll_name);
@ -155,18 +139,14 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature(
if (!fp)
fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc(
d3d12_dll, "D3D12SerializeRootSignature");
#else
fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)D3D12SerializeRootSignature;
#endif
if (fp)
return fp(pRootSignature, ppBlob, ppErrorBlob);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
#endif
bool d3d12_init_base(d3d12_video_t* d3d12)
{

View File

@ -19,14 +19,12 @@
#include "config.h"
#endif
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
#endif
#include "d3dcompiler_common.h"
#include "../../verbosity.h"
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
static dylib_t d3dcompiler_dll;
static const char* d3dcompiler_dll_list[] = {
"D3DCompiler_47.dll", "D3DCompiler_46.dll", "D3DCompiler_45.dll", "D3DCompiler_44.dll",
@ -34,7 +32,6 @@ static const char* d3dcompiler_dll_list[] = {
"D3DCompiler_39.dll", "D3DCompiler_38.dll", "D3DCompiler_37.dll", "D3DCompiler_36.dll",
"D3DCompiler_35.dll", "D3DCompiler_34.dll", "D3DCompiler_33.dll", NULL,
};
#endif
HRESULT WINAPI D3DCompile(
LPCVOID pSrcData,
@ -50,7 +47,6 @@ HRESULT WINAPI D3DCompile(
ID3DBlob** ppErrorMsgs)
{
static pD3DCompile fp;
#ifdef HAVE_DYNAMIC
const char** dll_name = d3dcompiler_dll_list;
while (!d3dcompiler_dll && *dll_name)
d3dcompiler_dll = dylib_load(*dll_name++);
@ -60,17 +56,13 @@ HRESULT WINAPI D3DCompile(
if (!fp)
fp = (pD3DCompile)dylib_proc(d3dcompiler_dll, "D3DCompile");
#else
fp = D3DCompile;
#endif
if (fp)
return fp(
pSrcData, SrcDataSize, pSourceName, pDefines, pInclude, pEntrypoint, pTarget, Flags1,
Flags2, ppCode, ppErrorMsgs);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
@ -90,7 +82,6 @@ HRESULT WINAPI D3DCompileFromFile(
LPCSTR pEntrypoint, LPCSTR pTarget, UINT Flags1, UINT Flags2, ID3DBlob** ppCode,
ID3DBlob** ppErrorMsgs);
static pD3DCompileFromFile fp;
#ifdef HAVE_DYNAMIC
const char** dll_name = d3dcompiler_dll_list;
while (!d3dcompiler_dll && *dll_name)
d3dcompiler_dll = dylib_load(*dll_name++);
@ -100,28 +91,24 @@ HRESULT WINAPI D3DCompileFromFile(
if (!fp)
fp = (pD3DCompileFromFile)dylib_proc(d3dcompiler_dll, "D3DCompileFromFile");
#else
fp = D3DCompileFromFile;
#endif
if (fp)
return fp(
pFileName, pDefines, pInclude, pEntrypoint, pTarget, Flags1, Flags2, ppCode,
ppErrorMsgs);
#ifdef HAVE_DYNAMIC
error:
#endif
return TYPE_E_CANTLOADLIBRARY;
}
#endif
bool d3d_compile(const char* src, size_t size, LPCSTR entrypoint, LPCSTR target, D3DBlob* out)
{
D3DBlob error_msg;
UINT compileflags = 0;
#ifdef DEBUG
compileflags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
UINT compileflags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
#else
UINT compileflags = 0;
#endif
if (FAILED(D3DCompile(
@ -141,10 +128,10 @@ bool d3d_compile(const char* src, size_t size, LPCSTR entrypoint, LPCSTR target,
bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out)
{
D3DBlob error_msg;
UINT compileflags = 0;
#ifdef DEBUG
compileflags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
UINT compileflags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
#else
UINT compileflags = 0;
#endif
if (FAILED(D3DCompileFromFile(