Use C++11 raw string literals instead of SHADER_SOURCE macro

This is better in many ways:
1. It doesn't confuse clang format
2. \n doesn't need to be included after preprocessor directives like
   the version directive.
3. It's using built-in functionality instead of something custom.

Raw string literals should be the preferred way to include shader
source in C++ files going forward.

BUG=angleproject:2157
TEST=angle_end2end_tests

Change-Id: I8b236a6e2d5c25d920297e5bc5b5b143eddeba1f
Reviewed-on: https://chromium-review.googlesource.com/671046
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
This commit is contained in:
Olli Etuaho 2017-09-18 13:32:29 +03:00 коммит произвёл Commit Bot
Родитель bb5a7e29d2
Коммит a20af6d7e8
54 изменённых файлов: 672 добавлений и 925 удалений

Просмотреть файл

@ -26,23 +26,19 @@ class HelloTriangleSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 vPosition;
const std::string vs =
R"(attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -27,9 +27,8 @@ class MipMap2DSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
uniform float u_offset;
const std::string vs =
R"(uniform float u_offset;
attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
@ -38,19 +37,16 @@ class MipMap2DSample : public SampleApplication
gl_Position = a_position;
gl_Position.x += u_offset;
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -40,21 +40,18 @@ class MultiTextureSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vs =
R"(attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main()
{
gl_Position = a_position;
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_baseMap;
uniform sampler2D s_lightMap;
@ -66,8 +63,7 @@ class MultiTextureSample : public SampleApplication
baseColor = texture2D(s_baseMap, v_texCoord);
lightColor = texture2D(s_lightMap, v_texCoord);
gl_FragColor = baseColor * (lightColor + 0.25);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -26,23 +26,19 @@ class MultiWindowSample : public SampleApplication
bool initialize() override
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 vPosition;
const std::string vs =
R"(attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -36,9 +36,8 @@ class ParticleSystemSample : public SampleApplication
bool initialize() override
{
const std::string vs = SHADER_SOURCE
(
uniform float u_time;
const std::string vs =
R"(uniform float u_time;
uniform vec3 u_centerPosition;
attribute float a_lifetime;
attribute vec3 a_startPosition;
@ -59,12 +58,10 @@ class ParticleSystemSample : public SampleApplication
v_lifetime = 1.0 - (u_time / a_lifetime);
v_lifetime = clamp(v_lifetime, 0.0, 1.0);
gl_PointSize = (v_lifetime * v_lifetime) * 40.0;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
uniform vec4 u_color;
varying float v_lifetime;
uniform sampler2D s_texture;
@ -74,8 +71,7 @@ class ParticleSystemSample : public SampleApplication
texColor = texture2D(s_texture, gl_PointCoord);
gl_FragColor = vec4(u_color) * texColor;
gl_FragColor.a *= v_lifetime;
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -39,9 +39,8 @@ class PostSubBufferSample : public SampleApplication
return false;
}
const std::string vs = SHADER_SOURCE
(
uniform mat4 u_mvpMatrix;
const std::string vs =
R"(uniform mat4 u_mvpMatrix;
attribute vec4 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
@ -49,18 +48,15 @@ class PostSubBufferSample : public SampleApplication
{
gl_Position = u_mvpMatrix * a_position;
v_texcoord = a_texcoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texcoord;
void main()
{
gl_FragColor = vec4(v_texcoord.x, v_texcoord.y, 1.0, 1.0);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -50,9 +50,8 @@ class SimpleInstancingSample : public SampleApplication
return false;
}
const std::string vs = SHADER_SOURCE
(
attribute vec3 a_position;
const std::string vs =
R"(attribute vec3 a_position;
attribute vec2 a_texCoord;
attribute vec3 a_instancePos;
varying vec2 v_texCoord;
@ -60,19 +59,16 @@ class SimpleInstancingSample : public SampleApplication
{
gl_Position = vec4(a_position.xyz + a_instancePos.xyz, 1.0);
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -27,28 +27,24 @@ class SimpleTexture2DSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vs =
R"(attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main()
{
gl_Position = a_position;
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -28,28 +28,24 @@ class SimpleTextureCubemapSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vs =
R"(attribute vec4 a_position;
attribute vec3 a_normal;
varying vec3 v_normal;
void main()
{
gl_Position = a_position;
v_normal = a_normal;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec3 v_normal;
uniform samplerCube s_texture;
void main()
{
gl_FragColor = textureCube(s_texture, v_normal);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -32,9 +32,8 @@ class SimpleVertexShaderSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
uniform mat4 u_mvpMatrix;
const std::string vs =
R"(uniform mat4 u_mvpMatrix;
attribute vec4 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
@ -42,18 +41,15 @@ class SimpleVertexShaderSample : public SampleApplication
{
gl_Position = u_mvpMatrix * a_position;
v_texcoord = a_texcoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texcoord;
void main()
{
gl_FragColor = vec4(v_texcoord.x, v_texcoord.y, 1.0, 1.0);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -26,24 +26,20 @@ class StencilOperationsSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vs =
R"(attribute vec4 a_position;
void main()
{
gl_Position = a_position;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
uniform vec4 u_color;
void main()
{
gl_FragColor = u_color;
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -88,28 +88,24 @@ class TexRedefBenchSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vs =
R"(attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main()
{
gl_Position = a_position;
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -27,9 +27,8 @@ class TextureWrapSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
uniform float u_offset;
const std::string vs =
R"(uniform float u_offset;
attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
@ -38,19 +37,16 @@ class TextureWrapSample : public SampleApplication
gl_Position = a_position;
gl_Position.x += u_offset;
v_texCoord = a_texCoord;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -134,23 +134,19 @@ class TriangleFanBenchSample : public SampleApplication
virtual bool initialize()
{
const std::string vs = SHADER_SOURCE
(
attribute vec4 vPosition;
const std::string vs =
R"(attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
);
})";
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
mProgram = CompileProgram(vs, fs);
if (!mProgram)

Просмотреть файл

@ -183,21 +183,25 @@ class EGLPresentPathD3D11 : public testing::TestWithParam<PlatformParameters>
GLint mTexture2DUniformLocation;
const std::string vertexShaderSource =
SHADER_SOURCE(precision highp float; attribute vec4 position; varying vec2 texcoord;
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
void main()
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
});
void main()
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
})";
const std::string fragmentShaderSource2D =
SHADER_SOURCE(precision highp float; uniform sampler2D tex; varying vec2 texcoord;
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
});
void main()
{
gl_FragColor = texture2D(tex, texcoord);
})";
m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D);
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");

Просмотреть файл

@ -167,23 +167,19 @@ class EGLSurfaceTest : public testing::Test
GLuint createProgram()
{
const std::string testVertexShaderSource = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string testVertexShaderSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string testFragmentShaderSource = SHADER_SOURCE
(
void main(void)
const std::string testFragmentShaderSource =
R"(void main(void)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
return CompileProgram(testVertexShaderSource, testFragmentShaderSource);
}

Просмотреть файл

@ -64,28 +64,22 @@ TEST_P(BindUniformLocationTest, Basic)
ASSERT_NE(mBindUniformLocation, nullptr);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vsSource =
R"(attribute vec4 a_position;
void main()
{
gl_Position = a_position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
uniform vec4 u_colorC;
uniform vec4 u_colorB[2];
uniform vec4 u_colorA;
void main()
{
gl_FragColor = u_colorA + u_colorB[0] + u_colorB[1] + u_colorC;
}
);
// clang-format on
})";
GLint colorALocation = 3;
GLint colorBLocation = 10;
@ -141,27 +135,21 @@ TEST_P(BindUniformLocationTest, ConflictsDetection)
ASSERT_NE(nullptr, mBindUniformLocation);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vsSource =
R"(attribute vec4 a_position;
void main()
{
gl_Position = a_position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
uniform vec4 u_colorA;
uniform vec4 u_colorB;
void main()
{
gl_FragColor = u_colorA + u_colorB;
}
);
// clang-format on
})";
GLint colorALocation = 3;
GLint colorBLocation = 4;
@ -203,10 +191,8 @@ TEST_P(BindUniformLocationTest, Compositor)
ASSERT_NE(nullptr, mBindUniformLocation);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vsSource =
R"(attribute vec4 a_position;
attribute vec2 a_texCoord;
uniform mat4 matrix;
uniform vec2 color_a[4];
@ -218,12 +204,10 @@ TEST_P(BindUniformLocationTest, Compositor)
v_color.zw = color_a[2] + color_a[3];
v_color += color_b;
gl_Position = matrix * a_position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
varying vec4 v_color;
uniform float alpha;
uniform vec4 multiplier;
@ -242,9 +226,7 @@ TEST_P(BindUniformLocationTest, Compositor)
color_c_sum.w = alpha;
color_c_sum *= multiplier;
gl_FragColor = v_color + color_c_sum;
}
);
// clang-format on
})";
int counter = 6;
int matrixLocation = counter++;
@ -319,28 +301,22 @@ TEST_P(BindUniformLocationTest, UnusedUniformUpdate)
ASSERT_NE(nullptr, mBindUniformLocation);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vsSource =
R"(attribute vec4 a_position;
void main()
{
gl_Position = a_position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
uniform vec4 u_colorA;
uniform float u_colorU;
uniform vec4 u_colorC;
void main()
{
gl_FragColor = u_colorA + u_colorC;
}
);
// clang-format on
})";
const GLint colorULocation = 1;
const GLint nonexistingLocation = 5;
@ -430,24 +406,18 @@ TEST_P(BindUniformLocationTest, UseSamplerWhenUnusedUniforms)
ASSERT_NE(nullptr, mBindUniformLocation);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
void main()
const std::string vsSource =
R"(void main()
{
gl_Position = vec4(0);
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
uniform sampler2D tex;
const std::string fsSource =
R"(uniform sampler2D tex;
void main()
{
gl_FragColor = texture2D(tex, vec2(1));
}
);
// clang-format on
})";
const GLuint texLocation = 54;
@ -485,26 +455,20 @@ TEST_P(BindUniformLocationTest, SameLocationForUsedAndUnusedUniform)
ASSERT_NE(nullptr, mBindUniformLocation);
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
void main()
const std::string vsSource =
R"(void main()
{
gl_Position = vec4(0);
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
uniform vec4 a;
uniform vec4 b;
void main()
{
gl_FragColor = a;
}
);
// clang-format on
})";
const GLuint location = 54;

Просмотреть файл

@ -123,24 +123,19 @@ class BlendMinMaxTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string testVertexShaderSource = SHADER_SOURCE
(
attribute highp vec4 aPosition;
const std::string testVertexShaderSource =
R"(attribute highp vec4 aPosition;
void main(void)
{
gl_Position = aPosition;
}
);
})";
const std::string testFragmentShaderSource = SHADER_SOURCE
(
uniform highp vec4 color;
const std::string testFragmentShaderSource =
R"(uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
})";
mProgram = CompileProgram(testVertexShaderSource, testFragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -65,9 +65,8 @@ class BlitFramebufferANGLETest : public ANGLETest
{
ANGLETest::SetUp();
const std::string passthroughVS = SHADER_SOURCE
(
precision highp float;
const std::string passthroughVS =
R"(precision highp float;
attribute vec4 position;
varying vec4 pos;
@ -75,12 +74,10 @@ class BlitFramebufferANGLETest : public ANGLETest
{
gl_Position = position;
pos = position;
}
);
})";
const std::string checkeredFS = SHADER_SOURCE
(
precision highp float;
const std::string checkeredFS =
R"(precision highp float;
varying vec4 pos;
void main()
@ -93,19 +90,16 @@ class BlitFramebufferANGLETest : public ANGLETest
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
}
);
})";
const std::string blueFS = SHADER_SOURCE
(
precision highp float;
const std::string blueFS =
R"(precision highp float;
varying vec4 pos;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
);
})";
mCheckerProgram = CompileProgram(passthroughVS, checkeredFS);
mBlueProgram = CompileProgram(passthroughVS, blueFS);

Просмотреть файл

@ -35,27 +35,23 @@ class BufferDataTest : public ANGLETest
{
ANGLETest::SetUp();
const char * vsSource = SHADER_SOURCE
(
attribute vec4 position;
const char *vsSource =
R"(attribute vec4 position;
attribute float in_attrib;
varying float v_attrib;
void main()
{
v_attrib = in_attrib;
gl_Position = position;
}
);
})";
const char * fsSource = SHADER_SOURCE
(
precision mediump float;
const char *fsSource =
R"(precision mediump float;
varying float v_attrib;
void main()
{
gl_FragColor = vec4(v_attrib, 0, 0, 1);
}
);
})";
glGenBuffers(1, &mBuffer);
ASSERT_NE(mBuffer, 0U);
@ -253,27 +249,23 @@ class IndexedBufferCopyTest : public ANGLETest
{
ANGLETest::SetUp();
const char * vsSource = SHADER_SOURCE
(
attribute vec3 in_attrib;
const char *vsSource =
R"(attribute vec3 in_attrib;
varying vec3 v_attrib;
void main()
{
v_attrib = in_attrib;
gl_Position = vec4(0.0, 0.0, 0.5, 1.0);
gl_PointSize = 100.0;
}
);
})";
const char * fsSource = SHADER_SOURCE
(
precision mediump float;
const char *fsSource =
R"(precision mediump float;
varying vec3 v_attrib;
void main()
{
gl_FragColor = vec4(v_attrib, 1);
}
);
})";
glGenBuffers(2, mBuffers);
ASSERT_NE(mBuffers[0], 0U);

Просмотреть файл

@ -75,26 +75,22 @@ class ClearTestBase : public ANGLETest
void setupDefaultProgram()
{
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
void main()
{
gl_Position = position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);

Просмотреть файл

@ -25,23 +25,19 @@ class CubeMapTextureTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string vsSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
uniform highp vec4 color;
const std::string fsSource =
R"(uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
})";
mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0)

Просмотреть файл

@ -32,9 +32,8 @@ class D3DImageFormatConversionTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -42,20 +41,17 @@ class D3DImageFormatConversionTest : public ANGLETest
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string fragmentShaderSource2D = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource2D =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D);
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");

Просмотреть файл

@ -36,10 +36,8 @@ class D3DTextureTest : public ANGLETest
{
ANGLETest::SetUp();
// clang-format off
const std::string vsSource = SHADER_SOURCE
(
precision highp float;
const std::string vsSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -48,31 +46,25 @@ class D3DTextureTest : public ANGLETest
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
texcoord.y = 1.0 - texcoord.y;
}
);
})";
const std::string textureFSSource = SHADER_SOURCE
(
precision highp float;
const std::string textureFSSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
const std::string textureFSSourceNoSampling = SHADER_SOURCE
(
precision highp float;
const std::string textureFSSourceNoSampling =
R"(precision highp float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}
);
// clang-format on
})";
mTextureProgram = CompileProgram(vsSource, textureFSSource);
ASSERT_NE(0u, mTextureProgram) << "shader compilation failed.";

Просмотреть файл

@ -28,9 +28,8 @@ class DXT1CompressedTextureTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
precision highp float;
const std::string vsSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -39,20 +38,17 @@ class DXT1CompressedTextureTest : public ANGLETest
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
texcoord.y = 1.0 - texcoord.y;
}
);
})";
const std::string textureFSSource = SHADER_SOURCE
(
precision highp float;
const std::string textureFSSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
mTextureProgram = CompileProgram(vsSource, textureFSSource);
if (mTextureProgram == 0)

Просмотреть файл

@ -68,9 +68,8 @@ class DepthStencilFormatsTestBase : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -78,20 +77,17 @@ class DepthStencilFormatsTestBase : public ANGLETest
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -32,26 +32,22 @@ class DifferentStencilMasksTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
void main()
{
gl_Position = position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);
@ -118,26 +114,22 @@ class DifferentStencilMasksWithoutStencilBufferTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
void main()
{
gl_Position = position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);

Просмотреть файл

@ -25,23 +25,19 @@ class FramebufferRenderMipmapTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string vsSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
uniform highp vec4 color;
const std::string fsSource =
R"(uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
})";
mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0)

Просмотреть файл

@ -30,14 +30,12 @@ class GLSLTest : public ANGLETest
{
ANGLETest::SetUp();
mSimpleVSSource = SHADER_SOURCE
(
attribute vec4 inputAttribute;
mSimpleVSSource =
R"(attribute vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
}
);
})";
}
std::string GenerateVaryingType(GLint vectorSize)
@ -449,12 +447,12 @@ class GLSLTest_ES3 : public GLSLTest
ANGLETest::SetUp();
mSimpleVSSource =
"#version 300 es\n"
"in vec4 inputAttribute;"
"void main()"
"{"
" gl_Position = inputAttribute;"
"}";
R"(#version 300 es
in vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
})";
}
};
@ -465,21 +463,19 @@ class GLSLTest_ES31 : public GLSLTest
ANGLETest::SetUp();
mSimpleVSSource =
"#version 310 es\n"
"in vec4 inputAttribute;"
"void main()"
"{"
" gl_Position = inputAttribute;"
"}";
R"(#version 310 es
in vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
})";
}
};
TEST_P(GLSLTest, NamelessScopedStructs)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
void main()
{
struct
@ -489,8 +485,7 @@ TEST_P(GLSLTest, NamelessScopedStructs)
gl_FragColor = vec4(1, 0, 0, 1);
gl_FragColor.a += b.q;
}
);
})";
GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
@ -508,9 +503,8 @@ TEST_P(GLSLTest, ScopedStructsOrderBug)
return;
}
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
struct T
{
@ -531,8 +525,7 @@ TEST_P(GLSLTest, ScopedStructsOrderBug)
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);
@ -540,9 +533,8 @@ TEST_P(GLSLTest, ScopedStructsOrderBug)
TEST_P(GLSLTest, ScopedStructsBug)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
struct T_0
{
@ -563,8 +555,7 @@ TEST_P(GLSLTest, ScopedStructsBug)
gl_FragColor.a += a.f;
gl_FragColor.a += b.v.x;
}
);
})";
GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
@ -572,28 +563,24 @@ TEST_P(GLSLTest, ScopedStructsBug)
TEST_P(GLSLTest, DxPositionBug)
{
const std::string &vertexShaderSource = SHADER_SOURCE
(
attribute vec4 inputAttribute;
const std::string &vertexShaderSource =
R"(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;
const std::string &fragmentShaderSource =
R"(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);
@ -664,20 +651,17 @@ TEST_P(GLSLTest, FrontFacingAndVarying)
{
EGLPlatformParameters platform = GetParam().eglParameters;
const std::string vertexShaderSource = SHADER_SOURCE
(
attribute vec4 a_position;
const std::string vertexShaderSource =
R"(attribute vec4 a_position;
varying float v_varying;
void main()
{
v_varying = a_position.x;
gl_Position = a_position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
varying float v_varying;
void main()
{
@ -692,8 +676,7 @@ TEST_P(GLSLTest, FrontFacingAndVarying)
c = vec4(0, v_varying, 0, 1.0);
}
gl_FragColor = c;
}
);
})";
GLuint program = CompileProgram(vertexShaderSource, fragmentShaderSource);
@ -1570,9 +1553,8 @@ TEST_P(GLSLTest, BadIndexBug)
// Test that structs defined in uniforms are translated correctly.
TEST_P(GLSLTest, StructSpecifiersUniforms)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
uniform struct S { float field;} s;
@ -1580,8 +1562,7 @@ TEST_P(GLSLTest, StructSpecifiersUniforms)
{
gl_FragColor = vec4(1, 0, 0, 1);
gl_FragColor.a += s.field;
}
);
})";
GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
EXPECT_NE(0u, program);
@ -1593,15 +1574,13 @@ TEST_P(GLSLTest, StructSpecifiersUniforms)
// (note this test is still Impl-independent)
TEST_P(GLSLTestNoValidation, DepthRangeUniforms)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(gl_DepthRange.near, gl_DepthRange.far, gl_DepthRange.diff, 1);
}
);
})";
ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShaderSource);
@ -1683,9 +1662,8 @@ TEST_P(GLSLTest, PowOfSmallConstant)
// than FL9_3.
TEST_P(GLSLTest, LoopIndexingValidation)
{
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision mediump float;
const std::string fragmentShaderSource =
R"(precision mediump float;
uniform float loopMax;
@ -1699,8 +1677,7 @@ TEST_P(GLSLTest, LoopIndexingValidation)
gl_FragColor.a += 0.1;
}
}
}
);
})";
GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);

Просмотреть файл

@ -28,9 +28,8 @@ class IncompleteTextureTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -38,20 +37,17 @@ class IncompleteTextureTest : public ANGLETest
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -29,14 +29,22 @@ class IndexBufferOffsetTest : public ANGLETest
ANGLETest::SetUp();
const std::string vertexShaderSource =
SHADER_SOURCE(precision highp float; attribute vec2 position;
R"(precision highp float;
attribute vec2 position;
void main() { gl_Position = vec4(position, 0.0, 1.0); });
void main()
{
gl_Position = vec4(position, 0.0, 1.0);
})";
const std::string fragmentShaderSource =
SHADER_SOURCE(precision highp float; uniform vec4 color;
R"(precision highp float;
uniform vec4 color;
void main() { gl_FragColor = color; });
void main()
{
gl_FragColor = color;
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);

Просмотреть файл

@ -32,34 +32,45 @@ class IndexedPointsTest : public ANGLETest
ANGLETest::SetUp();
const std::string vertexShaderSource =
SHADER_SOURCE(precision highp float; attribute vec2 position;
R"(precision highp float;
attribute vec2 position;
void main() {
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
});
void main() {
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
})";
const std::string fragmentShaderSource =
SHADER_SOURCE(precision highp float;
R"(precision highp float;
void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); });
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);
const std::string vertexShaderSource2 =
SHADER_SOURCE(precision highp float; attribute vec2 position; attribute vec4 color;
varying vec4 vcolor;
R"(precision highp float;
attribute vec2 position;
attribute vec4 color;
varying vec4 vcolor;
void main() {
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
vcolor = color;
});
void main() {
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
vcolor = color;
})";
const std::string fragmentShaderSource2 =
SHADER_SOURCE(precision highp float; varying vec4 vcolor;
void main() { gl_FragColor = vec4(vcolor.xyz, 1.0); });
R"(precision highp float;
varying vec4 vcolor;
void main()
{
gl_FragColor = vec4(vcolor.xyz, 1.0);
})";
mVertexWithColorBufferProgram = CompileProgram(vertexShaderSource2, fragmentShaderSource2);
ASSERT_NE(0u, mVertexWithColorBufferProgram);

Просмотреть файл

@ -25,12 +25,19 @@ class LineLoopTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE(attribute highp vec4 position;
void main(void) { gl_Position = position; });
const std::string vsSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
})";
const std::string fsSource =
SHADER_SOURCE(uniform highp vec4 color; void main(void) { gl_FragColor = color; });
R"(uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
})";
mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0)

Просмотреть файл

@ -25,9 +25,8 @@ class MaxTextureSizeTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
precision highp float;
const std::string vsSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -35,30 +34,25 @@ class MaxTextureSizeTest : public ANGLETest
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string textureFSSource = SHADER_SOURCE
(
precision highp float;
const std::string textureFSSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
const std::string blueFSSource = SHADER_SOURCE
(
precision highp float;
const std::string blueFSSource =
R"(precision highp float;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
);
})";
mTextureProgram = CompileProgram(vsSource, textureFSSource);
mBlueProgram = CompileProgram(vsSource, blueFSSource);

Просмотреть файл

@ -75,23 +75,19 @@ class MipmapTest : public BaseMipmapTest
void setUp2DProgram()
{
// Vertex Shader source
// clang-format off
const std::string vs = SHADER_SOURCE
(
attribute vec4 position;
const std::string vs =
R"(attribute vec4 position;
varying vec2 vTexCoord;
void main()
{
gl_Position = position;
vTexCoord = (position.xy * 0.5) + 0.5;
}
);
})";
// Fragment Shader source
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
uniform sampler2D uTexture;
varying vec2 vTexCoord;
@ -99,9 +95,7 @@ class MipmapTest : public BaseMipmapTest
void main()
{
gl_FragColor = texture2D(uTexture, vTexCoord);
}
);
// clang-format on
})";
m2DProgram = CompileProgram(vs, fs);
ASSERT_NE(0u, m2DProgram);
@ -110,31 +104,25 @@ class MipmapTest : public BaseMipmapTest
void setUpCubeProgram()
{
// A simple vertex shader for the texture cube
// clang-format off
const std::string cubeVS = SHADER_SOURCE
(
attribute vec4 position;
const std::string cubeVS =
R"(attribute vec4 position;
varying vec4 vPosition;
void main()
{
gl_Position = position;
vPosition = position;
}
);
})";
// A very simple fragment shader to sample from the negative-Y face of a texture cube.
const std::string cubeFS = SHADER_SOURCE
(
precision mediump float;
const std::string cubeFS =
R"(precision mediump float;
uniform samplerCube uTexture;
varying vec4 vPosition;
void main()
{
gl_FragColor = textureCube(uTexture, vec3(vPosition.x, -1, vPosition.y));
}
);
// clang-format on
})";
mCubeProgram = CompileProgram(cubeVS, cubeFS);
ASSERT_NE(0u, mCubeProgram);
@ -264,9 +252,8 @@ class MipmapTestES3 : public BaseMipmapTest
// Don't put "#version ..." on its own line. See [cpp]p1:
// "If there are sequences of preprocessing tokens within the list of arguments that
// would otherwise act as preprocessing directives, the behavior is undefined"
// clang-format off
return SHADER_SOURCE
( #version 300 es\n
return
R"(#version 300 es
precision highp float;
in vec4 position;
out vec2 texcoord;
@ -275,15 +262,13 @@ class MipmapTestES3 : public BaseMipmapTest
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
);
// clang-format on
})";
}
void setUpArrayProgram()
{
const std::string fragmentShaderSourceArray = SHADER_SOURCE
( #version 300 es\n
const std::string fragmentShaderSourceArray =
R"(#version 300 es
precision highp float;
uniform highp sampler2DArray tex;
uniform int slice;
@ -293,8 +278,7 @@ class MipmapTestES3 : public BaseMipmapTest
void main()
{
out_FragColor = texture(tex, vec3(texcoord, float(slice)));
}
);
})";
mArrayProgram = CompileProgram(vertexShaderSource(), fragmentShaderSourceArray);
if (mArrayProgram == 0)
@ -312,8 +296,8 @@ class MipmapTestES3 : public BaseMipmapTest
void setUp3DProgram()
{
const std::string fragmentShaderSource3D = SHADER_SOURCE
( #version 300 es\n
const std::string fragmentShaderSource3D =
R"(#version 300 es
precision highp float;
uniform highp sampler3D tex;
uniform float slice;
@ -324,8 +308,7 @@ class MipmapTestES3 : public BaseMipmapTest
void main()
{
out_FragColor = textureLod(tex, vec3(texcoord, slice), lod);
}
);
})";
m3DProgram = CompileProgram(vertexShaderSource(), fragmentShaderSource3D);
if (m3DProgram == 0)
@ -347,9 +330,8 @@ class MipmapTestES3 : public BaseMipmapTest
void setUp2DProgram()
{
// clang-format off
const std::string fragmentShaderSource2D = SHADER_SOURCE
( #version 300 es\n
const std::string fragmentShaderSource2D =
R"(#version 300 es
precision highp float;
uniform highp sampler2D tex;
in vec2 texcoord;
@ -358,9 +340,7 @@ class MipmapTestES3 : public BaseMipmapTest
void main()
{
out_FragColor = texture(tex, texcoord);
}
);
// clang-format on
})";
m2DProgram = CompileProgram(vertexShaderSource(), fragmentShaderSource2D);
ASSERT_NE(0u, m2DProgram);
@ -371,9 +351,8 @@ class MipmapTestES3 : public BaseMipmapTest
void setUpCubeProgram()
{
// A very simple fragment shader to sample from the negative-Y face of a texture cube.
// clang-format off
const std::string cubeFS = SHADER_SOURCE
( #version 300 es\n
const std::string cubeFS =
R"(#version 300 es
precision mediump float;
uniform samplerCube uTexture;
in vec2 texcoord;
@ -382,9 +361,7 @@ class MipmapTestES3 : public BaseMipmapTest
void main()
{
out_FragColor = texture(uTexture, vec3(texcoord.x, -1, texcoord.y));
}
);
// clang-format on
})";
mCubeProgram = CompileProgram(vertexShaderSource(), cubeFS);
ASSERT_NE(0u, mCubeProgram);

Просмотреть файл

@ -28,23 +28,19 @@ class OcclusionQueriesTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string passthroughVS = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string passthroughVS =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string passthroughPS = SHADER_SOURCE
(
precision highp float;
const std::string passthroughPS =
R"(precision highp float;
void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
mProgram = CompileProgram(passthroughVS, passthroughPS);
ASSERT_NE(0u, mProgram);
@ -288,23 +284,19 @@ TEST_P(OcclusionQueriesTest, MultiContext)
eglMakeCurrent(display, surface, surface, context.context);
const std::string passthroughVS = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string passthroughVS =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string passthroughPS = SHADER_SOURCE
(
precision highp float;
const std::string passthroughPS =
R"(precision highp float;
void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
context.program = CompileProgram(passthroughVS, passthroughPS);
ASSERT_NE(context.program, 0u);

Просмотреть файл

@ -34,18 +34,24 @@ class PBOExtensionTest : public ANGLETest
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
const char *vertexShaderSrc =
SHADER_SOURCE(attribute vec4 aTest; attribute vec2 aPosition; varying vec4 vTest;
R"(attribute vec4 aTest;
attribute vec2 aPosition;
varying vec4 vTest;
void main() {
vTest = aTest;
gl_Position = vec4(aPosition, 0.0, 1.0);
gl_PointSize = 1.0;
});
void main()
{
vTest = aTest;
gl_Position = vec4(aPosition, 0.0, 1.0);
gl_PointSize = 1.0;
})";
const char *fragmentShaderSrc =
SHADER_SOURCE(precision mediump float; varying vec4 vTest;
void main() { gl_FragColor = vTest; });
R"(precision mediump float;
varying vec4 vTest;
void main()
{
gl_FragColor = vTest;
})";
mProgram = CompileProgram(vertexShaderSrc, fragmentShaderSrc);

Просмотреть файл

@ -32,21 +32,19 @@ class PackUnpackTest : public ANGLETest
ANGLETest::SetUp();
// Vertex Shader source
const std::string vs = SHADER_SOURCE
( #version 300 es\n
const std::string vs =
R"(#version 300 es
precision mediump float;
in vec4 position;
void main()
{
gl_Position = position;
}
);
})";
// clang-format off
// Fragment Shader source
const std::string sNormFS = SHADER_SOURCE
( #version 300 es\n
const std::string sNormFS =
R"(#version 300 es
precision mediump float;
uniform mediump vec2 v;
layout(location = 0) out mediump vec4 fragColor;
@ -56,12 +54,11 @@ class PackUnpackTest : public ANGLETest
uint u = packSnorm2x16(v);
vec2 r = unpackSnorm2x16(u);
fragColor = vec4(r, 0.0, 1.0);
}
);
})";
// Fragment Shader source
const std::string uNormFS = SHADER_SOURCE
( #version 300 es\n
const std::string uNormFS =
R"(#version 300 es
precision mediump float;
uniform mediump vec2 v;
layout(location = 0) out mediump vec4 fragColor;
@ -71,12 +68,11 @@ class PackUnpackTest : public ANGLETest
uint u = packUnorm2x16(v);
vec2 r = unpackUnorm2x16(u);
fragColor = vec4(r, 0.0, 1.0);
}
);
})";
// Fragment Shader source
const std::string halfFS = SHADER_SOURCE
( #version 300 es\n
const std::string halfFS =
R"(#version 300 es
precision mediump float;
uniform mediump vec2 v;
layout(location = 0) out mediump vec4 fragColor;
@ -86,9 +82,7 @@ class PackUnpackTest : public ANGLETest
uint u = packHalf2x16(v);
vec2 r = unpackHalf2x16(u);
fragColor = vec4(r, 0.0, 1.0);
}
);
// clang-format on
})";
mSNormProgram = CompileProgram(vs, sNormFS);
mUNormProgram = CompileProgram(vs, uNormFS);

Просмотреть файл

@ -26,9 +26,8 @@ class PbufferTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
precision highp float;
const std::string vsSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -37,20 +36,17 @@ class PbufferTest : public ANGLETest
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
texcoord.y = 1.0 - texcoord.y;
}
);
})";
const std::string textureFSSource = SHADER_SOURCE
(
precision highp float;
const std::string textureFSSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
mTextureProgram = CompileProgram(vsSource, textureFSSource);
if (mTextureProgram == 0)

Просмотреть файл

@ -52,15 +52,21 @@ TEST_P(PointSpritesTest, PointCoordAndPointSizeCompliance)
return;
}
const std::string fs = SHADER_SOURCE(precision mediump float; void main() {
gl_FragColor = vec4(gl_PointCoord.x, gl_PointCoord.y, 0, 1);
});
const std::string fs =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(gl_PointCoord.x, gl_PointCoord.y, 0, 1);
})";
const std::string vs =
SHADER_SOURCE(attribute vec4 vPosition; uniform float uPointSize; void main() {
R"(attribute vec4 vPosition;
uniform float uPointSize;
void main()
{
gl_PointSize = uPointSize;
gl_Position = vPosition;
});
})";
ANGLE_GL_PROGRAM(program, vs, fs);
@ -156,25 +162,19 @@ TEST_P(PointSpritesTest, PointWithoutAttributesCompliance)
return;
}
// clang-format off
const std::string fs = SHADER_SOURCE
(
precision mediump float;
const std::string fs =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
);
})";
const std::string vs = SHADER_SOURCE
(
void main()
const std::string vs =
R"(void main()
{
gl_PointSize = 2.0;
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
);
// clang-format on
})";
ANGLE_GL_PROGRAM(program, vs, fs);
ASSERT_GL_NO_ERROR();
@ -201,7 +201,10 @@ TEST_P(PointSpritesTest, PointCoordRegressionTest)
}
const std::string fs =
SHADER_SOURCE(precision mediump float; varying vec4 v_color; void main() {
R"(precision mediump float;
varying vec4 v_color;
void main()
{
// It seems as long as this mathematical expression references
// gl_PointCoord, the fragment's color is incorrect.
vec2 diff = gl_PointCoord - vec2(.5, .5);
@ -210,17 +213,20 @@ TEST_P(PointSpritesTest, PointCoordRegressionTest)
// The point should be a solid color.
gl_FragColor = v_color;
});
})";
const std::string vs =
SHADER_SOURCE(varying vec4 v_color;
// The X and Y coordinates of the center of the point.
attribute vec2 a_vertex; uniform float u_pointSize; void main() {
gl_PointSize = u_pointSize;
gl_Position = vec4(a_vertex, 0.0, 1.0);
// The color of the point.
v_color = vec4(0.0, 1.0, 0.0, 1.0);
});
R"(varying vec4 v_color;
// The X and Y coordinates of the center of the point.
attribute vec2 a_vertex;
uniform float u_pointSize;
void main()
{
gl_PointSize = u_pointSize;
gl_Position = vec4(a_vertex, 0.0, 1.0);
// The color of the point.
v_color = vec4(0.0, 1.0, 0.0, 1.0);
})";
ANGLE_GL_PROGRAM(program, vs, fs);
ASSERT_GL_NO_ERROR();
@ -278,18 +284,27 @@ TEST_P(PointSpritesTest, PointSizeEnabledCompliance)
return;
}
const std::string fs = SHADER_SOURCE(precision mediump float; varying vec4 color;
const std::string fs =
R"(precision mediump float;
varying vec4 color;
void main() { gl_FragColor = color; });
void main()
{
gl_FragColor = color;
})";
const std::string vs = SHADER_SOURCE(attribute vec3 pos; attribute vec4 colorIn;
uniform float pointSize; varying vec4 color;
const std::string vs =
R"(attribute vec3 pos;
attribute vec4 colorIn;
uniform float pointSize;
varying vec4 color;
void main() {
gl_PointSize = pointSize;
color = colorIn;
gl_Position = vec4(pos, 1.0);
});
void main()
{
gl_PointSize = pointSize;
color = colorIn;
gl_Position = vec4(pos, 1.0);
})";
// The WebGL test is drawn on a 2x2 canvas. Emulate this by setting a 2x2 viewport.
glViewport(0, 0, 2, 2);
@ -387,15 +402,20 @@ TEST_P(PointSpritesTest, PointSizeEnabledCompliance)
// Verify that rendering works correctly when gl_PointSize is declared in a shader but isn't used
TEST_P(PointSpritesTest, PointSizeDeclaredButUnused)
{
const std::string vs = SHADER_SOURCE(attribute highp vec4 position;
const std::string vs =
R"(attribute highp vec4 position;
void main(void) {
gl_PointSize = 1.0;
gl_Position = position;
});
void main(void)
{
gl_PointSize = 1.0;
gl_Position = position;
})";
const std::string fs =
SHADER_SOURCE(void main(void) { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); });
R"(void main(void)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
})";
ANGLE_GL_PROGRAM(program, vs, fs);
ASSERT_GL_NO_ERROR();
@ -413,44 +433,34 @@ TEST_P(PointSpritesTest, PointSizeDeclaredButUnused)
// spites.
TEST_P(PointSpritesTest, PointSpriteAlternatingDrawTypes)
{
// clang-format off
const std::string pointFS = SHADER_SOURCE
(
precision mediump float;
const std::string pointFS =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
);
})";
const std::string pointVS = SHADER_SOURCE
(
void main()
const std::string pointVS =
R"(void main()
{
gl_PointSize = 16.0;
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
);
})";
const std::string quadFS = SHADER_SOURCE
(
precision mediump float;
const std::string quadFS =
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
const std::string quadVS = SHADER_SOURCE
(
precision mediump float;
const std::string quadVS =
R"(precision mediump float;
attribute vec4 pos;
void main()
{
gl_Position = pos;
}
);
// clang-format on
})";
ANGLE_GL_PROGRAM(pointProgram, pointVS, pointFS);

Просмотреть файл

@ -34,22 +34,18 @@ class ProgramBinaryTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
attribute vec4 inputAttribute;
const std::string vertexShaderSource =
R"(attribute vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
void main()
const std::string fragmentShaderSource =
R"(void main()
{
gl_FragColor = vec4(1,0,0,1);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)
@ -452,25 +448,23 @@ class ProgramBinaryTransformFeedbackTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
( #version 300 es\n
const std::string vertexShaderSource =
R"(#version 300 es
in vec4 inputAttribute;
out vec4 outputVarying;
void main()
{
outputVarying = inputAttribute;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
( #version 300 es\n
const std::string fragmentShaderSource =
R"(#version 300 es
precision highp float;
out vec4 outputColor;
void main()
{
outputColor = vec4(1,0,0,1);
}
);
})";
std::vector<std::string> transformFeedbackVaryings;
transformFeedbackVaryings.push_back("outputVarying");
@ -633,50 +627,44 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
GLuint createES2ProgramFromSource()
{
const std::string testVertexShaderSource = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string testVertexShaderSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string testFragmentShaderSource = SHADER_SOURCE
(
void main(void)
const std::string testFragmentShaderSource =
R"(void main(void)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
return CompileProgram(testVertexShaderSource, testFragmentShaderSource);
}
GLuint createES3ProgramFromSource()
{
const std::string testVertexShaderSource = SHADER_SOURCE
( #version 300 es\n
const std::string testVertexShaderSource =
R"(#version 300 es
precision highp float;
in highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string testFragmentShaderSource = SHADER_SOURCE
( #version 300 es \n
const std::string testFragmentShaderSource =
R"(#version 300 es
precision highp float;
out vec4 out_FragColor;
void main(void)
{
out_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
return CompileProgram(testVertexShaderSource, testFragmentShaderSource);
}

Просмотреть файл

@ -54,14 +54,12 @@ void SimpleOperationTest::verifyBuffer(const std::vector<uint8_t> &data, GLenum
TEST_P(SimpleOperationTest, CompileVertexShader)
{
const std::string source = SHADER_SOURCE
(
attribute vec4 a_input;
const std::string source =
R"(attribute vec4 a_input;
void main()
{
gl_Position = a_input;
}
);
})";
GLuint shader = CompileShader(GL_VERTEX_SHADER, source);
EXPECT_NE(shader, 0u);
@ -72,15 +70,13 @@ TEST_P(SimpleOperationTest, CompileVertexShader)
TEST_P(SimpleOperationTest, CompileFragmentShader)
{
const std::string source = SHADER_SOURCE
(
precision mediump float;
const std::string source =
R"(precision mediump float;
varying vec4 v_input;
void main()
{
gl_FragColor = v_input;
}
);
})";
GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
EXPECT_NE(shader, 0u);
@ -91,21 +87,17 @@ TEST_P(SimpleOperationTest, CompileFragmentShader)
TEST_P(SimpleOperationTest, LinkProgram)
{
const std::string vsSource = SHADER_SOURCE
(
void main()
const std::string vsSource =
R"(void main()
{
gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
void main()
const std::string fsSource =
R"(void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);
@ -123,23 +115,19 @@ TEST_P(SimpleOperationTest, LinkProgramWithUniforms)
return;
}
const std::string vsSource = SHADER_SOURCE
(
void main()
const std::string vsSource =
R"(void main()
{
gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
precision mediump float;
const std::string fsSource =
R"(precision mediump float;
uniform vec4 u_input;
void main()
{
gl_FragColor = u_input;
}
);
})";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);
@ -161,22 +149,18 @@ TEST_P(SimpleOperationTest, LinkProgramWithAttributes)
return;
}
const std::string vsSource = SHADER_SOURCE
(
attribute vec4 a_input;
const std::string vsSource =
R"(attribute vec4 a_input;
void main()
{
gl_Position = a_input;
}
);
})";
const std::string fsSource = SHADER_SOURCE
(
void main()
const std::string fsSource =
R"(void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
);
})";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);

Просмотреть файл

@ -50,9 +50,8 @@ class SixteenBppTextureTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -60,20 +59,17 @@ class SixteenBppTextureTest : public ANGLETest
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string fragmentShaderSource2D = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource2D =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D);
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");

Просмотреть файл

@ -64,9 +64,8 @@ class SwizzleTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -74,20 +73,17 @@ class SwizzleTest : public ANGLETest
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string fragmentShaderSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);

Просмотреть файл

@ -49,9 +49,8 @@ class TexCoordDrawTest : public ANGLETest
virtual std::string getVertexShaderSource()
{
return std::string(SHADER_SOURCE
(
precision highp float;
return
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -59,9 +58,7 @@ class TexCoordDrawTest : public ANGLETest
{
gl_Position = vec4(position.xy, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
)
);
})";
}
virtual std::string getFragmentShaderSource() = 0;
@ -140,18 +137,15 @@ class Texture2DTest : public TexCoordDrawTest
std::string getFragmentShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision highp float;
return
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
)
);
})";
}
virtual const char *getTextureUniformName() { return "tex"; }
@ -497,9 +491,8 @@ class Texture2DTestWithDrawScale : public Texture2DTest
std::string getVertexShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision highp float;
return
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
@ -509,9 +502,7 @@ class Texture2DTestWithDrawScale : public Texture2DTest
{
gl_Position = vec4(position.xy * drawScale, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
}
)
);
})";
}
void SetUp() override
@ -539,9 +530,8 @@ class Sampler2DAsFunctionParameterTest : public Texture2DTest
std::string getFragmentShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision highp float;
return
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
@ -553,9 +543,7 @@ class Sampler2DAsFunctionParameterTest : public Texture2DTest
void main()
{
gl_FragColor = computeFragColor(tex);
}
)
);
})";
}
void SetUp() override
@ -579,9 +567,8 @@ class TextureCubeTest : public TexCoordDrawTest
std::string getFragmentShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision highp float;
return
R"(precision highp float;
uniform sampler2D tex2D;
uniform samplerCube texCube;
varying vec2 texcoord;
@ -590,9 +577,7 @@ class TextureCubeTest : public TexCoordDrawTest
{
gl_FragColor = texture2D(tex2D, texcoord);
gl_FragColor += textureCube(texCube, vec3(texcoord, 0));
}
)
);
})";
}
void SetUp() override
@ -650,18 +635,15 @@ class SamplerArrayTest : public TexCoordDrawTest
std::string getFragmentShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision mediump float;
return
R"(precision mediump float;
uniform highp sampler2D tex2DArray[2];
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex2DArray[0], texcoord);
gl_FragColor += texture2D(tex2DArray[1], texcoord);
}
)
);
})";
}
void SetUp() override
@ -728,9 +710,8 @@ class SamplerArrayAsFunctionParameterTest : public SamplerArrayTest
std::string getFragmentShaderSource() override
{
return std::string(SHADER_SOURCE
(
precision mediump float;
return
R"(precision mediump float;
uniform highp sampler2D tex2DArray[2];
varying vec2 texcoord;
@ -742,9 +723,7 @@ class SamplerArrayAsFunctionParameterTest : public SamplerArrayTest
void main()
{
gl_FragColor = computeFragColor(tex2DArray);
}
)
);
})";
}
};
@ -3936,20 +3915,20 @@ TEST_P(TextureCubeTestES3, SpecifyAndSampleFromBaseLevel1)
}
const std::string vs =
R"(#version 300 es
precision mediump float;
in vec3 pos;
void main() {
gl_Position = vec4(pos, 1.0);
})";
precision mediump float;
in vec3 pos;
void main() {
gl_Position = vec4(pos, 1.0);
})";
const std::string fs =
R"(#version 300 es
precision mediump float;
out vec4 color;
uniform samplerCube uTex;
void main(){
color = texture(uTex, vec3(1.0));
})";
precision mediump float;
out vec4 color;
uniform samplerCube uTex;
void main(){
color = texture(uTex, vec3(1.0));
})";
ANGLE_GL_PROGRAM(program, vs, fs);
glUseProgram(program);

Просмотреть файл

@ -78,14 +78,21 @@ class TransformFeedbackTest : public TransformFeedbackTestBase
ASSERT_EQ(0u, mProgram);
const std::string vertexShaderSource =
SHADER_SOURCE(precision highp float; attribute vec4 position;
R"(precision highp float;
attribute vec4 position;
void main() { gl_Position = position; });
void main()
{
gl_Position = position;
})";
const std::string fragmentShaderSource =
SHADER_SOURCE(precision highp float;
R"(precision highp float;
void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); });
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
})";
mProgram = CompileProgramWithTransformFeedback(vertexShaderSource, fragmentShaderSource,
tfVaryings, bufferMode);
@ -421,28 +428,24 @@ TEST_P(TransformFeedbackTest, MultiplePaused)
const size_t transformFeedbackCount = 8;
// clang-format off
const std::string vertexShaderSource = SHADER_SOURCE
( #version 300 es\n
in highp vec4 position;
in float transformFeedbackInput;
out float transformFeedbackOutput;
void main(void)
{
gl_Position = position;
transformFeedbackOutput = transformFeedbackInput;
}
);
const std::string vertexShaderSource =
R"(#version 300 es
in highp vec4 position;
in float transformFeedbackInput;
out float transformFeedbackOutput;
void main(void)
{
gl_Position = position;
transformFeedbackOutput = transformFeedbackInput;
})";
const std::string fragmentShaderSource = SHADER_SOURCE
( #version 300 es\n
out mediump vec4 color;
void main(void)
{
color = vec4(1.0, 1.0, 1.0, 1.0);
}
);
// clang-format on
const std::string fragmentShaderSource =
R"(#version 300 es
out mediump vec4 color;
void main(void)
{
color = vec4(1.0, 1.0, 1.0, 1.0);
})";
std::vector<std::string> tfVaryings;
tfVaryings.push_back("transformFeedbackOutput");
@ -558,9 +561,8 @@ TEST_P(TransformFeedbackTest, MultiContext)
eglMakeCurrent(display, surface, surface, context.context);
// clang-format off
const std::string vertexShaderSource = SHADER_SOURCE
( #version 300 es\n
const std::string vertexShaderSource =
R"(#version 300 es
in highp vec4 position;
in float transformFeedbackInput;
out float transformFeedbackOutput;
@ -568,18 +570,15 @@ TEST_P(TransformFeedbackTest, MultiContext)
{
gl_Position = position;
transformFeedbackOutput = transformFeedbackInput;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
( #version 300 es\n
const std::string fragmentShaderSource =
R"(#version 300 es
out mediump vec4 color;
void main(void)
{
color = vec4(1.0, 1.0, 1.0, 1.0);
}
);
// clang-format on
})";
std::vector<std::string> tfVaryings;
tfVaryings.push_back("transformFeedbackOutput");

Просмотреть файл

@ -29,14 +29,23 @@ class UniformBufferTest : public ANGLETest
{
ANGLETest::SetUp();
mVertexShaderSource = SHADER_SOURCE(#version 300 es\n in vec4 position;
void main() { gl_Position = position; });
mVertexShaderSource =
R"(#version 300 es
in vec4 position;
void main()
{
gl_Position = position;
})";
mFragmentShaderSource =
SHADER_SOURCE(#version 300 es\n precision highp float; uniform uni { vec4 color; };
out vec4 fragColor;
void main() { fragColor = color; });
R"(#version 300 es
precision highp float;
uniform uni { vec4 color; };
out vec4 fragColor;
void main()
{
fragColor = color;
})";
mProgram = CompileProgram(mVertexShaderSource, mFragmentShaderSource);
ASSERT_NE(mProgram, 0u);

Просмотреть файл

@ -110,25 +110,21 @@ TEST_P(UniformTest, UniformArrayLocations)
return;
}
const std::string vertexShader = SHADER_SOURCE
(
precision mediump float;
const std::string vertexShader =
R"(precision mediump float;
uniform float uPosition[4];
void main(void)
{
gl_Position = vec4(uPosition[0], uPosition[1], uPosition[2], uPosition[3]);
}
);
})";
const std::string fragShader = SHADER_SOURCE
(
precision mediump float;
const std::string fragShader =
R"(precision mediump float;
uniform float uColor[4];
void main(void)
{
gl_FragColor = vec4(uColor[0], uColor[1], uColor[2], uColor[3]);
}
);
})";
GLuint program = CompileProgram(vertexShader, fragShader);
ASSERT_NE(program, 0u);

Просмотреть файл

@ -31,26 +31,22 @@ class UnpackAlignmentTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
void main()
{
gl_Position = position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
uniform sampler2D tex;
const std::string fragmentShaderSource =
R"(uniform sampler2D tex;
void main()
{
gl_FragColor = texture2D(tex, vec2(0.0, 1.0));
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -31,26 +31,22 @@ class UnpackRowLengthTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
const std::string vertexShaderSource =
R"(precision highp float;
attribute vec4 position;
void main()
{
gl_Position = position;
}
);
})";
const std::string fragmentShaderSource = SHADER_SOURCE
(
uniform sampler2D tex;
const std::string fragmentShaderSource =
R"(uniform sampler2D tex;
void main()
{
gl_FragColor = texture2D(tex, vec2(0.0, 1.0));
}
);
})";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -122,23 +122,19 @@ class ViewportTest : public ANGLETest
{
ANGLETest::SetUp();
const std::string testVertexShaderSource = SHADER_SOURCE
(
attribute highp vec4 position;
const std::string testVertexShaderSource =
R"(attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
})";
const std::string testFragmentShaderSource = SHADER_SOURCE
(
void main(void)
const std::string testFragmentShaderSource =
R"(void main(void)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
})";
mProgram = CompileProgram(testVertexShaderSource, testFragmentShaderSource);
if (mProgram == 0)

Просмотреть файл

@ -131,15 +131,24 @@ void TexSubImageBenchmark::initializeBenchmark()
{
const auto &params = GetParam();
const std::string vs = SHADER_SOURCE(attribute vec4 a_position; attribute vec2 a_texCoord;
varying vec2 v_texCoord; void main() {
gl_Position = a_position;
v_texCoord = a_texCoord;
});
const std::string vs =
R"(attribute vec4 a_position;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main()
{
gl_Position = a_position;
v_texCoord = a_texCoord;
})";
const std::string fs =
SHADER_SOURCE(precision mediump float; varying vec2 v_texCoord; uniform sampler2D s_texture;
void main() { gl_FragColor = texture2D(s_texture, v_texCoord); });
R"(precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
gl_FragColor = texture2D(s_texture, v_texCoord);
})";
mProgram = CompileProgram(vs, fs);
ASSERT_NE(0u, mProgram);

Просмотреть файл

@ -18,49 +18,37 @@ namespace
const char *SimpleScaleAndOffsetVertexShaderSource()
{
// clang-format off
return SHADER_SOURCE
(
attribute vec2 vPosition;
return
R"(attribute vec2 vPosition;
uniform float uScale;
uniform float uOffset;
void main()
{
gl_Position = vec4(vPosition * vec2(uScale) + vec2(uOffset), 0, 1);
}
);
// clang-format on
})";
}
const char *SimpleDrawVertexShaderSource()
{
// clang-format off
return SHADER_SOURCE
(
attribute vec2 vPosition;
return
R"(attribute vec2 vPosition;
const float scale = 0.5;
const float offset = -0.5;
void main()
{
gl_Position = vec4(vPosition * vec2(scale) + vec2(offset), 0, 1);
}
);
// clang-format on
})";
}
const char *SimpleFragmentShaderSource()
{
// clang-format off
return SHADER_SOURCE
(
precision mediump float;
return
R"(precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
// clang-format on
})";
}
void Generate2DTriangleData(size_t numTris, std::vector<float> *floatData)

Просмотреть файл

@ -18,8 +18,6 @@
#include <string>
#include <vector>
#define SHADER_SOURCE(...) #__VA_ARGS__
ANGLE_EXPORT GLuint CompileShader(GLenum type, const std::string &source);
ANGLE_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);