Restore ability to dump SKSL in addition to GLSL

Change-Id: Ib5d980414803234c0aff39b2cf085bb84405574a
Reviewed-on: https://skia-review.googlesource.com/79902
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-12-04 16:45:30 -05:00 committed by Skia Commit-Bot
parent 64ca6be98c
commit 06ab3836f7

View File

@ -18,7 +18,8 @@
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(gpu->glInterface(), R, X)
// Print the source code for all shaders generated.
static const bool c_PrintShaders{false};
static const bool gPrintSKSL = false;
static const bool gPrintGLSL = false;
static void print_source_lines_with_numbers(const char* source,
std::function<void(const char*)> println) {
@ -49,6 +50,16 @@ static void print_glsl_line_by_line(const SkSL::String& glsl,
print_source_lines_with_numbers(glsl.c_str(), println);
}
void print_shader_banner(GrGLenum type) {
const char* typeName = "Unknown";
switch (type) {
case GR_GL_VERTEX_SHADER: typeName = "Vertex"; break;
case GR_GL_GEOMETRY_SHADER: typeName = "Geometry"; break;
case GR_GL_FRAGMENT_SHADER: typeName = "Fragment"; break;
}
SkDebugf("---- %s shader ----------------------------------------------------\n", typeName);
}
std::unique_ptr<SkSL::Program> GrSkSLtoGLSL(const GrGLContext& context, GrGLenum type,
const char** skslStrings, int* lengths, int count,
const SkSL::Program::Settings& settings,
@ -91,6 +102,10 @@ std::unique_ptr<SkSL::Program> GrSkSLtoGLSL(const GrGLContext& context, GrGLenum
SkDEBUGFAIL("SKSL compilation failed!\n");
return nullptr;
}
if (gPrintSKSL) {
print_shader_banner(type);
print_sksl_line_by_line(skslStrings, lengths, count);
}
return program;
}
@ -142,14 +157,8 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
}
}
if (c_PrintShaders) {
const char* typeName = "Unknown";
switch (type) {
case GR_GL_VERTEX_SHADER: typeName = "Vertex"; break;
case GR_GL_GEOMETRY_SHADER: typeName = "Geometry"; break;
case GR_GL_FRAGMENT_SHADER: typeName = "Fragment"; break;
}
SkDebugf("---- %s shader ----------------------------------------------------\n", typeName);
if (gPrintGLSL) {
print_shader_banner(type);
print_glsl_line_by_line(glsl);
}