icd/dispatch: add init method to extract proc query function
This commit is contained in:
parent
7e6e5dc1b1
commit
d80fff482b
@ -15,7 +15,6 @@ endif ()
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icd")
|
file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icd")
|
||||||
include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
|
|
||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
@ -48,7 +47,6 @@ DEPENDS
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
"${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
|
icd/fwd.hpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/icd/vtable.hpp
|
${CMAKE_CURRENT_BINARY_DIR}/icd/vtable.hpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/icd/dispatch.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/icd/dispatch.cpp
|
||||||
|
icd/dispatch.hpp
|
||||||
icd/vendor.hpp
|
icd/vendor.hpp
|
||||||
icd/vendor.cpp
|
icd/vendor.cpp
|
||||||
icd/vendor_${VK_LOADER_VENDOR}
|
icd/vendor_${VK_LOADER_VENDOR}
|
||||||
icd/vtable.cpp
|
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)
|
target_link_libraries (cruft-vk-icd cruft-json cruft)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -135,6 +141,12 @@ list (APPEND sources
|
|||||||
##-----------------------------------------------------------------------------
|
##-----------------------------------------------------------------------------
|
||||||
add_library (cruft-vk STATIC ${sources})
|
add_library (cruft-vk STATIC ${sources})
|
||||||
target_link_libraries (cruft-vk cruft-vk-icd cruft)
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
7
icd/dispatch.hpp
Normal file
7
icd/dispatch.hpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "vendor.hpp"
|
||||||
|
|
||||||
|
namespace cruft::vk::icd {
|
||||||
|
void init (vendor const&);
|
||||||
|
}
|
@ -34,6 +34,8 @@ namespace cruft::vk::icd {
|
|||||||
VkAllocationCallbacks const*,
|
VkAllocationCallbacks const*,
|
||||||
VkInstance*
|
VkInstance*
|
||||||
) noexcept;
|
) noexcept;
|
||||||
|
|
||||||
|
void (*GetInstanceProc) (VkInstance instance, const char* pName) noexcept;
|
||||||
} vtable;
|
} vtable;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -795,21 +795,21 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
dst.write("""
|
dst.write("""
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
template <typename NativeT>
|
template <typename NativeT>
|
||||||
struct is_instance:
|
struct is_instance:
|
||||||
public std::false_type
|
public std::false_type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <typename NativeT>
|
template <typename NativeT>
|
||||||
struct is_device:
|
struct is_device:
|
||||||
public std::false_type
|
public std::false_type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto is_instance_v = is_instance<T>::value;
|
constexpr auto is_instance_v = is_instance<T>::value;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto is_device_v = is_device<T>::value;
|
constexpr auto is_device_v = is_device<T>::value;
|
||||||
""")
|
""")
|
||||||
@ -876,12 +876,25 @@ if __name__ == '__main__':
|
|||||||
#include "../vk.hpp"
|
#include "../vk.hpp"
|
||||||
#include "vtable.hpp"
|
#include "vtable.hpp"
|
||||||
|
|
||||||
|
#include "icd/dispatch.hpp"
|
||||||
|
|
||||||
#include <cruft/util/debug.hpp>
|
#include <cruft/util/debug.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
|
||||||
static cruft::vk::icd::instance_table const *i_table = nullptr;
|
static cruft::vk::icd::instance_table const *i_table = nullptr;
|
||||||
static cruft::vk::icd::device_table const *d_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:
|
for obj in commands:
|
||||||
@ -905,7 +918,7 @@ if __name__ == '__main__':
|
|||||||
dispatch.write(f"""
|
dispatch.write(f"""
|
||||||
extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{
|
extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{
|
||||||
using first_arg_t = std::decay_t<decltype({obj.params[0].name})>;
|
using first_arg_t = std::decay_t<decltype({obj.params[0].name})>;
|
||||||
|
|
||||||
if constexpr (is_instance_v<first_arg_t>) {{
|
if constexpr (is_instance_v<first_arg_t>) {{
|
||||||
auto const entry = reinterpret_cast<cruft::vk::icd::func const*> ({obj.params[0].name});
|
auto const entry = reinterpret_cast<cruft::vk::icd::func const*> ({obj.params[0].name});
|
||||||
auto const *table = reinterpret_cast<decltype({table})> (entry->table);
|
auto const *table = reinterpret_cast<decltype({table})> (entry->table);
|
||||||
|
Loading…
Reference in New Issue
Block a user