-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vkcube and vkcubepp: Check if GPU support the surface #1047
Conversation
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
cube/cube.c
Outdated
|
||
static void demo_select_physical_device(struct demo* demo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seperate physical device selection to a function because we need to create surface between creating instance and selecting physical device.
cube/cube.c
Outdated
@@ -4188,7 +4191,10 @@ static void demo_init_vk(struct demo *demo) { | |||
for (uint32_t i = 0; i < gpu_count; i++) { | |||
vkGetPhysicalDeviceProperties(physical_devices[i], &physicalDeviceProperties); | |||
assert(physicalDeviceProperties.deviceType <= VK_PHYSICAL_DEVICE_TYPE_CPU); | |||
count_device_type[physicalDeviceProperties.deviceType]++; | |||
VkBool32 supported = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if GPU support the surface
@@ -4492,8 +4516,6 @@ static VkSurfaceFormatKHR pick_surface_format(const VkSurfaceFormatKHR *surfaceF | |||
static void demo_init_vk_swapchain(struct demo *demo) { | |||
VkResult U_ASSERT_ONLY err; | |||
|
|||
demo_create_surface(demo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move demo_create_surface to time between demo_init and demo_select_physical_device.
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
@@ -4868,6 +4890,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, | |||
demo.connection = hInstance; | |||
strncpy(demo.name, "Vulkan Cube", APP_NAME_STR_LEN); | |||
demo_create_window(&demo); | |||
demo_create_surface(&demo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let demo_create_surface after demo_create_window
@@ -4959,6 +4985,8 @@ static void processCommand(struct android_app *app, int32_t cmd) { | |||
for (int i = 0; i < argc; i++) free(argv[i]); | |||
|
|||
demo.window = (void *)app->window; | |||
demo_create_surface(&demo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let demo_create_surface after demo.window is inited.
@@ -5044,6 +5072,8 @@ int main(int argc, char **argv) { | |||
break; | |||
#endif | |||
} | |||
demo_create_surface(&demo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let demo_create_surface after window is created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good changes.
I was wanting these changes to be made for quite a while but never found time for it.
Only thing I would suggest doing is porting the changes over to cube.cpp so the C++ version has the same functionality.
Fix bug on checking and refine logic of selection.
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
|
||
for (uint32_t i = 0; i < gpu_count; i++) { | ||
vkGetPhysicalDeviceProperties(physical_devices[i], &physicalDeviceProperties); | ||
if (physicalDeviceProperties.deviceType == search_for_device_type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use priority to select physical device so that only one loop is needed. It will be more convenient to filter GPU if only one loop existed.
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
I have ported the changes over to vkcubepp. |
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay, the changes look good.
I went ahead and added the one nitpick I did find (not checking the return value of vkGetPhysicalDeviceSurfaceSupportKHR().
Add condition to filter if the GPU support the surface.
Solve #950