Define vertex texture sampling intrinsics only when supported

TRAC #12245 This ensures that the shader will fail to compile when using VTF when it's not supported. Previously an error was generated only at link time and it was not very descriptive. Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@433 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c5f8dea4
...@@ -311,15 +311,6 @@ static TString BuiltInFunctionsCommon() ...@@ -311,15 +311,6 @@ static TString BuiltInFunctionsCommon()
s.append(TString("bvec4 not(bvec4 x);")); s.append(TString("bvec4 not(bvec4 x);"));
// //
// Texture Functions.
//
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
//
// Noise functions. // Noise functions.
// //
//s.append(TString("float noise1(float x);")); //s.append(TString("float noise1(float x);"));
...@@ -342,7 +333,6 @@ static TString BuiltInFunctionsCommon() ...@@ -342,7 +333,6 @@ static TString BuiltInFunctionsCommon()
//s.append(TString("vec4 noise4(vec3 x);")); //s.append(TString("vec4 noise4(vec3 x);"));
//s.append(TString("vec4 noise4(vec4 x);")); //s.append(TString("vec4 noise4(vec4 x);"));
s.append(TString("\n"));
return s; return s;
} }
...@@ -351,7 +341,7 @@ static TString BuiltInFunctionsCommon() ...@@ -351,7 +341,7 @@ static TString BuiltInFunctionsCommon()
// Prototypes for built-in functions seen by vertex shaders only. // Prototypes for built-in functions seen by vertex shaders only.
// //
//============================================================================ //============================================================================
static TString BuiltInFunctionsVertex() static TString BuiltInFunctionsVertex(const TBuiltInResource& resources)
{ {
TString s; TString s;
...@@ -363,12 +353,18 @@ static TString BuiltInFunctionsVertex() ...@@ -363,12 +353,18 @@ static TString BuiltInFunctionsVertex()
// //
// Texture Functions. // Texture Functions.
// //
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);")); if (resources.MaxVertexTextureImageUnits > 0) {
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);")); s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
}
s.append(TString("\n"));
return s; return s;
} }
...@@ -384,6 +380,11 @@ static TString BuiltInFunctionsFragment(const TBuiltInResource& resources) ...@@ -384,6 +380,11 @@ static TString BuiltInFunctionsFragment(const TBuiltInResource& resources)
// //
// Texture Functions. // Texture Functions.
// //
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);")); s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
...@@ -406,7 +407,6 @@ static TString BuiltInFunctionsFragment(const TBuiltInResource& resources) ...@@ -406,7 +407,6 @@ static TString BuiltInFunctionsFragment(const TBuiltInResource& resources)
s.append(TString("vec4 fwidth(vec4 p);")); s.append(TString("vec4 fwidth(vec4 p);"));
} }
s.append(TString("\n"));
return s; return s;
} }
...@@ -429,7 +429,6 @@ static TString StandardUniforms() ...@@ -429,7 +429,6 @@ static TString StandardUniforms()
s.append(TString("};")); s.append(TString("};"));
s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;")); s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
s.append(TString("\n"));
return s; return s;
} }
...@@ -445,7 +444,6 @@ static TString DefaultPrecisionVertex() ...@@ -445,7 +444,6 @@ static TString DefaultPrecisionVertex()
s.append(TString("precision highp int;")); s.append(TString("precision highp int;"));
s.append(TString("precision highp float;")); s.append(TString("precision highp float;"));
s.append(TString("\n"));
return s; return s;
} }
...@@ -461,7 +459,6 @@ static TString DefaultPrecisionFragment() ...@@ -461,7 +459,6 @@ static TString DefaultPrecisionFragment()
s.append(TString("precision mediump int;")); s.append(TString("precision mediump int;"));
// No default precision for float in fragment shaders // No default precision for float in fragment shaders
s.append(TString("\n"));
return s; return s;
} }
...@@ -500,7 +497,7 @@ void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInRes ...@@ -500,7 +497,7 @@ void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInRes
case EShLangVertex: case EShLangVertex:
builtInStrings.push_back(DefaultPrecisionVertex()); builtInStrings.push_back(DefaultPrecisionVertex());
builtInStrings.push_back(BuiltInFunctionsCommon()); builtInStrings.push_back(BuiltInFunctionsCommon());
builtInStrings.push_back(BuiltInFunctionsVertex()); builtInStrings.push_back(BuiltInFunctionsVertex(resources));
builtInStrings.push_back(StandardUniforms()); builtInStrings.push_back(StandardUniforms());
break; break;
......
...@@ -56,7 +56,7 @@ static bool InitializeSymbolTable( ...@@ -56,7 +56,7 @@ static bool InitializeSymbolTable(
builtInShaders[0] = (*i).c_str(); builtInShaders[0] = (*i).c_str();
builtInLengths[0] = (int) (*i).size(); builtInLengths[0] = (int) (*i).size();
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) if (builtInLengths[0] && PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0)
{ {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment