summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-07-15 10:11:39 +0000
committerGitHub <noreply@github.com>2025-07-15 10:11:39 +0000
commitd964555d2ee83fac2ba357e4ec81e2a393a7b12f (patch)
tree2ae1591535f39a75c8231e2cf56b6492d330c820 /tests
parent66d915ac8ec6ab31320c8dbbb43027b33e3a69fd (diff)
Replace [KnownBuiltin] string-based comparisons with enum-based system (#7714)
* Initial plan * Implement enum-based KnownBuiltin system to replace string comparisons Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add test for enum-based KnownBuiltin system and verify functionality Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Implement enum-based KnownBuiltin system with direct integer values Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix IntVal access and update tests for new enum-based KnownBuiltin system Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Replace hardcoded KnownBuiltin integers with preprocessor enum syntax - Updated all KnownBuiltin attributes to use $( (int)KnownBuiltinDeclName::EnumValue) syntax - Added space between parentheses to avoid preprocessor bug: $( (int) instead of $((int) - Updated both core.meta.slang and hlsl.meta.slang files - Eliminates preprocessor-time integer conversion, baking enum values directly into meta files - Maintains same functionality while using type-safe enum references Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix IDifferentiablePtr KnownBuiltin mapping regression Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unused IDifferentiablePtrType enum case from KnownBuiltinDeclName Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Clean up temporary AST dump files from testing Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Replace hardcoded integer with descriptive constant in KnownBuiltin test Replace the hardcoded [KnownBuiltin(0)] with a descriptive named constant GEOMETRY_STREAM_APPEND_BUILTIN to improve code readability and maintainability. The test now clearly indicates which builtin enum value is being tested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com> Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-4131.slang2
-rw-r--r--tests/language-feature/known-builtin-enum-test.slang22
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/bugs/gh-4131.slang b/tests/bugs/gh-4131.slang
index d72bc5d0d..59eaff868 100644
--- a/tests/bugs/gh-4131.slang
+++ b/tests/bugs/gh-4131.slang
@@ -16,7 +16,7 @@ StructuredBuffer<TypeB> b_buffer : register(t0, space0);
struct VertexIn {
int32_t vert_idx : SV_VertexID;
- [[KnownBuiltin("DrawIndex")]]
+ [[KnownBuiltin(0)]]
uint32_t draw_idx : POSITION0;
};
diff --git a/tests/language-feature/known-builtin-enum-test.slang b/tests/language-feature/known-builtin-enum-test.slang
new file mode 100644
index 000000000..cf2c9c63e
--- /dev/null
+++ b/tests/language-feature/known-builtin-enum-test.slang
@@ -0,0 +1,22 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<float> outputBuffer;
+
+// Test that KnownBuiltin attribute works with enum-based system
+// Using GeometryStreamAppend enum value (0) for testing
+static const int GEOMETRY_STREAM_APPEND_BUILTIN = 0;
+
+[KnownBuiltin(GEOMETRY_STREAM_APPEND_BUILTIN)]
+void testKnownBuiltin()
+{
+ // This function just needs to exist to test attribute processing
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // Simple test that the code compiles and runs
+ outputBuffer[0] = 42.0f;
+ // CHECK: 42.0
+} \ No newline at end of file