From 4a4da858cf7ab965f930d667f6ba9101709e58a3 Mon Sep 17 00:00:00 2001 From: "james.brodman" Date: Tue, 17 Dec 2013 15:55:59 -0500 Subject: [PATCH] Clean up exported varyings and add support for querying program count from C/C++ --- module.cpp | 13 +++++++------ stdlib.ispc | 9 +++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/module.cpp b/module.cpp index 6328c32c..5569ab4f 100644 --- a/module.cpp +++ b/module.cpp @@ -607,7 +607,10 @@ lRecursiveCheckValidParamType(const Type *t, bool vectorOk) { return lRecursiveCheckValidParamType(pt->GetBaseType(), true); } - return true; + if (t->IsVaryingType() && !vectorOk) + return false; + else + return true; } @@ -830,9 +833,9 @@ Module::AddFunctionDeclaration(const std::string &name, // If the function is exported, make sure that the parameter // doesn't have any funky stuff going on in it. // JCB nomosoa - Varying is now a-ok. - if (functionType->isExported) { - lCheckExportedParameterTypes(argType, argName, argPos); - } + if (functionType->isExported) { + lCheckExportedParameterTypes(argType, argName, argPos); + } // ISPC assumes that no pointers alias. (It should be possible to // specify when this is not the case, but this should be the @@ -2340,8 +2343,6 @@ lGetVaryingDispatchType(FunctionTargetVariants &funcs) { return resultFuncTy; } -#include - /** Create the dispatch function for an exported ispc function. This function checks to see which vector ISAs the system the code is running on supports and calls out to the best available diff --git a/stdlib.ispc b/stdlib.ispc index 6768594b..ef519d22 100644 --- a/stdlib.ispc +++ b/stdlib.ispc @@ -5158,3 +5158,12 @@ __declspec(safe) static unmasked inline int16 avg_down(int16 a, int16 b) { return __avg_down_int16(a, b); } + + +// Added so programmers can query programCount +// at runtime from C/C++. +// This is useful for using varying +// structures with exported functions +export uniform int32 get_programCount() { + return programCount; +}