aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-02-16 16:37:32 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-17 22:00:23 +0000
commit52cad15d0b4443b763a7d41ec8d1131a7638f866 (patch)
tree67c5e00fd79130b1c49b93556152cf29480b3a58 /src/sksl/ir
parentc12551c1f3f34f50cd58b4e3fb0697c7fe40e8f0 (diff)
sksl support for geometry shaders
BUG=skia: Change-Id: I8541b98aadcf4c2484fef73e2f49be3ee38bc1e2 Reviewed-on: https://skia-review.googlesource.com/8409 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ir')
-rw-r--r--src/sksl/ir/SkSLLayout.h72
-rw-r--r--src/sksl/ir/SkSLProgram.h3
2 files changed, 70 insertions, 5 deletions
diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h
index 75650e271d..5e7ec4486b 100644
--- a/src/sksl/ir/SkSLLayout.h
+++ b/src/sksl/ir/SkSLLayout.h
@@ -19,6 +19,17 @@ namespace SkSL {
* layout (location = 0) int x;
*/
struct Layout {
+ enum Primitive {
+ kUnspecified_Primitive = -1,
+ kPoints_Primitive,
+ kLines_Primitive,
+ kLineStrip_Primitive,
+ kLinesAdjacency_Primitive,
+ kTriangles_Primitive,
+ kTriangleStrip_Primitive,
+ kTrianglesAdjacency_Primitive
+ };
+
// These are used by images in GLSL. We only support a subset of what GL supports.
enum class Format {
kUnspecified = -1,
@@ -79,7 +90,8 @@ struct Layout {
Layout(int location, int offset, int binding, int index, int set, int builtin,
int inputAttachmentIndex, bool originUpperLeft, bool overrideCoverage,
- bool blendSupportAllEquations, Format format, bool pushconstant)
+ bool blendSupportAllEquations, Format format, bool pushconstant, Primitive primitive,
+ int maxVertices, int invocations)
: fLocation(location)
, fOffset(offset)
, fBinding(binding)
@@ -91,7 +103,10 @@ struct Layout {
, fOverrideCoverage(overrideCoverage)
, fBlendSupportAllEquations(blendSupportAllEquations)
, fFormat(format)
- , fPushConstant(pushconstant) {}
+ , fPushConstant(pushconstant)
+ , fPrimitive(primitive)
+ , fMaxVertices(maxVertices)
+ , fInvocations(invocations) {}
Layout()
: fLocation(-1)
@@ -105,7 +120,10 @@ struct Layout {
, fOverrideCoverage(false)
, fBlendSupportAllEquations(false)
, fFormat(Format::kUnspecified)
- , fPushConstant(false) {}
+ , fPushConstant(false)
+ , fPrimitive(kUnspecified_Primitive)
+ , fMaxVertices(-1)
+ , fInvocations(-1) {}
SkString description() const {
SkString result;
@@ -158,6 +176,46 @@ struct Layout {
result += separator + "push_constant";
separator = ", ";
}
+ switch (fPrimitive) {
+ case kPoints_Primitive:
+ result += separator + "points";
+ separator = ", ";
+ break;
+ case kLines_Primitive:
+ result += separator + "lines";
+ separator = ", ";
+ break;
+ case kLineStrip_Primitive:
+ result += separator + "line_strip";
+ separator = ", ";
+ break;
+ case kLinesAdjacency_Primitive:
+ result += separator + "lines_adjacency";
+ separator = ", ";
+ break;
+ case kTriangles_Primitive:
+ result += separator + "triangles";
+ separator = ", ";
+ break;
+ case kTriangleStrip_Primitive:
+ result += separator + "triangle_strip";
+ separator = ", ";
+ break;
+ case kTrianglesAdjacency_Primitive:
+ result += separator + "triangles_adjacency";
+ separator = ", ";
+ break;
+ case kUnspecified_Primitive:
+ break;
+ }
+ if (fMaxVertices >= 0) {
+ result += separator + "max_vertices = " + to_string(fMaxVertices);
+ separator = ", ";
+ }
+ if (fInvocations >= 0) {
+ result += separator + "invocations = " + to_string(fInvocations);
+ separator = ", ";
+ }
if (result.size() > 0) {
result = "layout (" + result + ")";
}
@@ -175,7 +233,10 @@ struct Layout {
fOriginUpperLeft == other.fOriginUpperLeft &&
fOverrideCoverage == other.fOverrideCoverage &&
fBlendSupportAllEquations == other.fBlendSupportAllEquations &&
- fFormat == other.fFormat;
+ fFormat == other.fFormat &&
+ fPrimitive == other.fPrimitive &&
+ fMaxVertices == other.fMaxVertices &&
+ fInvocations == other.fInvocations;
}
bool operator!=(const Layout& other) const {
@@ -198,6 +259,9 @@ struct Layout {
bool fBlendSupportAllEquations;
Format fFormat;
bool fPushConstant;
+ Primitive fPrimitive;
+ int fMaxVertices;
+ int fInvocations;
};
} // namespace
diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h
index e4a975b279..2ca9372ec4 100644
--- a/src/sksl/ir/SkSLProgram.h
+++ b/src/sksl/ir/SkSLProgram.h
@@ -52,7 +52,8 @@ struct Program {
enum Kind {
kFragment_Kind,
- kVertex_Kind
+ kVertex_Kind,
+ kGeometry_Kind
};
Program(Kind kind,