<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/rewriter/resources-in-structs.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>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>Parameter blocks (#245)</title>
<updated>2017-11-06T18:37:27+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2017-11-06T18:37:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9919c823938ae929b16efac9d507f6d5eb122bf4'/>
<id>urn:sha1:9919c823938ae929b16efac9d507f6d5eb122bf4</id>
<content type='text'>
* Rename existing ParameterBlock to ParameterGroup

We are planning to add a new `ParameterBlock&lt;T&gt;` type, which maps to the notion of a "parameter block" as used in the Spire research work.
Unfortunately, the compiler codebase already uses the term `ParameterBlock` as catch-all to encompass all of HLSL `cbuffer`/`tbuffer` and GLSL `uniform`/`buffer`/`in`/`out` blocks (all of which are lexical `{}`-enclosed blocks that define parameters...).

This change instead renames all of the existing concepts over to `ParameterGroup`, which isn't an ideal name, but at least doesn't directly overlap the new terminology or any existing terminology.

The new `ParameterBlockType` case will probably be a subclass of `ParameterGroupType`, since it is a logical extension of the underlying concept.

* Add Shader Model 5.1 profiles

The HLSL `register(..., space0)` syntax is only allowed on "SM5.1" and later profiles (which is supported by the newer version of `d3dcompiler_47.dll` that comes with the Win10 SDK, but not the older version of `d3dcompiler_47.dll` - good luck figuring out which you have!).

This change adds those profiles to our master list of profiles, and nothing else.

* First pass at support for `ParameterBlock&lt;T&gt;`

- Add the type declaration in stdlib

- Add a special case of `ParameterGroupType` for parameter blocks

- Handle parameter blocks in type layout (currently handling them identically to constant buffers for now, which isn't going to be right in the long term)

- Add an IR pass that basically replaces `ParameterBlock&lt;T&gt;` with `T`
  - Eventually this should replace it with either `T` or `ConstantBuffer&lt;T&gt;`, depending on whether the layout that was computed required a constant buffer to hold any "free" uniforms

- Add first stab at an IR pass to "scalarize" global variables using aggregate types with resources inside.
  - This currently only applies to global variables, so it won't handle things passed through functions, or used as local variables
  - It also only supports cases where the references to the original variable are always references to its fields, and not the whole value itself

- Add a single test case that technically passes with this level of support, but probably isn't very representative of what we need from the feature

* Fold parameter-block desugaring into a more complete "type legalization" pass

The basic problem that was arising is that once you desugar `ParameterBlock&lt;T&gt;` into `T`, you then need todeal with splitting `T` into its constituent fields if it contains any resource types.
Handling those transformations by following the usual use-def chains wasn't really helping, because you might need systematic rewriting that can really only be handled bottom-up.

This change adds a new pass that is intended to perform multiple kinds of type "legalization" at once:

- It will turn `ParameterBlock&lt;T&gt;` into `T`
  - It may at some point also convert `ConstantBuffer&lt;T&gt;` into `T` as well
- It will turn an value of an aggregate type that contains resources into N different values (one per field)
  - As a result of this, it will also deal with AOS-to-SOA conversion of these types

Legalization is applied to *every* function/instruction/value, so that it can make large-scale changes that would be tough to manage with a work list.

This pass needs to be run *after* generics have been fully specialized, so that we know we are always dealing with fully concrete types, so that their legalization for a given target is completely known.

This is still work in progress; there's more to be done to get this working with all our test cases, and finish the remaining `ParameterBlock&lt;T&gt;` work.

* Improve binding/layout information when using parameter blocks

- When doing type layout for a parameter block, don't include the resources consumed by the element type in the resource usage for the parameter block
  - Note that this is pretty much identical to how a `ConstantBuffer&lt;T&gt;` does not report any `LayoutResourceKind::Uniform` usage, except that `ParameterBlock&lt;T&gt;` is *also* going to hide underlying texture/sampler reigster usage
  - The one exception here is that any nested items that use up entire `space`s or `set`s those need to be exposed in the resource usage of the parent (I don't have a test for this)

- When type legalization needs to scalarize things, it must propagate layout information down to the new leaf variables. In general, the register/index for a new leaf parameter should be the sum of the offsets for all of the parent variables along the "chain" from the original variable down to the leaf (we aren't dealing with arrays here just yet).

- When type legalization decides to eliminate a pointer(-like) type (e.g., desugar `ParameterBlock&lt;T&gt;` over to `T`), actually deal with that in terms of the `LegalVal`s created, so that we can know to turn a `load` into a no-op when applied to a value that got indirection removed.

- Hack up the "complex" parameter-block test so that it actually passes (the big hack here is that the HLSL baseline is using names that are generated by the IR, and are unlikely to be stable as we add/remove transformations).
  - Note: I can't make these be compute tests right now, because regsiter spaces/sets are a feature of D3D12/Vulkan, and our test runner isn't using those APIs.
</content>
</entry>
<entry>
<title>Work around glslang issue 988</title>
<updated>2017-07-24T01:37:52+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-07-24T01:22:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d4cfe5781284551d7c5ccf2cf1d28a86211bb1df'/>
<id>urn:sha1:d4cfe5781284551d7c5ccf2cf1d28a86211bb1df</id>
<content type='text'>
The basic bug there is that if you have a member of `struct` type in a `uniform` block and then pass a reference to that member directly to a call:

```
struct Foo { vec4 bar; };
uniform U { Foo foo; };

void main() { doSomething(foo); }
```

then glslang generates invalid SPIR-V which seems to cause an issue for some drivers.

This change works around the problem by detecting cases where an argument to a function call is a reference to `uniform` block member (of `struct` type) and then rewrites the code to move that value to a temporary before the call.
</content>
</entry>
<entry>
<title>Don't assign a `binding` to a `push_constant` buffer</title>
<updated>2017-07-14T18:09:10+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-07-14T17:44:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2bf87743ffe73f041036ae62c8bf53f09215ca53'/>
<id>urn:sha1:2bf87743ffe73f041036ae62c8bf53f09215ca53</id>
<content type='text'>
Fixes #12

- This was a latent issue, but the previous commit brought it to the front.

- As indicated in #12, I don't allocate a descriptor-table slot to the block
  - Instead I allocate a `PushConstantBuffer`

- Unlike what #12 asks for, I don't use a different resource type for the contents of the block
  - Pretty much all the logic is easiest if these continue to be just plain `Uniform` data
</content>
</entry>
<entry>
<title>Initial work on handling resources in structs during cross-compilation</title>
<updated>2017-07-11T19:07:09+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoley@nvidia.com</email>
</author>
<published>2017-07-10T22:40:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bd7105ff8683a680d1270eca8cd74f9002144dbd'/>
<id>urn:sha1:bd7105ff8683a680d1270eca8cd74f9002144dbd</id>
<content type='text'>
- The basic idea is that during the "lowering" pass, some types (notably: aggregate types that contain resource variables) will get turned into "tuple" types, which are pseduo-types that aren't meant to survive lowering.

- An attempt to declare a variable with a tuple type expands into a tuple of declarations

- An attempt to reference such a tuple-ified variable leads to a tuple of expressions

- An attempt to extract a member from such a tuple expression will pick the appropriate sub-element

- Dereference a tuple by dereferencing the primary expression

- Expand a tuple in the argument list to a call into N arguments (by recursively flattening the tuple)

- Don't create tuple types when not generating GLSL

- Make sure to preserve the specialized type of a call expression through lowering, since emission of unchecked calls relies on that info.
  - TODO: maybe the infix/prefix/postifx/select information should come in as a side-band? Should we have modifiers on expressions?

- Make sure to offset the layout for a nested field based on teh base offset of its parent variable, when generating declarations for nested fields
</content>
</entry>
</feed>
