Browse Source

Vulkan: Fixes for intel's anvil driver

Panagiotis Christopoulos Charitos 9 years ago
parent
commit
9dac08cbce
3 changed files with 16 additions and 7 deletions
  1. 1 1
      CMakeLists.txt
  2. 7 1
      src/core/NativeWindowSdl.cpp
  3. 8 5
      src/gr/vulkan/GrManagerImpl.cpp

+ 1 - 1
CMakeLists.txt

@@ -92,7 +92,7 @@ set(ANKI_EXTRA_LIB_DIRS CACHE STRING "Some extra lib paths (Needed for some weir
 # Valgrind
 option(ANKI_VALGRIND_HAPPY "Make valgrind happy" OFF)
 
-set(ANKI_GR_BACKEND "GL" CACHE STRING "The graphics API (GL or VK)")
+set(ANKI_GR_BACKEND "GL" CACHE STRING "The graphics API (GL or VULKAN)")
 
 if(${ANKI_GR_BACKEND} STREQUAL "GL")
 	set(GL TRUE)

+ 7 - 1
src/core/NativeWindowSdl.cpp

@@ -29,6 +29,7 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 	//
 	ANKI_LOGI("Creating SDL window");
 
+#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_GL
 	if(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, init.m_rgbaBits[0])
 		|| SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, init.m_rgbaBits[1])
 		|| SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, init.m_rgbaBits[2])
@@ -39,11 +40,16 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 		ANKI_LOGE("SDL_GL_SetAttribute() failed");
 		return ErrorCode::FUNCTION_FAILED;
 	}
+#endif
 
 	//
 	// Create window
 	//
-	U32 flags = SDL_WINDOW_OPENGL;
+	U32 flags = 0;
+
+#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_GL
+	flags |= SDL_WINDOW_OPENGL;
+#endif
 
 	if(init.m_fullscreenDesktopRez)
 	{

+ 8 - 5
src/gr/vulkan/GrManagerImpl.cpp

@@ -243,7 +243,7 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 	app.applicationVersion = 1;
 	app.pEngineName = "AnKi 3D Engine";
 	app.engineVersion = (ANKI_VERSION_MAJOR << 1) | ANKI_VERSION_MINOR;
-	app.apiVersion = VK_MAKE_VERSION(1, 0, 8);
+	app.apiVersion = VK_MAKE_VERSION(1, 0, 3);
 
 	VkInstanceCreateInfo ci = {};
 	ci.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
@@ -381,7 +381,7 @@ Error GrManagerImpl::initSwapchain(const GrManagerInitInfo& init)
 		m_physicalDevice, m_surface, &formatCount, &formats[0]));
 
 	VkColorSpaceKHR colorspace = VK_COLOR_SPACE_MAX_ENUM_KHR;
-	while(--formatCount)
+	while(formatCount--)
 	{
 		if(formats[formatCount].format == VK_FORMAT_B8G8R8A8_SRGB)
 		{
@@ -752,9 +752,12 @@ void* GrManagerImpl::reallocateCallback(void* userData,
 //==============================================================================
 void GrManagerImpl::freeCallback(void* userData, void* ptr)
 {
-	ANKI_ASSERT(userData);
-	GrManagerImpl* self = static_cast<GrManagerImpl*>(userData);
-	self->getAllocator().getMemoryPool().free(ptr);
+	if(ptr)
+	{
+		ANKI_ASSERT(userData);
+		GrManagerImpl* self = static_cast<GrManagerImpl*>(userData);
+		self->getAllocator().getMemoryPool().free(ptr);
+	}
 }
 
 //==============================================================================