Display matrix memory order in cbuffer type column. Refs #800

This commit is contained in:
baldurk
2018-02-19 11:53:20 +00:00
parent 41112d10e5
commit 2eb56e4279
9 changed files with 41 additions and 21 deletions
+6 -1
View File
@@ -840,7 +840,12 @@ QString TypeString(const ShaderVariable &v)
if(v.rows == 1)
return QFormatStr("%1%2").arg(typeStr).arg(v.columns);
else
return QFormatStr("%1%2x%3").arg(typeStr).arg(v.rows).arg(v.columns);
return QFormatStr("%1%2x%3 (%4)")
.arg(typeStr)
.arg(v.rows)
.arg(v.columns)
.arg(v.rowMajor ? QApplication::tr("row major", "FormatElement")
: QApplication::tr("column major", "FormatElement"));
}
template <typename el>
@@ -281,7 +281,7 @@ bool ConstantBufferPreviewer::updateVariables(RDTreeWidgetItem *root,
// different size or type? can't update
if(a.rows != b.rows || a.columns != b.columns || a.displayAsHex != b.displayAsHex ||
a.isStruct != b.isStruct || a.type != b.type)
a.isStruct != b.isStruct || a.rowMajor != b.rowMajor || a.type != b.type)
return false;
// update this node's value column
+10 -5
View File
@@ -187,10 +187,12 @@ struct ShaderVariable
return type < o.type;
if(!(displayAsHex == o.displayAsHex))
return displayAsHex < o.displayAsHex;
if(memcmp(&value, &o.value, sizeof(value)) < 0)
return true;
if(!(isStruct == o.isStruct))
return isStruct < o.isStruct;
if(!(rowMajor == o.rowMajor))
return rowMajor < o.rowMajor;
if(memcmp(&value, &o.value, sizeof(value)) < 0)
return true;
if(!(members == o.members))
return members < o.members;
return false;
@@ -206,15 +208,18 @@ struct ShaderVariable
DOCUMENT("The :class:`basic type <VarType>` of this variable.");
VarType type;
DOCUMENT("``True`` if the contents of this variable should be displayed as hex.");
bool displayAsHex;
DOCUMENT("The :class:`contents <ShaderValue>` of this variable if it has no members.");
ShaderValue value;
DOCUMENT("``True`` if the contents of this variable should be displayed as hex.");
bool displayAsHex;
DOCUMENT("``True`` if this variable is a structure and not an array or basic type.");
bool isStruct;
DOCUMENT("``True`` if this variable is stored in rows in memory. Only relevant for matrices.");
bool rowMajor;
DOCUMENT("The members of this variable as a list of :class:`ShaderValue`.");
rdcarray<ShaderVariable> members;
};
+4
View File
@@ -406,6 +406,7 @@ void D3D11DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
var.name = basename;
var.rows = var.columns = 0;
var.type = VarType::Float;
var.rowMajor = false;
std::vector<ShaderVariable> varmembers;
@@ -426,6 +427,7 @@ void D3D11DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
vr.name = basename + buf;
vr.rows = vr.columns = 0;
vr.type = VarType::Float;
vr.rowMajor = false;
std::vector<ShaderVariable> mems;
@@ -543,6 +545,7 @@ void D3D11DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
outvars[outIdx].type = type;
outvars[outIdx].isStruct = false;
outvars[outIdx].columns = cols;
outvars[outIdx].rowMajor = !columnMajor;
ShaderVariable &var = outvars[outIdx];
@@ -654,6 +657,7 @@ void D3D11DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
(*out)[outIdx + r].type = type;
(*out)[outIdx + r].isStruct = false;
(*out)[outIdx + r].columns = regLen;
(*out)[outIdx + r].rowMajor = !columnMajor;
size_t totalSize = 0;
+4
View File
@@ -485,6 +485,7 @@ void D3D12DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
var.name = basename;
var.rows = var.columns = 0;
var.type = VarType::Float;
var.rowMajor = false;
std::vector<ShaderVariable> varmembers;
@@ -505,6 +506,7 @@ void D3D12DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
vr.name = basename + buf;
vr.rows = vr.columns = 0;
vr.type = VarType::Float;
vr.rowMajor = false;
std::vector<ShaderVariable> mems;
@@ -621,6 +623,7 @@ void D3D12DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
outvars[outIdx].type = type;
outvars[outIdx].isStruct = false;
outvars[outIdx].columns = cols;
outvars[outIdx].rowMajor = !columnMajor;
ShaderVariable &var = outvars[outIdx];
@@ -732,6 +735,7 @@ void D3D12DebugManager::FillCBufferVariables(const std::string &prefix, size_t &
(*out)[outIdx + r].type = type;
(*out)[outIdx + r].isStruct = false;
(*out)[outIdx + r].columns = regLen;
(*out)[outIdx + r].rowMajor = !columnMajor;
size_t totalSize = 0;
+7 -9
View File
@@ -1748,9 +1748,8 @@ void GLReplay::SavePipelineState()
pipe.hints.polySmoothingEnabled = rs.Enabled[GLRenderState::eEnabled_PolySmooth];
}
void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, bool rowMajor,
uint32_t offs, uint32_t matStride, const bytebuf &data,
ShaderVariable &outVar)
void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, uint32_t offs,
uint32_t matStride, const bytebuf &data, ShaderVariable &outVar)
{
const byte *bufdata = data.empty() ? NULL : &data[offs];
size_t datasize = data.size() - offs;
@@ -1768,7 +1767,7 @@ void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacke
uint32_t majorsize = outVar.columns;
uint32_t minorsize = outVar.rows;
if(rowMajor)
if(outVar.rowMajor)
{
majorsize = outVar.rows;
minorsize = outVar.columns;
@@ -1803,7 +1802,7 @@ void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacke
}
}
if(!rowMajor)
if(!outVar.rowMajor)
{
if(outVar.type != VarType::Double)
{
@@ -1839,6 +1838,7 @@ void GLReplay::FillCBufferVariables(WrappedOpenGL &gl, GLuint prog, bool bufferB
var.rows = desc.rows;
var.columns = desc.columns;
var.type = desc.type;
var.rowMajor = desc.rowMajorStorage;
if(!variables[i].type.members.empty())
{
@@ -1902,8 +1902,7 @@ void GLReplay::FillCBufferVariables(WrappedOpenGL &gl, GLuint prog, bool bufferB
if(desc.elements == 0)
{
FillCBufferValue(gl, prog, bufferBacked, desc.rowMajorStorage ? true : false, values[0],
values[1], data, var);
FillCBufferValue(gl, prog, bufferBacked, values[0], values[1], data, var);
}
else
{
@@ -1913,8 +1912,7 @@ void GLReplay::FillCBufferVariables(WrappedOpenGL &gl, GLuint prog, bool bufferB
ShaderVariable el = var;
el.name = StringFormat::Fmt("%s[%u]", var.name.c_str(), a);
FillCBufferValue(gl, prog, bufferBacked, desc.rowMajorStorage ? true : false,
values[0] + values[2] * a, values[1], data, el);
FillCBufferValue(gl, prog, bufferBacked, values[0] + values[2] * a, values[1], data, el);
el.isStruct = false;
+2 -3
View File
@@ -237,9 +237,8 @@ public:
bool IsReplayContext(void *ctx) { return m_ReplayCtx.ctx == NULL || ctx == m_ReplayCtx.ctx; }
private:
void FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, bool rowMajor,
uint32_t offs, uint32_t matStride, const bytebuf &data,
ShaderVariable &outVar);
void FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, uint32_t offs,
uint32_t matStride, const bytebuf &data, ShaderVariable &outVar);
void FillCBufferVariables(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, std::string prefix,
const rdcarray<ShaderConstant> &variables,
std::vector<ShaderVariable> &outvars, const bytebuf &data);
+4
View File
@@ -1414,6 +1414,7 @@ void VulkanReplay::FillCBufferVariables(rdcarray<ShaderConstant> invars,
var.name = basename;
var.rows = var.columns = 0;
var.type = VarType::Float;
var.rowMajor = rowMajor;
vector<ShaderVariable> varmembers;
@@ -1425,6 +1426,7 @@ void VulkanReplay::FillCBufferVariables(rdcarray<ShaderConstant> invars,
vr.name = StringFormat::Fmt("%s[%u]", basename.c_str(), i);
vr.rows = vr.columns = 0;
vr.type = VarType::Float;
vr.rowMajor = rowMajor;
vector<ShaderVariable> mems;
@@ -1465,6 +1467,7 @@ void VulkanReplay::FillCBufferVariables(rdcarray<ShaderConstant> invars,
outvars[outIdx].type = invars[v].type.descriptor.type;
outvars[outIdx].isStruct = false;
outvars[outIdx].columns = cols;
outvars[outIdx].rowMajor = rowMajor;
size_t elemByteSize = 4;
if(outvars[outIdx].type == VarType::Double)
@@ -1541,6 +1544,7 @@ void VulkanReplay::FillCBufferVariables(rdcarray<ShaderConstant> invars,
varmembers[e].type = invars[v].type.descriptor.type;
varmembers[e].isStruct = false;
varmembers[e].columns = cols;
varmembers[e].rowMajor = rowMajor;
size_t rowDataOffset = dataOffset;
+3 -2
View File
@@ -321,12 +321,13 @@ void DoSerialise(SerialiserType &ser, ShaderVariable &el)
SERIALISE_MEMBER(columns);
SERIALISE_MEMBER(name);
SERIALISE_MEMBER(type);
SERIALISE_MEMBER(displayAsHex);
SERIALISE_MEMBER(isStruct);
SERIALISE_MEMBER(rowMajor);
SERIALISE_MEMBER(value.u64v);
SERIALISE_MEMBER(isStruct);
SERIALISE_MEMBER(members);
SIZE_CHECK(184);