Hash :
2bf8b372
Author :
Date :
2014-06-16T17:18:51
Fix link error when using varyings with "dx_". Varyings beginning with "dx_" would not get decorated properly, or at all, which could cause potential internal variables and certainly caused link errors. Fix this by no longer treating the "dx_" prefix differently. Also fix our naming of "dx_Position" to be consistent with our other internal types. BUG=angle:678 Change-Id: I03da0494a3d934d82ae7b3f8f12a576ff9bc3869 Reviewed-on: https://chromium-review.googlesource.com/203777 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
#include "ANGLETest.h"
class GLSLTest : public ANGLETest
{
protected:
GLSLTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
virtual void SetUp()
{
ANGLETest::SetUp();
mSimpleVSSource = SHADER_SOURCE
(
attribute vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
}
);
}
std::string mSimpleVSSource;
};
TEST_F(GLSLTest, nameless_scoped_structs)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
void main()
{
struct
{
float q;
} b;
gl_FragColor = vec4(1, 0, 0, 1);
gl_FragColor.a += b.q;
}
);
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
}
TEST_F(GLSLTest, scoped_structs_order_bug)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
struct T
{
float f;
};
void main()
{
T a;
struct T
{
float q;
};
T b;
gl_FragColor = vec4(1, 0, 0, 1);
gl_FragColor.a += a.f;
gl_FragColor.a += b.q;
}
);
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
}
TEST_F(GLSLTest, scoped_structs_bug)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
struct T_0
{
float f;
};
void main()
{
gl_FragColor = vec4(1, 0, 0, 1);
struct T
{
vec2 v;
};
T_0 a;
T b;
gl_FragColor.a += a.f;
gl_FragColor.a += b.v.x;
}
);
GLuint program = compileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
}
TEST_F(GLSLTest, dx_position_bug)
{
const std::string &vertexShaderSource = SHADER_SOURCE
(
attribute vec4 inputAttribute;
varying float dx_Position;
void main()
{
gl_Position = vec4(inputAttribute);
dx_Position = 0.0;
}
);
const std::string &fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
varying float dx_Position;
void main()
{
gl_FragColor = vec4(dx_Position, 0, 0, 1);
}
);
GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource);
EXPECT_NE(0u, program);
}