#version 300 es
uniform sampler2D s2D;
-uniform sampler3D s3D;
+uniform lowp sampler3D s3D;
uniform samplerCube sCube;
-uniform samplerCubeShadow sCubeShadow;
-uniform sampler2DShadow s2DShadow;
-uniform sampler2DArray s2DArray;
-uniform sampler2DArrayShadow s2DArrayShadow;
+uniform lowp samplerCubeShadow sCubeShadow;
+uniform lowp sampler2DShadow s2DShadow;
+uniform lowp sampler2DArray s2DArray;
+uniform lowp sampler2DArrayShadow s2DArrayShadow;
-uniform isampler2D is2D;
-uniform isampler3D is3D;
-uniform isamplerCube isCube;
-uniform isampler2DArray is2DArray;
-
-uniform usampler2D us2D;
-uniform usampler3D us3D;
-uniform usamplerCube usCube;
-uniform usampler2DArray us2DArray;
+uniform lowp isampler2D is2D;
+uniform lowp isampler3D is3D;
+uniform lowp isamplerCube isCube;
+uniform lowp isampler2DArray is2DArray;
+uniform lowp usampler2D us2D;
+uniform lowp usampler3D us3D;
+uniform lowp usamplerCube usCube;
+uniform lowp usampler2DArray us2DArray;
+precision lowp float;
in float c1D;
in vec2 c2D;
in vec3 c3D;
flat in ivec3 ic3D;
flat in ivec4 ic4D;
noperspective in vec4 badv; // ERROR
-in sampler2D bads; // ERROR
-precision lowp uint; // ERROR
+in sampler2D bads; // ERROR
+precision lowp uint; // ERROR
struct s {
int i;
- sampler2D s; // ERROR
+ sampler2D s;
};
-out s badout; // ERROR
+out s badout; // ERROR
void main()
{
#version 300 es
+precision mediump float;
+
struct S {
vec4 u;
uvec4 v;
- isampler3D sampler;
+ lowp isampler3D sampler;
vec3 w;
struct T1 { // ERROR
int a;
uniform fooBlock {
uvec4 bv;
mat2 bm2;
- isampler2D sampler; // ERROR
+ lowp isampler2D sampler; // ERROR
struct T2 { // ERROR
int a;
} t;
void main()
{
texture(s.sampler, vec3(inst.ni, bv.y, insts[2].nbv.z));
- insts[s.v.x]; // ERROR
+ insts[s.v.x]; // ERROR
}
#version 300 es
-
+precision mediump float;
in vec4 pos;
layout (location = 2) in vec4 color; // ERROR
#version 300 es
uniform block {
- float f;
+ mediump float f;
} instanceName;
struct S {
+#version 110
+
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
#version 100\r
\r
-varying vec3 color;\r
+varying vec3 color; // ERRROR, there is no default qualifier for float\r
\r
lowp vec2 foo(mediump vec3 mv3)\r
{\r
#version 300 es
uniform int c, d;
-in float x;
+highp in float x;
void main()
{
130.frag
140.frag
precision.frag
+precision.vert
nonSquare.vert
matrixError.vert
cppSimple.vert
#version 300 es
in uvec2 badu; // ERROR
flat in uvec2 t;
-in float f;
-in vec2 tc;
+in highp float f;
+in highp vec2 tc;
in bool bad; // ERROR
uniform uvec4 v;
uniform int i;
out uvec4 c;
-uniform usampler2D usampler;
+uniform lowp usampler2D usampler;
void main()
{
//\r
#version 300 es\r
\r
-in vec3 color;\r
-out vec4 foo;\r
+in highp vec3 color;\r
+out highp vec4 foo;\r
\r
-uniform sampler2DArrayShadow bar;\r
+uniform highp sampler2DArrayShadow bar;\r
\r
void main()\r
{\r
for (int type = 0; type < EbtNumTypes; ++type)
defaultPrecision[type] = EpqNone;
+ for (int type = 0; type < maxSamplerIndex; ++type)
+ defaultSamplerPrecision[type] = EpqNone;
+
if (profile == EEsProfile) {
+ TSampler sampler;
+ sampler.set(EbtFloat, Esd2D);
+ defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
+ sampler.set(EbtFloat, EsdCube);
+ defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
+
switch (language) {
case EShLangVertex:
defaultPrecision[EbtInt] = EpqHigh;
{
TBasicType basicType = publicType.basicType;
- if (basicType == EbtSampler || basicType == EbtInt || basicType == EbtFloat) {
+ if (basicType == EbtSampler) {
+ defaultSamplerPrecision[computeSamplerTypeIndex(publicType.sampler)] = qualifier;
+
+ return; // all is well
+ }
+
+ if (basicType == EbtInt || basicType == EbtFloat) {
if (publicType.isScalar()) {
defaultPrecision[basicType] = qualifier;
if (basicType == EbtInt)
error(line, "cannot apply precision statement to this type; use 'float', 'int' or a sampler type", TType::getBasicString(basicType), "");
}
+// used to flatten the sampler type space into a single dimension
+// correlates with the declaration of defaultSamplerPrecision[]
+int TParseContext::computeSamplerTypeIndex(TSampler& sampler)
+{
+ int arrayIndex = sampler.arrayed ? 1 : 0;
+ int shadowIndex = sampler.shadow ? 1 : 0;
+
+ return EsdNumDims * (EbtNumTypes * (2 * arrayIndex + shadowIndex) + sampler.type) + sampler.dim;
+}
+
+TPrecisionQualifier TParseContext::getDefaultPrecision(TPublicType& publicType)
+{
+ if (publicType.basicType == EbtSampler)
+ return defaultSamplerPrecision[computeSamplerTypeIndex(publicType.sampler)];
+ else
+ return defaultPrecision[publicType.basicType];
+}
+
+void TParseContext::precisionQualifierCheck(int line, TPublicType& publicType)
+{
+ if (profile != EEsProfile)
+ return;
+
+ if (publicType.basicType == EbtFloat || publicType.basicType == EbtUint || publicType.basicType == EbtInt || publicType.basicType == EbtSampler) {
+ if (publicType.qualifier.precision == EpqNone)
+ error(line, "type requires declaration of default precision qualifier", TType::getBasicString(publicType.basicType), "");
+ }
+}
+
void TParseContext::parameterSamplerCheck(int line, TStorageQualifier qualifier, const TType& type)
{
if ((qualifier == EvqOut || qualifier == EvqInOut) && type.getBasicType() != EbtStruct && type.getBasicType() == EbtSampler)
struct TPragma contextPragma;
TPrecisionQualifier defaultPrecision[EbtNumTypes];
+ static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex()
+ TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
TQualifier defaultGlobalQualification;
TString HashErrMsg;
bool AfterEOF;
bool structQualifierErrorCheck(int line, const TPublicType& pType);
void mergeQualifiers(int line, TPublicType& dst, const TPublicType& src, bool force);
void setDefaultPrecision(int line, TPublicType&, TPrecisionQualifier);
+ int computeSamplerTypeIndex(TSampler&);
+ TPrecisionQualifier getDefaultPrecision(TPublicType&);
+ void precisionQualifierCheck(int line, TPublicType&);
void parameterSamplerCheck(int line, TStorageQualifier qualifier, const TType& type);
bool containsSampler(const TType& type);
void nonInitConstCheck(int line, TString& identifier, TPublicType& type);
$2.arraySizes = 0;\r
\r
parseContext.mergeQualifiers($2.line, $2, $1, true);\r
+ parseContext.precisionQualifierCheck($2.line, $2);\r
\r
$$ = $2;\r
\r
type_specifier\r
: type_specifier_nonarray {\r
$$ = $1;\r
- $$.qualifier.precision = parseContext.defaultPrecision[$$.basicType];\r
+ $$.qualifier.precision = parseContext.getDefaultPrecision($$);\r
}\r
| type_specifier_nonarray array_specifier { \r
$$ = $1;\r
- $$.qualifier.precision = parseContext.defaultPrecision[$$.basicType];\r
+ $$.qualifier.precision = parseContext.getDefaultPrecision($$);\r
$$.arraySizes = $2.arraySizes;\r
}\r
;\r
$$ = $2;\r
\r
parseContext.voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1);\r
+ parseContext.precisionQualifierCheck($1.line, $1);\r
\r
for (unsigned int i = 0; i < $$->size(); ++i)\r
(*$$)[i].type->mergeType($1);\r
\r
parseContext.voidErrorCheck($2.line, (*$3)[0].type->getFieldName(), $2);\r
parseContext.mergeQualifiers($2.line, $2, $1, true);\r
+ parseContext.precisionQualifierCheck($2.line, $2);\r
\r
for (unsigned int i = 0; i < $$->size(); ++i)\r
(*$$)[i].type->mergeType($2);\r