|
|
@@ -1031,8 +1031,10 @@ namespace bgfx
|
|
|
VaryingMap varyingMap;
|
|
|
const char* parse = _varying;
|
|
|
|
|
|
- while (NULL != parse
|
|
|
- && *parse != '\0')
|
|
|
+ bool usesInterpolationQualifiers = false;
|
|
|
+
|
|
|
+ while (NULL != parse
|
|
|
+ && '\0' != *parse)
|
|
|
{
|
|
|
parse = bx::strws(parse);
|
|
|
const char* eol = bx::strFind(parse, ';');
|
|
|
@@ -1062,6 +1064,7 @@ namespace bgfx
|
|
|
{
|
|
|
interpolation = typen;
|
|
|
typen = parse = bx::strws(bx::strSkipWord(parse) );
|
|
|
+ usesInterpolationQualifiers = true;
|
|
|
}
|
|
|
|
|
|
const char* name = parse = bx::strws(bx::strSkipWord(parse) );
|
|
|
@@ -1815,6 +1818,7 @@ namespace bgfx
|
|
|
{
|
|
|
const bool need130 = 120 == glsl && (false
|
|
|
|| bx::findIdentifierMatch(input, s_130)
|
|
|
+ || usesInterpolationQualifiers
|
|
|
|| usesTexelFetch
|
|
|
);
|
|
|
|
|
|
@@ -1828,6 +1832,13 @@ namespace bgfx
|
|
|
glsl = 130;
|
|
|
}
|
|
|
|
|
|
+ if (need130)
|
|
|
+ {
|
|
|
+ bx::stringPrintf(code, "#define varying %s\n"
|
|
|
+ , 'f' == _options.shaderType ? "in" : "out"
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
if (usesInstanceID)
|
|
|
{
|
|
|
bx::stringPrintf(code
|
|
|
@@ -1923,7 +1934,7 @@ namespace bgfx
|
|
|
{
|
|
|
bx::stringPrintf(code
|
|
|
, "#define bgfxShadow2D(_sampler, _coord) vec4_splat(texture(_sampler, _coord))\n"
|
|
|
- "#define bgfxShadow2DProj(_sampler, _coord) vec4_splat(textureProj(_sampler, _coord))\n"
|
|
|
+ "#define bgfxShadow2DProj(_sampler, _coord) vec4_splat(textureProj(_sampler, _coord))\n"
|
|
|
);
|
|
|
}
|
|
|
else
|
|
|
@@ -1936,18 +1947,27 @@ namespace bgfx
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ if (usesInterpolationQualifiers)
|
|
|
+ {
|
|
|
+ bx::stringPrintf(code, "#version 300 es\n");
|
|
|
+ bx::stringPrintf(code, "#define attribute in\n");
|
|
|
+ bx::stringPrintf(code, "#define varying %s\n"
|
|
|
+ , 'f' == _options.shaderType ? "in" : "out"
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// Pretend that all extensions are available.
|
|
|
// This will be stripped later.
|
|
|
if (usesTextureLod)
|
|
|
{
|
|
|
bx::stringPrintf(code
|
|
|
, "#extension GL_EXT_shader_texture_lod : enable\n"
|
|
|
- "#define texture2DLod texture2DLodEXT\n"
|
|
|
- "#define texture2DGrad texture2DGradEXT\n"
|
|
|
- "#define texture2DProjLod texture2DProjLodEXT\n"
|
|
|
- "#define texture2DProjGrad texture2DProjGradEXT\n"
|
|
|
- "#define textureCubeLod textureCubeLodEXT\n"
|
|
|
- "#define textureCubeGrad textureCubeGradEXT\n"
|
|
|
+ "#define texture2DLod texture2DLodEXT\n"
|
|
|
+ "#define texture2DGrad texture2DGradEXT\n"
|
|
|
+ "#define texture2DProjLod texture2DProjLodEXT\n"
|
|
|
+ "#define texture2DProjGrad texture2DProjGradEXT\n"
|
|
|
+ "#define textureCubeLod textureCubeLodEXT\n"
|
|
|
+ "#define textureCubeGrad textureCubeGradEXT\n"
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -1965,8 +1985,8 @@ namespace bgfx
|
|
|
{
|
|
|
bx::stringPrintf(code
|
|
|
, "#extension GL_EXT_shadow_samplers : enable\n"
|
|
|
- "#define shadow2D shadow2DEXT\n"
|
|
|
- "#define shadow2DProj shadow2DProjEXT\n"
|
|
|
+ "#define shadow2D shadow2DEXT\n"
|
|
|
+ "#define shadow2DProj shadow2DProjEXT\n"
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -1988,7 +2008,7 @@ namespace bgfx
|
|
|
{
|
|
|
bx::stringPrintf(code
|
|
|
, "#extension GL_EXT_frag_depth : enable\n"
|
|
|
- "#define gl_FragDepth gl_FragDepthEXT\n"
|
|
|
+ "#define gl_FragDepth gl_FragDepthEXT\n"
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -1999,11 +2019,11 @@ namespace bgfx
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- bx::stringPrintf(code,
|
|
|
- "#define ivec2 vec2\n"
|
|
|
- "#define ivec3 vec3\n"
|
|
|
- "#define ivec4 vec4\n"
|
|
|
- );
|
|
|
+ bx::stringPrintf(code
|
|
|
+ , "#define ivec2 vec2\n"
|
|
|
+ "#define ivec3 vec3\n"
|
|
|
+ "#define ivec4 vec4\n"
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
else
|