From 8e6e884eca5b33218a8cb2714266fb6ed4548d75 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 8 Jun 2022 10:23:01 -0400 Subject: Actual global support (#2262) * #include an absolute path didn't work - because paths were taken to always be relative. * Use TerminatedUnownedStringSlice for literals in output C++. * Remove Escape/Unescape functions used in slang-token-reader.cpp Add target type of 'host-cpp' etc to map to the target types. * Fix some corner cases around string encoding. * Added unit test for string escaping. Fixed some assorted escaping bugs. * Updated test output. * Added decode test. * Stop using hex output, to get around 'greedy' aspect. Use octal instead. * Added HostHostCallable Small changes to use ArtifactDesc/Info instead of large switches. * Fix C++ emit to handle arbitrary function export. * Add options handling for callable without an output being specified. * Can compile with COM interface. Added example using com interface. * Use the IR Ptr type instead of hack in C++ emit for interfaces. * Fix issue with outputting the COM call when ptr is used. * Fix crash issue on compilation failure. * Add support for __global. * Added `ActualGlobalRate` Added special handling around globals and COM interfaces. Tested out in cpu-com-example. * Fix typo in NodeBase. * Support for accessing globals by name working. * Check that actual global initialization is working. * Refactor the com replacement such that it doesn't need a cache or do anything special with GlobalVar. * Remove context. Only create replacement if needed. * Split out COM host-callable into a unit-test. * host-callable com testing on C++and llvm. * Comment around the COM ptr replacement. * Disable com test on vs 32 bit. Fix C++ prelude * Disable 32 bit targets testing com host-callable. * Use JSON parsing to locate VS version. * Need platform detection in C++prelude. * Fix com host callable test for LLVM. * Work around for not being able to include "targetConditionals.h" --- examples/cpu-com-example/shader.slang | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'examples/cpu-com-example/shader.slang') diff --git a/examples/cpu-com-example/shader.slang b/examples/cpu-com-example/shader.slang index b0fe259be..44b1f5b81 100644 --- a/examples/cpu-com-example/shader.slang +++ b/examples/cpu-com-example/shader.slang @@ -1,6 +1,8 @@ // shader.slang -// Example of using 'NativeString' +// Example using 'NativeString' and COM interface + +public __global __extern_cpp IDoThings globalDoThings; public __extern_cpp NativeString getString(NativeString in) { @@ -12,10 +14,15 @@ interface IDoThings { int doThing(int a, int b); int calcHash(NativeString in); + void printMessage(NativeString nativeString); } -public __extern_cpp int calcHash(NativeString text, IDoThings doThings) +public __extern_cpp int calcHash(NativeString text) { - return doThings.calcHash(text); + return globalDoThings.calcHash(text); } +public __extern_cpp void printMessage(NativeString text) +{ + return globalDoThings.printMessage(text); +} -- cgit v1.2.3