diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2016-11-21 15:59:48 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-22 14:20:27 +0000 |
commit | 3605ace7ddaf0b576bf6df1c7a550ab4f44d22a8 (patch) | |
tree | 929ee78317ba05e8f2c36c0f1b4bafea87794ca0 /src/sksl/README | |
parent | 9bcca6a2124b60ce9fab18ba697b28fc6a1354db (diff) |
sksl programs can now directly query GLSL caps
This adds support for querying "sk_Caps.<cap>" directly from within an SkSL program.
Combined with the existing support for collapsing 'if' statements with constant tests,
this means we can query caps using ordinary 'if' statements and the tests will
collapse out at compile time.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4795
Change-Id: I24d716a7fe6abf1489760bf08189164264269076
Reviewed-on: https://skia-review.googlesource.com/4795
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/README')
-rw-r--r-- | src/sksl/README | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sksl/README b/src/sksl/README index 6302075507..0ab8a0500a 100644 --- a/src/sksl/README +++ b/src/sksl/README @@ -18,6 +18,19 @@ differences (for instance, you always use "in" and "out", and skslc will handle translating them to "varying" and "attribute" as appropriate). Be aware of the following differences between SkSL and GLSL: +* GLSL caps can be referenced via the syntax 'sk_Caps.<name>', e.g. + sk_Caps.sampleVariablesSupport. The value will be a constant boolean or int, + as appropriate. As SkSL supports constant folding and branch elimination, this + means that an 'if' statement which statically queries a cap will collapse down + to the chosen branch, meaning that: + + if (sk_Caps.externalTextureSupport) + do_something(); + else + do_something_else(); + + will compile as if you had written either 'do_something();' or + 'do_something_else();', depending on whether that cap is enabled or not. * no #version statement is required, and will be ignored if present * the output color is sk_FragColor (do not declare it) * lowp, mediump, and highp are always permitted (but will only be respected if |