mirror of https://github.com/bkaradzic/bgfx
Cleanup.
This commit is contained in:
parent
bab77d3e1b
commit
641d294b9d
|
@ -14,7 +14,7 @@
|
|||
#include <string.h> // memcpy
|
||||
|
||||
#ifndef ENTRY_CONFIG_USE_NOOP
|
||||
# define ENTRY_CONFIG_USE_NOOP (BX_PLATFORM_QNX || BX_PLATFORM_XBOXONE)
|
||||
# define ENTRY_CONFIG_USE_NOOP (BX_PLATFORM_QNX)
|
||||
#endif // ENTRY_CONFIG_USE_NOOP
|
||||
|
||||
#ifndef ENTRY_CONFIG_USE_SDL
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "entry_p.h"
|
||||
|
||||
#if BX_PLATFORM_WINRT
|
||||
#if BX_PLATFORM_WINRT || BX_PLATFORM_XBOXONE
|
||||
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
#include <bx/thread.h>
|
||||
|
@ -17,7 +17,9 @@ using namespace Windows::UI::Core;
|
|||
using namespace Windows::UI::Input;
|
||||
using namespace Windows::System;
|
||||
using namespace Windows::Foundation;
|
||||
#if BX_PLATFORM_WINRT
|
||||
using namespace Windows::Graphics::Display;
|
||||
#endif // BX_PLATFORM_WINRT
|
||||
using namespace Platform;
|
||||
|
||||
static char* g_emptyArgs[] = { "" };
|
||||
|
@ -36,13 +38,23 @@ public:
|
|||
// IFrameworkView Methods.
|
||||
virtual void Initialize(CoreApplicationView^ applicationView)
|
||||
{
|
||||
applicationView->Activated += ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
|
||||
applicationView->Activated += ref new
|
||||
TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
|
||||
|
||||
CoreApplication::Suspending += ref new
|
||||
EventHandler<SuspendingEventArgs^>(this, &App::OnSuspending);
|
||||
|
||||
CoreApplication::Resuming += ref new
|
||||
EventHandler<Platform::Object^>(this, &App::OnResuming);
|
||||
}
|
||||
|
||||
virtual void SetWindow(CoreWindow^ window)
|
||||
{
|
||||
window->VisibilityChanged += ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged);
|
||||
window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
|
||||
window->VisibilityChanged += ref new
|
||||
TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged);
|
||||
|
||||
window->Closed += ref new
|
||||
TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
|
||||
|
||||
bgfx::winrtSetWindow(reinterpret_cast<IUnknown*>(window) );
|
||||
}
|
||||
|
@ -58,13 +70,15 @@ public:
|
|||
|
||||
CoreWindow^ window = CoreWindow::GetForCurrentThread();
|
||||
auto bounds = window->Bounds;
|
||||
auto dpi = DisplayInformation::GetForCurrentView()->LogicalDpi;
|
||||
|
||||
#if BX_PLATFORM_WINRT
|
||||
auto dpi = DisplayInformation::GetForCurrentView()->LogicalDpi;
|
||||
static const float dipsPerInch = 96.0f;
|
||||
g_eventQueue.postSizeEvent(g_defaultWindow
|
||||
, lround(floorf(bounds.Width * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(floorf(bounds.Height * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(bx::ffloor(bounds.Width * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(bx::ffloor(bounds.Height * dpi / dipsPerInch + 0.5f) )
|
||||
);
|
||||
#endif // BX_PLATFORM_WINRT
|
||||
|
||||
while (!m_windowClosed)
|
||||
{
|
||||
|
@ -101,6 +115,16 @@ private:
|
|||
m_windowVisible = args->Visible;
|
||||
}
|
||||
|
||||
void OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
|
||||
{
|
||||
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
|
||||
BX_UNUSED(deferral);
|
||||
}
|
||||
|
||||
void OnResuming(Platform::Object^ sender, Platform::Object^ args)
|
||||
{
|
||||
}
|
||||
|
||||
void OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
|
||||
{
|
||||
m_windowClosed = true;
|
||||
|
@ -189,4 +213,4 @@ int main(Array<String^>^)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif // BX_PLATFORM_WINRT
|
||||
#endif // BX_PLATFORM_WINRT || BX_PLATFORM_XBOXONE
|
||||
|
|
|
@ -1076,13 +1076,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
DX_RELEASE(device, 2);
|
||||
}
|
||||
|
||||
memset(&m_adapterDesc, 0, sizeof(m_adapterDesc) );
|
||||
hr = adapter->GetDesc(&m_adapterDesc);
|
||||
if (FAILED(hr) )
|
||||
{
|
||||
BX_TRACE("Unable to create Direct3D11 device.");
|
||||
DX_RELEASE(adapter, 2);
|
||||
goto error;
|
||||
}
|
||||
BX_WARN(SUCCEEDED(hr), "Adapter GetDesc failed 0x%08x.", hr);
|
||||
|
||||
g_caps.vendorId = 0 == m_adapterDesc.VendorId
|
||||
? BGFX_PCI_ID_SOFTWARE_RASTERIZER
|
||||
|
@ -1354,140 +1350,168 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
|
||||
if (DXGI_FORMAT_UNKNOWN != fmt)
|
||||
{
|
||||
struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
|
||||
if (BX_ENABLED(BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
{
|
||||
DXGI_FORMAT InFormat;
|
||||
UINT OutFormatSupport;
|
||||
};
|
||||
struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
|
||||
{
|
||||
DXGI_FORMAT InFormat;
|
||||
UINT OutFormatSupport;
|
||||
};
|
||||
|
||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
|
||||
data.InFormat = fmt;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE2D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_BUFFER
|
||||
| D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
|
||||
| D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_VERTEX
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_SHADER_LOAD
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_RENDER_TARGET
|
||||
| D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_MSAA
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_TRACE("CheckFeatureSupport failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
||||
}
|
||||
|
||||
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE) )
|
||||
{
|
||||
// clear image flag for additional testing
|
||||
support &= ~BGFX_CAPS_FORMAT_TEXTURE_IMAGE;
|
||||
|
||||
data.InFormat = s_textureFormat[ii].m_fmt;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT2, &data, sizeof(data) );
|
||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
|
||||
data.InFormat = fmt;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD
|
||||
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE2D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_BUFFER
|
||||
| D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER
|
||||
| D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_VERTEX
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_SHADER_LOAD
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_RENDER_TARGET
|
||||
| D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_MSAA
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_TRACE("CheckFeatureSupport failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
||||
}
|
||||
|
||||
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE) )
|
||||
{
|
||||
// clear image flag for additional testing
|
||||
support &= ~BGFX_CAPS_FORMAT_TEXTURE_IMAGE;
|
||||
|
||||
data.InFormat = s_textureFormat[ii].m_fmt;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT2, &data, sizeof(data) );
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD
|
||||
| D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_IMAGE
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
support |= 0
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_3D
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_CUBE
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_IMAGE
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_VERTEX
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_IMAGE
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_MSAA
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (DXGI_FORMAT_UNKNOWN != fmtSrgb)
|
||||
{
|
||||
struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
|
||||
if (BX_ENABLED(BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
{
|
||||
DXGI_FORMAT InFormat;
|
||||
UINT OutFormatSupport;
|
||||
};
|
||||
struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
|
||||
{
|
||||
DXGI_FORMAT InFormat;
|
||||
UINT OutFormatSupport;
|
||||
};
|
||||
|
||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
|
||||
data.InFormat = fmtSrgb;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE2D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
|
||||
data.InFormat = fmtSrgb;
|
||||
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE2D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
support |= 0 != (data.OutFormatSupport & (0
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_TRACE("CheckFeatureSupport failed with %x for sRGB format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_TRACE("CheckFeatureSupport failed with %x for sRGB format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
||||
support |= 0
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue