13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Random Shader Generator 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Variable Value class. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rsgVariableValue.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rsg 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <class CompareOp> 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compareValueRangesAllTrue (const ConstValueRangeAccess& a, const ConstValueRangeAccess& b) 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(a.getType() == b.getType()); 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (a.getType().isStruct()) 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numMembers = (int)a.getType().getMembers().size(); 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numMembers; ndx++) 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareValueRangesAllTrue<CompareOp>(a.member(ndx), b.member(ndx))) 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (a.getType().isArray()) 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numElements = (int)a.getType().getNumElements(); 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareValueRangesAllTrue<CompareOp>(a.arrayElement(ndx), b.arrayElement(ndx))) 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numElements = (int)a.getType().getNumElements(); 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (a.getType().getBaseType()) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_FLOAT: 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float aMin = a.component(ndx).getMin().asFloat(); 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float aMax = a.component(ndx).getMax().asFloat(); 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float bMin = b.component(ndx).getMin().asFloat(); 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float bMax = b.component(ndx).getMax().asFloat(); 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!CompareOp()(aMin, aMax, bMin, bMax)) 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_INT: 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_SAMPLER_2D: 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_SAMPLER_CUBE: 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int aMin = a.component(ndx).getMin().asInt(); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int aMax = a.component(ndx).getMax().asInt(); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bMin = b.component(ndx).getMin().asInt(); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bMax = b.component(ndx).getMax().asInt(); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!CompareOp()(aMin, aMax, bMin, bMax)) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_BOOL: 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aMin = a.component(ndx).getMin().asBool(); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aMax = a.component(ndx).getMax().asBool(); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool bMin = b.component(ndx).getMin().asBool(); 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool bMax = b.component(ndx).getMax().asBool(); 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!CompareOp()(aMin, aMax, bMin, bMax)) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline int toInt (bool boolVal) { return boolVal ? 1 : 0; } 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct CompareIntersection 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (float aMin, float aMax, float bMin, float bMax) const { return (aMin <= bMax && bMin <= aMax); } 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (int aMin, int aMax, int bMin, int bMax) const { return (aMin <= bMax && bMin <= aMax); } 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (bool aMin, bool aMax, bool bMin, bool bMax) const 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CompareIntersection()(toInt(aMin), toInt(aMax), toInt(bMin), toInt(bMax)); 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct CompareIsSubsetOf 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (float aMin, float aMax, float bMin, float bMax) const 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return de::inRange(aMin, bMin, bMax) && de::inRange(aMax, bMin, bMax); 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (int aMin, int aMax, int bMin, int bMax) const 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return de::inRange(aMin, bMin, bMax) && de::inRange(aMax, bMin, bMax); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline bool operator() (bool aMin, bool aMax, bool bMin, bool bMax) const 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CompareIsSubsetOf()(toInt(aMin), toInt(aMax), toInt(bMin), toInt(bMax)); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ConstValueRangeAccess::intersects (const ConstValueRangeAccess& other) const 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareValueRangesAllTrue<CompareIntersection>(*this, other); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ConstValueRangeAccess::isSubsetOf (const ConstValueRangeAccess& other) const 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareValueRangesAllTrue<CompareIsSubsetOf>(*this, other); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ConstValueRangeAccess::isSupersetOf (const ConstValueRangeAccess& other) const 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return other.isSubsetOf(*this); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryValueRange::ValueRange (const VariableType& type) 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_type (type) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_min (type.getScalarSize()) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_max (type.getScalarSize()) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryValueRange::ValueRange (const VariableType& type, const ConstValueAccess& minVal, const ConstValueAccess& maxVal) 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_type (type) 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_min (type.getScalarSize()) 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_max (type.getScalarSize()) 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMin() = minVal.value(); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMax() = maxVal.value(); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryValueRange::ValueRange (const VariableType& type, const Scalar* minVal, const Scalar* maxVal) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_type (type) 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_min (type.getScalarSize()) 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_max (type.getScalarSize()) 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMin() = ConstValueAccess(type, minVal).value(); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMax() = ConstValueAccess(type, maxVal).value(); 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryValueRange::ValueRange (ConstValueRangeAccess other) 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_type (other.getType()) 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_min (other.getType().getScalarSize()) 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_max (other.getType().getScalarSize()) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMin() = other.getMin().value(); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getMax() = other.getMax().value(); 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1923c827367444ee418f129b2c238299f49d3264554Jarkko PoyryValueRange::~ValueRange (void) 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ValueRange::computeIntersection (ValueRange& dst, const ConstValueRangeAccess& a, const ConstValueRangeAccess& b) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeIntersection(dst.asAccess(), a, b); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ValueRange::computeIntersection (ValueRangeAccess dst, const ConstValueRangeAccess& a, const ConstValueRangeAccess& b) 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(dst.getType() == a.getType() && dst.getType() == b.getType()); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (a.getType().isStruct()) 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numMembers = (int)a.getType().getMembers().size(); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numMembers; ndx++) 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeIntersection(dst.member(ndx), a.member(ndx), b.member(ndx)); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (a.getType().isArray()) 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numElements = (int)a.getType().getNumElements(); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeIntersection(dst.arrayElement(ndx), a.arrayElement(ndx), b.arrayElement(ndx)); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numElements = (int)a.getType().getNumElements(); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (a.getType().getBaseType()) 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_FLOAT: 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float aMin = a.component(ndx).getMin().asFloat(); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float aMax = a.component(ndx).getMax().asFloat(); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float bMin = b.component(ndx).getMin().asFloat(); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float bMax = b.component(ndx).getMax().asFloat(); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMin() = de::max(aMin, bMin); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMax() = de::min(aMax, bMax); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_INT: 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_SAMPLER_2D: 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_SAMPLER_CUBE: 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int aMin = a.component(ndx).getMin().asInt(); 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int aMax = a.component(ndx).getMax().asInt(); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bMin = b.component(ndx).getMin().asInt(); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bMax = b.component(ndx).getMax().asInt(); 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMin() = de::max(aMin, bMin); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMax() = de::min(aMax, bMax); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case VariableType::TYPE_BOOL: 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numElements; ndx++) 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aMin = a.component(ndx).getMin().asBool(); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aMax = a.component(ndx).getMax().asBool(); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool bMin = b.component(ndx).getMin().asBool(); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool bMax = b.component(ndx).getMax().asBool(); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMin() = aMin || bMin; 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.component(ndx).getMax() = aMax && bMax; 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVariableValue::VariableValue (const VariableValue& other) 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_variable(other.m_variable) 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_storage(other.m_variable->getType()) 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_storage.getValue(getType()) = other.getValue().value(); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2763c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVariableValue& VariableValue::operator= (const VariableValue& other) 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_variable = other.m_variable; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_storage.setStorage(getType()); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_storage.getValue(getType()) = other.getValue().value(); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rsg 285