Skip to content
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

Merged
merged 4 commits into from
Nov 28, 2024

Conversation

water-chika
Copy link
Contributor

@water-chika water-chika commented Nov 5, 2024

Add condition to filter if the GPU support the surface.
Solve #950

@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg
Copy link

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) {
Copy link
Contributor Author

@water-chika water-chika Nov 5, 2024

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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg
Copy link

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

Copy link
Contributor

@charles-lunarg charles-lunarg left a 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.
@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg
Copy link

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) {
Copy link
Contributor Author

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.

@water-chika water-chika changed the title vkcube: Check if GPU support the surface vkcube and vkcubepp: Check if GPU support the surface Nov 6, 2024
@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

@water-chika
Copy link
Contributor Author

Only thing I would suggest doing is porting the changes over to cube.cpp so the C++ version has the same functionality.

I have ported the changes over to vkcubepp.

@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg
Copy link

Author water-chika not on autobuild list. Waiting for curator authorization before starting CI build.

Copy link
Contributor

@charles-lunarg charles-lunarg left a 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().

@charles-lunarg charles-lunarg merged commit a2224ab into KhronosGroup:main Nov 28, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants