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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 437593004: Pretty print of shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: removing unused variable Created 6 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 | « src/gpu/gl/GrGLSLPrettyPrint.cpp ('k') | tests/GrGLSLPrettyPrintTest.cpp » ('j') | 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 2012 Google Inc. 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLSLPrettyPrint.h"
10 #include "gl/GrGLUniformHandle.h" 11 #include "gl/GrGLUniformHandle.h"
11 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
12 #include "GrDrawEffect.h" 13 #include "GrDrawEffect.h"
13 #include "GrGpuGL.h" 14 #include "GrGpuGL.h"
14 #include "GrTexture.h" 15 #include "GrTexture.h"
15 #include "SkRTConf.h" 16 #include "SkRTConf.h"
16 #include "SkTraceEvent.h" 17 #include "SkTraceEvent.h"
17 18
18 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) 19 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
19 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) 20 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 GrGLenum type, 665 GrGLenum type,
665 const SkString& shaderSrc) { 666 const SkString& shaderSrc) {
666 const GrGLInterface* gli = glCtx.interface(); 667 const GrGLInterface* gli = glCtx.interface();
667 668
668 GrGLuint shaderId; 669 GrGLuint shaderId;
669 GR_GL_CALL_RET(gli, shaderId, CreateShader(type)); 670 GR_GL_CALL_RET(gli, shaderId, CreateShader(type));
670 if (0 == shaderId) { 671 if (0 == shaderId) {
671 return 0; 672 return 0;
672 } 673 }
673 674
675 #ifdef SK_DEBUG
676 SkString prettySource = GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, false) ;
677 const GrGLchar* sourceStr = prettySource.c_str();
678 GrGLint sourceLength = static_cast<GrGLint>(prettySource.size());
679 #else
680 GrGLint sourceLength = static_cast<GrGLint>(shaderSrc.size());
674 const GrGLchar* sourceStr = shaderSrc.c_str(); 681 const GrGLchar* sourceStr = shaderSrc.c_str();
675 GrGLint sourceLength = static_cast<GrGLint>(shaderSrc.size()); 682 #endif
676 GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength)); 683 GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength));
677 GR_GL_CALL(gli, CompileShader(shaderId)); 684 GR_GL_CALL(gli, CompileShader(shaderId));
678 685
679 // Calling GetShaderiv in Chromium is quite expensive. Assume success in rel ease builds. 686 // Calling GetShaderiv in Chromium is quite expensive. Assume success in rel ease builds.
680 bool checkCompiled = !glCtx.isChromium(); 687 bool checkCompiled = !glCtx.isChromium();
681 #ifdef SK_DEBUG 688 #ifdef SK_DEBUG
682 checkCompiled = true; 689 checkCompiled = true;
683 #endif 690 #endif
684 if (checkCompiled) { 691 if (checkCompiled) {
685 GrGLint compiled = GR_GL_INIT_ZERO; 692 GrGLint compiled = GR_GL_INIT_ZERO;
686 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_COMPILE_STATUS, &compiled)); 693 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_COMPILE_STATUS, &compiled));
687 694
688 if (!compiled) { 695 if (!compiled) {
689 GrGLint infoLen = GR_GL_INIT_ZERO; 696 GrGLint infoLen = GR_GL_INIT_ZERO;
690 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe n)); 697 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe n));
691 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg er 698 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg er
692 if (infoLen > 0) { 699 if (infoLen > 0) {
693 // retrieve length even though we don't need it to workaround bu g in Chromium cmd 700 // retrieve length even though we don't need it to workaround bu g in Chromium cmd
694 // buffer param validation. 701 // buffer param validation.
695 GrGLsizei length = GR_GL_INIT_ZERO; 702 GrGLsizei length = GR_GL_INIT_ZERO;
696 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, 703 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1,
697 &length, (char*)log.get())); 704 &length, (char*)log.get()));
698 GrPrintf(shaderSrc.c_str()); 705 GrPrintf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_s tr());
699 GrPrintf("\n%s", log.get()); 706 GrPrintf("\n%s", log.get());
700 } 707 }
701 SkDEBUGFAIL("Shader compilation failed!"); 708 SkDEBUGFAIL("Shader compilation failed!");
702 GR_GL_CALL(gli, DeleteShader(shaderId)); 709 GR_GL_CALL(gli, DeleteShader(shaderId));
703 return 0; 710 return 0;
704 } 711 }
705 } 712 }
706 713
707 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLSha der", 714 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLSha der",
708 TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shad erSrc.c_str())); 715 TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shad erSrc.c_str()));
709 if (c_PrintShaders) { 716 if (c_PrintShaders) {
710 GrPrintf(shaderSrc.c_str()); 717 GrPrintf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_str());
711 GrPrintf("\n"); 718 GrPrintf("\n");
712 } 719 }
713 720
714 // Attach the shader, but defer deletion until after we have linked the prog ram. 721 // Attach the shader, but defer deletion until after we have linked the prog ram.
715 // This works around a bug in the Android emulator's GLES2 wrapper which 722 // This works around a bug in the Android emulator's GLES2 wrapper which
716 // will immediately delete the shader object and free its memory even though it's 723 // will immediately delete the shader object and free its memory even though it's
717 // attached to a program, which then causes glLinkProgram to fail. 724 // attached to a program, which then causes glLinkProgram to fail.
718 GR_GL_CALL(gli, AttachShader(programId, shaderId)); 725 GR_GL_CALL(gli, AttachShader(programId, shaderId));
719 726
720 return shaderId; 727 return shaderId;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1062
1056 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, 1063 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this,
1057 effectCnt); 1064 effectCnt);
1058 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, 1065 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder,
1059 effectStages, 1066 effectStages,
1060 effectCnt, 1067 effectCnt,
1061 keyProvider, 1068 keyProvider,
1062 inOutFSColor); 1069 inOutFSColor);
1063 return pathTexGenEffectsBuilder.finish(); 1070 return pathTexGenEffectsBuilder.finish();
1064 } 1071 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLSLPrettyPrint.cpp ('k') | tests/GrGLSLPrettyPrintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698