summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-05-22 17:22:22 -0400
committerGitHub <noreply@github.com>2023-05-22 17:22:22 -0400
commit972a931452c3f06a23a4f67ccfb655851df53fa4 (patch)
tree309a75c5239af163e47bc0e123d023683c1ec74a /tests
parent33e15236c6fd8623bc516a194ca65e8810f1f855 (diff)
Source embedding for output (#2889)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix typo. * Add options for source embedding. * Small improvements. * Working with tests. * Add check for supported language types for embedding. * Try and remove assume warning. * Fix warning on MacOSX. * Some extra checking around Style::Text. * Some small improvements to docs/handling for headers extensions. * Fix md issue. * Small fixes around zeroing partial last element. * Another small fix.... * Small improvement in hex conversion. * Add an assert for unsignedness.
Diffstat (limited to 'tests')
-rw-r--r--tests/feature/source-embed/source-embed-1.slang44
-rw-r--r--tests/feature/source-embed/source-embed-2.slang45
-rw-r--r--tests/feature/source-embed/source-embed-3.slang45
-rw-r--r--tests/feature/source-embed/source-embed-4.slang45
4 files changed, 179 insertions, 0 deletions
diff --git a/tests/feature/source-embed/source-embed-1.slang b/tests/feature/source-embed/source-embed-1.slang
new file mode 100644
index 000000000..75b360a23
--- /dev/null
+++ b/tests/feature/source-embed/source-embed-1.slang
@@ -0,0 +1,44 @@
+//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style default
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// CHECK: const uint32_t data[] =
+// CHECK: 0x07230203, 0x00010000,
+// CHECK: const size_t data_sizeInBytes =
+
+int calcThing(int offset)
+{
+ int total = 0;
+ int another[2] = { 1, 2};
+
+ for (int k = 0; k < 20; ++k)
+ {
+ for (int i = 0; i < 17; ++i)
+ {
+ another[i & 1] += k + i;
+ }
+
+ total += another[k & 1];
+
+ if ((k + 7) % 5 == 4)
+ {
+ return 1;
+ }
+ }
+
+ if (total > 4)
+ {
+ total = -total;
+ }
+
+ return total;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = calcThing(index);
+}
diff --git a/tests/feature/source-embed/source-embed-2.slang b/tests/feature/source-embed/source-embed-2.slang
new file mode 100644
index 000000000..a4e4a75be
--- /dev/null
+++ b/tests/feature/source-embed/source-embed-2.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style binary-text -source-embed-name hello
+
+// CHECK: const char hello[] =
+// CHECK: const size_t hello_sizeInBytes =
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// Test loop handling, with more complex structure
+
+int calcThing(int offset)
+{
+ int total = 0;
+ int another[2] = { 1, 2};
+
+ for (int k = 0; k < 20; ++k)
+ {
+ for (int i = 0; i < 17; ++i)
+ {
+ another[i & 1] += k + i;
+ }
+
+ total += another[k & 1];
+
+ if ((k + 7) % 5 == 4)
+ {
+ return 1;
+ }
+ }
+
+ if (total > 4)
+ {
+ total = -total;
+ }
+
+ return total;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = calcThing(index);
+}
diff --git a/tests/feature/source-embed/source-embed-3.slang b/tests/feature/source-embed/source-embed-3.slang
new file mode 100644
index 000000000..9dc7cf324
--- /dev/null
+++ b/tests/feature/source-embed/source-embed-3.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=CHECK):-target dxil -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style u64 -source-embed-name hello64
+
+// CHECK: const uint64_t hello64[] =
+// CHECK: const size_t hello64_sizeInBytes =
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// Test loop handling, with more complex structure
+
+int calcThing(int offset)
+{
+ int total = 0;
+ int another[2] = { 1, 2};
+
+ for (int k = 0; k < 20; ++k)
+ {
+ for (int i = 0; i < 17; ++i)
+ {
+ another[i & 1] += k + i;
+ }
+
+ total += another[k & 1];
+
+ if ((k + 7) % 5 == 4)
+ {
+ return 1;
+ }
+ }
+
+ if (total > 4)
+ {
+ total = -total;
+ }
+
+ return total;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = calcThing(index);
+}
diff --git a/tests/feature/source-embed/source-embed-4.slang b/tests/feature/source-embed/source-embed-4.slang
new file mode 100644
index 000000000..d7324042e
--- /dev/null
+++ b/tests/feature/source-embed/source-embed-4.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=CHECK):-target glsl -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style default -source-embed-name z
+
+// CHECK: const char z[] =
+// CHECK: const size_t z_sizeInBytes =
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// Test loop handling, with more complex structure
+
+int calcThing(int offset)
+{
+ int total = 0;
+ int another[2] = { 1, 2};
+
+ for (int k = 0; k < 20; ++k)
+ {
+ for (int i = 0; i < 17; ++i)
+ {
+ another[i & 1] += k + i;
+ }
+
+ total += another[k & 1];
+
+ if ((k + 7) % 5 == 4)
+ {
+ return 1;
+ }
+ }
+
+ if (total > 4)
+ {
+ total = -total;
+ }
+
+ return total;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = calcThing(index);
+}