<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-reflection-api.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-09-10T22:55:00+00:00</updated>
<entry>
<title>Add FindModifier for Declarations (#8308)</title>
<updated>2025-09-10T22:55:00+00:00</updated>
<author>
<name>Xuanda Yang</name>
<email>th3charlie@gmail.com</email>
</author>
<published>2025-09-10T22:55:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f3e26754c4b63fee419407752b771ecf0bb8ed5a'/>
<id>urn:sha1:f3e26754c4b63fee419407752b771ecf0bb8ed5a</id>
<content type='text'>
Add `findModifier` for `DeclReflection` so pattern like `extern struct
foo;` can be properly reflected.

Closes #8009</content>
</entry>
<entry>
<title>Fix FunctionReflection getName() returning null for overloaded functions (#8113)</title>
<updated>2025-08-08T00:34:05+00:00</updated>
<author>
<name>Copilot</name>
<email>198982749+Copilot@users.noreply.github.com</email>
</author>
<published>2025-08-08T00:34:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=c7c4816146bb9ec055e9a8f8c3f975624f2fdb07'/>
<id>urn:sha1:c7c4816146bb9ec055e9a8f8c3f975624f2fdb07</id>
<content type='text'>
When using Slang reflection API to find functions by name in a type,
`FunctionReflection::getName()` would return `nullptr` for overloaded
functions instead of the expected function name.

The issue occurred in `spReflectionFunction_GetName` when
`findFunctionByNameInType` returned a `SlangReflectionFunction` wrapping
an `OverloadedExpr` (for overloaded functions) instead of a single
`DeclRef&lt;FunctionDeclBase&gt;`. The `convertToFunc()` function would fail
for `OverloadedExpr` objects, causing `getName()` to return `nullptr`.

**Example of the bug:**
```cpp
// This code would fail before the fix
public interface IBase {
    public void step(inout float f);
}

public struct Impl : IBase {
    public void step(inout float f) { f += 1.0f; }
}

// Using reflection API:
auto implType = reflection-&gt;findTypeByName("Impl");
auto stepFunction = reflection-&gt;findFunctionByNameInType(implType, "step");
auto name = stepFunction-&gt;getName(); // Would return nullptr
```

**Fix:**
Modified `spReflectionFunction_GetName` to handle overloaded functions
by falling back to the name of the first overload candidate when
`convertToFunc` fails. This follows the same pattern already used by
`spReflectionFunction_specializeWithArgTypes`.

The fix ensures that:
- Overloaded function containers return the correct function name
- Individual overload candidates also return their names correctly  
- Non-overloaded functions continue to work as before
- No regression in existing functionality

**Testing:**
Added comprehensive test cases covering both the original issue scenario
and explicit function overloading. All existing reflection tests
continue to pass.

Fixes #8047.

&lt;!-- START COPILOT CODING AGENT TIPS --&gt;
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] &lt;198982749+Copilot@users.noreply.github.com&gt;
Co-authored-by: csyonghe &lt;2652293+csyonghe@users.noreply.github.com&gt;
Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;
Co-authored-by: ArielG-NV &lt;159081215+ArielG-NV@users.noreply.github.com&gt;
Co-authored-by: slangbot &lt;ellieh+slangbot@nvidia.com&gt;
Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Add reflection api for overload candidate filtering. (#8066)</title>
<updated>2025-08-06T08:07:41+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2025-08-06T08:07:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=68b0125226464cb3c9e9b7f50bfb53cda97723b4'/>
<id>urn:sha1:68b0125226464cb3c9e9b7f50bfb53cda97723b4</id>
<content type='text'>
* Add reflection api for overload candidate filtering.

* Fix API.

* Fix.

* Update build.

* Update test.

* Update formatting.</content>
</entry>
<entry>
<title>Allow Link time constant array length sizing, warn on unsupported functionality (#7067)</title>
<updated>2025-07-01T15:36:02+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2025-07-01T15:36:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=c94ca1692e101df87215232e87fa7edadc1a7b05'/>
<id>urn:sha1:c94ca1692e101df87215232e87fa7edadc1a7b05</id>
<content type='text'>
* Add link time array layout test

* Add link time constant array size compilation test

* Link time constant array size test

* Allow getting link time array size

Closes https://github.com/shader-slang/slang/issues/6753

* format

* Switch to SIMPLE test and check output

* Implement without binary api changes

* diagnose on link time constant sized array

* fix test

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Hide atomics struct from reflection api (#7520)</title>
<updated>2025-06-26T18:15:43+00:00</updated>
<author>
<name>James Helferty (NVIDIA)</name>
<email>jhelferty@nvidia.com</email>
</author>
<published>2025-06-26T18:15:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=78dc7c3fd1441ba756c969b81ed90600fa9f9f38'/>
<id>urn:sha1:78dc7c3fd1441ba756c969b81ed90600fa9f9f38</id>
<content type='text'>
* Atomic reflection unit test

Test that Atomic&lt;int&gt; is reflected as a scalar/int instead of a struct
named Atomic.

* Hide AtomicType from reflection

Leverage the fact that returned variables go through convert() to
centralize the unwrapping of the AtomicType struct.

Fixes #6257

* Clean up unit test a bit

- rename bar to buf (since one of them is not Atomic and thus not a
  barrier)
- validate deeper into the fields of bufC
- remove debug code</content>
</entry>
<entry>
<title>Set current astbuilder for reflection API (#7488)</title>
<updated>2025-06-26T08:21:51+00:00</updated>
<author>
<name>Mukund Keshava</name>
<email>mkeshava@nvidia.com</email>
</author>
<published>2025-06-26T08:21:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=4a3342170fdba6d7883e4b18ef769bd54b4ee26e'/>
<id>urn:sha1:4a3342170fdba6d7883e4b18ef769bd54b4ee26e</id>
<content type='text'>
With the test code in the issue, a crash was observed inside Slang::DeclRefBase::getParent()
while accessing the astbuilder which was nullptr. This PR adds a fix for that.

For the test code in the issue, we now get:
================================================
    found Outer&lt;float&gt;::Inner: true
    found foo function: true
    function name: "foo"
    parameter count: 1
    attempting getParameterByIndex(0): true
    getParameterByIndex(0) succeeded: true
    parameter name: "param"
    parameter type: "float"
================================================
Fixes #6546</content>
</entry>
<entry>
<title>Mediate access to ContainerDecl members (#7242)</title>
<updated>2025-06-09T18:22:51+00:00</updated>
<author>
<name>Theresa Foley</name>
<email>10618364+tangent-vector@users.noreply.github.com</email>
</author>
<published>2025-06-09T18:22:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bfae49d853e0f9b6f9de495b13bcd1642ca4a285'/>
<id>urn:sha1:bfae49d853e0f9b6f9de495b13bcd1642ca4a285</id>
<content type='text'>
Most of what this change does is straightforward: take all the places in the code that used to operate directly on `ContainerDecl::members` and related fields, and instead have them call into a smaller set of accessor methods defined on `ContainerDecl`.

The primary motivation for making this change is that in order to implement on-demand loading of members from serialized AST modules, we need a way to identify and intercept the "demand" for those members.

On-demand loading benefits from having all accesses to the members of a `ContainerDecl` be as narrow as possible.
If a part of the code only need a member at a specific index, it should say so.
If it only needs access to members with a specific name, or a given subclass of `Decl`, then it should say so.

A secondary motivation for this change is that there have recently been several changes that added complexity and special cases by introducing code that operated on (and *mutated*) the member list of a container decl in ways that the existing code had never done before.

Any code that mutates the member list of a `ContainerDecl` needs to be sure to not disrupt the invariants that the lookup acceleration structures currently rely on.
One of the recent changes added a declaration-to-index map to the set of acceleration structures (with different validation/invalidation behavior than the others...) while other recent changes would remove or insert declarations in ways that could change the indices of other declarations in the same container.
It is not clear if any of these pieces of code were aware of the others, and the invariants that might be expected or broken along the way.

This change bottlenecks the vast majority of accesses to the members of a `ContainerDecl` through the following operations:

* Getting a `List` of all of the direct member declarations of a container

* Get the number of direct member declarations, and accessing them by index.

* Looking up the list of direct member declarations with a given name.

* Adding a new direct member declaration to the end of the list.

Some other operations are layered on top of those (e.g., getting a list of all the direct member declarations of a given C++ class).
These layered operations are still centralized on the `ContainerDecl`, with the intention that we *can* change them to be non-layered implementations if we ever need to for performance (e.g., by building a lookup structure for finding member declarations by their type).

The exceptional cases of access/mutation on the direct members of a `ContainerDecl` have also been encapsulated, but rather than expose what would risk appearing like general-purpose accessors (e.g., `removeDecl(d)`, `setDecl(index)`, etc.), these operations have been explicitly named after the specific use case that they serve in the codebase today, to discourage others from using them for more kinds of operations we'd rather not support.
These operations have also been given parameter signatures that match their use cases, to make it so that even somebody determined to abuse them would have to invent suitable arguments out of thin air.

In the case of the declaration-to-index mapping, this change eliminates that acceleration structure, in favor or slightly more complicated (and possibly inefficient, yes) code at the use site.

Over time, it would be good to closely scrutinize each of the use cases that requires more complicated interaction with the members of a `ContainerDecl`, to see whether any of them can be reframed in terms of the more basic operations, or if there is some clean abstraction we can introduce to make operations that mutate the member list feel like... hacky.</content>
</entry>
<entry>
<title>support specialization constant sized array (#6871)</title>
<updated>2025-05-14T17:11:53+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2025-05-14T17:11:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=375ecfe2903b09f07abeba2eafb88d9a564c1458'/>
<id>urn:sha1:375ecfe2903b09f07abeba2eafb88d9a564c1458</id>
<content type='text'>
Close #6859

Goal of this PR
We want to support an array whose size can be specialization constant for shared/global variable e.g.

layout (constant_id = 0) const uint BLOCK_SIZE = 64;
shared float buf_a[(BLOCK_SIZE + 5) * 4];
Overview of the solution:

During IndexExpr check, we will loose the restriction to allow SpecConst passing, but the size parameter will not be a constant value because it cannot be folded into a constant, so we will make it follow the same logic as generic parameter value, and the size will be represented by FuncCallIntVal/PolynomialIntVal/DeclRefIntVal.

During IR lowering, we will detect whether there is spec constant in the IntVal, and wrap the IRInst with a SpecConstRateType, and propagate the type though the lowering logic, such that the IntVal representing the array size will have SpecConstRateType.

During spirv emit stage, if we detect that a IRInst has SpecConstRateType, we will emit it as SpecConstantOp.

We have to implement new logic to emit OpSpecConstantOp, the existing emit logic doesn't support emitting OpSpecConstantOp, especially this op can embed arithmetic operation at global scope, where we can only emit arithmetic instruct at local. But there are only few instructs we need to support.

Overview of the solution:
This PR doesn't support generic, and we will create a separate PR to extend that, tracked in #6840.</content>
</entry>
<entry>
<title>Return non-escaped strings from user-defined attributes (#6735)</title>
<updated>2025-04-07T14:01:50+00:00</updated>
<author>
<name>aidanfnv</name>
<email>aidanf@nvidia.com</email>
</author>
<published>2025-04-07T14:01:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9972a5269f87618e237cd927b859636322596a76'/>
<id>urn:sha1:9972a5269f87618e237cd927b859636322596a76</id>
<content type='text'>
Fixes #6624

This commit changes the behavior of getArgumentValueString() to return
the string's value, instead of returning the string's token,
as that token also contains the surrounding quotation marks.
This commit also modifies the relevant unit test accordingly,
to not check for the surrounding quotations.</content>
</entry>
<entry>
<title>Make image format reflection easier (#6550)</title>
<updated>2025-03-20T06:38:52+00:00</updated>
<author>
<name>Devon</name>
<email>devonrutledge03@gmail.com</email>
</author>
<published>2025-03-20T06:38:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=30068d75fb97fecc163253fb331daddbb09234e6'/>
<id>urn:sha1:30068d75fb97fecc163253fb331daddbb09234e6</id>
<content type='text'>
* image format json reflection

* format code

* use direct include

---------

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
</feed>
