11 #include "commons/Exception.h" 14 #include "platform/win32/CharsetConverter.h" 24 PCIV_MICROSOFT = 0x1414,
29 #define RATIONAL_TO_FLOAT(rational) ((rational.Denominator != 0) ? \ 30 static_cast<float>(rational.Numerator) / static_cast<float>(rational.Denominator) : 0.0f) 32 namespace DisplayMetrics
39 static const bool SupportHighResolutions =
true;
44 static const float Dpi100 = 96.0f;
45 static const float DpiThreshold = 192.0f;
46 static const float WidthThreshold = 1920.0f;
47 static const float HeightThreshold = 1080.0f;
50 inline void BreakIfFailed(HRESULT hr)
55 #if _DEBUG && !defined(TARGET_WINDOWS_STORE) 58 throw new XbmcCommons::UncheckedException(__FUNCTION__,
"Unhandled error");
63 inline float ConvertDipsToPixels(
float dips,
float dpi)
65 static const float dipsPerInch = DisplayMetrics::Dpi100;
66 return floorf(dips * dpi / dipsPerInch + 0.5f);
69 inline float ConvertPixelsToDips(
float pixels,
float dpi)
71 static const float dipsPerInch = DisplayMetrics::Dpi100;
72 return floorf(pixels / (dpi / dipsPerInch) + 0.5f);
75 inline float RationalToFloat(DXGI_RATIONAL rational)
77 return RATIONAL_TO_FLOAT(rational);
80 inline void GetRefreshRatio(uint32_t refresh, uint32_t *num, uint32_t *den)
82 int i = (((refresh + 1) % 24) == 0 || ((refresh + 1) % 30) == 0) ? 1 : 0;
83 *num = (refresh + i) * 1000;
87 inline std::string GetErrorDescription(HRESULT hr)
92 DXGetErrorDescriptionW(hr, buff, 2048);
97 inline std::string GetFeatureLevelDescription(D3D_FEATURE_LEVEL featureLevel)
99 uint32_t fl_major = (featureLevel & 0xF000u) >> 12;
100 uint32_t fl_minor = (featureLevel & 0x0F00u) >> 8;
105 constexpr std::string_view GetGFXProviderName(UINT vendorId)
122 constexpr std::string_view DXGIFormatToShortString(
const DXGI_FORMAT format)
126 case DXGI_FORMAT_B8G8R8A8_UNORM:
128 case DXGI_FORMAT_R10G10B10A2_UNORM:
130 case DXGI_FORMAT_R16G16B16A16_FLOAT:
132 case DXGI_FORMAT_R32G32B32A32_FLOAT:
142 SizeGen<T>(T width, T height) { Width = width; Height = height; }
144 bool operator !=(
const SizeGen<T> &size)
const 146 return Width != size.Width || Height != size.Height;
152 Height -= size.Height;
159 Height += size.Height;
182 inline bool SdkLayersAvailable()
184 HRESULT hr = D3D11CreateDevice(
186 D3D_DRIVER_TYPE_NULL,
188 D3D11_CREATE_DEVICE_DEBUG,
197 return SUCCEEDED(hr);
201 const std::string DXGIFormatToString(
const DXGI_FORMAT format);
202 const std::string DXGIColorSpaceTypeToString(DXGI_COLOR_SPACE_TYPE type);
203 const std::string D3D11VideoProcessorFormatSupportToString(
204 D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT value);
207 #ifdef TARGET_WINDOWS_DESKTOP Definition: AsyncHelpers.h:15
Definition: DeviceResources.h:27
static std::string Format(const std::string &fmt, Args &&... args)
Get a formatted string similar to sprintf.
Definition: StringUtils.h:79
Definition: DirectXHelper.h:139