Бранимир Караџић před 5 roky
rodič
revize
4f3d1875e6
1 změnil soubory, kde provedl 31 přidání a 16 odebrání
  1. 31 16
      src/renderer_vk.cpp

+ 31 - 16
src/renderer_vk.cpp

@@ -1304,13 +1304,13 @@ VK_IMPORT_DEVICE
 
 			m_vulkan1Dll = bx::dlopen(
 #if BX_PLATFORM_WINDOWS
-					"vulkan-1.dll"
+				"vulkan-1.dll"
 #elif BX_PLATFORM_ANDROID
-					"libvulkan.so"
+				"libvulkan.so"
 #elif BX_PLATFORM_OSX
-					"libvulkan.dylib"
+				"libvulkan.dylib"
 #else
-					"libvulkan.so.1"
+				"libvulkan.so.1"
 #endif // BX_PLATFORM_*
 					);
 
@@ -1375,10 +1375,12 @@ VK_IMPORT
 				for (uint32_t ii = 0; ii < Extension::Count; ++ii)
 				{
 					const Extension& extension = s_extension[ii];
+					const LayerInfo& layerInfo = s_layer[extension.m_layer].m_instance;
 
-					bool layerEnabled = extension.m_layer == Layer::Count ||
-										(s_layer[extension.m_layer].m_instance.m_supported &&
-										 s_layer[extension.m_layer].m_instance.m_initialize);
+					const bool layerEnabled = false
+						|| extension.m_layer == Layer::Count
+						|| (layerInfo.m_supported && layerInfo.m_initialize)
+						;
 
 					if (extension.m_supported
 					&&  extension.m_initialize
@@ -1842,18 +1844,20 @@ VK_IMPORT_DEVICE
 				if (VK_SUCCESS != result)
 				{
 					void* xcbdll = bx::dlopen("libX11-xcb.so.1");
+
 					if (NULL != xcbdll)
 					{
 						typedef xcb_connection_t* (*PFN_XGETXCBCONNECTION)(Display*);
 						PFN_XGETXCBCONNECTION XGetXCBConnection = (PFN_XGETXCBCONNECTION)bx::dlsym(xcbdll, "XGetXCBConnection");
 
+						union { void* ptr; xcb_window_t window; } cast = { g_platformData.nwh };
+
 						VkXcbSurfaceCreateInfoKHR sci;
-						sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
-						sci.pNext = NULL;
+						sci.sType      = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+						sci.pNext      = NULL;
 						sci.flags      = 0;
 						sci.connection = XGetXCBConnection( (Display*)g_platformData.ndt);
-						union { void* ptr; xcb_window_t window; } cast = { g_platformData.nwh };
-						sci.window = cast.window;
+						sci.window     = cast.window;
 						result = vkCreateXcbSurfaceKHR(m_instance, &sci, m_allocatorCb, &m_surface);
 
 						bx::dlclose(xcbdll);
@@ -1864,13 +1868,17 @@ VK_IMPORT_DEVICE
 			{
 				if (NULL != vkCreateMacOSSurfaceMVK)
 				{
-					NSWindow* window = (NSWindow*)(g_platformData.nwh);
+					NSWindow* window    = (NSWindow*)(g_platformData.nwh);
 					NSView* contentView = (NSView*)window.contentView;
 					CAMetalLayer* layer = [CAMetalLayer layer];
+
 					if (_init.resolution.reset & BGFX_RESET_HIDPI)
+					{
 						layer.contentsScale = [window backingScaleFactor];
-					[contentView setWantsLayer : YES] ;
-					[contentView setLayer : layer] ;
+					}
+
+					[contentView setWantsLayer : YES];
+					[contentView setLayer : layer];
 
 					VkMacOSSurfaceCreateInfoMVK sci;
 					sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
@@ -1879,6 +1887,10 @@ VK_IMPORT_DEVICE
 					sci.pView = (__bridge void*)layer;
 					result = vkCreateMacOSSurfaceMVK(m_instance, &sci, m_allocatorCb, &m_surface);
 				}
+				else
+				{
+					result = VK_RESULT_MAX_ENUM;
+				}
 			}
 #else
 #	error "Figure out KHR surface..."
@@ -6762,12 +6774,15 @@ BX_UNUSED(presentMin, presentMax);
 			beginRenderPass = false;
 		}
 
-		setImageMemoryBarrier(m_commandBuffer
+		setImageMemoryBarrier(
+			  m_commandBuffer
 			, m_backBufferColorImage[m_backBufferColorIdx]
 			, VK_IMAGE_ASPECT_COLOR_BIT
 			, m_backBufferColorImageLayout[m_backBufferColorIdx]
 			, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
-			, 1, 1);
+			, 1
+			, 1
+			);
 		m_backBufferColorImageLayout[m_backBufferColorIdx] = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
 
 		VK_CHECK(vkEndCommandBuffer(m_commandBuffer) );