<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-ir-explicit-global-context.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-29T06:33:45+00:00</updated>
<entry>
<title>Update function type after inserting KernelContext parameter (#8551)</title>
<updated>2025-09-29T06:33:45+00:00</updated>
<author>
<name>Julius Ikkala</name>
<email>julius.ikkala@gmail.com</email>
</author>
<published>2025-09-29T06:33:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d5f3f477918769338dd5baa73ff560d10a5ca7e9'/>
<id>urn:sha1:d5f3f477918769338dd5baa73ff560d10a5ca7e9</id>
<content type='text'>
Without this, there are functions with missing parameters in their type
in the IR after running the `introduceExplicitGlobalContext` pass:

```
[layout(%15)]
[export("_SV4test12outputBuffer")]
[nameHint("outputBuffer")]
let  %outputBuffer      : _     = key
[noSideEffect]
[export("_S4test7dostuffp1pi_ff")]
[nameHint("dostuff")]
func %dostuff   : Func(Float, Float)
{
block %34(
                [nameHint("f")]
                param %f        : Float,
                [nameHint("kernelContext")]
                param %kernelContext    : Ptr(%KernelContext, 0 : UInt64, 1 : UInt64)):
        let  %35        : Float = mul(%f, %f)
        let  %36        : Ptr(ConstantBuffer(%GlobalParams, DefaultLayout), 0 : UInt64, 1 : UInt64)     = get_field_addr(%kernelContext, %globalParams)
        let  %37        : ConstantBuffer(%GlobalParams, DefaultLayout)  = load(%36)
        let  %38        : Ptr(RWStructuredBuffer(Float, DefaultLayout, %20))    = get_field_addr(%37, %outputBuffer)
        let  %39        : RWStructuredBuffer(Float, DefaultLayout, %20) = load(%38)
        let  %40        : Ptr(Float)    = rwstructuredBufferGetElementPtr(%39, 1 : Int)
        let  %41        : Float = load(%40)
        let  %42        : Float = mul(%35, %41)
        return_val(%42)
}
```

Not sure why this doesn't seem to negatively affect existing targets,
but it sure is an issue for the LLVM target I'm working on. I could've
left this fix for that PR, but I want to check now if this causes any
issues with the existing targets using the CI.

This also happens with the entry point functions, where the function
type is not updated after adding `ComputeThreadVaryingInput`. This had
no effect in the C++ target because
`convertEntryPointPtrParamsToRawPtrs(irModule);` is called right after
and fixes it.</content>
</entry>
<entry>
<title>[CBP] Pointer frontend changes + groupshared pointer support (#7848)</title>
<updated>2025-08-29T22:52:34+00:00</updated>
<author>
<name>ArielG-NV</name>
<email>159081215+ArielG-NV@users.noreply.github.com</email>
</author>
<published>2025-08-29T22:52:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=7758625d3fea67e55e98e7e4103d56c9918365be'/>
<id>urn:sha1:7758625d3fea67e55e98e7e4103d56c9918365be</id>
<content type='text'>
Resolves #7628
Resolves: #8197

Primary Goals:
1. Add `Access` to pointer
2. AddressSpace::GroupShared support for pointers (SPIR-V)
3. Add `__getAddress()` to replace `&amp;`
* `&amp;` is not updated to `require(cpu)` since slangpy uses `&amp;`. This
means we must: (1) merge PR; (2) replace `&amp;` with `__getAddress()`; (3)
add `require(cpu)` to `&amp;`

Changes:
* Added to `Ptr` the `Access` generic argument &amp; logic (for
`Access::Read`).
* Moved the generic argument `AddressSpace` from `Ptr` to the end of the
type.
* Added pointer casting support between any `Ptr` as long as the
`AddressSpace` is the same
* Disallow globallycoherent T* and coherent T*
* Disallow const T*, T const*, and const T*
* Fixed .natvis display of `ConstantValue` `ValOperandNode`
* Support generic resolution of type-casted integers
* Added `VariablePointer` emitting for spirv + other minor logic needed
for groupshared pointers

Breaking Changes:
* Anyone using the `AddressSpace` of `Ptr` will now have to account for
the `Access` argument
* we disallow various syntax paired with `Ptr` and `T*`

---------

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Address issues with GLSL style global in/out vars (#6669) (#6998)</title>
<updated>2025-06-06T20:13:43+00:00</updated>
<author>
<name>sricker-nvidia</name>
<email>115114531+sricker-nvidia@users.noreply.github.com</email>
</author>
<published>2025-06-06T20:13:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=649d533727b31b28397ffb3a530e655ac3861547'/>
<id>urn:sha1:649d533727b31b28397ffb3a530e655ac3861547</id>
<content type='text'>
* Address issues with GLSL style global in/out vars (#6669)

Asserts and segfaults were observed trying to compile a simple
vertex shader like:

````
in int2 inPos;

[shader("vertex")]
main(uniform int2 test1, int2 test2, out float4 pos: SV_Position)
void main()
{
    // Bogus use of all input vars to prevent optimizing out.
    pos = float4(inPos.x, test1.x, test2.y, 0);
}
````

Further investigation found that while replacing "uniform int2 test1"
with "int2 test1" allowed for successful compilation, the resulting
output shader would have overlapping location qualifiers. For example,
compiling the above with "int2 test1" to glsl might give:

````
...
layout(location = 0) in ivec2 test1_0;
layout(location = 1) in ivec2 test2_0;
layout(location = 0) in ivec2 translatedGlobalParams_inPos_0;
...
````

This was because Slang does not actually support mixing GLSL style global
in/out vars and entry point params. However, this is never checked for
or noted in documentation. Slang source also assumes input shaders do not
mix these and these assumptions ultimately led to the observed asserts
and seg faults when using uniform entry point params.

This change makes updates to throw an error when the compiler detects that
it is trying to translate global in/out variables into entry point params
when an entry point already contains parameters, allowing for compilation
to fail gracefully.

Certain tests have been updated to avoid mixing GLSL style global in/out
vars and entry point params. This was mostly for tests that were using
functions like WaveGetLaneIndex which use global in vars for certain
platforms (see __builtinWaveLaneIndex).

* Address issues with GLSL style global in/out vars - updates 1 (#6669)

Update addresses review feedback to support mixing GLSL-flavored global
in/out vars and entrypoint parameters when either all global in/out vars
or all entry point params have a system value binding semantic.

* Address issues with GLSL style global in/out vars - updates 2 (#6669)

This update attempts to actually allow mixing GLSL style global in
vars and entry point vars.

Change attempts to recalculate offsets when adding the global input
vars into the recreated entry point params layout.

Additional updates were made to:

-resolve further issues uncovered with entry point uniform params.

-Address improper use of SV_DispatchThreadID in wave-get-lane-index.slang
 for metal. "thread_position_in_grid" is not supported for signed integer
 scalars or vectors.

-Fix a spirv casting conflict due to the implementation of
 gl_PrimitiveID.get conflicting with PrimitiveIndex().

-Add a call to remove a global var in replaceUsesOfGlobalVar(). The global
 var is already replaced in this function and keeping it around can prevent
 it from being cleaned up by DCE if it still has decorations.

* format code

---------

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Remove unnecessary parameters from Metal entry point signature (#6131)</title>
<updated>2025-01-22T16:57:53+00:00</updated>
<author>
<name>Darren Wihandi</name>
<email>65404740+fairywreath@users.noreply.github.com</email>
</author>
<published>2025-01-22T16:57:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=14211ec3c4e56e59f479dbac23123ea61eab7d91'/>
<id>urn:sha1:14211ec3c4e56e59f479dbac23123ea61eab7d91</id>
<content type='text'>
* fix metal entry point global params

* address review comments, cleanup and test

* remove dead code

* undo accidental change

* address review comments and cleanup

* minor fix and cleanup

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Support specialization constant on WGSL and Metal. (#5780)</title>
<updated>2024-12-06T08:55:35+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-12-06T08:55:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=8ce7c6f6958f9f5ed750ef1a823b9e9ed8c042d8'/>
<id>urn:sha1:8ce7c6f6958f9f5ed750ef1a823b9e9ed8c042d8</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move switch statement bodies to their own lines (#5493)</title>
<updated>2024-11-05T17:47:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-11-05T17:47:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b118451e301d734e3e783b3acdf871f3f6ea851c'/>
<id>urn:sha1:b118451e301d734e3e783b3acdf871f3f6ea851c</id>
<content type='text'>
* Move switch statement bodies to their own lines

* format

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>Remove using SpvStorageClass values casted into AddressSpace values (#4861)</title>
<updated>2024-08-19T22:06:34+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-08-19T22:06:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f77a5ac9d1547a4394bba4ab8e94d905972c79b7'/>
<id>urn:sha1:f77a5ac9d1547a4394bba4ab8e94d905972c79b7</id>
<content type='text'>
* Remove using SpvStorageClass values casted into AddressSpace values

Also removes support for specific storage classes in __target_intrinsic snippets

* remove SLANG_RETURN_NEVER macro

* squash warnings

* Make nonexhaustive switch statement error on gcc

* Add SLANG_EXHAUSTIVE_SWITCH_BEGIN/END macros

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Move SPIRV global variables into a context variable (#4741)</title>
<updated>2024-07-31T03:04:08+00:00</updated>
<author>
<name>ArielG-NV</name>
<email>159081215+ArielG-NV@users.noreply.github.com</email>
</author>
<published>2024-07-31T03:04:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=04e7327a2067c82db3eaef51955f211e148ac933'/>
<id>urn:sha1:04e7327a2067c82db3eaef51955f211e148ac933</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Overhaul IR lowering of pointer types. (#4710)</title>
<updated>2024-07-25T22:00:14+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-07-25T22:00:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=c9d89a40775a055873adf82cfb0ee1cb6bdcb93c'/>
<id>urn:sha1:c9d89a40775a055873adf82cfb0ee1cb6bdcb93c</id>
<content type='text'>
* Overhaul IR lowering of pointer types.

* Propagate address space in IRBuilder.

* Fixup.

* Fix.

* Fix.

* Change how Ptr type is printed to text.

* Fix.</content>
</entry>
</feed>
