939688e | Tim Foley | 07 November 2017, 22:05:22 UTC | Add reflection API to get type name (#263) This is currently only useful for `struct` types. I implemented a special-case exception so that the auto-generated `struct` types used for `cbuffer` members don't show their internal name. I did *not* implement any logic to avoid returning the name `vector` for a vector type, etc., since they are all `DeclRefType`s and it seemed easiest to just let the user access information they can't really use. | 07 November 2017, 22:05:22 UTC |
417c9f3 | Yong He | 07 November 2017, 21:55:08 UTC | Merge pull request #256 from tfoleyNV/falcor-integration-work Falcor integration work | 07 November 2017, 21:55:08 UTC |
a543643 | Tim Foley | 07 November 2017, 19:57:58 UTC | Merge branch 'master' into falcor-integration-work | 07 November 2017, 19:57:58 UTC |
d1b45f3 | Tim Foley | 07 November 2017, 19:57:48 UTC | IR: support for select and negate (#257) - During IR emit, treat a "select" expression (`?:` operator) like any other `InvokeExpr`, since it will have an `__intrinsic_op` modifier attached to turn it into a `select` instruction. - During HLSL/GLSL emit from IR, turn a `select` instruction into a `?:` expression - Also add support for the `neg` instruction during HLSL/GLSL emit Note that right now we are assuming HLSL semantics for `?:` where it does not short-circuit. Correctly handling the GLSL case would require going back to special-case codegen for `SelectExpr`, but we can cross that bridge when we come to it. | 07 November 2017, 19:57:48 UTC |
ccea570 | Tim Foley | 07 November 2017, 18:22:53 UTC | Emit pointer-type parameters as out params The IR encodes `out` and `in out` function parameters as pointer types, so the emit logic needs to handle it. We had code to handle translation of pointers types into `out` declarations for function *declarations* but weren't handling it for function *definitions*. This change unifies the logic so that it is shared by function definitions and decalrations. This change does *not* deal with the following issues that need to be addressed sometime soon-ish: - We currently always translate pointers into `out`, even if they should be `in out`. This is obviously wrong. - If/when we eventually have targets that support true pointers (e.g., CUDA, NVIDIA OpenGL, etc.) we'll need a way to tell the difference between an `in` pointer parameter, and an `out` parameter. Both of these issues are meant to be addressed by having a few special cases of pointer types, for the `out` and `in out` cases, and only translating those (not all pointers). We need to plumb those through the IR more completely, but I'm not dealing with that here. | 07 November 2017, 19:00:02 UTC |
ed29b29 | Tim Foley | 07 November 2017, 18:09:16 UTC | Fix expected output for loop test now that barrier isn't an intrinsic The test case had previously been calling `GroupBarrierWithGroupSync` as if it was a special-cased instruction, but now it is just calling it as an ordinary (intrinsic) function. I haven't removed the now-useless instruction, but it would be a good cleanup to go through and eliminate all the instruction cases we aren't using in the near future. | 07 November 2017, 18:58:59 UTC |
f4c4f63 | Tim Foley | 07 November 2017, 18:02:10 UTC | Fix for emitting subscript calls in HLSL/GLSL The old approach was relying on an `__intrinsic_op` modifier to tell us we need to do something special with an `InvokeExpr`, but a previous change removed a bunch of those modifiers. Instead, we will now check for calls to subscript declarations as part of the normal flow of emitting *any* call, similar to what is done for constructor calls already. Eventually we should be able to eliminate the special case in the `__intrinsic_op` path, but I'm holding off on that because the AST emit logic can probably be cleaned up a *lot* once it doesn't have to be used for cross-compilation as well. | 07 November 2017, 18:56:45 UTC |
97a1a95 | Tim Foley | 07 November 2017, 17:55:53 UTC | Try to fix up IR emit for subscript calls This code isn't especially useful right now since most of the important subscripts are still special-cased with `__intrinsic_op`, but the idea is that if we de-mangle an intrinsic operation's name and see it is called `operator[]` then we are probably calling a subscript, and should emit an appropriate expression. Aside: this change has pointed out to me that our current name mangling isn't properly handling non-alphanumeric characters, so we'll be in trouble as soon as we have non-intrinsic subscripts, operators, etc. | 07 November 2017, 18:54:47 UTC |
722105f | Tim Foley | 07 November 2017, 17:45:08 UTC | Add a comparison operator to UnownedStringSlice This is to allow me to compare for particular names in my de-mangling logic in `emit.cpp`. | 07 November 2017, 18:54:06 UTC |
5c22029 | Tim Foley | 07 November 2017, 17:25:41 UTC | Fixes for name mangling/demangling The source of a lot of these changes is that our current strategy for dealing with "builtin" operations when emitting HLSL from the IR is to de-mangle the mangled name of an operation, and then emit HLSL code for a function call to an operation with that de-mangled name. This change introduces a few fixups for that work: - It adds support for parsing the mangled names of generics (specialized and unspecialized) - It adds logic for detecting when the operation being invoked is a member function - This is currently a bit ugly, since we compare the number of actual arguments we have in the IR against the number of parameters declared for the callee, and if they don't match we assume we have an extra `this` argument. On the mangling side, we add (hacky) support for mangling a function name when its types involve generic parameters, e.g.: ``` __generic<T, let N : int> T length(vector<T,N> v); ``` In this case the mangled name of the function needs to include a mangling for the type `vector<T,N>` which means it also needs to include a mangling for `N`. The reason I describe this support as "hacky" is because we really shouldn't be reproducing the names `T` or `N` in the mangled symbol name. By doing so we make it so that a user changing the name of a generic parameter would break (IR) binary compatibility with existing code that was separately compiled. I've included comments in the code about a better way to handle this, but it isn't a priorit right now since binary compatibility isn't something meaningful until we start emitting usable bytecode modules. | 07 November 2017, 18:48:17 UTC |
93a444f | Tim Foley | 07 November 2017, 17:38:32 UTC | Attach correct types to subscript accessors Subscript declarations can have nested "accessor" declarations for the get/set behavior: ``` __subscript(int index) -> float { get { ... } set { ... } } ``` The AST type checks an expression like `a[i]` into a call to an appropriate `__subscript` declaration, and reads the return type off of that, but doesn't drill down to the individual getters/setters. During IR code generation, we need to resolve a call to the subscript operation down to the actual getter or setter, since those are what will have the executable code (or be intrinsics). If we have a non-intrinsic accessor, then we end up asking for its "return type" and get NULL, which crashes the compiler. The fix in this case is to add a bit more semantic checking for accessors, mostly just so that we can have them copy the return type from their parent declaration. While we are at it, this change goes ahead and has an accessor validate that the parent declaration is one that should be allowed, and emit a diagnostic if it is nested in an improper place. | 07 November 2017, 18:44:07 UTC |
9640df0 | Tim Foley | 07 November 2017, 16:31:06 UTC | Handle "ThisType" subsitutions when specialization generics in the IR The original code is handling the issue where a call site might be specializing a generic function, so it has a `DeclRef` that represents what it wants to specialize, but the callee is actually a different overload of the same generic function (e.g., a target-specific overload) and so we need to construct a set of substitutions that are equivalent (same arguments), but point to different `GenericDecl`s. That code was making some bad assumptions, though: 1. It assumed that the substitutions list would always start with a generic substitution (no longer true with `ThisTypeSubstitution`. 2. It assumed that only the top-most substitution would need to be translated. This assumption is probably safe for now, but it could break down if we ever introduced an ability for a type to be re-opened to introduce new (target-specific) overloads of its members. The new approach goes ahead and does a deep copy of the substitition list (but a shallow copy of the arguments), and only copies the generic substititions for now. | 07 November 2017, 18:40:04 UTC |
19c7c37 | Tim Foley | 06 November 2017, 22:05:32 UTC | Remove `__intrinsic_op` from many decls This attribute used to be how we marked ops for special handling in emission, but now it is being used to mark ops that map to single instructions. Either way, we have a bunch of intrinsic functions that need to get lowered in a more traditional fashion for HLSL, and the intrinsics are getting in the way. Subsequent changes will fix up issues created by this removal. A few cases were left unchanged, either because the ops really do map to single instructions, or because there is some special-case support attached to those operations that would be tricky to replace right now. | 07 November 2017, 18:38:56 UTC |
9919c82 | Tim Foley | 06 November 2017, 18:37:27 UTC | Parameter blocks (#245) * Rename existing ParameterBlock to ParameterGroup We are planning to add a new `ParameterBlock<T>` 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<T>` - 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<T>` with `T` - Eventually this should replace it with either `T` or `ConstantBuffer<T>`, 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<T>` 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<T>` into `T` - It may at some point also convert `ConstantBuffer<T>` 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<T>` 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<T>` does not report any `LayoutResourceKind::Uniform` usage, except that `ParameterBlock<T>` 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<T>` 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. | 06 November 2017, 18:37:27 UTC |
296e89c | Yong He | 05 November 2017, 21:39:38 UTC | Merge pull request #243 from csyonghe/master Adding associated types | 05 November 2017, 21:39:38 UTC |
ff7c46a | Yong He | 05 November 2017, 10:49:42 UTC | small cleanups | 05 November 2017, 10:49:42 UTC |
0d250f0 | Yong He | 05 November 2017, 00:21:19 UTC | style fixes | 05 November 2017, 00:21:19 UTC |
6e4ba9b | Yong He | 05 November 2017, 00:07:47 UTC | naming cleanup | 05 November 2017, 00:07:47 UTC |
87c15d3 | Yong He | 04 November 2017, 23:41:31 UTC | move advanced test cases out of 'smoke' category | 04 November 2017, 23:41:31 UTC |
33d9f07 | Yong He | 04 November 2017, 23:19:23 UTC | cleanup useless code | 04 November 2017, 23:19:23 UTC |
aeb69cb | Yong He | 04 November 2017, 23:12:01 UTC | Merge remote-tracking branch 'refs/remotes/official/master' | 04 November 2017, 23:12:01 UTC |
c6fb1de | Yong He | 04 November 2017, 23:11:37 UTC | fixed last couple warnings under release/x64 build. | 04 November 2017, 23:11:37 UTC |
8c0a429 | Yong He | 04 November 2017, 22:45:42 UTC | fix warnings | 04 November 2017, 22:45:42 UTC |
a4fabfc | Yong He | 04 November 2017, 22:43:26 UTC | Merge remote-tracking branch 'refs/remotes/official/master' | 04 November 2017, 22:43:26 UTC |
215ce20 | Yong He | 04 November 2017, 22:43:03 UTC | fixes x64 warnings | 04 November 2017, 22:43:03 UTC |
00e0382 | Yong He | 04 November 2017, 22:07:26 UTC | merge | 04 November 2017, 22:07:26 UTC |
d1009d1 | Yong He | 04 November 2017, 22:07:09 UTC | merge with fixWarnings branch | 04 November 2017, 22:07:09 UTC |
1f9686c | Yong He | 04 November 2017, 21:03:00 UTC | determineEncoding bug fix | 04 November 2017, 21:03:00 UTC |
cb0a577 | Yong He | 04 November 2017, 20:54:44 UTC | bug fix | 04 November 2017, 20:54:44 UTC |
784bd91 | Yong He | 04 November 2017, 20:30:18 UTC | fix linux build | 04 November 2017, 20:30:18 UTC |
98d2f27 | Yong He | 04 November 2017, 20:27:50 UTC | gcc warning fix | 04 November 2017, 20:27:50 UTC |
a7dd782 | Yong He | 04 November 2017, 20:23:21 UTC | fix linux build | 04 November 2017, 20:23:21 UTC |
8d19b2b | Yong He | 04 November 2017, 20:15:15 UTC | Merge branch 'master' of https://github.com/shader-slang/slang | 04 November 2017, 20:15:15 UTC |
288841f | Yong He | 04 November 2017, 20:09:48 UTC | fixed all warnings | 04 November 2017, 20:09:48 UTC |
664e0da | Yong He | 04 November 2017, 19:37:40 UTC | fix all unreachable code warnings | 04 November 2017, 19:37:40 UTC |
31e7f84 | Yong He | 04 November 2017, 19:20:21 UTC | Passing both assoctype-simple and assoctype-complex test cases. | 04 November 2017, 19:20:21 UTC |
d803bf7 | Yong He | 04 November 2017, 19:19:24 UTC | enable -use-ir option when executing compute test cases. | 04 November 2017, 19:19:24 UTC |
0ed248a | Yong He | 04 November 2017, 19:17:57 UTC | Natvis file update for improved debugging view of IR constructs | 04 November 2017, 19:17:57 UTC |
3d90678 | Yong He | 04 November 2017, 19:17:08 UTC | Fix encoding detection when reading text file. Win32 API could mistakenly report UTF16 when the file is actually UTF8. | 04 November 2017, 19:17:08 UTC |
ba396cc | Yong He | 04 November 2017, 10:59:12 UTC | Merge https://github.com/shader-slang/slang | 04 November 2017, 10:59:12 UTC |
76db363 | Yong He | 04 November 2017, 10:57:48 UTC | work in-progress | 04 November 2017, 10:57:48 UTC |
0a36567 | Yong He | 03 November 2017, 22:55:03 UTC | associatedtypes: generating almost correct HLSL, but is not calling correctly mangled function. | 03 November 2017, 22:55:03 UTC |
cc98fd4 | Tim Foley | 03 November 2017, 19:25:46 UTC | Fix #248 (#249) * Fix up test runner output for compute. We want compute-based tests to produce a `.actual` file when compilation fails, so we can easily diagnose the issue. I thought I'd added this capability previous, but it seemst to not be present any more. * Compute result types for constructor decls Fixes #246 When the parser sees an `init()` declaration, it can't easily know what type is is supposed to return, so it leaves the type as NULL. This was causing some downstream crashes. Rather than special-case every site that cares about the result type of a callable, we will instead ensure that we install an actual result type on an initializer/constructor as part of its semantic checking. This code needs to handle both the case where the initializer is declared inside a type, as well as the case where it is declared inside an `extension`. | 03 November 2017, 19:25:46 UTC |
38ec0e0 | Yong He | 03 November 2017, 13:45:54 UTC | Merge remote-tracking branch 'refs/remotes/official/master' | 03 November 2017, 13:45:54 UTC |
8fe947b | Yong He | 03 November 2017, 13:42:44 UTC | Update natvis file for better viewing of RefPtr, DeclRef and Name classes | 03 November 2017, 13:42:44 UTC |
a045826 | Yong He | 03 November 2017, 13:38:02 UTC | in-progress work | 03 November 2017, 13:38:02 UTC |
d5e2319 | YONGH\yongh | 02 November 2017, 23:21:15 UTC | work inprogress | 02 November 2017, 23:21:15 UTC |
e2b9760 | YONGH\yongh | 01 November 2017, 18:05:33 UTC | remove assoctype-complex case to get pass test | 01 November 2017, 18:05:33 UTC |
134354c | Yong He | 01 November 2017, 17:16:26 UTC | Adding support for associated types. | 01 November 2017, 17:16:26 UTC |
b623864 | Yong He | 01 November 2017, 17:00:29 UTC | Merge https://github.com/shader-slang/slang | 01 November 2017, 17:00:29 UTC |
ec41631 | Tim Foley | 01 November 2017, 15:30:45 UTC | Allow use of dxc compiler for DXIL generation (#241) - Add shader model 6.0, 6.1, and 6.2 targets - Add DXIL and DXIL assembly as output formats - Add header for DXC API to `external/` - Add `dxc-support.cpp` that wraps usage of the API - Add `-pass-through dxc` option, equivalent to what we have for `fxc` Notes: * This does *not* include any logic to add `dxcompiler.dll` to our build process; that is way out of scope for the build complexity I'm ready to deal with * For right now, the use of `dxcompiler.dll` is hard-coded, and it must be discoverable in the current executable's search path; options to customize can come later * The `-pass-through` option is kind of silly because the code doesn't actually pay attention to the value (just whether it is set). If you set it to `fxc` but ask for DXIL, we pass through `dxc` anyway. | 01 November 2017, 15:30:45 UTC |
b475415 | Yong He | 31 October 2017, 15:13:00 UTC | merge | 31 October 2017, 15:13:00 UTC |
093bf1e | Yong He | 31 October 2017, 15:12:08 UTC | work in-progress: type checking associated types | 31 October 2017, 15:12:08 UTC |
e2b4730 | Yong He | 31 October 2017, 10:28:23 UTC | Merge pull request #240 from csyonghe/master Fixing issue #236 | 31 October 2017, 10:28:23 UTC |
8ba5d28 | Yong He | 31 October 2017, 09:56:28 UTC | initiate rebuild | 31 October 2017, 09:56:28 UTC |
436c906 | Yong He | 31 October 2017, 08:26:06 UTC | Revert "work in-progress, add parsing for assoc type decls and member type expressions" This reverts commit 84f381cc180b3176d6a58da4085ee8470f246922. | 31 October 2017, 08:26:06 UTC |
84f381c | YONGH\yongh | 31 October 2017, 01:18:20 UTC | work in-progress, add parsing for assoc type decls and member type expressions | 31 October 2017, 01:18:20 UTC |
91ac155 | YONGH\yongh | 30 October 2017, 23:40:13 UTC | Fixing issue #236 | 30 October 2017, 23:40:13 UTC |
832d9c7 | Yong He | 30 October 2017, 23:31:52 UTC | Merge pull request #235 from tfoleyNV/explicit-this-expr Support `this` expressions (explicit and implicit) | 30 October 2017, 23:31:52 UTC |
3ffdf61 | Tim Foley | 30 October 2017, 20:47:04 UTC | Merge branch 'master' into explicit-this-expr | 30 October 2017, 20:47:04 UTC |
c24c173 | Tim Foley | 30 October 2017, 18:17:20 UTC | Fix output for type cast when checking fails (#238) There were some cases where we would try to emit an `ErrorType` to the output HLSL, which obviously isn't allowed. This change tries to avoid emitting error types, and instead use the original expression when it is available. I tried adding a test case for the change, but I can't convince Slang to output matching line numbers for the error message; it seems like more work is needed on that front. | 30 October 2017, 18:17:20 UTC |
11f4424 | Tim Foley | 30 October 2017, 17:03:52 UTC | Allow for implicit `this` expressions. - When peforming ordinary lookup, if the container declaration for a scope is an aggregate type or `extension` decl, then use a "breadcrumb" to make sure that we use a `this` expression as the base of any resulting declaration reference - Add a test case for implicit `this` usage - Update constrained generic test case to use implicit `this` for member reference, as was originally intended | 30 October 2017, 17:26:22 UTC |
42f1cff | Tim Foley | 30 October 2017, 15:54:09 UTC | Support explicit `this` expressions This is the first step towards supporting traditional object-oriented method definitions; the second step will be to allow `this` expressions to be implicit. - Add a test case using explicit `this`, and expected output - Update parsing logic for expressions so that it handled identifiers similarly to the declaration and statement logic: first try to parse using a syntax declaration looked up in the curent scope, and otherwise fall back to the ordinary `VarExpr` case. * As long as I'm making that change: switch `true` and `false` to be parsed via the callback mechanism rather than be special-cased. * This change will also help out if we ever wanted to add `super`/`base` expressions, `new`, `sizeof`/`alignof` or any other expression keywords. - Add a `ThisExpr` node and register a parser callback for it. - Add semantic checks for `ThisExpr`: basically just look upwards through scopes until we find either an aggregate type declaration or an `extension` declaration, and then use that as the type of the expression. - TODO: eventually we need to guard against a `this` expression inside of a `static` member. - The IR generation logic already handled creation of `this` parameters in function signatures; the missing piece was to register the appropriate parameter in the context, so that we can use it as the lowering of a `this` expression. | 30 October 2017, 16:40:04 UTC |
4ab545b | Tim Foley | 27 October 2017, 18:22:11 UTC | Initial work on support code generation for generics with constraints (#233) This change includes a lot of infrastructure work, but the main point is to allow code like the following: ``` // define an interface interface Helper { float help(); } // define a generic function that uses the interface float test<T : Helper>( T t ) { return t.help(); } // define a type that implements the interface struct A : Helper { float help() { return 1.0 } } // define an ordinary function that calls the // generic function with a concrete type: float doIt() { A a; return test<A>(a); } ``` Getting this to generate valid code involves a lot of steps. This change includes the initial version of all of these steps, but leaves a lot of gaps where more complete implementation is required. The changes include: - Member lookup on types has been centralized, and now handles the case where the type we are looking for a member in is a generic parameter (e.g., given `t.help()` we can now look up `help` in `Helper` by knowing that `t` is a `T` and `T` conforms to `Helper`). - There is an obvious cleanup still to be done here where the same exact logic should be used to look up available "constructor" declarations inside a type when the type is used like a function. - Add a notion of subtype constraint "wittnesses" to the type system. When a generic is declared as taking `<T : Helper>` it really takes two generic parameters: the type `T` and a proof that `T` conforms to `Helper`. The actual arguments to a generic will then include both the type argument and a suitable witness argument (both type-level values). - As it stands right now, a witness wraps a `DeclRef` to the declaration that represents the appropriate subtype relationship. So if we have `struct A : Helper`, that `: Helper` part turns into an `InheritanceDecl` member, and a reference to that member can serve as a witness to the fact that `A` conforms to `Helper`. - Make explicit generic application `G<A,B>` synthesize the additional arguments that represent conformances required by the generic. - This does *not* yet deal with the case where a generic is implicitly specialized as part of an ordinary call `G(a,b)` - A bug fix to not auto-specialize generics during lookup. The problem here was related to an attempted fix of an earlier issue. During checking of a method nested in a generic type, we were running into problems where `DeclRefType::create()` was getting called on an un-specialized reference to `vector`, and this was leading to a crash when the code looked for the arguments for the generic. This was worked around by having name lookup automatically specialize any generics it runs into while going through lookup contexts. That choice creates the problem that in a generic method like this: ``` void test<T>(T val) { ... } ``` any reference to `val` inside the body of `test` will end up getting specialized so that it is effectively `test<T>::val`, when that isn't really needed. - Add front-end logic to check that when a type claims to conform to an interface it actually must provide the methods required by the interface. The checking process goes ahead and builds a front-end "witness table" that maps declarations in the interface being conformed to over to their concrete implementations for the type. - At the moment the checking is completely broken and bad: it assumes that *any* member with the right name is an appropriate declaration to satisfy a requirement. That obviously needs to be fixed. - Add an explicit operation to the IR for lookup of methods: `lookup_interface_method(w, r)` where `w` is a reference to the "witness" value and `r` is an `IRDeclRef` for the member we want to look up. - Add an explicit notion of witness tables to the IR. These end up being the IR representation of an `InheritanceDecl` in a type, and they are generated by enumerating the members that satisfy the interface requirements (which were handily already enumerated by the front-end checking). The witness table is an explicit IR value, and so it will be referenced/used at the site where conformance is being exploited (e.g., as part of a `specialize` call), so it should be safe to eliminate witness tables that are unused (since they represent conformances that aren't actually exploited). Similarly, the entries in a witness table are uses of the functions that implement interface methods, and so keep those live. - In order to implement the above, I did a bit of a cleanup pass on the IR representation so that there is an `IRUser` base that `IRInst` inherits from, so that we can have users of values that aren't instructions. - One annoying thing is that because of how types and generics are handled in the IR, we needed a way to have a type-level `Val` that wraps an IR-level value: e.g., to allow an IR-level witness table to be used as one of the arguments for specialization of a generic. The design I chose here is to have a "proxy" `Val` subclass (`IRProxyVal`) that wraps an `IRValue*`. These should only ever appear as part of types and `DeclRef`s that are used by the IR. - One annoying bit here is that an IR value might then have a use that is not manifest in the set of IR instructions, and instead only appears as part of a type somewhere. - I'm not 100% happy with this design, but it seems like we'd have to tackle similar issues if/when we eventually allow functions to have `constexpr` or `@Constant` parameters - Make generic specialization also propagate witness table arguments through to their use sites (this is mostly just the existing substitution machinery, once we have `IRProxyVal`), and then include logic to specialize `lookup_interface_method` instructions when their first operand is a concrete witness table. All of this work allows a single limited test using generics with constraints to pass, but more work is needed to make the solution robust. | 27 October 2017, 18:22:11 UTC |
56bc826 | Yong He | 26 October 2017, 03:16:53 UTC | Merge pull request #230 from csyonghe/master Finish up implementation of render-test | 26 October 2017, 03:16:53 UTC |
3a7dcf6 | YONGH\yongh | 26 October 2017, 02:58:24 UTC | ignore RENDER_COMPUTE test cases in linux build. | 26 October 2017, 02:58:24 UTC |
1981c92 | YONGH\yongh | 26 October 2017, 02:23:02 UTC | render-test code cleanup | 26 October 2017, 02:23:02 UTC |
14d93b0 | YONGH\yongh | 26 October 2017, 02:13:11 UTC | fix d3d11 usage | 26 October 2017, 02:13:11 UTC |
9a28965 | YONGH\yongh | 26 October 2017, 01:44:42 UTC | test | 26 October 2017, 01:44:42 UTC |
9a120fc | YONGH\yongh | 26 October 2017, 01:32:28 UTC | test | 26 October 2017, 01:32:28 UTC |
ab1009c | YONGH\yongh | 26 October 2017, 01:08:29 UTC | test | 26 October 2017, 01:08:29 UTC |
052645e | YONGH\yongh | 26 October 2017, 01:03:52 UTC | test | 26 October 2017, 01:03:52 UTC |
785cb48 | YONGH\yongh | 26 October 2017, 00:38:00 UTC | test | 26 October 2017, 00:38:00 UTC |
24bb556 | YONGH\yongh | 26 October 2017, 00:35:57 UTC | test | 26 October 2017, 00:35:57 UTC |
23e3217 | YONGH\yongh | 26 October 2017, 00:18:25 UTC | test | 26 October 2017, 00:18:25 UTC |
cb83698 | YONGH\yongh | 26 October 2017, 00:13:45 UTC | test | 26 October 2017, 00:13:45 UTC |
52ceff4 | YONGH\yongh | 25 October 2017, 21:59:45 UTC | add new test mode: COMPARE_RENDER_COMPUTE, which runs a input vertex/fragment shader pair, but instead of comparing the resulting framebuffer, it expects the test shader to write results into a UAV, and compares the pixel shader UAV output to the reference output. | 25 October 2017, 21:59:45 UTC |
922c17b | YONGH\yongh | 25 October 2017, 20:33:59 UTC | Merge https://github.com/shader-slang/slang | 25 October 2017, 20:33:59 UTC |
5894c3b | YONGH\yongh | 25 October 2017, 20:33:18 UTC | finish up opengl renderer implementation for input resource binding. | 25 October 2017, 20:33:18 UTC |
3043171 | Yong He | 24 October 2017, 23:14:14 UTC | Merge pull request #227 from csyonghe/master Extending render-test to support various resource inputs | 24 October 2017, 23:14:14 UTC |
434d342 | Yong He | 24 October 2017, 03:42:23 UTC | bug fix | 24 October 2017, 03:42:23 UTC |
19c4119 | Yong He | 24 October 2017, 03:31:17 UTC | test 7 | 24 October 2017, 03:31:17 UTC |
ff4f9d9 | Yong He | 24 October 2017, 03:13:37 UTC | test 6 | 24 October 2017, 03:13:37 UTC |
deba0d8 | Yong He | 24 October 2017, 03:08:12 UTC | test 5 | 24 October 2017, 03:08:12 UTC |
84683a9 | Yong He | 24 October 2017, 02:58:24 UTC | test 4 | 24 October 2017, 02:58:24 UTC |
809f2bb | Yong He | 24 October 2017, 02:24:23 UTC | try fix 3 | 24 October 2017, 02:24:23 UTC |
2f549e9 | Yong He | 24 October 2017, 02:20:56 UTC | try fix 2 | 24 October 2017, 02:20:56 UTC |
fd22e8a | Yong He | 24 October 2017, 01:57:59 UTC | test | 24 October 2017, 01:57:59 UTC |
61624e3 | Yong He | 24 October 2017, 01:48:20 UTC | attempt to fix | 24 October 2017, 01:48:20 UTC |
0ed979e | Yong He | 24 October 2017, 01:40:53 UTC | Merge https://github.com/shader-slang/slang | 24 October 2017, 01:40:53 UTC |
9882956 | Yong He | 24 October 2017, 01:40:14 UTC | test | 24 October 2017, 01:40:14 UTC |
ab64cf2 | Tim Foley | 23 October 2017, 17:37:07 UTC | Fix output for matrix multiple in GLSL code (#228) When Slang sees a matrix multiplication `M * v` in GLSL code it should (obviously) output GLSL code that also does `M * v`, but there was a bug introduced where the type-checker manages to resolve the operation and recognize it as a matrix-vector multiply, and then the code-generation logic says "oh, I'm generating output for GLSL, and that is reversed from HLSL/Slang, so I'd better reverse these operands!" and outputs `v * M`... which isn't what we want. I've fixed the problem in an expedient way, by having the front-end resolve the operation to what it believes is an intrinsic multiply operation, rather than a matrix-vector operation. If we ever support cross compilation *from* GLSL (unlikely), we've need to fix this up so that we have both real matrix-vector multiplies and "reversed" multiplies where the operands folow the GLSL convention). I've added two tests here to confirm the fix. The one under `tests/bugs` catches the actual issue described above, and confirms the fix. The other one under `tests/cross-compile` is just to make sure that we *do* properly reverse the operands to a matrix-vector product when converting from Slang to GLSL. | 23 October 2017, 17:37:07 UTC |
c68224e | Yong He | 23 October 2017, 15:25:44 UTC | try fix linux build | 23 October 2017, 15:25:44 UTC |
3c64961 | Yong He | 23 October 2017, 15:10:40 UTC | fix test case | 23 October 2017, 15:10:40 UTC |
c8bda84 | Yong He | 23 October 2017, 14:53:17 UTC | fix compute shader test result comparison | 23 October 2017, 14:53:17 UTC |
4d6be35 | Yong He | 23 October 2017, 14:44:08 UTC | Merge https://github.com/shader-slang/slang | 23 October 2017, 14:44:08 UTC |
cc6184e | Yong He | 23 October 2017, 14:35:44 UTC | Work in-progress: simple compute test passed. (d3d renderer) | 23 October 2017, 14:35:44 UTC |
0c8efd1 | YONGH\yongh | 20 October 2017, 23:12:47 UTC | work in progress | 20 October 2017, 23:12:47 UTC |
0ee4d4b | YONGH\yongh | 20 October 2017, 22:24:30 UTC | in-progress work: allow render-test to generate and bind various resource inputs for running test shaders with arbitrary parameter definitions. This commit contains the parser of the resource input definition. | 20 October 2017, 22:24:30 UTC |
624d122 | Tim Foley | 20 October 2017, 22:16:10 UTC | Fix up emission of shader parameter semantics when using IR (#226) * Fix up emission of shader parameter semantics when using IR - Make sure to propagate entry point parameter layouts down to IR parameters when doing the initial cloning to form target-specific IR - When layout information is present on an IR node, prefer to use that over the original high-level declaration for outputting semantics in final HLSL - Fix up test runner to generate `.actual` files when running compute tests, in cases where the `render-test` application errors out (e.g., because of a Slang compilation error) - Add a first test of generics functionality, to show that they generate valid code through the IR - Right now this test is *not* using any "interesting" operations on the type parameter, so this is not a test that can confirm that interface constraints work * fixup: skip compute tests when running on Linux | 20 October 2017, 22:16:10 UTC |