summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-07-17Handle `flat` interpolation cases in cross compilationTim Foley
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
2017-07-14Merge pull request #92 from tfoleyNV/glsl-thread-group-sizeTim Foley
Add reflection support for GLSL thread-group-size modifier
2017-07-14Add reflection support for GLSL thread-group-size modifierTim Foley
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.
2017-07-14Merge pull request #90 from tfoleyNV/cbuffer-field-layout-fixTim Foley
Adjust type layout when parameter block constains member using the sa…
2017-07-14Adjust type layout when parameter block constains member using the same resourceTim Foley
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`.
2017-07-14Merge pull request #89 from tfoleyNV/glpervertex-location-fixTim Foley
Don't use "auto locations" mode in glslang
2017-07-14Don't assign a `binding` to a `push_constant` bufferTim Foley
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
2017-07-14Don't use "auto locations" mode in glslangTim Foley
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.
2017-07-13Merge pull request #87 from tfoleyNV/debug-dumpTim Foley
Add support for dumping intermediates for debugging.
2017-07-13Add support for dumping intermediates for debugging.Tim Foley
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`.
2017-07-13Merge pull request #86 from tfoleyNV/resource-array-layout-fixTim Foley
An array of resources in Vulkan only consumes one binding
2017-07-13Merge pull request #85 from tfoleyNV/workingTim Foley
Various bug fixes
2017-07-13An array of resources in Vulkan only consumes one bindingTim Foley
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.
2017-07-13Add several missing GLSL qualifiersTim Foley
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.
2017-07-13Allow GLSL `#version` to be selected based on profileTim Foley
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
2017-07-13Allow `spGetEntryPointCode` to return text results tooTim Foley
Fixes #77 - The `spGetEntryPointSource` function is now no longer needed, but I'm not going to "deprecate" it just yet
2017-07-13Don't emit C-style `#line` directives when directly generating GLSLTim Foley
- 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
2017-07-13Update version of `glslang` in submoduleTim Foley
2017-07-12Merge pull request #80 from tfoleyNV/falcor-workTim Foley
Fixes for shader cross-compilation
2017-07-12Add ability for intrinsics to require GLSL extensionsTim Foley
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.
2017-07-12Don't report error on assigning to an erroneous expressionTim Foley
An expression with error type may still fail the l-value check, but we don't want to emit an error in that case.
2017-07-12Don't emit interpolation modifiers on struct fields when outputting GLSLTim Foley
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...
2017-07-12Use C-style line directives, even for GLSLTim Foley
- 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
2017-07-12Properly register error on downstream compiler failureTim Foley
- 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
2017-07-12Add tuple lowering logic for assignmentTim Foley
- 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; ...`
2017-07-12Merge pull request #79 from tfoleyNV/sample-rate-reflectionTim Foley
Sample rate reflection
2017-07-12Add basic reflection query for checking if entry point is "sample-rate"Tim Foley
- 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.
2017-07-12Add per-entry-point information to reflection JSON dumpsTim Foley
- This also adds reflection API for querying: - Entry point name - Entry point parameter list
2017-07-11Merge pull request #76 from tfoleyNV/gh-75Tim Foley
Make parser recovering more robust to avoid infinite loops
2017-07-11Make parser recovering more robust to avoid infinite loopsTim Foley
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.
2017-07-11Merge pull request #74 from tfoleyNV/resources-in-structsTim Foley
Resources in structs
2017-07-11Bug fixes for resources-in-structs.Tim Foley
2017-07-11Add GLSL lowerings for `ddx*` and `ddy*`Tim Foley
2017-07-11Bug fix for lowering of tuple types without layout.Tim Foley
- Don't try to extract the body layout for a field without a layout
2017-07-11Merge pull request #73 from tfoleyNV/image-type-reflectionTim Foley
Improve reporting of GLSL `image*` types
2017-07-11Merge pull request #72 from tfoleyNV/resources-in-structsTim Foley
Resources in structs
2017-07-11Improve reporting of GLSL `image*` typesTim Foley
- 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
2017-07-11Initial work on handling resources in structs during cross-compilationTim Foley
- 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
2017-07-11Fixup for binary/string output.Tim Foley
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.
2017-07-11Merge pull request #70 from tfoleyNV/support-more-sv-semanticsTim Foley
Support more sv semantics
2017-07-11Add GLSL translations for many `SV_*` semanticsTim Foley
I haven't tried to be 100% exhaustie, but this should cover the main cases we are likely to encounter in library code.
2017-07-11Don't emitting an imported declaration unless it is used.Tim Foley
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).
2017-07-11Update `.gitignore` to deal with render-test outputTim Foley
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.
2017-07-10Merge pull request #67 from kyaoNV/spirvTim Foley
SPIR-V Support
2017-07-10Removed spGetTranslationUnitCode; Unified ↵Kai-Hwa Yao
EntryPointResult/TranslationUnitResult, added helper functionality; Ensure null termination when printing raw data
2017-07-10Don't assume vector contains contentsKai-Hwa Yao
2017-07-10Refactored compile output to work with raw data instead of StringsKai-Hwa Yao
2017-07-10Allow glslang wrapper to output regular SPIRV before disassemblyKai-Hwa Yao
2017-07-10Merge pull request #69 from tfoleyNV/falcor-fixesTim Foley
Handle function name properly for unchecked call
2017-07-10Handle function name properly for unchecked callTim Foley
The emit logic was checking for a missing decl, and then asking that same (missing) declaration for its name.