<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/bugs/vk-structured-buffer-load.hlsl.glsl, 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>2024-02-03T06:28:02+00:00</updated>
<entry>
<title>Capability type checking. (#3530)</title>
<updated>2024-02-03T06:28:02+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-02-03T06:28:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=14764896c34b230a5563f48d8b8e565de2f3aa10'/>
<id>urn:sha1:14764896c34b230a5563f48d8b8e565de2f3aa10</id>
<content type='text'>
* Capability type checking.

* Fix.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Compile append and consume structured buffers to glsl. (#3142)</title>
<updated>2023-08-22T00:07:34+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-08-22T00:07:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bd6dbaf7c3ea720b4ed39904fe08878f9dcbd947'/>
<id>urn:sha1:bd6dbaf7c3ea720b4ed39904fe08878f9dcbd947</id>
<content type='text'>
* Compile append and consume structured buffers to glsl.

* Fix.

* Update CI config.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Fix optimization pass not converging. (#2725)</title>
<updated>2023-03-23T23:59:02+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-03-23T23:59:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=50e7d9797d9bf4b98a056d5df128c24dde6e78bd'/>
<id>urn:sha1:50e7d9797d9bf4b98a056d5df128c24dde6e78bd</id>
<content type='text'>
* Fix optimization pass not converging.

* Fix.

* Fix tests.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>More control flow simplifications. (#2673)</title>
<updated>2023-02-24T18:01:47+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-02-24T18:01:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bd6306cdaa4a49344658bd026721b6532e103d09'/>
<id>urn:sha1:bd6306cdaa4a49344658bd026721b6532e103d09</id>
<content type='text'>
* More control flow and Phi param simplifications.

* Fix.

* Fix gcc error.

* Fix.

* More IR cleanup.

* Fix bug in phi param dce + ifelse simplify.

* Propagate and DCE side-effect-free functions.

* Enhance CFG simplifcation to remove loops with no side effects.

* Fix.

* Fixes.

* Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation.

* More cleanup.

* Fixes.

* Fix.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Overhaul global inst deduplication and cpp/cuda backend. (#2654)</title>
<updated>2023-02-16T21:55:32+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-02-16T21:55:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=4c4826d47eeef4675daae4ae53ff76f4d5ebd84a'/>
<id>urn:sha1:4c4826d47eeef4675daae4ae53ff76f4d5ebd84a</id>
<content type='text'>
* Overhaul global inst deduplication and cpp/cuda backend.

* Update IR documentation.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Improved SCCP, inlining and resource specialization passes, legalize `ImageSubscript` for GLSL (#2146)</title>
<updated>2022-02-26T04:49:31+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-02-26T04:49:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=c31577953d5041c82375c22d847c2eba06106c58'/>
<id>urn:sha1:c31577953d5041c82375c22d847c2eba06106c58</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Use "capability" system to select VKRT extension (#1647)</title>
<updated>2021-01-05T17:00:00+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-01-05T17:00:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b4f94629f225b837e7102acc337610c5d4d8a7c1'/>
<id>urn:sha1:b4f94629f225b837e7102acc337610c5d4d8a7c1</id>
<content type='text'>
* Use "capability" system to select VKRT extension

Slang currently supports translation of ray tracing shader code to Vulkan GLSL code that uses the `GL_NV_ray_tracing` extension. A multi-vendor equivalent of that extension has been released as `GL_EXT_ray_tracing` and we want Slang to support that extension as well.

At the simplest, making the change from one extension to the other is just a matter of changing a few strings, since it does not appear that anything of significance was changed at the GLSL level (or even in SPIR-V). Where this gets trickier is when we have users who want us to support *both* extensions, and to be able to switch between them.

The solution we've implemented here more or less amounts to:

* If you don't tell the compiler which extension to use, it will default to `GL_EXT_ray_tracing` (the newer multi-vendor one).

* If you explicitly want the older extension, you can opt into it using the `-profile` option or via a new API for explicitly adding capabilities to your target.

Making that work required a few different kinds of changes:

* The options parsing and public API needed ways to add optional capabilities to a target.

* During GLSL code emit, we can check the capabilities that were added to the target to see if the `GL_NV_ray_tracing` extension was explicitly enabled and, if not, default to using the `GL_EXT_ray_tracing` names for things. This step is needed because some of the modifiers/attributes involved in the extension have to be handled explicitly in the code generator rather than implicitly as part of mapping intrinsic functions.

* We add two different translations to the relevant operatiosn in the stdlib, one marked with each of the extensions. If profile/capability-based overload resolution can be relied on to pick the right one, this should Just Work.

* Next, a bunch of work had to go into making capability-based overloading Just Work for the purposes of this change. There's been a nearly complete reworking of the implementation of `CapabilitySet` here to make it more suitable for our needs.

* The tests that were using ray tracing translation for Vulkan needed to be updated. For some of them I updated their baselines to use `GL_EXT_ray_tracing` so that they can test the new path. For others, I updated the command line for the test case so that it explicitly opts into using `GL_NV_ray_tracing`. The result is that we have some coverage of each extension. I would have liked to have each test run in both modes, but our pass-through glslang support doesn't support `-D` options, so I couldn't take that step easily.

This change does *not* add support for `GL_EXT_ray_query`, the extension that supports "DXR 1.1" style queries under Vulkan. Adding support for that extension should hopefully be a smaller step because it doesn't have the same multiple-extensions issue.

This change does *not* address a lot of possible avenues for improvement or cleanup around the capability system. It focuses only on those changes that are necessary to make the ray tracing feature work and leaves the rest for future work.

* fixup: infinite loop

* Comment-only change to retrigger TC build</content>
</entry>
<entry>
<title>Yet more definitions moved into the stdlib (#1263)</title>
<updated>2020-03-09T16:02:36+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-03-09T16:02:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b1317cd16ab9c827596a28ccf4258ef1bb672d92'/>
<id>urn:sha1:b1317cd16ab9c827596a28ccf4258ef1bb672d92</id>
<content type='text'>
The only big catch that I ran into with this batch was that I found the `float.getPi()` function was being emitted to the output GLSL even when that function wasn't being used. This seems to have been a latent problem in the earlier PR, but was only surfaced in the tests once a Slang-&gt;GLSL test started using another intrinsic that led to the `float : __BuiltinFloatingPointType` witness table being live in the IR.

The fix for the gotcha here was to add a late IR pass that basically empties out all witness tables in the IR, so that functions that are only referenced by witness tables can then be removed as dead code. This pass is something we should *not* apply if/when we start supporting real dynamic dispatch through witness tables, but that is a problem to be solved on another day.

The remaining tricky pieces of this change were:

* Needed to remember to mark functions as target intrinsics on HLSL and/or GLSL as appropriate (hopefully I caught all the cases) so they don't get emitted as source there.

* The `msad4` function in HLSL is very poorly documented, so filling in its definition was tricky. I made my best effort based on how it is described on MSDN, but it is likely that if anybody wants to rely on this function they will need us to vet our results with some tests.</content>
</entry>
<entry>
<title>Fix bitwise And &amp; Or for scalar bool (#960)</title>
<updated>2019-05-01T16:33:50+00:00</updated>
<author>
<name>Robert Stepinski</name>
<email>rob.stepinski@gmail.com</email>
</author>
<published>2019-05-01T16:33:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=88a3f6476c37f3245de6d607d8055879f8892ee4'/>
<id>urn:sha1:88a3f6476c37f3245de6d607d8055879f8892ee4</id>
<content type='text'>
* Convert bitwise Or &amp; And to logical operations on scalar bools

* Test bitwise operations on scalar bools
</content>
</entry>
<entry>
<title>Allow plugging in types with resources for interface parameters (#913)</title>
<updated>2019-03-26T19:49:02+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-03-26T19:49:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=88859d413e53e4228ae3b832d8bbd2711ccce84a'/>
<id>urn:sha1:88859d413e53e4228ae3b832d8bbd2711ccce84a</id>
<content type='text'>
* Allow plugging in types with resources for interface parameters

The key feature enabled by this change is that you can take a shader declared with interface-type parameters:

```hlsl
ConstantBuffer&lt;ILight&gt; gLight;
float4 myShader(IMaterial material, ...)
{ ... }
```

and specialize its interface-type parameters to concrete type that can contain resources like textures, samplers, etc.

The hard part of doing this layout is that we need to support signatures that include a mix of interface and non-interface types. Imagine this contrived example:

```hlsl
float4 myShader(
    Texture2D diffuseMap,
    ILight        light,
    Texture2D specularMap)
{ ... }
```

We end up wanting `diffuseMap` to get `register(t0)` and `specularMap` to get `register(t1)`, so that they have the same location no matter what we plug in for `light`.
But if we plug in a concrete type for `light` that needs a texture register, we need to allocate it *somewhere*.
We handle this by having the `TypeLayout` for `light` come back with a "primary" type layout that doesn't have any texture registers, but with a "pending" type layout that includes the texture register requirements of whatever concrete type we plug in.

This split between "primary" and "pending" layout then needs to work its way up the hierarchy, so that an aggregate `struct` type with a mix of interface and non-interface fields (recursively), needs to compute an aggregate "primary type layout" and an aggregate "pending type layout," and then each field needs to be able to compute its offset in the primary/pending layout of the aggregate.

A large chunk of the work in this PR is then just implementing the split between primary and pending data, and ensuring that layouts are computed appropriately.

The next catch is that when a "parameter group" (either a parameter block or constant buffer) contains one or more values of interface type, then we can allow the parameter group to "mask" some of the resource usage of the concrete types we plug in, but others "bleed through."

For example, if we have:

```hlsl
struct MyStuff { float3 color; ILight light; }
ConstantBuffer&lt;MyStuff&gt; myStuff;

struct SpotLight { float3 position; Texture2D shadowMap; }
``

If we plug in the `SpotLight` type for `myStuff.light`, then the `float3` data for the light can be "masked" by the fact that we have a constant buffer (we can just allocate the `float3` `position` right after `color`), but the `Texture2D` needed for `shadowMap` needs to "bleed through" and become "pending" data for the `myStuff` shader parameter.

Adding support for that detail more or less required a full rewrite of the logic for allocating parameter group type layouts.

The next detail is that when we go to legalize a declaration like the `myStuff` buffer, we will end up with something like:

```hlsl
struct MyStuff_stripped { float3 color; }
struct Wrapped
{
    MyStuff_stripped primary;
    SpotLight pending;
}
ConstantBuffer&lt;Wrapped&gt; myStuff;
```

This "wrapped" version of the buffer type more accurately reflects the layout we need/want for the uniform/ordinary data, but in order to further legalize it and pull out the resource-type fields like `shadowMap` we need to have accurate layout information, and the problem is that layout information for the original buffer can't apply to this new "wrapped" buffer.

The last major piece of this change is logic that runs during existential type legalization to compute new layouts for "wrapped" buffers like these that embeds correct offset/binding/register information for any resources nested inside them. A key challenge in that code is that existential legalization needs to erase any "pending" data from the program entirely, so that offset information that used to be relatie to the "pending" part of a surrounding type now needs to be relative to the primary part.

The work here may not be 100% complete for all scenarios, but it does well enough on the new and existing tests that I want to checkpoint it. Note that a few other tests have had their output changed, but in all cases I've reviewed the diffs and determined that the change in observable behavior is consistent with what we intened Slang's behavior to be.

Note that there is still one major piece of support for interface-type parameters that is missing here, and which might force us to revisit some of the decisions in this code: we don't properly support user-defined `struct` types with interface-type fields.

* fixup: typos
</content>
</entry>
</feed>
