<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/reflection/multi-file.hlsl.expected, 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-08-01T09:18:53+00:00</updated>
<entry>
<title>Fix 7441: CUDA boolean vector layout to use 1-byte elements (#7862)</title>
<updated>2025-08-01T09:18:53+00:00</updated>
<author>
<name>Harsh Aggarwal (NVIDIA)</name>
<email>haaggarwal@nvidia.com</email>
</author>
<published>2025-08-01T09:18:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bdda8a90cdd44ca822b21233ac988f92d1f20826'/>
<id>urn:sha1:bdda8a90cdd44ca822b21233ac988f92d1f20826</id>
<content type='text'>
* Fix 7441: CUDA boolean vector layout to use 1-byte elements

Boolean vectors (bool1, bool2, bool3, bool4) were incorrectly implemented
as integer-based types using 4 bytes per element instead of actual 1-byte
boolean elements on CUDA targets.

Changes:
- Update CUDA prelude to define boolean vectors as structs with bool fields
  instead of typedef aliases to integer vectors
- Implement CUDALayoutRulesImpl::GetVectorLayout to use 1-byte alignment
  for boolean vectors, matching actual CUDA memory layout behavior
- Update make_bool functions to populate struct fields correctly

This ensures boolean vectors have the same memory layout as bool[4] arrays:
- bool1: 1 byte (was 4 bytes)
- bool2: 2 bytes (was 8 bytes)
- bool3: 3 bytes (was 12 bytes)
- bool4: 4 bytes (was 16 bytes)

Fixes memory layout mismatch between Slang reflection API and actual
CUDA compilation, achieving 75% memory savings for boolean vector usage.

* Fix CI issues -

Add and update associated functions and operators

* Make boolX same as uchar

* Use align construct on struct for boolX

* Improve Test case for robust alignment checks

* Formatting

* Disable selected slangpy tests

* add metal check which is slightly different than cuda

* Test-1

* Test-2

* Test-3

* Test-4

* ReflectionChange

* cleanup and update

* _slang_select with plain bool is needed for reverse-loop-checkpoint-test</content>
</entry>
<entry>
<title>Add inner texture type to reflection json (#6416)</title>
<updated>2025-02-28T01:52:14+00:00</updated>
<author>
<name>Devon</name>
<email>devonrutledge03@gmail.com</email>
</author>
<published>2025-02-28T01:52:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cd20e94af9f384c03e8be69f6c8ce9e97212cc9b'/>
<id>urn:sha1:cd20e94af9f384c03e8be69f6c8ce9e97212cc9b</id>
<content type='text'>
* Add inner texture type to reflection json

* Add expected result of test

* Adjust test expected results

* Fix ci test result

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Fixed stage and result field names in json reflection (#5927)</title>
<updated>2024-12-21T16:14:56+00:00</updated>
<author>
<name>Stan</name>
<email>109335133+stanoddly@users.noreply.github.com</email>
</author>
<published>2024-12-21T16:14:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=76fdeaa477a5d21176facf0296f77e28e2d59477'/>
<id>urn:sha1:76fdeaa477a5d21176facf0296f77e28e2d59477</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Cover a few corner cases in reflection API (#1163)</title>
<updated>2020-01-08T22:45:06+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-01-08T22:45:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0a856f458ff9f17d76bc646d008602713c6c66d1'/>
<id>urn:sha1:0a856f458ff9f17d76bc646d008602713c6c66d1</id>
<content type='text'>
This change adds some new entry points to the reflection API to cover corner cases that a majority of applications won't care about.
These are most likely to come up for users who want to make a complete copy of the Slang reflection information into a data format of their own design.

All of the information is stuff that we already computed as part of layout, and just hadn't exposed:

* Alignment information for type layouts. This is only useful for ordinary/uniform data; in all other cases alignment is always one. Even for uniform/ordinary data, it is unlikely that any application would actually make use of it.

* Layout information for the result of an entry point function. This would be useful for applications that need to enumerate the varying outputs (user- or system-defined) of a shader. Having information available for `out` parameters but not the function result was inconsistent.

* The "element type" of a parameter block type (e.g., going from `ParameterBlock&lt;X&gt;` to `X`). This seems to have been an oversight since `ConstantBuffer&lt;X&gt;` appears to have been implemented, and the case for a type *layout* was handled.

* The "container" variable layout for a parameter block or constant buffer. It took a while for us to arrive at the current representation of layout for parameter groups, and most client code continues to use the original API that requires us to generated kludged "do what I mean" data. However, if we don't expose the more useful new representation fully, there is no way for users to take advantage of it!

The reflection test tool has been updated to print the new information where it makes sense, which provides us some level of coverage for the new code.
Unfortunately, this led to some cascading changes:

* First, a bunch of the tests had their output changed since they include new information. That's the easy bit.

* Next, the "container" and "element" var layouts don't actually have names (because there is no actual variable underlying them), which means that the code to emit variable names in the JSON dump needed to be condition.

* Making the `"name"` output conditional messed up a lot of the delicate logic that had been dealing with when to emit commas for the output JSON (JSON uses commas as separators, and doesn't allow trailing commas). I added a bit of new infrastructure to make it simple(-ish) to track when a comma actually needs to be output.</content>
</entry>
<entry>
<title>Remove legacy feature for merging global shader parameters (#1139)</title>
<updated>2019-12-06T17:29:09+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-12-06T17:29:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=54d3c5f6657b1099326e1ce7ec0f0692e7025442'/>
<id>urn:sha1:54d3c5f6657b1099326e1ce7ec0f0692e7025442</id>
<content type='text'>
* Remove legacy feature for merging global shader parameters

There is a fair amount of special-case code in the Slang compiler today to deal with the scenario where a programmer declares the "same" shader parameter across two different translation units:

```hlsl
// a.hlsl
Texture2D a;
cbuffer C { float4 c; }
```

```hlsl
// b.hlsl
cbuffer C { float4 c; }
Texture2D b;
```

An important note here is that the declaration of `C` may be in a header file that both `a.hlsl` and `b.hlsl` `#include`, because from the standpoint of the parser and later stages of the compiler, there is no difference between `C` being in an included file vs. it being copy-pasted across both `a.hlsl` and `b.hlsl`.

When a user invokes `slangc a.hlsl b.hlsl` (or the equivalent via the API), then they may decide that it is "obvious" that the shader parameter `C` is the "same" in both `a.hlsl` and `b.hlsl`.
Knowing that the parameter is the "same" may lead them to make certain assumptions:

* They may assume that generated code for entry points in `a.hlsl` and `b.hlsl` will both agree on the exact `register`/`binding` occupied by `C`.

* They may assume that reflection information for their program will only reflect `C` once, and it will reflect it in a way that is applicable to entry points in both `a.hlsl` and `b.hlsl`

* They may assume that the compiler can and should handle this use case even when `C` contains fields with `struct` types that are declared in both `a.hlsl` and `b.hlsl` that have the "same" definition.

* They may assume that in cases where `C` is declared inconsistently between `a.hlsl` and `b.hlsl` the compiler can and will diagnose an error.

Making these assumptions work in practice required a lot of special-case code:

* When composing/linking programs was `ComponentType`s we had to include a special case `LegacyProgram` type that could provide these "do what I mean" semantics, since they are *not* what one would want in the general case for a `CompositeComponentType`.

* During enumeration of global shader parameter in a `LegacyProgram`, we had to detect parameters from distinct modules (translation units) with the same name, and then enforce that they must have the "same" type (via an ad hoc recursive structural type match). No other semantic checking logic needs or uses that kind of structural check.

* During parameter binding generation, we need to handle the case where a single global shader parameter might have multiple declarations, and make sure to collect explicit bindings from all of them (checking for inconsistency) and also to apply generated bindings to all of them.

* The `mapVarToLayout` member in `StructTypeLayout` is a concession to the fact that we might have multiple `VarDecl`s for each field of the struct that represents the global scope, we might need to look up a field and its layout using any of those declarations (much of the need for this field had gone away now that IR passes are largely using IR-based layout).

All of these different special cases added more complex code in many places in the compiler, all to support a scenario that isn't especially common.
Most users won't be affected by the original issue, because they will do one of several things that rule it out:

* Anybody using `slangc` like a stand-in for `fxc` or `dxc` and compiling one translation unit at a time will not suffer from any problems. If/when such users want consistent bindings across translation units, they already use either explicit binding or rely on consistent ordering and implicit binding.

* Anybody who puts all the entry points that get combined into a pass/pipeline in a single file will not have problems. They will automatically get consistent bindings because of Slang's guarantees, and there can't be duplicated declarations when there is only one translation unit.

* Anybody using `import` to factor out common declarations while compiling multiple translation units at once will not be affected. Parameters declared in an `import`ed module are the "same" in a much deeper way that it is trivial for Slang to support.

Only users of the Falcor framework are likely to be affected by this, and they have two easy migration paths: either put related entry points into the same file, or factor common parameters into an `import`ed module.

(It is also worth noting that for command-line `slangc`, it is possible to have a single module with multiple `.slang` files in it, which can all see global declarations like parameters across all the files. Anybody who buys into doing things the Slang Way should have no problem avoiding duplicated declarations)

With the rationale out of the way, the actual change mostly just amounts to deleting lots of code that is no longer needed. An astute reviewer might notice several `assert`-fail conditions where complex Slang features were never actually made to work correctly with this legacy behavior.

A small number of test cases broke with the code changes, but these were tests that specifically exercised the behavior being removed. In the case of the tests around binding/reflection generating, I rewrote the tests to use one of the idomatic workarounds (putting the shared parameters into an `import`ed module), but doing so required me to add support for `#include` when doing pass-through compilation with `fxc`. That logic added a bit more cruft than I had originally hoped to this commit, but having `#include` support when doing pass-through compilation is probably a net win.

* fixup: 64-bit warning
</content>
</entry>
<entry>
<title>Add basic reflection query for checking if entry point is "sample-rate"</title>
<updated>2017-07-12T18:07:45+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-07-12T18:07:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=74963469a169b49d61196e3a3b33a903ea8bfede'/>
<id>urn:sha1:74963469a169b49d61196e3a3b33a903ea8bfede</id>
<content type='text'>
- This really just checks two basic things:
  1. Was there any global variable declared with `in` and `sample`?
  2. Did any code encountered during lowering referenece `gl_SampleIndex`?

- This doesn't cover what HLSL could need, nor what we would need for cross-compilation. Consider it GLSL-specific for now.

- In order to generate the information with even a reasonable chance of being accurate (not giving a ton of false positives) I tried to integrate the checks into the lowering process (so they only see code that is referenced, one hopes).
  - For this to work with my testing setup, I needed to make sure that lowering is always performed, prior to emitting reflection info
  - This change broke several reflection tests, because they had been using code that wouldn't actually pass the downstream compiler. I checked in fixes for those.
</content>
</entry>
<entry>
<title>Add per-entry-point information to reflection JSON dumps</title>
<updated>2017-07-12T17:18:11+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-07-12T17:18:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2c6c501b36db9e7991c3f7999451b70f12329ecc'/>
<id>urn:sha1:2c6c501b36db9e7991c3f7999451b70f12329ecc</id>
<content type='text'>
- This also adds reflection API for querying:
  - Entry point name
  - Entry point parameter list
</content>
</entry>
<entry>
<title>Initial import of code.</title>
<updated>2017-06-09T20:44:59+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-06-09T18:34:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd'/>
<id>urn:sha1:fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd</id>
<content type='text'>
</content>
</entry>
</feed>
