aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/builders
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-07-13 08:47:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-13 08:47:54 -0700
commitb3772dcb306241f53fe10ba62117ed67f89f24b2 (patch)
tree27c56f55b15a8f86343f7121f41670ebeeddad00 /src/gpu/gl/builders
parent1185d90c785f743364cc9113d7007a59af07470c (diff)
Fix GL shader sources getting truncated by ADB log
Prints the shaders one line at a time so they don't get truncated by the ADB log. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2142223003 Review-Url: https://codereview.chromium.org/2142223003
Diffstat (limited to 'src/gpu/gl/builders')
-rw-r--r--src/gpu/gl/builders/GrGLShaderStringBuilder.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
index 52915b6f89..b4ce2824e2 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
@@ -17,6 +17,8 @@
SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false,
"Print the source code for all shaders generated.");
+static void print_shader_source(const char** strings, int* lengths, int count);
+
GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
GrGLuint programId,
GrGLenum type,
@@ -71,8 +73,7 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
// buffer param validation.
GrGLsizei length = GR_GL_INIT_ZERO;
GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (char*)log.get()));
- SkDebugf("%s", GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, true).c_str());
- SkDebugf("\n%s", log.get());
+ print_shader_source(strings, lengths, count);
}
SkDEBUGFAIL("Shader compilation failed!");
GR_GL_CALL(gli, DeleteShader(shaderId));
@@ -81,8 +82,7 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
}
if (c_PrintShaders) {
- SkDebugf("%s", GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, true).c_str());
- SkDebugf("\n");
+ print_shader_source(strings, lengths, count);
}
// Attach the shader, but defer deletion until after we have linked the program.
@@ -93,3 +93,13 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
return shaderId;
}
+
+static void print_shader_source(const char** strings, int* lengths, int count) {
+ const SkString& pretty = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, true);
+ SkTArray<SkString> lines;
+ SkStrSplit(pretty.c_str(), "\n", &lines);
+ for (const SkString& line : lines) {
+ // Print the shader one line at the time so it doesn't get truncated by the adb log.
+ SkDebugf("%s\n", line.c_str());
+ }
+}