summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/modules
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-12-08 16:10:27 -0800
committerGitHub <noreply@github.com>2023-12-08 16:10:27 -0800
commit12fcffaaaf2d1ffa2eefa680e2d7c9971e38a5db (patch)
treefab26218d438d6d6057eab2d3548a72561c18fae /tests/language-feature/modules
parent4321929879c1ed5b87ff95a99ca7da91e28d18fd (diff)
Handle import, entrypoint and global params in included files. (#3395)
* Handle `import`, entrypoint and global params in included files. * Fix language server. * Extend `_createScopeForLegacyLookup` for `__include`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature/modules')
-rw-r--r--tests/language-feature/modules/import-in-include/a.slang3
-rw-r--r--tests/language-feature/modules/import-in-include/b.slang14
-rw-r--r--tests/language-feature/modules/import-in-include/c.slang14
-rw-r--r--tests/language-feature/modules/import-in-include/helper.slang6
4 files changed, 37 insertions, 0 deletions
diff --git a/tests/language-feature/modules/import-in-include/a.slang b/tests/language-feature/modules/import-in-include/a.slang
new file mode 100644
index 000000000..e8bcd3ae8
--- /dev/null
+++ b/tests/language-feature/modules/import-in-include/a.slang
@@ -0,0 +1,3 @@
+implementing c;
+
+import helper;
diff --git a/tests/language-feature/modules/import-in-include/b.slang b/tests/language-feature/modules/import-in-include/b.slang
new file mode 100644
index 000000000..6d8ba30d5
--- /dev/null
+++ b/tests/language-feature/modules/import-in-include/b.slang
@@ -0,0 +1,14 @@
+implementing c;
+
+int f()
+{
+ return helperFunc();
+}
+
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ outputBuffer[0] = f();
+}
diff --git a/tests/language-feature/modules/import-in-include/c.slang b/tests/language-feature/modules/import-in-include/c.slang
new file mode 100644
index 000000000..5ff5e7ed6
--- /dev/null
+++ b/tests/language-feature/modules/import-in-include/c.slang
@@ -0,0 +1,14 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
+
+// Test that a module imported from an __include'd file can be used from other files
+// in the same module, and that entry points and global parameters defined in an
+// included file can be correctly discovered by the reflection API.
+
+module c;
+
+__include b; // uses helper module.
+__include a; // imports helper module.
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+//CHECK: 1
diff --git a/tests/language-feature/modules/import-in-include/helper.slang b/tests/language-feature/modules/import-in-include/helper.slang
new file mode 100644
index 000000000..92c1bfb96
--- /dev/null
+++ b/tests/language-feature/modules/import-in-include/helper.slang
@@ -0,0 +1,6 @@
+module helper;
+
+public int helperFunc()
+{
+ return 1;
+}