aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir/SkSLLayout.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-11-28 11:23:23 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-28 18:48:57 +0000
commit11d53974317fa29cc516075382e658ddd45fc151 (patch)
tree78c136fd223c11de1fa2a9601129243ce3c8c129 /src/sksl/ir/SkSLLayout.h
parent2b3dab62bccdbf6244aef9103e9e739147af8616 (diff)
unified ASTLayout/Layout and ASTModifiers/Modifiers
BUG=skia: Change-Id: Ib4c2c94401e586e93e926776e13c0f7c12212f7e Reviewed-on: https://skia-review.googlesource.com/5268 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ir/SkSLLayout.h')
-rw-r--r--src/sksl/ir/SkSLLayout.h84
1 files changed, 66 insertions, 18 deletions
diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h
index f433614da9..b2c158eeef 100644
--- a/src/sksl/ir/SkSLLayout.h
+++ b/src/sksl/ir/SkSLLayout.h
@@ -4,10 +4,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_LAYOUT
#define SKSL_LAYOUT
+#include "SkString.h"
+#include "SkSLUtil.h"
+
namespace SkSL {
/**
@@ -16,22 +19,67 @@ namespace SkSL {
* layout (location = 0) int x;
*/
struct Layout {
- Layout(const ASTLayout& layout)
- : fLocation(layout.fLocation)
- , fBinding(layout.fBinding)
- , fIndex(layout.fIndex)
- , fSet(layout.fSet)
- , fBuiltin(layout.fBuiltin)
- , fInputAttachmentIndex(layout.fInputAttachmentIndex)
- , fOriginUpperLeft(layout.fOriginUpperLeft)
- , fOverrideCoverage(layout.fOverrideCoverage)
- , fBlendSupportAllEquations(layout.fBlendSupportAllEquations)
- , fFormat(layout.fFormat)
- , fPushConstant(layout.fPushConstant) {}
+ // 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(SkString 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;
+ }
Layout(int location, int binding, int index, int set, int builtin, int inputAttachmentIndex,
bool originUpperLeft, bool overrideCoverage, bool blendSupportAllEquations,
- ASTLayout::Format format, bool pushconstant)
+ Format format, bool pushconstant)
: fLocation(location)
, fBinding(binding)
, fIndex(index)
@@ -54,7 +102,7 @@ struct Layout {
, fOriginUpperLeft(false)
, fOverrideCoverage(false)
, fBlendSupportAllEquations(false)
- , fFormat(ASTLayout::Format::kUnspecified)
+ , fFormat(Format::kUnspecified)
, fPushConstant(false) {}
SkString description() const {
@@ -96,8 +144,8 @@ struct Layout {
result += separator + "blend_support_all_equations";
separator = ", ";
}
- if (ASTLayout::Format::kUnspecified != fFormat) {
- result += separator + ASTLayout::FormatToStr(fFormat);
+ if (Format::kUnspecified != fFormat) {
+ result += separator + FormatToStr(fFormat);
separator = ", ";
}
if (fPushConstant) {
@@ -140,7 +188,7 @@ struct Layout {
bool fOriginUpperLeft;
bool fOverrideCoverage;
bool fBlendSupportAllEquations;
- ASTLayout::Format fFormat;
+ Format fFormat;
bool fPushConstant;
};