MCPcopy Create free account
hub / github.com/baldurk/renderdoc / UI_AddFixedVariables

Method UI_AddFixedVariables

qrenderdoc/Windows/BufferViewer.cpp:4264–4412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4262}
4263
4264void BufferViewer::UI_AddFixedVariables(RDTreeWidgetItem *root, uint32_t baseOffset,
4265 const rdcarray<ShaderConstant> &consts,
4266 const rdcarray<ShaderVariable> &vars)
4267{
4268 const bool showPadding = ui->showPadding->isChecked() && m_CurCBuffer.bytesBacked;
4269
4270 if(consts.size() != vars.size())
4271 qCritical() << "Shader variable mismatch";
4272
4273 uint32_t offset = 0;
4274
4275 for(size_t idx = 0; idx < consts.size() && idx < vars.size(); idx++)
4276 {
4277 const ShaderConstant &c = consts[idx];
4278 const ShaderVariable &v = vars[idx];
4279
4280 if(showPadding && c.byteOffset > offset)
4281 {
4282 uint32_t size = c.byteOffset - offset;
4283
4284 RDTreeWidgetItem *pad = new RDTreeWidgetItem({
4285 QString(),
4286 QFormatStr("%1 bytes").arg(Formatter::HumanFormat(size, Formatter::OffsetSize)),
4287 QString(),
4288 tr("Padding"),
4289 });
4290
4291 pad->setItalic(true);
4292 pad->setTag(QVariant::fromValue(FixedVarTag(size)));
4293
4294 root->addChild(pad);
4295
4296 offset = c.byteOffset;
4297 }
4298
4299 QVariant offsetStr = Formatter::HumanFormat(baseOffset + c.byteOffset, Formatter::OffsetSize);
4300
4301 if(c.bitFieldSize != 0)
4302 {
4303 offsetStr =
4304 offsetStr.toString() +
4305 QFormatStr(" (bits %1:%2)").arg(c.bitFieldOffset).arg(c.bitFieldOffset + c.bitFieldSize);
4306 }
4307
4308 if(m_CurCBuffer.compileConstants)
4309 offsetStr = lit("-");
4310
4311 RDTreeWidgetItem *n =
4312 new RDTreeWidgetItem({v.name, VarString(v, c), offsetStr, TypeString(v, c)});
4313
4314 // display colour swatch for floats with RGB display
4315 if((v.flags & ShaderVariableFlags::RGBDisplay) && VarTypeCompType(v.type) == CompType::Float &&
4316 v.rows == 1 && v.columns >= 1 && v.members.empty())
4317 {
4318 QColor swatchColor(0, 0, 0, 255);
4319 float rgb[3] = {0.0f, 0.0f, 0.0f};
4320 for(uint8_t col = 0; col < v.columns && col < 4; col++)
4321 {

Callers

nothing calls this directly

Calls 15

fromValueFunction · 0.85
FixedVarTagClass · 0.85
VarStringFunction · 0.85
VarTypeCompTypeFunction · 0.85
MakeSwatchIconFunction · 0.85
setTagMethod · 0.80
QStringFunction · 0.50
trFunction · 0.50
TypeStringFunction · 0.50
ConvertLinearToSRGBFunction · 0.50
sizeMethod · 0.45
argMethod · 0.45

Tested by

no test coverage detected