aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLUtil.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-03-31 09:33:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-31 15:25:32 +0000
commitf3333c89bf05fc602d9bf8e1e24547668c660383 (patch)
tree3c0855ef8829201299ce757ecaf28bfda50a2683 /src/sksl/SkSLUtil.h
parent66b09abdb184d843ece45a1d343fbe632075b323 (diff)
skslc can now be compiled with no Skia dependencies, in preparation for its eventual
role in Skia's build process. This reverts commit bcf35f86d50b784b165de703b404998dd4299f6a. BUG=skia: Change-Id: Id0a12dfc4d804d69a3c6bf60fed37e89ee130f02 Reviewed-on: https://skia-review.googlesource.com/10802 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/SkSLUtil.h')
-rw-r--r--src/sksl/SkSLUtil.h207
1 files changed, 161 insertions, 46 deletions
diff --git a/src/sksl/SkSLUtil.h b/src/sksl/SkSLUtil.h
index 678241d205..d1af9bb3c7 100644
--- a/src/sksl/SkSLUtil.h
+++ b/src/sksl/SkSLUtil.h
@@ -4,22 +4,159 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_UTIL
#define SKSL_UTIL
+#include <cstdarg>
+#include <memory>
#include "stdlib.h"
+#include "string.h"
#include "assert.h"
-#include "SkOpts.h"
-#include "SkRefCnt.h"
-#include "SkStream.h"
-#include "SkString.h"
-#include "SkTypes.h"
+#include "SkSLString.h"
+#include "SkSLStringStream.h"
+
+#ifndef SKSL_STANDALONE
#include "GrContextOptions.h"
#include "GrShaderCaps.h"
+#endif
+
+#ifdef SKSL_STANDALONE
+#if defined(_WIN32) || defined(__SYMBIAN32__)
+#define SKSL_BUILD_FOR_WIN
+#endif
+#else
+#ifdef SK_BUILD_FOR_WIN
+#define SKSL_BUILD_FOR_WIN
+#endif // SK_BUILD_FOR_WIN
+#endif // SKSL_STANDALONE
namespace SkSL {
+#ifdef SKSL_STANDALONE
+
+// we're being compiled standalone, so we don't have access to caps...
+enum GrGLSLGeneration {
+ k110_GrGLSLGeneration,
+ k130_GrGLSLGeneration,
+ k140_GrGLSLGeneration,
+ k150_GrGLSLGeneration,
+ k330_GrGLSLGeneration,
+ k400_GrGLSLGeneration,
+ k420_GrGLSLGeneration,
+ k310es_GrGLSLGeneration,
+ k320es_GrGLSLGeneration,
+};
+
+#define SKSL_CAPS_CLASS StandaloneShaderCaps
+class StandaloneShaderCaps {
+public:
+ GrGLSLGeneration generation() const {
+ return k400_GrGLSLGeneration;
+ }
+
+ bool canUseMinAndAbsTogether() const {
+ return true;
+ }
+
+ bool mustForceNegatedAtanParamToFloat() const {
+ return false;
+ }
+
+ bool shaderDerivativeSupport() const {
+ return true;
+ }
+
+ bool usesPrecisionModifiers() const {
+ return true;
+ }
+
+ bool mustDeclareFragmentShaderOutput() const {
+ return true;
+ }
+
+ bool fbFetchSupport() const {
+ return true;
+ }
+
+ bool fbFetchNeedsCustomOutput() const {
+ return false;
+ }
+
+ bool bindlessTextureSupport() const {
+ return false;
+ }
+
+ bool dropsTileOnZeroDivide() const {
+ return false;
+ }
+
+ bool flatInterpolationSupport() const {
+ return true;
+ }
+
+ bool noperspectiveInterpolationSupport() const {
+ return true;
+ }
+
+ bool multisampleInterpolationSupport() const {
+ return true;
+ }
+
+ bool sampleVariablesSupport() const {
+ return true;
+ }
+
+ bool sampleMaskOverrideCoverageSupport() const {
+ return true;
+ }
+
+ bool externalTextureSupport() const {
+ return true;
+ }
+
+ bool texelFetchSupport() const {
+ return true;
+ }
+
+ bool imageLoadStoreSupport() const {
+ return true;
+ }
+
+ bool mustEnableAdvBlendEqs() const {
+ return false;
+ }
+
+ bool mustEnableSpecificAdvBlendEqs() const {
+ return false;
+ }
+
+ bool canUseAnyFunctionInShader() const {
+ return false;
+ }
+
+ const char* shaderDerivativeExtensionString() const {
+ return nullptr;
+ }
+
+ const char* fragCoordConventionsExtensionString() const {
+ return nullptr;
+ }
+
+ const char* imageLoadStoreExtensionString() const {
+ return nullptr;
+ }
+
+ const char* versionDeclString() const {
+ return "";
+ }
+};
+
+extern StandaloneShaderCaps standaloneCaps;
+
+#else
+
+#define SKSL_CAPS_CLASS GrShaderCaps
// Various sets of caps for use in tests
class ShaderCapsFactory {
public:
@@ -98,60 +235,38 @@ public:
return result;
}
};
+#endif
-void write_data(const SkData& d, SkWStream& out);
-
-SkString operator+(const SkString& s, const char* c);
-
-SkString operator+(const char* c, const SkString& s);
-
-SkString operator+(const SkString& s1, const SkString& s2);
-
-bool operator==(const SkString& s1, const char* s2);
-
-bool operator!=(const SkString& s1, const char* s2);
-
-bool operator!=(const char* s1, const SkString& s2);
-
-SkString to_string(double value);
-
-SkString to_string(int32_t value);
-
-SkString to_string(uint32_t value);
-
-SkString to_string(int64_t value);
-
-SkString to_string(uint64_t value);
+void write_stringstream(const StringStream& d, OutputStream& out);
#if _MSC_VER
#define NORETURN __declspec(noreturn)
#else
#define NORETURN __attribute__((__noreturn__))
#endif
-int stoi(SkString s);
-
-double stod(SkString s);
-
-long stol(SkString s);
NORETURN void sksl_abort();
} // namespace
-#define ASSERT(x) SkASSERT(x)
-#define ASSERT_RESULT(x) SkAssertResult(x);
+#ifdef SKSL_STANDALONE
+#define ASSERT(x) (void)((x) || (ABORT("failed assert(%s): %s:%d\n", #x, __FILE__, __LINE__), 0))
+#define ASSERT_RESULT(x) ASSERT(x)
+#define SKSL_DEBUGCODE(x) x
+#else
+#define ASSERT SkASSERT
+#define ASSERT_RESULT(x) SkAssertResult(x)
+#define SKSL_DEBUGCODE(x) SkDEBUGCODE(x)
+#endif
-#ifdef SKIA
-#define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); }
+#define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+
+#if defined(__clang__) || defined(__GNUC__)
+#define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
#else
-#define ABORT(...) { sksl_abort(); }
+#define SKSL_PRINTF_LIKE(A, B)
#endif
-namespace std {
- template<> struct hash<SkString> {
- size_t operator()(const SkString& s) const {
- return SkOpts::hash_fn(s.c_str(), s.size(), 0);
- }
- };
-}
+#define ABORT(...) (printf(__VA_ARGS__), sksl_abort())
+
#endif