aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 21:42:45 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 21:42:45 +0000
commitd26b4dc2de8e858ec2a84ac80b1aaf3c8fb9f88b (patch)
tree1b5b60971d0bd0457932117f28ce1cb1c86c255d
parentf659c62780dc336805567586785a63b28d717047 (diff)
parent1022730270ba8dd80db1ae4013ec6ccb945b4162 (diff)
downloadskia-d26b4dc2de8e858ec2a84ac80b1aaf3c8fb9f88b.tar.gz
Snap for 10285248 from 1022730270ba8dd80db1ae4013ec6ccb945b4162 to tm-platform-releaseandroid-platform-13.0.0_r8
Change-Id: Ic22ef2941e102bf74e3d66920cbf9390e8f59a46
-rw-r--r--gn/sksl_tests.gni1
-rw-r--r--resources/sksl/errors/ProgramTooLarge_Parameters.rts14
-rw-r--r--src/sksl/ir/SkSLFunctionDefinition.cpp41
-rw-r--r--tests/sksl/errors/ProgramTooLarge_Parameters.glsl6
4 files changed, 16 insertions, 46 deletions
diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni
index fdb0b91aee..d4c4ad4958 100644
--- a/gn/sksl_tests.gni
+++ b/gn/sksl_tests.gni
@@ -146,7 +146,6 @@ sksl_error_tests = [
"/sksl/errors/PrivateTypes.rts",
"/sksl/errors/PrivateVariables.rts",
"/sksl/errors/ProgramTooLarge_Globals.rts",
- "/sksl/errors/ProgramTooLarge_Parameters.rts",
"/sksl/errors/ProgramTooLarge_Stack.rts",
"/sksl/errors/PrototypeInFuncBody.rts",
"/sksl/errors/RedeclareBasicType.rts",
diff --git a/resources/sksl/errors/ProgramTooLarge_Parameters.rts b/resources/sksl/errors/ProgramTooLarge_Parameters.rts
deleted file mode 100644
index cced977be4..0000000000
--- a/resources/sksl/errors/ProgramTooLarge_Parameters.rts
+++ /dev/null
@@ -1,14 +0,0 @@
-struct S {
- half4 ah4[1];
- half ah[99999];
- half4 h4;
- half h;
-};
-
-void func(int small,
- S big_chungus,
- S no_report /*we don't need to report overflows past the first*/) {}
-
-/*%%*
-variable 'big_chungus' exceeds the stack size limit
-*%%*/
diff --git a/src/sksl/ir/SkSLFunctionDefinition.cpp b/src/sksl/ir/SkSLFunctionDefinition.cpp
index 5daee59cc0..3c7c3d182e 100644
--- a/src/sksl/ir/SkSLFunctionDefinition.cpp
+++ b/src/sksl/ir/SkSLFunctionDefinition.cpp
@@ -21,8 +21,6 @@
#include "src/sksl/transform/SkSLProgramWriter.h"
#include <forward_list>
-#include <string_view>
-#include <vector>
namespace SkSL {
@@ -82,27 +80,7 @@ std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& c
FunctionSet* referencedBuiltinFunctions)
: fContext(context)
, fFunction(function)
- , fReferencedBuiltinFunctions(referencedBuiltinFunctions) {
- // Function parameters count as local variables.
- for (const Variable* var : function.parameters()) {
- this->addLocalVariable(var, function.fLine);
- }
- }
-
- void addLocalVariable(const Variable* var, int line) {
- // We count the number of slots used, but don't consider the precision of the base type.
- // In practice, this reflects what GPUs actually do pretty well. (i.e., RelaxedPrecision
- // math doesn't mean your variable takes less space.) We also don't attempt to reclaim
- // slots at the end of a Block.
- size_t prevSlotsUsed = fSlotsUsed;
- fSlotsUsed = SkSafeMath::Add(fSlotsUsed, var->type().slotCount());
- // To avoid overzealous error reporting, only trigger the error at the first
- // place where the stack limit is exceeded.
- if (prevSlotsUsed < kVariableSlotLimit && fSlotsUsed >= kVariableSlotLimit) {
- fContext.fErrors->error(line, "variable '" + std::string(var->name()) +
- "' exceeds the stack size limit");
- }
- }
+ , fReferencedBuiltinFunctions(referencedBuiltinFunctions) {}
~Finalizer() override {
SkASSERT(fBreakableLevel == 0);
@@ -166,8 +144,21 @@ std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& c
bool visitStatement(Statement& stmt) override {
switch (stmt.kind()) {
case Statement::Kind::kVarDeclaration: {
- const Variable* var = &stmt.as<VarDeclaration>().var();
- this->addLocalVariable(var, stmt.fLine);
+ // We count the number of slots used, but don't consider the precision of the
+ // base type. In practice, this reflects what GPUs really do pretty well.
+ // (i.e., RelaxedPrecision math doesn't mean your variable takes less space.)
+ // We also don't attempt to reclaim slots at the end of a Block.
+ size_t prevSlotsUsed = fSlotsUsed;
+ fSlotsUsed = SkSafeMath::Add(
+ fSlotsUsed, stmt.as<VarDeclaration>().var().type().slotCount());
+ // To avoid overzealous error reporting, only trigger the error at the first
+ // place where the stack limit is exceeded.
+ if (prevSlotsUsed < kVariableSlotLimit && fSlotsUsed >= kVariableSlotLimit) {
+ fContext.fErrors->error(
+ stmt.fLine,
+ "variable '" + std::string(stmt.as<VarDeclaration>().var().name()) +
+ "' exceeds the stack size limit");
+ }
break;
}
case Statement::Kind::kReturn: {
diff --git a/tests/sksl/errors/ProgramTooLarge_Parameters.glsl b/tests/sksl/errors/ProgramTooLarge_Parameters.glsl
deleted file mode 100644
index d92c3256e8..0000000000
--- a/tests/sksl/errors/ProgramTooLarge_Parameters.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-### Compilation failed:
-
-error: 10: variable 'big_chungus' exceeds the stack size limit
- S no_report /*we don't need to report overflows past the first*/) {}
- ^^
-1 error