1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxvk] Make vk::NameSet more versatile

This commit is contained in:
Philip Rebohle 2018-05-16 20:52:24 +02:00
parent 40b52758e3
commit d1eddbdc3f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 19 additions and 8 deletions

View File

@ -8,7 +8,7 @@ namespace dxvk {
void DxvkExtensionList::enableExtensions(const vk::NameSet& extensions) { void DxvkExtensionList::enableExtensions(const vk::NameSet& extensions) {
for (auto ext : m_extensions) { for (auto ext : m_extensions) {
if (extensions.supports(ext->name())) if (extensions.contains(ext->name()))
ext->setEnabled(true); ext->setEnabled(true);
} }
} }

View File

@ -85,7 +85,7 @@ namespace dxvk {
vk::NameList layersEnabled; vk::NameList layersEnabled;
for (auto l : layers) { for (auto l : layers) {
if (layersAvailable.supports(l)) if (layersAvailable.contains(l))
layersEnabled.add(l); layersEnabled.add(l);
else else
throw DxvkError(str::format("Requested layer not installed: ", l)); throw DxvkError(str::format("Requested layer not installed: ", l));
@ -107,12 +107,12 @@ namespace dxvk {
vk::NameList extensionsEnabled; vk::NameList extensionsEnabled;
for (auto e : extOptional) { for (auto e : extOptional) {
if (extensionsAvailable.supports(e)) if (extensionsAvailable.contains(e))
extensionsEnabled.add(e); extensionsEnabled.add(e);
} }
for (auto e : extRequired) { for (auto e : extRequired) {
if (!extensionsAvailable.supports(e)) if (!extensionsAvailable.contains(e))
throw DxvkError(str::format("DxvkInstance::getExtensions: Extension ", e, " not supported")); throw DxvkError(str::format("DxvkInstance::getExtensions: Extension ", e, " not supported"));
extensionsEnabled.add(e); extensionsEnabled.add(e);
} }

View File

@ -2,7 +2,12 @@
namespace dxvk::vk { namespace dxvk::vk {
bool NameSet::supports(const char* name) const { void NameSet::add(const std::string& name) {
m_names.insert(name);
}
bool NameSet::contains(const std::string& name) const {
return m_names.find(name) != m_names.end(); return m_names.find(name) != m_names.end();
} }
@ -48,7 +53,7 @@ namespace dxvk::vk {
NameSet result; NameSet result;
for (const auto& ext : extensions) for (const auto& ext : extensions)
result.m_names.insert(ext.extensionName); result.add(ext.extensionName);
return result; return result;
} }
@ -65,7 +70,7 @@ namespace dxvk::vk {
throw DxvkError("ExtensionSet::addInstanceExtensions: Failed to query instance extensions"); throw DxvkError("ExtensionSet::addInstanceExtensions: Failed to query instance extensions");
for (const auto& ext : extensions) for (const auto& ext : extensions)
m_names.insert(ext.extensionName); this->add(ext.extensionName);
} }
} }

View File

@ -51,13 +51,19 @@ namespace dxvk::vk {
public: public:
/**
* \brief Adds an extension to the set
* \param [in] name The extension to add
*/
void add(const std::string& name);
/** /**
* \brief Checks whether an extension or layer is supported * \brief Checks whether an extension or layer is supported
* *
* \param [in] name The layer or extension name * \param [in] name The layer or extension name
* \returns \c true if the entity is supported * \returns \c true if the entity is supported
*/ */
bool supports(const char* name) const; bool contains(const std::string& name) const;
/** /**
* \brief Enumerates instance layers * \brief Enumerates instance layers