Cleanup.
This commit is contained in:
Родитель
96c8ac71ff
Коммит
f58c2d327d
|
@ -31,15 +31,15 @@
|
||||||
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
|
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
# define BGFX_CONFIG_RENDERER_DIRECT3D11 (0 \
|
# define BGFX_CONFIG_RENDERER_DIRECT3D11 (0 \
|
||||||
|| BX_PLATFORM_WINDOWS \
|
|| BX_PLATFORM_WINDOWS \
|
||||||
|| BX_PLATFORM_XBOXONE \
|
|
||||||
|| BX_PLATFORM_WINRT \
|
|| BX_PLATFORM_WINRT \
|
||||||
|
|| BX_PLATFORM_XBOXONE \
|
||||||
? 1 : 0)
|
? 1 : 0)
|
||||||
# endif // BGFX_CONFIG_RENDERER_DIRECT3D11
|
# endif // BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||||
|
|
||||||
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
|
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
|
||||||
# define BGFX_CONFIG_RENDERER_DIRECT3D12 (0 \
|
# define BGFX_CONFIG_RENDERER_DIRECT3D12 (0 \
|
||||||
|| 0 /*BX_PLATFORM_XBOXONE*/ \
|
|
||||||
|| BX_PLATFORM_WINDOWS \
|
|| BX_PLATFORM_WINDOWS \
|
||||||
|
|| BX_PLATFORM_XBOXONE \
|
||||||
? 1 : 0)
|
? 1 : 0)
|
||||||
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
|
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
|
||||||
|
|
||||||
|
|
|
@ -560,7 +560,12 @@ namespace bgfx { namespace d3d12
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
hr = CreateDXGIFactory1(IID_IDXGIFactory4, (void**)&m_factory);
|
hr = CreateDXGIFactory1(IID_IDXGIFactory4, (void**)&m_factory);
|
||||||
|
#else
|
||||||
|
hr = S_OK;
|
||||||
|
m_factory = NULL;
|
||||||
|
#endif // BX_PLATFORM_*
|
||||||
BX_WARN(SUCCEEDED(hr), "Unable to create DXGI factory.");
|
BX_WARN(SUCCEEDED(hr), "Unable to create DXGI factory.");
|
||||||
|
|
||||||
if (FAILED(hr) )
|
if (FAILED(hr) )
|
||||||
|
@ -574,7 +579,11 @@ namespace bgfx { namespace d3d12
|
||||||
m_driverType = D3D_DRIVER_TYPE_HARDWARE;
|
m_driverType = D3D_DRIVER_TYPE_HARDWARE;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
IDXGIAdapter3* adapter;
|
IDXGIAdapter3* adapter;
|
||||||
|
#else
|
||||||
|
IDXGIAdapter* adapter;
|
||||||
|
#endif // BX_PLATFORM_*
|
||||||
for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != m_factory->EnumAdapters(ii, reinterpret_cast<IDXGIAdapter**>(&adapter) ); ++ii)
|
for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != m_factory->EnumAdapters(ii, reinterpret_cast<IDXGIAdapter**>(&adapter) ); ++ii)
|
||||||
{
|
{
|
||||||
DXGI_ADAPTER_DESC desc;
|
DXGI_ADAPTER_DESC desc;
|
||||||
|
@ -667,7 +676,11 @@ namespace bgfx { namespace d3d12
|
||||||
{
|
{
|
||||||
memset(&m_adapterDesc, 0, sizeof(m_adapterDesc) );
|
memset(&m_adapterDesc, 0, sizeof(m_adapterDesc) );
|
||||||
luid = m_device->GetAdapterLuid();
|
luid = m_device->GetAdapterLuid();
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
IDXGIAdapter3* adapter;
|
IDXGIAdapter3* adapter;
|
||||||
|
#else
|
||||||
|
IDXGIAdapter* adapter;
|
||||||
|
#endif // BX_PLATFORM_*
|
||||||
for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != m_factory->EnumAdapters(ii, reinterpret_cast<IDXGIAdapter**>(&adapter) ); ++ii)
|
for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != m_factory->EnumAdapters(ii, reinterpret_cast<IDXGIAdapter**>(&adapter) ); ++ii)
|
||||||
{
|
{
|
||||||
adapter->GetDesc(&m_adapterDesc);
|
adapter->GetDesc(&m_adapterDesc);
|
||||||
|
@ -760,14 +773,15 @@ namespace bgfx { namespace d3d12
|
||||||
m_resolution.m_width = BGFX_DEFAULT_WIDTH;
|
m_resolution.m_width = BGFX_DEFAULT_WIDTH;
|
||||||
m_resolution.m_height = BGFX_DEFAULT_HEIGHT;
|
m_resolution.m_height = BGFX_DEFAULT_HEIGHT;
|
||||||
|
|
||||||
|
m_numWindows = 1;
|
||||||
|
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
DX_CHECK(m_factory->MakeWindowAssociation( (HWND)g_platformData.nwh
|
DX_CHECK(m_factory->MakeWindowAssociation( (HWND)g_platformData.nwh
|
||||||
, 0
|
, 0
|
||||||
| DXGI_MWA_NO_WINDOW_CHANGES
|
| DXGI_MWA_NO_WINDOW_CHANGES
|
||||||
| DXGI_MWA_NO_ALT_ENTER
|
| DXGI_MWA_NO_ALT_ENTER
|
||||||
) );
|
) );
|
||||||
|
|
||||||
m_numWindows = 1;
|
|
||||||
|
|
||||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||||
{
|
{
|
||||||
hr = m_device->QueryInterface(IID_ID3D12InfoQueue, (void**)&m_infoQueue);
|
hr = m_device->QueryInterface(IID_ID3D12InfoQueue, (void**)&m_infoQueue);
|
||||||
|
@ -793,6 +807,7 @@ namespace bgfx { namespace d3d12
|
||||||
DX_RELEASE_WARNONLY(m_infoQueue, 0);
|
DX_RELEASE_WARNONLY(m_infoQueue, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
D3D12_DESCRIPTOR_HEAP_DESC rtvDescHeap;
|
D3D12_DESCRIPTOR_HEAP_DESC rtvDescHeap;
|
||||||
rtvDescHeap.NumDescriptors = 0
|
rtvDescHeap.NumDescriptors = 0
|
||||||
|
@ -1776,6 +1791,8 @@ data.NumQualityLevels = 0;
|
||||||
|
|
||||||
preReset();
|
preReset();
|
||||||
|
|
||||||
|
BX_UNUSED(resize);
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
if (resize)
|
if (resize)
|
||||||
{
|
{
|
||||||
uint32_t nodeMask[] = { 1, 1, 1, 1 };
|
uint32_t nodeMask[] = { 1, 1, 1, 1 };
|
||||||
|
@ -1793,6 +1810,7 @@ data.NumQualityLevels = 0;
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
{
|
{
|
||||||
updateMsaa();
|
updateMsaa();
|
||||||
m_scd.SampleDesc = s_msaa[(m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
|
m_scd.SampleDesc = s_msaa[(m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
|
||||||
|
@ -2625,21 +2643,27 @@ data.NumQualityLevels = 0;
|
||||||
void* m_dxgidll;
|
void* m_dxgidll;
|
||||||
|
|
||||||
D3D_DRIVER_TYPE m_driverType;
|
D3D_DRIVER_TYPE m_driverType;
|
||||||
IDXGIAdapter3* m_adapter;
|
|
||||||
DXGI_ADAPTER_DESC m_adapterDesc;
|
DXGI_ADAPTER_DESC m_adapterDesc;
|
||||||
D3D12_FEATURE_DATA_ARCHITECTURE m_architecture;
|
D3D12_FEATURE_DATA_ARCHITECTURE m_architecture;
|
||||||
D3D12_FEATURE_DATA_D3D12_OPTIONS m_options;
|
D3D12_FEATURE_DATA_D3D12_OPTIONS m_options;
|
||||||
|
|
||||||
IDXGIFactory4* m_factory;
|
#if BX_PLATFORM_WINDOWS
|
||||||
|
IDXGIAdapter3* m_adapter;
|
||||||
|
IDXGIFactory4* m_factory;
|
||||||
IDXGISwapChain3* m_swapChain;
|
IDXGISwapChain3* m_swapChain;
|
||||||
|
ID3D12InfoQueue* m_infoQueue;
|
||||||
|
#else
|
||||||
|
IDXGIAdapter* m_adapter;
|
||||||
|
IDXGIFactory2* m_factory;
|
||||||
|
IDXGISwapChain1* m_swapChain;
|
||||||
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
int64_t m_presentElapsed;
|
int64_t m_presentElapsed;
|
||||||
uint16_t m_lost;
|
uint16_t m_lost;
|
||||||
uint16_t m_numWindows;
|
uint16_t m_numWindows;
|
||||||
FrameBufferHandle m_windows[BGFX_CONFIG_MAX_FRAME_BUFFERS];
|
FrameBufferHandle m_windows[BGFX_CONFIG_MAX_FRAME_BUFFERS];
|
||||||
|
|
||||||
ID3D12Device* m_device;
|
ID3D12Device* m_device;
|
||||||
ID3D12InfoQueue* m_infoQueue;
|
|
||||||
TimerQueryD3D12 m_gpuTimer;
|
TimerQueryD3D12 m_gpuTimer;
|
||||||
OcclusionQueryD3D12 m_occlusionQuery;
|
OcclusionQueryD3D12 m_occlusionQuery;
|
||||||
|
|
||||||
|
@ -4579,7 +4603,9 @@ data.NumQualityLevels = 0;
|
||||||
uint32_t statsNumIndices = 0;
|
uint32_t statsNumIndices = 0;
|
||||||
uint32_t statsKeyType[2] = {};
|
uint32_t statsKeyType[2] = {};
|
||||||
|
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
m_backBufferColorIdx = m_swapChain->GetCurrentBackBufferIndex();
|
m_backBufferColorIdx = m_swapChain->GetCurrentBackBufferIndex();
|
||||||
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
||||||
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
||||||
|
@ -5273,6 +5299,7 @@ data.NumQualityLevels = 0;
|
||||||
, processMemoryUsed
|
, processMemoryUsed
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if BX_PLATFORM_WINDOWS
|
||||||
DXGI_QUERY_VIDEO_MEMORY_INFO memInfo;
|
DXGI_QUERY_VIDEO_MEMORY_INFO memInfo;
|
||||||
DX_CHECK(m_adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memInfo) );
|
DX_CHECK(m_adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memInfo) );
|
||||||
|
|
||||||
|
@ -5294,6 +5321,7 @@ data.NumQualityLevels = 0;
|
||||||
, availableForReservation
|
, availableForReservation
|
||||||
, currentReservation
|
, currentReservation
|
||||||
);
|
);
|
||||||
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
pos = 10;
|
pos = 10;
|
||||||
tvm.printf(10, pos++, 0x8e, " Frame: % 7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS "
|
tvm.printf(10, pos++, 0x8e, " Frame: % 7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS "
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#ifndef BGFX_RENDERER_D3D12_H_HEADER_GUARD
|
#ifndef BGFX_RENDERER_D3D12_H_HEADER_GUARD
|
||||||
#define BGFX_RENDERER_D3D12_H_HEADER_GUARD
|
#define BGFX_RENDERER_D3D12_H_HEADER_GUARD
|
||||||
|
|
||||||
#define USE_D3D12_DYNAMIC_LIB 1
|
#define USE_D3D12_DYNAMIC_LIB BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
#include <sal.h>
|
#include <sal.h>
|
||||||
#if BX_PLATFORM_XBOXONE
|
#if BX_PLATFORM_XBOXONE
|
||||||
|
@ -38,9 +38,13 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wmissing-field-initializers");
|
||||||
#endif // BX_PLATFORM_XBOXONE
|
#endif // BX_PLATFORM_XBOXONE
|
||||||
BX_PRAGMA_DIAGNOSTIC_POP();
|
BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
|
|
||||||
#if !BX_PLATFORM_XBOXONE
|
#if BX_PLATFORM_WINDOWS
|
||||||
# include <dxgi1_4.h>
|
# include <dxgi1_4.h>
|
||||||
#endif // !BX_PLATFORM_XBOXONE
|
#endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
|
#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
|
||||||
|
# define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 1024
|
||||||
|
#endif // D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
|
||||||
|
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "renderer_d3d.h"
|
#include "renderer_d3d.h"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче