diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aae9aa..77cd2ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,6 @@ endif () ############################################################################### file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icd") -include_directories ("${CMAKE_CURRENT_BINARY_DIR}") if (WIN32) @@ -48,7 +47,6 @@ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml" ) -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan") ############################################################################### @@ -66,12 +64,20 @@ add_library (cruft-vk-icd STATIC icd/fwd.hpp ${CMAKE_CURRENT_BINARY_DIR}/icd/vtable.hpp ${CMAKE_CURRENT_BINARY_DIR}/icd/dispatch.cpp + icd/dispatch.hpp icd/vendor.hpp icd/vendor.cpp icd/vendor_${VK_LOADER_VENDOR} icd/vtable.cpp ) +target_include_directories (cruft-vk-icd + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan" +) + target_link_libraries (cruft-vk-icd cruft-json cruft) ############################################################################### @@ -135,6 +141,12 @@ list (APPEND sources ##----------------------------------------------------------------------------- add_library (cruft-vk STATIC ${sources}) target_link_libraries (cruft-vk cruft-vk-icd cruft) +target_include_directories (cruft-vk + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan" + ) ############################################################################### diff --git a/icd/dispatch.hpp b/icd/dispatch.hpp new file mode 100644 index 0000000..23c84a8 --- /dev/null +++ b/icd/dispatch.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "vendor.hpp" + +namespace cruft::vk::icd { + void init (vendor const&); +} \ No newline at end of file diff --git a/icd/vendor.hpp b/icd/vendor.hpp index 21a857f..d40bdef 100644 --- a/icd/vendor.hpp +++ b/icd/vendor.hpp @@ -34,6 +34,8 @@ namespace cruft::vk::icd { VkAllocationCallbacks const*, VkInstance* ) noexcept; + + void (*GetInstanceProc) (VkInstance instance, const char* pName) noexcept; } vtable; private: diff --git a/tools/spec.py b/tools/spec.py index 787f879..8f99e9d 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -795,21 +795,21 @@ if __name__ == '__main__': dst.write(""" #include - + template struct is_instance: public std::false_type {}; - + template struct is_device: public std::false_type {}; - - + + template constexpr auto is_instance_v = is_instance::value; - + template constexpr auto is_device_v = is_device::value; """) @@ -876,12 +876,25 @@ if __name__ == '__main__': #include "../vk.hpp" #include "vtable.hpp" + #include "icd/dispatch.hpp" + #include #pragma GCC diagnostic ignored "-Wunused-parameter" static cruft::vk::icd::instance_table const *i_table = nullptr; static cruft::vk::icd::device_table const *d_table = nullptr; + + void (*cruft_vk_icdGetInstanceProcAddr) ( + VkInstance instance, + const char* pName + ) = nullptr; + + void cruft::vk::icd::init (vendor const &impl) + { + cruft_vk_icdGetInstanceProcAddr = impl.vtable.GetInstanceProc; + } + """) for obj in commands: @@ -905,7 +918,7 @@ if __name__ == '__main__': dispatch.write(f""" extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{ using first_arg_t = std::decay_t; - + if constexpr (is_instance_v) {{ auto const entry = reinterpret_cast ({obj.params[0].name}); auto const *table = reinterpret_cast (entry->table);