<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-lookup.h, 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-01-17T01:06:00+00:00</updated>
<entry>
<title>Fix cyclic lookups with UnscopedEnums (#6110)</title>
<updated>2025-01-17T01:06:00+00:00</updated>
<author>
<name>Julius Ikkala</name>
<email>julius.ikkala@gmail.com</email>
</author>
<published>2025-01-17T01:06:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d3ad6bb4997d3b7ba2dc9653a2d5f7dc965b150f'/>
<id>urn:sha1:d3ad6bb4997d3b7ba2dc9653a2d5f7dc965b150f</id>
<content type='text'>
* Fix cyclic lookups with UnscopedEnums

* Add test with multiple unscoped enums with explicit types

---------

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>Fix lookup to prevent finding `typedef` itself. (#3848)</title>
<updated>2024-03-27T19:21:07+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-03-27T19:21:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=8395acfa0ad8379011e4470b94362189cafac93f'/>
<id>urn:sha1:8395acfa0ad8379011e4470b94362189cafac93f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Support visibility control and default to `internal`. (#3380)</title>
<updated>2023-12-06T20:05:07+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-12-06T20:05:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=11111e5733b189127dc2c4934d67693b9bc6e764'/>
<id>urn:sha1:11111e5733b189127dc2c4934d67693b9bc6e764</id>
<content type='text'>
* Support visibility control and default to `internal`.

* Fix wip.

* Fixes.

* Fix.

* Fix test.

* Add legacy language detection and compatibility for existing code.

* Add doc.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Redesign `DeclRef` and systematic `Val` deduplication (#3049)</title>
<updated>2023-08-04T22:47:39+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-08-04T22:47:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=a2d90fb275962da84611160f8ddd74d934a68dbd'/>
<id>urn:sha1:a2d90fb275962da84611160f8ddd74d934a68dbd</id>
<content type='text'>
* Redesign DeclRef + Deduplicate Val.

* Update project files

* Fix warning.

* Fix.

* Fix.

* Remove `Val::_equalsImplOverride`.

* Rmove `Val::_getHashCodeOverride`.

* Remove `semanticVisitor` param from `resolve`.

* Cleanups.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Fix erroneous error claiming variable is being used before its declaration (#2958)</title>
<updated>2023-07-06T19:52:00+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2023-07-06T19:52:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cdfea42f1b28c6ec7b13500a64be823f67bf8e0a'/>
<id>urn:sha1:cdfea42f1b28c6ec7b13500a64be823f67bf8e0a</id>
<content type='text'>
* Simplify type of diagnoseImpl

* Show source line for Note diagnostics, opting out of this where appropriate

* Make declared after use diagnostic clearer

* Fix erroneous error claiming variable is being used before its declaration

Closes https://github.com/shader-slang/slang/issues/2936

* Fix build on msvc

---------

Co-authored-by: jsmall-nvidia &lt;jsmall@nvidia.com&gt;</content>
</entry>
<entry>
<title>Auto synthesis of Differential type (#2466)</title>
<updated>2022-10-26T15:32:24+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-10-26T15:32:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=939be44ca23476e622dfb24a592383fe2a1da61f'/>
<id>urn:sha1:939be44ca23476e622dfb24a592383fe2a1da61f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make Scope non ref counted (#1904)</title>
<updated>2021-07-09T20:29:23+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2021-07-09T20:29:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=7b447bdad29c828b49ba63cefacc677bd7c58b28'/>
<id>urn:sha1:7b447bdad29c828b49ba63cefacc677bd7c58b28</id>
<content type='text'>
* Add debug symbols for release build.

* Hack to try and capture failing compilation.

* Typo fix for capture hack.

* Specify return type on lambdas.

* Added const.

* Try breakpoint.

* Up count

* Let's capture everything so we can valgrind.

* Disable always writing repros.

* Make Scope non RefCounted.

* Fix issue with not serializing Scope.

* More comments around changes to Scope.
Remove Scope* from serialization.

* Remove code used for testing original issue.</content>
</entry>
<entry>
<title>Work on struct inheritance and interfaces</title>
<updated>2020-06-18T23:00:40+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2020-06-17T21:55:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0eddf45f36f3948c18b8a45ef52b980f2a2b0cc9'/>
<id>urn:sha1:0eddf45f36f3948c18b8a45ef52b980f2a2b0cc9</id>
<content type='text'>
The main new feature that works here is that a derived `struct` type can satisfy one or more interface requirements using methods it inherited from a base `struct` type:

```hlsl
interface ICounter { [mutating] void increment(); }

struct CounterBase { int val; [mutating] void increment() { val++; } }

struct ResetableCounter : CounterBase, ICounter
{
    [mutating] void reset() { val = 0; }
}
```

Here the derived `ResetableCounter` type is satisfying the `increment()` requirement from `ICounter` using the inherited `CounterBase` method instead of one defined on `ResetableCounter`.

The crux of the problem here was that after lowering to HLSL/GLSL, the above code looks something like:

```hlsl
struct CounterBase { int val; };

void CounterBase_increment(in out CounterBase this) { this.val++; }

struct ResetableCounter { CounterBase base; }

void ResetableCounter_reset(in out ResetableCounter this) { this.base.val = 0; }
```

The central problem is that `CounterBase_increment` here is not type-compatible what we expect to find in the witness table for `ResetableCounter : ICounter`: the `this` parameter has the wrong type!

The basic solution strategy here is to intercept the search for a witness to sastify an interface requirement in `findWitnessForInterfaceRequirement` (those witnesses get collected into a witness table). The revised logic first looks for an exact match, which will only consider members introduced for the type itself, and not those introduced by base types.

If an exact match for a method requirement is not found, the semantic checker then tries to *synthesize* a witness for the requirement, which more or less amounts to generating a function like:

```hlsl
[mutating] void ResetableCounter::synthesized_increment()
{
    this.increment();
}
```

The body of that synthesized method will type-check just fine in this case (because it desugars into `this.base.increment()`, more or less), and thus the synthesized method declaration can be used as the actual witness that drives downstream code generation.

Details:

* I added some options to lookup to allow us to explicitly skip member lookup through base interfaces; this should make sure that we don't accidentally satisfy an interface requirement using a member of the same or another interface (since such members are conceptually `abstract`).

* As it originally stood, the semantic checker was allowing `CounterBase.increment()` to satisfy the `increment()` requirement of `ResetableCounter` directly, with the result that we got invalid HLSL/GLSL code as output. In order to avoid this and other bad cases, I made sure that the "exact match" case of requirement satisfaction ignores members that included any "breadcrumbs" in the lookup result item (since the breadcrumbs would all indicate transformations that needed to be applied to `this` to find the right member).

* If we eventually have targets where `this` is passed by pointer/reference in all cases, then all of this work is not needed for the common case of single inheritance, and the base-type method should be usable as a witness directly. I don't see any easy way to handle that special case without producing target-dependent code in the front-end. It might be that we need an IR pass that can detect functions that are trivial "forwarding" functions and replace them with the function they forward to.

* This change includes a test case that should have come along with the original PR that started adding struct inheritance

Caveats:

* The comments in this change talk about things like allowing a method with a default parameter to satisfy a requirement without that parameter. That scenario won't actually work at present because we still have an enormous hack in our logic for checking methods against requirements: we don't actually consider their signatures! I couldn't fold a fix for that issue into this change because there are subtle corner cases around associated types that we need to handle correctly (which were part of the reason why the checking is as hacked as it is)

* This change does *not* try to test or address the case where we want to have a `Derived` type conform to `ISomething` because it inherits from `Base` and `Base : ISomething`. That case has its own details that need to be worked out, but ideally can follow a similar implementation strategy when it comes to re-using methods from `Base` to satisfy requirement on `Derived`.
</content>
</entry>
<entry>
<title>ASTNodes use MemoryArena (#1376)</title>
<updated>2020-06-05T22:20:09+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-06-05T22:20:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=43c146794aab638924d2ab838d10f8af2ebf02a7'/>
<id>urn:sha1:43c146794aab638924d2ab838d10f8af2ebf02a7</id>
<content type='text'>
* Add a ASTBuilder to a Module
Only construct on valid ASTBuilder (was being called on nullptr on occassion)

* Add nodes to ASTBuilder.

* Compiles with RefPtr removed from AST node types.

* Initialize all AST node pointer variables in headers to nullptr;

* Initialize AST node variables as nullptr.
Make ASTBuilder keep a ref on node types.
Make SyntaxParseCallback returns a NodeBase

* Don't release canonicalType on dtor (managed by ASTBuilder).

* Give ASTBuilders a name and id, to help in debugging.
For now destroy the session TypeCache, to stop it holding things released when the compile request destroys ASTBuilders.

* Moved the TypeCheckingCache over to Linkage from Session.

* NodeBase no longer derived from RefObject.

* Only add/dtor nodes that need destruction.
First pass compile on linux.</content>
</entry>
</feed>
