Browse Source

[wip] remove one unordered map and a static constructor / destructor

chainsaw-surgery
Vladimír Vondruš 7 years ago
parent
commit
e68b551faf
  1. 52
      src/Magnum/GL/Context.cpp
  2. 6
      src/Magnum/GL/Implementation/driverSpecific.cpp

52
src/Magnum/GL/Context.cpp

@ -672,20 +672,20 @@ bool Context::tryCreate() {
/* List of extensions from future versions (extensions from current and /* List of extensions from future versions (extensions from current and
previous versions should be supported automatically, so we don't need previous versions should be supported automatically, so we don't need
to check for them) */ to check for them) */
std::unordered_map<std::string, Extension> futureExtensions; // std::unordered_map<std::string, Extension> futureExtensions;
for(std::size_t i = future; i != versions.size(); ++i) // for(std::size_t i = future; i != versions.size(); ++i)
for(const Extension& extension: Extension::extensions(versions[i])) // for(const Extension& extension: Extension::extensions(versions[i]))
futureExtensions.emplace(extension.string(), extension); // futureExtensions.emplace(extension.string(), extension);
//
/* Check for presence of future and vendor extensions */ // /* Check for presence of future and vendor extensions */
const std::vector<std::string> extensions = extensionStrings(); // const std::vector<std::string> extensions = extensionStrings();
for(const std::string& extension: extensions) { // for(const std::string& extension: extensions) {
const auto found = futureExtensions.find(extension); // const auto found = futureExtensions.find(extension);
if(found != futureExtensions.end()) { // if(found != futureExtensions.end()) {
_supportedExtensions.push_back(found->second); // _supportedExtensions.push_back(found->second);
_extensionStatus.set(found->second.index(), true); // _extensionStatus.set(found->second.index(), true);
} // }
} // }
/* Reset minimal required version to Version::None for whole array */ /* Reset minimal required version to Version::None for whole array */
for(auto& i: _extensionRequiredVersion) i = Version::None; for(auto& i: _extensionRequiredVersion) i = Version::None;
@ -716,21 +716,21 @@ bool Context::tryCreate() {
Debug{output} << "Disabling extensions:"; Debug{output} << "Disabling extensions:";
/* Put remaining extensions into the hashmap for faster lookup */ /* Put remaining extensions into the hashmap for faster lookup */
std::unordered_map<std::string, Extension> allExtensions{std::move(futureExtensions)}; // std::unordered_map<std::string, Extension> allExtensions{std::move(futureExtensions)};
for(std::size_t i = 0; i != future; ++i) // for(std::size_t i = 0; i != future; ++i)
for(const Extension& extension: Extension::extensions(versions[i])) // for(const Extension& extension: Extension::extensions(versions[i]))
allExtensions.emplace(extension.string(), extension); // allExtensions.emplace(extension.string(), extension);
/* Disable extensions that are known and supported and print a message /* Disable extensions that are known and supported and print a message
for each */ for each */
for(auto&& extension: _disabledExtensions) { // for(auto&& extension: _disabledExtensions) {
auto found = allExtensions.find(extension); // auto found = allExtensions.find(extension);
/** @todo Error message here? I should not clutter the output at this point */ // /** @todo Error message here? I should not clutter the output at this point */
if(found == allExtensions.end()) continue; // if(found == allExtensions.end()) continue;
//
_extensionRequiredVersion[found->second.index()] = Version::None; // _extensionRequiredVersion[found->second.index()] = Version::None;
Debug{output} << " " << extension; // Debug{output} << " " << extension;
} // }
} }
_state.emplace(*this, output); _state.emplace(*this, output);

6
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -36,7 +36,7 @@ namespace Magnum { namespace GL {
namespace { namespace {
/* Search the code for the following strings to see where they are implemented. */ /* Search the code for the following strings to see where they are implemented. */
std::vector<std::string> KnownWorkarounds{ const char* KnownWorkarounds[]{
/* [workarounds] */ /* [workarounds] */
#if defined(CORRADE_TARGET_ANDROID) && defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_ANDROID) && defined(MAGNUM_TARGET_GLES)
/* glBeginQuery() with GL_TIME_ELAPSED causes a GL_OUT_OF_MEMORY error when /* glBeginQuery() with GL_TIME_ELAPSED causes a GL_OUT_OF_MEMORY error when
@ -360,7 +360,7 @@ auto Context::detectedDriver() -> DetectedDrivers {
void Context::disableDriverWorkaround(const std::string& workaround) { void Context::disableDriverWorkaround(const std::string& workaround) {
/* Ignore unknown workarounds */ /* Ignore unknown workarounds */
if(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) == KnownWorkarounds.end()) { if(std::find(std::begin(KnownWorkarounds), std::end(KnownWorkarounds), workaround) == std::end(KnownWorkarounds)) {
Warning() << "Unknown workaround" << workaround; Warning() << "Unknown workaround" << workaround;
return; return;
} }
@ -368,7 +368,7 @@ void Context::disableDriverWorkaround(const std::string& workaround) {
} }
bool Context::isDriverWorkaroundDisabled(const char* workaround) { bool Context::isDriverWorkaroundDisabled(const char* workaround) {
CORRADE_INTERNAL_ASSERT(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) != KnownWorkarounds.end()); CORRADE_INTERNAL_ASSERT(std::find(std::begin(KnownWorkarounds), std::end(KnownWorkarounds), workaround) != std::end(KnownWorkarounds));
/* If the workaround was already asked for or disabled, return its state, /* If the workaround was already asked for or disabled, return its state,
otherwise add it to the list as used one */ otherwise add it to the list as used one */

Loading…
Cancel
Save