Commit 9376f84
Changed files (4)
libgogvk/gogvid.c
@@ -5,6 +5,8 @@
#include <string.h>
#include <vulkan/vulkan_core.h>
+
+
gog_result gog_graphics_init(gog_graphics_hndl *gh)
{
struct gog_vk_ext extensions;
@@ -14,10 +16,15 @@ gog_result gog_graphics_init(gog_graphics_hndl *gh)
gog_vulkan_init(&gh->vk_instance, extensions, 0);
//get surface
SDL_Vulkan_CreateSurface(gh->sdl_window_p, gh->vk_instance, &gh->vk_surface);
+
+ gog_device_init(gh,extensions);
//get phizical device
//gog_get_physical_device(gh, extensions, VK_QUEUE_GRAPHICS_BIT);
//get logical device plus queues
//gog_get_logical_device();
+
+ return GET_GOG_RESULT(GOG_SUCCES, 0);
+}
//swapchain
//load shaders into memory
//create pipelines
@@ -25,9 +32,6 @@ gog_result gog_graphics_init(gog_graphics_hndl *gh)
//command buffer
//uniforms
//descriptor sets / texture loading
-
- return GET_GOG_RESULT(GOG_SUCCES, 0);
-}
gog_result gog_graphics_update(int flags)
{
@@ -87,7 +91,7 @@ gog_result gog_vulkan_init(VkInstance * instance, struct gog_vk_ext extensions,
return GET_GOG_RESULT(GOG_SUCCES,result);
}
-gog_result gog_device_init(gog_graphics_hndl *gh, struct gog_vk_ext gog_ext, int queue_flags)
+gog_result gog_device_init(gog_graphics_hndl *gh, struct gog_vk_ext gog_ext)
{
unsigned int gpu_num;
VkPhysicalDeviceProperties gpu_prop;
@@ -109,21 +113,24 @@ gog_result gog_device_init(gog_graphics_hndl *gh, struct gog_vk_ext gog_ext, int
vkGetPhysicalDeviceQueueFamilyProperties(gpu_list[i],&queue_num,NULL);
VkQueueFamilyProperties queue_properties_list[queue_num];
vkGetPhysicalDeviceQueueFamilyProperties(gpu_list[i], &queue_num, queue_properties_list);
- if(gog_verify_device_queues(queue_properties_list,queue_num,queue_flags).status==GOG_FAIL)
+ if(gog_find_device_queues(gh,queue_properties_list,queue_num).status==GOG_FAIL)
{
continue;
}
- for(int j=0;j<queue_num;j++);
-
- if(vkGetPhysicalDeviceSurfaceSupportKHR(gpu_list[i], , , ))
+ VkBool32 present_support=0;
+ gh->vk_queue_index_present=-1;
+ for(int j=0;j<queue_num;j++)
{
- continue;
- }
- else
- {
- gh->vk_gpu=gpu_list[i];
- printf("valid gpu: %s\n",gpu_prop.deviceName);
- }
+ vkGetPhysicalDeviceSurfaceSupportKHR(gpu_list[i], j, gh->vk_surface,&present_support);
+ if(present_support)
+ {
+ gh->vk_queue_index_present=j;
+ continue;
+ }
+ }
+ gh->vk_gpu=gpu_list[i];
+ printf("valid gpu: %s\n",gpu_prop.deviceName);
+
}
return GET_GOG_RESULT(GOG_SUCCES, 0);
}
@@ -148,7 +155,6 @@ gog_result gog_verify_device_extensions(struct gog_vk_ext gog_ext,VkExtensionPro
gog_result gog_find_device_queues(gog_graphics_hndl *gh, VkQueueFamilyProperties * queue_prop_p, int queue_prop_count)
{
-
gh->vk_queue_index_graphics=-1;
gh->vk_queue_index_compute=-1;
gh->vk_queue_index_transfer=-1;
libgogvk/gogvid.h
@@ -38,6 +38,7 @@ typedef struct vk_graphics_vars
int32_t vk_queue_index_compute;
int32_t vk_queue_index_transfer;
int32_t vk_queue_index_sparse_binding;
+ int32_t vk_queue_index_present;
int32_t vk_queues_c;
VkQueue * vk_queues_p;
VkSwapchainKHR vk_swapchain;
@@ -60,4 +61,5 @@ gog_result gog_vulkan_init(VkInstance * instance, struct gog_vk_ext extensions,
gog_result gog_get_physical_device(gog_graphics_hndl *gh, struct gog_vk_ext ext, int flags);
gog_result gog_verify_device_extensions(struct gog_vk_ext gog_ext,VkExtensionProperties *ext, int ext_count);
gog_result gog_find_device_queues(gog_graphics_hndl *gh, VkQueueFamilyProperties * queue_prop_p, int queue_prop_count);
+gog_result gog_device_init(gog_graphics_hndl *gh, struct gog_vk_ext gog_ext);
gog_result gog_graphics_init(gog_graphics_hndl *gh);
libgogvk.a
Binary file
main.c
@@ -11,7 +11,6 @@ int main()
SDL_Event e;
gog_graphics_hndl gh;
gog_graphics_init(&gh);
-
while(1)
{
SDL_PollEvent(&e);