| 4422 | } |
| 4423 | |
| 4424 | void BufferViewer::calcBoundingData(CalcBoundingBoxData &bbox) |
| 4425 | { |
| 4426 | for(size_t stage = 0; stage < ARRAY_COUNT(bbox.input); stage++) |
| 4427 | { |
| 4428 | const BufferConfiguration &s = bbox.input[stage]; |
| 4429 | |
| 4430 | QList<FloatVector> &minOutputList = bbox.output.bounds[stage].Min; |
| 4431 | QList<FloatVector> &maxOutputList = bbox.output.bounds[stage].Max; |
| 4432 | |
| 4433 | minOutputList.reserve(s.columns.count()); |
| 4434 | maxOutputList.reserve(s.columns.count()); |
| 4435 | |
| 4436 | for(int i = 0; i < s.columns.count(); i++) |
| 4437 | { |
| 4438 | FloatVector maxvec(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX); |
| 4439 | |
| 4440 | if(s.columns[i].type.columns == 1) |
| 4441 | maxvec.y = maxvec.z = maxvec.w = 0.0; |
| 4442 | else if(s.columns[i].type.columns == 2) |
| 4443 | maxvec.z = maxvec.w = 0.0; |
| 4444 | else if(s.columns[i].type.columns == 3) |
| 4445 | maxvec.w = 0.0; |
| 4446 | |
| 4447 | minOutputList.push_back(maxvec); |
| 4448 | maxOutputList.push_back(FloatVector(-maxvec.x, -maxvec.y, -maxvec.z, -maxvec.w)); |
| 4449 | } |
| 4450 | |
| 4451 | QVector<CachedElData> cache; |
| 4452 | |
| 4453 | CacheDataForIteration(cache, s.columns, s.props, s.buffers, bbox.input[0].curInstance); |
| 4454 | |
| 4455 | // possible optimisation here if this shows up as a hot spot - sort and unique the indices and |
| 4456 | // iterate in ascending order, to be more cache friendly |
| 4457 | |
| 4458 | for(uint32_t row = 0; row < s.numRows; row++) |
| 4459 | { |
| 4460 | uint32_t idx = row; |
| 4461 | |
| 4462 | if(s.indices && s.indices->hasData()) |
| 4463 | { |
| 4464 | idx = CalcIndex(s.indices, row, s.baseVertex, s.primRestart); |
| 4465 | |
| 4466 | if(idx == ~0U || (s.primRestart && idx == s.primRestart)) |
| 4467 | continue; |
| 4468 | } |
| 4469 | |
| 4470 | for(int col = 0; col < s.columns.count(); col++) |
| 4471 | { |
| 4472 | const CachedElData &d = cache[col]; |
| 4473 | const ShaderConstant *el = d.el; |
| 4474 | const BufferElementProperties *prop = d.prop; |
| 4475 | |
| 4476 | float *minOut = (float *)&minOutputList[col]; |
| 4477 | float *maxOut = (float *)&maxOutputList[col]; |
| 4478 | |
| 4479 | if(d.data) |
| 4480 | { |
| 4481 | const byte *bytes = d.data; |
nothing calls this directly
no test coverage detected