Add boolean vartype

This commit is contained in:
baldurk committed 2020-04-24 20:14:48 +01:00
1 parent 76a866a5c2
commit 267798b240
15 files changed
+56 -27

No files matched your search

+13 -13
View File
@@ -272,7 +272,7 @@ ShaderConstant BufferFormatter::ParseFormatString(const QString &formatString, u
if(basetype == lit("bool"))
{
el.type.descriptor.type = VarType::UInt;
el.type.descriptor.type = VarType::Bool;
}
else if(basetype == lit("byte"))
{
@@ -849,18 +849,9 @@ QString BufferFormatter::DeclareStruct(QList<QString> &declaredStructs, const QS
}
uint32_t size = lastChild->type.descriptor.rows * lastChild->type.descriptor.columns;
if(lastChild->type.descriptor.type == VarType::Double ||
lastChild->type.descriptor.type == VarType::ULong ||
lastChild->type.descriptor.type == VarType::SLong)
size *= 8;
else if(lastChild->type.descriptor.type == VarType::Float ||
lastChild->type.descriptor.type == VarType::UInt ||
lastChild->type.descriptor.type == VarType::SInt)
size *= 4;
else if(lastChild->type.descriptor.type == VarType::Half ||
lastChild->type.descriptor.type == VarType::UShort ||
lastChild->type.descriptor.type == VarType::SShort)
size *= 2;
uint32_t typeSize = VarTypeByteSize(lastChild->type.descriptor.type);
if(typeSize > 1)
size *= typeSize;
if(lastChild->type.descriptor.elements > 1)
size *= lastChild->type.descriptor.elements;
@@ -911,6 +902,7 @@ ResourceFormat GetInterpretedResourceFormat(const ShaderConstant &elem)
case VarType::SShort:
case VarType::SLong:
case VarType::SByte: format.compType = CompType::SInt; break;
case VarType::Bool:
case VarType::UInt:
case VarType::UShort:
case VarType::ULong:
@@ -991,6 +983,8 @@ static void FillShaderVarData(ShaderVariable &var, const ShaderConstant &elem, c
var.value.u64v[dst] = o.toULongLong();
else if(var.type == VarType::SLong)
var.value.s64v[dst] = o.toLongLong();
else if(var.type == VarType::Bool)
var.value.uv[dst] = o.toBool() ? 1 : 0;
else if(var.type == VarType::UInt || var.type == VarType::UShort || var.type == VarType::UByte)
var.value.uv[dst] = o.toUInt();
else if(var.type == VarType::SInt || var.type == VarType::SShort || var.type == VarType::SByte)
@@ -1596,6 +1590,12 @@ QString RowString(const ShaderVariable &v, uint32_t row, VarType type)
return RowValuesToString((int)v.columns, v.displayAsHex, v.value.uv[row * v.columns + 0],
v.value.uv[row * v.columns + 1], v.value.uv[row * v.columns + 2],
v.value.uv[row * v.columns + 3]);
else if(type == VarType::Bool)
return RowValuesToString((int)v.columns, v.displayAsHex,
v.value.uv[row * v.columns + 0] ? true : false,
v.value.uv[row * v.columns + 1] ? true : false,
v.value.uv[row * v.columns + 2] ? true : false,
v.value.uv[row * v.columns + 3] ? true : false);
else
return RowValuesToString((int)v.columns, v.displayAsHex, v.value.fv[row * v.columns + 0],
v.value.fv[row * v.columns + 1], v.value.fv[row * v.columns + 2],
+1
View File
@@ -235,6 +235,7 @@ struct Formatter
{
return QFormatStr("%1").arg(u, hex ? 2 : 0, hex ? 16 : 10, QLatin1Char('0')).toUpper();
}
static QString Format(bool b, bool hex = false) { return b ? lit("true") : lit("false"); }
static QString HexFormat(uint32_t u, uint32_t byteSize)
{
if(byteSize == 1)
+6 -1
View File
@@ -2748,7 +2748,8 @@ void ShaderViewer::updateWatchVariables()
var.type == VarType::UShort || var.type == VarType::UByte)
regcast = QLatin1Char('u');
else if(var.type == VarType::SLong || var.type == VarType::SInt ||
var.type == VarType::SShort || var.type == VarType::SByte)
var.type == VarType::SShort || var.type == VarType::SByte ||
var.type == VarType::Bool)
regcast = QLatin1Char('i');
else if(var.type == VarType::Unknown)
regcast = ui->intView->isChecked() ? QLatin1Char('i') : QLatin1Char('f');
@@ -2858,6 +2859,8 @@ RDTreeWidgetItem *ShaderViewer::makeSourceVariableNode(const SourceVariableMappi
typeName = lit("float");
else if(l.type == VarType::Double)
typeName = lit("double");
else if(l.type == VarType::Bool)
typeName = lit("bool");
QList<RDTreeWidgetItem *> children;
@@ -3024,6 +3027,8 @@ RDTreeWidgetItem *ShaderViewer::makeSourceVariableNode(const SourceVariableMappi
value += Formatter::Format(reg->value.uv[r.component]);
else if(l.type == VarType::SInt)
value += Formatter::Format(reg->value.iv[r.component]);
else if(l.type == VarType::Bool)
value += Formatter::Format(reg->value.uv[r.component] ? true : false);
else if(l.type == VarType::Float)
value += Formatter::Format(reg->value.fv[r.component]);
else if(l.type == VarType::Double)