From e334c596546c7ec79f2b0e55b3a1c2839a94f352 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 15 May 2017 11:00:58 -0400 Subject: [PATCH] Attempt to work around iOS varying limit in GLPrograms test Dump shaders when linking fails. Bug: skia:6627 Change-Id: I7f1df4be039eb56d990aa64c58c8dd2a22d97dbe Reviewed-on: https://skia-review.googlesource.com/16867 Reviewed-by: Robert Phillips Commit-Queue: Brian Salomon --- gn/gpu.gni | 8 +- gn/tests.gni | 2 +- include/gpu/gl/GrGLSLPrettyPrint.h | 19 --- ...GrGLSLPrettyPrint.cpp => GrSKSLPrettyPrint.cpp} | 22 ++-- src/gpu/GrSKSLPrettyPrint.h | 16 +++ src/gpu/gl/builders/GrGLProgramBuilder.cpp | 22 +++- src/gpu/gl/builders/GrGLShaderStringBuilder.cpp | 135 +++++++++++++-------- src/gpu/gl/builders/GrGLShaderStringBuilder.h | 5 +- tests/GLProgramsTest.cpp | 62 +++------- ...ettyPrintTest.cpp => GrSKSLPrettyPrintTest.cpp} | 15 ++- 10 files changed, 164 insertions(+), 142 deletions(-) delete mode 100644 include/gpu/gl/GrGLSLPrettyPrint.h rename src/gpu/{gl/builders/GrGLSLPrettyPrint.cpp => GrSKSLPrettyPrint.cpp} (93%) create mode 100644 src/gpu/GrSKSLPrettyPrint.h rename tests/{GrGLSLPrettyPrintTest.cpp => GrSKSLPrettyPrintTest.cpp} (90%) diff --git a/gn/gpu.gni b/gn/gpu.gni index 006267f..83e904b 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -31,7 +31,6 @@ skia_gpu_sources = [ "$_include/gpu/gl/GrGLExtensions.h", "$_include/gpu/gl/GrGLFunctions.h", "$_include/gpu/gl/GrGLInterface.h", - "$_include/gpu/gl/GrGLSLPrettyPrint.h", "$_include/gpu/gl/GrGLTypes.h", # Private includes @@ -189,8 +188,8 @@ skia_gpu_sources = [ "$_src/gpu/GrTestUtils.h", "$_src/gpu/GrShaderVar.cpp", "$_src/gpu/GrShaderVar.h", - "$_src/gpu/GrSWMaskHelper.cpp", - "$_src/gpu/GrSWMaskHelper.h", + "$_src/gpu/GrSKSLPrettyPrint.cpp", + "$_src/gpu/GrSKSLPrettyPrint.h", "$_src/gpu/GrSoftwarePathRenderer.cpp", "$_src/gpu/GrSoftwarePathRenderer.h", "$_src/gpu/GrSurfacePriv.h", @@ -198,6 +197,8 @@ skia_gpu_sources = [ "$_src/gpu/GrSurfaceContext.cpp", "$_src/gpu/GrSurfaceContext.h", "$_src/gpu/GrSurfaceProxy.cpp", + "$_src/gpu/GrSWMaskHelper.cpp", + "$_src/gpu/GrSWMaskHelper.h", "$_src/gpu/GrTexture.cpp", "$_src/gpu/GrTextureAdjuster.cpp", "$_src/gpu/GrTextureAdjuster.h", @@ -424,7 +425,6 @@ skia_gpu_sources = [ "$_src/gpu/gl/builders/GrGLProgramBuilder.h", "$_src/gpu/gl/builders/GrGLShaderStringBuilder.cpp", "$_src/gpu/gl/builders/GrGLShaderStringBuilder.h", - "$_src/gpu/gl/builders/GrGLSLPrettyPrint.cpp", # GLSL "$_src/gpu/glsl/GrGLSL.cpp", diff --git a/gn/tests.gni b/gn/tests.gni index f63fb75..e6ac245 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -91,10 +91,10 @@ tests_sources = [ "$_tests/GrContextAbandonTest.cpp", "$_tests/GrContextFactoryTest.cpp", "$_tests/GrDrawTargetTest.cpp", - "$_tests/GrGLSLPrettyPrintTest.cpp", "$_tests/GrMemoryPoolTest.cpp", "$_tests/GrPorterDuffTest.cpp", "$_tests/GrShapeTest.cpp", + "$_tests/GrSKSLPrettyPrintTest.cpp", "$_tests/GrSurfaceTest.cpp", "$_tests/GrTextureMipMapInvalidationTest.cpp", "$_tests/GrTRecorderTest.cpp", diff --git a/include/gpu/gl/GrGLSLPrettyPrint.h b/include/gpu/gl/GrGLSLPrettyPrint.h deleted file mode 100644 index 52fb745..0000000 --- a/include/gpu/gl/GrGLSLPrettyPrint.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2014 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef GrGLSLPrettyPrint_DEFINED -#define GrGLSLPrettyPrint_DEFINED - -#include "SkString.h" - -namespace GrGLSLPrettyPrint { - SkString PrettyPrintGLSL(const char** strings, - int* lengths, - int count, - bool countlines); -}; - -#endif /* GRGLPRETTYPRINTSL_H_ */ diff --git a/src/gpu/gl/builders/GrGLSLPrettyPrint.cpp b/src/gpu/GrSKSLPrettyPrint.cpp similarity index 93% rename from src/gpu/gl/builders/GrGLSLPrettyPrint.cpp rename to src/gpu/GrSKSLPrettyPrint.cpp index 0280298..65175c9 100644 --- a/src/gpu/gl/builders/GrGLSLPrettyPrint.cpp +++ b/src/gpu/GrSKSLPrettyPrint.cpp @@ -4,18 +4,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "gl/GrGLSLPrettyPrint.h" +#include "GrSKSLPrettyPrint.h" -namespace GrGLSLPrettyPrint { +namespace GrSKSLPrettyPrint { class GLSLPrettyPrint { public: GLSLPrettyPrint() {} - SkString prettify(const char** strings, - int* lengths, - int count, - bool countlines) { + SkString prettify(const char** strings, int* lengths, int count, bool countlines) { fCountlines = countlines; fTabs = 0; fLinecount = 1; @@ -60,7 +57,8 @@ public: * existing shader code and we also have a special case for handling whitespace * at the beginning of fresh lines. * - * Otherwise just add the new character to the pretty string, indenting if necessary. + * Otherwise just add the new character to the pretty string, indenting if + * necessary. */ if (fInParseUntilNewline) { this->parseUntilNewline(); @@ -87,7 +85,7 @@ public: } else if (!parensDepth && this->hasToken(";")) { this->newline(); } else if ('\t' == fInput[fIndex] || '\n' == fInput[fIndex] || - (fFreshline && ' ' == fInput[fIndex])) { + (fFreshline && ' ' == fInput[fIndex])) { fIndex++; } else { this->appendChar(fInput[fIndex]); @@ -96,6 +94,7 @@ public: } return fPretty; } + private: void appendChar(char c) { this->tabString(); @@ -193,12 +192,9 @@ private: const char* fInParseUntilToken; }; -SkString PrettyPrintGLSL(const char** strings, - int* lengths, - int count, - bool countlines) { +SkString PrettyPrint(const char** strings, int* lengths, int count, bool countlines) { GLSLPrettyPrint pp; return pp.prettify(strings, lengths, count, countlines); } -} // end namespace +} // namespace GrSKSLPrettyPrint diff --git a/src/gpu/GrSKSLPrettyPrint.h b/src/gpu/GrSKSLPrettyPrint.h new file mode 100644 index 0000000..8fa4c1e --- /dev/null +++ b/src/gpu/GrSKSLPrettyPrint.h @@ -0,0 +1,16 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef GrSKSLPrettyPrint_DEFINED +#define GrSKSLPrettyPrint_DEFINED + +#include "SkString.h" + +namespace GrSKSLPrettyPrint { +SkString PrettyPrint(const char** strings, int* lengths, int count, bool countlines); +}; + +#endif diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 79cb2ca..f63e56b 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -19,7 +19,6 @@ #include "SkTraceEvent.h" #include "gl/GrGLGpu.h" #include "gl/GrGLProgram.h" -#include "gl/GrGLSLPrettyPrint.h" #include "gl/builders/GrGLShaderStringBuilder.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLGeometryProcessor.h" @@ -158,7 +157,24 @@ GrGLProgram* GrGLProgramBuilder::finalize() { checkLinked = true; #endif if (checkLinked) { - checkLinkStatus(programID); + if (!this->checkLinkStatus(programID)) { + SkDebugf("VS:\n"); + GrGLPrintShader(fGpu->glContext(), GR_GL_VERTEX_SHADER, fVS.fCompilerStrings.begin(), + fVS.fCompilerStringLengths.begin(), fVS.fCompilerStrings.count(), + settings); + if (primProc.willUseGeoShader()) { + SkDebugf("\nGS:\n"); + GrGLPrintShader(fGpu->glContext(), GR_GL_GEOMETRY_SHADER, + fGS.fCompilerStrings.begin(), fGS.fCompilerStringLengths.begin(), + fGS.fCompilerStrings.count(), settings); + } + SkDebugf("\nFS:\n"); + GrGLPrintShader(fGpu->glContext(), GR_GL_FRAGMENT_SHADER, fFS.fCompilerStrings.begin(), + fFS.fCompilerStringLengths.begin(), fFS.fCompilerStrings.count(), + settings); + SkDEBUGFAIL(""); + return nullptr; + } } this->resolveProgramResourceLocations(programID); @@ -197,6 +213,7 @@ bool GrGLProgramBuilder::checkLinkStatus(GrGLuint programID) { GrGLint linked = GR_GL_INIT_ZERO; GL_CALL(GetProgramiv(programID, GR_GL_LINK_STATUS, &linked)); if (!linked) { + SkDebugf("Program linking failed.\n"); GrGLint infoLen = GR_GL_INIT_ZERO; GL_CALL(GetProgramiv(programID, GR_GL_INFO_LOG_LENGTH, &infoLen)); SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger @@ -210,7 +227,6 @@ bool GrGLProgramBuilder::checkLinkStatus(GrGLuint programID) { (char*)log.get())); SkDebugf("%s", (char*)log.get()); } - SkDEBUGFAIL("Error linking program"); GL_CALL(DeleteProgram(programID)); programID = 0; } diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp index e3d2def..eb320d3 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp @@ -6,12 +6,12 @@ */ #include "GrGLShaderStringBuilder.h" +#include "GrSKSLPrettyPrint.h" #include "SkAutoMalloc.h" #include "SkSLCompiler.h" #include "SkSLGLSLCodeGenerator.h" #include "SkTraceEvent.h" #include "gl/GrGLGpu.h" -#include "gl/GrGLSLPrettyPrint.h" #include "ir/SkSLProgram.h" #define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X) @@ -20,68 +20,103 @@ // Print the source code for all shaders generated. static const bool c_PrintShaders{false}; -static void print_source_with_line_numbers(const SkString&); - -GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, - GrGLuint programId, - GrGLenum type, - const char** strings, - int* lengths, - int count, - GrGpu::Stats* stats, - const SkSL::Program::Settings& settings, - SkSL::Program::Inputs* outInputs) { - const GrGLInterface* gli = glCtx.interface(); +static SkString list_source_with_line_numbers(const char* source) { + SkTArray lines; + SkStrSplit(source, "\n", kStrict_SkStrSplitMode, &lines); + SkString result; + for (int line = 0; line < lines.count(); ++line) { + // Print the shader one line at the time so it doesn't get truncated by the adb log. + result.appendf("%4i\t%s\n", line + 1, lines[line].c_str()); + } + return result; +} - GrGLuint shaderId; - GR_GL_CALL_RET(gli, shaderId, CreateShader(type)); - if (0 == shaderId) { - return 0; +SkString list_shaders(const char** skslStrings, int* lengths, int count, const SkSL::String& glsl) { + SkString sksl = GrSKSLPrettyPrint::PrettyPrint(skslStrings, lengths, count, false); + SkString result("SKSL:\n"); + result.append(list_source_with_line_numbers(sksl.c_str())); + if (!glsl.isEmpty()) { + result.append("GLSL:\n"); + result.append(list_source_with_line_numbers(glsl.c_str())); } + return result; +} +std::unique_ptr translate_to_glsl(const GrGLContext& context, GrGLenum type, + const char** skslStrings, int* lengths, int count, + const SkSL::Program::Settings& settings, + SkSL::String* glsl) { SkString sksl; #ifdef SK_DEBUG - sksl = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, false); + sksl = GrSKSLPrettyPrint::PrettyPrint(skslStrings, lengths, count, false); #else for (int i = 0; i < count; i++) { - sksl.append(strings[i], lengths[i]); + sksl.append(skslStrings[i], lengths[i]); } #endif - - SkSL::String glsl; if (type == GR_GL_VERTEX_SHADER || type == GR_GL_FRAGMENT_SHADER) { - SkSL::Compiler& compiler = *glCtx.compiler(); + SkSL::Compiler* compiler = context.compiler(); std::unique_ptr program; - program = compiler.convertProgram( - type == GR_GL_VERTEX_SHADER ? SkSL::Program::kVertex_Kind - : SkSL::Program::kFragment_Kind, - sksl, - settings); - if (!program || !compiler.toGLSL(*program, &glsl)) { + program = compiler->convertProgram(type == GR_GL_VERTEX_SHADER + ? SkSL::Program::kVertex_Kind + : SkSL::Program::kFragment_Kind, + sksl, + settings); + if (!program || !compiler->toGLSL(*program, glsl)) { SkDebugf("SKSL compilation error\n----------------------\n"); - SkDebugf("SKSL:\n"); - print_source_with_line_numbers(sksl); - SkDebugf("\nErrors:\n%s\n", compiler.errorText().c_str()); + SkDebugf(list_shaders(skslStrings, lengths, count, *glsl).c_str()); + SkDebugf("\nErrors:\n%s\n", compiler->errorText().c_str()); SkDEBUGFAIL("SKSL compilation failed!\n"); + return nullptr; } - *outInputs = program->fInputs; + return program; } else { // TODO: geometry shader support in sksl. SkASSERT(type == GR_GL_GEOMETRY_SHADER); - glsl = sksl; + return nullptr; } +} +GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, + GrGLuint programId, + GrGLenum type, + const char** skslStrings, + int* lengths, + int count, + GrGpu::Stats* stats, + const SkSL::Program::Settings& settings, + SkSL::Program::Inputs* outInputs) { + const GrGLInterface* gli = glCtx.interface(); + + SkSL::String glsl; + auto program = translate_to_glsl(glCtx, type, skslStrings, lengths, count, settings, &glsl); + if (!program) { + return 0; + } + + // Specify GLSL source to the driver. + GrGLuint shaderId; + GR_GL_CALL_RET(gli, shaderId, CreateShader(type)); + if (0 == shaderId) { + return 0; + } const char* glslChars = glsl.c_str(); GrGLint glslLength = (GrGLint) glsl.size(); GR_GL_CALL(gli, ShaderSource(shaderId, 1, &glslChars, &glslLength)); - // If tracing is enabled in chrome then we pretty print + // Lazy initialized pretty-printed shaders for dumping. + SkString shaderDebugString; + + // Trace event for shader preceding driver compilation bool traceShader; TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), &traceShader); if (traceShader) { - SkString shader = GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, false); + if (shaderDebugString.isEmpty()) { + shaderDebugString = list_shaders(skslStrings, lengths, count, glsl); + } TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLShader", - TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shader.c_str())); + TRACE_EVENT_SCOPE_THREAD, "shader", + TRACE_STR_COPY(shaderDebugString.c_str())); } stats->incShaderCompilations(); @@ -97,6 +132,11 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_COMPILE_STATUS, &compiled)); if (!compiled) { + if (shaderDebugString.isEmpty()) { + shaderDebugString = list_shaders(skslStrings, lengths, count, glsl); + } + SkDebugf("GLSL compilation error\n----------------------\n"); + SkDebugf(shaderDebugString.c_str()); GrGLint infoLen = GR_GL_INIT_ZERO; GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLen)); SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger @@ -105,11 +145,6 @@ 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"); - print_source_with_line_numbers(sksl); - SkDebugf("GLSL:\n"); - print_source_with_line_numbers(glsl); SkDebugf("Errors:\n%s\n", (const char*) log.get()); } SkDEBUGFAIL("GLSL compilation failed!"); @@ -126,7 +161,10 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, case GR_GL_FRAGMENT_SHADER: typeName = "Fragment"; break; } SkDebugf("---- %s shader ----------------------------------------------------\n", typeName); - print_source_with_line_numbers(sksl); + if (shaderDebugString.isEmpty()) { + shaderDebugString = list_shaders(skslStrings, lengths, count, glsl); + } + SkDebugf(shaderDebugString.c_str()); } // Attach the shader, but defer deletion until after we have linked the program. @@ -134,15 +172,14 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, // will immediately delete the shader object and free its memory even though it's // attached to a program, which then causes glLinkProgram to fail. GR_GL_CALL(gli, AttachShader(programId, shaderId)); - + *outInputs = program->fInputs; return shaderId; } -static void print_source_with_line_numbers(const SkString& source) { - SkTArray lines; - SkStrSplit(source.c_str(), "\n", kStrict_SkStrSplitMode, &lines); - for (int line = 0; line < lines.count(); ++line) { - // Print the shader one line at the time so it doesn't get truncated by the adb log. - SkDebugf("%4i\t%s\n", line + 1, lines[line].c_str()); +void GrGLPrintShader(const GrGLContext& context, GrGLenum type, const char** skslStrings, + int* lengths, int count, const SkSL::Program::Settings& settings) { + SkSL::String glsl; + if (translate_to_glsl(context, type, skslStrings, lengths, count, settings, &glsl)) { + SkDebugf(list_shaders(skslStrings, lengths, count, glsl).c_str()); } } diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.h b/src/gpu/gl/builders/GrGLShaderStringBuilder.h index 242fe61..59dea35 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.h +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.h @@ -17,11 +17,14 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx, GrGLuint programId, GrGLenum type, - const char** strings, + const char** skslStrings, int* lengths, int count, GrGpu::Stats*, const SkSL::Program::Settings& settings, SkSL::Program::Inputs* inputs); +void GrGLPrintShader(const GrGLContext&, GrGLenum type, const char** skslStrings, int* lengths, + int count, const SkSL::Program::Settings&); + #endif diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 86b7469..db65c9b 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -341,56 +341,32 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { static int get_glprograms_max_stages(GrContext* context) { GrGLGpu* gpu = static_cast(context->getGpu()); - /* - * For the time being, we only support the test with desktop GL or for android on - * ARM platforms - * TODO When we run ES 3.00 GLSL in more places, test again - */ - if (kGL_GrGLStandard == gpu->glStandard() || - kARM_GrGLVendor == gpu->ctxInfo().vendor()) { - return 6; - } else if (kTegra3_GrGLRenderer == gpu->ctxInfo().renderer() || - kOther_GrGLRenderer == gpu->ctxInfo().renderer()) { - return 1; - } - return 0; -} - -static void test_glprograms_native(skiatest::Reporter* reporter, - const sk_gpu_test::ContextInfo& ctxInfo) { - int maxStages = get_glprograms_max_stages(ctxInfo.grContext()); - if (maxStages == 0) { - return; + int maxStages = 6; + if (kGLES_GrGLStandard == gpu->glStandard()) { + // We've had issues with driver crashes and HW limits being exceeded with many effects on + // Android devices. We have passes on ARM devices with the default number of stages. + // TODO When we run ES 3.00 GLSL in more places, test again +#ifdef SK_BUILD_FOR_ANDROID + if (kARM_GrGLVendor != gpu->ctxInfo().vendor()) { + maxStages = 1; + } +#endif + // On iOS we can exceed the maximum number of varyings. http://skbug.com/6627. +#ifdef SK_BUILDF_FOR_IOS + maxStages = 3; +#endif } - REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest(ctxInfo.grContext(), maxStages)); + return maxStages; } -static void test_glprograms_other_contexts( - skiatest::Reporter* reporter, - const sk_gpu_test::ContextInfo& ctxInfo) { +static void test_glprograms(skiatest::Reporter* reporter, const sk_gpu_test::ContextInfo& ctxInfo) { int maxStages = get_glprograms_max_stages(ctxInfo.grContext()); -#ifdef SK_BUILD_FOR_WIN - // Some long shaders run out of temporary registers in the D3D compiler on ANGLE and - // command buffer. - maxStages = SkTMin(maxStages, 2); -#endif if (maxStages == 0) { return; } REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest(ctxInfo.grContext(), maxStages)); } -static bool is_native_gl_context_type(sk_gpu_test::GrContextFactory::ContextType type) { - return type == sk_gpu_test::GrContextFactory::kGL_ContextType || - type == sk_gpu_test::GrContextFactory::kGLES_ContextType; -} - -static bool is_other_rendering_gl_context_type(sk_gpu_test::GrContextFactory::ContextType type) { - return !is_native_gl_context_type(type) && - kOpenGL_GrBackend == sk_gpu_test::GrContextFactory::ContextTypeBackend(type) && - sk_gpu_test::GrContextFactory::IsRenderingContext(type); -} - DEF_GPUTEST(GLPrograms, reporter, /*factory*/) { // Set a locale that would cause shader compilation to fail because of , as decimal separator. // skbug 3330 @@ -404,10 +380,8 @@ DEF_GPUTEST(GLPrograms, reporter, /*factory*/) { GrContextOptions opts; opts.fSuppressPrints = true; sk_gpu_test::GrContextFactory debugFactory(opts); - skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_context_type, - reporter, &debugFactory); - skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, - &is_other_rendering_gl_context_type, reporter, &debugFactory); + skiatest::RunWithGPUTestContexts(test_glprograms, &skiatest::IsRenderingGLContextType, reporter, + &debugFactory); } #endif diff --git a/tests/GrGLSLPrettyPrintTest.cpp b/tests/GrSKSLPrettyPrintTest.cpp similarity index 90% rename from tests/GrGLSLPrettyPrintTest.cpp rename to tests/GrSKSLPrettyPrintTest.cpp index 1a5152f..ec5dddb 100644 --- a/tests/GrGLSLPrettyPrintTest.cpp +++ b/tests/GrSKSLPrettyPrintTest.cpp @@ -5,11 +5,10 @@ * found in the LICENSE file. */ -#include "SkTypes.h" +#include "Test.h" #if SK_SUPPORT_GPU -#include "Test.h" -#include "gl/GrGLSLPrettyPrint.h" +#include "GrSKSLPrettyPrint.h" #define ASSERT(x) REPORTER_ASSERT(r, x) @@ -88,7 +87,7 @@ const SkString neg2("###\n##\n#####(((((((((((((unbalanced verything;;;"); const SkString neg3("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}" ";;;;;;/////"); -DEF_TEST(GrGLSLPrettyPrint, r) { +DEF_TEST(GrSKSLPrettyPrint, r) { SkTArray testStr; SkTArray lengths; testStr.push_back(input1.c_str()); @@ -104,8 +103,8 @@ DEF_TEST(GrGLSLPrettyPrint, r) { testStr.push_back(input6.c_str()); lengths.push_back((int)input6.size()); - SkString test = GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths.begin(), - testStr.count(), true); + SkString test = GrSKSLPrettyPrint::PrettyPrint(testStr.begin(), lengths.begin(), + testStr.count(), true); ASSERT(output1 == test); testStr.reset(); @@ -118,8 +117,8 @@ DEF_TEST(GrGLSLPrettyPrint, r) { lengths.push_back((int)neg3.size()); // Just test we don't crash with garbage input - ASSERT(GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths.begin(), 1, - true).c_str() != nullptr); + ASSERT(GrSKSLPrettyPrint::PrettyPrint(testStr.begin(), lengths.begin(), 1, + true).c_str() != nullptr); } #endif -- 2.7.4