Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1165)

Side by Side Diff: src/gpu/gl/builders/GrGLShaderStringBuilder.cpp

Issue 2248853002: Print error from driver when shader compiler fails (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698