D3D11: Enable compilation on Linux.
This commit is contained in:
parent
1fa7570ef8
commit
4c0baf5603
@ -19,9 +19,11 @@
|
||||
#define BGFX_EMBEDDED_SHADER_SPIRV(...)
|
||||
|
||||
#define BGFX_PLATFORM_SUPPORTS_DX9BC (0 \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_WINDOWS \
|
||||
)
|
||||
#define BGFX_PLATFORM_SUPPORTS_DXBC (0 \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE \
|
||||
|
10
src/bgfx.cpp
10
src/bgfx.cpp
@ -2692,10 +2692,12 @@ namespace bgfx
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_LINUX) )
|
||||
{
|
||||
score += RendererType::Vulkan == renderer ? 30 : 0;
|
||||
score += RendererType::OpenGL == renderer ? 20 : 0;
|
||||
score += RendererType::OpenGLES == renderer ? 10 : 0;
|
||||
score += RendererType::Direct3D12 == renderer ? 5 : 0;
|
||||
score += RendererType::Vulkan == renderer ? 50 : 0;
|
||||
score += RendererType::OpenGL == renderer ? 40 : 0;
|
||||
score += RendererType::OpenGLES == renderer ? 30 : 0;
|
||||
score += RendererType::Direct3D12 == renderer ? 20 : 0;
|
||||
score += RendererType::Direct3D11 == renderer ? 10 : 0;
|
||||
score += RendererType::Direct3D9 == renderer ? 5 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||
# define BGFX_CONFIG_RENDERER_DIRECT3D11 (0 \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE \
|
||||
|
25
src/dxgi.cpp
25
src/dxgi.cpp
@ -128,15 +128,27 @@ namespace bgfx
|
||||
|
||||
bool Dxgi::init(Caps& _caps)
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
m_dxgiDll = bx::dlopen("dxgi.dll");
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
|
||||
const char* dxgiDllName =
|
||||
#if BX_PLATFORM_LINUX
|
||||
"dxgi.so"
|
||||
#else
|
||||
"dxgi.dll"
|
||||
#endif // BX_PLATFORM_LINUX
|
||||
;
|
||||
m_dxgiDll = bx::dlopen(dxgiDllName);
|
||||
|
||||
if (NULL == m_dxgiDll)
|
||||
{
|
||||
BX_TRACE("Init error: Failed to load dxgi.dll.");
|
||||
BX_TRACE("Init error: Failed to load %s.", dxgiDllName);
|
||||
return false;
|
||||
}
|
||||
|
||||
# if BX_PLATFORM_WINDOWS
|
||||
m_dxgiDebugDll = bx::dlopen("dxgidebug.dll");
|
||||
|
||||
|
||||
if (NULL != m_dxgiDebugDll)
|
||||
{
|
||||
DXGIGetDebugInterface = (PFN_GET_DEBUG_INTERFACE )bx::dlsym(m_dxgiDebugDll, "DXGIGetDebugInterface");
|
||||
@ -161,6 +173,7 @@ namespace bgfx
|
||||
BX_TRACE("Init error: Function CreateDXGIFactory not found.");
|
||||
return false;
|
||||
}
|
||||
# endif // BX_PLATFORM_WINDOWS
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
@ -273,7 +286,7 @@ namespace bgfx
|
||||
BX_TRACE("\t\t AttachedToDesktop: %d", outputDesc.AttachedToDesktop);
|
||||
BX_TRACE("\t\t Rotation: %d", outputDesc.Rotation);
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
IDXGIOutput6* output6;
|
||||
hr = output->QueryInterface(IID_IDXGIOutput6, (void**)&output6);
|
||||
if (SUCCEEDED(hr) )
|
||||
@ -381,7 +394,7 @@ namespace bgfx
|
||||
|
||||
uint32_t scdFlags = _scd.flags;
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
IDXGIFactory5* factory5;
|
||||
hr = m_factory->QueryInterface(IID_IDXGIFactory5, (void**)&factory5);
|
||||
|
||||
@ -733,7 +746,7 @@ namespace bgfx
|
||||
|
||||
uint32_t scdFlags = _scd.flags;
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
IDXGIFactory5* factory5;
|
||||
hr = m_factory->QueryInterface(IID_IDXGIFactory5, (void**)&factory5);
|
||||
|
||||
|
@ -6,11 +6,8 @@
|
||||
#ifndef BGFX_DXGI_H_HEADER_GUARD
|
||||
#define BGFX_DXGI_H_HEADER_GUARD
|
||||
|
||||
#if BX_PLATFORM_LINUX
|
||||
# include <unknwn.h>
|
||||
typedef void* HMODULE;
|
||||
#define _Out_writes_bytes_to_(s,c)
|
||||
#endif // BX_PLATFORM_LINUX
|
||||
#include <sal.h>
|
||||
#include <unknwn.h>
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
|
||||
# include <d3dcommon.h>
|
||||
@ -59,7 +56,7 @@ namespace bgfx
|
||||
///
|
||||
struct Dxgi
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
typedef ::IDXGIAdapter3 AdapterI;
|
||||
typedef ::IDXGIFactory5 FactoryI;
|
||||
typedef ::IDXGISwapChain3 SwapChainI;
|
||||
|
@ -19,6 +19,10 @@
|
||||
# define DX_CHECK_EXTRA_ARGS
|
||||
#endif // BGFX_CONFIG_DEBUG && BGFX_CONFIG_RENDERER_DIRECT3D9
|
||||
|
||||
#ifndef DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
|
||||
# define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE HRESULT(0x887A0022)
|
||||
#endif // DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
|
||||
|
||||
#define DXGI_FORMAT_ASTC_4X4_TYPELESS DXGI_FORMAT(133)
|
||||
#define DXGI_FORMAT_ASTC_4X4_UNORM DXGI_FORMAT(134)
|
||||
#define DXGI_FORMAT_ASTC_4X4_UNORM_SRGB DXGI_FORMAT(135)
|
||||
|
@ -811,11 +811,19 @@ namespace bgfx { namespace d3d11
|
||||
m_nvapi.init();
|
||||
|
||||
#if USE_D3D11_DYNAMIC_LIB
|
||||
m_d3d11Dll = bx::dlopen("d3d11.dll");
|
||||
const char* d3d11DllName =
|
||||
#if BX_PLATFORM_LINUX
|
||||
"d3d11.so"
|
||||
#else
|
||||
"d3d11.dll"
|
||||
#endif // BX_PLATFORM_LINUX
|
||||
;
|
||||
|
||||
m_d3d11Dll = bx::dlopen(d3d11DllName);
|
||||
|
||||
if (NULL == m_d3d11Dll)
|
||||
{
|
||||
BX_TRACE("Init error: Failed to load d3d11.dll.");
|
||||
BX_TRACE("Init error: Failed to load %s.", d3d11DllName);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1004,11 +1012,11 @@ namespace bgfx { namespace d3d11
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
m_swapEffect =
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
DXGI_SWAP_EFFECT_FLIP_DISCARD
|
||||
#else
|
||||
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL
|
||||
#endif // !BX_PLATFORM_WINDOWS
|
||||
#endif // BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
;
|
||||
|
||||
m_swapBufferCount = bx::clamp<uint8_t>(_init.resolution.numBackBuffers, 2, BGFX_CONFIG_MAX_BACK_BUFFERS);
|
||||
@ -1040,7 +1048,10 @@ namespace bgfx { namespace d3d11
|
||||
;
|
||||
m_scd.swapEffect = m_swapEffect;
|
||||
|
||||
m_scd.alphaMode = (_init.resolution.reset & BGFX_RESET_TRANSPARENT_BACKBUFFER) ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE;
|
||||
m_scd.alphaMode = (_init.resolution.reset & BGFX_RESET_TRANSPARENT_BACKBUFFER)
|
||||
? DXGI_ALPHA_MODE_PREMULTIPLIED
|
||||
: DXGI_ALPHA_MODE_IGNORE
|
||||
;
|
||||
|
||||
m_scd.flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
|
@ -18,7 +18,10 @@ BX_PRAGMA_DIAGNOSTIC_PUSH();
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunknown-pragmas" );
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wpragmas");
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinition
|
||||
|
||||
#include <sal.h>
|
||||
#include <unknwn.h>
|
||||
|
||||
#define D3D11_NO_HELPERS
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
|
||||
# include <d3d11_3.h>
|
||||
|
@ -541,10 +541,6 @@ namespace bgfx { namespace d3d12
|
||||
return createCommittedResource(_device, _heapProperty, &resourceDesc, NULL);
|
||||
}
|
||||
|
||||
#ifndef DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
|
||||
# define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE HRESULT(0x887A0022)
|
||||
#endif // DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
|
||||
|
||||
inline bool isLost(HRESULT _hr)
|
||||
{
|
||||
return false
|
||||
|
@ -8,11 +8,8 @@
|
||||
|
||||
#define USE_D3D12_DYNAMIC_LIB (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX)
|
||||
|
||||
#if BX_PLATFORM_LINUX
|
||||
# include <unknwn.h>
|
||||
#else
|
||||
# include <sal.h>
|
||||
#endif // BX_PLATFORM_LINUX
|
||||
#include <sal.h>
|
||||
#include <unknwn.h>
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
|
||||
# include <d3d12.h>
|
||||
|
Loading…
Reference in New Issue
Block a user