3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Random Shader Generator
5 * ----------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 *//*--------------------------------------------------------------------*/
26 #include "rsgDefs.hpp"
27 #include "rsgShader.hpp"
28 #include "rsgVariableValue.hpp"
29 #include "deRandom.hpp"
30 #include "rsgGeneratorState.hpp"
38 void computeUnifiedUniforms (const Shader& vertexShader, const Shader& fragmentShader, std::vector<const ShaderInput*>& uniforms);
39 void computeUniformValues (de::Random& rnd, std::vector<VariableValue>& values, const std::vector<const ShaderInput*>& uniforms);
41 // \todo [2011-03-26 pyry] Move to ExpressionUtils!
43 bool isUndefinedValueRange (ConstValueRangeAccess valueRange);
45 int getConservativeValueExprDepth (const GeneratorState& state, ConstValueRangeAccess valueRange);
46 int getTypeConstructorDepth (const VariableType& type);
48 VariableType computeRandomType (GeneratorState& state, int maxScalars);
49 void computeRandomValueRange (GeneratorState& state, ValueRangeAccess valueRange);
51 float computeDynamicRangeWeight (ConstValueRangeAccess valueRange);
53 inline float getQuantizedFloat (de::Random& rnd, float min, float max, float step)
55 int numSteps = (int)((max-min)/step);
56 return min + step * (float)rnd.getInt(0, numSteps);
59 inline bool quantizeFloatRange (float& min, float& max)
61 const float subdiv = 8;
63 float newMin = deFloatCeil(min*subdiv)/subdiv;
65 min = newMin; // Minimum value quantized
69 float newMax = deFloatFloor(max*subdiv)/subdiv;
80 #endif // _RSGUTILS_HPP