summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2025-07-31Handle debug-layer messages in a separate channel (#7988)Jay Kwak
* Handle debug-layer messages in a separate channel The Problem (Issue #7343) The issue was that Vulkan Validation Layer error messages were being mixed into regular test output, causing potential false positives or negatives. When using -enable-debug-layers true, validation messages would appear in the same output stream as test results, potentially matching //CHECK: patterns incorrectly. Example Problem: - Test expects: //CHECK: 1 - Validation layer prints: VALIDATION ERROR: 1 invalid buffer binding - Test incorrectly matches the "1" in the error message instead of the actual output Slang Test Communication Architecture Execution Modes Slang has 3 different execution modes controlled by SpawnType: enum class SpawnType { UseSharedLibrary, // In-process execution UseTestServer, // Out-of-process via persistent server UseFullyIsolatedTestServer, // Out-of-process via isolated server UseExe // Direct executable spawn } 1. In-Process Mode (UseSharedLibrary) ┌─────────────────────────────────────────┐ │ slang-test │ │ ┌─────────────┐ ┌─────────────────┐ │ │ │render-test │ │gfx-unit-test │ │ │ │unit-test │ │slangc library │ │ │ └─────────────┘ └─────────────────┘ │ │ │ │ │ │ └───► StdWriters ◄──┘ │ │ (shared) │ └─────────────────────────────────────────┘ - Communication: Direct function calls, shared memory - Debug callbacks: Single callback instance in StdWriters - Used when: Default mode for most tests 2. Out-of-Process Mode (UseTestServer) ┌──────────────────┐ JSON-RPC ┌──────────────────┐ │ slang-test │◄──over pipes────┤ test-server.exe │ │ │ │ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │ │ │StdWriters │ │ │ │render-test │ │ │ │+debug │ │ │ │gfx-unit-test│ │ │ │callback │ │ │ │+debug │ │ │ └─────────────┘ │ │ │callback │ │ └──────────────────┘ │ └─────────────┘ │ └──────────────────┘ - Communication: JSON-RPC over stdin/stdout pipes - Debug callbacks: Separate instances in each process - Used when: CI/CD, multi-threaded testing, crash isolation 3. Direct Executable Mode (UseExe) ┌──────────────────┐ pipes ┌──────────────────┐ │ slang-test │◄───────────────┤ slangc.exe │ │ │ │ other tools │ └──────────────────┘ └──────────────────┘ - Communication: Standard process pipes (stdout/stderr) - Debug callbacks: None (external executables) - Used when: Testing external tools Communication Mechanisms Deep Dive JSON-RPC Protocol Over Pipes The test-server.exe communicates with slang-test using JSON-RPC over stdin/stdout pipes: // Parent process (slang-test) creates child with pipes Process* testServerProcess = /* spawn test-server.exe */; // JSONRPCConnection wraps the pipe communication JSONRPCConnection connection; connection.initWithStdStreams(); // Uses stdin/stdout pipes // Send RPC call TestServerProtocol::ExecutionResult result; connection.sendCall("executeTool", &args, &result); Key Point: The pipes carry structured JSON messages, not raw stdout/stderr. This is what enables clean separation of different data channels. Protocol Structure Your changes extend the ExecutionResult protocol: struct ExecutionResult { String stdOut; // Regular program output String stdError; // Error messages String debugLayer; // NEW: Debug/validation messages int32_t result; int32_t returnCode; }; Your Debug Layer Solution The Challenge Memory pointers cannot cross process boundaries. A debugCallback pointer in the parent process is meaningless in the child process. The Solution: String-Based Serialization You solved this by using string capture and serialization: 1. Debug Callback Interface (slang-std-writers.h) class IDebugCallback { virtual void handleMessage( DebugMessageType type, DebugMessageSource source, const char* message) = 0; }; 2. String-Capturing Implementation (slang-support.h) class CoreDebugCallback : public Slang::IDebugCallback { StringBuilder m_buf; // Captures messages as strings void handleMessage(DebugMessageType type, DebugMessageSource source, const char* message) { if (type == DebugMessageType::Error) { m_buf << message << '\n'; // Serialize to string } } String getString() { return m_buf.toString(); } // Extract accumulated messages }; 3. Bridge Between RHI and Core (slang-support.h) class CoreToRHIDebugBridge : public rhi::IDebugCallback { Slang::IDebugCallback* m_coreCallback; void handleMessage(rhi::DebugMessageType type, rhi::DebugMessageSource source, const char* message) { // Convert RHI types to core types and forward m_coreCallback->handleMessage(convertType(type), convertSource(source), message); } }; Data Flow: Debug Messages End-to-End In-Process Mode Flow GPU Driver → RHI Debug Callback → Core Debug Callback → String Buffer → Test Output Out-of-Process Mode Flow Child Process: GPU Driver → RHI Debug Callback → Core Debug Callback → String Buffer ↓ Parent Process: JSON-RPC Serialization Test Output ← String Processing ← ExecutionResult.debugLayer ←┘ Step-by-Step Example 1. Test Execution Starts // In test-server process CoreDebugCallback debugCallback; CoreToRHIDebugBridge bridge; bridge.setCoreCallback(&debugCallback); // Set up graphics device with debug layers deviceDesc.debugCallback = &bridge; 2. Graphics API Call Triggers Validation Error // Inside Vulkan driver (external code) // Validation layer detects error and calls our callback bridge.handleMessage(RHI_ERROR, RHI_LAYER, "Invalid buffer binding"); 3. Message Capture // In CoreDebugCallback::handleMessage m_buf << "Invalid buffer binding\n"; // Stored in string buffer 4. Test Completion & Serialization // Back in test-server TestServerProtocol::ExecutionResult result; result.debugLayer = debugCallback.getString(); // "Invalid buffer binding\n" result.stdOut = "1"; // Regular test output // Send via JSON-RPC connection.sendResult(&result); 5. Parent Process Receives & Separates Output // In slang-test process String output = buildTestOutput(result); // Results in clean separation: // standard output = { // 1 // } // debug layer = { // Invalid buffer binding // } Why This Solution Works 1. Process Isolation: Each process has its own callback objects, no shared pointers 2. String Serialization: Debug messages converted to strings that can cross process boundaries 3. Protocol Extension: Uses existing JSON-RPC infrastructure, just adds new field 4. Clean Separation: Debug messages never mix with stdout/stderr 5. Backward Compatibility: Existing tests unaffected, debug layer field optional Key Benefits - Eliminates False Positives: Debug messages can't interfere with //CHECK: patterns - Better Debugging: Debug messages clearly separated and labeled - Robust Architecture: Works across all execution modes - Minimal Changes: Leverages existing communication infrastructure This elegant solution transforms a fundamental cross-process communication challenge into a simple string serialization problem, using the existing test server architecture to cleanly separate validation layer messages from test results. * Cover the missing slang-test execution path * format code (#82) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-31Fix bug in ci test (#8005)Jay Kwak
This commit fixes two problems. 1. uninitialized file handle for lock-file test 2. uninitialized static variable for lock-file test The first bug is more of speculartive rather than actual bug. The second bug was causing heap corruption when it was retried, because the counter was not reset to zero on "retry" and it wrote data to an invalida range in an array.
2025-07-31msvc style bitfield packing (#7963)Ellie Hermaszewska
Closes https://github.com/shader-slang/slang/issues/3646 New tests rather than just adding another TEST line to existing tests so that we get the msvc- prefix in the output of slang-test
2025-07-30disallow `static const` variables without default-value (#7993)ArielG-NV
* Fix static const variables without initializers causing internal errors Add validation in SemanticsDeclHeaderVisitor::checkVarDeclCommon to detect static const variables without initializers and emit proper error diagnostics instead of allowing internal errors to escape during SPIR-V generation. - Add new diagnostic (ID 31225) for static const variables without initializers - Skip validation for extern static const variables - Skip validation for interface member variables - Add comprehensive test case covering various scenarios Fixes #7989 Co-authored-by: ArielG-NV <ArielG-NV@users.noreply.github.com> * clean up test and implementation * format code (#7994) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ArielG-NV <ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-30[Language Server]: Don't eagerly check file upon open doc. (#7995)Yong He
2025-07-30Lowering unsupported matrix types for GLSL/WGSL/Metal targets (#7936)venkataram-nv
* Add emit cases for WGSL and GLSL * Fix compilation warnings Modify short cutting test to reflect change in emit logic Lower matrix for metal as well Add emit matrix logic for metal Fix compiler warning Brace initializer for lowered matrices Fix compiler warnings * Tests for metal * Fix mult, any, and determinant * Fix matrix-matrix multiplication * Fix mat mul to be element-wise * Fix compiler warning * Move makeMatrix to legalization * Move unary and binary arithmetic operator lowering to legalization * Remove emit logic and move final comparison operators to legalization * Handle vector/matrix negation for WGSL * Restore older SPIR-V emit logic * Address PR comments * Revert to zero minus for negation * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-29Fix ICE when immutable value is passed to a bwd_diff function. (#7973)Yong He
2025-07-29Fix Metal invalid as_type cast for 64-bit RWByteAddressBuffer.Store values ↵Gangzheng Tong
(#7843) * Fix 64-bit val lowering for metal * Add ByteAddressBuffer load/store 64-bit tests * Handle Store/Load ptr types * Use bitcast for non-pointer typers * format code (#7966) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-29Fix slang-no-embedded-core-module-source embedding core module (#7885)Julius Ikkala
2025-07-29Invoke `clang++` on C++ code instead of `clang` (#7958)Sam Estep
2025-07-29[Language Server]: Show signature help on generic parameters. (#7913)Yong He
* Show signature help on generic parameters. * Fix. * Update tests. * slang-test: make vvl error go through stderr. * update slang-rhi * Update slang-rhi
2025-07-29Detect uses of uninitialized resource fields (#7962)Ellie Hermaszewska
Closes https://github.com/shader-slang/slang/issues/3386
2025-07-29Improve diagnostics over ambiguous references. (#7930)Yong He
* Improve diagnostics over ambiguous references. * Fix. * Remove files. * Fix some optix hitobject intrinsics. * Fix some hitobject intrinsics for optix. * Fix. * update rhi * revert slang-rhi * Update slang-rhi
2025-07-29Fix CUDA backend missing U32_firstbitlow implementation (#7921)Copilot
* Initial plan * Add U32_firstbitlow implementation for CUDA and CPP backends Co-authored-by: bmillsNV <163073245+bmillsNV@users.noreply.github.com> * Add I32_firstbitlow and comprehensive testing for signed/unsigned firstbitlow Co-authored-by: bmillsNV <163073245+bmillsNV@users.noreply.github.com> * Convert firstbitlow test to use inline filecheck syntax Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Add U32_firstbithigh and I32_firstbithigh implementations for CUDA and CPP backends Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update prelude/slang-cpp-scalar-intrinsics.h * Update prelude/slang-cpp-scalar-intrinsics.h * Update prelude/slang-cpp-scalar-intrinsics.h * Refactor Metal bit intrinsics to handle zero case correctly Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Update slang-cuda-prelude.h remove fake links * Update hlsl.meta.slang * if -1, return -1 due to implicit hlsl rule * -1 or 0 is ~0u as per hlsl implictly * 0 or -1 as per hlsl * fix the math to map to hlsl * fix compile error * forgot `31 - clz` * format code (#7943) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Update source/slang/hlsl.meta.slang * Update source/slang/hlsl.meta.slang * Update source/slang/hlsl.meta.slang * Update source/slang/hlsl.meta.slang --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bmillsNV <163073245+bmillsNV@users.noreply.github.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: ArielG-NV <aglasroth@nvidia.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-28Fix issue in multi-level break elimination by handling multi-level continue ↵Sai Praveen Bangaru
statements (#7953)
2025-07-28Update slang-rhi to fix CI error on debug. (#7946)Yong He
* Update slang-rhi * Fix profile lookup on `nullptr`. * update rhi
2025-07-25Fix mesh shader reflection JSON output (#7868)pdeayton-nv
* Fix mesh shader reflection JSON output Fixes issue #7736 where mesh shaders were showing stage "UNKNOWN" and missing type information in reflection JSON output. Changes: - Add missing SLANG_STAGE_MESH and SLANG_STAGE_AMPLIFICATION cases to shader stage switch statements in emitReflectionVarBindingInfoJSON and emitReflectionEntryPointJSON - Add missing MeshOutput to TypeReflection::Kind enum in slang.h - Add missing type kind cases (OutputStream, MeshOutput, Specialized, None) to emitReflectionTypeInfoJSON Testing: - Simple mesh shader now correctly shows "stage": "mesh" instead of "UNKNOWN" - Complex mesh shader with parameters shows proper stage and input type information - Output parameters show "kind": "None" instead of crashing with assertion 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> * Remove test files from mesh shader reflection fix As requested, removed test files since there is no testing infrastructure for reflection JSON output. Focus is now only on the core mesh and amplification shader reflection fixes. Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> * Address review comments: move MeshOutput enum to end and restore assert - Move MeshOutput enum member to end of TypeReflection::Kind enum for backward compatibility - Replace fprintf with SLANG_ASSERT for unhandled type kinds Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-07-25Fix nv_viewport_mask semantic to emit SpvBuiltInViewportMaskNV (#7904)davli-nv
Fixes #7903 SPV_NV_viewport_array2 says ViewportMaskNV corresponds to gl_ViewportMask
2025-07-25Fix for Generic Function Redefinition Error (#7891)Gangzheng Tong
* emit literal values in getTypeNameHint for bool, str etc. * add test for specializing generics with bool literals * fix build error * add specializing with Enum type test
2025-07-25Add combined texture-sampler flag to reflection API to differentiate ↵Copilot
Texture2D from Sampler2D (#7901) * Initial plan * Add SLANG_TEXTURE_COMBINED_FLAG to differentiate combined texture-samplers Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix regression in hlsl-to-vulkan-combined test by updating expected output Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-25Fix compiler crash when enum is used as vertex output data (#7915)Copilot
* Initial plan * Initial investigation and plan for enum vertex output fix Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix compiler crash when enum is used as vertex output data Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix compiler crash when enum is used as vertex output data Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address reviewer feedback: use SLANG_ASSERT and improve CHECK directives Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-25Fix SPIRV OpMemberName member indices (#7912)davli-nv
OpMemberName instructions were all using member index 0 instead of incrementing indices (0, 1, 2, ...) as required by the SPIR-V spec. The bug was that the member index increment (id++) was only happening for physical struct types, but OpMemberName emission occurs for all struct types when they have name decorations. This fix ensures member indices are properly incremented for both physical and non-physical struct types. Fixes #7909 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: davli-nv <davli-nv@users.noreply.github.com>
2025-07-25Fix metallib-asm target parsing by adding missing comma (#7902)Jay Kwak
* Fix metallib-asm target parsing by adding missing comma The metallib-asm target was not being recognized from command line because of a syntax error in the target string definition in slang-type-text-util.cpp. A missing comma after the first "metallib-asm" string caused C++ string literal concatenation to create a malformed string. Resolves #7774 Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> * format code (#7910) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * regenerate command line reference (#7911) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: Claude Code <claude@anthropic.com> Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-24Avoid early specialization for witness tables in SimplifyIR (#7636)Jay Kwak
* Avoid early specialization for witness tables in SimplifyIR Prevents SimplifyIR from prematurely specializing witness tables before the main specialization pass. Witness tables are hoistable immutable objects that must maintain consistent signatures to avoid incorrect deduplication. SimplifyIR was incorrectly transforming expressions like "witness_table_t(%IFoo)(specialize(%7, %GenericValue4))" into "witness_table_t(%IFoo)(%Foo)" even when %GenericValue4 was unused. Fixes #7233 * Add a missing test file
2025-07-24Organize code better by splitting some big files (#7890)Theresa Foley
* Organize code better by splitting some big files The basic change here is that the majority of the declarations in `slang-compiler.h` have been split out into a set of smaller and more focused files. As a result, the implement of those declarations have been moved from `slang-compiler.cpp` and `slang.cpp` over to those new files when the proper home for code is obvious. I have tried as much as possible to *not* make any edits to the code along the way, and just copy-paste declarations from one place to another as-is. The exceptions I am aware of are: * In some cases a function that used to be file-scope `static` was used by code that landed in two or more different `.cpp` files. In these cases, I changed the function to be non-`static` (removing the `_` prefix from its name, if it had one, per our naming conventions), and put a declaration for the function into the most appropriate header I could identify. * I added a few comments in places where I saw ugly or unfortunate things in the code I was moving, and wanted to tag them with `TODO`s so we can hopefully get to them in the fullness of time. * I added top-level comments to each of the new `.h` files that was introduced to try to explain the logic for what goes into that file. * In cases where one of the new header files mostly existed to declare a single type, I sometimes added more detail to the doc comment on that type, to better explain the type and its role in the compiler (this is text that otherwise might have gone into the comment at the top leve lof the file, but I figured that the doc comment would have higher discoverability). I expect that the most contentious choice here is that the `Session` class lands in `slang-global-session.h` while `slang-session.h` holds the `Linkage` class. The names used in this change are consistent with how the relevant concepts in the public Slang API are named, and are consistent with how we *intend* to rename the classes themselves in time. * format code * fixup --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-24Fix confusing error messages for interface return type mismatches (#7854)Copilot
* Initial plan * Add improved diagnostic for interface return type mismatches Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Complete fix for interface return type mismatch error reporting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move diagnostic to synthesis phase for better interface return type mismatch errors Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove extraneous test file and update .gitignore Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add diagnostic test for interface return type mismatch and apply formatting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: restore whitespace and use filecheck for diagnostic test Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix logic error in return type mismatch detection Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unnecessary flag by using out parameter for diagnostic tracking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Refactor witness synthesis failure reporting to use structured approach Replace ad-hoc `outSpecificDiagnosticEmitted` parameter with `WitnessSynthesisFailureReason` enum and `MethodWitnessSynthesisFailureDetails` struct as requested in code review. This provides: - Clear taxonomy of failure reasons (General, MethodResultTypeMismatch, MethodParameterMismatch) - Centralized diagnostic emission in findWitnessForInterfaceRequirement - Better extensibility for future failure types - Improved maintainability by removing state tracking flags The return type mismatch diagnostic continues to work correctly, showing error 38106 with precise location information. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unused MethodParameterMismatch enum and duplicate code Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove redundant requiredMethod field from MethodWitnessSynthesisFailureDetails Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: add outFailureDetails guard and remove unnecessary hasReturnTypeError variable Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix regression: restore original diagnostic message for mutating method mismatch Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix. * Fix. * Remove `innerSink`. * Print candidates considered for interface match upon error. * Fix tests. --------- 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: Yong He <yonghe@outlook.com>
2025-07-24Include Inst UID in some assert failure messages. (#7882)Yong He
2025-07-24Skip creating transitive witnesses for interface conformances that are ↵aidanfnv
inherited through structs (#7597) * Eliminate null-pointer reference in multilevel struct interface inheritance * Add test * Replace witness nullptr guard with conformance check to skip the witness * Update test * Skip creating transitive witness entirely for struct-struct-interface * format code (#14) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Removes casts, check for identity witness --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-24Document how to use LLDB in the Slang codebase (#7809)Sam Estep
* Document how to use LLDB in the Slang codebase * Include `slang_lldb.py` in `.lldbinit` * Switch from GCC to Clang * Include a VS Code task to build before debugging * Fix clangd
2025-07-23Add LLDB data formatters for Slang IR (#7828)Sam Estep
2025-07-23fix #7869 (#7871)ArielG-NV
2025-07-22Fix visibility of synthesized Differential typedefs. (#7865)Yong He
* Fix visibility of synthesized `Differential` typedefs. * Delete incorrect test.
2025-07-22Fix public unscoped enum constants not visible across module boundaries (#7864)Copilot
* Initial plan * Fix public unscoped enum constants visibility across module boundaries Add visibility modifier copying in CompleteDecl for unscoped enum cases. When synthesizing static const declarations for unscoped enum cases, copy the visibility modifiers from the original enum declaration to ensure they have the same visibility scope across module boundaries. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Create new visibility modifier instances instead of sharing existing ones Address reviewer feedback to avoid sharing modifier instances between declarations since modifiers form a linked list. Now creates new instances of the appropriate visibility modifier type (Public, Private, or Internal) instead of reusing the existing instance. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move unscoped enum visibility tests into subdirectory structure Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Use createByNodeType for visibility modifier creation as suggested Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * format code (#7867) Co-authored-by: slangbot <186143334+slangbot@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: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-22Fix scalar to array conversion for tessellation factors (#7837)Yong He
* Fix scalar to array conversion for tessellation factors in GLSL legalization Add scalar-to-array conversion support in adaptType() function to handle cases where users declare scalar tessellation factors (e.g., float TessLevelInner) but GLSL requires arrays (float[2] for gl_TessLevelInner). This prevents the generation of BuiltinCast instructions that crash the SPIR-V emitter. Fixes crash: "unimplemented: Unhandled local inst in spirv-emit: BuiltinCast" - Add scalar-to-array case in slang-ir-glsl-legalize.cpp adaptType() - Fill all array elements with the scalar value for tessellation factors - Add test case for scalar tessellation factor conversion Fixes #7000 Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Apply review feedback fixes - Change test directive to TEST:SIMPLE - Use IRArrayType instead of IRArrayTypeBase - Use MakeArrayFromElement for cleaner scalar-to-array conversion Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Fix type conversion in scalar-to-array tessellation factor conversion Convert scalar value to array element type before creating array to handle cases where scalar type differs from array element type (e.g., int to float[3]). Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Use CHECK-DAG for order-independent tessellation factor checks Co-authored-by: Yong He <csyonghe@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Yong He <csyonghe@users.noreply.github.com>
2025-07-22Fix segfault when using -separate-debug-info with unsupported targets (#7777)Copilot
* Initial plan * Fix segfault when using -separate-debug-info with unsupported targets Add validation to emit a diagnostic error when -separate-debug-info is used with targets other than SPIR-V binary. Previously, this would cause a segfault because the separate debug info logic is only implemented for SPIR-V targets. Changes: - Added new diagnostic error (ID 18) for unsupported separate debug info usage - Added validation in OptionsParser::_parse() to check target compatibility - Created test cases for HLSL and GLSL targets to verify the fix - Updated error message to clarify only SPIR-V binary targets are supported The fix prevents segfaults and provides clear feedback to users about target limitations for the -separate-debug-info option. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: fix segfault properly instead of preventing it Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-22Fix crash when private ctor is used for coercion. (#7858)Yong He
* Fix crash when private ctor is used for coercion. * Fix tests. * Fix. * Fix test error.
2025-07-22Fix findFunctionByNameInType to preserve functions with different signatures ↵Copilot
(#7827) findFunctionByNameInType was only returning one function when multiple functions existed with the same name but different signatures. This broke reflection functionality for extension methods. Fix the issue by changing findDeclFromStringInType by not calling maybeResolveOverloadedExpr if checkedTerm is overloaded functions. We still call maybeResolveOverloadedExpr when any candidates in the overloaded list is not DeclRefExpr referencing a function.
2025-07-22Add CI to check ir module versioning (#7821)Ellie Hermaszewska
2025-07-22Add Python type stubs for LLDB (#7826)Sam Estep
2025-07-22Fix Conditioanl<T, false> fields with a semantic. (#7855)Yong He
* Fix Conditioanl<T, false> fields with a semantic. * Add unit test. * Fix test.
2025-07-21Fix C-style casts in GLSL pointer cast operations (#7841)Copilot
* Initial plan * Fix C-style casts in GLSL pointer cast operations Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-21Add utility to trace creation of problematic IRInsts to assist LLM in ↵Copilot
debugging (#7820) * Initial plan * Add SLANG_DEBUG_IR_BREAK environment variable support Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply code formatting to SLANG_DEBUG_IR_BREAK implementation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Improve stack trace debugging with -rdynamic flag and backtrace_symbols Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: use PlatformUtil::getEnvironmentVariable, remove -rdynamic flag, and delete fallback branch Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: simplify env var parsing, move backtrace to PlatformUtil, use #if for SLANG_LINUX_FAMILY Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: remove unneeded include, make backtrace() more generic by removing uid parameter Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix and clone source tracking. * Add python script to dump traces. * Update instructions. * Batch calls to addr2line * Cleanup claude instructions. * update claude action. * Remove duplicated build instructions from claude.yml workflow Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * fix build error. * Fix build errors --------- 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: Yong He <yonghe@outlook.com> Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com>
2025-07-18Fix enum array indexing by adding implicit conversion support (#7815)Copilot
* Initial plan * Fix enum array indexing by adding implicit conversion support Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update enum array indexing test to support GPU backends Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-18Fix debug info generation for let variables in SPIR-V output (#7743)Copilot
* Initial plan * Fix debug info for let variables Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix parameter count for emitDebugVar function call Fixed regression where let variable debug info generation was missing the optional argIndex parameter in emitDebugVar call. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add location validity check for debug info generation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Don't insert debug value for nondebuggable types. --------- 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: Yong He <yonghe@outlook.com>
2025-07-18Lower int/uint/bool matrices to arrays for SPIRV (#7687)venkataram-nv
* Add tests for expected behaviour * Allow matrix types in logical or/and * Legalize int/bool matrix types and construction with makeMatrix * Legalize uint matrices and operations * Limit testing to only SPIRV * Better tests for int and bool * Add test for uint * Remove GLSL tests * Remove old test for diagnosing int matrices * Emit SPIRV directly in tests * format code * Address PR comments * Improve testing * Address PR comments * format code * Add tests for matrix intrinsic operations * Move matrix lowering to dedicated legalization pass * Fix compiler warning * Remove signal again * Reorder matrix and vector legalization * Fix formatting * Add shift and comparison tests --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-18Add bounds checking for out-of-bounds array access with constant indices (#7814)Copilot
* Initial plan * Implement out-of-bounds array access checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add tests and format code for array bounds checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move checkForOutOfBoundAccess to separate file and refactor using InstPassBase Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Optimize out-of-bounds checker to use single IR traversal Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix DiagnosticSink forward declaration from struct to class Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update 0-array-1 test to use runtime indices to avoid bounds checking diagnostic Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Use SV_DispatchThreadID for truly runtime array access in 0-array-1 test Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-17Fix GLSL global const diagnostic regression (#7808)Copilot
* Initial plan * Fix GLSL global const diagnostic regression - add test exclusion for GLSL module Co-authored-by: csyonghe <2652293+csyonghe@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>
2025-07-17Prelink ForceInlined functions during lowering. (#7812)Yong He
* Prelink ForceInlined functions during lowering. * Fixes and cleanups. * Fix warning. * Fix crash.
2025-07-17slang: Add support for generating getters for IR struct defs. (#7725)Sruthik P
This change expands the IR struct definition generation logic in slang-ir.h.lua to code generate the getters for the operands of an IR. To facilitate the above, the schema for the IR definitions in slang-ir-insts.lua is updated to allow for explicit specification of the operands of an IR, with Fiddle code generating the getters for them. slang-ir.h is updated to remove the hardcoded getters of the IRs since they are now generated by Fiddle. Fixes part of #7185
2025-07-17fix const qualifier for specialization constants (#7640)Sirox
Co-authored-by: Yong He <yonghe@outlook.com>