| 4197 | } |
| 4198 | |
| 4199 | void BufferViewer::UI_AddTaskPayloads(RDTreeWidgetItem *root, size_t baseOffset, |
| 4200 | const rdcarray<ShaderConstant> &consts, BufferData *buffer) |
| 4201 | { |
| 4202 | uint32_t offset = 0; |
| 4203 | |
| 4204 | for(size_t idx = 0; idx < consts.size(); idx++) |
| 4205 | { |
| 4206 | const ShaderConstant &c = consts[idx]; |
| 4207 | ShaderVariable v = InterpretShaderVar(c, buffer->data() + baseOffset + offset, buffer->end()); |
| 4208 | |
| 4209 | RDTreeWidgetItem *n = new RDTreeWidgetItem({v.name, VarString(v, c), TypeString(v, c)}); |
| 4210 | |
| 4211 | root->addChild(n); |
| 4212 | |
| 4213 | TaskAddMatrixRows(n, c, v); |
| 4214 | |
| 4215 | // if it's an array the value (v) will be expanded with one element in each of v.members, but |
| 4216 | // the constant (c) will just have the type with a number of elements |
| 4217 | if(c.type.elements > 1) |
| 4218 | { |
| 4219 | ShaderConstant noarray = c; |
| 4220 | noarray.type.elements = 1; |
| 4221 | |
| 4222 | // calculate the tight scalar-packed advance, so we can detect padding |
| 4223 | uint32_t elSize = BufferFormatter::GetVarAdvance(Packing::Scalar, noarray); |
| 4224 | |
| 4225 | for(uint32_t e = 0; e < v.members.size(); e++) |
| 4226 | { |
| 4227 | const uint32_t elOffset = (uint32_t)baseOffset + c.byteOffset + c.type.arrayByteStride * e; |
| 4228 | |
| 4229 | RDTreeWidgetItem *el = new RDTreeWidgetItem( |
| 4230 | {v.members[e].name, VarString(v.members[e], c), TypeString(v.members[e], c)}); |
| 4231 | |
| 4232 | // if it's an array of structs we can recurse, just need to do the outer iteration here |
| 4233 | // because v.members[...].members will be the actual struct members because of the expansion |
| 4234 | if(c.type.baseType == VarType::Struct) |
| 4235 | { |
| 4236 | UI_AddTaskPayloads(el, elOffset, c.type.members, buffer); |
| 4237 | } |
| 4238 | else |
| 4239 | { |
| 4240 | // otherwise just expand by hand since there will be no more members in c.type.members for |
| 4241 | // us to recurse with |
| 4242 | TaskAddMatrixRows(el, c, v.members[e]); |
| 4243 | } |
| 4244 | |
| 4245 | n->addChild(el); |
| 4246 | |
| 4247 | // don't count the padding in the last struct in an array of structs, it will be handled as |
| 4248 | // padding after the array |
| 4249 | if(c.type.baseType == VarType::Struct && e + 1 == v.members.size()) |
| 4250 | break; |
| 4251 | } |
| 4252 | } |
| 4253 | // for single structs, recurse |
| 4254 | else if(v.type == VarType::Struct) |
| 4255 | { |
| 4256 | UI_AddTaskPayloads(n, c.byteOffset, c.type.members, buffer); |
nothing calls this directly
no test coverage detected