From 29b3434e48ca41672266ac40f5b9e8f8a0405cb5 Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Tue, 23 Jan 2018 16:39:42 -0500 Subject: [PATCH] Revert "converted vertex shaders to device coords" This reverts commit e7e81c15c144b8133f696d0744ed9f7e8d06e936. Reason for revert: Chrome perf regressions Bug: skia: Change-Id: I17fadc97c4b8e80bfdccbf123554614a00c58473 Reviewed-on: https://skia-review.googlesource.com/99040 Reviewed-by: Ethan Nicholas Commit-Queue: Ethan Nicholas --- src/gpu/gl/GrGLUniformHandler.cpp | 12 +--- src/gpu/glsl/GrGLSLProgramBuilder.cpp | 14 ++-- src/gpu/glsl/GrGLSLUniformHandler.h | 9 +-- src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp | 12 ++-- src/gpu/vk/GrVkUniformHandler.cpp | 2 +- src/sksl/README | 3 +- src/sksl/SkSLCompiler.cpp | 19 +++--- src/sksl/SkSLCompiler.h | 3 - src/sksl/SkSLIRGenerator.cpp | 89 ++----------------------- src/sksl/SkSLIRGenerator.h | 10 +-- tests/SkSLGLSLTest.cpp | 67 ------------------- 11 files changed, 31 insertions(+), 209 deletions(-) diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp index 39392f996b..b3b4b9f6b5 100644 --- a/src/gpu/gl/GrGLUniformHandler.cpp +++ b/src/gpu/gl/GrGLUniformHandler.cpp @@ -10,19 +10,10 @@ #include "gl/GrGLCaps.h" #include "gl/GrGLGpu.h" #include "gl/builders/GrGLProgramBuilder.h" -#include "SkSLCompiler.h" #define GL_CALL(X) GR_GL_CALL(this->glGpu()->glInterface(), X) #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->glGpu()->glInterface(), R, X) -bool valid_name(const char* name) { - // disallow unknown names that start with "sk_" - if (!strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) { - return !strcmp(name, SkSL::Compiler::RTADJUST_NAME); - } - return true; -} - GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray( uint32_t visibility, GrSLType type, @@ -32,7 +23,6 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray( int arrayCount, const char** outName) { SkASSERT(name && strlen(name)); - SkASSERT(valid_name(name)); SkASSERT(0 != visibility); SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type)); @@ -46,7 +36,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray( // uniform view matrix, they should upload the view matrix in their setData along with regular // uniforms. char prefix = 'u'; - if ('u' == name[0] || !strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) { + if ('u' == name[0]) { prefix = '\0'; } fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName); diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp index 04ebc6ad8e..118b904540 100644 --- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp +++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp @@ -15,7 +15,6 @@ #include "glsl/GrGLSLGeometryProcessor.h" #include "glsl/GrGLSLVarying.h" #include "glsl/GrGLSLXferProcessor.h" -#include "SkSLCompiler.h" const int GrGLSLProgramBuilder::kVarsPerBlock = 8; @@ -75,16 +74,13 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr this->nameExpression(outputCoverage, "outputCoverage"); SkASSERT(!fUniformHandles.fRTAdjustmentUni.isValid()); - GrShaderFlags rtAdjustVisibility; + GrShaderFlags rtAdjustVisibility = kVertex_GrShaderFlag; if (proc.willUseGeoShader()) { - rtAdjustVisibility = kGeometry_GrShaderFlag; - } else { - rtAdjustVisibility = kVertex_GrShaderFlag; + rtAdjustVisibility |= kGeometry_GrShaderFlag; } - fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform( - rtAdjustVisibility, - kFloat4_GrSLType, - SkSL::Compiler::RTADJUST_NAME); + fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform(rtAdjustVisibility, + kFloat4_GrSLType, + "rtAdjustment"); const char* rtAdjustName = this->uniformHandler()->getUniformCStr(fUniformHandles.fRTAdjustmentUni); diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h index 662486eebe..e1511c2578 100644 --- a/src/gpu/glsl/GrGLSLUniformHandler.h +++ b/src/gpu/glsl/GrGLSLUniformHandler.h @@ -12,9 +12,6 @@ #include "GrShaderVar.h" #include "GrSwizzle.h" -// variable names beginning with this prefix will not be mangled -#define GR_NO_MANGLE_PREFIX "sk_" - class GrGLSLProgramBuilder; class GrGLSLUniformHandler { @@ -54,8 +51,7 @@ public: int arrayCount, const char** outName = nullptr) { SkASSERT(!GrSLTypeIsCombinedSamplerType(type)); - bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX)); - return this->internalAddUniformArray(visibility, type, precision, name, mangle, arrayCount, + return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount, outName); } @@ -65,8 +61,7 @@ public: int arrayCount, const char** outName = nullptr) { SkASSERT(!GrSLTypeIsCombinedSamplerType(type)); - bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX)); - return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, mangle, + return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, true, arrayCount, outName); } diff --git a/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp b/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp index dba57bb8a5..1cf85f7249 100644 --- a/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp +++ b/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp @@ -23,14 +23,16 @@ void GrGLSLVertexGeoBuilder::emitNormalizedSkPosition(SkString* out, const char* out->appendf("{float2 _posTmp = %s;", devPos); } out->appendf("_posTmp = floor(_posTmp) + half2(0.5, 0.5);" - "sk_Position = float4(_posTmp, 0, 1);}"); + "sk_Position = float4(_posTmp.x * %s.x + %s.y," + "_posTmp.y * %s.z + %s.w, 0, 1);}", + rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName); } else if (kFloat3_GrSLType == devPosType) { - out->appendf("sk_Position = float4(%s.x , %s.y, 0, %s.z);", - devPos, devPos, devPos); + out->appendf("sk_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);", + devPos, rtAdjustName, devPos, rtAdjustName, devPos); } else { SkASSERT(kFloat2_GrSLType == devPosType); - out->appendf("sk_Position = float4(%s.x , %s.y, 0, 1);", - devPos, devPos); + out->appendf("sk_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", + devPos, rtAdjustName, rtAdjustName, devPos, rtAdjustName, rtAdjustName); } } diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp index e76cbda959..040926e314 100644 --- a/src/gpu/vk/GrVkUniformHandler.cpp +++ b/src/gpu/vk/GrVkUniformHandler.cpp @@ -203,7 +203,7 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray( // uniform view matrix, they should upload the view matrix in their setData along with regular // uniforms. char prefix = 'u'; - if ('u' == name[0] || !strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) { + if ('u' == name[0]) { prefix = '\0'; } fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName); diff --git a/src/sksl/README b/src/sksl/README index e9e46566a8..7c2cf04551 100644 --- a/src/sksl/README +++ b/src/sksl/README @@ -38,8 +38,7 @@ Differences from GLSL 'do_something_else();', depending on whether that cap is enabled or not. * no #version statement is required, and it will be ignored if present * the output color is sk_FragColor (do not declare it) -* use sk_Position instead of gl_Position. sk_Position is in device coordinates - rather than normalized coordinates. +* use sk_Position instead of gl_Position * use sk_PointSize instead of gl_PointSize * use sk_VertexID instead of gl_VertexID * use sk_InstanceID instead of gl_InstanceID diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index 7589da98ee..bf321c8e1e 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -200,8 +200,7 @@ Compiler::Compiler(Flags flags) fIRGenerator->fSymbolTable->add(skArgsName, std::unique_ptr(skArgs)); std::vector> ignored; - fIRGenerator->convertProgram(Program::kFragment_Kind, SKSL_INCLUDE, strlen(SKSL_INCLUDE), - *fTypes, &ignored); + fIRGenerator->convertProgram(SKSL_INCLUDE, strlen(SKSL_INCLUDE), *fTypes, &ignored); fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); if (fErrorCount) { printf("Unexpected errors: %s\n", fErrorText.c_str()); @@ -1165,19 +1164,19 @@ std::unique_ptr Compiler::convertProgram(Program::Kind kind, String tex std::vector> elements; switch (kind) { case Program::kVertex_Kind: - fIRGenerator->convertProgram(kind, SKSL_VERT_INCLUDE, strlen(SKSL_VERT_INCLUDE), - *fTypes, &elements); + fIRGenerator->convertProgram(SKSL_VERT_INCLUDE, strlen(SKSL_VERT_INCLUDE), *fTypes, + &elements); break; case Program::kFragment_Kind: - fIRGenerator->convertProgram(kind, SKSL_FRAG_INCLUDE, strlen(SKSL_FRAG_INCLUDE), - *fTypes, &elements); + fIRGenerator->convertProgram(SKSL_FRAG_INCLUDE, strlen(SKSL_FRAG_INCLUDE), *fTypes, + &elements); break; case Program::kGeometry_Kind: - fIRGenerator->convertProgram(kind, SKSL_GEOM_INCLUDE, strlen(SKSL_GEOM_INCLUDE), - *fTypes, &elements); + fIRGenerator->convertProgram(SKSL_GEOM_INCLUDE, strlen(SKSL_GEOM_INCLUDE), *fTypes, + &elements); break; case Program::kFragmentProcessor_Kind: - fIRGenerator->convertProgram(kind, SKSL_FP_INCLUDE, strlen(SKSL_FP_INCLUDE), *fTypes, + fIRGenerator->convertProgram(SKSL_FP_INCLUDE, strlen(SKSL_FP_INCLUDE), *fTypes, &elements); break; } @@ -1189,7 +1188,7 @@ std::unique_ptr Compiler::convertProgram(Program::Kind kind, String tex } std::unique_ptr textPtr(new String(std::move(text))); fSource = textPtr.get(); - fIRGenerator->convertProgram(kind, textPtr->c_str(), textPtr->size(), *fTypes, &elements); + fIRGenerator->convertProgram(textPtr->c_str(), textPtr->size(), *fTypes, &elements); if (!fErrorCount) { for (auto& element : elements) { if (element->fKind == ProgramElement::kFunction_Kind) { diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h index eb2fc45b51..ca39c8c659 100644 --- a/src/sksl/SkSLCompiler.h +++ b/src/sksl/SkSLCompiler.h @@ -45,9 +45,6 @@ class IRGenerator; */ class Compiler : public ErrorReporter { public: - static constexpr const char* RTADJUST_NAME = "sk_RTAdjust"; - static constexpr const char* PERVERTEX_NAME = "sk_PerVertex"; - enum Flags { kNone_Flags = 0, // permits static if/switch statements to be used with non-constant tests. This is used when diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index 3388a4758d..019aee8eaa 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -154,9 +154,6 @@ void IRGenerator::start(const Program::Settings* settings) { this->pushSymbolTable(); fInvocations = -1; fInputs.reset(); - fSkPerVertex = nullptr; - fRTAdjust = nullptr; - fRTAdjustInterfaceBlock = nullptr; } void IRGenerator::finish() { @@ -174,26 +171,8 @@ std::unique_ptr IRGenerator::convertStatement(const ASTStatement& sta return this->convertBlock((ASTBlock&) statement); case ASTStatement::kVarDeclaration_Kind: return this->convertVarDeclarationStatement((ASTVarDeclarationStatement&) statement); - case ASTStatement::kExpression_Kind: { - std::unique_ptr result = - this->convertExpressionStatement((ASTExpressionStatement&) statement); - if (fRTAdjust && Program::kGeometry_Kind == fKind) { - ASSERT(result->fKind == Statement::kExpression_Kind); - Expression& expr = *((ExpressionStatement&) *result).fExpression; - if (expr.fKind == Expression::kFunctionCall_Kind) { - FunctionCall& fc = (FunctionCall&) expr; - if (fc.fFunction.fBuiltin && fc.fFunction.fName == "EmitVertex") { - std::vector> statements; - statements.push_back(getNormalizeSkPositionCode()); - statements.push_back(std::move(result)); - return std::unique_ptr(new Block(statement.fOffset, - std::move(statements), - fSymbolTable)); - } - } - } - return result; - } + case ASTStatement::kExpression_Kind: + return this->convertExpressionStatement((ASTExpressionStatement&) statement); case ASTStatement::kIf_Kind: return this->convertIf((ASTIfStatement&) statement); case ASTStatement::kFor_Kind: @@ -278,11 +257,6 @@ std::unique_ptr IRGenerator::convertVarDeclarations(const ASTVa } auto var = std::unique_ptr(new Variable(decl.fOffset, decl.fModifiers, varDecl.fName, *type, storage)); - if (var->fName == Compiler::RTADJUST_NAME) { - ASSERT(!fRTAdjust); - ASSERT(var->fType == *fContext.fFloat4_Type); - fRTAdjust = var.get(); - } std::unique_ptr value; if (varDecl.fValue) { value = this->convertExpression(*varDecl.fValue); @@ -498,10 +472,6 @@ std::unique_ptr IRGenerator::convertExpressionStatement( std::unique_ptr IRGenerator::convertReturn(const ASTReturnStatement& r) { ASSERT(fCurrentFunction); - // early returns from a vertex main function will bypass the sk_Position normalization, so - // assert that we aren't doing that. It is of course possible to fix this by adding a - // normalization before each return, but it will probably never actually be necessary. - ASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->fName); if (r.fExpression) { std::unique_ptr result = this->convertExpression(*r.fExpression); if (!result) { @@ -605,40 +575,6 @@ std::unique_ptr IRGenerator::applyInvocationIDWorkaround(std::unique_ptr< return std::unique_ptr(new Block(-1, std::move(children))); } -std::unique_ptr IRGenerator::getNormalizeSkPositionCode() { - // sk_Position = float4(sk_Position.x * rtAdjust.x + sk_Position.w * rtAdjust.y, - // sk_Position.y * rtAdjust.z + sk_Position.w * rtAdjust.w, - // 0, - // sk_Position.w); - ASSERT(fSkPerVertex && fRTAdjust); - #define REF(var) std::unique_ptr(\ - new VariableReference(-1, *var, VariableReference::kRead_RefKind)) - #define FIELD(var, idx) std::unique_ptr(\ - new FieldAccess(REF(var), idx, FieldAccess::kAnonymousInterfaceBlock_OwnerKind)) - #define POS std::unique_ptr(new FieldAccess(REF(fSkPerVertex), 0, \ - FieldAccess::kAnonymousInterfaceBlock_OwnerKind)) - #define ADJUST (fRTAdjustInterfaceBlock ? \ - FIELD(fRTAdjustInterfaceBlock, fRTAdjustFieldIndex) : \ - REF(fRTAdjust)) - #define SWIZZLE(expr, field) std::unique_ptr(new Swizzle(fContext, expr, { field })) - #define OP(left, op, right) std::unique_ptr(\ - new BinaryExpression(-1, left, op, right, *fContext.fFloat_Type)) - std::vector> children; - children.push_back(OP(OP(SWIZZLE(POS, 0), Token::STAR, SWIZZLE(ADJUST, 0)), - Token::PLUS, - OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 1)))); - children.push_back(OP(OP(SWIZZLE(POS, 1), Token::STAR, SWIZZLE(ADJUST, 2)), - Token::PLUS, - OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 3)))); - children.push_back(std::unique_ptr(new FloatLiteral(fContext, -1, 0.0))); - children.push_back(SWIZZLE(POS, 3)); - std::unique_ptr result = OP(POS, Token::EQ, - std::unique_ptr(new Constructor(-1, - *fContext.fFloat4_Type, - std::move(children)))); - return std::unique_ptr(new ExpressionStatement(std::move(result))); -} - void IRGenerator::convertFunction(const ASTFunction& f) { const Type* returnType = this->convertType(*f.fReturnType); if (!returnType) { @@ -755,9 +691,7 @@ void IRGenerator::convertFunction(const ASTFunction& f) { } // conservatively assume all user-defined functions have side effects ((Modifiers&) decl->fModifiers).fFlags |= Modifiers::kHasSideEffects_Flag; - if (Program::kVertex_Kind == fKind && f.fName == "main" && fRTAdjust) { - body->fStatements.insert(body->fStatements.end(), this->getNormalizeSkPositionCode()); - } + fProgramElements->push_back(std::unique_ptr( new FunctionDefinition(f.fOffset, *decl, std::move(body)))); } @@ -768,7 +702,6 @@ std::unique_ptr IRGenerator::convertInterfaceBlock(const ASTInte AutoSymbolTable table(this); std::vector fields; bool haveRuntimeArray = false; - bool foundRTAdjust = false; for (size_t i = 0; i < intf.fDeclarations.size(); i++) { std::unique_ptr decl = this->convertVarDeclarations( *intf.fDeclarations[i], @@ -783,11 +716,6 @@ std::unique_ptr IRGenerator::convertInterfaceBlock(const ASTInte "only the last entry in an interface block may be a runtime-sized " "array"); } - if (vd.fVar == fRTAdjust) { - foundRTAdjust = true; - ASSERT(vd.fVar->fType == *fContext.fFloat4_Type); - fRTAdjustFieldIndex = fields.size(); - } fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->fName, &vd.fVar->fType)); if (vd.fValue) { @@ -841,9 +769,6 @@ std::unique_ptr IRGenerator::convertInterfaceBlock(const ASTInte Variable* var = new Variable(intf.fOffset, intf.fModifiers, intf.fInstanceName.fLength ? intf.fInstanceName : intf.fTypeName, *type, Variable::kGlobal_Storage); - if (foundRTAdjust) { - fRTAdjustInterfaceBlock = var; - } old->takeOwnership(var); if (intf.fInstanceName.fLength) { old->addWithoutOwnership(intf.fInstanceName, var); @@ -853,10 +778,6 @@ std::unique_ptr IRGenerator::convertInterfaceBlock(const ASTInte (int) i))); } } - if (var->fName == Compiler::PERVERTEX_NAME) { - ASSERT(!fSkPerVertex); - fSkPerVertex = var; - } return std::unique_ptr(new InterfaceBlock(intf.fOffset, var, intf.fTypeName, @@ -2106,12 +2027,10 @@ void IRGenerator::markWrittenTo(const Expression& expr, bool readWrite) { } } -void IRGenerator::convertProgram(Program::Kind kind, - const char* text, +void IRGenerator::convertProgram(const char* text, size_t length, SymbolTable& types, std::vector>* out) { - fKind = kind; fProgramElements = out; Parser parser(text, length, types, fErrors); std::vector> parsed = parser.file(); diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h index 327fe6fc7a..1df9b65bd0 100644 --- a/src/sksl/SkSLIRGenerator.h +++ b/src/sksl/SkSLIRGenerator.h @@ -62,8 +62,7 @@ public: IRGenerator(const Context* context, std::shared_ptr root, ErrorReporter& errorReporter); - void convertProgram(Program::Kind kind, - const char* text, + void convertProgram(const char* text, size_t length, SymbolTable& types, std::vector>* result); @@ -157,15 +156,12 @@ private: std::unique_ptr convertWhile(const ASTWhileStatement& w); void convertEnum(const ASTEnum& e); std::unique_ptr applyInvocationIDWorkaround(std::unique_ptr main); - // returns a statement which converts sk_Position from device to normalized coordinates - std::unique_ptr getNormalizeSkPositionCode(); void fixRectSampling(std::vector>& arguments); void checkValid(const Expression& expr); void markWrittenTo(const Expression& expr, bool readWrite); void getConstantInt(const Expression& value, int64_t* out); - Program::Kind fKind; const FunctionDeclaration* fCurrentFunction; std::unordered_map fCapsMap; std::shared_ptr fRootSymbolTable; @@ -179,10 +175,6 @@ private: ErrorReporter& fErrors; int fInvocations; std::vector>* fProgramElements; - Variable* fSkPerVertex; - Variable* fRTAdjust; - Variable* fRTAdjustInterfaceBlock; - int fRTAdjustFieldIndex; friend class AutoSymbolTable; friend class AutoLoopLevel; diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp index 62c5cd6955..53710c9516 100644 --- a/tests/SkSLGLSLTest.cpp +++ b/tests/SkSLGLSLTest.cpp @@ -1071,21 +1071,6 @@ DEF_TEST(SkSLFragCoord, r) { "}\n", SkSL::Program::kVertex_Kind); - test(r, - "in uniform float4 sk_RTAdjust; in float4 pos; void main() { sk_Position = pos; }", - *SkSL::ShaderCapsFactory::CannotUseFragCoord(), - "#version 400\n" - "out vec4 sk_FragCoord_Workaround;\n" - "in uniform vec4 sk_RTAdjust;\n" - "in vec4 pos;\n" - "void main() {\n" - " sk_FragCoord_Workaround = (gl_Position = pos);\n" - " gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * sk_RTAdjust.y, " - "gl_Position.y * sk_RTAdjust.z + gl_Position.w * sk_RTAdjust.w, 0.0, " - "gl_Position.w);\n" - "}\n", - SkSL::Program::kVertex_Kind); - test(r, "void main() { sk_FragColor.xy = sk_FragCoord.xy; }", *SkSL::ShaderCapsFactory::CannotUseFragCoord(), @@ -1754,58 +1739,6 @@ DEF_TEST(SkSLForceHighPrecision, r) { &inputs); } -DEF_TEST(SkSLNormalization, r) { - test(r, - "uniform float4 sk_RTAdjust; void main() { sk_Position = half4(1); }", - *SkSL::ShaderCapsFactory::Default(), - "#version 400\n" - "uniform vec4 sk_RTAdjust;\n" - "void main() {\n" - " gl_Position = vec4(1.0);\n" - " gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * sk_RTAdjust.y, " - "gl_Position.y * sk_RTAdjust.z + gl_Position.w * sk_RTAdjust.w, " - "0.0, " - "gl_Position.w);\n" - "}\n", - SkSL::Program::kVertex_Kind); - test(r, - "uniform float4 sk_RTAdjust;" - "layout(points) in;" - "layout(invocations = 2) in;" - "layout(line_strip, max_vertices = 2) out;" - "void main() {" - "sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);" - "EmitVertex();" - "sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);" - "EmitVertex();" - "EndPrimitive();" - "}", - *SkSL::ShaderCapsFactory::GeometryShaderSupport(), - "#version 400\n" - "uniform vec4 sk_RTAdjust;\n" - "layout (points) in ;\n" - "layout (invocations = 2) in ;\n" - "layout (line_strip, max_vertices = 2) out ;\n" - "void main() {\n" - " gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n" - " {\n" - " gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * " - "sk_RTAdjust.y, gl_Position.y * sk_RTAdjust.z + gl_Position.w * " - "sk_RTAdjust.w, 0.0, gl_Position.w);\n" - " EmitVertex();\n" - " }\n" - " gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));\n" - " {\n" - " gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * " - "sk_RTAdjust.y, gl_Position.y * sk_RTAdjust.z + gl_Position.w * " - "sk_RTAdjust.w, 0.0, gl_Position.w);\n" - " EmitVertex();\n" - " }\n" - " EndPrimitive();\n" - "}\n", - SkSL::Program::kGeometry_Kind); -} - DEF_TEST(SkSLTernaryLValue, r) { test(r, "void main() { half r, g; (true ? r : g) = 1; (false ? r : g) = 0; "