From 15341a284e78651d2b47b89753044f8d6e7eda0a Mon Sep 17 00:00:00 2001 From: jvanverth Date: Mon, 10 Oct 2016 09:18:23 -0700 Subject: Revert of Turned on SkSL->GLSL compiler (patchset #47 id:1200001 of https://codereview.chromium.org/2288033003/ ) Reason for revert: Looks like it introduces new static initializers, and it's failing the Chrome roll. Original issue's description: > Turned on SkSL->GLSL compiler > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2288033003 > > Committed: https://skia.googlesource.com/skia/+/9b0fe3d125f237d9884732a48414fa85fc71b4e3 > Committed: https://skia.googlesource.com/skia/+/b12b3c6908c62c908b3680be01e3b5bfd30de310 > Committed: https://skia.googlesource.com/skia/+/f008b0a59f45c0d4bea3e66faf3b01805009ec89 > Committed: https://skia.googlesource.com/skia/+/08b2ccf398e2b81bc05d2c105837e5419899469b TBR=benjaminwagner@google.com,bsalomon@google.com,egdaniel@google.com,ethannicholas@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2403083002 --- src/gpu/gl/builders/GrGLShaderStringBuilder.cpp | 130 ++---------------------- src/gpu/gl/builders/GrGLShaderStringBuilder.h | 3 - 2 files changed, 7 insertions(+), 126 deletions(-) (limited to 'src/gpu/gl/builders') diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp index b26ce894f0..d2e49a5cfb 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp @@ -9,9 +9,6 @@ #include "gl/GrGLGpu.h" #include "gl/GrGLSLPrettyPrint.h" #include "SkTraceEvent.h" -#include "SkSLCompiler.h" -#include "SkSLGLSLCodeGenerator.h" -#include "ir/SkSLProgram.h" #define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X) #define GL_CALL_RET(R, X) GR_GL_CALL_RET(gpu->glInterface(), R, X) @@ -21,90 +18,6 @@ static const bool c_PrintShaders{false}; static void print_shader_source(const char** strings, int* lengths, int count); -SkSL::GLCaps GrGLSkSLCapsForContext(const GrGLContext& context) { - GrGLStandard standard = context.standard(); - const GrGLCaps* caps = context.caps(); - const GrGLSLCaps* glslCaps = caps->glslCaps(); - SkSL::GLCaps result; - switch (standard) { - case kGL_GrGLStandard: - result.fStandard = SkSL::GLCaps::kGL_Standard; - break; - case kGLES_GrGLStandard: - result.fStandard = SkSL::GLCaps::kGLES_Standard; - break; - default: - SkASSERT(false); - result.fStandard = SkSL::GLCaps::kGL_Standard; - } - - switch (glslCaps->generation()) { - case k110_GrGLSLGeneration: - if (kGLES_GrGLStandard == standard) { - // ES2's shader language is based on GLSL 1.20 but is version 1.00 of the ES - // language - result.fVersion = 100; - } else { - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 110; - } - break; - case k130_GrGLSLGeneration: - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 130; - break; - case k140_GrGLSLGeneration: - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 140; - break; - case k150_GrGLSLGeneration: - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 150; - break; - case k330_GrGLSLGeneration: - if (kGLES_GrGLStandard == standard) { - result.fVersion = 300; - } else { - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 330; - } - break; - case k400_GrGLSLGeneration: - SkASSERT(kGL_GrGLStandard == standard); - result.fVersion = 400; - break; - case k310es_GrGLSLGeneration: - SkASSERT(kGLES_GrGLStandard == standard); - result.fVersion = 310; - break; - case k320es_GrGLSLGeneration: - SkASSERT(kGLES_GrGLStandard == standard); - result.fVersion = 320; - break; - } - result.fIsCoreProfile = caps->isCoreProfile(); - result.fUsesPrecisionModifiers = glslCaps->usesPrecisionModifiers(); - result.fMustDeclareFragmentShaderOutput = glslCaps->mustDeclareFragmentShaderOutput(); - result.fCanUseMinAndAbsTogether = glslCaps->canUseMinAndAbsTogether(); - return result; -} - -static void dump_string(std::string s) { - // on Android, SkDebugf only displays the first 1K characters of output, which results in - // incomplete shader source code. Print each line individually to avoid this problem. - size_t index = 0; - for (;;) { - size_t next = s.find("\n", index); - if (next == std::string::npos) { - SkDebugf("%s", s.substr(index).c_str()); - break; - } else { - SkDebugf("%s", s.substr(index, next - index + 1).c_str()); - index = next + 1; - } - } -} - GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, GrGLuint programId, GrGLenum type, @@ -120,40 +33,15 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, return 0; } - std::string sksl; #ifdef SK_DEBUG SkString prettySource = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, false); - sksl = std::string(prettySource.c_str()); + const GrGLchar* sourceStr = prettySource.c_str(); + GrGLint sourceLength = static_cast(prettySource.size()); + GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength)); #else - for (int i = 0; i < count; i++) { - sksl.append(strings[i], lengths[i]); - } -#endif - - std::string glsl; - SkSL::Compiler& compiler = *glCtx.compiler(); - SkSL::GLCaps caps = GrGLSkSLCapsForContext(glCtx); - SkASSERT(type == GR_GL_VERTEX_SHADER || type == GR_GL_FRAGMENT_SHADER); - SkDEBUGCODE(bool result = )compiler.toGLSL(type == GR_GL_VERTEX_SHADER - ? SkSL::Program::kVertex_Kind - : SkSL::Program::kFragment_Kind, - std::string(sksl.c_str()), - caps, - &glsl); -#ifdef SK_DEBUG - if (!result) { - SkDebugf("SKSL compilation error\n----------------------\n"); - SkDebugf("SKSL:\n"); - dump_string(sksl); - SkDebugf("\nErrors:\n%s\n", compiler.errorText().c_str()); - SkDEBUGFAIL("SKSL compilation failed!\n"); - } + GR_GL_CALL(gli, ShaderSource(shaderId, count, strings, lengths)); #endif - const char* glslChars = glsl.c_str(); - GrGLint glslLength = (GrGLint) glsl.length(); - GR_GL_CALL(gli, ShaderSource(shaderId, 1, &glslChars, &glslLength)); - // If tracing is enabled in chrome then we pretty print bool traceShader; TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), &traceShader); @@ -184,14 +72,10 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, // buffer param validation. GrGLsizei length = GR_GL_INIT_ZERO; GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (char*)log.get())); - SkDebugf("GLSL compilation error\n----------------------\n"); - SkDebugf("SKSL:\n"); - dump_string(sksl); - SkDebugf("GLSL:\n"); - dump_string(glsl); - SkDebugf("Errors:\n%s\n", (const char*) log.get()); + print_shader_source(strings, lengths, count); + SkDebugf("\n%s", (const char*)log.get()); } - SkDEBUGFAIL("GLSL compilation failed!"); + SkDEBUGFAIL("Shader compilation failed!"); GR_GL_CALL(gli, DeleteShader(shaderId)); return 0; } diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.h b/src/gpu/gl/builders/GrGLShaderStringBuilder.h index 4365751c3a..062e229cdf 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.h +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.h @@ -11,11 +11,8 @@ #include "GrAllocator.h" #include "GrGpu.h" #include "gl/GrGLContext.h" -#include "SkSLGLSLCodeGenerator.h" #include "SkTypes.h" -SkSL::GLCaps GrGLSkSLCapsForContext(const GrGLContext& context); - GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, GrGLuint programId, GrGLenum type, -- cgit v1.2.3