Browse Source

DXGI: Display spec info.

Branimir Karadžić 8 years ago
parent
commit
c0413c9103
1 changed files with 68 additions and 0 deletions
  1. 68 0
      src/renderer_d3d12.cpp

+ 68 - 0
src/renderer_d3d12.cpp

@@ -264,6 +264,38 @@ namespace bgfx { namespace d3d12
 	};
 	};
 	BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
 	BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
 
 
+	static const char* s_colorSpace[] =
+	{
+		// https://msdn.microsoft.com/en-us/library/windows/desktop/dn903661(v=vs.85).aspx
+		"RGB,    0-255, 2.2, Image, BT.709,  n/a",    // DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
+		"RGB,    0-255, 1.0, Image, BT.709,  n/a",    // DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
+		"RGB,   16-235, 2.2, Image, BT.709,  n/a",    // DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709
+		"RGB,   16-235, 2.2, Image, BT.2020, n/a",    // DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020
+		"Reserved",                                   // DXGI_COLOR_SPACE_RESERVED
+		"YCbCr,  0-255, 2.2, Image, BT.709,  BT.601", // DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601
+		"YCbCr, 16-235, 2.2, Video, BT.601,  n/a",    // DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601
+		"YCbCr,  0-255, 2.2, Video, BT.601,  n/a",    // DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709
+		"", // DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020
+		"", // DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020
+		"", // DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020
+		"", // DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020
+		"", // DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020
+//		"", // DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709
+//		"", // DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020
+//		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709
+//		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020
+//		"", // DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020
+		"Custom",
+	};
+	BX_STATIC_ASSERT(BX_COUNTOF(s_colorSpace) == DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020+2);
+
 	static const D3D12_INPUT_ELEMENT_DESC s_attrib[] =
 	static const D3D12_INPUT_ELEMENT_DESC s_attrib[] =
 	{
 	{
 		{ "POSITION",     0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
 		{ "POSITION",     0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
@@ -392,6 +424,8 @@ namespace bgfx { namespace d3d12
 	static const GUID IID_IDXGIDevice3              = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
 	static const GUID IID_IDXGIDevice3              = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
 	static const GUID IID_IDXGIFactory2             = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
 	static const GUID IID_IDXGIFactory2             = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
 	static const GUID IID_IDXGIFactory4             = { 0x1bc6ea02, 0xef36, 0x464f, { 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a } };
 	static const GUID IID_IDXGIFactory4             = { 0x1bc6ea02, 0xef36, 0x464f, { 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a } };
+	static const GUID IID_IDXGIOutput6              = { 0x068346e8, 0xaaec, 0x4b84, { 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1 } };
+
 
 
 	BX_PRAGMA_DIAGNOSTIC_POP();
 	BX_PRAGMA_DIAGNOSTIC_POP();
 
 
@@ -1050,6 +1084,40 @@ namespace bgfx { namespace d3d12
 				}
 				}
 			}
 			}
 
 
+			{
+				IDXGIOutput* output;
+				hr = m_swapChain->GetContainingOutput(&output);
+				if (SUCCEEDED(hr) )
+				{
+					IDXGIOutput6* output6;
+					hr = output->QueryInterface(IID_IDXGIOutput6, (void**)&output6);
+					if (SUCCEEDED(hr) )
+					{
+						DXGI_OUTPUT_DESC1 desc;
+						hr = output6->GetDesc1(&desc);
+						if (SUCCEEDED(hr) )
+						{
+							BX_TRACE("Display specs:")
+							BX_TRACE("\t         BitsPerColor: %d", desc.BitsPerColor);
+							BX_TRACE("\t          Color space: %s (colorspace, range, gamma, sitting, primaries, transform)"
+								, s_colorSpace[bx::min<uint32_t>(desc.ColorSpace, DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020+1)]
+								);
+							BX_TRACE("\t           RedPrimary: %f, %f", desc.RedPrimary[0],   desc.RedPrimary[1]);
+							BX_TRACE("\t         GreenPrimary: %f, %f", desc.GreenPrimary[0], desc.GreenPrimary[1]);
+							BX_TRACE("\t          BluePrimary: %f, %f", desc.BluePrimary[0],  desc.BluePrimary[1]);
+							BX_TRACE("\t           WhitePoint: %f, %f", desc.WhitePoint[0],   desc.WhitePoint[1]);
+							BX_TRACE("\t         MinLuminance: %f", desc.MinLuminance);
+							BX_TRACE("\t         MaxLuminance: %f", desc.MaxLuminance);
+							BX_TRACE("\tMaxFullFrameLuminance: %f", desc.MaxFullFrameLuminance);
+						}
+
+						DX_RELEASE(output6, 1);
+					}
+
+					DX_RELEASE(output, 0);
+				}
+			}
+
 			m_presentElapsed = 0;
 			m_presentElapsed = 0;
 
 
 			{
 			{