From d9b73266ab46c9b4ba3b0d25d369e30143ac398f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 26 Feb 2019 12:25:02 -0500 Subject: Dx11 & Dx12 device startup (#861) * Added CombinationUtil to produce combinations of flags Used in Dx11 device creation making it fall back to release driver if debug driver is not found * Made dx12 renderer startup similar to dx11 - testing multiple configs. * Small improvements in naming. * * Moved functionality to gfx from core * Use FlagCombiner to simplify construction, and can be iterated over, without need for array * Share DeviceCheckFlags * Improve comments. * Re-add the comment about combinations tested to set up dx11 device. * More comment improvements. --- tools/gfx/flag-combiner.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tools/gfx/flag-combiner.cpp (limited to 'tools/gfx/flag-combiner.cpp') diff --git a/tools/gfx/flag-combiner.cpp b/tools/gfx/flag-combiner.cpp new file mode 100644 index 000000000..04617368a --- /dev/null +++ b/tools/gfx/flag-combiner.cpp @@ -0,0 +1,55 @@ +#include "flag-combiner.h" + +namespace gfx { +using namespace Slang; + +void FlagCombiner::add(uint32_t flags, ChangeType type) +{ + // The flag/s must be set + SLANG_ASSERT(flags); + SLANG_ASSERT((flags & m_usedFlags) == 0); + // Mark the flags used + m_usedFlags |= flags; + + if (type == ChangeType::On || type == ChangeType::OnOff) + { + m_invertBits |= flags; + } + if (type == ChangeType::OnOff || type == ChangeType::OffOn) + { + m_changingBits[m_numChangingBits++] = flags; + } +} + +void FlagCombiner::calcCombinations(List& outCombinations) const +{ + const int numCombinations = getNumCombinations(); + outCombinations.SetSize(numCombinations); + uint32_t* dstCombinations = outCombinations.Buffer(); + for (int i = 0; i < numCombinations; ++i) + { + dstCombinations[i] = getCombination(i); + } +} + +uint32_t FlagCombiner::getCombination(int index) const +{ + SLANG_ASSERT(index >= 0 && index < getNumCombinations()); + + uint32_t combination = 0; + uint32_t bit = 1; + for (int i = 0; i < m_numChangingBits; ++i, bit += bit) + { + combination |= ((bit & index) ? m_changingBits[i] : 0); + } + return combination ^ m_invertBits; +} + +void FlagCombiner::reset() +{ + m_numChangingBits = 0; + m_usedFlags = 0; + m_invertBits = 0; +} + +} // namespace gfx -- cgit v1.2.3