mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-22 06:26:30 +00:00
Preserve uselists through DXIL decode/encode
This commit is contained in:
@@ -1149,7 +1149,30 @@ Program::Program(const byte *bytes, size_t length)
|
||||
}
|
||||
else if(IS_KNOWN(funcChild.id, KnownBlock::USELIST_BLOCK))
|
||||
{
|
||||
RDCDEBUG("Ignoring uselist block");
|
||||
for(const LLVMBC::BlockOrRecord &uselist : funcChild.children)
|
||||
{
|
||||
if(uselist.IsBlock())
|
||||
{
|
||||
RDCERR("Unexpected subblock in USELIST_BLOCK");
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool bb = IS_KNOWN(uselist.id, UselistRecord::BB);
|
||||
if(IS_KNOWN(uselist.id, UselistRecord::DEFAULT) || bb)
|
||||
{
|
||||
UselistEntry u;
|
||||
u.block = bb;
|
||||
u.shuffle = uselist.ops;
|
||||
u.value = m_Values[(size_t)u.shuffle.back()];
|
||||
u.shuffle.pop_back();
|
||||
f.uselist.push_back(u);
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Unexpected record %u in USELIST_BLOCK", uselist.id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -579,6 +579,13 @@ struct Block
|
||||
rdcarray<const Block *> preds;
|
||||
};
|
||||
|
||||
struct UselistEntry
|
||||
{
|
||||
bool block = false;
|
||||
Value value;
|
||||
rdcarray<uint64_t> shuffle;
|
||||
};
|
||||
|
||||
struct Function
|
||||
{
|
||||
rdcstr name;
|
||||
@@ -597,6 +604,8 @@ struct Function
|
||||
rdcarray<Constant> constants;
|
||||
rdcarray<Metadata> metadata;
|
||||
|
||||
rdcarray<UselistEntry> uselist;
|
||||
|
||||
AttachedMetadata attachedMeta;
|
||||
};
|
||||
|
||||
|
||||
@@ -1098,6 +1098,21 @@ bytebuf DXIL::ProgramEditor::EncodeProgram() const
|
||||
writer.EndBlock();
|
||||
}
|
||||
|
||||
if(!f.uselist.empty())
|
||||
{
|
||||
writer.BeginBlock(LLVMBC::KnownBlock::USELIST_BLOCK);
|
||||
|
||||
for(const UselistEntry &u : f.uselist)
|
||||
{
|
||||
vals = u.shuffle;
|
||||
vals.push_back(getValueID(u.value));
|
||||
|
||||
writer.Record(u.block ? LLVMBC::UselistRecord::BB : LLVMBC::UselistRecord::DEFAULT, vals);
|
||||
}
|
||||
|
||||
writer.EndBlock();
|
||||
}
|
||||
|
||||
writer.EndBlock();
|
||||
|
||||
values.resize(values.size() - f.values.size());
|
||||
|
||||
@@ -175,6 +175,12 @@ enum class ValueSymtabRecord : uint32_t
|
||||
COMBINED_ENTRY = 5,
|
||||
};
|
||||
|
||||
enum class UselistRecord : uint32_t
|
||||
{
|
||||
DEFAULT = 1,
|
||||
BB = 2,
|
||||
};
|
||||
|
||||
enum class MetaDataRecord : uint32_t
|
||||
{
|
||||
STRING_OLD = 1,
|
||||
|
||||
Reference in New Issue
Block a user