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>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index 5f689c9..1096709 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -49,9 +49,8 @@
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 @@
{
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 @@
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 @@
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 @@
{
gl_Position = vec4(position.xy * drawScale, 0.0, 1.0);
texcoord = (position.xy * 0.5) + 0.5;
- }
- )
- );
+ })";
}
void SetUp() override
@@ -539,9 +530,8 @@
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 @@
void main()
{
gl_FragColor = computeFragColor(tex);
- }
- )
- );
+ })";
}
void SetUp() override
@@ -579,9 +567,8 @@
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 @@
{
gl_FragColor = texture2D(tex2D, texcoord);
gl_FragColor += textureCube(texCube, vec3(texcoord, 0));
- }
- )
- );
+ })";
}
void SetUp() override
@@ -650,18 +635,15 @@
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 @@
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 @@
void main()
{
gl_FragColor = computeFragColor(tex2DArray);
- }
- )
- );
+ })";
}
};
@@ -3936,20 +3915,20 @@
}
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);