Skip to content

Commit

Permalink
avoid producing variable names with double underscores
Browse files Browse the repository at this point in the history
Could happen with for example mutable uniforms that were starting with
an underscore name.
  • Loading branch information
aras-p committed Sep 25, 2013
1 parent a2f2118 commit 51f7888
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 151 deletions.
6 changes: 3 additions & 3 deletions hlslang/GLSLCodeGen/glslSymbol.cpp
Expand Up @@ -209,12 +209,12 @@ GlslSymbol::GlslSymbol( const std::string &n, const std::string &s, int id, EGls
{
if (IsReservedGlslKeyword(n))
{
name = "xlat_var_" + n;
name = "xlat_var" + n;
}
mangledName = name;

if (qual == EqtMutableUniform)
mutableMangledName = "xlat_mutable_" + mangledName;
mutableMangledName = "xlat_mutable" + mangledName;
else
mutableMangledName = mangledName;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ void GlslSymbol::mangleName()
s << "_" << mangleCounter;
mangledName = name + s.str();
if ( qual == EqtMutableUniform)
mutableMangledName = "xlat_mutable_" + mangledName;
mutableMangledName = "xlat_mutable" + mangledName;
else
mutableMangledName = mangledName;
}
14 changes: 7 additions & 7 deletions tests/combined/index-matrix-assignment-fragment-out.txt
Expand Up @@ -24,22 +24,22 @@ uniform sampler2DShadow shadow_map;
#line 21
#line 41
#line 41
vec4 ps_main( in PS_INPUT xlat_var_input, in int primitive_id ) {
vec4 ps_main( in PS_INPUT xlat_varinput, in int primitive_id ) {
vec4 c = vec4( 1.0, 1.0, 1.0, float(primitive_id));
c = texture2D( diffuse_map, xlat_var_input.uv);
c = texture2D( diffuse_map, xlat_varinput.uv);
float depth = 1.0;
#line 45
vec4 shadow = vec4( xlat_var_input.uv, depth, 1.0);
vec4 shadow = vec4( xlat_varinput.uv, depth, 1.0);
c *= shadow2DProj( shadow_map, shadow).x;
return c;
}
varying vec2 xlv_TEXCOORD0;
void main() {
vec4 xl_retval;
PS_INPUT xlt_xlat_var_input;
xlt_xlat_var_input.position = vec4(0.0);
xlt_xlat_var_input.uv = vec2(xlv_TEXCOORD0);
xl_retval = ps_main( xlt_xlat_var_input, int(gl_PrimitiveID));
PS_INPUT xlt_xlat_varinput;
xlt_xlat_varinput.position = vec4(0.0);
xlt_xlat_varinput.uv = vec2(xlv_TEXCOORD0);
xl_retval = ps_main( xlt_xlat_varinput, int(gl_PrimitiveID));
gl_FragData[0] = vec4(xl_retval);
}

Expand Down
34 changes: 17 additions & 17 deletions tests/combined/index-matrix-assignment-vertex-out.txt
Expand Up @@ -58,39 +58,39 @@ uniform sampler2D diffuse_map;
uniform sampler2DShadow shadow_map;
#line 21
#line 41
mat4 xlat_mutable_stupid[10];
mat4 xlat_mutablestupid[10];
#line 21
PS_INPUT vs_main( in VS_INPUT xlat_var_input ) {
PS_INPUT vs_main( in VS_INPUT xlat_varinput ) {
PS_INPUT o;
mat3 dummy = xll_transpose_mf3x3(mat3( vec3( 0.0), vec3( 0.0), vec3( 0.0)));
#line 26
vec4 wp = (xlat_var_input.position * world);
xlat_mutable_stupid[2] = view;
vec4 wp = (xlat_varinput.position * world);
xlat_mutablestupid[2] = view;
vec3 xlat_swiztemp0 = vec3(dummy[1].z, dummy[0].x, dummy[0].x);
xlat_mutable_stupid[2][0][3] = xlat_swiztemp0.x;
xlat_mutable_stupid[2][1][3] = xlat_swiztemp0.y;
xlat_mutable_stupid[2][2][3] = xlat_swiztemp0.z;
xlat_mutablestupid[2][0][3] = xlat_swiztemp0.x;
xlat_mutablestupid[2][1][3] = xlat_swiztemp0.y;
xlat_mutablestupid[2][2][3] = xlat_swiztemp0.z;
#line 31
dummy[0][2] = 0.0;
vec2 xlat_swiztemp1 = vec2( 0.0, 0.0);
dummy[0][2] = xlat_swiztemp1.x;
dummy[2][0] = xlat_swiztemp1.y;
dummy[2][2] = float( xll_matrixindexdynamic_mf3x3_i (dummy, ((xlat_var_input.instance_id * 2) + xlat_var_input.vertex_id)));
dummy[2][2] = float( xll_matrixindexdynamic_mf3x3_i (dummy, ((xlat_varinput.instance_id * 2) + xlat_varinput.vertex_id)));
#line 35
o.position = ((wp * xlat_mutable_stupid[2]) * proj);
o.uv = xlat_var_input.uv;
o.position = ((wp * xlat_mutablestupid[2]) * proj);
o.uv = xlat_varinput.uv;
return o;
}
varying vec2 xlv_TEXCOORD0;
void main() {
xlat_mutable_stupid = stupid;
xlat_mutablestupid = stupid;
PS_INPUT xl_retval;
VS_INPUT xlt_xlat_var_input;
xlt_xlat_var_input.position = vec4(gl_Vertex);
xlt_xlat_var_input.uv = vec2(gl_MultiTexCoord0);
xlt_xlat_var_input.vertex_id = int(gl_VertexID);
xlt_xlat_var_input.instance_id = int(gl_InstanceIDARB);
xl_retval = vs_main( xlt_xlat_var_input);
VS_INPUT xlt_xlat_varinput;
xlt_xlat_varinput.position = vec4(gl_Vertex);
xlt_xlat_varinput.uv = vec2(gl_MultiTexCoord0);
xlt_xlat_varinput.vertex_id = int(gl_VertexID);
xlt_xlat_varinput.instance_id = int(gl_InstanceIDARB);
xl_retval = vs_main( xlt_xlat_varinput);
gl_Position = vec4(xl_retval.position);
xlv_TEXCOORD0 = vec2(xl_retval.uv);
}
Expand Down
20 changes: 10 additions & 10 deletions tests/fragment/uniforms-mutable-out.txt
Expand Up @@ -3,29 +3,29 @@ uniform vec4 uni4;
#line 4
uniform sampler2D tex1;
#line 12
float xlat_mutable_uni1;
vec4 xlat_mutable_uni4;
float xlat_mutableuni1;
vec4 xlat_mutableuni4;
#line 6
vec3 SampleDiffuse( in vec2 uv ) {
#line 8
xlat_mutable_uni4.xy = uv;
return vec3( texture2D( tex1, xlat_mutable_uni4.xy));
xlat_mutableuni4.xy = uv;
return vec3( texture2D( tex1, xlat_mutableuni4.xy));
}
#line 12
vec4 xlat_main( in vec4 uv ) {
vec4 c = vec4( 0.0);
c.x += xlat_mutable_uni4.x;
c.x += xlat_mutableuni4.x;
c.xyz += SampleDiffuse( uv.xy);
#line 16
c.z += xlat_mutable_uni1;
xlat_mutable_uni1 += 2.0;
c.w += xlat_mutable_uni1;
c.z += xlat_mutableuni1;
xlat_mutableuni1 += 2.0;
c.w += xlat_mutableuni1;
return c;
}
varying vec4 xlv_TEXCOORD0;
void main() {
xlat_mutable_uni1 = uni1;
xlat_mutable_uni4 = uni4;
xlat_mutableuni1 = uni1;
xlat_mutableuni4 = uni4;
vec4 xl_retval;
xl_retval = xlat_main( vec4(xlv_TEXCOORD0));
gl_FragData[0] = vec4(xl_retval);
Expand Down
20 changes: 10 additions & 10 deletions tests/fragment/uniforms-mutable-outES.txt
Expand Up @@ -3,29 +3,29 @@ uniform mediump vec4 uni4;
#line 4
uniform sampler2D tex1;
#line 12
highp float xlat_mutable_uni1;
mediump vec4 xlat_mutable_uni4;
highp float xlat_mutableuni1;
mediump vec4 xlat_mutableuni4;
#line 6
highp vec3 SampleDiffuse( in highp vec2 uv ) {
#line 8
xlat_mutable_uni4.xy = uv;
return vec3( texture2D( tex1, xlat_mutable_uni4.xy));
xlat_mutableuni4.xy = uv;
return vec3( texture2D( tex1, xlat_mutableuni4.xy));
}
#line 12
lowp vec4 xlat_main( in highp vec4 uv ) {
lowp vec4 c = vec4( 0.0);
c.x += xlat_mutable_uni4.x;
c.x += xlat_mutableuni4.x;
c.xyz += SampleDiffuse( uv.xy);
#line 16
c.z += xlat_mutable_uni1;
xlat_mutable_uni1 += 2.0;
c.w += xlat_mutable_uni1;
c.z += xlat_mutableuni1;
xlat_mutableuni1 += 2.0;
c.w += xlat_mutableuni1;
return c;
}
varying highp vec4 xlv_TEXCOORD0;
void main() {
xlat_mutable_uni1 = uni1;
xlat_mutable_uni4 = uni4;
xlat_mutableuni1 = uni1;
xlat_mutableuni4 = uni4;
lowp vec4 xl_retval;
xl_retval = xlat_main( vec4(xlv_TEXCOORD0));
gl_FragData[0] = vec4(xl_retval);
Expand Down
20 changes: 10 additions & 10 deletions tests/fragment/uniforms-mutable-outES3.txt
Expand Up @@ -3,29 +3,29 @@ uniform mediump vec4 uni4;
#line 4
uniform sampler2D tex1;
#line 12
highp float xlat_mutable_uni1;
mediump vec4 xlat_mutable_uni4;
highp float xlat_mutableuni1;
mediump vec4 xlat_mutableuni4;
#line 6
highp vec3 SampleDiffuse( in highp vec2 uv ) {
#line 8
xlat_mutable_uni4.xy = uv;
return vec3( texture( tex1, xlat_mutable_uni4.xy));
xlat_mutableuni4.xy = uv;
return vec3( texture( tex1, xlat_mutableuni4.xy));
}
#line 12
lowp vec4 xlat_main( in highp vec4 uv ) {
lowp vec4 c = vec4( 0.0);
c.x += xlat_mutable_uni4.x;
c.x += xlat_mutableuni4.x;
c.xyz += SampleDiffuse( uv.xy);
#line 16
c.z += xlat_mutable_uni1;
xlat_mutable_uni1 += 2.0;
c.w += xlat_mutable_uni1;
c.z += xlat_mutableuni1;
xlat_mutableuni1 += 2.0;
c.w += xlat_mutableuni1;
return c;
}
in highp vec4 xlv_TEXCOORD0;
void main() {
xlat_mutable_uni1 = uni1;
xlat_mutable_uni4 = uni4;
xlat_mutableuni1 = uni1;
xlat_mutableuni4 = uni4;
lowp vec4 xl_retval;
xl_retval = xlat_main( vec4(xlv_TEXCOORD0));
gl_FragData[0] = vec4(xl_retval);
Expand Down
8 changes: 4 additions & 4 deletions tests/fragment/z-SurfaceMutableUniform-out.txt
Expand Up @@ -38,11 +38,11 @@ uniform vec4 ololo;
#line 32
#line 51
uniform vec4 _MainTex_ST;
vec4 xlat_mutable_ololo;
vec4 xlat_mutableololo;
#line 32
vec4 LightingNoLight( in SurfaceOutput s, in vec3 lightDir, in float atten ) {
vec4 c;
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutable_ololo)));
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutableololo)));
c.w = 1.0;
#line 36
return c;
Expand All @@ -51,7 +51,7 @@ vec4 LightingNoLight( in SurfaceOutput s, in vec3 lightDir, in float atten ) {
void surf( in Input IN, inout SurfaceOutput o ) {
#line 40
vec4 c = texture2D( _MainTex, IN.uv_MainTex);
xlat_mutable_ololo = c;
xlat_mutableololo = c;
o.Albedo = c.xyz;
o.Alpha = c.w;
}
Expand Down Expand Up @@ -82,7 +82,7 @@ varying vec2 xlv_TEXCOORD0;
varying vec3 xlv_TEXCOORD1;
varying vec3 xlv_TEXCOORD2;
void main() {
xlat_mutable_ololo = ololo;
xlat_mutableololo = ololo;
vec4 xl_retval;
v2f_surf xlt_IN;
xlt_IN.pos = vec4(xlv_SV_POSITION);
Expand Down
8 changes: 4 additions & 4 deletions tests/fragment/z-SurfaceMutableUniform-outES.txt
Expand Up @@ -38,11 +38,11 @@ uniform lowp vec4 ololo;
#line 32
#line 51
uniform highp vec4 _MainTex_ST;
lowp vec4 xlat_mutable_ololo;
lowp vec4 xlat_mutableololo;
#line 32
lowp vec4 LightingNoLight( in SurfaceOutput s, in lowp vec3 lightDir, in lowp float atten ) {
lowp vec4 c;
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutable_ololo)));
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutableololo)));
c.w = 1.0;
#line 36
return c;
Expand All @@ -51,7 +51,7 @@ lowp vec4 LightingNoLight( in SurfaceOutput s, in lowp vec3 lightDir, in lowp fl
void surf( in Input IN, inout SurfaceOutput o ) {
#line 40
mediump vec4 c = texture2D( _MainTex, IN.uv_MainTex);
xlat_mutable_ololo = c;
xlat_mutableololo = c;
o.Albedo = c.xyz;
o.Alpha = c.w;
}
Expand Down Expand Up @@ -82,7 +82,7 @@ varying highp vec2 xlv_TEXCOORD0;
varying lowp vec3 xlv_TEXCOORD1;
varying lowp vec3 xlv_TEXCOORD2;
void main() {
xlat_mutable_ololo = ololo;
xlat_mutableololo = ololo;
lowp vec4 xl_retval;
v2f_surf xlt_IN;
xlt_IN.pos = vec4(xlv_SV_POSITION);
Expand Down
8 changes: 4 additions & 4 deletions tests/fragment/z-SurfaceMutableUniform-outES3.txt
Expand Up @@ -38,11 +38,11 @@ uniform lowp vec4 ololo;
#line 32
#line 51
uniform highp vec4 _MainTex_ST;
lowp vec4 xlat_mutable_ololo;
lowp vec4 xlat_mutableololo;
#line 32
lowp vec4 LightingNoLight( in SurfaceOutput s, in lowp vec3 lightDir, in lowp float atten ) {
lowp vec4 c;
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutable_ololo)));
c.xyz = (s.Alpha * (s.Albedo + vec3( xlat_mutableololo)));
c.w = 1.0;
#line 36
return c;
Expand All @@ -51,7 +51,7 @@ lowp vec4 LightingNoLight( in SurfaceOutput s, in lowp vec3 lightDir, in lowp fl
void surf( in Input IN, inout SurfaceOutput o ) {
#line 40
mediump vec4 c = texture( _MainTex, IN.uv_MainTex);
xlat_mutable_ololo = c;
xlat_mutableololo = c;
o.Albedo = c.xyz;
o.Alpha = c.w;
}
Expand Down Expand Up @@ -82,7 +82,7 @@ in highp vec2 xlv_TEXCOORD0;
in lowp vec3 xlv_TEXCOORD1;
in lowp vec3 xlv_TEXCOORD2;
void main() {
xlat_mutable_ololo = ololo;
xlat_mutableololo = ololo;
lowp vec4 xl_retval;
v2f_surf xlt_IN;
xlt_IN.pos = vec4(xlv_SV_POSITION);
Expand Down
14 changes: 7 additions & 7 deletions tests/vertex/const-main-arg-out.txt
Expand Up @@ -9,16 +9,16 @@ struct VertexInput {
};
#line 11
#line 11
VertexOutput xlat_main( const VertexInput xlat_var_input ) {
VertexOutput xlat_var_output;
xlat_var_output.pos = xlat_var_input.pos;
VertexOutput xlat_main( const VertexInput xlat_varinput ) {
VertexOutput xlat_varoutput;
xlat_varoutput.pos = xlat_varinput.pos;
#line 15
return xlat_var_output;
return xlat_varoutput;
}
void main() {
VertexOutput xl_retval;
VertexInput xlt_xlat_var_input;
xlt_xlat_var_input.pos = vec4(gl_Vertex);
xl_retval = xlat_main( xlt_xlat_var_input);
VertexInput xlt_xlat_varinput;
xlt_xlat_varinput.pos = vec4(gl_Vertex);
xl_retval = xlat_main( xlt_xlat_varinput);
gl_Position = vec4(xl_retval.pos);
}
14 changes: 7 additions & 7 deletions tests/vertex/const-main-arg-outES.txt
Expand Up @@ -9,17 +9,17 @@ struct VertexInput {
};
#line 11
#line 11
VertexOutput xlat_main( const VertexInput xlat_var_input ) {
VertexOutput xlat_var_output;
xlat_var_output.pos = xlat_var_input.pos;
VertexOutput xlat_main( const VertexInput xlat_varinput ) {
VertexOutput xlat_varoutput;
xlat_varoutput.pos = xlat_varinput.pos;
#line 15
return xlat_var_output;
return xlat_varoutput;
}
attribute highp vec4 xlat_attrib_POSITION;
void main() {
VertexOutput xl_retval;
VertexInput xlt_xlat_var_input;
xlt_xlat_var_input.pos = vec4(xlat_attrib_POSITION);
xl_retval = xlat_main( xlt_xlat_var_input);
VertexInput xlt_xlat_varinput;
xlt_xlat_varinput.pos = vec4(xlat_attrib_POSITION);
xl_retval = xlat_main( xlt_xlat_varinput);
gl_Position = vec4(xl_retval.pos);
}

0 comments on commit 51f7888

Please sign in to comment.