libcruft-vk/icd/vendor.cpp

49 lines
1.4 KiB
C++

#include "vendor.hpp"
#include <cruft/json/tree.hpp>
using cruft::vk::icd::vendor;
///////////////////////////////////////////////////////////////////////////////
template <>
cruft::vk::icd::icd_t
json::tree::io<cruft::vk::icd::icd_t>::deserialise (json::tree::node const &obj)
{
return {
.file_format_version = obj["file_format_version"].as_string (),
.icd = {
.library_path = obj["ICD"]["library_path"].as_string ().native (),
.api_version = obj["ICD"]["api_version"].as_string (),
},
};
}
///////////////////////////////////////////////////////////////////////////////
cruft::vk::icd::global_table const *cruft::vk::icd::g_table;
///////////////////////////////////////////////////////////////////////////////
vendor::vendor (icd_t const &_icd):
vendor (cruft::library (_icd.icd.library_path))
{ ; }
//-----------------------------------------------------------------------------
vendor::vendor (::cruft::library &&_library)
: m_library (std::move (_library))
, m_get_proc (
m_library.symbol<decltype(m_get_proc)> ("vk_icdGetInstanceProcAddr")
)
{
#define LOADFN(name) \
vtable.name = reinterpret_cast< \
decltype(vtable.name) \
> ( \
m_get_proc(nullptr, #name) \
);
MAP_INSTANCE_COMMANDS (LOADFN)
}