mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-26 17:31:42 +00:00
Add boolean vartype
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -832,8 +832,13 @@ rdcstr DoStringise(const VarType &el)
|
||||
STRINGISE_ENUM_CLASS_NAMED(ULong, "ulong");
|
||||
STRINGISE_ENUM_CLASS_NAMED(SByte, "byte");
|
||||
STRINGISE_ENUM_CLASS_NAMED(UByte, "ubyte");
|
||||
STRINGISE_ENUM_CLASS_NAMED(Unknown, "unknown");
|
||||
STRINGISE_ENUM_CLASS_NAMED(Bool, "bool");
|
||||
STRINGISE_ENUM_CLASS_NAMED(GPUPointer, "pointer");
|
||||
STRINGISE_ENUM_CLASS_NAMED(ConstantBlock, "cbuffer");
|
||||
STRINGISE_ENUM_CLASS_NAMED(ReadOnlyResource, "resource");
|
||||
STRINGISE_ENUM_CLASS_NAMED(ReadWriteResource, "rwresource");
|
||||
STRINGISE_ENUM_CLASS_NAMED(Sampler, "sampler");
|
||||
STRINGISE_ENUM_CLASS_NAMED(Unknown, "unknown");
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
@@ -195,6 +195,10 @@ DOCUMENT(R"(Represents the base type of a shader variable in debugging or consta
|
||||
|
||||
An unsigned 8-bit integer value.
|
||||
|
||||
.. data:: Bool
|
||||
|
||||
A boolean value.
|
||||
|
||||
.. data:: GPUPointer
|
||||
|
||||
A 64-bit pointer into GPU-addressable memory. Variables with this type are stored with opaque
|
||||
@@ -237,6 +241,7 @@ enum class VarType : uint8_t
|
||||
ULong,
|
||||
SByte,
|
||||
UByte,
|
||||
Bool,
|
||||
GPUPointer,
|
||||
ConstantBlock,
|
||||
ReadOnlyResource,
|
||||
@@ -260,7 +265,7 @@ constexpr uint32_t VarTypeByteSize(VarType type)
|
||||
// clang-format off
|
||||
return (type == VarType::UByte || type == VarType::SByte) ? 1
|
||||
: (type == VarType::Half || type == VarType::UShort || type == VarType::SShort) ? 2
|
||||
: (type == VarType::Float || type == VarType::UInt || type == VarType::SInt ) ? 4
|
||||
: (type == VarType::Float || type == VarType::UInt || type == VarType::SInt || type == VarType::Bool) ? 4
|
||||
: (type == VarType::Double || type == VarType::ULong || type == VarType::SLong ) ? 8
|
||||
: 0;
|
||||
// clang-format on
|
||||
|
||||
@@ -260,6 +260,9 @@ struct GLWindowingData
|
||||
#error "Unknown platform"
|
||||
#endif
|
||||
|
||||
#undef None
|
||||
#undef Bool
|
||||
|
||||
struct GLPlatform
|
||||
{
|
||||
// simple wrapper for OS functions to make/delete a context
|
||||
|
||||
@@ -2083,6 +2083,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b
|
||||
case VarType::SInt:
|
||||
GL.glGetUniformiv(prog, location, (int32_t *)uniformData.data());
|
||||
break;
|
||||
case VarType::Bool:
|
||||
case VarType::UInt:
|
||||
GL.glGetUniformuiv(prog, location, (uint32_t *)uniformData.data());
|
||||
break;
|
||||
@@ -2133,6 +2134,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b
|
||||
case VarType::SInt:
|
||||
GL.glGetUniformiv(prog, location + a, (int32_t *)uniformData.data());
|
||||
break;
|
||||
case VarType::Bool:
|
||||
case VarType::UInt:
|
||||
GL.glGetUniformuiv(prog, location + a, (uint32_t *)uniformData.data());
|
||||
break;
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "gl_common.h"
|
||||
|
||||
#define Bool int
|
||||
|
||||
// glX functions
|
||||
typedef GLXContext (*PFN_glXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList,
|
||||
Bool direct);
|
||||
|
||||
@@ -39,7 +39,7 @@ static ShaderVariableType MakeShaderVariableType(DXBC::CBufferVariableType type)
|
||||
case DXBC::VARTYPE_MIN12INT:
|
||||
case DXBC::VARTYPE_MIN16INT:
|
||||
case DXBC::VARTYPE_INT: ret.descriptor.type = VarType::SInt; break;
|
||||
case DXBC::VARTYPE_BOOL:
|
||||
case DXBC::VARTYPE_BOOL: ret.descriptor.type = VarType::Bool; break;
|
||||
case DXBC::VARTYPE_MIN16UINT:
|
||||
case DXBC::VARTYPE_UINT: ret.descriptor.type = VarType::UInt; break;
|
||||
case DXBC::VARTYPE_DOUBLE: ret.descriptor.type = VarType::Double; break;
|
||||
|
||||
@@ -206,7 +206,7 @@ SPDBChunk::SPDBChunk(void *chunk)
|
||||
typeInfo[T_LONG] = {"int32_t", VarType::SInt, 4, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_SHORT] = {"int16_t", VarType::SInt, 2, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_CHAR] = {"char", VarType::SInt, 1, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_BOOL32FF] = {"bool", VarType::UInt, 4, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_BOOL32FF] = {"bool", VarType::Bool, 4, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_UINT4] = {"uint32_t", VarType::UInt, 4, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_UINT2] = {"uint16_t", VarType::UInt, 2, 1, 0, 0, LF_NUMERIC, {}};
|
||||
typeInfo[T_UINT1] = {"uint8_t", VarType::UInt, 1, 1, 0, 0, LF_NUMERIC, {}};
|
||||
|
||||
@@ -565,8 +565,7 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
|
||||
|
||||
ShaderVariable var;
|
||||
var.rows = var.columns = 1;
|
||||
// TODO we should add a bool type
|
||||
var.type = VarType::UInt;
|
||||
var.type = VarType::Bool;
|
||||
|
||||
if(opdata.op == Op::PtrEqual)
|
||||
var.value.uv[0] = isEqual ? 1 : 0;
|
||||
@@ -1295,8 +1294,7 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
|
||||
var.value.uv[c] = (var.value.fv[c] > b.value.fv[c]) ? 0 : 1;
|
||||
}
|
||||
|
||||
// TODO we should add a bool type
|
||||
var.type = VarType::UInt;
|
||||
var.type = VarType::Bool;
|
||||
|
||||
SetDst(comp.result, var);
|
||||
break;
|
||||
@@ -1310,6 +1308,8 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
|
||||
for(uint8_t c = 0; c < var.columns; c++)
|
||||
var.value.uv[c] = 1U - var.value.uv[c];
|
||||
|
||||
var.type = VarType::Bool;
|
||||
|
||||
SetDst(negate.result, var);
|
||||
break;
|
||||
}
|
||||
@@ -1342,8 +1342,7 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
|
||||
for(uint8_t c = 0; c < var.columns; c++)
|
||||
var.value.uv[c] = isnan(var.value.fv[c]) ? 1 : 0;
|
||||
|
||||
// TODO we should add a bool type
|
||||
var.type = VarType::UInt;
|
||||
var.type = VarType::Bool;
|
||||
|
||||
SetDst(is.result, var);
|
||||
break;
|
||||
@@ -1357,8 +1356,7 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
|
||||
for(uint8_t c = 0; c < var.columns; c++)
|
||||
var.value.uv[c] = isinf(var.value.fv[c]) ? 1 : 0;
|
||||
|
||||
// TODO we should add a bool type
|
||||
var.type = VarType::UInt;
|
||||
var.type = VarType::Bool;
|
||||
|
||||
SetDst(is.result, var);
|
||||
break;
|
||||
|
||||
@@ -412,6 +412,7 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint,
|
||||
case VarType::SInt:
|
||||
case VarType::SShort:
|
||||
case VarType::SByte: ret += ToStr(value.i.x); break;
|
||||
case VarType::Bool: ret += value.u.x ? "true" : "false"; break;
|
||||
case VarType::UInt:
|
||||
case VarType::UShort:
|
||||
case VarType::UByte: ret += ToStr(value.u.x); break;
|
||||
@@ -1571,6 +1572,7 @@ rdcstr Reflector::StringiseConstant(rdcspv::Id id) const
|
||||
case VarType::SInt:
|
||||
case VarType::SShort:
|
||||
case VarType::SByte: return ToStr(value.value.i.x);
|
||||
case VarType::Bool: return value.value.u.x ? "true" : "false";
|
||||
case VarType::UInt:
|
||||
case VarType::UShort:
|
||||
case VarType::UByte: return ToStr(value.value.u.x);
|
||||
@@ -1601,6 +1603,7 @@ rdcstr Reflector::StringiseConstant(rdcspv::Id id) const
|
||||
case VarType::UShort:
|
||||
case VarType::UByte: ret += ToStr(value.value.uv[i]); break;
|
||||
case VarType::SLong: ret += ToStr(value.value.s64v[i]); break;
|
||||
case VarType::Bool: return value.value.u.x ? "true" : "false";
|
||||
case VarType::Unknown:
|
||||
case VarType::GPUPointer:
|
||||
case VarType::ConstantBlock:
|
||||
|
||||
@@ -522,6 +522,7 @@ void Processor::RegisterOp(Iter it)
|
||||
|
||||
ShaderVariable v("true", 1, 0, 0, 0);
|
||||
v.columns = 1;
|
||||
v.type = VarType::Bool;
|
||||
|
||||
constants[decoded.result] = {decoded.resultType, decoded.result, v, {}, opdata.op};
|
||||
if(opdata.op == Op::SpecConstantTrue)
|
||||
@@ -533,6 +534,7 @@ void Processor::RegisterOp(Iter it)
|
||||
|
||||
ShaderVariable v("true", 0, 0, 0, 0);
|
||||
v.columns = 1;
|
||||
v.type = VarType::Bool;
|
||||
|
||||
constants[decoded.result] = {decoded.resultType, decoded.result, v, {}, opdata.op};
|
||||
if(opdata.op == Op::SpecConstantFalse)
|
||||
|
||||
@@ -86,7 +86,7 @@ struct Scalar
|
||||
}
|
||||
else if(type == Op::TypeBool)
|
||||
{
|
||||
return VarType::UInt;
|
||||
return VarType::Bool;
|
||||
}
|
||||
|
||||
return VarType::Unknown;
|
||||
|
||||
@@ -62,6 +62,9 @@
|
||||
#include "serialise/serialiser.h"
|
||||
#include "vk_dispatchtables.h"
|
||||
|
||||
#undef Bool
|
||||
#undef None
|
||||
|
||||
// enable this to cause every internal QueueSubmit to immediately call DeviceWaitIdle(), and to only
|
||||
// submit one command buffer at once to narrow down the cause of device lost errors
|
||||
#define SINGLE_FLUSH_VALIDATE OPTION_OFF
|
||||
|
||||
Reference in New Issue
Block a user