mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-13 02:01:08 +00:00
Remove register/HLSL handling from shader viewer, work agnostically
* The shader viewer shouldn't handle specifics of D3D bytecode, instead it now works generally with whatever the debug and source variables are. * VarType::Unknown is used for D3D registers which are typeless.
This commit is contained in:
@@ -1511,6 +1511,8 @@ QString TypeString(const ShaderVariable &v)
|
||||
typeStr = lit("xbyte");
|
||||
}
|
||||
|
||||
if(v.type == VarType::Unknown)
|
||||
return lit("Typeless");
|
||||
if(v.rows == 1 && v.columns == 1)
|
||||
return typeStr;
|
||||
if(v.rows == 1)
|
||||
|
||||
+546
-516
File diff suppressed because it is too large
Load Diff
@@ -164,15 +164,12 @@ private:
|
||||
void PopulateCompileToolParameters();
|
||||
bool ProcessIncludeDirectives(QString &source, const rdcstrpairs &files);
|
||||
|
||||
void getRegisterFromWord(const QString &text, VariableCategory &varCat, int &index, int &member);
|
||||
|
||||
void updateWindowTitle();
|
||||
void gotoSourceDebugging();
|
||||
void gotoDisassemblyDebugging();
|
||||
|
||||
void insertSnippet(const QString &text);
|
||||
|
||||
void showVariableTooltip(VariableCategory varCat, int index, int member);
|
||||
void showVariableTooltip(QString name);
|
||||
void updateVariableTooltip();
|
||||
void hideVariableTooltip();
|
||||
@@ -181,7 +178,6 @@ private:
|
||||
|
||||
ShaderEncoding currentEncoding();
|
||||
|
||||
VariableCategory m_TooltipVarCat = VariableCategory::Variables;
|
||||
QString m_TooltipName;
|
||||
int m_TooltipVarIndex = -1;
|
||||
int m_TooltipMember = -1;
|
||||
@@ -267,11 +263,12 @@ private:
|
||||
int instructionForDisassemblyLine(sptr_t line);
|
||||
|
||||
void updateDebugging();
|
||||
void updateWatchVariables();
|
||||
|
||||
RDTreeWidgetItem *makeSourceVariableNode(const SourceVariableMapping &l);
|
||||
RDTreeWidgetItem *makeSourceVariableNode(const SourceVariableMapping &l, int globalVarIdx,
|
||||
int localVarIdx);
|
||||
|
||||
const ShaderVariable *GetRegisterVariable(const DebugVariableReference &r);
|
||||
const ShaderVariable *GetRegisterVariable(VariableCategory category, int index, int member);
|
||||
|
||||
void ensureLineScrolled(ScintillaEdit *s, int i);
|
||||
|
||||
@@ -280,7 +277,11 @@ private:
|
||||
void runTo(QVector<size_t> runToInstructions, bool forward,
|
||||
ShaderEvents condition = ShaderEvents::NoEvent);
|
||||
|
||||
QString stringRep(const ShaderVariable &var, bool useType);
|
||||
QString stringRep(const ShaderVariable &var);
|
||||
void combineStructures(RDTreeWidgetItem *root, int skipPrefixLength = 0);
|
||||
RDTreeWidgetItem *findLocal(RDTreeWidgetItem *root, QString name);
|
||||
RDTreeWidgetItem *findVarInTree(RDTreeWidgetItem *root, QString name, bool fullmatch, int maxDepth);
|
||||
void highlightMatchingVars(RDTreeWidgetItem *root, const QString varName,
|
||||
const QColor highlightColor);
|
||||
bool findVar(QString name, ShaderVariable *var = NULL);
|
||||
bool getVar(RDTreeWidgetItem *item, ShaderVariable *var, QString *regNames);
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ struct ShaderVariable
|
||||
name = "";
|
||||
rows = columns = 0;
|
||||
displayAsHex = isStruct = rowMajor = isPointer = false;
|
||||
type = VarType::Float;
|
||||
type = VarType::Unknown;
|
||||
for(int i = 0; i < 16; i++)
|
||||
value.uv[i] = 0;
|
||||
}
|
||||
@@ -332,7 +332,10 @@ struct DebugVariableReference
|
||||
DebugVariableReference() = default;
|
||||
DebugVariableReference(const DebugVariableReference &) = default;
|
||||
DebugVariableReference &operator=(const DebugVariableReference &) = default;
|
||||
|
||||
DebugVariableReference(DebugVariableType type, rdcstr name, uint32_t component = 0)
|
||||
: name(name), type(type), component(component)
|
||||
{
|
||||
}
|
||||
bool operator==(const DebugVariableReference &o) const
|
||||
{
|
||||
return name == o.name && type == o.type && component == o.component;
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
#include "os/os_specific.h"
|
||||
#include "dxbc_container.h"
|
||||
|
||||
static ShaderVariable makeReg(rdcstr name)
|
||||
{
|
||||
ShaderVariable ret(name, 0U, 0U, 0U, 0U);
|
||||
ret.type = VarType::Unknown;
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace DXBCBytecode
|
||||
{
|
||||
Program::Program(const byte *bytes, size_t length)
|
||||
@@ -461,31 +468,28 @@ void Program::SetupRegisterFile(rdcarray<ShaderVariable> ®isters) const
|
||||
registers.reserve(numRegisters);
|
||||
|
||||
for(uint32_t i = 0; i < m_NumTemps; i++)
|
||||
registers.push_back(ShaderVariable(GetRegisterName(TYPE_TEMP, i), 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(GetRegisterName(TYPE_TEMP, i)));
|
||||
|
||||
for(size_t i = 0; i < m_IndexTempSizes.size(); i++)
|
||||
{
|
||||
rdcstr name = GetRegisterName(TYPE_INDEXABLE_TEMP, (uint32_t)i);
|
||||
registers.push_back(ShaderVariable(name, 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(name));
|
||||
registers.back().members.resize(m_IndexTempSizes[i]);
|
||||
for(uint32_t t = 0; t < m_IndexTempSizes[i]; t++)
|
||||
{
|
||||
registers.back().members[t] =
|
||||
ShaderVariable(StringFormat::Fmt("%s[%u]", name.c_str(), t), 0l, 0l, 0l, 0l);
|
||||
}
|
||||
registers.back().members[t] = makeReg(StringFormat::Fmt("%s[%u]", name.c_str(), t));
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < m_NumOutputs; i++)
|
||||
registers.push_back(ShaderVariable("", 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(rdcstr()));
|
||||
|
||||
// this could be oDepthGE or oDepthLE, that will be fixed up when the external code sets up the
|
||||
// names etc of all outputs with reflection info
|
||||
if(m_OutputDepth)
|
||||
registers.push_back(ShaderVariable("", 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(rdcstr()));
|
||||
if(m_OutputStencil)
|
||||
registers.push_back(ShaderVariable("", 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(rdcstr()));
|
||||
if(m_OutputCoverage)
|
||||
registers.push_back(ShaderVariable("", 0l, 0l, 0l, 0l));
|
||||
registers.push_back(makeReg(rdcstr()));
|
||||
}
|
||||
|
||||
uint32_t Program::GetRegisterIndex(OperandType type, uint32_t index) const
|
||||
|
||||
@@ -1681,7 +1681,7 @@ void FlattenSingleVariable(const rdcstr &cbname, uint32_t byteOffset, const rdcs
|
||||
for(uint32_t reg = 0; reg < numRegisters; reg++)
|
||||
{
|
||||
outvars[outIdx + reg].rows = 1;
|
||||
outvars[outIdx + reg].type = v.type;
|
||||
outvars[outIdx + reg].type = VarType::Unknown;
|
||||
outvars[outIdx + reg].isStruct = false;
|
||||
outvars[outIdx + reg].columns = v.columns;
|
||||
outvars[outIdx + reg].rowMajor = v.rowMajor;
|
||||
|
||||
Reference in New Issue
Block a user