summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index b1b9f6d80..c48eb7755 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -2723,5 +2723,41 @@ Module* getModule(Decl* decl)
return nullptr;
}
+bool findImageFormatByName(char const* name, ImageFormat* outFormat)
+{
+ static const struct
+ {
+ char const* name;
+ ImageFormat format;
+ } kFormats[] =
+ {
+#define FORMAT(NAME) { #NAME, ImageFormat::NAME },
+#include "image-format-defs.h"
+ };
+
+ for( auto item : kFormats )
+ {
+ if( strcmp(item.name, name) == 0 )
+ {
+ *outFormat = item.format;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+char const* getGLSLNameForImageFormat(ImageFormat format)
+{
+ switch( format )
+ {
+ default: return "unhandled";
+#define FORMAT(NAME) case ImageFormat::NAME: return #NAME;
+#include "image-format-defs.h"
+ }
+}
+
+
+
} // namespace Slang