| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGLShaderStringBuilder.h" | 8 #include "GrGLShaderStringBuilder.h" |
| 9 #include "gl/GrGLGpu.h" | 9 #include "gl/GrGLGpu.h" |
| 10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if (!compiled) { | 66 if (!compiled) { |
| 67 GrGLint infoLen = GR_GL_INIT_ZERO; | 67 GrGLint infoLen = GR_GL_INIT_ZERO; |
| 68 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); | 68 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); |
| 69 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er | 69 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er |
| 70 if (infoLen > 0) { | 70 if (infoLen > 0) { |
| 71 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd | 71 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd |
| 72 // buffer param validation. | 72 // buffer param validation. |
| 73 GrGLsizei length = GR_GL_INIT_ZERO; | 73 GrGLsizei length = GR_GL_INIT_ZERO; |
| 74 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (
char*)log.get())); | 74 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (
char*)log.get())); |
| 75 print_shader_source(strings, lengths, count); | 75 print_shader_source(strings, lengths, count); |
| 76 SkDebugf("\n%s", (const char*)log.get()); |
| 76 } | 77 } |
| 77 SkDEBUGFAIL("Shader compilation failed!"); | 78 SkDEBUGFAIL("Shader compilation failed!"); |
| 78 GR_GL_CALL(gli, DeleteShader(shaderId)); | 79 GR_GL_CALL(gli, DeleteShader(shaderId)); |
| 79 return 0; | 80 return 0; |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 if (c_PrintShaders) { | 84 if (c_PrintShaders) { |
| 84 print_shader_source(strings, lengths, count); | 85 print_shader_source(strings, lengths, count); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Attach the shader, but defer deletion until after we have linked the prog
ram. | 88 // Attach the shader, but defer deletion until after we have linked the prog
ram. |
| 88 // This works around a bug in the Android emulator's GLES2 wrapper which | 89 // This works around a bug in the Android emulator's GLES2 wrapper which |
| 89 // will immediately delete the shader object and free its memory even though
it's | 90 // will immediately delete the shader object and free its memory even though
it's |
| 90 // attached to a program, which then causes glLinkProgram to fail. | 91 // attached to a program, which then causes glLinkProgram to fail. |
| 91 GR_GL_CALL(gli, AttachShader(programId, shaderId)); | 92 GR_GL_CALL(gli, AttachShader(programId, shaderId)); |
| 92 | 93 |
| 93 return shaderId; | 94 return shaderId; |
| 94 } | 95 } |
| 95 | 96 |
| 96 static void print_shader_source(const char** strings, int* lengths, int count) { | 97 static void print_shader_source(const char** strings, int* lengths, int count) { |
| 97 const SkString& pretty = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths
, count, true); | 98 const SkString& pretty = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths
, count, true); |
| 98 SkTArray<SkString> lines; | 99 SkTArray<SkString> lines; |
| 99 SkStrSplit(pretty.c_str(), "\n", &lines); | 100 SkStrSplit(pretty.c_str(), "\n", &lines); |
| 100 for (const SkString& line : lines) { | 101 for (const SkString& line : lines) { |
| 101 // Print the shader one line at the time so it doesn't get truncated by
the adb log. | 102 // Print the shader one line at the time so it doesn't get truncated by
the adb log. |
| 102 SkDebugf("%s\n", line.c_str()); | 103 SkDebugf("%s\n", line.c_str()); |
| 103 } | 104 } |
| 104 } | 105 } |
| OLD | NEW |