| 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 "../GrGpuGL.h" | 9 #include "../GrGpuGL.h" |
| 10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (!compiled) { | 54 if (!compiled) { |
| 55 GrGLint infoLen = GR_GL_INIT_ZERO; | 55 GrGLint infoLen = GR_GL_INIT_ZERO; |
| 56 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); | 56 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); |
| 57 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er | 57 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er |
| 58 if (infoLen > 0) { | 58 if (infoLen > 0) { |
| 59 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd | 59 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd |
| 60 // buffer param validation. | 60 // buffer param validation. |
| 61 GrGLsizei length = GR_GL_INIT_ZERO; | 61 GrGLsizei length = GR_GL_INIT_ZERO; |
| 62 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, | 62 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, |
| 63 &length, (char*)log.get())); | 63 &length, (char*)log.get())); |
| 64 GrPrintf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_s
tr()); | 64 SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_s
tr()); |
| 65 GrPrintf("\n%s", log.get()); | 65 SkDebugf("\n%s", log.get()); |
| 66 } | 66 } |
| 67 SkDEBUGFAIL("Shader compilation failed!"); | 67 SkDEBUGFAIL("Shader compilation failed!"); |
| 68 GR_GL_CALL(gli, DeleteShader(shaderId)); | 68 GR_GL_CALL(gli, DeleteShader(shaderId)); |
| 69 return 0; | 69 return 0; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLSha
der", | 73 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLSha
der", |
| 74 TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shad
erSrc.c_str())); | 74 TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shad
erSrc.c_str())); |
| 75 if (c_PrintShaders) { | 75 if (c_PrintShaders) { |
| 76 GrPrintf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_str()); | 76 SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_str()); |
| 77 GrPrintf("\n"); | 77 SkDebugf("\n"); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Attach the shader, but defer deletion until after we have linked the prog
ram. | 80 // Attach the shader, but defer deletion until after we have linked the prog
ram. |
| 81 // This works around a bug in the Android emulator's GLES2 wrapper which | 81 // This works around a bug in the Android emulator's GLES2 wrapper which |
| 82 // will immediately delete the shader object and free its memory even though
it's | 82 // will immediately delete the shader object and free its memory even though
it's |
| 83 // attached to a program, which then causes glLinkProgram to fail. | 83 // attached to a program, which then causes glLinkProgram to fail. |
| 84 GR_GL_CALL(gli, AttachShader(programId, shaderId)); | 84 GR_GL_CALL(gli, AttachShader(programId, shaderId)); |
| 85 | 85 |
| 86 return shaderId; | 86 return shaderId; |
| 87 } | 87 } |
| OLD | NEW |