From e77895ee039c0723a911acc838c2ec924d1f69e3 Mon Sep 17 00:00:00 2001 From: Xuelian Bai Date: Thu, 24 Mar 2022 14:06:14 +0800 Subject: [PATCH] Fix building errors from TV 1. Fix -Werror=shadow in cube.cpp 2. Ignore other errors in vulkaninfo.h Change-Id: I479267a9582e7786e22f5b04b21e523e7e2e4428 Signed-off-by: Xuelian Bai Upgrade to v1.3.208 Change-Id: I59a7e25b26f42a2fcf43dedd84d982c53e13ede3 Fix vkcube issue xdg-wm-base isn't supported by e20, so replace it by wl_shell Change-Id: Ic0c84d9ce301ed6c44995ad181318b9a79fdf919 Signed-off-by: Xuelian Bai Fix build error Fix following error: /home/abuild/rpmbuild/BUILD/vulkan-tools-1.3.208/cube/ xdg-decoration-client-header.h:79:1: error: unterminated comment Change-Id: I10fb5f7ed92d37beccaab33a349bae50232b677e Signed-off-by: Xuelian Bai --- CMakeLists.txt | 2 ++ cube/cube.c | 82 ++++++++++++++++++++++----------------------- cube/cube.cpp | 78 +++++++++++++++++++++++++++++------------- packaging/vulkan-tools.spec | 8 ++--- 4 files changed, 101 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9821a42..e9df00c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,8 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # "Helper" targets that don't have interesting source code should set their FOLDER property to this set(TOOLS_HELPER_FOLDER "Helper Targets") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -Wno-shadow -Wno-cast-align") + # ~~~ # Find Vulkan Headers and Loader # Search order: diff --git a/cube/cube.c b/cube/cube.c index 75d573b..99c5907 100644 --- a/cube/cube.c +++ b/cube/cube.c @@ -38,7 +38,7 @@ #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) #include #include "xdg-shell-client-header.h" -#include "xdg-decoration-client-header.h" +//#include "xdg-decoration-client-header.h" #endif #ifdef _WIN32 @@ -345,12 +345,13 @@ struct demo { struct xdg_wm_base *xdg_wm_base; struct zxdg_decoration_manager_v1 *xdg_decoration_mgr; struct zxdg_toplevel_decoration_v1 *toplevel_decoration; - struct xdg_surface *xdg_surface; + struct wl_shell_surface *xdg_surface; int xdg_surface_has_been_configured; struct xdg_toplevel *xdg_toplevel; struct wl_seat *seat; struct wl_pointer *pointer; struct wl_keyboard *keyboard; + struct wl_shell *shell; #elif defined(VK_USE_PLATFORM_DIRECTFB_EXT) IDirectFB *dfb; IDirectFBSurface *window; @@ -2470,14 +2471,14 @@ static void demo_cleanup(struct demo *demo) { if (demo->keyboard) wl_keyboard_destroy(demo->keyboard); if (demo->pointer) wl_pointer_destroy(demo->pointer); if (demo->seat) wl_seat_destroy(demo->seat); - xdg_toplevel_destroy(demo->xdg_toplevel); - xdg_surface_destroy(demo->xdg_surface); + //xdg_toplevel_destroy(demo->xdg_toplevel); + //xdg_surface_destroy(demo->xdg_surface); wl_surface_destroy(demo->window); - xdg_wm_base_destroy(demo->xdg_wm_base); + /*xdg_wm_base_destroy(demo->xdg_wm_base); if (demo->xdg_decoration_mgr) { zxdg_toplevel_decoration_v1_destroy(demo->toplevel_decoration); zxdg_decoration_manager_v1_destroy(demo->xdg_decoration_mgr); - } + }*/ wl_compositor_destroy(demo->compositor); wl_registry_destroy(demo->registry); wl_display_disconnect(demo->display); @@ -2858,41 +2859,28 @@ static void demo_run(struct demo *demo) { } } -static void handle_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) { - struct demo *demo = (struct demo *)data; - xdg_surface_ack_configure(xdg_surface, serial); - if (demo->xdg_surface_has_been_configured) { - demo_resize(demo); - } - demo->xdg_surface_has_been_configured = 1; + +static void PingCb(void *data, struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); } -static const struct xdg_surface_listener xdg_surface_listener = {handle_surface_configure}; +static void ConfigureCb(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ -static void handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel UNUSED, int32_t width, int32_t height, - struct wl_array *states UNUSED) { - struct demo *demo = (struct demo *)data; - /* zero values imply the program may choose its own size, so in that case - * stay with the existing value (which on startup is the default) */ - if (width > 0) { - demo->width = width; - } - if (height > 0) { - demo->height = height; - } - /* This should be followed by a surface configure */ } -static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel UNUSED) { - struct demo *demo = (struct demo *)data; - demo->quit = true; +static void PopupDoneCb(void *data, struct wl_shell_surface *shell_surface) +{ + } -static const struct xdg_toplevel_listener xdg_toplevel_listener = {handle_toplevel_configure, handle_toplevel_close}; static void demo_create_window(struct demo *demo) { - if (!demo->xdg_wm_base) { - printf("Compositor did not provide the standard protocol xdg-wm-base\n"); + if (!demo->shell) { + printf("Compositor did not provide the standard protocol\n"); fflush(stdout); exit(1); } @@ -2904,7 +2892,14 @@ static void demo_create_window(struct demo *demo) { exit(1); } - demo->xdg_surface = xdg_wm_base_get_xdg_surface(demo->xdg_wm_base, demo->window); + demo->xdg_surface = wl_shell_get_shell_surface(demo->shell, + demo->window); + static const struct wl_shell_surface_listener shell_surface_listener = + {PingCb, ConfigureCb, PopupDoneCb}; + wl_shell_surface_add_listener(demo->xdg_surface, &shell_surface_listener, demo); + wl_shell_surface_set_toplevel(demo->xdg_surface); + wl_shell_surface_set_title(demo->xdg_surface, APP_SHORT_NAME); + /*demo->xdg_surface = xdg_wm_base_get_xdg_surface(demo->xdg_wm_base, demo->window); if (!demo->xdg_surface) { printf("Can not get xdg_surface from wayland_surface!\n"); fflush(stdout); @@ -2924,7 +2919,7 @@ static void demo_create_window(struct demo *demo) { demo->toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(demo->xdg_decoration_mgr, demo->xdg_toplevel); zxdg_toplevel_decoration_v1_set_mode(demo->toplevel_decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } + }*/ wl_surface_commit(demo->window); } @@ -3899,7 +3894,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uin uint32_t state) { struct demo *demo = data; if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) { - xdg_toplevel_move(demo->xdg_toplevel, demo->seat, serial); + //xdg_toplevel_move(demo->xdg_toplevel, demo->seat, serial); } } @@ -3967,11 +3962,11 @@ static const struct wl_seat_listener seat_listener = { seat_handle_capabilities, }; -static void wm_base_ping(void *data UNUSED, struct xdg_wm_base *xdg_wm_base, uint32_t serial) { +/*static void wm_base_ping(void *data UNUSED, struct xdg_wm_base *xdg_wm_base, uint32_t serial) { xdg_wm_base_pong(xdg_wm_base, serial); } -static const struct xdg_wm_base_listener wm_base_listener = {wm_base_ping}; +static const struct xdg_wm_base_listener wm_base_listener = {wm_base_ping};*/ static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version UNUSED) { @@ -3984,15 +3979,20 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uin fprintf(stderr, "Wayland compositor doesn't support VK_KHR_incremental_present, disabling.\n"); demo->VK_KHR_incremental_present_enabled = false; } - } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) { + } else if (strcmp(interface, "wl_shell") == 0) + { + demo->shell = (struct wl_shell *)wl_registry_bind(registry, id, + &wl_shell_interface, 1); + } + /*else if (strcmp(interface, xdg_wm_base_interface.name) == 0) { demo->xdg_wm_base = wl_registry_bind(registry, id, &xdg_wm_base_interface, 1); xdg_wm_base_add_listener(demo->xdg_wm_base, &wm_base_listener, NULL); - } else if (strcmp(interface, wl_seat_interface.name) == 0) { + } */else if (strcmp(interface, wl_seat_interface.name) == 0) { demo->seat = wl_registry_bind(registry, id, &wl_seat_interface, 1); wl_seat_add_listener(demo->seat, &seat_listener, demo); - } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { + } /*else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { demo->xdg_decoration_mgr = wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1); - } + }*/ } static void registry_handle_global_remove(void *data UNUSED, struct wl_registry *registry UNUSED, uint32_t name UNUSED) {} diff --git a/cube/cube.cpp b/cube/cube.cpp index ff24b5d..4a53103 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -24,7 +24,7 @@ #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) #include #include "xdg-shell-client-header.h" -#include "xdg-decoration-client-header.h" +//#include "xdg-decoration-client-header.h" #endif #include @@ -307,15 +307,17 @@ struct Demo { wl_registry *registry = nullptr; wl_compositor *compositor = nullptr; wl_surface *window = nullptr; - xdg_wm_base *wm_base = nullptr; - zxdg_decoration_manager_v1 *xdg_decoration_mgr = nullptr; - zxdg_toplevel_decoration_v1 *toplevel_decoration = nullptr; - xdg_surface *window_surface = nullptr; + //xdg_wm_base *wm_base = nullptr; + //zxdg_decoration_manager_v1 *xdg_decoration_mgr = nullptr; + //zxdg_toplevel_decoration_v1 *toplevel_decoration = nullptr; + //xdg_surface *window_surface = nullptr; bool xdg_surface_has_been_configured = false; - xdg_toplevel *window_toplevel = nullptr; + //xdg_toplevel *window_toplevel = nullptr; wl_seat *seat = nullptr; wl_pointer *pointer = nullptr; wl_keyboard *keyboard = nullptr; + wl_shell *shell; + wl_shell_surface *window_surface; #elif defined(VK_USE_PLATFORM_DIRECTFB_EXT) IDirectFB *dfb = nullptr; IDirectFBSurface *window = nullptr; @@ -435,9 +437,9 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer, uint32 static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { - Demo &demo = *static_cast(data); + //Demo &demo = *static_cast(data); if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) { - xdg_toplevel_move(demo.window_toplevel, demo.seat, serial); + //xdg_toplevel_move(demo.window_toplevel, demo.seat, serial); } } @@ -514,16 +516,19 @@ static void registry_handle_global(void *data, wl_registry *registry, uint32_t i // pickup wayland objects when they appear if (strcmp(interface, wl_compositor_interface.name) == 0) { demo.compositor = (wl_compositor *)wl_registry_bind(registry, id, &wl_compositor_interface, 1); - } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) { + } else if (strcmp(interface, "wl_shell") == 0) { + demo.shell = (struct wl_shell *)wl_registry_bind(registry, id, + &wl_shell_interface, 1); + } /*else if (strcmp(interface, xdg_wm_base_interface.name) == 0) { demo.wm_base = (xdg_wm_base *)wl_registry_bind(registry, id, &xdg_wm_base_interface, 1); xdg_wm_base_add_listener(demo.wm_base, &wm_base_listener, nullptr); - } else if (strcmp(interface, wl_seat_interface.name) == 0) { + } */else if (strcmp(interface, wl_seat_interface.name) == 0) { demo.seat = (wl_seat *)wl_registry_bind(registry, id, &wl_seat_interface, 1); wl_seat_add_listener(demo.seat, &seat_listener, &demo); - } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { + } /*else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { demo.xdg_decoration_mgr = (zxdg_decoration_manager_v1 *)wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1); - } + }*/ } static void registry_handle_global_remove(void *data, wl_registry *registry, uint32_t name) {} @@ -604,14 +609,15 @@ void Demo::cleanup() { if (keyboard) wl_keyboard_destroy(keyboard); if (pointer) wl_pointer_destroy(pointer); if (seat) wl_seat_destroy(seat); - xdg_toplevel_destroy(window_toplevel); - xdg_surface_destroy(window_surface); + //xdg_toplevel_destroy(window_toplevel); + //xdg_surface_destroy(window_surface); + wl_shell_surface_destroy(window_surface); wl_surface_destroy(window); - xdg_wm_base_destroy(wm_base); + /*xdg_wm_base_destroy(wm_base); if (xdg_decoration_mgr) { zxdg_toplevel_decoration_v1_destroy(toplevel_decoration); zxdg_decoration_manager_v1_destroy(xdg_decoration_mgr); - } + }*/ wl_compositor_destroy(compositor); wl_registry_destroy(registry); wl_display_disconnect(display); @@ -2425,7 +2431,7 @@ void Demo::update_data_buffer() { /* Convert ppm image data from header file into RGBA texture image */ #include "lunarg.ppm.h" -bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::SubresourceLayout &layout, uint32_t &width, uint32_t &height) { +bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::SubresourceLayout &layout, uint32_t &w, uint32_t &h) { (void)filename; char *cPtr; cPtr = (char *)lunarg_ppm; @@ -2434,7 +2440,7 @@ bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::Subresource } while (strncmp(cPtr++, "\n", 1)) ; - sscanf(cPtr, "%u %u", &width, &height); + sscanf(cPtr, "%u %u", &w, &h); if (rgba_data == nullptr) { return true; } @@ -2445,9 +2451,9 @@ bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::Subresource } while (strncmp(cPtr++, "\n", 1)) ; - for (uint32_t y = 0; y < height; y++) { + for (uint32_t y = 0; y < h; y++) { uint8_t *rowPtr = rgba_data; - for (uint32_t x = 0; x < width; x++) { + for (uint32_t x = 0; x < w; x++) { memcpy(rowPtr, cPtr, 3); rowPtr[3] = 255; /* Alpha of 1 */ rowPtr += 4; @@ -2801,9 +2807,26 @@ static void handle_toplevel_close(void *data, xdg_toplevel *xdg_toplevel) { static const xdg_toplevel_listener toplevel_listener = {handle_toplevel_configure, handle_toplevel_close}; +static void PingCb(void *data, struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); +} + +static void ConfigureCb(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ + +} + +static void PopupDoneCb(void *data, struct wl_shell_surface *shell_surface) +{ + +} + void Demo::create_window() { - if (!wm_base) { - printf("Compositor did not provide the standard protocol xdg-wm-base\n"); + if (!shell) { + printf("Compositor did not provide the standard protocol\n"); fflush(stdout); exit(1); } @@ -2815,7 +2838,14 @@ void Demo::create_window() { exit(1); } - window_surface = xdg_wm_base_get_xdg_surface(wm_base, window); + window_surface = wl_shell_get_shell_surface(shell, window); + static const struct wl_shell_surface_listener shell_surface_listener = + {PingCb, ConfigureCb, PopupDoneCb}; + wl_shell_surface_add_listener(window_surface, &shell_surface_listener, this); + wl_shell_surface_set_toplevel(window_surface); + wl_shell_surface_set_title(window_surface, APP_SHORT_NAME); + + /*window_surface = xdg_wm_base_get_xdg_surface(wm_base, window); if (!window_surface) { printf("Can not get xdg_surface from wayland_surface!\n"); fflush(stdout); @@ -2834,7 +2864,7 @@ void Demo::create_window() { // if supported, let the compositor render titlebars for us toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(xdg_decoration_mgr, window_toplevel); zxdg_toplevel_decoration_v1_set_mode(toplevel_decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } + }*/ wl_surface_commit(window); } diff --git a/packaging/vulkan-tools.spec b/packaging/vulkan-tools.spec index 34b86a3..69ccf2d 100644 --- a/packaging/vulkan-tools.spec +++ b/packaging/vulkan-tools.spec @@ -1,5 +1,5 @@ Name: vulkan-tools -Version: 1.2.179 +Version: 1.3.208 Release: 0 Summary: Vulkan tools Group: Graphics & UI Framework/GL @@ -17,6 +17,7 @@ BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-cursor) BuildRequires: pkgconfig(wayland-server) BuildRequires: pkgconfig(wayland-egl) +BuildRequires: pkgconfig(wayland-protocols) %define BUILD_TYPE Debug @@ -33,8 +34,8 @@ cmake -DCMAKE_BUILD_TYPE=%{BUILD_TYPE} -DGLSLANG_INSTALL_DIR=%{_bindir} \ -DBUILD_WSI_XLIB_SUPPORT=OFF -DBUILD_WSI_XCB_SUPPORT=OFF -DBUILD_WSI_WAYLAND_SUPPORT=ON \ -DCUBE_WSI_SELECTION=WAYLAND \ -DCMAKE_INSTALL_LIBDIR=%{_libdir} -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \ - -DCMAKE_INSTALL_DATADIR=%{_datadir} -DCMAKE_INSTALL_BINDIR=%{_bindir} -make + -DCMAKE_INSTALL_DATADIR=%{_datadir} -DCMAKE_INSTALL_BINDIR=%{_bindir} . +make -j6 %install rm -rf %{buildroot} @@ -47,4 +48,3 @@ rm -rf %{buildroot} %license LICENSE.txt %defattr(-,root,root,-) %{_bindir}/* - -- 2.7.4