Browse Source

GL: Added vendorId identification. Issue #922.

Branimir Karadžić 9 years ago
parent
commit
6ebdf2e0c0
1 changed files with 22 additions and 0 deletions
  1. 22 0
      src/renderer_gl.cpp

+ 22 - 0
src/renderer_gl.cpp

@@ -1381,6 +1381,19 @@ namespace bgfx { namespace gl
 	};
 #endif // BGFX_CONFIG_USE_OVR
 
+	struct VendorId
+	{
+		const char* name;
+		uint16_t id;
+	};
+
+	static const VendorId s_vendorIds[] =
+	{
+		{ "NVIDIA Corporation",           BGFX_PCI_ID_NVIDIA },
+		{ "Advanced Micro Devices, Inc.", BGFX_PCI_ID_AMD    },
+		{ "Intel",                        BGFX_PCI_ID_INTEL  },
+	};
+
 	struct RendererContextGL : public RendererContextI
 	{
 		RendererContextGL()
@@ -1441,6 +1454,15 @@ namespace bgfx { namespace gl
 			m_version     = getGLString(GL_VERSION);
 			m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
 
+			for (uint32_t ii = 0; ii < BX_COUNTOF(s_vendorIds); ++ii)
+			{
+				const VendorId& vendorId = s_vendorIds[ii];
+				if (0 == strncmp(vendorId.name, m_vendor, strlen(vendorId.name) ) )
+				{
+					g_caps.vendorId = vendorId.id;
+				}
+			}
+
 			GLint numCmpFormats = 0;
 			GL_CHECK(glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCmpFormats) );
 			BX_TRACE("GL_NUM_COMPRESSED_TEXTURE_FORMATS %d", numCmpFormats);