diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-10 11:31:16 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-11 09:38:28 -0700 |
| commit | d86748d3e0767c01d9be6def86df63febb82c2eb (patch) | |
| tree | 1ba432b042edcd38c1ba40d6cbc57cea55737bd5 /source | |
| parent | 7d2c2f1bf75ed89bc97f35d5b095356db9b2b725 (diff) | |
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).
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/lower.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 9f117106b..fa38264d4 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -1299,17 +1299,20 @@ struct LoweringVisitor RefPtr<ImportDecl> visitImportDecl(ImportDecl* decl) { - // No need to translate things here if we are - // in "full" mode, because we will selectively - // translate the imported declarations at their - // use sites(s). - if (!shared->isRewrite) - return nullptr; - - for (auto dd : decl->importedModuleDecl->Members) - { - translateDeclRef(dd); - } + // We could unconditionally output the declarations in the + // imported code, but this could cause problems if any + // of those declarations used capabilities not allowed + // by the target pipeline stage (e.g., `discard` is + // an error in a GLSL vertex shader file, even if + // it is in a function that never gets called). + // + // As a result, we just ignore the `import` step, + // and allow declarations to be pulled in by + // their use sites. + // + // If this proves to be a problem, we will need + // a pass that resolves which declarations in imported + // modules are "valid" for the chosen target stage. // Don't actually include a representation of // the import declaration in the output |
