<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/hlsl.meta.slang.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>2020-03-06T22:15:58+00:00</updated>
<entry>
<title>Remove generated header files (#1264)</title>
<updated>2020-03-06T22:15:58+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-06T22:15:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cdee13466080b737ed18c148e36af75898285ed6'/>
<id>urn:sha1:cdee13466080b737ed18c148e36af75898285ed6</id>
<content type='text'>
* Update slang-binaries to verison with SPIR-V version support.

* Support vec and matrix Wave intrinsics on vk.
Added wave-vector.slang test
Add wave-diverge.slang test
Add support for more wave intrinsics to vk.

* Test out Wave intrinsic support for matrices.

* Remove matrix glsl intrinsics -&gt; not available.
Fix some typo.

* Remove generated slang generated headers.</content>
</entry>
<entry>
<title>Wave intrinsics for Vector and Matrix types (#1262)</title>
<updated>2020-03-06T20:46:35+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-06T20:46:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b94a12b91086ea004d9b78fa8a14fd4726af9e76'/>
<id>urn:sha1:b94a12b91086ea004d9b78fa8a14fd4726af9e76</id>
<content type='text'>
* Update slang-binaries to verison with SPIR-V version support.

* Support vec and matrix Wave intrinsics on vk.
Added wave-vector.slang test
Add wave-diverge.slang test
Add support for more wave intrinsics to vk.

* Test out Wave intrinsic support for matrices.

* Remove matrix glsl intrinsics -&gt; not available.
Fix some typo.</content>
</entry>
<entry>
<title>Expand range of definitions that can be moved into stdlib (#1259)</title>
<updated>2020-03-06T19:37:36+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-03-06T19:37:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=18be2d81fd2740d3f0c06fc407cff1702b93d468'/>
<id>urn:sha1:18be2d81fd2740d3f0c06fc407cff1702b93d468</id>
<content type='text'>
The actual definitions that got moved into the stdlib here are pretty few:

* `clip()`
* `cross()`
* `dxx()`, `ddy()` etc.
* `degrees()`
* `distance()`
* `dot()`
* `faceforward()`

The meat of the change is infrastructure changes required to support these new declarations

* Generic versions of the standard operators (e.g., `operator+`) were added that are generic for a type `T` that implements the matching `__Builtin`-prefixed interface. An open question is whether we can now drop the non-generic versions in favor of just having these generic operators.

* A `__BuiltinLogicalType` interface was added to capture the commonality between integers and `bool`

* `__BuiltinArithmeticType` was extended so that implementations must support initialization from an `int`

* `__BuiltinFloatingPointType` was extended to require an accessor that returns the value of pi for the given type, and the concrete floating-point types were extended to provide definitions of this value.

* It turns out that our logic for checking if two functions have the same signature (and should thus count as redeclarations/redefinitions) wasn't taking generic constraints into account at all. That was fixed with a stopgap solution that checks if the generic constraints are pairwise identical, but I didn't implement the more "correct" fix that would require canonicalizing the constraints.

* When doing overload resolution and considering potential callees, logic was added so that a non-generic candidate should always be selected over a generic one (generally the Right Thing to do), and also so that a generic candidate with fewer parameters will be selected over one with more (an approximation of the much more complicated rule we'd ideally have).

* The formatting of declarations/overloads for "ambiguous overload" errors was fleshed out a bit to include more context (the "kind" of declaration where appropriate, the return type for function declarations) and to properly space thing when outputting specialization of operator overloads that end with `&lt;` (so that we print `func &lt; &lt;int&gt;(int, int)` instead of just `func &lt;&lt;int,int&gt;(int,int)`).

* The core lookup routines were heavily refactored and reorganized to try to make them bottleneck more effectively so that all paths handle all the nuances of inheritance, extensions, etc.

* Because of the refactoring to lookup logic, the semantic checking logic related to checking if a type conforms to an interface was updated to be driven based on the `Type` that is supposed to be conforming, rather than a `DeclRef` to the type's declaration. This allows it to use the type-based lookup entry point and eliminates one special-case entry point for lookup.

In addition to the various core changes, this change also refactors some of the existing stdlib code to favor writing more things in actual Slang syntax, and less in C++ code that uses `StringBuilder` to construct the Slang syntax. There is a lot more that could be done along those lines, but even pushing this far is showing that the current approach that `slang-generate` takes for how to separate meta-level C++ and Slang code isn't really ideal, so a revamp of the generator code is probably needed before I continue pushing.

One surprising casualty of the refactoring of lookup is that we no longer have the `lookedUpDecls` field in `LookupResult`. That field probably didn't belong there anyway, but the role it served was important. The idea of `lookedUpDecls` was to avoid looking up in the same interface more than once in cases where a type might have a "diamond" inheritance pattern. Removing that field doesn't appear to affect correctness of any of our existing tests, but by adding a specific test for "diamond" inheritance I could see that the refactoring introduced a regression and made looking up a member inherited along multiple paths ambiguous.

Rather than add back `lookedUpDecls` I went for a simpler (but arguably even hackier) solution where when ranking candidates from a `LookupResult` we check for identical `DeclRef`s and arbitrarily favor one over the other. One complication that arises here is that when comparing `DeclRef`s inherited along different paths they might have a `ThisTypeSubstitution` for the same type, but with different subtype witnesses (because different inheritance paths could lead to different transitive subtype witnesses: e.g., `A : B : D` and `A : C : D`).</content>
</entry>
<entry>
<title>Feature/glslang spirv version (#1256)</title>
<updated>2020-03-05T15:59:54+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-05T15:59:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=6684d32db1f5693bcfb4971558cb30e855cd3bad'/>
<id>urn:sha1:6684d32db1f5693bcfb4971558cb30e855cd3bad</id>
<content type='text'>
* WIP add support for __spirv_version .

* Added IRRequireSPIRVVersionDecoration

* SPIR-V version passed to glslang.
Enable VK wave tests.
Split ExtensionTracker out, so can be cast and used externally to emit.
Added SourceResult.

* Fix warning on Clang.

* Missing hlsl.meta.h

* Refactor communication/parsing of __spirv_version with glslang.

* Fix some debug typos.
Be more precise in handling of substring handling.

* Make glslang forwards and backwards binary compatible.

* Small comment improvements.

* Added slang-spirv-target-info.h/cpp

* Fix for major/minor on gcc.

* Another fix for gcc/clang.

* VS projects include slang-spirv-target-info.h/cpp

* Removed SPIRVTargetInfo
Added SemanticVersion.
Don't bother with passing a target to glslang. Should be separate from 'version'.

* Renamed slang-emit-glsl-extension-tracker.cpp/.h -&gt; slang-glsl-extension-tracker.cpp/.h
Fixed some VS project issues.

* Fix a comment.

* Added slang-semantic-version.cpp/.h

* Added slang-glsl-extension-tracker.cpp/.h

* Added split that can check for input has all been parsed.

* Fix problem on x86 win build.
</content>
</entry>
<entry>
<title>__spirv_version Decoration (#1255)</title>
<updated>2020-03-03T23:41:07+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-03T23:41:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=5951d2a45f3546a619fb5b032a4a422229c46e4c'/>
<id>urn:sha1:5951d2a45f3546a619fb5b032a4a422229c46e4c</id>
<content type='text'>
* WIP add support for __spirv_version .

* Added IRRequireSPIRVVersionDecoration
</content>
</entry>
<entry>
<title>Move definitions of simple vector/matrix builtins to stdlib. (#1247)</title>
<updated>2020-03-03T19:49:40+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-03-03T19:49:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0f1f4a42df4efd32b80fd2b01f3893435e47e980'/>
<id>urn:sha1:0f1f4a42df4efd32b80fd2b01f3893435e47e980</id>
<content type='text'>
Some of the functions declared in the Slang standard library are built in on some targets (almost always the case for HLSL) but aren't available on other targets (often the case for GLSL, CUDA, and CPU). To date, the CUDA and CPU targets have worked around this issue by synthesizing definitions of the missing functions on the fly as part of output code generation, at the cost of some amount of code complexity in the emit pass.

This change adds definitions inside the stdlib itself for a large number of built-in HLSL functions that act element-wise over both vectors and matrices (e.g., `sin()`, `sqrt()`, etc.), and changes the CPU/CUDA codegen path to *not* synthesize C++ code for those functions (instead relying on code generated from the Slang definitions).

The element-wise vector/matrix function bodies are being defined using macros in the stdlib, so that we can more easily swap out the definitions en masse if we find an implementation strategy we like better. This could involve defining special-case syntax just for vector/matrix "map" operations that can lower directly to the IR and theoretically generate cleaner code after specialization is complete.

As a byproduct of this change, the matrix versions of these functions should in principle now be available to GLSL (GLSL only defines vector versions of functions like `sin()`, and leaves out matrix ones). No testing has been done to confirm this fix.

In some cases builtins were being declared with multiple declarations to split out the HLSL and GLSL cases, and this change tries to unify these as much as possible into single declarations to keep the stdlib as small as possible.

Two functions -- `sincos()` and `saturate()` -- were simple enough that their full definitions could be given in the stdlib so that even the scalar cases wouldn't need to be synthesized, so the corresponding enumerants were removed in `slang-hlsl-intrinsic-set.h`. In the case of `saturate()` the pre-existing definition used for GLSL codegen could have been used for CPU/CUDA all along.

In some cases functions that can and should be defined in the future have had commented-out bodies added as an outline for what should be inserted in the future. Most of these functions cannot be implemented directly in the stdlib today because basic operations like `operator+` are currently not defined for `T : __BuiltinArithmeticType`, etc. Adding such declarations should be straightforward, but brings risks of creating unexpected breakage, so it seemed best to leave for a future change.

This change does not try to address making vector or matrix versions of builtin functions that map to single `IROp`s, because the existing mechanisms for target-based specialization, etc., do not apply for such cases. In the future we will either have to make those operations into ordinary functions (eliminating many `IROp`s) so that stdlib definitions can apply, or add an explicit IR pass to deal with legalizing vector/matrix ops for targets that don't support them natively. The right path for this is not yet clear, so this change doesn't wade into it.

This change does not touch the `Wave*` functions added in Shader Model 6, despite many of these having vector/matrix versions that could benefit from the same default mapping. It is expected that these functions will have GLSL/Vulkan translation added soon, and it probably makes sense to know what cases are directly supported on Vulkan before adding the hand-written definitions.

Because of the limitations on what could be ported into the stdlib, it is not yet possible to remove any of the infrastructure for synthesizing builtin function definitions in the CPU and CUDA back-ends.</content>
</entry>
<entry>
<title>Feature/glsl wave intrinsic (#1253)</title>
<updated>2020-03-02T22:22:03+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-02T22:22:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=dbd8e8dc0847338a2a93d35385f48b5ce5671dd6'/>
<id>urn:sha1:dbd8e8dc0847338a2a93d35385f48b5ce5671dd6</id>
<content type='text'>
* Test for some wave intrinsics.
More wave intrinsic support on CUDA.

* Use shfl_xor_sync.

* Improvements around wave intrinsics.
Fix built in integer types belong to __BuiltinIntegerType.

* Improvements and fixes around Wave intrinsics.

* Added WaveIsFirstLane test.
No longer use __wavemask_lt, as appears not available as an intrinsic.

* Small fixes to CUDA prelude.

* Add wave-active-product test.
Handle the special case for arbitray sums.

* Used macro to implement CUDA wave intrinsics.

* First pass at glsl wave intrinsics. Doesn't work in practice because require mechanism to set spir-v version
Replace use of _lanemask_lt() for CUDA.
</content>
</entry>
<entry>
<title>Additional Wave Intrinsic Support (#1252)</title>
<updated>2020-03-02T21:18:20+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-03-02T21:18:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=8899c149b05def1cce626ea649012c4c974861de'/>
<id>urn:sha1:8899c149b05def1cce626ea649012c4c974861de</id>
<content type='text'>
* Test for some wave intrinsics.
More wave intrinsic support on CUDA.

* Use shfl_xor_sync.

* Improvements around wave intrinsics.
Fix built in integer types belong to __BuiltinIntegerType.

* Improvements and fixes around Wave intrinsics.

* Added WaveIsFirstLane test.
No longer use __wavemask_lt, as appears not available as an intrinsic.

* Small fixes to CUDA prelude.

* Add wave-active-product test.
Handle the special case for arbitray sums.

* Used macro to implement CUDA wave intrinsics.
</content>
</entry>
<entry>
<title>WIP on RWTexture types on CUDA/CPU (#1234)</title>
<updated>2020-02-20T23:24:00+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-02-20T23:24:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=1f401d04e32c6feaeb35243ea5bfc2b14520344b'/>
<id>urn:sha1:1f401d04e32c6feaeb35243ea5bfc2b14520344b</id>
<content type='text'>
* CUDA support for array of resources.

* * Add support for Texture2DArray on CPU
* Expand texture-simple.slang to test Texture2DArray

* Reorganise CUDAComputeUtil to split out createTextureResource.

* Add TextureCubeArray support for CPU/CUDA targets.

* Pulled out CUDAResource
Renamed derived classes to reflect that change.

* Creation of SurfObject type.

* Functions to return read/write access for simplifying future additions.

* WIP for RWTexture access on CPU/CUDA.

* CUsurfObject cannot have mips.

* Ability to set number of mips on test data.
Preliminary support for CUsurfObj and RWTexture1D on CUDA.
CUDA docs improvements.

* Fix typo.
</content>
</entry>
<entry>
<title>Don't allocate a default space for a VK push-constant buffer (#1231)</title>
<updated>2020-02-19T22:36:44+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-02-19T22:36:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=788556aaaab1b5767e24cf86dc2f71fd285c06f5'/>
<id>urn:sha1:788556aaaab1b5767e24cf86dc2f71fd285c06f5</id>
<content type='text'>
When a shader only uses `ParameterBlock`s plus a single buffer for root constants:

```hlsl
ParameterBlock&lt;A&gt; a;
ParameterBlock&lt;B&gt; b;

[[vk::push_constant]] cbuffer Stuff { ... }
```

we expect the push-constant buffer should not affect the `space` allocated to the parameter blocks (so `a` should get `space=0`).

This behavior wasn't being implemented correctly in `slang-parameter-binding.cpp`. There was logic to ignore certain resource kinds in entry-point parameter lists when computing whether a default space is needed, but the equivalent logic for the global scope only considered parameters that consuem whole register spaces/sets.

This change shuffles the code around and makes sure it considers a global push-constant buffer as *not* needing a default space/set.

Note that this change will have no impact on D3D targets, where `Stuff` above would always get put in `space0` because for D3D targets a push-constant buffer is no different from any other constant buffer in terms of register/space allocation.

One unrelated point that this change brings to mind is the `[[vk::push_constant]]` should ideally also be allowed to apply to an entry point (where it would modify the default/implicit constant buffer). In fact, it could be argued that push-constant allocation should be the *default* for (non-RT) entry point `uniform` parameters (while `[[vk::shader_record]]` should be the default for RT entry point `uniform` parameters).</content>
</entry>
</feed>
