mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-13 05:50:04 -04:00
Support compilation with VK_NO_PROTOTYPES defined (#328)
* Add checks for VK_NO_PROTOTYPES so the can still compile if that is defined
This commit is contained in:
parent
d566d2200c
commit
0e76bc68e3
@ -2357,6 +2357,7 @@ void VulkanHppGenerator::writeDispatchLoaderDynamic(std::ostream &os)
|
|||||||
public:
|
public:
|
||||||
DispatchLoaderDynamic() = default;
|
DispatchLoaderDynamic() = default;
|
||||||
|
|
||||||
|
#if !defined(VK_NO_PROTOTYPES)
|
||||||
// This interface is designed to be used for per-device function pointers in combination with a linked vulkan library.
|
// This interface is designed to be used for per-device function pointers in combination with a linked vulkan library.
|
||||||
DispatchLoaderDynamic(vk::Instance const& instance, vk::Device const& device = {})
|
DispatchLoaderDynamic(vk::Instance const& instance, vk::Device const& device = {})
|
||||||
{
|
{
|
||||||
@ -2368,6 +2369,7 @@ void VulkanHppGenerator::writeDispatchLoaderDynamic(std::ostream &os)
|
|||||||
{
|
{
|
||||||
init(instance, ::vkGetInstanceProcAddr, device, device ? ::vkGetDeviceProcAddr : nullptr);
|
init(instance, ::vkGetInstanceProcAddr, device, device ? ::vkGetDeviceProcAddr : nullptr);
|
||||||
}
|
}
|
||||||
|
#endif // !defined(VK_NO_PROTOTYPES)
|
||||||
|
|
||||||
// This interface does not require a linked vulkan library.
|
// This interface does not require a linked vulkan library.
|
||||||
DispatchLoaderDynamic( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr )
|
DispatchLoaderDynamic( VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device = VK_NULL_HANDLE, PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr )
|
||||||
@ -2465,6 +2467,20 @@ void VulkanHppGenerator::writeDispatchLoaderStatic(std::ostream &os)
|
|||||||
os << replaceWithMap(dispatchTemplate, { { "commands", commands.str() } });
|
os << replaceWithMap(dispatchTemplate, { { "commands", commands.str() } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VulkanHppGenerator::writeDispatchLoaderDefault(std::ostream &os)
|
||||||
|
{
|
||||||
|
os << std::endl
|
||||||
|
<< "#if !defined(VK_NO_PROTOTYPES)";
|
||||||
|
writeDispatchLoaderStatic(os);
|
||||||
|
os << R"(
|
||||||
|
typedef DispatchLoaderStatic DispatchLoaderDefault;
|
||||||
|
#else // !defined(VK_NO_PROTOTYPES)
|
||||||
|
class NeedExplicitDispatchLoader;
|
||||||
|
typedef NeedExplicitDispatchLoader DispatchLoaderDefault;
|
||||||
|
#endif
|
||||||
|
)";
|
||||||
|
}
|
||||||
|
|
||||||
void VulkanHppGenerator::writeEnum(std::ostream & os, std::pair<std::string,EnumData> const& enumData) const
|
void VulkanHppGenerator::writeEnum(std::ostream & os, std::pair<std::string,EnumData> const& enumData) const
|
||||||
{
|
{
|
||||||
std::string values;
|
std::string values;
|
||||||
@ -3343,7 +3359,7 @@ void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::str
|
|||||||
os << ", ";
|
os << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << "typename Dispatch" << (withDefault ? " = DispatchLoaderStatic" : "") << ">" << std::endl;
|
os << "typename Dispatch" << (withDefault ? " = DispatchLoaderDefault" : "") << ">" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanHppGenerator::writeHandle(std::ostream & os, std::pair<std::string, HandleData> const& handleData, std::set<std::string> & listedHandles) const
|
void VulkanHppGenerator::writeHandle(std::ostream & os, std::pair<std::string, HandleData> const& handleData, std::set<std::string> & listedHandles) const
|
||||||
@ -4076,7 +4092,7 @@ void VulkanHppGenerator::writeUniqueTypes(std::ostream &os, std::string const& p
|
|||||||
|
|
||||||
static const std::string uniqueTypesTemplate = R"(
|
static const std::string uniqueTypesTemplate = R"(
|
||||||
template <typename Dispatch> class UniqueHandleTraits<${type}, Dispatch> { public: using deleter = ${deleterType}${deleterAction}<${deleterParent}${deleterPool}, Dispatch>; };
|
template <typename Dispatch> class UniqueHandleTraits<${type}, Dispatch> { public: using deleter = ${deleterType}${deleterAction}<${deleterParent}${deleterPool}, Dispatch>; };
|
||||||
using Unique${type} = UniqueHandle<${type}, DispatchLoaderStatic>;)";
|
using Unique${type} = UniqueHandle<${type}, DispatchLoaderDefault>;)";
|
||||||
|
|
||||||
os << replaceWithMap(uniqueTypesTemplate,
|
os << replaceWithMap(uniqueTypesTemplate,
|
||||||
{
|
{
|
||||||
@ -5101,7 +5117,7 @@ namespace std
|
|||||||
<< classOptional
|
<< classOptional
|
||||||
<< classStructureChain
|
<< classStructureChain
|
||||||
<< classUniqueHandle;
|
<< classUniqueHandle;
|
||||||
generator.writeDispatchLoaderStatic(ofs);
|
generator.writeDispatchLoaderDefault(ofs);
|
||||||
ofs << classObjectDestroy
|
ofs << classObjectDestroy
|
||||||
<< classObjectFree
|
<< classObjectFree
|
||||||
<< classPoolFree
|
<< classPoolFree
|
||||||
|
@ -41,6 +41,7 @@ class VulkanHppGenerator
|
|||||||
void writeBitmasks(std::ostream & os) const;
|
void writeBitmasks(std::ostream & os) const;
|
||||||
void writeDispatchLoaderDynamic(std::ostream &os); // use vkGet*ProcAddress to get function pointers
|
void writeDispatchLoaderDynamic(std::ostream &os); // use vkGet*ProcAddress to get function pointers
|
||||||
void writeDispatchLoaderStatic(std::ostream &os); // use exported symbols from loader
|
void writeDispatchLoaderStatic(std::ostream &os); // use exported symbols from loader
|
||||||
|
void writeDispatchLoaderDefault(std::ostream &os); // typedef to DispatchLoaderStatic or undefined type, based on VK_NO_PROTOTYPES
|
||||||
void writeEnums(std::ostream & os) const;
|
void writeEnums(std::ostream & os) const;
|
||||||
void writeForwardDeclarations(std::ostream & os) const;
|
void writeForwardDeclarations(std::ostream & os) const;
|
||||||
void writeHandles(std::ostream & os) const;
|
void writeHandles(std::ostream & os) const;
|
||||||
|
1717
vulkan/vulkan.hpp
1717
vulkan/vulkan.hpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user