<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-decl-defs.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-05-08T18:31:40+00:00</updated>
<entry>
<title>AST nodes using C++ Extractor (#1341)</title>
<updated>2020-05-08T18:31:40+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-05-08T18:31:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=798f3bc2236ce81499b05662dc11e7c071e7cde8'/>
<id>urn:sha1:798f3bc2236ce81499b05662dc11e7c071e7cde8</id>
<content type='text'>
* Extractor builds without any reference to syntax (as it will be helping to produce this!).

* Change macros to include the super class.

* WIP replacing defs files.

* Added indexOf(const UnownedSubString&amp; in) to UnownedSubString.
Refactored extractor
* Output a macro for each type with the extracted info - can be used during injection in class
* Simplify the header file - as can get super type and last from macro now
* Store the 'origin' of a definition

* Some small tidy ups to the extractor.

* Improve comments on the extractor options.

* Made CPPExtractor own SourceOrigins

* Small fixes around SourceOrigin.

* Small tidy up around macroOrign

* WIP Visitor seems now to work correctly.
Split out types used by ast into slang-ast-support-types.h

* Fix remaining problems with C++ extractor being used with AST nodes.
Add CountOf to extractor type ids.
Added ReflectClassInfo::getInfo to turn an ASTNodeType into a ReflectClassInfo

* Fix compiling on linux.
Fix typo in memset.

* Small tidy up around comments/layout.
Moved NodeBase casting to NodeBase.

* Make premake generate project that builds with cpp-extractor for AST.

* Get the source directory from the filter in premake.

* Fix typo in source path

* Explicitly set the source path for  premake generation for AST.

* Special case handling of override to apease Clang.

* Use a more general way to find the slang-ast-reflect.h file to run the extractor.

* Appveyor is not triggering slang-cpp-extractor - try putting dependson together.

* Put building slang-cpp-extractor first.

* Disable some project options to stop MSBuild producing internal compiler errors.

* Try reordering the projects in premake5.lua

* Hack to try and make slang-cpp-extractor built on appveyor.

* Disable flags - not required for MSBuild on appveyor.

* Disable flags not required for build on AppVeyor.

* Updated Visual Studio projects with slang-cpp-extractor.

* Added Visual Studio slang-cpp-extractor project.</content>
</entry>
<entry>
<title>Optimize creation of memberDictionary (#1305)</title>
<updated>2020-04-02T21:06:16+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2020-04-02T21:06:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=00e1dba744dc8d09bc59d0a46f18076e3704c566'/>
<id>urn:sha1:00e1dba744dc8d09bc59d0a46f18076e3704c566</id>
<content type='text'>
* Improve performance of building members dictionary by adding when needed.

* Fix unbounded-array-of-array-syntax.slang, that DISABLE_TEST now uses up an index. Use IGNORE_TEST.

* Improve variable name.
Small improvements.

Co-authored-by: Tim Foley &lt;tfoleyNV@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Add basic support for namespaces (#1304)</title>
<updated>2020-04-02T15:52:42+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-04-02T15:52:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=487d4a4f406c9dd9803ecdca02467d09ee1ecf4a'/>
<id>urn:sha1:487d4a4f406c9dd9803ecdca02467d09ee1ecf4a</id>
<content type='text'>
This change adds logic for parsing `namespace` declarations, referencing them, and looking up their members.

* The parser changes are a bit subtle, because that is where we deal with the issue of "re-opening" a namespace. We kludge things a bit by re-using an existing `NamespaceDecl` in the same parent if one is available, and thereby ensure that all the members in the same namespace can see on another.

* In order to allow namespaces to be referenced by name they need to have a type so that a `DeclRefExpr` to them can be formed. For this purpose we introduce `NamespaceType` which is the (singleton) type of a reference to a given namespace.

* The new `NamespaceType` case is detected in the `MemberExpr` checking logic and routed to the same logic that `StaticMemberExpr` uses, and the static lookup logic was extended with support for looking up in a namespace (a thin wrapper around one of the existing worker routines in `slang-lookup.cpp`.

* I made `NamespaceDecl` have a shared base class with `ModuleDecl` in the hopes that this would allow us to allow references to modules by name in the future. That hasn't been tested as part of this change.

* I cleaned up a bunch of logic around `ModuleDecl` holding a `Scope` pointer that was being used for some of the more ad hoc lookup routines in the public API. Those have been switched over to something that is a bit more sensible given the language rules and that doesn't rely on keeping state sititng around on the `ModuleDecl`.

* I added a test case to make sure the new funcitonality works, which includes re-opening a namespace, and it also tests both `.` and `::` operations for lookup in a namespace.

* The main missing feature here is the ability to do something like C++ `using`. It would probably be cleanest if we used `import` for this, since we already have that syntax (and having both `import` and `using` seems like a recipe for confusion). Most of the infrastructure is present to support `import`ing one namespace into another (in a way that wouldn't automatically pollute the namespace for clients), but some careful thought needs to be put into how import of namespaces vs. modules should work.</content>
</entry>
<entry>
<title>Initial work for "global generic value parameters" (#1127)</title>
<updated>2019-11-19T21:53:52+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-11-19T21:53:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=fae3d9ae91a24e59ce6ec64b8a1217fa81f5acee'/>
<id>urn:sha1:fae3d9ae91a24e59ce6ec64b8a1217fa81f5acee</id>
<content type='text'>
* Initial work for "global generic value parameters"

The main new feature here is support for the `__generic_value_param` keyword, which introduces a *global generic value parameter*.
For example:

    __generic_value_param kOffset : uint = 0;

This declaration introduces a global generic value parameter `kOffset` of type `uint` that has a nominal default value of zero.

The broad strokes of how this feature was added are as follows:

* A new `GlobalGenericValueParamDecl` AST node type is introduces in `slang-decl-defs.h`

* A new `parseGlobalGenericValueParamDecl` subroutine is added to `slang-parser.cpp`, and is added to the list of declaration cases as the callback for the `__generic_value_param` name.

* Cases for `GlobalGenericValueParamDecl` are added to the declaration checking passes in `slang-check-decl.cpp`, mirroring what is done for other variable declaration cases.

* A case for `GlobalGenericValueParamDecl` is aded to the `Module::_collectShaderParams` function, so that it is recognized as a kind of specialization parameter. This introduces a specialization parameter of flavor `SpecializationParam::Flavor::GenericValue` (which was already defined before this change, although it was unused).

* A case for `SpecializationParam::Flavor::GenericValue` is added in `Module::_validateSpecializationArgsImpl` to check that a specialization argument represents a compile-time-constant value (not a type).

* A case for `GlobalGenericValueParmDecl` is introduced in `slang-lower-to-ir.cpp` that introduces a global generic parameter in the IR

* The `IRBuilder` is extended to support creating `IRGlobalGenericParam`s for the distinct cases of type, witness-table, and value parameters. The same IR instruction type/opcode is used for all cases, and only the type of the IR instruction differs.

* The existing mechanisms for lowering specialization arguments to the IR, and doing specialization on the IR itself Just Work with global generic value parameters since they already support value parameters on explicit generic declarations.

That's the santized version of things, but there were also a bunch of cleanups and tweaks required along the way:

* The `SpecializationParam` type was extended to also track a `SourceLoc` to help in diagnostic messages, which meant some churn in the code that collects specialization parameters.

* The `_extractSpecializationArgs` function is tweaked to support any kind of "term" as a specialization argument (either a type or a value).

* To allow *parsing* specialization arguments that can't possibly be types (e.g., integer literals) we replace the existing `parseTypeString` routine with `parseTermString` and then in `parseTermFromSourceFile` call through to a general case of expression parsing (which can also parse types) rather than only parsing types directly.

* Right before doing back-end code generation, we check if the program we are going to emit has remaining (unspecialized) parameters, in which case we emit a diagnostic message for the parameters that haven't been specialized rather than go on to emit code that will fail to compile downstream.

* Within the `render-test` tool we collapse down the arrays that held both "generic" and "existential" specialization arguments, so that we just have *global* and *entry-point* specialization argument lists. This mirrors how Slang has worked internally for a while, but the difference hasn't been important to the test tool because no tests currently mix generic and existential specialization. The logic for parsing `TEST_INPUT` lines has been streamlined down to just the global and entry-point cases, but the pre-existing keywords are still allowed so that I don't have to tweak any test cases.

There are several significant caveats for this feature, which mean that it isn't really ready for users to hammer on just yet:

* There is no support for `Val`s of anything but integers, so there is no way to meaningfully have a generic value param with a type other than `int` or `uint`.

* We allow for a default-value expression on global generic parameters, but do not actually make use of that value for anything (e.g., to allow a programmer to omit specialization arguments), nor check that it meets the constraints of being compile-time constant.

* Global generic value parameters are *not* currently being treated the same as explicit generic parameters in terms of how they can be used for things like array sizes or other things that require constants. This will probably be relaxed at some point, but allowing a global generic to be used to size an array creates questions around layout.

* The IR optimization passes in Slang currently won't eliminate entire blocks of code based on constant values, so using a global generic value parameter to enable/disable features will *not* currently lead to us outputting drastically different HLSL or GLSL. That said, we expect most downstream compilers to be able to handle an `if(0)` well.

* Fix regression for tagged union types

The change that made specialization arguments be parsed as "terms" first, and then coerced to types meant that any special-case logic that is specific to the parsing of types would be bypassed and thus not apply.
Most of that special-case logic isn't wanted for specialization arguments, since it pertains to cases were we want to, e.g, declare a `struct` type while also declaring a variable of that type.
The one special case that *is* useful is the `__TaggedUnion(...)` syntax, which is the only way to introduce a tagged union type right now.

In order to get that case working again, all I had to do was register the existing logic for parsing `__TaggedUnion` as an expression keyword with the right callback, and the existing logic in expression parsing kicks in (that logic was already handling expression keywords like `this` and `true`).

I left in the existing logic for handling `__TaggedUnion` directly where types get parsed, rather than try to unify things.
A better long-term fix is to make the base case for type parsing route into `parseAtomicExpr` so that the two paths share the core logic.
That change should probably come as its own refactoring/cleanup, because it creates the potential for some subtle breakage.

* fixup: typo
</content>
</entry>
<entry>
<title>Use slang- prefix on slang compiler and core source (#973)</title>
<updated>2019-05-31T21:20:37+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2019-05-31T21:20:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=6cbc3929a54d37bd23cb5efa8e3320ba02f78b2f'/>
<id>urn:sha1:6cbc3929a54d37bd23cb5efa8e3320ba02f78b2f</id>
<content type='text'>
* Prefixing source files in source/slang with slang-

* Prefix source in source/slang with slang- prefix.

* Rename core source files with slang- prefix.

* Update project files.

* Fix problems from automatic merge.
</content>
</entry>
</feed>
