From b2fb0f7134de4e0b1a0db685eb1ae3c0678a33c5 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 10 Jul 2017 10:44:02 -0700 Subject: 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 --- source/slang/type-layout.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'source/slang/type-layout.cpp') 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()) + { + // 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()) { // 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()) + { + // 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"); -- cgit v1.2.3