diff --git a/CMakeLists.txt b/CMakeLists.txt index f56a321..fb41283 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ endif () ############################################################################### set (GENERATED_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/cruft/vk/") -file (MAKE_DIRECTORY "${GENERATED_PREFIX}/icd") +file (MAKE_DIRECTORY "${GENERATED_PREFIX}/load") if (WIN32) @@ -31,8 +31,8 @@ endif() add_custom_command ( OUTPUT "${GENERATED_PREFIX}/vk.hpp" - "${GENERATED_PREFIX}/icd/dispatch.cpp" - "${GENERATED_PREFIX}/icd/vtable.hpp" + "${GENERATED_PREFIX}/load/dispatch.cpp" + "${GENERATED_PREFIX}/load/vtable.hpp" COMMENT "[spec.py] vk.hpp" COMMAND @@ -40,8 +40,8 @@ COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py" "--src" "${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml" "--dst" "${GENERATED_PREFIX}/vk.hpp" - "--icd" "${GENERATED_PREFIX}/icd/vtable.hpp" - "--dispatch" "${GENERATED_PREFIX}/icd/dispatch.cpp" + "--load" "${GENERATED_PREFIX}/load/vtable.hpp" + "--dispatch" "${GENERATED_PREFIX}/load/dispatch.cpp" "--platform" "${VK_PLATFORM}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py" @@ -61,27 +61,27 @@ endif() ##----------------------------------------------------------------------------- -add_library (cruft-vk-icd STATIC - icd/fwd.hpp - ${GENERATED_PREFIX}/icd/vtable.hpp - ${GENERATED_PREFIX}/icd/dispatch.cpp - icd/dispatch.hpp - icd/ostream.cpp - icd/ostream.hpp - icd/vendor.hpp - icd/vendor.cpp - icd/vendor_${VK_LOADER_VENDOR} - icd/vtable.cpp +add_library (cruft-vk-load STATIC + load/fwd.hpp + ${GENERATED_PREFIX}/load/vtable.hpp + ${GENERATED_PREFIX}/load/dispatch.cpp + load/dispatch.hpp + load/ostream.cpp + load/ostream.hpp + load/vendor.hpp + load/vendor.cpp + load/vendor_${VK_LOADER_VENDOR} + load/vtable.cpp ) -target_include_directories (cruft-vk-icd +target_include_directories (cruft-vk-load 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) +target_link_libraries (cruft-vk-load cruft-json cruft) ############################################################################### list (APPEND sources @@ -143,7 +143,7 @@ list (APPEND sources ##----------------------------------------------------------------------------- add_library (cruft-vk STATIC ${sources}) -target_link_libraries (cruft-vk cruft-vk-icd cruft) +target_link_libraries (cruft-vk cruft-vk-load cruft) target_include_directories (cruft-vk PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/icd/vtable.cpp b/icd/vtable.cpp deleted file mode 100644 index 72f00a5..0000000 --- a/icd/vtable.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include - -using cruft::vk::icd::instance_table; - - -/////////////////////////////////////////////////////////////////////////////// -cruft::vk::icd::vendor_table const *cruft::vk::icd::v_table = nullptr; -cruft::vk::icd::instance_table const *cruft::vk::icd::i_table = nullptr; diff --git a/icd/dispatch.hpp b/load/dispatch.hpp similarity index 71% rename from icd/dispatch.hpp rename to load/dispatch.hpp index 23c84a8..a464eff 100644 --- a/icd/dispatch.hpp +++ b/load/dispatch.hpp @@ -2,6 +2,6 @@ #include "vendor.hpp" -namespace cruft::vk::icd { +namespace cruft::vk::load { void init (vendor const&); } \ No newline at end of file diff --git a/icd/fwd.hpp b/load/fwd.hpp similarity index 91% rename from icd/fwd.hpp rename to load/fwd.hpp index 703146d..f67d1db 100644 --- a/icd/fwd.hpp +++ b/load/fwd.hpp @@ -9,6 +9,6 @@ #pragma once -namespace cruft::vk::icd { +namespace cruft::vk::load { struct icd_t; } diff --git a/icd/ostream.cpp b/load/ostream.cpp similarity index 78% rename from icd/ostream.cpp rename to load/ostream.cpp index b17ba16..30b0410 100644 --- a/icd/ostream.cpp +++ b/load/ostream.cpp @@ -13,10 +13,10 @@ /////////////////////////////////////////////////////////////////////////////// std::ostream& -cruft::vk::icd::operator<< (std::ostream &os, icd_t const &value) +cruft::vk::load::operator<< (std::ostream &os, icd_t const &value) { return os << "{ file_format_version: '" << value.file_format_version << "'" - << ", icd: { library_path: '" << value.icd.library_path << "'" - << ", api_version: '" << value.icd.api_version << "'" + << ", icd: { library_path: '" << value.icd.library_path << "'" + << ", api_version: '" << value.icd.api_version << "'" << " } }"; }; diff --git a/icd/ostream.hpp b/load/ostream.hpp similarity index 93% rename from icd/ostream.hpp rename to load/ostream.hpp index d22156a..5a8714b 100644 --- a/icd/ostream.hpp +++ b/load/ostream.hpp @@ -12,6 +12,6 @@ #include -namespace cruft::vk::icd { +namespace cruft::vk::load { std::ostream& operator<< (std::ostream&, icd_t const&); } diff --git a/icd/vendor.cpp b/load/vendor.cpp similarity index 92% rename from icd/vendor.cpp rename to load/vendor.cpp index 6c57dae..354cccb 100644 --- a/icd/vendor.cpp +++ b/load/vendor.cpp @@ -5,7 +5,7 @@ #include #include -using cruft::vk::icd::vendor; +using cruft::vk::load::vendor; #define MAP_ICD_COMMANDS(FUNC,...) MAP0(FUNC,\ @@ -16,8 +16,8 @@ using cruft::vk::icd::vendor; /////////////////////////////////////////////////////////////////////////////// template <> -cruft::vk::icd::icd_t -json::tree::io::deserialise (json::tree::node const &obj) +cruft::vk::load::icd_t +json::tree::io::deserialise (json::tree::node const &obj) { return { .file_format_version = obj["file_format_version"].as_string (), @@ -63,7 +63,7 @@ vendor::vendor (::cruft::library &&_library) throw std::runtime_error (unknown_message); case VK_SUCCESS: - LOG_INFO ("vk::icd version %!", version); + LOG_INFO ("vk::load version %!", version); break; } diff --git a/icd/vendor.hpp b/load/vendor.hpp similarity index 93% rename from icd/vendor.hpp rename to load/vendor.hpp index 0e76883..6133ccc 100644 --- a/icd/vendor.hpp +++ b/load/vendor.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace cruft::vk::icd { +namespace cruft::vk::load { struct icd_t { std::string file_format_version; struct { diff --git a/icd/vendor_posix.cpp b/load/vendor_posix.cpp similarity index 96% rename from icd/vendor_posix.cpp rename to load/vendor_posix.cpp index d99135c..59da7e2 100644 --- a/icd/vendor_posix.cpp +++ b/load/vendor_posix.cpp @@ -12,8 +12,8 @@ namespace fs = std::filesystem; /////////////////////////////////////////////////////////////////////////////// -std::vector -cruft::vk::icd::enumerate (void) +std::vector +cruft::vk::load::enumerate (void) { // The predefined, ordered, search locations for manifests static char const *locations[] = { diff --git a/icd/vendor_win32.cpp b/load/vendor_win32.cpp similarity index 93% rename from icd/vendor_win32.cpp rename to load/vendor_win32.cpp index f4305f6..b9bd674 100644 --- a/icd/vendor_win32.cpp +++ b/load/vendor_win32.cpp @@ -9,8 +9,8 @@ /////////////////////////////////////////////////////////////////////////////// -std::vector -cruft::vk::icd::enumerate() +std::vector +cruft::vk::load::enumerate() { std::vector res; diff --git a/load/vtable.cpp b/load/vtable.cpp new file mode 100644 index 0000000..994ef1b --- /dev/null +++ b/load/vtable.cpp @@ -0,0 +1,8 @@ +#include + +using cruft::vk::load::instance_table; + + +/////////////////////////////////////////////////////////////////////////////// +cruft::vk::load::vendor_table const *cruft::vk::load::v_table = nullptr; +cruft::vk::load::instance_table const *cruft::vk::load::i_table = nullptr; diff --git a/tools/hello.cpp b/tools/hello.cpp index 53cebc8..cec46ae 100644 --- a/tools/hello.cpp +++ b/tools/hello.cpp @@ -293,15 +293,15 @@ public: /////////////////////////////////////////////////////////////////////////////// -#include -#include +#include +#include int main (void) { - cruft::vk::icd::vendor v (cruft::vk::icd::enumerate ()[0]); - cruft::vk::icd::i_table = &v.itable; - cruft::vk::icd::v_table = &v.vtable; + cruft::vk::load::vendor v (cruft::vk::load::enumerate ()[0]); + cruft::vk::load::i_table = &v.itable; + cruft::vk::load::v_table = &v.vtable; LOG_INFO ("intialising glfw"); glfw::instance glfw_instance; diff --git a/tools/info.cpp b/tools/info.cpp index 7232657..02692c7 100644 --- a/tools/info.cpp +++ b/tools/info.cpp @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include #include @@ -19,8 +19,8 @@ #include -#include "../icd/vendor.hpp" -#include "icd/vtable.hpp" +#include "../load/vendor.hpp" +#include "load/vtable.hpp" /////////////////////////////////////////////////////////////////////////////// @@ -28,10 +28,10 @@ int main (int, char**) { std::cout << "[ "; - for (auto const &i: cruft::vk::icd::enumerate ()) { - cruft::vk::icd::vendor v (i); - cruft::vk::icd::i_table = &v.itable; - cruft::vk::icd::v_table = &v.vtable; + for (auto const &i: cruft::vk::load::enumerate ()) { + cruft::vk::load::vendor v (i); + cruft::vk::load::i_table = &v.itable; + cruft::vk::load::v_table = &v.vtable; cruft::vk::instance instance; diff --git a/tools/spec.py b/tools/spec.py index b201196..98dbcfe 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -791,7 +791,7 @@ def write_header(dst: TextIO, q: List[Type], reg: Registry): # ----------------------------------------------------------------------------- -def write_icd(dst: TextIO, q: List[Type], reg: Registry): +def write_load(dst: TextIO, q: List[Type], reg: Registry): commands = [i for i in q if isinstance(i, Command)] collections = { @@ -806,7 +806,7 @@ def write_icd(dst: TextIO, q: List[Type], reg: Registry): #include - namespace cruft::vk::icd {{ + namespace cruft::vk::load {{ class vendor; #define MAP_COMMANDS(FUNC) MAP0(FUNC,{",".join(i.name for i in commands)}) @@ -837,8 +837,8 @@ def write_icd(dst: TextIO, q: List[Type], reg: Registry): dst.write(""" struct vendor_table; - extern cruft::vk::icd::vendor_table const *v_table; - extern cruft::vk::icd::instance_table const *i_table; + extern cruft::vk::load::vendor_table const *v_table; + extern cruft::vk::load::instance_table const *i_table; } """) @@ -847,8 +847,8 @@ def write_icd(dst: TextIO, q: List[Type], reg: Registry): def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): dst.write(""" #include - #include - #include + #include + #include #include @@ -863,12 +863,12 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): implementations = { 'vkCreateInstance': """ - auto res = std::make_unique> (); - auto err = cruft::vk::icd::i_table->vkCreateInstance (pCreateInfo, pAllocator, &res->handle); + auto res = std::make_unique> (); + auto err = cruft::vk::load::i_table->vkCreateInstance (pCreateInfo, pAllocator, &res->handle); if (err != VK_SUCCESS) return err; - #define GET(NAME) res->table.NAME = reinterpret_cast (cruft::vk::icd::v_table->vk_icdGetInstanceProcAddr (res->handle, #NAME)); + #define GET(NAME) res->table.NAME = reinterpret_cast (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (res->handle, #NAME)); MAP_INSTANCE_COMMANDS(GET) #undef GET @@ -890,7 +890,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): 'vkEnumeratePhysicalDevices': """ auto const entry = reinterpret_cast< - indirect const* + indirect const* > (instance); if (!pPhysicalDeviceCount || !pPhysicalDevices) { @@ -909,7 +909,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): return err; for (uint32_t i = 0; i < *pPhysicalDeviceCount; ++i) { - auto wrapped = std::make_unique> (); + auto wrapped = std::make_unique> (); wrapped->handle = res[i]; #define GET(NAME) wrapped->table.NAME = wrapped->table.NAME ?: reinterpret_cast (vkGetInstanceProcAddr (instance, #NAME)); @@ -927,7 +927,7 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): first_arg = reg.types[obj.params[0].type] instance_forward = f""" - return cruft::vk::icd::i_table->{obj.name} ({", ".join(p.name for p in obj.params)}); + return cruft::vk::load::i_table->{obj.name} ({", ".join(p.name for p in obj.params)}); """ if obj.is_instance(reg): @@ -945,10 +945,10 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry): is_creating = False if obj.is_instance(reg) and obj.params[0].type not in ['VkInstance', 'VkPhysicalDevice']: - forwarding = f"return ::cruft::vk::icd::i_table->{obj.name} ({', '.join (i.name for i in obj.params)});" + forwarding = f"return ::cruft::vk::load::i_table->{obj.name} ({', '.join (i.name for i in obj.params)});" else: forwarding = f""" - auto const entry = reinterpret_cast const*> ({obj.params[0].name}); + auto const entry = reinterpret_cast const*> ({obj.params[0].name}); return (entry->table.{obj.name})( {", ".join(['entry->handle'] + [p.name for p in obj.params[1:]])} @@ -973,7 +973,7 @@ def main(): parser = argparse.ArgumentParser(description='Transform XML API specification into C++ headers') parser.add_argument('--src', type=str, help='the path to the XML file to transform') parser.add_argument('--dst', type=str, help='the output path for the result') - parser.add_argument('--icd', type=str, help='the output path for the icd loading routines') + parser.add_argument('--load', type=str, help='the output path for the loading routines') parser.add_argument('--dispatch', type=str, help="the output path for function dispatch") parser.add_argument( '--platform', @@ -1064,12 +1064,12 @@ def main(): extensions = ["VK_KHR_swapchain", "VK_EXT_debug_report", "VK_KHR_external_memory"] q = reg.serialise(args.platform) - # Finally write out the header, icd, and dispatch code. + # Finally write out the header, vtables, and dispatch code. with open(args.dst, 'w') as dst: write_header(dst, q, reg) - with open(args.icd, 'w') as dst: - write_icd(dst, q, reg) + with open(args.load, 'w') as dst: + write_load(dst, q, reg) with open(args.dispatch, 'w') as dst: write_dispatch(dst, q, reg)