Бранимир Караџић %!s(int64=5) %!d(string=hai) anos
pai
achega
d1685a366a
Modificáronse 4 ficheiros con 34 adicións e 28 borrados
  1. 2 2
      src/glcontext_egl.cpp
  2. 20 14
      src/glcontext_glx.cpp
  3. 10 10
      src/glcontext_wgl.cpp
  4. 2 2
      src/renderer_vk.cpp

+ 2 - 2
src/glcontext_egl.cpp

@@ -452,7 +452,7 @@ EGL_IMPORT
 			{                                                                            \
 				if (NULL == _func)                                                       \
 				{                                                                        \
-					_func = bx::functionCast<_proto>(bx::dlsym(glesv2, #_import));       \
+					_func = bx::dlsym<_proto>(glesv2, #_import);                         \
 					BX_TRACE("\t%p " #_func " (" #_import ")", _func);                   \
 					BGFX_FATAL(_optional || NULL != _func                                \
 						, Fatal::UnableToInitialize                                      \
@@ -465,7 +465,7 @@ EGL_IMPORT
 			{                                                                            \
 				if (NULL == _func)                                                       \
 				{                                                                        \
-					_func = bx::functionCast<_proto>(eglGetProcAddress(#_import) );      \
+					_func = bx::dlsym<_proto>(eglGetProcAddress(#_import) );             \
 					BX_TRACE("\t%p " #_func " (" #_import ")", _func);                   \
 					BGFX_FATAL(_optional || NULL != _func                                \
 						, Fatal::UnableToInitialize                                      \

+ 20 - 14
src/glcontext_glx.cpp

@@ -83,6 +83,12 @@ namespace bgfx { namespace gl
 		}
 	}
 
+	template<typename ProtoT>
+	static ProtoT glXGetProcAddress(const char* _name)
+	{
+		return bx::functionCast<ProtoT>( (void*)::glXGetProcAddress( (const GLubyte*)_name) );
+	}
+
 	void GlContext::create(uint32_t _width, uint32_t _height)
 	{
 		BX_UNUSED(_width, _height);
@@ -190,7 +196,7 @@ namespace bgfx { namespace gl
 			m_context = glXCreateContext(m_display, m_visualInfo, 0, GL_TRUE);
 			BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
 
-			glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
+			glXCreateContextAttribsARB = glXGetProcAddress<PFNGLXCREATECONTEXTATTRIBSARBPROC>("glXCreateContextAttribsARB");
 
 			if (NULL != glXCreateContextAttribsARB)
 			{
@@ -230,7 +236,7 @@ namespace bgfx { namespace gl
 
 			if (haveGlxExtension("GLX_EXT_swap_control", extensions) )
 			{
-				glXSwapIntervalEXT = bx::functionCast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress( (const GLubyte*)"glXSwapIntervalEXT") );
+				glXSwapIntervalEXT = glXGetProcAddress<PFNGLXSWAPINTERVALEXTPROC>("glXSwapIntervalEXT");
 
 				if (NULL != glXSwapIntervalEXT)
 				{
@@ -243,7 +249,7 @@ namespace bgfx { namespace gl
 			if (!foundSwapControl
 			&&  haveGlxExtension("GLX_MESA_swap_control", extensions) )
 			{
-				glXSwapIntervalMESA = bx::functionCast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress( (const GLubyte*)"glXSwapIntervalMESA") );
+				glXSwapIntervalMESA = glXGetProcAddress<PFNGLXSWAPINTERVALMESAPROC>("glXSwapIntervalMESA");
 
 				if (NULL != glXSwapIntervalMESA)
 				{
@@ -256,7 +262,7 @@ namespace bgfx { namespace gl
 			if (!foundSwapControl
 			&&  haveGlxExtension("GLX_SGI_swap_control", extensions) )
 			{
-				glXSwapIntervalSGI = bx::functionCast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress( (const GLubyte*)"glXSwapIntervalSGI") );
+				glXSwapIntervalSGI = glXGetProcAddress<PFNGLXSWAPINTERVALSGIPROC>("glXSwapIntervalSGI");
 
 				if (NULL != glXSwapIntervalSGI)
 				{
@@ -362,16 +368,16 @@ namespace bgfx { namespace gl
 	{
 		BX_TRACE("Import:");
 
-#	define GL_EXTENSION(_optional, _proto, _func, _import)                                       \
-		{                                                                                        \
-			if (NULL == _func)                                                                   \
-			{                                                                                    \
-				_func = bx::functionCast<_proto>(glXGetProcAddress( (const GLubyte*)#_import) ); \
-				BX_TRACE("%p " #_func " (" #_import ")", _func);                                 \
-				BGFX_FATAL(_optional || NULL != _func                                            \
-					, Fatal::UnableToInitialize                                                  \
-					, "Failed to create OpenGL context. glXGetProcAddress %s", #_import);        \
-			}                                                                                    \
+#	define GL_EXTENSION(_optional, _proto, _func, _import)                                \
+		{                                                                                 \
+			if (NULL == _func)                                                            \
+			{                                                                             \
+				_func = glXGetProcAddress<_proto>(#_import);                              \
+				BX_TRACE("%p " #_func " (" #_import ")", _func);                          \
+				BGFX_FATAL(_optional || NULL != _func                                     \
+					, Fatal::UnableToInitialize                                           \
+					, "Failed to create OpenGL context. glXGetProcAddress %s", #_import); \
+			}                                                                             \
 		}
 
 #	include "glimports.h"

+ 10 - 10
src/glcontext_wgl.cpp

@@ -106,7 +106,7 @@ namespace bgfx { namespace gl
 		m_opengl32dll = bx::dlopen("opengl32.dll");
 		BGFX_FATAL(NULL != m_opengl32dll, Fatal::UnableToInitialize, "Failed to load opengl32.dll.");
 
-		wglGetProcAddress = bx::functionCast<PFNWGLGETPROCADDRESSPROC>(bx::dlsym(m_opengl32dll, "wglGetProcAddress");
+		wglGetProcAddress = bx::dlsym<PFNWGLGETPROCADDRESSPROC>(m_opengl32dll, "wglGetProcAddress");
 		BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
 
 
@@ -136,13 +136,13 @@ namespace bgfx { namespace gl
 
 		if (NULL != g_platformData.nwh && NULL == g_platformData.context )
 		{
-			wglMakeCurrent = bx::functionCast<PFNWGLMAKECURRENTPROC>(bx::dlsym(m_opengl32dll, "wglMakeCurrent") );
+			wglMakeCurrent = bx::dlsym<PFNWGLMAKECURRENTPROC>(m_opengl32dll, "wglMakeCurrent");
 			BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");
 
-			wglCreateContext = bx::functionCast<PFNWGLCREATECONTEXTPROC>(bx::dlsym(m_opengl32dll, "wglCreateContext") );
+			wglCreateContext = bx::dlsym<PFNWGLCREATECONTEXTPROC>(m_opengl32dll, "wglCreateContext");
 			BGFX_FATAL(NULL != wglCreateContext, Fatal::UnableToInitialize, "Failed get wglCreateContext.");
 
-			wglDeleteContext = bx::functionCast<PFNWGLDELETECONTEXTPROC>(bx::dlsym(m_opengl32dll, "wglDeleteContext") );
+			wglDeleteContext = bx::dlsym<PFNWGLDELETECONTEXTPROC>(m_opengl32dll, "wglDeleteContext");
 			BGFX_FATAL(NULL != wglDeleteContext, Fatal::UnableToInitialize, "Failed get wglDeleteContext.");
 
 			m_hdc = GetDC( (HWND)g_platformData.nwh);
@@ -171,10 +171,10 @@ namespace bgfx { namespace gl
 
 			HGLRC context = createContext(hdc);
 
-			wglGetExtensionsStringARB  = bx::functionCast<PFNWGLGETEXTENSIONSSTRINGARBPROC>(wglGetProcAddress("wglGetExtensionsStringARB") );
-			wglChoosePixelFormatARB    = bx::functionCast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB") );
+			wglGetExtensionsStringARB  = bx::functionCast<PFNWGLGETEXTENSIONSSTRINGARBPROC >(wglGetProcAddress("wglGetExtensionsStringARB") );
+			wglChoosePixelFormatARB    = bx::functionCast<PFNWGLCHOOSEPIXELFORMATARBPROC   >(wglGetProcAddress("wglChoosePixelFormatARB") );
 			wglCreateContextAttribsARB = bx::functionCast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB") );
-			wglSwapIntervalEXT         = bx::functionCast<PFNWGLSWAPINTERVALEXTPROC>(wglGetProcAddress("wglSwapIntervalEXT") );
+			wglSwapIntervalEXT         = bx::functionCast<PFNWGLSWAPINTERVALEXTPROC        >(wglGetProcAddress("wglSwapIntervalEXT") );
 
 			if (NULL != wglGetExtensionsStringARB)
 			{
@@ -392,10 +392,10 @@ namespace bgfx { namespace gl
 		{                                                                                      \
 			if (NULL == _func)                                                                 \
 			{                                                                                  \
-				_func = bx::functionCast<_proto>(wglGetProcAddress(#_import);                  \
-				if (_func == NULL)                                                             \
+				_func = bx::functionCast<_proto>(wglGetProcAddress(#_import) );                \
+				if (NULL == _func)                                                             \
 				{                                                                              \
-					_func = bx::functionCast<_proto>(bx::dlsym(m_opengl32dll, #_import);       \
+					_func = bx::dlsym<_proto>(m_opengl32dll, #_import);                        \
 					BX_TRACE("    %p " #_func " (" #_import ")", _func);                       \
 				}                                                                              \
 				else                                                                           \

+ 2 - 2
src/renderer_vk.cpp

@@ -5193,8 +5193,8 @@ VK_DESTROY
 			m_height    = ti.height;
 			m_depth     = ti.depth;
 			m_numLayers = ti.numLayers;
-			m_requestedFormat = bgfx::TextureFormat::Enum(imageContainer.m_format);
-			m_textureFormat = getViableTextureFormat(imageContainer);
+			m_requestedFormat = uint8_t(imageContainer.m_format);
+			m_textureFormat   = uint8_t(getViableTextureFormat(imageContainer) );
 			m_format = bimg::isDepth(bimg::TextureFormat::Enum(m_textureFormat) )
 				? s_textureFormat[m_textureFormat].m_fmtDsv
 				: (m_flags & BGFX_TEXTURE_SRGB) ? s_textureFormat[m_textureFormat].m_fmtSrgb : s_textureFormat[m_textureFormat].m_fmt