Remove sampler support from .fp files
Change-Id: I46e5bc6d39aa185b26436e1795f50a0c7bb9905b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411307
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 3ae983d..d7c7469 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -46,10 +46,6 @@
ProcessorOptimizationFlags(inputFP.get()) & kCompatibleWithCoverageAsAlpha_OptimizationFlag
}
-@samplerParams(integral) {
- samplerParams
-}
-
@class {
static std::unique_ptr<GrFragmentProcessor> MakeIntegralFP(GrRecordingContext* rContext,
float sixSigma) {
diff --git a/src/sksl/README b/src/sksl/README
index 1259b63..640b041 100644
--- a/src/sksl/README
+++ b/src/sksl/README
@@ -112,8 +112,6 @@
the name of the GrGLSLProgramDataManager)
@test(<testData>) (the body of the TestCreate function, where <testData> is
the name of the GrProcessorTestData* parameter)
- @samplerParams(<sampler>)
- (the sampler params to attach to the named sampler2D)
* global 'in' variables represent data passed to the fragment processor at
construction time. These variables become constructor parameters and are
stored in fragment processor fields. By default float2/half2 maps to SkPoints,
diff --git a/src/sksl/SkSLSectionAndParameterHelper.cpp b/src/sksl/SkSLSectionAndParameterHelper.cpp
index 7790487..640a618 100644
--- a/src/sksl/SkSLSectionAndParameterHelper.cpp
+++ b/src/sksl/SkSLSectionAndParameterHelper.cpp
@@ -54,10 +54,8 @@
errors.error(s.fOffset,
("unsupported section '@" + name + "'").c_str());
}
- if (!SectionPermitsDuplicates(name.c_str()) &&
- fSections.find(name) != fSections.end()) {
- errors.error(s.fOffset,
- ("duplicate section '@" + name + "'").c_str());
+ if (fSections.find(name) != fSections.end()) {
+ errors.error(s.fOffset, ("duplicate section '@" + name + "'").c_str());
}
fSections[name].push_back(&s);
break;
diff --git a/src/sksl/SkSLSectionAndParameterHelper.h b/src/sksl/SkSLSectionAndParameterHelper.h
index 6dc7cf4..9ca7b83 100644
--- a/src/sksl/SkSLSectionAndParameterHelper.h
+++ b/src/sksl/SkSLSectionAndParameterHelper.h
@@ -32,7 +32,6 @@
inline constexpr char kInitializersSection[] = "initializers";
inline constexpr char kMakeSection[] = "make";
inline constexpr char kOptimizationFlagsSection[] = "optimizationFlags";
-inline constexpr char kSamplerParamsSection[] = "samplerParams";
inline constexpr char kSetDataSection[] = "setData";
inline constexpr char kTestCodeSection[] = "test";
@@ -41,7 +40,6 @@
SectionAndParameterHelper(const Program* program, ErrorReporter& errors);
const Section* getSection(const char* name) {
- SkASSERT(!SectionPermitsDuplicates(name));
auto found = fSections.find(name);
if (found == fSections.end()) {
return nullptr;
@@ -83,27 +81,20 @@
!strcmp(name, kInitializersSection) ||
!strcmp(name, kMakeSection) ||
!strcmp(name, kOptimizationFlagsSection) ||
- !strcmp(name, kSamplerParamsSection) ||
!strcmp(name, kSetDataSection) ||
!strcmp(name, kTestCodeSection);
}
static bool SectionAcceptsArgument(const char* name) {
- return !strcmp(name, kSamplerParamsSection) ||
- !strcmp(name, kSetDataSection) ||
+ return !strcmp(name, kSetDataSection) ||
!strcmp(name, kTestCodeSection);
}
static bool SectionRequiresArgument(const char* name) {
- return !strcmp(name, kSamplerParamsSection) ||
- !strcmp(name, kSetDataSection) ||
+ return !strcmp(name, kSetDataSection) ||
!strcmp(name, kTestCodeSection);
}
- static bool SectionPermitsDuplicates(const char* name) {
- return !strcmp(name, kSamplerParamsSection);
- }
-
private:
const Program& fProgram;
std::vector<const Variable*> fParameters;
diff --git a/src/sksl/codegen/SkSLCPPCodeGenerator.cpp b/src/sksl/codegen/SkSLCPPCodeGenerator.cpp
index f1c54bb..af0573c 100644
--- a/src/sksl/codegen/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLCPPCodeGenerator.cpp
@@ -20,8 +20,7 @@
namespace SkSL {
static bool needs_uniform_var(const Variable& var) {
- return (var.modifiers().fFlags & Modifiers::kUniform_Flag) &&
- var.type().typeKind() != Type::TypeKind::kSampler;
+ return (var.modifiers().fFlags & Modifiers::kUniform_Flag);
}
CPPCodeGenerator::CPPCodeGenerator(const Context* context, const Program* program,
@@ -31,7 +30,6 @@
, fFullName(String::printf("Gr%s", fName.c_str()))
, fSectionAndParameterHelper(program, *errors) {
fLineEnding = "\n";
- fTextureFunctionOverride = "sample";
}
void CPPCodeGenerator::writef(const char* s, va_list va) {
@@ -120,8 +118,7 @@
static bool is_uniform_in(const Variable& var) {
const Modifiers& modifiers = var.modifiers();
return (modifiers.fFlags & Modifiers::kUniform_Flag) &&
- (modifiers.fFlags & Modifiers::kIn_Flag) &&
- var.type().typeKind() != Type::TypeKind::kSampler;
+ (modifiers.fFlags & Modifiers::kIn_Flag);
}
String CPPCodeGenerator::formatRuntimeValue(const Type& type,
@@ -236,19 +233,6 @@
}
}
-String CPPCodeGenerator::getSamplerHandle(const Variable& var) {
- int samplerCount = 0;
- for (const auto param : fSectionAndParameterHelper.getParameters()) {
- if (&var == param) {
- return "args.fTexSamplers[" + to_string(samplerCount) + "]";
- }
- if (param->type().typeKind() == Type::TypeKind::kSampler) {
- ++samplerCount;
- }
- }
- SK_ABORT("should have found sampler in parameters\n");
-}
-
void CPPCodeGenerator::writeIntLiteral(const IntLiteral& i) {
this->write(to_string(i.value()));
}
@@ -282,12 +266,6 @@
break;
default:
const Variable& var = *ref.variable();
- if (var.type().typeKind() == Type::TypeKind::kSampler) {
- this->write("%s");
- fFormatArgs.push_back("fragBuilder->getProgramBuilder()->samplerVariable(" +
- this->getSamplerHandle(*ref.variable()) + ")");
- return;
- }
if (var.modifiers().fFlags & Modifiers::kUniform_Flag) {
this->write("%s");
String name = var.name();
@@ -355,8 +333,7 @@
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
const FunctionDeclaration& function = c.function();
const ExpressionArray& arguments = c.arguments();
- if (function.isBuiltin() && function.name() == "sample" &&
- arguments[0]->type().typeKind() != Type::TypeKind::kSampler) {
+ if (function.isBuiltin() && function.name() == "sample") {
int sampleCounter = fSampleCounter++;
// Validity checks that are detected by function definition in sksl_fp.inc
@@ -427,15 +404,6 @@
}
this->write(")");
}
- if (function.isBuiltin() && function.name() == "sample") {
- this->write(".%s");
- SkASSERT(arguments.size() >= 1);
- SkASSERT(arguments[0]->is<VariableReference>());
- String sampler =
- this->getSamplerHandle(*arguments[0]->as<VariableReference>().variable());
- fFormatArgs.push_back("fragBuilder->getProgramBuilder()->samplerSwizzle(" + sampler +
- ").asString().c_str()");
- }
}
static const char* glsltype_string(const Context& context, const Type& type) {
@@ -672,7 +640,6 @@
static bool is_accessible(const Variable& var) {
const Type& type = var.type();
return !type.isFragmentProcessor() &&
- Type::TypeKind::kSampler != type.typeKind() &&
Type::TypeKind::kOther != type.typeKind();
}
@@ -989,7 +956,6 @@
this->writef(" }\n");
}
if (section) {
- int samplerIndex = 0;
for (const ProgramElement* p : fProgram.elements()) {
if (p->is<GlobalVarDeclaration>()) {
const GlobalVarDeclaration& global = p->as<GlobalVarDeclaration>();
@@ -997,15 +963,7 @@
const Variable& variable = decl.var();
String nameString(variable.name());
const char* name = nameString.c_str();
- if (variable.type().typeKind() == Type::TypeKind::kSampler) {
- this->writef(" const GrSurfaceProxyView& %sView = "
- "_outer.textureSampler(%d).view();\n",
- name, samplerIndex);
- this->writef(" GrTexture& %s = *%sView.proxy()->peekTexture();\n",
- name, name);
- this->writef(" (void) %s;\n", name);
- ++samplerIndex;
- } else if (needs_uniform_var(variable)) {
+ if (needs_uniform_var(variable)) {
this->writef(" UniformHandle& %s = %sVar;\n"
" (void) %s;\n",
name, HCodeGenerator::FieldName(name).c_str(), name);
@@ -1030,29 +988,6 @@
this->write(" }\n");
}
-void CPPCodeGenerator::writeOnTextureSampler() {
- bool foundSampler = false;
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- if (param->type().typeKind() == Type::TypeKind::kSampler) {
- if (!foundSampler) {
- this->writef(
- "const GrFragmentProcessor::TextureSampler& %s::onTextureSampler(int "
- "index) const {\n",
- fFullName.c_str());
- this->writef(" return IthTextureSampler(index, %s",
- HCodeGenerator::FieldName(String(param->name()).c_str()).c_str());
- foundSampler = true;
- } else {
- this->writef(", %s",
- HCodeGenerator::FieldName(String(param->name()).c_str()).c_str());
- }
- }
- }
- if (foundSampler) {
- this->write(");\n}\n");
- }
-}
-
void CPPCodeGenerator::writeClone() {
if (!this->writeSection(kCloneSection)) {
if (fSectionAndParameterHelper.getSection(kFieldsSection)) {
@@ -1072,15 +1007,6 @@
}
this->writef(" {\n");
this->writef(" this->cloneAndRegisterAllChildProcessors(src);\n");
- int samplerCount = 0;
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- if (param->type().typeKind() == Type::TypeKind::kSampler) {
- ++samplerCount;
- }
- }
- if (samplerCount) {
- this->writef(" this->setTextureSamplerCnt(%d);", samplerCount);
- }
if (fAccessSampleCoordsDirectly) {
this->writef(" this->setUsesSampleCoordsDirectly();\n");
}
@@ -1269,8 +1195,7 @@
if (p->is<GlobalVarDeclaration>()) {
const GlobalVarDeclaration& global = p->as<GlobalVarDeclaration>();
const VarDeclaration& decl = global.declaration()->as<VarDeclaration>();
- if ((decl.var().modifiers().fFlags & Modifiers::kUniform_Flag) &&
- decl.var().type().typeKind() != Type::TypeKind::kSampler) {
+ if (decl.var().modifiers().fFlags & Modifiers::kUniform_Flag) {
uniforms.push_back(&decl.var());
}
@@ -1344,7 +1269,6 @@
"}\n");
this->writeClone();
this->writeDumpInfo();
- this->writeOnTextureSampler();
this->writeTest();
this->writeSection(kCppEndSection);
diff --git a/src/sksl/codegen/SkSLCPPCodeGenerator.h b/src/sksl/codegen/SkSLCPPCodeGenerator.h
index 2a027f5..890ea9b 100644
--- a/src/sksl/codegen/SkSLCPPCodeGenerator.h
+++ b/src/sksl/codegen/SkSLCPPCodeGenerator.h
@@ -47,8 +47,6 @@
void writeVariableReference(const VariableReference& ref) override;
- String getSamplerHandle(const Variable& var);
-
void writeIfStatement(const IfStatement& s) override;
void writeReturnStatement(const ReturnStatement& s) override;
@@ -94,8 +92,6 @@
void writeGetKey();
- void writeOnTextureSampler();
-
void writeClone();
void writeDumpInfo();
diff --git a/src/sksl/codegen/SkSLDSLCPPCodeGenerator.cpp b/src/sksl/codegen/SkSLDSLCPPCodeGenerator.cpp
index 512da72..d85cdc9 100644
--- a/src/sksl/codegen/SkSLDSLCPPCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLDSLCPPCodeGenerator.cpp
@@ -49,7 +49,6 @@
, fFullName(String::printf("Gr%s", fName.c_str()))
, fSectionAndParameterHelper(program, *errors) {
fLineEnding = "\n";
- fTextureFunctionOverride = "sample";
}
void DSLCPPCodeGenerator::writef(const char* s, va_list va) {
diff --git a/src/sksl/codegen/SkSLHCodeGenerator.cpp b/src/sksl/codegen/SkSLHCodeGenerator.cpp
index d5aa841..04fbe6b 100644
--- a/src/sksl/codegen/SkSLHCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLHCodeGenerator.cpp
@@ -74,9 +74,7 @@
String HCodeGenerator::FieldType(const Context& context, const Type& type,
const Layout& layout) {
- if (type.typeKind() == Type::TypeKind::kSampler) {
- return "TextureSampler";
- } else if (type.isFragmentProcessor()) {
+ if (type.isFragmentProcessor()) {
// we don't store fragment processors in fields, they get registered via
// registerChildProcessor instead
SkASSERT(false);
@@ -190,8 +188,7 @@
fFullName.c_str());
separator = "";
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- if (param->type().isFragmentProcessor() ||
- param->type().typeKind() == Type::TypeKind::kSampler) {
+ if (param->type().isFragmentProcessor()) {
this->writef("%sstd::move(%s)", separator, String(param->name()).c_str());
} else {
this->writef("%s%s", separator, String(param->name()).c_str());
@@ -240,16 +237,7 @@
String nameString(param->name());
const char* name = nameString.c_str();
const Type& type = param->type();
- if (type.typeKind() == Type::TypeKind::kSampler) {
- this->writef("\n , %s(std::move(%s)", FieldName(name).c_str(), name);
- for (const Section* s : fSectionAndParameterHelper.getSections(
- kSamplerParamsSection)) {
- if (s->argument() == name) {
- this->writef(", %s", s->text().c_str());
- }
- }
- this->writef(")");
- } else if (type.isFragmentProcessor()) {
+ if (type.isFragmentProcessor()) {
// do nothing
} else {
this->writef("\n , %s(%s)", FieldName(name).c_str(), name);
@@ -262,12 +250,9 @@
this->writef(" this->setUsesSampleCoordsDirectly();\n");
}
- int samplerCount = 0;
for (const Variable* param : fSectionAndParameterHelper.getParameters()) {
const Type& paramType = param->type();
- if (paramType.typeKind() == Type::TypeKind::kSampler) {
- ++samplerCount;
- } else if (paramType.isFragmentProcessor()) {
+ if (paramType.isFragmentProcessor()) {
SampleUsage usage = Analysis::GetSampleUsage(fProgram, *param);
std::string usageArg = usage.constructor();
@@ -276,9 +261,6 @@
usageArg.c_str());
}
}
- if (samplerCount) {
- this->writef(" this->setTextureSamplerCnt(%d);\n", samplerCount);
- }
this->writef(" }\n");
}
@@ -349,12 +331,6 @@
" void onGetGLSLProcessorKey(const GrShaderCaps&, "
"GrProcessorKeyBuilder*) const override;\n"
" bool onIsEqual(const GrFragmentProcessor&) const override;\n");
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- if (param->type().typeKind() == Type::TypeKind::kSampler) {
- this->writef(" const TextureSampler& onTextureSampler(int) const override;");
- break;
- }
- }
this->writef("#if GR_TEST_UTILS\n"
" SkString onDumpInfo() const override;\n"
"#endif\n"