Reland image storage with fixes.
Revert "Revert "Initial OpenGL Image support.""
This reverts commit 59dc41175d99d0a31c046aec0c26c4d82a3a3574.
BUG=skia:
Change-Id: Ibe3c87ce7f746f065fdbcc5a518388cc291112f5
Reviewed-on: https://skia-review.googlesource.com/5131
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 4ecab9c..51dccc5 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -34,6 +34,8 @@
kBufferSampler_GrSLType,
kTexture2D_GrSLType,
kSampler_GrSLType,
+ kImageStorage2D_GrSLType,
+ kIImageStorage2D_GrSLType,
};
enum GrShaderType {
@@ -103,6 +105,8 @@
case kUint_GrSLType:
case kTexture2D_GrSLType:
case kSampler_GrSLType:
+ case kImageStorage2D_GrSLType:
+ case kIImageStorage2D_GrSLType:
return false;
}
SkFAIL("Unexpected type");
@@ -131,6 +135,8 @@
case kBool_GrSLType:
case kTexture2D_GrSLType:
case kSampler_GrSLType:
+ case kImageStorage2D_GrSLType:
+ case kIImageStorage2D_GrSLType:
return false;
}
SkFAIL("Unexpected type");
@@ -159,6 +165,38 @@
case kBool_GrSLType:
case kTexture2D_GrSLType:
case kSampler_GrSLType:
+ case kImageStorage2D_GrSLType:
+ case kIImageStorage2D_GrSLType:
+ return false;
+ }
+ SkFAIL("Unexpected type");
+ return false;
+}
+
+static inline bool GrSLTypeIsImageStorage(GrSLType type) {
+ switch (type) {
+ case kImageStorage2D_GrSLType:
+ case kIImageStorage2D_GrSLType:
+ return true;
+
+ case kVoid_GrSLType:
+ case kFloat_GrSLType:
+ case kVec2f_GrSLType:
+ case kVec3f_GrSLType:
+ case kVec4f_GrSLType:
+ case kMat22f_GrSLType:
+ case kMat33f_GrSLType:
+ case kMat44f_GrSLType:
+ case kInt_GrSLType:
+ case kUint_GrSLType:
+ case kBool_GrSLType:
+ case kTexture2D_GrSLType:
+ case kSampler_GrSLType:
+ case kTexture2DSampler_GrSLType:
+ case kITexture2DSampler_GrSLType:
+ case kTextureExternalSampler_GrSLType:
+ case kTexture2DRectSampler_GrSLType:
+ case kBufferSampler_GrSLType:
return false;
}
SkFAIL("Unexpected type");
@@ -183,6 +221,8 @@
case kBufferSampler_GrSLType:
case kTexture2D_GrSLType:
case kSampler_GrSLType:
+ case kImageStorage2D_GrSLType:
+ case kIImageStorage2D_GrSLType:
return true;
case kVoid_GrSLType:
@@ -300,6 +340,40 @@
//////////////////////////////////////////////////////////////////////////////
+enum class GrImageStorageFormat {
+ kRGBA8,
+ kRGBA8i,
+ kRGBA16f,
+ kRGBA32f,
+};
+
+/**
+ * Describes types of caching and compiler optimizations allowed for certain variable types
+ * (currently only image storages).
+ **/
+enum class GrSLMemoryModel {
+ /** No special restrctions on memory accesses or compiler optimizations */
+ kNone,
+ /** Cache coherent across shader invocations */
+ kCoherent,
+ /**
+ * Disallows compiler from eliding loads or stores that appear redundant in a single
+ * invocation. Implies coherent.
+ */
+ kVolatile
+};
+
+/**
+ * If kYes then the memory backing the varialble is only accessed via the variable. This is
+ * currently only used with image storages.
+ */
+enum class GrSLRestrict {
+ kYes,
+ kNo,
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
/**
* We have coverage effects that clip rendering to the edge of some geometric primitive.
* This enum specifies how that clipping is performed. Not all factories that take a