PDA

View Full Version : Vulkan / GLFW init error



PadMad
09-07-2016, 03:14 AM
--------------------
g++ 5.4.0
--------------------
GNU Make 4.1
--------------------
GLFW 3.2.1
--------------------
Vulkan 1.0.8
--------------------
Ubuntu 16.04
--------------------

hey,

I know it's OpenGL here... but there aren't really vulkan forums on the net, so I hope it's okay...

I started a vulkan project and I use glfw for window / surface stuff. everything works great so far but when I try to create a surface via glfwCreateWindowSurface() I recieve the following error:

"Vulkan: Window surface creation extensions not found"

glfwGetRequiredInstanceExtensions() returns NULL, and number of extensions is 0. So I know thats the exact error.

this is the window creation code:



int cDEcore::DEcore_create_window(const char * ptitle)
{
int exit_code = DE_NO_ERROR;
GLFWmonitor * pprimary = NULL;
int glfw_major_v = 0;
int glfw_minor_v = 0;
int glfw_rev = 0;

#ifdef DE_DEBUG
glfwGetVersion(&glfw_major_v, &glfw_minor_v, &glfw_rev);
cout << "glfw version: (" << glfw_major_v << "." << glfw_minor_v << "." << glfw_rev << ")" << endl;
#endif

if(glfwInit() != GLFW_TRUE)
{
exit_code = DE_GLFW_FAILED;

#ifdef DE_DEBUG
if(!exit_code)
{cout << "glfwInit() failed!" << endl;}
#endif
}

if(!exit_code)
{
if(!glfwVulkanSupported())
{
exit_code = DE_GLFW_VK_SUPPORT;

#ifdef DE_DEBUG
cout << "glfw: vulkan not supported!" << endl;
#endif
}
}

if(!exit_code)
{glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);}

if(!exit_code)
{
pprimary = glfwGetPrimaryMonitor();

if(pprimary != NULL)
{
const GLFWvidmode * pmode = glfwGetVideoMode(pprimary);

if(pmode != NULL)
{
glfwWindowHint(GLFW_RED_BITS, pmode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, pmode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, pmode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, pmode->refreshRate);

this->pwindow = glfwCreateWindow(pmode->width, pmode->height, ptitle, pprimary, NULL);

if(this->pwindow == NULL)
{
exit_code = DE_CREATE_WND;

#ifdef DE_DEBUG
if(!exit_code)
{cout << "glfwCreateWindow() failed!" << endl;}
#endif
}
}
else
{
exit_code = DE_VIDEO_MODE;

#ifdef DE_DEBUG
if(!exit_code)
{cout << "glfwGetVideoMode() failed!" << endl;}
#endif
}
}
else
{
exit_code = DE_NOPRIM_MONITOR;

#ifdef DE_DEBUG
if(!exit_code)
{cout << "no primary monitor found!" << endl;}
#endif
}
}

return exit_code;
}


this is the vk instance creation code:



int cDEcore::DEcore_init_vk_instance(const char * papp_name)
{
int exit_code = DE_NO_ERROR;
unsigned int num_extensions = 0;
const char ** ppextensions = NULL;

// instance

this->vk_app_info = {};
this->vk_app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
this->vk_app_info.pApplicationName = papp_name;
this->vk_app_info.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
this->vk_app_info.pEngineName = "Dycon Engine";
this->vk_app_info.engineVersion = VK_MAKE_VERSION(1, 0, 0);
this->vk_app_info.apiVersion = VK_API_VERSION_1_0;
this->vk_app_info.pNext = NULL;

this->vk_instance_info = {};
this->vk_instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
this->vk_instance_info.pApplicationInfo = &(this->vk_app_info);
ppextensions = glfwGetRequiredInstanceExtensions(&num_extensions);

if(ppextensions == NULL)
{
exit_code = DE_NO_EXTENSIONS;

#ifdef DE_DEBUG
cout << "no extensions loaded for instance!" << endl;
#endif
}

this->vk_instance_info.enabledExtensionCount = num_extensions;
this->vk_instance_info.ppEnabledExtensionNames = ppextensions;
this->vk_instance_info.enabledLayerCount = 0;
this->vk_instance_info.flags = 0;
this->vk_instance_info.pNext = NULL;

if(!exit_code)
{
if(vkCreateInstance(&(this->vk_instance_info), nullptr, &(this->vk_instance)) != VK_SUCCESS)
{
exit_code = DE_VK_INSTANCE;

#ifdef DE_DEBUG
cout << "vkCreateInstance() failed!" << endl;
#endif
}
}

return exit_code;
}


this is the surface creation call:



int cDEcore::DEcore_init_vulkan(const char * papp_name)
{
int exit_code = DE_NO_ERROR;

exit_code = this->DEcore_init_vk_instance(papp_name);

if(!exit_code)
{
if(glfwCreateWindowSurface(this->vk_instance, this->pwindow, nullptr, &(this->surface)) != VK_SUCCESS)
{
exit_code = DE_SURFACE;

#ifdef DE_DEBUG
cout << "failed to create surface!" << endl;
#endif
}
}

if(!exit_code)
{exit_code = this->DEcore_init_physical_device();}

if(!exit_code)
{exit_code = this->DEcore_init_logical_device();}

return exit_code;
}


All 3 functions are called in the order I mentioned them. So the strange thing is:
- glfwVulkanSupported() returns true!
- vkEnumerateInstanceExtensionProperties() gives an output of:
VK_KHR_surface
VK_KHR_xcb_surface
VK_EXT_debug_report

So the extension I need is there (VK_KHR_surface)! I read the glfw reference of glfwGetRequiredInstanceExtensions() and it doesn't offer any help really, 'cause everything that could fail, works... the only thing mentioned on the reference page is:


If Vulkan is available but no set of extensions allowing window surface creation was found, this function returns NULL. You may still use Vulkan for off-screen rendering and compute work.

... okay... but I do want to render on-screen :dejection:
So any help or guesses?

Vulkan examples in the SDK do work!

Silence
09-07-2016, 04:11 AM
I know it's OpenGL here... but there aren't really vulkan forums on the net, so I hope it's okay...

Maybe this one (https://forums.khronos.org/forumdisplay.php/114-Vulkan-High-Efficiency-GPU-Graphics-and-Compute) ?

MrLGarcia
12-01-2016, 05:25 PM
Hey mate, I've the same error. Did you find the solution?