https://github.com/shader-slang/slang

sort by:
Revision Author Date Message Commit Date
a727017 Merge pull request #123 from tfoleyNV/parameter-block-name-fixes Fixes for how parameter block names are set up. 19 July 2017, 16:06:53 UTC
efedd5e Fixes for how parameter block names are set up. We generate implicit names for global-scope parameter blocks (including HLSL `cbuffer`s, since the "name" the user sees is really just for reflection purposes), but this had a few problems: - We used the generated names for parameter-binding purposes - Except for a GLSL block with an explicit name, in which case we'd use the internal name and not the reflection name for matching - The generated named didn't match between GLSL and HLSL/Slang declarations This change tries to fix both of these issues. I changed the name generation to try to make it identical between HLSL and GLSL (to the extent we can control it), just in case. But then I also went and changed the parameter-binding-generation logic to use the *reflection* name instead of the internal name when deciding if things are the "same" parameter. 19 July 2017, 15:49:58 UTC
4c3d56a Merge pull request #121 from tfoleyNV/gaussian-blur-fixes Gaussian blur fixes 18 July 2017, 22:26:20 UTC
a010145 Merge pull request #120 from tfoleyNV/compile-time-loop Add a compile-time loop construct to Slang 18 July 2017, 22:22:20 UTC
4d6da3a Swizzle result of buffer load based on element type When lowering `buf[i]` to `texelFetch(..., i)` we need to deal with the case where the type of `b` might be `Buffer<float>` in which case we want to add a `.x` swizzle to the end of the fetch. 18 July 2017, 22:21:04 UTC
b2b46a9 Add basic GLSL lowering buffer `Buffer` loads - This isn't going to work for writable buffers, and certainly not for writes - As it exists right now, this shows a flaw in how I'm handling texture-type results on fetches 18 July 2017, 22:13:44 UTC
2476c03 Add a compile-time loop construct to Slang The basic syntax is: $for(i in Range(0,99)) { /* stuff goes here */ } Note that the exact form is very restrictive. All that you are allowed to change is `i`, `0`, `99` or `/* stuff goes here */`. As a tiny bit of syntax sugar, the following should work: $for(i in Range(99)) { /* stuff goes here */ } Note that the range given is half-open (C++ iterator `[begin,end)` style). Both the beginning and end of the range must be compile-time constant expressions that Slang knows how to constant-fold. The implementation will basically generate code for `/* stuff goes here */` N times, once for each value in the half-open range. Each time, the variable `i` will be replaced with a different compile-time-constant expression. While I was working on a test case for this, I also found that our build of glslang had an issue with resource limits, so I fixed that. Clients will need to build a new glslang to use the fix. 18 July 2017, 21:51:12 UTC
3d313d9 Merge pull request #118 from tfoleyNV/falcor-shadow-fixes Falcor shadow fixes 18 July 2017, 20:32:56 UTC
1c022e2 Support scalarization of varying input/output for GLSL GLSL technically supports varying (`in`, `out`) parameters of `struct` type, but there are some annoying constraints (not allowed for VS input), and it doesn't work with how an HLSL user would usually put "system-value" inputs/outputs into a `struct` together with ordinary inputs/outputs. To work around this, this change adds support for using an imported Slang `struct` type for an `in` or `out` parameter, in which case it will (1) be scalarized and (2) will have system-value semantics mapped appropriately, just as for an entry-point parameter when cross-compiling an HLSL-style `main()`. Changes: - Add a notion of a `VaryingTupleExpr` and `VaryingTupleVarDecl`, similar to those for the resources-in-structs case - Trigger use of these when we have a global-scope varying in/out using an imported `struct` type - Also use these in the cross-compilation case for ordinary varying input/output (since this approach seems like it should be more general, and can hopefully handle stuff like GS input/output some day) - When generating parameter binding information, special case global-scope input/output, and treat it the same as entry-point-parameter input/output - Revamp how used resource ranges are computed so that we can eventually make this specific to an entry point - Actually implement first signs of life for `maybeMoveTemp` so that assignments to the tuple-ified outputs will work better - Add first test case that actually seems to work - Add diagnostics for conflicting explicit bindings on a parameter - Add diagnostic for different parameters with overlapping bindings - Make global-scope varying input/output use a tracking data structure specific to the translation unit for computing locations (so that they are independent of other TUs) 18 July 2017, 19:58:48 UTC
361e295 Map HLSL `GatherRed` to GLSL `textureGather`, etc. This is a straightforward mapping given the infrastructure already in place. 18 July 2017, 19:58:47 UTC
f04bf3c Don't allow varying parameters to be merged in reflection data All varying input/output parameters need to be specified to the entry point that declared them. In the case of HLSL/Slang this happens for free, but in the case of GLSL we need to be careful not to merge global-scope `in` or `out` parameters in ways that don't make sense. 18 July 2017, 19:58:47 UTC
ac310e2 Merge pull request #114 from tfoleyNV/csm-shadow-sampler-fix Make sure to treat imported modules as Slang 18 July 2017, 00:30:02 UTC
ac2d419 Make sure to treat imported modules as Slang - When generating parameter binding/reflection info, treated imported modules as Slang code, instead of the source language of the outer translation unit - This fixes an issue where global-scope shader parameters in a `.slang` file were getting ignored for binding-generation purposes when imported by a GLSL file 17 July 2017, 23:42:32 UTC
400e347 Merge pull request #112 from tfoleyNV/gh-94 Handle `Buffer` types more like textures 17 July 2017, 23:37:34 UTC
ff46214 Handle `Buffer` types more like textures Fixes #94 We'd been handling HLSL `Buffer` and `RWBuffer` in a one-off fashion, and that led to a lot of code duplication, and also to the issue that we weren't handling `RasterizerOrderedBuffer` at all. This change basically folds `Buffer` in so that it is conceptually a texture type (just with a unique shape). Hopefully all the other logic still works. 17 July 2017, 22:13:37 UTC
0059ccb Merge pull request #111 from tfoleyNV/falcor-shadows-fixes Falcor shadows fixes 17 July 2017, 20:43:58 UTC
453a9ca Handle arrays when scalarizing "resources in structs" The basic idea is that an array of `struct`s will get scalarized into per-field arrays (for any fields that need to be scalarized). So given: struct Foo { float x; Texture2D t; }; cbuffer C { Foo foo[4]; } We'll get output like: struct Foo { float x; }; cbuffer C { Foo foo[4]; } Texture2D C_foo_t[4]; (Of course the output would also be translated over to GLSL, but I'm only concerned about this one transformation here). 17 July 2017, 20:35:22 UTC
77e3c3b Map HLSL `SampleGrad` to GLSL `textureGrad[Offset]` - This was an easy case, as far as these things go. 17 July 2017, 20:35:22 UTC
fcf0072 Add hacky GLSL lowering for `GetDimensions` This is hacky for two big reasons: 1. It uses "operator comma" in the output to deal with calling multiple functions in an expression context 2. The way I'm lowering things to GLSL ends up using certain function arguments more than once, which means they get emitted as GLSL more than once, which means their *side effects* get evaluated more than once. Please don't put an expression with side effects in as an argument to `GetDimensions` when cross-compiling. Solving these issues requires the translation of builtins to be more directly handled as part of lowering, rather than a purely textual operation done during emission. I don't have time to fix that right now. 17 July 2017, 20:35:22 UTC
5d5aca4 Improve handling of `SampleCmpLevelZero` - We map `SampleCmpLevelZero` to either `textureLod` or `textureGrad` based on what the GLSL spec seems to allow - We map `SamplerComparisonState` to `samplerShadow` (instead of just `sampler`) 17 July 2017, 20:35:22 UTC
6f239b0 Map HLSL `linear` to GLSL... nothing The behavior of the `linear` modifier should be the default interpolation behavior in GLSL. 17 July 2017, 20:35:22 UTC
b4977c1 Merge pull request #110 from tfoleyNV/gl-layer-pick-version Pick correct GLSL version when `gl_Layer` used 17 July 2017, 18:53:56 UTC
dc0e9d7 Pick correct GLSL version when `gl_Layer` used `gl_Layer` as a fragment input requires at least version 4.30 of GLSL, so we try to track that information when we see the name used. Note that this does *not* override a user-specified `#version` line. This required re-ordering when lowering happens relative to emitting the `#version` directive, since this code works by actually modifying the chosen profile for the entry point. Yes, that is kind of gross and we should do something cleaner in the long term. 17 July 2017, 17:54:05 UTC
0b4992f Merge pull request #108 from tfoleyNV/gh-105 Don't crash-fail on errors in entry point parameters 17 July 2017, 17:27:52 UTC
c69060a Merge pull request #107 from tfoleyNV/glsl-matrix-mult-bug Add explicit operator overloads for scalar/matrix cases 17 July 2017, 17:08:22 UTC
782e6f0 Add emit logic for generic app expressions Work on #105 These can occur in unchecked code (or code that had a semantic error), so we need to be able to handle them. 17 July 2017, 16:49:32 UTC
f23738e Fix AST node type for `TriangleStream` - This was being mapped to `HLSLLineStreamType` because of a copy-paste typo 17 July 2017, 16:48:45 UTC
fbae51f Skip unknown types during parameter-binding/-reflection step Work on #105 If a semantic error occurs in the type of an entry-point parameter, we need to be able to skip over it when doing parameter binding and reflection-generation work. 17 July 2017, 16:47:23 UTC
f881f52 Add explicit operator overloads for scalar/matrix cases Fixes #103 - Previously I was relying on scalar-to-vector promotion to pick the right type in these cases, but I hadn't implemented scalar-to-matrix promotion (I should...) - Rather than relying on promotion behavior, this change goes ahead and adds explicit overloads. I think this is probably a better decision in the long term, since one might want to support these cases for operators, while warning (or erroring) on the more general cases of implicit conversion. - This covers matrix/scalar, scalar/matrix, vector/scalar, and scalar/vector cases 17 July 2017, 16:30:24 UTC
fdab35e Merge pull request #106 from tfoleyNV/varying-integer Handle `flat` interpolation cases in cross compilation 17 July 2017, 16:27:34 UTC
15aba2f Handle `flat` interpolation cases in cross compilation Fixes #104 - Map HLSL `nointerpolation` to GLSL `flat` - When lowering a `struct` type varying input/output, look for interpolation modifiers along the "chain" from the leaf field up to the original shader input variable (and take the first one found) - Not sure if this is strictly needed, but it seems like a reasonable policy - Add `flat` to varying input of integer type, with no other interpolation modifier - Note: I do *not* do anything to ignore a manually imposed interpolation modifier that might be incorrect 17 July 2017, 15:58:47 UTC
eecb6c5 Merge pull request #92 from tfoleyNV/glsl-thread-group-size Add reflection support for GLSL thread-group-size modifier 15 July 2017, 00:15:51 UTC
66bae40 Add reflection support for GLSL thread-group-size modifier Fixes #15 These are the modifiers like: layout(local_size_x = 16) in; Unlike the HLSL case, these don't get attache to the entry point function itself, so there is a bit more work involed in looking them up. Just to make sure I didn't mess up the HLSL case, I went ahead and added two tests for this capability: one for GLSL and one for HLSL. 14 July 2017, 21:42:51 UTC
ffa7f2a Merge pull request #90 from tfoleyNV/cbuffer-field-layout-fix Adjust type layout when parameter block constains member using the sa… 14 July 2017, 19:07:45 UTC
f4ac13d Adjust type layout when parameter block constains member using the same resource If we have something like to following in HLSL: cbuffer C { Texture2D t; ... } and we are compiling to GLSL, then both `C` and `C.t` consume the same kind of resource (a descriptor-table slot). The way reflection was working right now, querying the index of `C` would return its binding (let's say it is `4` just to be concrete) and then a query on `C::t` would give its offset, which was being computed as `0` because it is the first field in the logical `struct` type. That obviously leads to bad math and requires some subtle `+1`s in cases to get things right (e.g., when scalaring during lowering, I had to carefully add one in some cases). It is unreasonable to expect users to deal with this. This commit changes it so that the offset of field `C::t` is `1` so that hopefully more things Just Work. The special-case logic in lowering is now gone. One important catch here is that this pretty much only works in the case where the element type of a parameter block is a `struct` type (which is really all that makes sense right now). If we ever want to generalize this in the future, then it will probably be necessary to change the `TypeLayout` case for parameter blocks to store a `VarLayout` for the element, rather than just a `TypeLayout`. 14 July 2017, 19:00:29 UTC
d9366db Merge pull request #89 from tfoleyNV/glpervertex-location-fix Don't use "auto locations" mode in glslang 14 July 2017, 18:31:23 UTC
2bf8774 Don't assign a `binding` to a `push_constant` buffer 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 14 July 2017, 18:09:10 UTC
082003a Don't use "auto locations" mode in glslang Fixes #88 The code was using `glslang::TShader::setAutoMapLocations` as a workaround for an old glslang issue, but apparently this mode has a bug where it ends up applying a `location` layout to the implicitly-created `gl_PerVertex` definition (which shouldn't be allowed). This change drops the call to `setAutoMapLocations` (and `setAutoMapBindings`) since it should no longer be required. 14 July 2017, 17:05:38 UTC
47e94a1 Merge pull request #87 from tfoleyNV/debug-dump Add support for dumping intermediates for debugging. 13 July 2017, 20:24:56 UTC
6d7be36 Add support for dumping intermediates for debugging. Calling: spSetDumpIntermedites(compileRequest, true); will set up a mode where Slang tries to dump every intermediate HLSL, GLSL, DXBC, SPIR-V, etc. file it generates. If SPIR-V or DXBC is requested then we also dump assembly of those. Right now the files are all named as `slang-<counter>.<ext>`, and get dropped in whatever the working directory is, but I'm open to ideas on how to improve that. Note: this change introduces a new binary interface to `glslang`, so pulling it requires an updated `glslang.dll`. 13 July 2017, 20:00:38 UTC
4bc59f8 Merge pull request #86 from tfoleyNV/resource-array-layout-fix An array of resources in Vulkan only consumes one binding 13 July 2017, 17:31:09 UTC
c963b44 Merge pull request #85 from tfoleyNV/working Various bug fixes 13 July 2017, 16:54:47 UTC
bb8ebb4 An array of resources in Vulkan only consumes one binding Fixes #84 - When computing resource usage for an array type, don't multiply the resource usage of the element type by the element count foor descriptor-table-slot resources. - When reporting the "stride" of an array type through reflection, report the stride for descriptor table slots as zero, always. 13 July 2017, 16:52:19 UTC
c51fd4e Add several missing GLSL qualifiers Fixes #81 - This is based on a san over the GLSL spec (but is probably not exhaustive) - There are some qualifiers that are currently being handled by general-case code for all languages, and some of these happen to cover GLSL qualifiers too - Some of the qualifiers being handled by the general-case mechanism are *accidentally* working for GLSL (e.g., the HLSL `shared` qualifier doesn't mean the same thing as GLSL `shared`, but as long as we spit it back out nobody seems to care). - This should be fixed sooner or later. 13 July 2017, 16:35:20 UTC
6da80f5 Allow GLSL `#version` to be selected based on profile Fixes #83 - The basic idea is that I added a bunch of more specific profile names line `glsl_vertex_430` which indicate the desired GLSL version the user wants. - An explicit `#version` line in the code always overrides one specified by profile, though 13 July 2017, 16:17:27 UTC
72a3e97 Allow `spGetEntryPointCode` to return text results too Fixes #77 - The `spGetEntryPointSource` function is now no longer needed, but I'm not going to "deprecate" it just yet 13 July 2017, 15:36:47 UTC
f48035f Don't emit C-style `#line` directives when directly generating GLSL - This fixes the render tests, which aren't tested by the continuous integration setup - This was broken in the commit that decided to use C-style directives all the time. - This works for stuff that eventually passes through glslang (or at least our build of it) - It *doensn't* work if we take the GLSL and pass it off to an OpenGL driver (which is what I do for testing) - A longer-term fix is still required to deal with line directives properly 13 July 2017, 15:31:18 UTC
c2fca57 Update version of `glslang` in submodule 13 July 2017, 15:25:38 UTC
9058358 Merge pull request #80 from tfoleyNV/falcor-work Fixes for shader cross-compilation 12 July 2017, 21:52:21 UTC
02f77bb Add ability for intrinsics to require GLSL extensions When cross-compiling, we need to detect when an intrinsic is used that required non-default GLSL capabilities and emit an appropriate `#extension ... : require` line. I'm handling this by attaching a custom modifier to declarations that require an extension in order to be callable. 12 July 2017, 21:21:52 UTC
d43ee03 Don't report error on assigning to an erroneous expression An expression with error type may still fail the l-value check, but we don't want to emit an error in that case. 12 July 2017, 20:48:20 UTC
aca34e7 Don't emit interpolation modifiers on struct fields when outputting GLSL HLSL (and thus Slang) commonly puts interpolation modifiers like `sample` on the fields of `struct` types used as stage input/output, while GLSL only allows them on global-scope `in` and `out` variables (or ones in blocks). This change emits a really hacky filtering step to skip over certain modifiers when emitting a declaration. This lets us skip interpolation-mode modifiers when outputting a struct field to GLSL. Note: this probably gets the `in` or `out` block case wrong... 12 July 2017, 20:40:30 UTC
b65861f Use C-style line directives, even for GLSL - As long as we are always going to pass GLSL through glslang, there should be no harm in this - Eventually we may need to re-enable the old style 12 July 2017, 20:32:24 UTC
0174470 Properly register error on downstream compiler failure - The old code was just doing `exit(1)` if glslang or `D3DCompile` failed, which is obviously unacceptable - The new approach adds the output to the diagnostic buffer (or invokes the callback), and tracks the error count just like any other errors 12 July 2017, 20:26:53 UTC
11f12cd Add tuple lowering logic for assignment - When assigning tuples `(a0, ...) = (b0, ...)` generate a tuple of assignments `(a0 = b0, ...)` - Given an expression statement on a tuple `(a0, ...);` generate a sequence of statements `a0; ...` 12 July 2017, 18:56:02 UTC
6101e48 Merge pull request #79 from tfoleyNV/sample-rate-reflection Sample rate reflection 12 July 2017, 18:30:43 UTC
7496346 Add basic reflection query for checking if entry point is "sample-rate" - This really just checks two basic things: 1. Was there any global variable declared with `in` and `sample`? 2. Did any code encountered during lowering referenece `gl_SampleIndex`? - This doesn't cover what HLSL could need, nor what we would need for cross-compilation. Consider it GLSL-specific for now. - In order to generate the information with even a reasonable chance of being accurate (not giving a ton of false positives) I tried to integrate the checks into the lowering process (so they only see code that is referenced, one hopes). - For this to work with my testing setup, I needed to make sure that lowering is always performed, prior to emitting reflection info - This change broke several reflection tests, because they had been using code that wouldn't actually pass the downstream compiler. I checked in fixes for those. 12 July 2017, 18:07:45 UTC
2c6c501 Add per-entry-point information to reflection JSON dumps - This also adds reflection API for querying: - Entry point name - Entry point parameter list 12 July 2017, 17:18:11 UTC
88f451c Merge pull request #76 from tfoleyNV/gh-75 Make parser recovering more robust to avoid infinite loops 12 July 2017, 00:47:58 UTC
24a44ff Make parser recovering more robust to avoid infinite loops Fixes #75 In order to avoid cascaded errors, I went ahead and made the parser refuse to skip past a `}` in recovery mode. The problem with this is that we fail to make forward progress if we are stuck on a `}` (this happens if you have an extra `}` at the global scope. 11 July 2017, 22:43:18 UTC
d8d8fef Merge pull request #74 from tfoleyNV/resources-in-structs Resources in structs 11 July 2017, 22:10:24 UTC
5d06d42 Bug fixes for resources-in-structs. 11 July 2017, 21:46:48 UTC
88ccba1 Add GLSL lowerings for `ddx*` and `ddy*` 11 July 2017, 21:46:48 UTC
20aac94 Bug fix for lowering of tuple types without layout. - Don't try to extract the body layout for a field without a layout 11 July 2017, 21:46:48 UTC
fa48d2d Merge pull request #73 from tfoleyNV/image-type-reflection Improve reporting of GLSL `image*` types 11 July 2017, 20:04:58 UTC
a60dd57 Merge pull request #72 from tfoleyNV/resources-in-structs Resources in structs 11 July 2017, 19:41:05 UTC
0cd5602 Improve reporting of GLSL `image*` types - Update stdlib so taht `image*` types have read-write access encoded in their type - TODO: this isn't 100% right, since there are GLSL qualifiers that might override this - Add a test case to verify that the reflection API reports `image*` parameters 11 July 2017, 19:18:13 UTC
bd7105f Initial work on handling resources in structs during cross-compilation - 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 11 July 2017, 19:07:09 UTC
6723329 Fixup for binary/string output. Actually output SPIR-V/DXBC assembly as text, instead of binary. This fixes a bunch of tests that were passing on accident, because nothing was producing output. 11 July 2017, 19:07:09 UTC
98b3e5b Merge pull request #70 from tfoleyNV/support-more-sv-semantics Support more sv semantics 11 July 2017, 16:57:13 UTC
1b6af03 Add GLSL translations for many `SV_*` semantics I haven't tried to be 100% exhaustie, but this should cover the main cases we are likely to encounter in library code. 11 July 2017, 16:38:28 UTC
d86748d Don't emitting an imported declaration unless it is used. This helps avoid the problem where we emit a function that does a `discard` and thus get a GLSL compilation failure in a vertex shader (that doesn't even call the function). 11 July 2017, 16:38:28 UTC
7d2c2f1 Update `.gitignore` to deal with render-test output The rule of thumb so far is that expected output for `.slang` files should be checked in, but not for `.hlsl` or `.glsl`. The render test breaks that rule, because we never want to check in the expected output. 11 July 2017, 16:38:28 UTC
a923aff Merge pull request #67 from kyaoNV/spirv SPIR-V Support 11 July 2017, 02:45:21 UTC
22c7a4d Removed spGetTranslationUnitCode; Unified EntryPointResult/TranslationUnitResult, added helper functionality; Ensure null termination when printing raw data 11 July 2017, 00:54:50 UTC
61a816c Don't assume vector contains contents 11 July 2017, 00:49:35 UTC
7c0ebee Refactored compile output to work with raw data instead of Strings 11 July 2017, 00:49:35 UTC
4bb88c4 Allow glslang wrapper to output regular SPIRV before disassembly 11 July 2017, 00:49:35 UTC
5577e2d Merge pull request #69 from tfoleyNV/falcor-fixes Handle function name properly for unchecked call 10 July 2017, 22:06:14 UTC
f8c6905 Handle function name properly for unchecked call The emit logic was checking for a missing decl, and then asking that same (missing) declaration for its name. 10 July 2017, 22:02:47 UTC
d24eaa5 Merge pull request #68 from tfoleyNV/static-bug-fix Fix emission of `static` for HLSL 10 July 2017, 21:20:25 UTC
1669b43 Fix emission of `static` for HLSL I forgot to include a trailing space. 10 July 2017, 21:18:44 UTC
3c92fed Merge pull request #66 from tfoleyNV/falcor-work Falcor work 10 July 2017, 17:58:47 UTC
d6d49ea Add support for `imageBuffer` This was mostly just a missing `typedef` in the Slang standard library code. This should also cover `textureBuffer` and `samplerBuffer`. 10 July 2017, 17:52:30 UTC
b2fb0f7 Try to be more robust against un-checked types during lowering, etc. - Try to handle `ErrorType` gracefully when computing type layouts - When outputting a `TypeExp`, if the type part is errorneous (or missing), try to use the expression part - Make sure to lower the expressions side of a `TypeExp` during lowering 10 July 2017, 17:44:02 UTC
8abdf2d Merge pull request #65 from tfoleyNV/falcor-work Falcor work 10 July 2017, 16:49:46 UTC
5b7c254 Start handling system-value semantics during lowering I hadn't been lowering `SV_Position` outputs to `gl_Position`, and had somehow been relying on hidden driver behavior that I guess made things Just Work. This change adds some infrastructure to handle `SV_` semantics during lowering of an entry point (currently only covering `SV_Position` and `SV_Target`, FWIW). As a byproduct, this also means that a `VarLayout` stores semantic info, which could conceivably be exposed through reflection data now. 10 July 2017, 16:29:11 UTC
7af89d1 Cleanups for test cases: - Allow a code-generation target of `NONE` in order to suppress ordinary output in test cases where we don't care about the actual output (just pass/fail result) - Add explicit `location` layout qualifiers to intermediate vertex-to-fragment variables in GLSL test cases for rendering, to work around apparent Intel driver bugs. 10 July 2017, 16:04:50 UTC
0e220da More cross-compilation fixes - Add GLSL mappings for more `Texture*` methods - The annoying one here is `Texture*.Load()` because it doesn't take a sampler, but the GLSL equivalent needs one (while the SPIR-V does *not*). I've hacked this pretty seriously for now. - Try to ensure that we add `uniform` to global declarations that need it in GLSL - When outputting an `in` or `out` variable that might have been created from an `inout` shader parameter, filter the layout qualifiers that we output to only cover the appropriate resource kind. 10 July 2017, 15:34:52 UTC
928cc86 Ensure that lowered globals for `inout` shader parameters have unique names If the user had a shader entry point with an `inout` parameter, we would end up lowering it to two GLSL global variables with the same name. This change adds a `SLANG_in_` or `SLANG_out_` prefix to the two declarations. Note: I haven't dealt with the issue that we end up printing two different `layout` qualifiers on such a variable... 10 July 2017, 02:42:35 UTC
8aa0dcf Fix up scoping for cross-compiled `main()` body The earier changes to add sequence statements and change how the `isBuildingStmt` logic in lowering works doesn't work for this logic, which assumes it can just set `isBuildingStmt` and be sure that decls will go into the right place. 10 July 2017, 01:38:46 UTC
064c28f Pick layout rules based on target languge, not source. The tricky bit here was that the `reflection-json` output format isn't really a code generation target like the others, and we need to be able to have multiple "targets" active to make sense of it. This needs cleaning-up. 10 July 2017, 01:08:22 UTC
54364eb Some quick fixes to reflection API to try to help Falcor - Expand most queries that handle `TextureType` to handle `TextureTypeBase`, in hopes that this covers most uses of `image*` types in Vulkan GLSL - Adopt the quick fix from Falcor to return read-write access for shader-storage-block types. Something more comprehensive is probably needed if people want to do queries on these, since constant buffers should really be included, then. 10 July 2017, 00:09:58 UTC
68df74b Merge pull request #60 from tfoleyNV/revise-rewriter Revise rewriter 09 July 2017, 01:58:42 UTC
767d47a Fix constant folding for `ParenExpr` Adding an explicit AST node for `(expr)` was a good change, but it broke constant folding because I forgot to handle it. 09 July 2017, 01:22:26 UTC
5c864cb Move renaming logic to lowering pass. Code in Slang that is cross-compiled *might* introduce declarations that collide with language keywords that are reserved in the target. This was previously being dealth with during final code emission, but the challenge there is that we want to allow user code that is being "rewritten" to use whatever identifiers it wants (they know better than us what is an error), and only apply renaming to our own code. The approach here is to apply renaming during lowering - we validate each declaration to make sure its name is valid. Any expressions/types that refer to those declarations will automatically get emitted with the new name (while unchecked expressions will continue to be emitted with their existing name). This isn't quite perfect, since we could in theory still rename a declaration in user code. A more robust version down the line would try to determine if a declaration was nested inside code for the "rewriter." Also note that this does *not* deal with any issues of name conflicts that might arise between modules. That would require a more complete and robust renaming pass, which seems tricky for me to pull off. 09 July 2017, 01:22:26 UTC
780a0bc Add back `UnparsedStmt` If the user doesn't use any `import` declarations, there is no reason to parse their code at all, so having the option of falling back to `UnparsedStmt` can potentially save us some headaches down the road. The new rule now is that if you have the "no checking" flag on, *and* the parser hasn't yet seen any `import` declarations, then it still used `UnparsedStmt` to avoid touching function bodies. Otherwise, I go ahead and parse function bodies, and assume I can rewrite any code I can semantically understand. 09 July 2017, 01:22:26 UTC
a40b667 Differentiate HLSL `for` loops in AST HLSL has the bad scoping behavior for `for` loops, and we need to respect that. But, we need to have correct scoping for GLSL, and we'd like it for Slang. We also need to ensure that `for` loops written in a "correct" language get the correct behavior when emitted as HLSL. There was already code to handle this in the emit pass, but it was unfortunately using an `isRewrite` flag to try to tell if the HLSL behavior was wanted. This doesn't work when the code being emitted might come from a mix of languages. This change adds a distinct `UnscopedForStmt` syntax node type, and uses that when parsing HLSL input (bot not for other languages). We make sure to preserve this node type through lowering, and then specialize our emit logic on this case. With this, there are no more remaining uses of `isRewrite` in the emit logic, which is good because it didn't mean what I needed it to mean any more (since we now emit only a single module, that was merged during lowering). 09 July 2017, 01:22:26 UTC
6233f9b Revise how hidden implicit casts are recognized. The old approach used an `isRewriter` flag in the emit logic, but I kind of need that flag to go away. Instead, I now how the semantic checking pass detect whether an implicitly-generated type cast is in rewriter code, and if so it uses the new `HiddenImplicitCastExpr` AST node. The emit logic then looks for that specific node and eliminates it. 09 July 2017, 01:22:26 UTC
c77c039 Revise the (only) rewriter-error test case This was testing that we let the downstream compiler report a parse error, but that is no longer a goal (because we need to rewrite function bodies to deal with type validation). I've switched it to a type error in the function body, and confirmed that we do let fxc report the problem. 09 July 2017, 01:22:26 UTC
back to top