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

Method evaluateVar

qrenderdoc/Windows/ShaderViewer.cpp:3447–3697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3445}
3446
3447const RDTreeWidgetItem *ShaderViewer::evaluateVar(const RDTreeWidgetItem *item, uint32_t swizzle,
3448 ShaderVariable *var,
3449 SourceVariableMapping *mappingPtr)
3450{
3451 VariableTag tag = item->tag().value<VariableTag>();
3452
3453 // if the tag is invalid, it's not a proper match
3454 if(tag.absoluteRefPath.empty())
3455 return NULL;
3456
3457 // if we have a debug var tag then it's easy-mode
3458 if(tag.debugVarType != DebugVariableType::Undefined)
3459 {
3460 // found a match. If we don't want the variable contents, just return true now
3461 if(!var)
3462 return item;
3463
3464 DebugVariableReference debugVar;
3465 debugVar.type = tag.debugVarType;
3466 debugVar.name = tag.absoluteRefPath;
3467
3468 const ShaderVariable *reg = GetDebugVariable(debugVar);
3469
3470 if(reg)
3471 {
3472 *var = *reg;
3473 var->name = debugVar.name;
3474
3475 if(swizzle != ~0U)
3476 {
3477 // only support swizzles if the debug variable is a plain vector or scalar
3478 if(!reg->members.empty() || reg->rows > 1)
3479 return NULL;
3480
3481 var->value = ShaderValue();
3482
3483 size_t compSize = VarTypeByteSize(var->type);
3484 for(uint32_t i = 0; i < 4; i++)
3485 {
3486 uint8_t sw = (swizzle >> (i * 8)) & 0xff;
3487
3488 if(sw == 0xff)
3489 {
3490 // swizzle has finished, truncate
3491 break;
3492 }
3493 else if(sw < reg->columns)
3494 {
3495 var->columns = i + 1;
3496
3497 memcpy(var->value.u8v.data() + compSize * i, reg->value.u8v.data() + compSize * sw,
3498 compSize);
3499 }
3500 else
3501 {
3502 // out of bounds swizzle
3503 return NULL;
3504 }

Callers

nothing calls this directly

Calls 15

VarTypeByteSizeFunction · 0.85
ShaderVariableClass · 0.85
memcpyFunction · 0.50
ToQStrFunction · 0.50
QStringFunction · 0.50
tagMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
parentMethod · 0.45
countMethod · 0.45
childCountMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected