diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-10 10:44:02 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-10 10:44:02 -0700 |
| commit | b2fb0f7134de4e0b1a0db685eb1ae3c0678a33c5 (patch) | |
| tree | 5597bca9d791391e069c8997a84ac9a8b1061024 /source/slang/type-layout.cpp | |
| parent | 8abdf2dddd10feb9794c86cdf6b2159a2b6383e4 (diff) | |
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
Diffstat (limited to 'source/slang/type-layout.cpp')
| -rw-r--r-- | source/slang/type-layout.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 31c8ed607..9bc001e88 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -895,6 +895,28 @@ SimpleLayoutInfo GetLayoutImpl( rules, outTypeLayout); } + else if (auto imageType = type->As<GLSLImageType>()) + { + // TODO: the logic here should really be defined by the rules, + // and not at this top level... + ShaderParameterKind kind; + switch( imageType->getAccess() ) + { + default: + kind = ShaderParameterKind::MutableImage; + break; + + case SLANG_RESOURCE_ACCESS_READ: + kind = ShaderParameterKind::Image; + break; + } + + return GetSimpleLayoutImpl( + rules->GetObjectLayout(kind), + type, + rules, + outTypeLayout); + } else if (auto textureSamplerType = type->As<TextureSamplerType>()) { // TODO: the logic here should really be defined by the rules, @@ -1126,6 +1148,19 @@ SimpleLayoutInfo GetLayoutImpl( return info; } } + else if (auto errorType = type->As<ErrorType>()) + { + // An error type means that we encountered something we don't understand. + // + // We should probalby inform the user with an error message here. + + SimpleLayoutInfo info; + return GetSimpleLayoutImpl( + info, + type, + rules, + outTypeLayout); + } // catch-all case in case nothing matched assert(!"unimplemented"); |
