improved names for workload::Region constants

This commit is contained in:
Andrew Meadows 2019-07-11 11:17:04 -07:00
parent 1a5a925a4c
commit ba8978862d
6 changed files with 20 additions and 21 deletions

View file

@ -26,10 +26,9 @@ public:
INVALID, // INVALID = not known to workload
};
static const uint8_t NUM_CLASSIFICATIONS = 4;
static const uint8_t NUM_TRANSITIONS = NUM_CLASSIFICATIONS * (NUM_CLASSIFICATIONS - 1);
static const uint8_t NUM_VIEW_REGIONS = (NUM_CLASSIFICATIONS - 1);
static constexpr uint32_t NUM_KNOWN_REGIONS = uint32_t(Region::R4 - Region::R1 + 1); // R1 through R4 inclusive
static constexpr uint32_t NUM_TRACKED_REGIONS = uint32_t(Region::R3 - Region::R1 + 1); // R1 through R3 inclusive
static const uint8_t NUM_REGION_TRANSITIONS = NUM_KNOWN_REGIONS * (NUM_KNOWN_REGIONS - 1);
static uint8_t computeTransitionIndex(uint8_t prevIndex, uint8_t newIndex);
@ -63,11 +62,11 @@ inline uint8_t Region::computeTransitionIndex(uint8_t prevIndex, uint8_t newInde
// 3 | | | | |
// | 9 | 10 | 11 | -1 |
// +-------+-------+-------+-------+
uint8_t p = prevIndex + Region::NUM_CLASSIFICATIONS * newIndex;
if (0 == (p % (Region::NUM_CLASSIFICATIONS + 1))) {
uint8_t p = prevIndex + Region::NUM_KNOWN_REGIONS * newIndex;
if (0 == (p % (Region::NUM_KNOWN_REGIONS + 1))) {
return -1;
}
return p - (1 + p / (Region::NUM_CLASSIFICATIONS + 1));
return p - (1 + p / (Region::NUM_KNOWN_REGIONS + 1));
}
} // namespace workload

View file

@ -34,7 +34,7 @@ void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs)
space->categorizeAndGetChanges(outChanges);
// use exit/enter lists for each region less than Region::R4
outRegionChanges.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1));
outRegionChanges.resize(2 * workload::Region::NUM_TRACKED_REGIONS);
for (uint32_t i = 0; i < outChanges.size(); ++i) {
Space::Change& change = outChanges[i];
if (change.prevRegion < Region::R4) {

View file

@ -42,11 +42,11 @@ Sphere View::evalRegionSphere(const View& view, float originRadius, float maxDis
}
void View::updateRegionsDefault(View& view) {
std::vector<float> config(Region::NUM_VIEW_REGIONS * 2, 0.0f);
std::vector<float> config(Region::NUM_TRACKED_REGIONS * 2, 0.0f);
float refFar = 10.0f;
float refClose = 2.0f;
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
for (int i = 0; i < Region::NUM_TRACKED_REGIONS; i++) {
float weight = i + 1.0f;
config[i * 2] = refClose;
config[i * 2 + 1] = refFar * weight;
@ -56,13 +56,13 @@ void View::updateRegionsDefault(View& view) {
}
void View::updateRegionsFromBackFronts(View& view) {
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
for (int i = 0; i < Region::NUM_TRACKED_REGIONS; i++) {
view.regions[i] = evalRegionSphere(view, view.regionBackFronts[i].x, view.regionBackFronts[i].y);
}
}
void View::updateRegionsFromBackFrontDistances(View& view, const float* configDistances) {
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
for (int i = 0; i < Region::NUM_TRACKED_REGIONS; i++) {
view.regionBackFronts[i] = glm::vec2(configDistances[i * 2], configDistances[i * 2 + 1]);
}
updateRegionsFromBackFronts(view);

View file

@ -48,10 +48,10 @@ public:
float originRadius{ 0.5f };
// N regions distances
glm::vec2 regionBackFronts[Region::NUM_VIEW_REGIONS + 1];
glm::vec2 regionBackFronts[Region::NUM_TRACKED_REGIONS];
// N regions spheres
Sphere regions[Region::NUM_VIEW_REGIONS];
Sphere regions[Region::NUM_TRACKED_REGIONS];
// Set fov properties from angle
void setFov(float angleRad);

View file

@ -82,7 +82,7 @@ void SetupViews::run(const WorkloadContextPointer& renderContext, const Input& i
ControlViews::ControlViews() {
for (int32_t i = 0; i < workload::Region::NUM_VIEW_REGIONS; i++) {
for (int32_t i = 0; i < workload::Region::NUM_TRACKED_REGIONS; i++) {
regionBackFronts[i] = MIN_VIEW_BACK_FRONTS[i];
regionRegulators[i] = Regulator(std::chrono::milliseconds(2), MIN_VIEW_BACK_FRONTS[i], MAX_VIEW_BACK_FRONTS[i], glm::vec2(RELATIVE_STEP_DOWN), glm::vec2(RELATIVE_STEP_UP));
}
@ -166,7 +166,7 @@ glm::vec2 Regulator::clamp(const glm::vec2& backFront) const {
void ControlViews::regulateViews(workload::Views& outViews, const workload::Timings& timings) {
for (auto& outView : outViews) {
for (int32_t r = 0; r < workload::Region::NUM_VIEW_REGIONS; r++) {
for (int32_t r = 0; r < workload::Region::NUM_TRACKED_REGIONS; r++) {
outView.regionBackFronts[r] = regionBackFronts[r];
}
}
@ -198,12 +198,12 @@ void ControlViews::enforceRegionContainment() {
// and each region should never exceed its min/max limits
const glm::vec2 MIN_REGION_GAP = { 1.0f, 2.0f };
// enforce outside --> in
for (int32_t i = workload::Region::NUM_VIEW_REGIONS - 2; i >= 0; --i) {
for (int32_t i = workload::Region::NUM_TRACKED_REGIONS - 2; i >= 0; --i) {
int32_t j = i + 1;
regionBackFronts[i] = regionRegulators[i].clamp(glm::min(regionBackFronts[i], regionBackFronts[j] - MIN_REGION_GAP));
}
// enforce inside --> out
for (int32_t i = 1; i < workload::Region::NUM_VIEW_REGIONS; ++i) {
for (int32_t i = 1; i < workload::Region::NUM_TRACKED_REGIONS; ++i) {
int32_t j = i - 1;
regionBackFronts[i] = regionRegulators[i].clamp(glm::max(regionBackFronts[i], regionBackFronts[j] + MIN_REGION_GAP));
}

View file

@ -196,7 +196,7 @@ namespace workload {
} data;
struct DataExport {
static const int SIZE{ workload::Region::NUM_VIEW_REGIONS };
static const int SIZE{ workload::Region::NUM_TRACKED_REGIONS };
float timings[SIZE];
glm::vec2 ranges[SIZE];
QList<qreal> _timings { 6, 2.0 };
@ -252,8 +252,8 @@ namespace workload {
void configure(const Config& config);
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
std::array<glm::vec2, workload::Region::NUM_VIEW_REGIONS> regionBackFronts;
std::array<Regulator, workload::Region::NUM_VIEW_REGIONS> regionRegulators;
std::array<glm::vec2, workload::Region::NUM_TRACKED_REGIONS> regionBackFronts;
std::array<Regulator, workload::Region::NUM_TRACKED_REGIONS> regionRegulators;
void regulateViews(workload::Views& views, const workload::Timings& timings);
void enforceRegionContainment();