mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Represent function types as plain func, not ptr-to-func
* This is not how LLVM does things, but sometimes DXIL blobs don't have the ptr- to-func types present, and we always access the real function type anyway so it should be safe to store the direct function type.
This commit is contained in:
@@ -217,13 +217,9 @@ static bool AnnotateDXILShader(const DXBC::DXBCContainer *dxbc, uint32_t space,
|
||||
|
||||
const DXIL::Type *funcType = editor.AddType(atomicType);
|
||||
|
||||
DXIL::Type funcPtrType;
|
||||
funcPtrType.type = DXIL::Type::Pointer;
|
||||
funcPtrType.inner = funcType;
|
||||
|
||||
DXIL::Function atomicFunc;
|
||||
atomicFunc.name = "dx.op.atomicBinOp.i32";
|
||||
atomicFunc.funcType = editor.AddType(funcPtrType);
|
||||
atomicFunc.funcType = funcType;
|
||||
atomicFunc.external = true;
|
||||
|
||||
for(const DXIL::AttributeSet &attrs : editor.GetAttributeSets())
|
||||
|
||||
@@ -483,13 +483,6 @@ Program::Program(const byte *bytes, size_t length)
|
||||
for(size_t p = 6; p < rootchild.ops.size(); p++)
|
||||
RDCASSERT(rootchild.ops[p] == 0, p, rootchild.ops[p]);
|
||||
|
||||
const Type *ptrType = GetPointerType(f.funcType, Type::PointerAddrSpace::Default);
|
||||
|
||||
if(ptrType == f.funcType)
|
||||
RDCERR("Expected to find pointer type for function");
|
||||
|
||||
f.funcType = ptrType;
|
||||
|
||||
if(!f.external)
|
||||
functionDecls.push_back(m_Functions.size());
|
||||
|
||||
@@ -981,11 +974,11 @@ Program::Program(const byte *bytes, size_t length)
|
||||
size_t prevNumSymbols = m_Values.size();
|
||||
size_t instrSymbolStart = 0;
|
||||
|
||||
f.args.reserve(f.funcType->inner->members.size());
|
||||
for(size_t i = 0; i < f.funcType->inner->members.size(); i++)
|
||||
f.args.reserve(f.funcType->members.size());
|
||||
for(size_t i = 0; i < f.funcType->members.size(); i++)
|
||||
{
|
||||
Instruction arg;
|
||||
arg.type = f.funcType->inner->members[i];
|
||||
arg.type = f.funcType->members[i];
|
||||
arg.name = StringFormat::Fmt("arg%zu", i);
|
||||
f.args.push_back(arg);
|
||||
m_Values.push_back(Value(&f.args.back()));
|
||||
@@ -1276,16 +1269,16 @@ Program::Program(const byte *bytes, size_t length)
|
||||
}
|
||||
|
||||
inst.funcCall = v.function;
|
||||
inst.type = inst.funcCall->funcType->inner->inner;
|
||||
inst.type = inst.funcCall->funcType->inner;
|
||||
|
||||
if(funcCallType)
|
||||
{
|
||||
RDCASSERT(funcCallType == inst.funcCall->funcType->inner);
|
||||
RDCASSERT(funcCallType == inst.funcCall->funcType);
|
||||
}
|
||||
|
||||
for(size_t i = 0; op.remaining() > 0; i++)
|
||||
{
|
||||
if(inst.funcCall->funcType->inner->members[i]->type == Type::Metadata)
|
||||
if(inst.funcCall->funcType->members[i]->type == Type::Metadata)
|
||||
{
|
||||
int32_t offs = (int32_t)op.get<uint32_t>();
|
||||
size_t idx = m_Values.size() - offs;
|
||||
@@ -1301,7 +1294,7 @@ Program::Program(const byte *bytes, size_t length)
|
||||
inst.args.push_back(v);
|
||||
}
|
||||
|
||||
RDCASSERTEQUAL(inst.args.size(), inst.funcCall->funcType->inner->members.size());
|
||||
RDCASSERTEQUAL(inst.args.size(), inst.funcCall->funcType->members.size());
|
||||
|
||||
f.instructions.push_back(inst);
|
||||
|
||||
|
||||
@@ -1135,7 +1135,7 @@ bytebuf ProgramEditor::EncodeProgram() const
|
||||
for(size_t i = 0; i < m_Functions.size(); i++)
|
||||
{
|
||||
const Function &f = m_Functions[i];
|
||||
uint64_t typeIndex = getTypeID(f.funcType->inner);
|
||||
uint64_t typeIndex = getTypeID(f.funcType);
|
||||
|
||||
RDCASSERT((size_t)typeIndex < m_Types.size());
|
||||
|
||||
@@ -1357,7 +1357,7 @@ bytebuf ProgramEditor::EncodeProgram() const
|
||||
vals.push_back(flags);
|
||||
if(inst.opFlags != InstructionFlags::NoFlags)
|
||||
vals.push_back((uint64_t)inst.opFlags);
|
||||
vals.push_back(getTypeID(inst.funcCall->funcType->inner));
|
||||
vals.push_back(getTypeID(inst.funcCall->funcType));
|
||||
encodeRelativeValueID(Value(inst.funcCall));
|
||||
for(size_t a = 0; a < inst.args.size(); a++)
|
||||
{
|
||||
|
||||
@@ -628,8 +628,8 @@ void Program::MakeDisassemblyString()
|
||||
}
|
||||
|
||||
m_Disassembly += (func.external ? "declare " : "define ");
|
||||
m_Disassembly += func.funcType->inner->declFunction("@" + escapeStringIfNeeded(func.name),
|
||||
func.args, func.attrs);
|
||||
m_Disassembly +=
|
||||
func.funcType->declFunction("@" + escapeStringIfNeeded(func.name), func.args, func.attrs);
|
||||
|
||||
if(func.attrs && func.attrs->functionSlot)
|
||||
m_Disassembly += StringFormat::Fmt(" #%u", funcAttrGroups.indexOf(func.attrs->functionSlot));
|
||||
|
||||
Reference in New Issue
Block a user