<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/ast-legalize.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>2018-02-03T15:30:54+00:00</updated>
<entry>
<title>Remove non-IR codegen paths (#398)</title>
<updated>2018-02-03T15:30:54+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2018-02-03T15:30:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=662f43fff6721c6cd013a8f1b2639c2e29fe6be3'/>
<id>urn:sha1:662f43fff6721c6cd013a8f1b2639c2e29fe6be3</id>
<content type='text'>
The basic change is simple: remove support for all code generation paths other than the IR.
There is a lot of vestigial code left, but the main logic in `ast-legalize.*` is gone.

Doing this breaks a *lot* of tests, for various reasons:

- We can no longer guarantee exactly matching DXBC or SPIR-V output after things pass through out IR

- Many builtins don't have matching versions defined for GLSL output via IR (even when they had versions defined via the earlier approach that worked with the AST)

- A lot of code creates intermediate values of opaque types in the IR, which turn into opaque-type temporaries that aren't allowed (this breaks many GLSL tests, but also some HLSL)

I implemented some small fixes for issues that I could get working in the time I had, but most of the above are larger than made sense to fix in this commit.

For now I'm disabling the tests that cause problems, but we will need to make a concerted effort to get things working on this new substrate if we are going to make good on our goals.</content>
</entry>
<entry>
<title>Remove support for the -no-checking flag (#392)</title>
<updated>2018-02-02T16:49:04+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2018-02-02T16:49:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0360f81b9741ece65768a65731bd23455a3b7a96'/>
<id>urn:sha1:0360f81b9741ece65768a65731bd23455a3b7a96</id>
<content type='text'>
* Remove support for the -no-checking flag

Fixes #381
Fixes #383
Work on #382

- No longer expose flag through API (`SLANG_COMPILE_FLAG_NO_CHECKING`) and command-line (`-no-checking`) options

- Remove all logic in `check.cpp` that was withholding diagnostics (including errors) when the no-checking mode was enabled

- Remove `HiddenImplicitCastExpr`, which was only created to support no-checking mode (it represented an implicit cast that our checking through was needed, but couldn't emit because it might be wrong)

- Remove logic for storing function bodies as raw token lists when checking is turned off. I'm leaving in the `UnparsedStmt` AST node in case we ever need/want to lazily parse and check function bodies down the line.

- Remove a few of the code-generation paths we had to contend with, but keep the comment about them in place.

- Remove GLSL-based tests that can't meaningfully work with the new approach.

- Fix other tests that used a GLSL baseline so that their GLSL compiles with `-pass-through glslang` instead of invoking `slang` with the `-no-checking` flag.

- Remove tests that were explicitly added to test the "rewriter + IR" path, since that is no longer supported.

There is more cleanup that can be done here, now that we know that AST-based rewrite and IR will never co-exist, but it is probably easier to deal with that as part of removing the AST-based rewrite path.

We've lost some test coverage here, but actually not too much if we consider that we are dropping GLSL input anyway.

* Fixup: test runner was mis-counting ignored tests

* Fixup: turn on dumping on test failure under Travis

* Fixup: enable extensions in Linux build of glslang
</content>
</entry>
<entry>
<title>All compiler fixes to get ir branch work with falcor feature demo.</title>
<updated>2018-01-18T01:54:56+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2018-01-17T19:48:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=caf6f7a03793be3fc74683994414776f3604ad8a'/>
<id>urn:sha1:caf6f7a03793be3fc74683994414776f3604ad8a</id>
<content type='text'>
- support overloaded generic function. this involves adding a new expression type, `OverloadedExpr2` to hold the candidate expressions for the generic function decl being referenced.
- make BitNot a normal IROp instead of an IRPseudoOp
- make sure we clone the decorations of parameters when cloning ir functions
- propagate geometry shader entry point attributes (`[maxvertexcount]` and `[instance]`) through HLSL emit
- IR emit: handle geometry shader entry-point parameter decorations, such as 'triangle'.
- IR emit: treat geometry shader stream output typed ir value as `should fold into use`.
</content>
</entry>
<entry>
<title>Refactor substitution representation in DeclRefBase (#363)</title>
<updated>2018-01-12T22:15:56+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2018-01-12T22:15:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=df6eeb93c1718334779ae328db277cdf7a9d7b04'/>
<id>urn:sha1:df6eeb93c1718334779ae328db277cdf7a9d7b04</id>
<content type='text'>
This commit changes the type of `DeclRefBase::substitutions` from `RefPtr&lt;Substitutions&gt;` to `SubstitutionSet`, which is a new type defined as following:
```
struct SubstitutionSet
{
    RefPtr&lt;GenericSubstitution&gt; genericSubstitutions;
    RefPtr&lt;ThisTypeSubstitution&gt; thisTypeSubstitution;
    RefPtr&lt;GlobalGenericParamSubstitution&gt; globalGenParamSubstitutions;
}
```
This change get rid of most helper functions to retreive the substitution of a certain type, as well as surgery operations to insert a `ThisTypeSubstitution` or `GlobalGenericTypeSubstittuion` at top or bottom of the substitution chain. It also simplies type comparison when certain type of substitution should not be considered as part of type definition.</content>
</entry>
<entry>
<title>Always respect dependency order when lowering decls via AST (#344)</title>
<updated>2018-01-02T17:29:21+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2018-01-02T17:29:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=17369d9a4f26a15393c15a9de4199d2963236c0b'/>
<id>urn:sha1:17369d9a4f26a15393c15a9de4199d2963236c0b</id>
<content type='text'>
Fixes #333

The code in `ast-legalize` is passed an array of declarations that have been ordered by dependencies using a topological sort. Unfortunately, it was only using that list in the case where the request was considered to be a "rewrite" request, and would otherwise rely on the order in which things get forced during the recursive walk (which doesn't really work for our needs).</content>
</entry>
<entry>
<title>fix ast-lowering of `TransitiveSubtypeWitness` values.</title>
<updated>2017-12-27T01:20:54+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2017-12-27T01:20:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=fd0b8ca60e62bbc51b2be220f985dc3cc0d6dc82'/>
<id>urn:sha1:fd0b8ca60e62bbc51b2be220f985dc3cc0d6dc82</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix up parameter block emit for mixed rewriter+IR (#316)</title>
<updated>2017-12-19T23:17:23+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2017-12-19T23:17:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=563fc0cb8268a3e028f32b93ca94ff1c27cd1a10'/>
<id>urn:sha1:563fc0cb8268a3e028f32b93ca94ff1c27cd1a10</id>
<content type='text'>
* Fix up parameter block emit for mixed rewriter+IR

The basic problem here arose when a parameter block was declared in code that will be lowered via IR, but is referenced from user code that will use the AST-based lowering pass. The type legalization would split up the parameter block, and the AST would refer to the new variables, but it would fail to recognize when those variables represent constant buffers, and thus should get implicit-dereference behavior.

The fix here was just to propagate type information through when creating new AST (pseudo-)expressions to represent IR declarations that were split.

A more complete fix down the road should try to make sure that both the expression emit logic and the declaration-emit logic agree on whether a particular declaration of a parameter block or constant buffer needs to support the "implicit dereference" case or not. I'm leaving that to future work.

With this change, two test cases that had been disabled now pass.

* Fixup: don't do implicit deref for `ParameterBlock` values

Right now the rules for `ParameterBlock` and all other uniform praameter groups needs to be different, but the `isImplicitBaseExpr` logic wasn't taking that into account.
</content>
</entry>
<entry>
<title>Work on getting rewriter + IR playing nice together. (#314)</title>
<updated>2017-12-18T23:14:59+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2017-12-18T23:14:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=393e25fd2e2b8c5ff82ff4c6b14a9d7152d37a5e'/>
<id>urn:sha1:393e25fd2e2b8c5ff82ff4c6b14a9d7152d37a5e</id>
<content type='text'>
* Work on getting rewriter + IR playing nice together.

There are a few different changes here, with the goal of improving the interaction between the "rewriter" code generation approach and the new IR and type legalization code.

The main changes are:

- Add a new pass that occurs before the AST legalization pass, which walks the (used) AST declarations and tries to discover (1) which declarations need to be specialized/lowered via the IR, and (2) which declarations need to be included in the resulting AST module.

- AST-based legalization now uses the generated list when in "rewriter" mode, so that we should be working around issues that users were seeing with types not getting emitted.
  - TODO: we still need an equivalent fixup in the case of non-"rewriter" emit, so this may still be a problem for `.slang` files.

- IR type legalization now precedes AST legalization, so that we can record information on how any IR global values got legalized (e.g., if they got split). Then AST legalization includes logic to reconstruct suitable tuple expressions to reference a split global.

- When emitting using IR + AST, we walk all of the declarations that we decided belonged to the IR, but which were subsequently referenced in the AST, to make sure they get output (this would include `struct` types that are declared in a file compiled via IR, but never used in IR-based code).

The rewriter+IR use case still doesn't *quite* work, but the logic for walking the AST in a pre-pass ends up being needed/useful to fix some pure rewriter bugs, so I'm getting this checked in sooner rather than later.

* Fixup: walk arguments to generic declaration reference

The gotcha here is that the code for walking the AST would walk a line of code like:

    SomeType a;

and know to traverse the declaration of `SomeType`, but if it saw a line of code like:

    ParameterBlock&lt;SomeType&gt; b;

it would traverse the declaration of `ParameterBlock`, but fail to visit that of `SomeType`.
</content>
</entry>
<entry>
<title>Fix parameter block binding for Vulkan (#308)</title>
<updated>2017-12-13T23:48:29+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2017-12-13T23:48:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=6d6142122b15461d6c8cabdb31292b0de688ba35'/>
<id>urn:sha1:6d6142122b15461d6c8cabdb31292b0de688ba35</id>
<content type='text'>
Fixes #307

This ends up being a major overhaul over how type layout computation is structured and exposed.
The big problems all arise around cases where both the "container" for a parameter block or CB, and the "element" type both use the same kind of resource.
E.g., if you define a CB with a texture in it, then in Vulkan both the CB and the texture use the same kind of resource, and so if you query the CB's resource usage it will just tell you it uses two descriptor-table slots, but nothing more than that.

Similar confusion still arises in the HLSL case, when a CB with a texture in it reports its parameter category as "mixed" so that a user might query for a category they didn't mean to. There were also cases in the existing code where a parameter block might expose *both* a register-space usage and another concrete resource type, which isn't right.

The most important changes here are:

- A `ParameterGroupTypeLayout` now has a more refined internal structure, consisting of:
  - A `containerTypeLayout`, which represents the resource usage of the buffer/block itself (e.g., if a constant buffer had to be allocated)
  - An `elementVarLayout` which stores the offsets that need to be applied to get from the `VarLayout` for an instance of this parameter-group type to the offsets of its elements. The `TypeLayout` for this variable layout should be the "raw" type of the block/CB element.
  - The `offsetElementTypeLayout` (formerly just `elementTypeLayout`) which represents the element type, but in the case of a `struct` element type, will have fields offset similar to the `elementVarLayout`. This is what all the old code used to use, so we need to keep it for compatibility.

- When doing reflection on a `ParameterGroupTypeLayout`, we now only report the resource usage of the `containerTypeLayout`. This is technically a potentially breaking change in the public API, but I don't think Falcor will mind, since they actually want something closer to this behavior.

- Add a new public API for querying the element variable layout of a parameter block of constant buffer. This could be used by savvy applications to fold the handling of CB element offsetting into some notion of a "reflection path." This would be required for applications that want to handle CBs or parameter blocks where the element type is *not* a `struct` type.

- Remove old logic for applying an offset when creating a type layout for constant buffer element, and instead perform offsetting more uniformly later, by constructing the `offsetElementTypeLayout` from the `rawElementTypeLayout`. This is useful both because we want to keep both (the "raw" type layout becomes the type layout of the `elementVarLayout`), and also because we can decide later whether we even want to allocate a CB register for a buffer, based on whether it actually contains any uniform data.

- Fix cases where we might end up with a parameter block type reporting both that it uses a whole register space (and thus should not expose the resource usage of the container/element type) *and* a constant-buffer register/slot. The latter should be hidden inside the regsiter space.

- Clean up the `spReflectionParameter_GetBinding{Index,Space}` functions to just route to `spReflectionVariableLayout_Get{Offset,Space}`, using the "default" category of the parameter

- Try to make the `GetSpace` query take into account cases where a variable also has an explicit `RegisterSpace` allocation.
  - This probably still needs some cleanup, since ideally we'd just move things into the `space` field on the `ReosurceInfo` and have an invariant that a variable *either* has a `RegisterSpace` allocation, or it has other resource infos, but never both...

- Add some ad-hoc logic so that if the user queries for a binding index/space using a parameter category that doesn't actually apply (e.g., they query for a D3D `t` register when using Vulkan), we can optionally remap it to the resource type they "probably" meant. This is a mess of Do What I Mean code, but it is also what our users want right now.

- Fix various bits of emit logic so that if a parameter block has a register space/set allocated to it, we properly output that as part of the binding information for it.
  - This is another thing that might be cleaned up if we rationale the way that things get split during legalization.

- Add a GLSL case for emitting a parameter block variable as a `cbuffer`.</content>
</entry>
<entry>
<title>Cleanups to `ParameterBlock&lt;T&gt;` behavior. (#304)</title>
<updated>2017-12-08T22:23:12+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2017-12-08T22:23:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0f55649cc1aa8ad3218b7f8ba7b1eabdd2ec6526'/>
<id>urn:sha1:0f55649cc1aa8ad3218b7f8ba7b1eabdd2ec6526</id>
<content type='text'>
* Cleanups to `ParameterBlock&lt;T&gt;` behavior.

These add some more realistic tests using the `ParameterBlock&lt;T&gt;` support, and show that it can work with the "rewriter" mode.

Unfortunately, this code does *not* currently work with the rewriter + the IR at once. That will need to be fixed in a follow-on change, because I now see that the root problem is pretty ugly.

* cleanup
</content>
</entry>
</feed>
