summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-syntax.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-15 10:52:55 -0400
committerGitHub <noreply@github.com>2021-05-15 10:52:55 -0400
commit1027225ac7ec8da0e471b633f358333c8a95b010 (patch)
tree39575cd03fed47dffb56d7ca0ec7eff3385d1407 /source/slang/slang-syntax.cpp
parent1856b8ad85266ed66985b42bd2321a35f8573a00 (diff)
Support for HW format conversions for RWTexture on CUDA (#1840)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix for writing to RWTexture with half types on CUDA. * CUDA half functionality doc updates. * First pass support for sust.p RWTexture format conversion on write. * Tidy up implementation of $C. Made clamping mode #define able. * A simple test for RWTexture CUDA format conversion.
Diffstat (limited to 'source/slang/slang-syntax.cpp')
-rw-r--r--source/slang/slang-syntax.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index d5f2c13db..6b2140056 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -1186,38 +1186,40 @@ Module* getModule(Decl* decl)
return moduleDecl->module;
}
-bool findImageFormatByName(char const* name, ImageFormat* outFormat)
+static const ImageFormatInfo kImageFormatInfos[] =
{
- static const struct
- {
- char const* name;
- ImageFormat format;
- } kFormats[] =
- {
-#define FORMAT(NAME) { #NAME, ImageFormat::NAME },
+#define SLANG_IMAGE_FORMAT_INFO(TYPE, COUNT, SIZE) SLANG_SCALAR_TYPE_##TYPE, uint8_t(COUNT), uint8_t(SIZE)
+#define FORMAT(NAME, OTHER) \
+ { SLANG_IMAGE_FORMAT_INFO OTHER, UnownedStringSlice::fromLiteral(#NAME) },
#include "slang-image-format-defs.h"
- };
+#undef FORMAT
+#undef SLANG_IMAGE_FORMAT_INFO
+};
- for( auto item : kFormats )
+bool findImageFormatByName(char const* inName, ImageFormat* outFormat)
+{
+ const UnownedStringSlice name(inName);
+
+ for (Index i = 0; i < SLANG_COUNT_OF(kImageFormatInfos); ++i)
{
- if( strcmp(item.name, name) == 0 )
+ const auto& info = kImageFormatInfos[i];
+ if (info.name == name)
{
- *outFormat = item.format;
+ *outFormat = ImageFormat(i);
return true;
}
}
-
return false;
}
char const* getGLSLNameForImageFormat(ImageFormat format)
{
- switch( format )
- {
- default: return "unhandled";
-#define FORMAT(NAME) case ImageFormat::NAME: return #NAME;
-#include "slang-image-format-defs.h"
- }
+ return kImageFormatInfos[Index(format)].name.begin();
}
+ const ImageFormatInfo& getImageFormatInfo(ImageFormat format)
+ {
+ return kImageFormatInfos[Index(format)];
+ }
+
} // namespace Slang