<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl, 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-02-05T18:37:03+00:00</updated>
<entry>
<title>Feature/initialize list side branch (#6058)</title>
<updated>2025-02-05T18:37:03+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2025-02-05T18:37:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9ec6b91686b651d959fd9ffbec283845bd725dd6'/>
<id>urn:sha1:9ec6b91686b651d959fd9ffbec283845bd725dd6</id>
<content type='text'>
* SP004: implement initialize list translation to ctor

- We synthesize a member-wise constructor for each struct follow
   the rules described in SP004.
- Add logic to translate the initialize list to constructor invoke
- Add cuda-host decoration for the synthesized constructor
- Remove the default constructor when we have a valid member init constructor
- Disable -zero-initialize option, will re-implement it in followup (#6109).
- Fix the overload lookup issue
    When creating invoke expression for ctor, we need to call
    ResolveInvoke() to find us the best candidates, however
    the existing lookup logic could find us the base constructor
    for child struct, we should eliminate this case by providing
    the LookupOptions::IgnoreInheritance to lookup, this requires
    us to create a subcontext on SemanticsVisitor to indicate that
    we only want to use this option on looking the constructor.
- Do not implicit initialize a struct that doesn't have explicit default
   constructor.

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Proper lowering of functiosn that returns NonCopyable values. (#3179)</title>
<updated>2023-09-03T19:56:31+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-09-03T19:56:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb'/>
<id>urn:sha1:1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb</id>
<content type='text'>
* Proper lowering of functiosn that returns NonCopyable values.

* Fix tests.

* Fix clang errors.

* Fix.

* Fix clang error.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Fixes for Shader Execution Reordering on VK (#2929)</title>
<updated>2023-06-13T21:40:02+00:00</updated>
<author>
<name>Theresa Foley</name>
<email>10618364+tangent-vector@users.noreply.github.com</email>
</author>
<published>2023-06-13T21:40:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f161686e8e260a4b0e6e0a773cf1cf16069f41bf'/>
<id>urn:sha1:f161686e8e260a4b0e6e0a773cf1cf16069f41bf</id>
<content type='text'>
* Fixes for Shader Execution Reordering on VK

There are some mismatches between the way that hit objects are
handled between the current NVAPI/HLSL and proposed GLSL extensions
for shader execution reordering. These mismatches create complications
for generating valid GLSL/SPIR-V code from input Slang.

Many of the problems that apply to `HitObject` also apply to the
existing `RayQuery&lt;&gt;` type used for "inline" ray tracing.

In the case of `RayQuery&lt;&gt;` we have that for *both* HLSL and
GLSL/SPIR-V:

* A `RayQuery` (or `rayQueryEXT`) is an opaque handle to underlying
  mutable storage

* The storage that backs a `RayQuery` is allocated as part of the
  "defualt constructor" for a local variable declared with type
  `RayQuery`.

* The `RayQuery` API provides numerous operations that mutate the
  storage referred to by the opaque handle.

The key difference between HLSL and GLSL/SPIR-V for the case of a
`RayQuery` amounts to:

* In HLSL, local variables of type `RayQuery` can be assigned to,
  and assignment has by-reference semantics. It is possible to create
  multiple aliased handles to the same underlying storage.

* In GLSL/SPIR-V, local variables of type `rayQueryEXT` cannot be
  assigned to, returned from functions, etc. It is impossible to
  create multiple aliased handles to the same underlying storage.

The case for `HitObject`s is signicantly *more* messy, because:

* In NVAPI/HLSL a `HitObject` is effectively a "value type" in that
  it only exposes constructors, and there is no way to mutate the
  state of a `HitObject` other than by assignment to a variable of that
  type. It makes no semantic difference whether a `HitObject` directly
  stores the value(s), or if it is a handle, since there is no way
  to introduce aliasing of mutable state. Assignment of `HitObject`s
  semantically creates a copy.

* In GLSL/SPIR-V, a `hitObjectNV` is, like a `rayQueryEXT`, a handle
  to underlying mutable state. These handles cannot be assigned,
  returned from functions, etc. There is no way to make a copy of
  a hit object.

This change includes several changes to how *both* `RayQuery&lt;&gt;` and
`HitObject` are implemented, with the intention of getting more cases
to work correctly when compiling for GLSL/SPIR-V, and to set up a
more clear mental model for the semantics we want to give to these
types in Slang, and how those semantics can/should map to our targets.

An overview of important changes:

* Marked a few operations on `RayQuery` as `[mutating]` that
  realistically should have already been that way.

* Marked the `HitObject` type as being non-copyable (an attribute we
  do not currently enforce), and marked the various GLSL operations that
  construct a hit object as having an `out` parameter of the `HitObject`
  type (even if they are nominally specified in GLSL as not writing
  to the correspondign parameter).

* Added a distinct IR opcode (`allocateOpaqueHandle`) to represent the
  implicit allocation that happens when declaring a variable of type
  `HitObject` or `RayQuery`, and made the "implicit constructor" for
  those types map to the new op. This operation took a lot of tweaking
  to get emitting in a reasonable way, and I'm still not 100% sure that
  all of the emission-related logic for it is strictly required
  (or correct).

* Added new IR instructions for `HitObject` and `RayQuery` types, and
  made the stdlib types map to those IR instructions.

* Treat `HitObject` and `RayQuery` as resource types for the purpose
  of our existing pass that specializes calls to functions that have
  outputs of resource type

* Added a new test case that includes a function that returns a
  `HitObject` as its result.

* Many test cases saw slight changes in their output (especially around
  the relative ordering of declarations of `HitObject`s and `RayQuery`s
  with other instructions)

* Remove debugging logic</content>
</entry>
<entry>
<title>Fix function side-effectness prop logic. (#2875)</title>
<updated>2023-05-09T16:44:33+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-05-09T16:44:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=38ed03a7203baacf36fca62539ac74fd45ed42d2'/>
<id>urn:sha1:38ed03a7203baacf36fca62539ac74fd45ed42d2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix Phi simplification bug. (#2710)</title>
<updated>2023-03-17T06:46:14+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-03-17T06:46:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9476d4543f4336a66308e55f722b0b0b2bd69dd2'/>
<id>urn:sha1:9476d4543f4336a66308e55f722b0b0b2bd69dd2</id>
<content type='text'>
* Fix Phi simplification bug.

* Fix up.

* Fix.

* Fix.

* Fix.

* Fix.

* Fix.

* Fix test.

* Fix test.

---------

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>Fixed the implementation of RayQuery flags passed through the generic parameter on GLSL. (#2207)</title>
<updated>2022-04-25T22:43:39+00:00</updated>
<author>
<name>Alexey Panteleev</name>
<email>alpanteleev@nvidia.com</email>
</author>
<published>2022-04-25T22:43:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b69b0e43e27ec94c0397774db804b4077b062b21'/>
<id>urn:sha1:b69b0e43e27ec94c0397774db804b4077b062b21</id>
<content type='text'>
Improved the trace-ray-inline test to check that the flag is not ignored anymore.</content>
</entry>
<entry>
<title>Add Vulkan/SPIR-V support for TraceRayInline() (#1737)</title>
<updated>2021-03-05T23:02:44+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-03-05T23:02:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=e962f1a1c12e87baa7adc2ade507512dc8269348'/>
<id>urn:sha1:e962f1a1c12e87baa7adc2ade507512dc8269348</id>
<content type='text'>
For the most part, this translation is straightforward because the `GL_EXT_ray_query` extension is well aligned with the DXR 1.1 `RayQuery` feature. Many function map one-to-one from one extension to the other.

A few notable details:

* The equivalent of the `RayQuery&lt;Flags&gt;` type is non-generic in GLSL, and the GLSL path previously didn't have support for trying to look up an intrinsic type name on an IR type declaration, so that required some tweaks to the emit logic.

* All the GLSL functions are free functions instead of member functions, but our IR doesn't recognize that distinction anyway

* The main `TraceRayInline()` call is the one that took the most tweaking, just because it takes a `RayDesc` structure for D3D/HLSL but takes individual vector sand scalars for VK/GLSL. The approach here is a standard one for how we manage this stuff in the stdlib (and I wanted to avoid adding even more `$` magic for intrinsics).

* For several other calls, the HLSL API had distinct `Candidate***()` and `Committed***()` calls that return information about a candidate hit vs. the one committed into the query. In contrast, the GLSL API uses a single call that takes an additional "must be compile-time constant" `bool` parameter to select between the two behaviors. This is even the case for one call that basically returns a value of a different `enum` type depending on the state of that `bool`. The D3D API model here seems almost strictly better and I have no idea why the GLSL extension was defined this way.

* Because both the `GL_EXT_ray_query` and `GL_EXT_ray_tracing` extensions declare the `accelerationStructureEXT` type, we can no longer infer what extension is supposed to be used based only on the presene of such a type. The logic right now is a bit slippery, because in theory a program that declares an acceleration structure but never traces into it could end up getting a compilation error now. We will have to see if that corner case comes up in practice. :(

The one big detail that is looming after doing this work is that both the HLSL and GLSL exposures of ray queries are extremely "slippery" about the actual identity of queries (e.g., when is one query a copy of another, vs. just being a new variable that references the existing query). Somehow queries get their identity from the original declaration, and as such our "default constructor" approach to them seems semanticay correct, but the whole thing is kind of slippery at a foundational level and I don't know how to fix it with the API as defined. Oh well; just something to keep an eye on.

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
</feed>
