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

Unified Diff: src/gpu/gl/builders/GrGLShaderStringBuilder.cpp

Issue 929503002: Multi-string shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows warning Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderStringBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
index 1e750489ff404da200246b32e22f6e25d3ec521c..59e0cd897825fdfef1b57889b850e3c157c86fc0 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
@@ -20,7 +20,9 @@ SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false,
GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
GrGLuint programId,
GrGLenum type,
- const SkString& shaderSrc,
+ const char** strings,
+ int* lengths,
+ int count,
GrGpu::Stats* stats) {
const GrGLInterface* gli = glCtx.interface();
@@ -31,14 +33,23 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
}
#ifdef SK_DEBUG
- SkString prettySource = GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, false);
+ SkString prettySource = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, false);
const GrGLchar* sourceStr = prettySource.c_str();
GrGLint sourceLength = static_cast<GrGLint>(prettySource.size());
+ GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength));
#else
- GrGLint sourceLength = static_cast<GrGLint>(shaderSrc.size());
- const GrGLchar* sourceStr = shaderSrc.c_str();
+ GR_GL_CALL(gli, ShaderSource(shaderId, count, strings, lengths));
#endif
- GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength));
+
+ // If tracing is enabled in chrome then we pretty print
+ bool traceShader;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), &traceShader);
+ if (traceShader) {
+ SkString shader = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, false);
+ TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLShader",
+ TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shader.c_str()));
+ }
+
stats->incShaderCompilations();
GR_GL_CALL(gli, CompileShader(shaderId));
@@ -59,9 +70,8 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
// retrieve length even though we don't need it to workaround bug in Chromium cmd
// buffer param validation.
GrGLsizei length = GR_GL_INIT_ZERO;
- GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1,
- &length, (char*)log.get()));
- SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_str());
+ GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (char*)log.get()));
+ SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, true).c_str());
SkDebugf("\n%s", log.get());
}
SkDEBUGFAIL("Shader compilation failed!");
@@ -70,10 +80,8 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
}
}
- TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLShader",
- TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shaderSrc.c_str()));
if (c_PrintShaders) {
- SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(shaderSrc, true).c_str());
+ SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, true).c_str());
SkDebugf("\n");
}
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderStringBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698