diff options
Diffstat (limited to 'meta-amdfalconx86/recipes-graphics/vulkan')
8 files changed, 717 insertions, 0 deletions
diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0001-CMakeLists-add-include-path-so-Xlib.h-is-found-as-ne.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0001-CMakeLists-add-include-path-so-Xlib.h-is-found-as-ne.patch new file mode 100644 index 00000000..05fbd360 --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0001-CMakeLists-add-include-path-so-Xlib.h-is-found-as-ne.patch @@ -0,0 +1,84 @@ +From 32f2777c9cc8f7dfc8b1e0c6894191167e76d5c4 Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Tue, 16 Aug 2016 19:35:35 +0500 +Subject: [PATCH] CMakeLists: add include path so Xlib.h is found as needed + +All the targets including vk_platform.h or directly including +X11/Xlib.h require to know the directory for the installed +header. Add the directory to these so the requirements are +filled in properly. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + CMakeLists.txt | 2 ++ + demos/CMakeLists.txt | 2 +- + layers/CMakeLists.txt | 1 + + libs/vkjson/CMakeLists.txt | 1 + + loader/CMakeLists.txt | 1 + + 5 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 263002e..20e9fd6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -190,6 +190,8 @@ find_path(SPIRV_TOOLS_INCLUDE_DIR spirv-tools/libspirv.h HINTS "${EXTERNAL_SOURC + "${EXTERNAL_SOURCE_ROOT}/source/spirv-tools/external/include" + DOC "Path to spirv-tools/libspirv.h") + ++find_path(X11_XLIB_INCLUDE_DIR X11/Xlib.h DOC "Path to X11/Xlib.h") ++ + find_library(GLSLANG_LIB NAMES glslang + HINTS ${GLSLANG_SEARCH_PATH} ) + +diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt +index 26e86fb..9fdabf8 100644 +--- a/demos/CMakeLists.txt ++++ b/demos/CMakeLists.txt +@@ -92,7 +92,7 @@ if(NOT WIN32) + link_libraries(${XCB_LIBRARIES}) + endif() + if(BUILD_WSI_XLIB_SUPPORT) +- include_directories(${X11_INCLUDE_DIRS}) ++ include_directories(${X11_INCLUDE_DIRS} ${X11_XLIB_INCLUDE_DIR}) + link_libraries(${X11_LIBRARIES}) + endif() + if(BUILD_WSI_WAYLAND_SUPPORT) +diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt +index 076b847..b384803 100644 +--- a/layers/CMakeLists.txt ++++ b/layers/CMakeLists.txt +@@ -90,6 +90,7 @@ include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../loader + ${CMAKE_CURRENT_SOURCE_DIR}/../include/vulkan + ${CMAKE_CURRENT_BINARY_DIR} ++ ${X11_XLIB_INCLUDE_DIR} + ) + + if (WIN32) +diff --git a/libs/vkjson/CMakeLists.txt b/libs/vkjson/CMakeLists.txt +index fc69bb6..fe5e814 100644 +--- a/libs/vkjson/CMakeLists.txt ++++ b/libs/vkjson/CMakeLists.txt +@@ -26,6 +26,7 @@ include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../loader + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/vulkan ++ ${X11_XLIB_INCLUDE_DIR} + ) + + add_library(vkjson STATIC vkjson.cc vkjson_instance.cc ../../loader/cJSON.c) +diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt +index a4d2b21..227162c 100644 +--- a/loader/CMakeLists.txt ++++ b/loader/CMakeLists.txt +@@ -1,6 +1,7 @@ + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ++ ${X11_XLIB_INCLUDE_DIR} + ) + + if (WIN32) +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0003-obey-CMAKE_INSTALL_LIBDIR.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0003-obey-CMAKE_INSTALL_LIBDIR.patch new file mode 100644 index 00000000..3ede3bac --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0003-obey-CMAKE_INSTALL_LIBDIR.patch @@ -0,0 +1,54 @@ +From 52231c657cb1241cee099ca2626c1eebcc944e4e Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Wed, 17 Aug 2016 13:25:36 +0500 +Subject: [PATCH 1/2] obey CMAKE_INSTALL_LIBDIR + +The CMAKE_INSTALL_* directories provide a mechanism to +relocate installations so rather than doing this through +hardcoded variable they should be used whereever possible. +This fixes installation to required directory. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + layers/CMakeLists.txt | 4 ++-- + tests/layers/CMakeLists.txt | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt +index 076b847..cfab1bf 100644 +--- a/layers/CMakeLists.txt ++++ b/layers/CMakeLists.txt +@@ -81,7 +81,7 @@ else() + target_link_Libraries(VkLayer_${target} VkLayer_utils) + add_dependencies(VkLayer_${target} generate_vk_layer_helpers) + set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") +- install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging) ++ install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endmacro() + endif() + +@@ -148,7 +148,7 @@ if (WIN32) + add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) + else() + add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) +- install(TARGETS VkLayer_utils DESTINATION ${PROJECT_BINARY_DIR}/install_staging) ++ install(TARGETS VkLayer_utils DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + + add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp vk_safe_struct.cpp descriptor_sets.cpp) +diff --git a/tests/layers/CMakeLists.txt b/tests/layers/CMakeLists.txt +index 87d7793..f62e054 100644 +--- a/tests/layers/CMakeLists.txt ++++ b/tests/layers/CMakeLists.txt +@@ -49,7 +49,7 @@ else() + add_library(VkLayer_${target} SHARED ${ARGN}) + add_dependencies(VkLayer_${target} generate_vk_layer_helpers) + set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") +- install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging) ++ install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endmacro() + endif() + +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0004-install-the-vulkan-loader.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0004-install-the-vulkan-loader.patch new file mode 100644 index 00000000..68026245 --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0004-install-the-vulkan-loader.patch @@ -0,0 +1,27 @@ +From d30812f7afc355269df0edd5d4f030d470192cad Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Wed, 17 Aug 2016 13:28:32 +0500 +Subject: [PATCH 2/2] install the vulkan loader + +The vulkan loader is an essential component so it should +be installed to the directory that is intended to be +pushed to the target. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + loader/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt +index a4d2b21..2790faa 100644 +--- a/loader/CMakeLists.txt ++++ b/loader/CMakeLists.txt +@@ -84,4 +84,5 @@ else() + add_library(vulkan SHARED ${LOADER_SRCS}) + set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "1.0.26") + target_link_libraries(vulkan -ldl -lpthread -lm) ++ install(TARGETS vulkan DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0005-install-demos.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0005-install-demos.patch new file mode 100644 index 00000000..08f0f8f0 --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0005-install-demos.patch @@ -0,0 +1,52 @@ +From 15f3a15ce6d65714f7901eab118a13d9d70a9a3b Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Tue, 30 Aug 2016 15:17:55 +0500 +Subject: [PATCH] install demos + +Install demos to the target. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + demos/CMakeLists.txt | 2 ++ + demos/smoke/CMakeLists.txt | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt +index 9fdabf8..42e5499 100644 +--- a/demos/CMakeLists.txt ++++ b/demos/CMakeLists.txt +@@ -136,5 +136,8 @@ else() + target_link_libraries(cube ${LIBRARIES} ) + endif() + ++install(TARGETS cube DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(TARGETS tri DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(TARGETS vulkaninfo DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_subdirectory(smoke) + +diff --git a/demos/smoke/CMakeLists.txt b/demos/smoke/CMakeLists.txt +index 4dc90cd..415ac2f 100644 +--- a/demos/smoke/CMakeLists.txt ++++ b/demos/smoke/CMakeLists.txt +@@ -85,3 +85,5 @@ add_executable(smoketest ${sources}) + target_compile_definitions(smoketest ${definitions}) + target_include_directories(smoketest ${includes}) + target_link_libraries(smoketest ${libraries}) ++ ++install(TARGETS smoketest DESTINATION ${CMAKE_INSTALL_BINDIR}) +diff --git a/libs/vkjson/CMakeLists.txt b/libs/vkjson/CMakeLists.txt +index 4c0aef8..9b03d3d 100644 +--- a/libs/vkjson/CMakeLists.txt ++++ b/libs/vkjson/CMakeLists.txt +@@ -32,6 +32,8 @@ if(UNIX) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") + add_executable(vkjson_unittest vkjson_unittest.cc) + add_executable(vkjson_info vkjson_info.cc) ++ install(TARGETS vkjson_unittest DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ install(TARGETS vkjson_info DESTINATION ${CMAKE_INSTALL_BINDIR}) + else() + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS") + add_executable(vkjson_unittest vkjson_unittest.cc) +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0006-json-correct-layer-lib-paths.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0006-json-correct-layer-lib-paths.patch new file mode 100644 index 00000000..54d092ba --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0006-json-correct-layer-lib-paths.patch @@ -0,0 +1,114 @@ +From e66538f44c606d9f6c2ada9d78b310343e4386da Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Wed, 31 Aug 2016 15:13:28 +0500 +Subject: [PATCH] json: correct layer lib paths + +Rather than using a hardcoded ./ path for the libraries +we should use loose paths so the system could search +on its own when the library is required. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + layers/linux/VkLayer_core_validation.json | 2 +- + layers/linux/VkLayer_image.json | 2 +- + layers/linux/VkLayer_object_tracker.json | 2 +- + layers/linux/VkLayer_parameter_validation.json | 2 +- + layers/linux/VkLayer_swapchain.json | 2 +- + layers/linux/VkLayer_threading.json | 2 +- + layers/linux/VkLayer_unique_objects.json | 2 +- + 7 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/layers/linux/VkLayer_core_validation.json b/layers/linux/VkLayer_core_validation.json +index 3f2162d..c0ef9b7 100644 +--- a/layers/linux/VkLayer_core_validation.json ++++ b/layers/linux/VkLayer_core_validation.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_LUNARG_core_validation", + "type": "GLOBAL", +- "library_path": "./libVkLayer_core_validation.so", ++ "library_path": "libVkLayer_core_validation.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "LunarG Validation Layer", +diff --git a/layers/linux/VkLayer_image.json b/layers/linux/VkLayer_image.json +index 97a250e..6fa3bbd 100644 +--- a/layers/linux/VkLayer_image.json ++++ b/layers/linux/VkLayer_image.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_LUNARG_image", + "type": "GLOBAL", +- "library_path": "./libVkLayer_image.so", ++ "library_path": "libVkLayer_image.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "LunarG Validation Layer", +diff --git a/layers/linux/VkLayer_object_tracker.json b/layers/linux/VkLayer_object_tracker.json +index 1c5d79b..49e5a29 100644 +--- a/layers/linux/VkLayer_object_tracker.json ++++ b/layers/linux/VkLayer_object_tracker.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_LUNARG_object_tracker", + "type": "GLOBAL", +- "library_path": "./libVkLayer_object_tracker.so", ++ "library_path": "libVkLayer_object_tracker.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "LunarG Validation Layer", +diff --git a/layers/linux/VkLayer_parameter_validation.json b/layers/linux/VkLayer_parameter_validation.json +index 899ea88..6df74f8 100644 +--- a/layers/linux/VkLayer_parameter_validation.json ++++ b/layers/linux/VkLayer_parameter_validation.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_LUNARG_parameter_validation", + "type": "GLOBAL", +- "library_path": "./libVkLayer_parameter_validation.so", ++ "library_path": "libVkLayer_parameter_validation.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "LunarG Validation Layer", +diff --git a/layers/linux/VkLayer_swapchain.json b/layers/linux/VkLayer_swapchain.json +index 5fe0ef8..6d0b500 100644 +--- a/layers/linux/VkLayer_swapchain.json ++++ b/layers/linux/VkLayer_swapchain.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_LUNARG_swapchain", + "type": "GLOBAL", +- "library_path": "./libVkLayer_swapchain.so", ++ "library_path": "libVkLayer_swapchain.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "LunarG Validation Layer", +diff --git a/layers/linux/VkLayer_threading.json b/layers/linux/VkLayer_threading.json +index 59feb59..fd6bedf 100644 +--- a/layers/linux/VkLayer_threading.json ++++ b/layers/linux/VkLayer_threading.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_GOOGLE_threading", + "type": "GLOBAL", +- "library_path": "./libVkLayer_threading.so", ++ "library_path": "libVkLayer_threading.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "Google Validation Layer", +diff --git a/layers/linux/VkLayer_unique_objects.json b/layers/linux/VkLayer_unique_objects.json +index 59e1f89..72b77ee 100644 +--- a/layers/linux/VkLayer_unique_objects.json ++++ b/layers/linux/VkLayer_unique_objects.json +@@ -3,7 +3,7 @@ + "layer" : { + "name": "VK_LAYER_GOOGLE_unique_objects", + "type": "GLOBAL", +- "library_path": "./libVkLayer_unique_objects.so", ++ "library_path": "libVkLayer_unique_objects.so", + "api_version": "1.0.26", + "implementation_version": "1", + "description": "Google Validation Layer" +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0008-demos-make-shader-location-relative.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0008-demos-make-shader-location-relative.patch new file mode 100644 index 00000000..16409b57 --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0008-demos-make-shader-location-relative.patch @@ -0,0 +1,261 @@ +From 4e68da29ebc45a41845d7127979878930b4c170b Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Mon, 5 Sep 2016 15:47:16 +0500 +Subject: [PATCH 1/2] demos: make shader location relative + +The demo binaries expect the shader (frag/vert.spv) +location to be PWD so a user has to cd to /usr/bin +if the binaries are installed there in order to +run them correctly. +This patch tries to find the location of the binary +and then assumes that the shaders are located in the +same location as the binary so a user can install +everything to a single dir and that will work. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + demos/cube.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ + demos/tri.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 105 insertions(+), 8 deletions(-) + +diff --git a/demos/cube.c b/demos/cube.c +index 6017444..f79bc59 100644 +--- a/demos/cube.c ++++ b/demos/cube.c +@@ -29,6 +29,7 @@ + #include <stdbool.h> + #include <assert.h> + #include <signal.h> ++#include <unistd.h> + #if defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) + #include <X11/Xutil.h> + #endif +@@ -415,6 +416,8 @@ struct demo { + + uint32_t current_buffer; + uint32_t queue_count; ++ ++ char bin_path[255]; + }; + + VKAPI_ATTR VkBool32 VKAPI_CALL +@@ -1206,18 +1209,25 @@ static void demo_prepare_textures(struct demo *demo) { + const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM; + VkFormatProperties props; + uint32_t i; ++ char tex_file[255]; + + vkGetPhysicalDeviceFormatProperties(demo->gpu, tex_format, &props); + + for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { + VkResult U_ASSERT_ONLY err; +- ++ if (strlen(demo->bin_path) > 0) { ++ strcpy(tex_file, demo->bin_path); ++ strcat(tex_file, "/"); ++ strcat(tex_file, tex_files[i]); ++ } ++ else ++ strcpy(tex_file, tex_files[i]); + if ((props.linearTilingFeatures & + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) && + !demo->use_staging_buffer) { + /* Device can texture using linear textures */ + demo_prepare_texture_image( +- demo, tex_files[i], &demo->textures[i], VK_IMAGE_TILING_LINEAR, ++ demo, tex_file, &demo->textures[i], VK_IMAGE_TILING_LINEAR, + VK_IMAGE_USAGE_SAMPLED_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); +@@ -1228,13 +1238,13 @@ static void demo_prepare_textures(struct demo *demo) { + + memset(&staging_texture, 0, sizeof(staging_texture)); + demo_prepare_texture_image( +- demo, tex_files[i], &staging_texture, VK_IMAGE_TILING_LINEAR, ++ demo, tex_file, &staging_texture, VK_IMAGE_TILING_LINEAR, + VK_IMAGE_USAGE_TRANSFER_SRC_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + + demo_prepare_texture_image( +- demo, tex_files[i], &demo->textures[i], VK_IMAGE_TILING_OPTIMAL, ++ demo, tex_file, &demo->textures[i], VK_IMAGE_TILING_OPTIMAL, + (VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + +@@ -1557,8 +1567,16 @@ static VkShaderModule demo_prepare_vs(struct demo *demo) { + #else + void *vertShaderCode; + size_t size; ++ char fname[255]; ++ if (strlen(demo->bin_path) > 0) { ++ strcpy(fname, demo->bin_path); ++ strcat(fname, "/"); ++ strcat(fname, "cube-vert.spv"); ++ } ++ else ++ strcpy(fname, "cube-vert.spv"); + +- vertShaderCode = demo_read_spv("cube-vert.spv", &size); ++ vertShaderCode = demo_read_spv(fname, &size); + + demo->vert_shader_module = + demo_prepare_shader_module(demo, vertShaderCode, size); +@@ -1582,8 +1600,16 @@ static VkShaderModule demo_prepare_fs(struct demo *demo) { + #else + void *fragShaderCode; + size_t size; ++ char fname[255]; ++ if (strlen(demo->bin_path) > 0) { ++ strcpy(fname, demo->bin_path); ++ strcat(fname, "/"); ++ strcat(fname, "cube-frag.spv"); ++ } ++ else ++ strcpy(fname, "cube-frag.spv"); + +- fragShaderCode = demo_read_spv("cube-frag.spv", &size); ++ fragShaderCode = demo_read_spv(fname, &size); + + demo->frag_shader_module = + demo_prepare_shader_module(demo, fragShaderCode, size); +@@ -3034,6 +3060,30 @@ static void demo_init_connection(struct demo *demo) { + #endif + } + ++static void find_bin_path(char *in_arg, char *ret_path) { ++ char *ptr = getenv("PATH"); ++ char *pch_temp; ++ char pch[255]; ++ ++ if (access(in_arg, F_OK ) == 0) { ++ pch_temp = strrchr(in_arg, '/'); ++ strncpy(ret_path, in_arg, strlen(in_arg) - strlen(pch_temp)); ++ } else if (in_arg[0] != '/') { ++ pch_temp = strtok(ptr, ":"); ++ while (pch_temp != NULL) { ++ strcpy(pch, pch_temp); ++ strcat(pch, "/"); ++ strcat(pch, in_arg); ++ if ((access(pch, F_OK ) == 0)) { ++ strcpy(ret_path, pch_temp); ++ break; ++ } ++ else ++ pch_temp = strtok(NULL, ":"); ++ } ++ } ++} ++ + static void demo_init(struct demo *demo, int argc, char **argv) { + vec3 eye = {0.0f, 3.0f, 5.0f}; + vec3 origin = {0, 0, 0}; +@@ -3053,6 +3053,8 @@ static void demo_init(struct demo *demo, int argc, char **argv) { + mat4x4_identity(demo->model_matrix); + + demo->projection_matrix[1][1]*=-1; //Flip projection matrix from GL to Vulkan orientation. ++ ++ find_bin_path(argv[0], demo->bin_path); + } + + #if defined(VK_USE_PLATFORM_WIN32_KHR) +diff --git a/demos/tri.c b/demos/tri.c +index 35d33f2..77ee5a1 100644 +--- a/demos/tri.c ++++ b/demos/tri.c +@@ -39,6 +39,7 @@ + #include <stdbool.h> + #include <assert.h> + #include <signal.h> ++#include <unistd.h> + + #ifdef _WIN32 + #pragma comment(linker, "/subsystem:windows") +@@ -262,6 +263,8 @@ struct demo { + bool quit; + uint32_t current_buffer; + uint32_t queue_count; ++ ++ char bin_path[255]; + }; + + VKAPI_ATTR VkBool32 VKAPI_CALL +@@ -1288,8 +1291,16 @@ static VkShaderModule demo_prepare_vs(struct demo *demo) { + #else + void *vertShaderCode; + size_t size = 0; ++ char fname[255]; ++ if (strlen(demo->bin_path) > 0) { ++ strcpy(fname, demo->bin_path); ++ strcat(fname, "/"); ++ strcat(fname, "tri-vert.spv"); ++ } ++ else ++ strcpy(fname, "tri-vert.spv"); + +- vertShaderCode = demo_read_spv("tri-vert.spv", &size); ++ vertShaderCode = demo_read_spv(fname, &size); + + demo->vert_shader_module = + demo_prepare_shader_module(demo, vertShaderCode, size); +@@ -1313,8 +1324,16 @@ static VkShaderModule demo_prepare_fs(struct demo *demo) { + #else + void *fragShaderCode; + size_t size; ++ char fname[255]; ++ if (strlen(demo->bin_path) > 0) { ++ strcpy(fname, demo->bin_path); ++ strcat(fname, "/"); ++ strcat(fname, "tri-frag.spv"); ++ } ++ else ++ strcpy(fname, "tri-frag.spv"); + +- fragShaderCode = demo_read_spv("tri-frag.spv", &size); ++ fragShaderCode = demo_read_spv(fname, &size); + + demo->frag_shader_module = + demo_prepare_shader_module(demo, fragShaderCode, size); +@@ -2447,6 +2466,30 @@ static void demo_init_connection(struct demo *demo) { + #endif // _WIN32 + } + ++static void find_bin_path(const char *in_arg, char *ret_path) { ++ char *ptr = getenv("PATH"); ++ char *pch_temp; ++ char pch[255]; ++ ++ if (access(in_arg, F_OK ) == 0) { ++ pch_temp = strrchr(in_arg, '/'); ++ strncpy(ret_path, in_arg, strlen(in_arg) - strlen(pch_temp)); ++ } else if (in_arg[0] != '/') { ++ pch_temp = strtok(ptr, ":"); ++ while (pch_temp != NULL) { ++ strcpy(pch, pch_temp); ++ strcat(pch, "/"); ++ strcat(pch, in_arg); ++ if ((access(pch, F_OK ) == 0)) { ++ strcpy(ret_path, pch_temp); ++ break; ++ } ++ else ++ pch_temp = strtok(NULL, ":"); ++ } ++ } ++} ++ + static void demo_init(struct demo *demo, const int argc, const char *argv[]) + { + memset(demo, 0, sizeof(*demo)); +@@ -2490,6 +2533,8 @@ static void demo_init(struct demo *demo, const int argc, const char *argv[]) + demo->height = 300; + demo->depthStencil = 1.0; + demo->depthIncrement = -0.01f; ++ ++ find_bin_path(argv[0], demo->bin_path); + } + + static void demo_cleanup(struct demo *demo) { +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0009-vulkaninfo.c-fix-segfault-when-DISPLAY-is-not-set.patch b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0009-vulkaninfo.c-fix-segfault-when-DISPLAY-is-not-set.patch new file mode 100644 index 00000000..25785ffb --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers/0009-vulkaninfo.c-fix-segfault-when-DISPLAY-is-not-set.patch @@ -0,0 +1,67 @@ +From b73227e97086116e596206b22ce0356bfc9b0a2c Mon Sep 17 00:00:00 2001 +From: Awais Belal <awais_belal@mentor.com> +Date: Fri, 11 Nov 2016 14:48:54 +0500 +Subject: [PATCH] vulkaninfo.c: fix segfault when DISPLAY is not set + +Both xlib and xcb interfaces expect the DISPLAY environment +variable to be set before creation of a window and the +display creation mechanism would segfault if that is +not the case and won't provide the user with details on +what has to be done to correct the problem. +We now handle such scenarios and exit cleanly after +providing the user with some details. + +Signed-off-by: Awais Belal <awais_belal@mentor.com> +--- + demos/vulkaninfo.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c +index 324720c..da0a7c3 100644 +--- a/demos/vulkaninfo.c ++++ b/demos/vulkaninfo.c +@@ -900,6 +900,9 @@ static void app_create_xlib_window(struct app_instance *inst) { + long visualMask = VisualScreenMask; + int numberOfVisuals; + ++ if (inst->xlib_display == NULL) ++ return; ++ + XVisualInfo vInfoTemplate={}; + vInfoTemplate.screen = DefaultScreen(inst->xlib_display); + XVisualInfo *visualInfo = XGetVisualInfo(inst->xlib_display, visualMask, +@@ -1488,6 +1491,12 @@ int main(int argc, char **argv) { + app_destroy_win32_window(&inst); + } + #endif ++#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) ++ if (getenv("DISPLAY") == NULL) { ++ printf("'DISPLAY' environment variable not set... Exiting!\n"); ++ goto out; ++ } ++#endif + //--XCB-- + #ifdef VK_USE_PLATFORM_XCB_KHR + if (has_extension(VK_KHR_XCB_SURFACE_EXTENSION_NAME, +@@ -1508,6 +1517,10 @@ int main(int argc, char **argv) { + if (has_extension(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, + inst.global_extension_count, inst.global_extensions)) { + app_create_xlib_window(&inst); ++ if (inst.xlib_display == NULL) { ++ printf("'DISPLAY' variable not set correctly. Exiting!\n'"); ++ goto out; ++ } + for (i = 0; i < gpu_count; i++) { + app_create_xlib_surface(&inst); + printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName); +@@ -1528,6 +1541,7 @@ int main(int argc, char **argv) { + printf("\n\n"); + } + ++out: + for (i = 0; i < gpu_count; i++) + app_gpu_destroy(&gpus[i]); + +-- +1.9.1 + diff --git a/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers_1.0.26.bb b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers_1.0.26.bb new file mode 100644 index 00000000..e8ea2605 --- /dev/null +++ b/meta-amdfalconx86/recipes-graphics/vulkan/vulkan-loader-layers_1.0.26.bb @@ -0,0 +1,58 @@ +SUMMARY = "Vulkan Ecosystem Components - Loader and Validation Layers" +DESCRIPTION = "Vulkan is a new generation graphics and compute API that \ + provides high-efficiency, cross-platform access to modern \ + GPUs used in a wide variety of devices from PCs and \ + consoles to mobile phones and embedded platforms." +SECTION = "graphics" +HOMEPAGE = "https://www.khronos.org/vulkan" +DEPENDS = "bison-native libx11 libxcb glslang glslang-native spirv-tools \ + libice libxext libsm" + +RDEPENDS_${PN} = "${PN}-layer-libs libxcb-sync libxcb-present libxcb-dri3" + +inherit cmake python3native + +REQUIRED_DISTRO_FEATURES = "x11" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=99c647ca3d4f6a4b9d8628f757aad156" + +S = "${WORKDIR}/git" + +SRCREV = "ebf46deb849a2d4cab3382c606a9fe36699dfa78" +SRC_URI = "git://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers;branch=sdk-${PV} \ + file://0001-CMakeLists-add-include-path-so-Xlib.h-is-found-as-ne.patch \ + file://0003-obey-CMAKE_INSTALL_LIBDIR.patch \ + file://0004-install-the-vulkan-loader.patch \ + file://0005-install-demos.patch \ + file://0006-json-correct-layer-lib-paths.patch \ + file://0008-demos-make-shader-location-relative.patch \ + file://0009-vulkaninfo.c-fix-segfault-when-DISPLAY-is-not-set.patch" + +EXTRA_OECMAKE = " \ + -DCUSTOM_GLSLANG_BIN_ROOT=1 \ + -DGLSLANG_BINARY_ROOT=${STAGING_DIR_HOST}/usr \ + -DCUSTOM_SPIRV_TOOLS_BIN_ROOT=1 \ + -DSPIRV_TOOLS_BINARY_ROOT=${STAGING_DIR_HOST}/usr \ + -DBUILD_TESTS=1 \ +" + +PACKAGES =+ "${PN}-layer-libs" +FILES_${PN}-layer-libs = "${libdir}/libVkLayer_*.so" + +FILES_SOLIBSDEV = "" +FILES_${PN} += "${libdir}/libvulkan.so" +INSANE_SKIP_${PN} = "dev-so" + +do_install_append() { + cp -f ${B}/demos/*.spv ${D}${bindir} + cp -f ${B}/demos/*.ppm ${D}${bindir} + mv ${D}${bindir}/tri ${D}${bindir}/tri-vulkan + mv ${D}${bindir}/cube ${D}${bindir}/cube-vulkan + + install -d ${D}${sysconfdir}/vulkan/explicit_layer.d + cp -f ${B}/layers/*.json ${D}${sysconfdir}/vulkan/explicit_layer.d + + install -d ${D}${includedir} + cp -rf ${S}/include/vulkan ${D}${includedir} +} |