diff options
author | Brian Salomon <bsalomon@google.com> | 2016-11-16 12:06:01 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-16 19:31:11 +0000 |
commit | 2a51de82ceb6790f329b9f4cc85e61f34fc2d0d4 (patch) | |
tree | 90fe38a87ff97476dea77d88c1583350a8980e12 /src/sksl/ast | |
parent | 50500ad470af3d82c68144fec7e55c9cdffb5d98 (diff) |
Revert "Revert "Add support for image load to SkSL""
This reverts commit cb115bdeed5898ded3fdbe572a14616cff809b7c.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4900
Change-Id: Ibcb381bae83d0cfc1a1226be90792061d401426a
Reviewed-on: https://skia-review.googlesource.com/4900
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/sksl/ast')
-rw-r--r-- | src/sksl/ast/SkSLASTLayout.h | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/src/sksl/ast/SkSLASTLayout.h b/src/sksl/ast/SkSLASTLayout.h index 515eb2bdbb..ae3c3b6168 100644 --- a/src/sksl/ast/SkSLASTLayout.h +++ b/src/sksl/ast/SkSLASTLayout.h @@ -19,9 +19,67 @@ namespace SkSL { * layout (location = 0) int x; */ struct ASTLayout : public ASTNode { - // For all parameters, a -1 means no value + // These are used by images in GLSL. We only support a subset of what GL supports. + enum class Format { + kUnspecified = -1, + kRGBA32F, + kR32F, + kRGBA16F, + kR16F, + kRGBA8, + kR8, + kRGBA8I, + kR8I, + }; + + static const char* FormatToStr(Format format) { + switch (format) { + case Format::kUnspecified: return ""; + case Format::kRGBA32F: return "rgba32f"; + case Format::kR32F: return "r32f"; + case Format::kRGBA16F: return "rgba16f"; + case Format::kR16F: return "r16f"; + case Format::kRGBA8: return "rgba8"; + case Format::kR8: return "r8"; + case Format::kRGBA8I: return "rgba8i"; + case Format::kR8I: return "r8i"; + } + SkFAIL("Unexpected format"); + return ""; + } + + static bool ReadFormat(std::string str, Format* format) { + if (str == "rgba32f") { + *format = Format::kRGBA32F; + return true; + } else if (str == "r32f") { + *format = Format::kR32F; + return true; + } else if (str == "rgba16f") { + *format = Format::kRGBA16F; + return true; + } else if (str == "r16f") { + *format = Format::kR16F; + return true; + } else if (str == "rgba8") { + *format = Format::kRGBA8; + return true; + } else if (str == "r8") { + *format = Format::kR8; + return true; + } else if (str == "rgba8i") { + *format = Format::kRGBA8I; + return true; + } else if (str == "r8i") { + *format = Format::kR8I; + return true; + } + return false; + } + + // For int parameters, a -1 means no value ASTLayout(int location, int binding, int index, int set, int builtin, bool originUpperLeft, - bool overrideCoverage, bool blendSupportAllEquations) + bool overrideCoverage, bool blendSupportAllEquations, Format format) : fLocation(location) , fBinding(binding) , fIndex(index) @@ -29,7 +87,8 @@ struct ASTLayout : public ASTNode { , fBuiltin(builtin) , fOriginUpperLeft(originUpperLeft) , fOverrideCoverage(overrideCoverage) - , fBlendSupportAllEquations(blendSupportAllEquations) {} + , fBlendSupportAllEquations(blendSupportAllEquations) + , fFormat(format) {} std::string description() const { std::string result; @@ -66,6 +125,10 @@ struct ASTLayout : public ASTNode { result += separator + "blend_support_all_equations"; separator = ", "; } + if (fFormat != Format::kUnspecified) { + result += separator + FormatToStr(fFormat); + separator = ", "; + } if (result.length() > 0) { result = "layout (" + result + ")"; } @@ -80,6 +143,7 @@ struct ASTLayout : public ASTNode { const bool fOriginUpperLeft; const bool fOverrideCoverage; const bool fBlendSupportAllEquations; + const Format fFormat; }; } // namespace |