mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
DXIL ControlFlow optimisations
Lazy evaluate the connections map
This commit is contained in:
@@ -300,7 +300,23 @@ void ControlFlow::Construct(const rdcarray<rdcpair<uint32_t, uint32_t>> &links)
|
||||
{
|
||||
m_Connections[from].resize(maxBlockIndex);
|
||||
for(uint32_t to = 0; to < maxBlockIndex; ++to)
|
||||
m_Connections[from][to] = IsBlockConnected(from, to);
|
||||
m_Connections[from][to] = ConnectionState::Unknown;
|
||||
}
|
||||
|
||||
for(uint32_t p = 0; p < m_Paths.size(); ++p)
|
||||
{
|
||||
const BlockPath &path = m_Paths[p];
|
||||
for(size_t i = 0; i < path.size() - 1; ++i)
|
||||
{
|
||||
uint32_t from = path[i];
|
||||
for(size_t j = i + 1; j < path.size(); ++j)
|
||||
{
|
||||
uint32_t to = path[j];
|
||||
if(to == PATH_END)
|
||||
break;
|
||||
m_Connections[from][to] = ConnectionState::Connected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A loop block is defined by any block which appears in any path starting from the block
|
||||
@@ -446,6 +462,18 @@ uint32_t ControlFlow::GetNextUniformBlock(uint32_t from) const
|
||||
}
|
||||
return bestBlock;
|
||||
}
|
||||
|
||||
bool ControlFlow::IsForwardConnection(uint32_t from, uint32_t to) const
|
||||
{
|
||||
if(m_Connections[from][to] == ConnectionState::Unknown)
|
||||
{
|
||||
if(IsBlockConnected(from, to))
|
||||
m_Connections[from][to] = ConnectionState::Connected;
|
||||
else
|
||||
m_Connections[from][to] = ConnectionState::NotConnected;
|
||||
}
|
||||
return m_Connections[from][to] == ConnectionState::Connected;
|
||||
}
|
||||
}; // namespace DXIL
|
||||
|
||||
#if ENABLED(ENABLE_UNIT_TESTS)
|
||||
|
||||
@@ -39,11 +39,18 @@ public:
|
||||
rdcarray<uint32_t> GetUniformBlocks() const { return m_UniformBlocks; }
|
||||
rdcarray<uint32_t> GetLoopBlocks() const { return m_LoopBlocks; }
|
||||
uint32_t GetNextUniformBlock(uint32_t from) const;
|
||||
bool IsForwardConnection(uint32_t from, uint32_t to) const { return m_Connections[from][to]; }
|
||||
bool IsForwardConnection(uint32_t from, uint32_t to) const;
|
||||
|
||||
private:
|
||||
typedef rdcarray<uint32_t> BlockPath;
|
||||
|
||||
enum class ConnectionState : uint8_t
|
||||
{
|
||||
Unknown,
|
||||
NotConnected,
|
||||
Connected,
|
||||
};
|
||||
|
||||
bool TraceBlockFlow(const uint32_t from, BlockPath &path);
|
||||
bool BlockInAllPaths(uint32_t block, uint32_t pathIdx, int32_t startIdx) const;
|
||||
int32_t BlockInAnyPath(uint32_t block, uint32_t pathIdx, int32_t startIdx, int32_t steps) const;
|
||||
@@ -61,6 +68,6 @@ private:
|
||||
|
||||
rdcarray<uint32_t> m_UniformBlocks;
|
||||
rdcarray<uint32_t> m_LoopBlocks;
|
||||
rdcarray<rdcarray<bool>> m_Connections;
|
||||
mutable rdcarray<rdcarray<ConnectionState>> m_Connections;
|
||||
};
|
||||
}; // namespace DXIL
|
||||
|
||||
Reference in New Issue
Block a user