aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLSPIRVCodeGenerator.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2018-02-27 15:25:47 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-28 19:02:26 +0000
commit0fc07f95bb2cf6c3e5da1c088694eb1b495cbf01 (patch)
tree03e04c29a4726f4ec0ea5701aa187a435cd1fe8c /src/sksl/SkSLSPIRVCodeGenerator.h
parent874c93b2e7dadb2635db229b487105e371d6bf0c (diff)
Update certain instrinsic calls in SkSL SPIR-V gen to not mix vectors and scalars.
Functions like min, max, clamp, and mix cannot intermix vectors and scalars as operands and return value. This updates SkSL to promote scalars to vectors if need be before calling these functions. Bug: skia:7653 Change-Id: I13f98d452978e3f15bafddea638b7bbe313d98ce Reviewed-on: https://skia-review.googlesource.com/110660 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/sksl/SkSLSPIRVCodeGenerator.h')
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h
index 0d51af5d71..4bd8d86dd8 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/SkSLSPIRVCodeGenerator.h
@@ -90,6 +90,10 @@ private:
enum SpecialIntrinsic {
kAtan_SpecialIntrinsic,
+ kClamp_SpecialIntrinsic,
+ kMax_SpecialIntrinsic,
+ kMin_SpecialIntrinsic,
+ kMix_SpecialIntrinsic,
kMod_SpecialIntrinsic,
kSubpassLoad_SpecialIntrinsic,
kTexelFetch_SpecialIntrinsic,
@@ -149,6 +153,20 @@ private:
SpvId writeFunctionCall(const FunctionCall& c, OutputStream& out);
+
+ void writeGLSLExtendedInstruction(const Type& type, SpvId id, SpvId floatInst,
+ SpvId signedInst, SpvId unsignedInst,
+ const std::vector<SpvId>& args, OutputStream& out);
+
+ /**
+ * Given a list of potentially mixed scalars and vectors, promotes the scalars to match the
+ * size of the vectors and returns the ids of the written expressions. e.g. given (float, vec2),
+ * returns (vec2(float), vec2). It is an error to use mismatched vector sizes, e.g. (float,
+ * vec2, vec3).
+ */
+ std::vector<SpvId> vectorize(const std::vector<std::unique_ptr<Expression>>& args,
+ OutputStream& out);
+
SpvId writeSpecialIntrinsic(const FunctionCall& c, SpecialIntrinsic kind, OutputStream& out);
SpvId writeConstantVector(const Constructor& c);