Merge "Add eight-bit GEMM-like intrinsic."
diff --git a/api/GenerateHeaderFiles.cpp b/api/GenerateHeaderFiles.cpp
index eb4c9dd..db94b40 100644
--- a/api/GenerateHeaderFiles.cpp
+++ b/api/GenerateHeaderFiles.cpp
@@ -72,7 +72,8 @@
 }
 
 static void writeComment(GeneratedFile* file, const string& name, const string& briefComment,
-                         const vector<string>& comment, bool closeBlock) {
+                         const vector<string>& comment, bool addDeprecatedWarning,
+                         bool closeBlock) {
     if (briefComment.empty() && comment.size() == 0) {
         return;
     }
@@ -81,6 +82,10 @@
         *file << " * " << name << ": " << briefComment << "\n";
         *file << " *\n";
     }
+    if (addDeprecatedWarning) {
+        *file << " * DEPRECATED.  Do not use.\n";
+        *file << " *\n";
+    }
     for (size_t ct = 0; ct < comment.size(); ct++) {
         string s = stripHtml(comment[ct]);
         s = stringReplace(s, "@", "");
@@ -97,7 +102,8 @@
 
 static void writeConstantComment(GeneratedFile* file, const Constant& constant) {
     const string name = constant.getName();
-    writeComment(file, name, constant.getSummary(), constant.getDescription(), true);
+    writeComment(file, name, constant.getSummary(), constant.getDescription(),
+                 constant.deprecated(), true);
 }
 
 static void writeConstantSpecification(GeneratedFile* file, const ConstantSpecification& spec) {
@@ -171,7 +177,7 @@
 
 static void writeTypeComment(GeneratedFile* file, const Type& type) {
     const string name = type.getName();
-    writeComment(file, name, type.getSummary(), type.getDescription(), true);
+    writeComment(file, name, type.getSummary(), type.getDescription(), type.deprecated(), true);
 }
 
 static void writeFunctionPermutation(GeneratedFile* file, const FunctionSpecification& spec,
@@ -268,7 +274,8 @@
 
 static void writeFunctionComment(GeneratedFile* file, const Function& function) {
     // Write the generic documentation.
-    writeComment(file, function.getName(), function.getSummary(), function.getDescription(), false);
+    writeComment(file, function.getName(), function.getSummary(), function.getDescription(),
+                 function.deprecated(), false);
 
     // Comment the parameters.
     if (function.someParametersAreDocumented()) {
@@ -276,7 +283,7 @@
         *file << " * Parameters:\n";
         for (auto p : function.getParameters()) {
             if (!p->documentation.empty()) {
-                *file << " *   " << p->name << " " << p->documentation << "\n";
+                *file << " *   " << p->name << ": " << p->documentation << "\n";
             }
         }
     }
@@ -310,7 +317,8 @@
     // Write the comments that start the file.
     file.writeNotices();
     writeComment(&file, headerFileName, specFile.getBriefDescription(),
-                 specFile.getFullDescription(), true);
+                 specFile.getFullDescription(), false, true);
+    file << "\n";
 
     // Write the ifndef that prevents the file from being included twice.
     const string guard = makeGuardString(headerFileName);
diff --git a/api/GenerateHtmlDocumentation.cpp b/api/GenerateHtmlDocumentation.cpp
index a9e4d43..1de5328 100644
--- a/api/GenerateHtmlDocumentation.cpp
+++ b/api/GenerateHtmlDocumentation.cpp
@@ -81,8 +81,8 @@
 }
 
 static void writeHtmlFooter(GeneratedFile* file) {
-    *file << "</div> <!-- end body-content -->\n"
-             "</body></html>\n";
+    //*file << "</div>n"
+    *file << "<!-- end body-content -->\n</body></html>\n";
 }
 
 // If prefix starts input, copy it to stream and remove it from input.
@@ -244,14 +244,13 @@
     return true;
 }
 
-static void writeSummaryTableStart(GeneratedFile* file, const char* label, bool labelIsHeading) {
+static void writeSummaryTableStart(GeneratedFile* file, const string& label, bool labelIsHeading) {
     if (labelIsHeading) {
-        *file << "<h2 style='margin-bottom: 0px;'>" << label << "</h2><hr>\n";
+        *file << "<h2 style='margin-bottom: 0px;'>" << label << "</h2><hr/>\n";
     }
-    //#TODO promethods was the id.  implication?
-    *file << "<table id='id" << label << "' class='jd-sumtable'><tbody>\n";
+    *file << "<table class='jd-sumtable'><tbody>\n";
     if (!labelIsHeading) {
-        *file << "  <tr><th colspan='12'>" << label << "</th></tr>\n";
+        *file << "  <tr><th colspan='2'>" << label << "</th></tr>\n";
     }
 }
 
@@ -259,86 +258,83 @@
     *file << "</tbody></table>\n";
 }
 
-static void writeSummaryTableEntry(GeneratedFile* file, Constant* constant) {
-    if (constant->hidden()) {
+enum DeprecatedSelector {
+    DEPRECATED_ONLY,
+    NON_DEPRECATED_ONLY,
+    ALL,
+};
+
+static void writeSummaryTableEntry(ostream* stream, Definition* definition,
+                                   DeprecatedSelector deprecatedSelector) {
+    if (definition->hidden()) {
         return;
     }
-    *file << "  <tr class='alt-color api apilevel-1'>\n";
-    *file << "    <td class='jd-linkcol'><nobr>\n";
-    *file << "      <a href='" << constant->getUrl() << "'>" << constant->getName()
-          << "</a></nobr>\n";
-    *file << "    </td>\n";
-    *file << "    <td class='jd-descrcol' width='100%'><nobr>\n";
-    *file << "        " << constant->getSummary() << "\n";
-    *file << "    </td>\n";
-    *file << "  </tr>\n";
-}
-
-static void writeSummaryTableEntry(GeneratedFile* file, Type* type) {
-    if (type->hidden()) {
+    const bool deprecated = definition->deprecated();
+    if ((deprecatedSelector == DEPRECATED_ONLY && !deprecated) ||
+        (deprecatedSelector == NON_DEPRECATED_ONLY && deprecated)) {
         return;
     }
-    *file << "  <tr class='alt-color api apilevel-1'>\n";
-    *file << "    <td class='jd-linkcol'><nobr>\n";
-    *file << "      <a href='" << type->getUrl() << "'>" << type->getName() << "</a></nobr>\n";
-    *file << "    </td>\n";
-    *file << "    <td class='jd-descrcol' width='100%'><nobr>\n";
-    *file << "        " << type->getSummary() << "\n";
-    *file << "    </td>\n";
-    *file << "  </tr>\n";
+
+    *stream << "  <tr class='alt-color api apilevel-1'>\n";
+    *stream << "    <td class='jd-linkcol'>\n";
+    *stream << "      <a href='" << definition->getUrl() << "'>" << definition->getName() << "</a>\n";
+    *stream << "    </td>\n";
+    *stream << "    <td class='jd-descrcol' width='100%'>\n";
+    *stream << "      ";
+    if (deprecated) {
+        *stream << "<b>Deprecated</b>.  ";
+    }
+    *stream << definition->getSummary() << "\n";
+    *stream << "    </td>\n";
+    *stream << "  </tr>\n";
 }
 
-static void writeSummaryTableEntry(GeneratedFile* file, Function* function) {
-    *file << "  <tr class='alt-color api apilevel-1'>\n";
-    *file << "    <td class='jd-linkcol'>\n";
-    *file << "      <a href='" << function->getUrl() << "'>" << function->getName() << "</a>\n";
-    *file << "    </td>\n";
-    *file << "    <td class='jd-linkcol' width='100%'>\n";  // TODO jd-typecol
-    //    *file << "      <nobr><span class='sympad'></span></nobr>\n";
-    *file << "      <div class='jd-descrdiv'>\n";
-    *file << "        " << function->getSummary() << "\n";
-    *file << "      </div>\n";
-    *file << "    </td>\n";
-    *file << "  </tr>\n";
+static void writeSummaryTable(GeneratedFile* file, const ostringstream* entries, const char* name,
+                              DeprecatedSelector deprecatedSelector, bool labelAsHeader) {
+    string s = entries->str();
+    if (!s.empty()) {
+        string prefix;
+        if (deprecatedSelector == DEPRECATED_ONLY) {
+            prefix = "Deprecated ";
+        }
+        writeSummaryTableStart(file, prefix + name, labelAsHeader);
+        *file << s;
+        writeSummaryTableEnd(file);
+    }
 }
 
 static void writeSummaryTables(GeneratedFile* file, const map<string, Constant*>& constants,
                                const map<string, Type*>& types,
-                               const map<string, Function*>& functions, bool labelAsHeader) {
-    if (constants.size() > 0) {
-        writeSummaryTableStart(file, "Constants", labelAsHeader);
-        for (auto e : constants) {
-            writeSummaryTableEntry(file, e.second);
-        }
-        writeSummaryTableEnd(file);
+                               const map<string, Function*>& functions,
+                               DeprecatedSelector deprecatedSelector, bool labelAsHeader) {
+    ostringstream constantStream;
+    for (auto e : constants) {
+        writeSummaryTableEntry(&constantStream, e.second, deprecatedSelector);
     }
+    writeSummaryTable(file, &constantStream, "Constants", deprecatedSelector, labelAsHeader);
 
-    if (types.size() > 0) {
-        writeSummaryTableStart(file, "Types", labelAsHeader);
-        for (auto e : types) {
-            writeSummaryTableEntry(file, e.second);
-        }
-        writeSummaryTableEnd(file);
+    ostringstream typeStream;
+    for (auto e : types) {
+        writeSummaryTableEntry(&typeStream, e.second, deprecatedSelector);
     }
+    writeSummaryTable(file, &typeStream, "Types", deprecatedSelector, labelAsHeader);
 
-    if (functions.size() > 0) {
-        writeSummaryTableStart(file, "Functions", labelAsHeader);
-        for (auto e : functions) {
-            writeSummaryTableEntry(file, e.second);
-        }
-        writeSummaryTableEnd(file);
+    ostringstream functionStream;
+    for (auto e : functions) {
+        writeSummaryTableEntry(&functionStream, e.second, deprecatedSelector);
     }
+    writeSummaryTable(file, &functionStream, "Functions", deprecatedSelector, labelAsHeader);
 }
 
 static void writeHtmlVersionTag(GeneratedFile* file, VersionInfo info) {
+    ostringstream stream;
     if (info.intSize == 32) {
-        *file << "For 32 bits: ";
+        stream << "When compiling for 32 bits. ";
     } else if (info.intSize == 64) {
-        *file << "For 64 bits: ";
+        stream << "When compiling for 64 bits. ";
     }
 
     if (info.minVersion > 1 || info.maxVersion) {
-        *file << "<div>";
         const char* mid =
                     "<a "
                     "href='http://developer.android.com/guide/topics/manifest/"
@@ -346,64 +342,81 @@
         if (info.minVersion <= 1) {
             // No minimum
             if (info.maxVersion > 0) {
-                *file << "Removed from " << mid << info.maxVersion + 1;
+                stream << "Removed from " << mid << info.maxVersion + 1;
             }
         } else {
             if (info.maxVersion == 0) {
                 // No maximum
-                *file << "Added in " << mid << info.minVersion;
+                stream << "Added in " << mid << info.minVersion;
             } else {
-                *file << mid << info.minVersion << " - " << info.maxVersion;
+                stream << mid << info.minVersion << " - " << info.maxVersion;
             }
         }
-        *file << "</a></div>\n";
+        stream << "</a>";
+    }
+    const string s = stream.str();
+    if (!s.empty()) {
+        // TODO simplify
+        //*file << "    <p>" << s << "</p>\n";
+        *file << "    " << s << "\n";
     }
 }
 
-static void writeDetailedType(GeneratedFile* file, const TypeSpecification* type) {
+
+static void writeDetailedTypeSpecification(GeneratedFile* file, const TypeSpecification* type) {
     switch (type->getKind()) {
         case SIMPLE:
-            *file << "Base type: " << type->getSimpleType() << "\n";
+            *file << "<p>A typedef of: " << type->getSimpleType()
+                  << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+            writeHtmlVersionTag(file, type->getVersionInfo());
+            *file << "</p>\n";
             break;
         case ENUM: {
-            *file << "An enum<br>\n";
-            *file << "    <table class='jd-tagtable'><tbody>\n";
+            *file << "<p>An enum with the following values:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
+            writeHtmlVersionTag(file, type->getVersionInfo());
+            *file << "</p>\n";
 
+            *file << "  <table class='jd-tagtable'><tbody>\n";
             const vector<string>& values = type->getValues();
             const vector<string>& valueComments = type->getValueComments();
             for (size_t i = 0; i < values.size(); i++) {
-                *file << "    <tr><th>" << values[i] << "</th>";
-                if (valueComments.size() > i && !valueComments[i].empty()) {
-                    *file << "<td>" << valueComments[i] << "</td>";
+                *file << "    <tr><th>" << values[i] << "</th><td>";
+                if (valueComments.size() > i) {
+                    *file << valueComments[i];
                 }
-                *file << "</tr>\n";
+                *file << "</td></tr>\n";
             }
-            *file << "    </tbody></table>\n";
+            *file << "  </tbody></table><br/>\n";
             break;
         }
         case STRUCT: {
             // TODO string mStructName;             // The name found after the struct keyword
-            *file << "A structure<br>\n";
-            *file << "    <table class='jd-tagtable'><tbody>\n";
+            *file << "<p>A structure with the following fields:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+            writeHtmlVersionTag(file, type->getVersionInfo());
+            *file << "</p>\n";
+
+            *file << "  <table class='jd-tagtable'><tbody>\n";
             const vector<string>& fields = type->getFields();
             const vector<string>& fieldComments = type->getFieldComments();
             for (size_t i = 0; i < fields.size(); i++) {
-                *file << "    <tr><th>" << fields[i] << "</th>";
+                *file << "    <tr><th>" << fields[i] << "</th><td>";
                 if (fieldComments.size() > i && !fieldComments[i].empty()) {
-                    *file << "<td>" << fieldComments[i] << "</td>";
+                    *file << fieldComments[i];
                 }
-                *file << "</tr>\n";
+                *file << "</td></tr>\n";
             }
-            *file << "    </tbody></table>\n";
+            *file << "  </tbody></table><br/>\n";
             break;
         }
     }
-    writeHtmlVersionTag(file, type->getVersionInfo());
 }
 
-static void writeDetailedConstant(GeneratedFile* file, ConstantSpecification* c) {
+static void writeDetailedConstantSpecification(GeneratedFile* file, ConstantSpecification* c) {
+    *file << "      <tr><td>";
     *file << "Value: " << c->getValue() << "\n";
     writeHtmlVersionTag(file, c->getVersionInfo());
+    *file << "      </td></tr>\n";
+    *file << "<br/>\n";
 }
 
 static bool writeOverviewForFile(GeneratedFile* file, const SpecFile& specFile) {
@@ -416,7 +429,8 @@
     // Write the summary tables.
     // file << "<h2>Summary</h2>\n";
     writeSummaryTables(file, specFile.getDocumentedConstants(), specFile.getDocumentedTypes(),
-                       specFile.getDocumentedFunctions(), false);
+                       specFile.getDocumentedFunctions(), NON_DEPRECATED_ONLY, false);
+
     return success;
 }
 
@@ -428,8 +442,7 @@
     bool success = true;
     writeHtmlHeader(&file);
 
-    file << "<h1 itemprop='name'>Overview</h1>\n";
-    // TODO Have the overview text here!
+    file << "<h1>Overview</h1>\n";
 
     for (auto specFile : systemSpecification.getSpecFiles()) {
         if (!writeOverviewForFile(&file, *specFile)) {
@@ -450,13 +463,30 @@
     writeHtmlHeader(&file);
 
     writeSummaryTables(&file, systemSpecification.getConstants(), systemSpecification.getTypes(),
-                       systemSpecification.getFunctions(), true);
+                       systemSpecification.getFunctions(), NON_DEPRECATED_ONLY, true);
+
+    writeSummaryTables(&file, systemSpecification.getConstants(), systemSpecification.getTypes(),
+                       systemSpecification.getFunctions(), DEPRECATED_ONLY, true);
 
     writeHtmlFooter(&file);
     file.close();
     return true;
 }
 
+static void writeDeprecatedWarning(GeneratedFile* file, Definition* definition) {
+    if (definition->deprecated()) {
+        *file << "    <p><b>Deprecated.</b>  ";
+        string s = definition->getDeprecatedMessage();
+        convertDocumentationRefences(&s);
+        if (!s.empty()) {
+            *file << s;
+        } else {
+            *file << "Do not use.";
+        }
+        *file << "</p>\n";
+    }
+}
+
 static bool writeDetailedConstant(GeneratedFile* file, Constant* constant) {
     if (constant->hidden()) {
         return true;
@@ -465,7 +495,7 @@
 
     // TODO need names that distinguish fn.const. type
     // TODO had attr_android:...
-    *file << "<a name='android_rs:" << name << "'></a>\n";
+    *file << "<a id='android_rs:" << name << "'></a>\n";
     *file << "<div class='jd-details'>\n";
     *file << "  <h4 class='jd-details-title'>\n";
     *file << "    <span class='sympad'>" << name << "</span>\n";
@@ -474,17 +504,20 @@
 
     *file << "  <div class='jd-details-descr'>\n";
     *file << "    <table class='jd-tagtable'><tbody>\n";
-    for (auto f : constant->getSpecifications()) {
-        *file << "      <tr><td>";
-        writeDetailedConstant(file, f);
-        *file << "      </td></tr>\n";
-        *file << "<br/>\n";
+    auto specifications = constant->getSpecifications();
+    bool addSeparator = specifications.size() > 1;
+    for (auto spec : specifications) {
+        if (addSeparator) {
+            *file << "    <h5 class='jd-tagtitle'>Variant:</h5>\n";
+        }
+        writeDetailedConstantSpecification(file, spec);
     }
     *file << "    </tbody></table>\n";
     *file << "  </div>\n";
 
     *file << "    <div class='jd-tagdata jd-tagdescr'>\n";
 
+    writeDeprecatedWarning(file, constant);
     if (!generateHtmlParagraphs(file, constant->getDescription())) {
         return false;
     }
@@ -503,7 +536,7 @@
 
     // TODO need names that distinguish fn.const. type
     // TODO had attr_android:...
-    *file << "<a name='android_rs:" << name << "'></a>\n";
+    *file << "<a id='android_rs:" << name << "'></a>\n";
     *file << "<div class='jd-details'>\n";
     *file << "  <h4 class='jd-details-title'>\n";
     *file << "    <span class='sympad'>" << name << "</span>\n";
@@ -511,25 +544,16 @@
     *file << "  </h4>\n";
 
     *file << "  <div class='jd-details-descr'>\n";
-    *file << "    <h5 class='jd-tagtitle'>Variants</h5>\n";
-    *file << "    <table class='jd-tagtable'><tbody>\n";
-    for (auto f : type->getSpecifications()) {
-        *file << "      <tr><td>";
-        writeDetailedType(file, f);
-        *file << "      </td></tr>\n";
-        *file << "<br/>\n";
+    for (auto spec : type->getSpecifications()) {
+        writeDetailedTypeSpecification(file, spec);
     }
-    *file << "    </tbody></table>\n";
-    *file << "  </div>\n";
 
-    *file << "    <div class='jd-tagdata jd-tagdescr'>\n";
-
+    writeDeprecatedWarning(file, type);
     if (!generateHtmlParagraphs(file, type->getDescription())) {
         return false;
     }
 
-    *file << "    </div>\n";
-
+    *file << "  </div>\n";
     *file << "</div>\n";
     *file << "\n";
     return true;
@@ -540,7 +564,7 @@
 
     // TODO need names that distinguish fn.const. type
     // TODO had attr_android:...
-    *file << "<a name='android_rs:" << name << "'></a>\n";
+    *file << "<a id='android_rs:" << name << "'></a>\n";
     *file << "<div class='jd-details'>\n";
     *file << "  <h4 class='jd-details-title'>\n";
     *file << "    <span class='sympad'>" << name << "</span>\n";
@@ -548,17 +572,17 @@
     *file << "  </h4>\n";
 
     *file << "  <div class='jd-details-descr'>\n";
-    *file << "    <table class='jd-tagtable'><tbody>\n";
     map<string, DetailedFunctionEntry> entries;
     if (!getUnifiedFunctionPrototypes(function, &entries)) {
         return false;
     }
+    *file << "    <table class='jd-tagtable'><tbody>\n";
     for (auto i : entries) {
         *file << "      <tr>\n";
-        *file << "        <td>" << i.second.htmlDeclaration << "<td/>\n";
+        *file << "        <td>" << i.second.htmlDeclaration << "</td>\n";
         *file << "        <td>";
         writeHtmlVersionTag(file, i.second.info);
-        *file << "</td>\n";
+        *file << "        </td>\n";
         *file << "      </tr>\n";
     }
     *file << "    </tbody></table>\n";
@@ -586,6 +610,7 @@
     }
 
     *file << "  <div class='jd-tagdata jd-tagdescr'>\n";
+    writeDeprecatedWarning(file, function);
     if (!generateHtmlParagraphs(file, function->getDescription())) {
         return false;
     }
@@ -608,8 +633,7 @@
     file << "<br/>";
 
     // Write the file documentation.
-    file << "<h1 itemprop='name'>" << specFile.getBriefDescription()
-         << "</h1>\n";  // TODO not sure about itemprop
+    file << "<h1>" << specFile.getBriefDescription() << "</h1>\n";
 
     file << "<h2>Overview</h2>\n";
     if (!generateHtmlParagraphs(&file, specFile.getFullDescription())) {
@@ -621,7 +645,9 @@
     const auto& constants = specFile.getDocumentedConstants();
     const auto& types = specFile.getDocumentedTypes();
     const auto& functions = specFile.getDocumentedFunctions();
-    writeSummaryTables(&file, constants, types, functions, false);
+
+    writeSummaryTables(&file, constants, types, functions, NON_DEPRECATED_ONLY, false);
+    writeSummaryTables(&file, constants, types, functions, DEPRECATED_ONLY, false);
 
     // Write the full details of each constant, type, and function.
     if (!constants.empty()) {
diff --git a/api/Scanner.h b/api/Scanner.h
index 593ff49..c3d6f33 100644
--- a/api/Scanner.h
+++ b/api/Scanner.h
@@ -20,7 +20,7 @@
 #include <fstream>
 #include <string>
 
-class ParameterEntry;
+struct ParameterEntry;
 
 class Scanner {
 private:
diff --git a/api/Specification.cpp b/api/Specification.cpp
index 92d14d6..fbbbc21 100644
--- a/api/Specification.cpp
+++ b/api/Specification.cpp
@@ -214,7 +214,7 @@
     }
 }
 
-Definition::Definition(const std::string& name) : mName(name), mHidden(false) {
+Definition::Definition(const std::string& name) : mName(name), mDeprecated(false), mHidden(false) {
 }
 
 void Definition::scanDocumentationTags(Scanner* scanner, bool firstOccurence,
@@ -223,6 +223,10 @@
         scanner->checkNoValue();
         mHidden = true;
     }
+    if (scanner->findOptionalTag("deprecated:")) {
+        mDeprecated = true;
+        mDeprecatedMessage = scanner->getValue();
+    }
     if (firstOccurence) {
         if (scanner->findTag("summary:")) {
             mSummary = scanner->getValue();
@@ -561,7 +565,7 @@
 
 FunctionPermutation::FunctionPermutation(Function* func, FunctionSpecification* spec,
                                          int replacementIndexes[MAX_REPLACEABLES], Scanner* scanner)
-    : mFunction(func), mReturn(nullptr), mInputCount(0), mOutputCount(0) {
+    : mReturn(nullptr), mInputCount(0), mOutputCount(0) {
     // We expand the strings now to make capitalization easier.  The previous code preserved
     // the #n
     // markers just before emitting, which made capitalization difficult.
diff --git a/api/Specification.h b/api/Specification.h
index f5211f0..3fa1aa3 100644
--- a/api/Specification.h
+++ b/api/Specification.h
@@ -137,6 +137,8 @@
 class Definition {
 protected:
     std::string mName;
+    bool mDeprecated;                       // True if this API should not be used
+    std::string mDeprecatedMessage;         // Optional specific warning if the API is deprecated
     bool mHidden;                           // True if it should not be documented
     std::string mSummary;                   // A one-line description
     std::vector<std::string> mDescription;  // The comments to be included in the header
@@ -146,6 +148,8 @@
     Definition(const std::string& name);
 
     std::string getName() const { return mName; }
+    bool deprecated() const { return mDeprecated; }
+    std::string getDeprecatedMessage() const { return mDeprecatedMessage; }
     bool hidden() const { return mHidden; }
     std::string getSummary() const { return mSummary; }
     const std::vector<std::string>& getDescription() const { return mDescription; }
@@ -340,7 +344,6 @@
      */
     std::string mUnexpandedName;
     ParameterEntry* mReturn;  // The return type. The name should be empty.  Owned.
-    int mReturnLineNumber;
     std::vector<ParameterEntry*> mParameters;  // The parameters.  Owned.
     std::vector<std::string> mInline;          // The inline code to be included in the header
 
@@ -391,8 +394,6 @@
  */
 class FunctionPermutation {
 private:
-    Function* mFunction;  // NOT OWNED.
-
     // These are the expanded version of those found on FunctionSpecification
     std::string mName;
     std::string mNameTrunk;  // The name without any expansion, e.g. convert
diff --git a/api/Utilities.cpp b/api/Utilities.cpp
index b372b13..6464ae1 100644
--- a/api/Utilities.cpp
+++ b/api/Utilities.cpp
@@ -39,7 +39,7 @@
             " */\n\n";
 
 const char AUTO_GENERATED_WARNING[] =
-            "Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.";
+            "Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.";
 
 string capitalize(const string& source) {
     int length = source.length();
@@ -95,28 +95,29 @@
 }
 
 string stripHtml(const string& html) {
-    string s;
-    for (size_t start = 0; start < html.size(); start++) {
-        size_t lt = html.find('<', start);
+    string in = stringReplace(html, "<li>", "- ");
+    string out;
+    for (size_t start = 0; start < in.size(); start++) {
+        size_t lt = in.find('<', start);
         if (lt == string::npos) {
-            s += html.substr(start);
+            out += in.substr(start);
             break;
         }
-        s += html.substr(start, lt - start);
-        if (isalpha(html[lt + 1]) || html[lt + 1] == '/') {
+        out += in.substr(start, lt - start);
+        if (isalpha(in[lt + 1]) || in[lt + 1] == '/') {
             // It's an HTML tag.  Search for the end.
-            start = html.find('>', lt + 1);
+            start = in.find('>', lt + 1);
             if (start == string::npos) {
                 break;
             }
         } else {
-            s += '<';
+            out += '<';
         }
     }
-    s = stringReplace(s, "&gt;", ">");
-    s = stringReplace(s, "&lt;", "<");
-    s = stringReplace(s, "&nbsp;", " ");
-    return s;
+    out = stringReplace(out, "&gt;", ">");
+    out = stringReplace(out, "&lt;", "<");
+    out = stringReplace(out, "&nbsp;", " ");
+    return out;
 }
 
 string hashString(const string& s) {
diff --git a/api/generate.sh b/api/generate.sh
index fd0085d..e216e46 100755
--- a/api/generate.sh
+++ b/api/generate.sh
@@ -22,7 +22,9 @@
 mkdir -p scriptc
 mkdir -p html
 
-./generator rs_allocation.spec rs_atomic.spec rs_core_math.spec rs_core.spec rs_debug.spec rs_element.spec rs_graphics.spec rs_math.spec rs_matrix.spec rs_mesh.spec rs_object.spec rs_program.spec rs_quaternion.spec rs_sampler.spec rs_time.spec rs_types.spec
+# Because rsIs/Clear/SetObject is documented in rs_object_info but also found in rs_graphics, the latter must appear
+# after the former.
+./generator rs_core.spec rs_value_types.spec rs_object_types.spec rs_allocation_data.spec rs_atomic.spec rs_convert.spec rs_debug.spec rs_for_each.spec rs_io.spec rs_math.spec rs_matrix.spec rs_object_info.spec rs_quaternion.spec rs_time.spec rs_vector_math.spec rs_graphics.spec
 
 rm -f ../../../cts/tests/tests/renderscript/src/android/renderscript/cts/generated/*
 mv test/* ../../../cts/tests/tests/renderscript/src/android/renderscript/cts/generated/
diff --git a/api/rs_allocation.spec b/api/rs_allocation_data.spec
similarity index 76%
rename from api/rs_allocation.spec
rename to api/rs_allocation_data.spec
index 51ec190..fd1e215 100644
--- a/api/rs_allocation.spec
+++ b/api/rs_allocation_data.spec
@@ -17,6 +17,8 @@
 header:
 summary: Allocation routines
 description:
+ TODO Adjust documentation.
+
  Functions that can be used to query the characteristics of an allocation,
  to set and get elements of the allocation.
 end:
@@ -40,7 +42,6 @@
 test: none
 end:
 
-
 function: rsAllocationCopy2DRange
 version: 14
 ret: void
@@ -65,83 +66,6 @@
 test: none
 end:
 
-function: rsAllocationGetDimFaces
-ret: uint32_t, "Returns 1 if more than one face is present, 0 otherwise."
-arg: rs_allocation a
-summary: Presence of more than one face
-description:
- If the allocation is a cubemap, this function returns 1 if there's more than one
- face present.  In all other cases, it returns 0.
-test: none
-end:
-
-function: rsAllocationGetDimLOD
-ret: uint32_t, "Returns 1 if more than one LOD is present, 0 otherwise."
-arg: rs_allocation a
-summary: Presence of levels of details
-description:
- Query an allocation for the presence of more than one Level Of Details.  This is useful for mipmaps.
-test: none
-end:
-
-function: rsAllocationGetDimX
-ret: uint32_t, "The X dimension of the allocation."
-arg: rs_allocation a
-summary: Size of the X dimension
-description:
- Returns the size of the X dimension of the allocation.
-test: none
-end:
-
-function: rsAllocationGetDimY
-ret: uint32_t, "The Y dimension of the allocation."
-arg: rs_allocation a
-summary: Size of the Y dimension
-description:
- Returns the size of the Y dimension of the allocation.
- If the allocation has less than two dimensions, returns 0.
-test: none
-end:
-
-function: rsAllocationGetDimZ
-ret: uint32_t, "The Z dimension of the allocation."
-arg: rs_allocation a
-summary: Size of the Z dimension
-description:
- Returns the size of the Z dimension of the allocation.
- If the allocation has less than three dimensions, returns 0.
-test: none
-end:
-
-function: rsAllocationGetElement
-ret: rs_element, "element describing allocation layout"
-arg: rs_allocation a, "allocation to get data from"
-summary:
-description:
- Get the element object describing the allocation's layout
-test: none
-end:
-
-function: rsAllocationIoReceive
-version: 16
-ret: void
-arg: rs_allocation a, "allocation to work on"
-summary: Receive new content from the queue
-description:
- Receive a new set of contents from the queue.
-test: none
-end:
-
-function: rsAllocationIoSend
-version: 16
-ret: void
-arg: rs_allocation a, "allocation to work on"
-summary: Send new content to the queue
-description:
- Send the contents of the Allocation to the queue.
-test: none
-end:
-
 function: rsAllocationVLoadX_#2#1
 version: 22
 w: 2, 3, 4
@@ -217,20 +141,6 @@
 test: none
 end:
 
-function: rsGetAllocation
-ret: rs_allocation
-arg: const void* p
-summary: Returns the Allocation for a given pointer
-description:
- Returns the Allocation for a given pointer.  The pointer should point within
- a valid allocation.  The results are undefined if the pointer is not from a
- valid allocation.
-
- This function is deprecated and will be removed from the SDK in a future
- release.
-test: none
-end:
-
 function: rsGetElementAt
 ret: const void*
 arg: rs_allocation a
diff --git a/api/rs_convert.spec b/api/rs_convert.spec
new file mode 100644
index 0000000..8e38a4a
--- /dev/null
+++ b/api/rs_convert.spec
@@ -0,0 +1,133 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: Conversion functions
+description:
+ TODO Add desc.
+end:
+
+function: convert_#3#1
+version: 9
+attrib: const
+w: 2, 3, 4
+t: u8, u16, u32, i8, i16, i32, f32
+t: u8, u16, u32, i8, i16, i32, f32
+ret: #3#1
+arg: #2#1 v, compatible(#3)
+summary: Converts numerical vectors
+description:
+ Component wise conversion from a numerical type to another.
+
+ Conversions of floating point values to integer will truncate.
+
+ Conversions of numbers too large to fit the destination type yield undefined results.
+ For example, converting a float that contains 1.0e18 to a short is undefined.
+ Use @clamp() to avoid this.
+end:
+
+function: convert_#3#1
+version: 21
+attrib: const
+w: 2, 3, 4
+t: u64, i64, f64
+t: u64, i64, f64
+ret: #3#1
+arg: #2#1 v, compatible(#3)
+end:
+
+function: convert_#3#1
+version: 21
+attrib: const
+w: 2, 3, 4
+t: u64, i64, f64
+t: u8, u16, u32, i8, i16, i32, f32
+ret: #3#1
+arg: #2#1 v, compatible(#3)
+end:
+
+function: convert_#3#1
+version: 21
+attrib: const
+w: 2, 3, 4
+t: u8, u16, u32, i8, i16, i32, f32
+t: u64, i64, f64
+ret: #3#1
+arg: #2#1 v, compatible(#3)
+end:
+
+function: rsPackColorTo8888
+attrib: const
+ret: uchar4
+arg: float r
+arg: float g
+arg: float b
+summary:
+description:
+ Pack floating point (0-1) RGB values into a uchar4.
+
+ For the float3 variant and the variant that only specifies r, g, b,
+ the alpha component is set to 255 (1.0).
+test: none
+end:
+
+function: rsPackColorTo8888
+attrib: const
+ret: uchar4
+arg: float r
+arg: float g
+arg: float b
+arg: float a
+test: none
+end:
+
+function: rsPackColorTo8888
+attrib: const
+ret: uchar4
+arg: float3 color
+test: none
+end:
+
+function: rsPackColorTo8888
+attrib: const
+ret: uchar4
+arg: float4 color
+test: none
+end:
+
+function: rsUnpackColor8888
+attrib: =const
+ret: float4
+arg: uchar4 c
+summary:
+description:
+ Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
+test: none
+end:
+
+function: rsYuvToRGBA_#2#1
+attrib: const
+w: 4
+t: u8, f32
+ret: #2#1
+arg: uchar y
+arg: uchar u
+arg: uchar v
+summary:
+description:
+ Convert from YUV to RGBA.
+test: none
+end:
diff --git a/api/rs_core.spec b/api/rs_core.spec
index bd5cda8..6177d44 100644
--- a/api/rs_core.spec
+++ b/api/rs_core.spec
@@ -34,378 +34,21 @@
 include:
  #define RS_KERNEL __attribute__((kernel))
 
- #include "rs_types.rsh"
- #include "rs_allocation.rsh"
+ #include "stdbool.h"
+
+ #include "rs_value_types.rsh"
+ #include "rs_object_types.rsh"
+
+ #include "rs_allocation_data.rsh"
  #include "rs_atomic.rsh"
- #include "rs_core_math.rsh"
+ #include "rs_convert.rsh"
  #include "rs_debug.rsh"
- #include "rs_element.rsh"
+ #include "rs_for_each.rsh"
+ #include "rs_io.rsh"
  #include "rs_math.rsh"
  #include "rs_matrix.rsh"
- #include "rs_object.rsh"
+ #include "rs_object_info.rsh"
  #include "rs_quaternion.rsh"
- #include "rs_sampler.rsh"
  #include "rs_time.rsh"
-end:
-
-type: rs_for_each_strategy_t
-enum: rs_for_each_strategy
-value: RS_FOR_EACH_STRATEGY_SERIAL = 0
-value: RS_FOR_EACH_STRATEGY_DONT_CARE = 1
-value: RS_FOR_EACH_STRATEGY_DST_LINEAR = 2
-value: RS_FOR_EACH_STRATEGY_TILE_SMALL = 3
-value: RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4
-value: RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
-summary: Launch order hint for rsForEach calls
-description:
- Launch order hint for rsForEach calls.  This provides a hint to the system to
- determine in which order the root function of the target is called with each
- cell of the allocation.
-
- This is a hint and implementations may not obey the order.
-end:
-
-type: rs_kernel_context
-version: 23
-simple: const struct rs_kernel_context_t *
-summary: Opaque handle to RenderScript kernel invocation context
-description:
- TODO
-end:
-
-type: rs_script_call_t
-struct: rs_script_call
-field: rs_for_each_strategy_t strategy
-field: uint32_t xStart
-field: uint32_t xEnd
-field: uint32_t yStart
-field: uint32_t yEnd
-field: uint32_t zStart
-field: uint32_t zEnd
-field: uint32_t arrayStart
-field: uint32_t arrayEnd
-summary: Provides extra information to a rsForEach call
-description:
- Structure to provide extra information to a rsForEach call.  Primarly used to
- restrict the call to a subset of cells in the allocation.
-end:
-
-function: rsForEach
-version: 9 13
-ret: void
-arg: rs_script script, "The target script to call"
-arg: rs_allocation input, "The allocation to source data from"
-arg: rs_allocation output, "the allocation to write date into"
-arg: const void* usrData, "The user defined params to pass to the root script.  May be NULL."
-arg: const rs_script_call_t* sc, "Extra control infomation used to select a sub-region of the allocation to be processed or suggest a walking strategy.  May be NULL."
-summary:
-description:
- Make a script to script call to launch work. One of the input or output is
- required to be a valid object. The input and output must be of the same
- dimensions.
-test: none
-end:
-
-function: rsForEach
-version: 9 13
-ret: void
-arg: rs_script script
-arg: rs_allocation input
-arg: rs_allocation output
-arg: const void* usrData
-test: none
-end:
-
-function: rsForEach
-version: 14 20
-ret: void
-arg: rs_script script
-arg: rs_allocation input
-arg: rs_allocation output
-arg: const void* usrData
-arg: size_t usrDataLen, "The size of the userData structure.  This will be used to perform a shallow copy of the data if necessary."
-arg: const rs_script_call_t* sc
-test: none
-end:
-
-function: rsForEach
-version: 14 20
-ret: void
-arg: rs_script script
-arg: rs_allocation input
-arg: rs_allocation output
-arg: const void* usrData
-arg: size_t usrDataLen
-test: none
-end:
-
-function: rsForEach
-version: 14
-ret: void
-arg: rs_script script
-arg: rs_allocation input
-arg: rs_allocation output
-test: none
-end:
-
-function: rsSendToClient
-ret: bool
-arg: int cmdID
-summary:
-description:
- Send a message back to the client.  Will not block and returns true
- if the message was sendable and false if the fifo was full.
- A message ID is required.  Data payload is optional.
-test: none
-end:
-
-function: rsSendToClient
-ret: bool
-arg: int cmdID
-arg: const void* data
-arg: uint len
-test: none
-end:
-
-function: rsSendToClientBlocking
-ret: void
-arg: int cmdID
-summary:
-description:
- Send a message back to the client, blocking until the message is queued.
- A message ID is required.  Data payload is optional.
-test: none
-end:
-
-function: rsSendToClientBlocking
-ret: void
-arg: int cmdID
-arg: const void* data
-arg: uint len
-test: none
-end:
-
-function: rsGetArray0
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Index in the Array0 dimension for the specified context
-description:
- Returns the index in the Array0 dimension of the cell being processed,
- as specified by the supplied context.
-
- This context is created when a kernel is launched and updated at each
- iteration.  It contains common characteristics of the allocations being
- iterated over and rarely used indexes, like the Array0 index.
-
- You can access the context by adding a rs_kernel_context argument to your
- kernel function.  E.g.<br/>
- <code>short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {<br/>
- &nbsp;&nbsp;// The current index in the common x, y, z, w dimensions are accessed by<br/>
- &nbsp;&nbsp;// adding these variables as arguments.  For the more rarely used indexes<br/>
- &nbsp;&nbsp;// to the other dimensions, extract them from the context:<br/>
- &nbsp;&nbsp;uint32_t index_a0 = rsGetArray0(context);<br/>
- &nbsp;&nbsp;//...<br/>
- }<br/></code>
-
- This function returns 0 if the Array0 dimension is not present.
-test: none
-end:
-
-function: rsGetArray1
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Index in the Array1 dimension for the specified context
-description:
- Returns the index in the Array1 dimension of the cell being processed,
- as specified by the supplied context.  See @rsGetArray0() for an explanation
- of the context.
-
- Returns 0 if the Array1 dimension is not present.
-test: none
-end:
-
-function: rsGetArray2
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Index in the Array2 dimension for the specified context
-description:
- Returns the index in the Array2 dimension of the cell being processed,
- as specified by the supplied context.  See @rsGetArray0() for an explanation
- of the context.
-
- Returns 0 if the Array2 dimension is not present.
-test: none
-end:
-
-function: rsGetArray3
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Index in the Array3 dimension for the specified context
-description:
- Returns the index in the Array3 dimension of the cell being processed,
- as specified by the supplied context.  See @rsGetArray0() for an explanation
- of the context.
-
- Returns 0 if the Array3 dimension is not present.
-test: none
-end:
-
-function: rsGetDimArray0
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Array0 dimension for the specified context
-description:
- Returns the size of the Array0 dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Array0 dimension is not present.
-#TODO Add an hyperlink to something that explains Array0/1/2/3
-# for the relevant functions.
-test: none
-end:
-
-function: rsGetDimArray1
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Array1 dimension for the specified context
-description:
- Returns the size of the Array1 dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Array1 dimension is not present.
-test: none
-end:
-
-function: rsGetDimArray2
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Array2 dimension for the specified context
-description:
- Returns the size of the Array2 dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Array2 dimension is not present.
-test: none
-end:
-
-function: rsGetDimArray3
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Array3 dimension for the specified context
-description:
- Returns the size of the Array3 dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Array3 dimension is not present.
-test: none
-end:
-
-function: rsGetDimHasFaces
-version: 23
-ret: bool, "Returns true if more than one face is present, false otherwise."
-arg: rs_kernel_context ctxt
-summary: Presence of more than one face for the specified context
-description:
- If the context refers to a cubemap, this function returns true if there's
- more than one face present.  In all other cases, it returns false.
- See @rsGetDimX() for an explanation of the context.
-
- @rsAllocationGetDimFaces() is similar but returns 0 or 1 instead of a bool.
-test: none
-end:
-
-function: rsGetDimLod
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Number of levels of detail for the specified context
-description:
- Returns the number of levels of detail for the specified context.
- This is useful for mipmaps.  See @rsGetDimX() for an explanation of the context.
- Returns 0 if Level of Detail is not used.
-
- @rsAllocationGetDimLOD() is similar but returns 0 or 1 instead the actual
- number of levels.
-test: none
-end:
-
-function: rsGetDimX
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the X dimension for the specified context
-description:
- Returns the size of the X dimension for the specified context.
-
- This context is created when a kernel is launched.  It contains common
- characteristics of the allocations being iterated over by the kernel in
- a very efficient structure.  It also contains rarely used indexes.
-
- You can access it by adding a rs_kernel_context argument to your kernel
- function.  E.g.<br/>
- <code>int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {<br/>
- &nbsp;&nbsp;uint32_t size = rsGetDimX(context); //...<br/></code>
-test: none
-end:
-
-function: rsGetDimY
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Y dimension for the specified context
-description:
- Returns the size of the X dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Y dimension is not present.
-test: none
-end:
-
-function: rsGetDimZ
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Size of the Z dimension for the specified context
-description:
- Returns the size of the Z dimension for the specified context.
- See @rsGetDimX() for an explanation of the context.
-
- Returns 0 if the Z dimension is not present.
-test: none
-end:
-
-function: rsGetFace
-version: 23
-ret: rs_allocation_cubemap_face
-arg: rs_kernel_context ctxt
-summary: Coordinate of the Face for the specified context
-description:
- Returns the face on which the cell being processed is found, as specified
- by the supplied context.  See @rsGetArray0() for an explanation of the context.
-
- Returns RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X if the face dimension is not
- present.
-test: none
-end:
-
-function: rsGetLod
-version: 23
-ret: uint32_t
-arg: rs_kernel_context ctxt
-summary: Index in the Levels of Detail dimension for the specified context.
-description:
- Returns the index in the Levels of Detail dimension of the cell being
- processed, as specified by the supplied context.  See @rsGetArray0() for
- an explanation of the context.
-
- Returns 0 if the Levels of Detail dimension is not present.
-test: none
+ #include "rs_vector_math.rsh"
 end:
diff --git a/api/rs_core_math.spec b/api/rs_core_math.spec
deleted file mode 100644
index bf47bdc..0000000
--- a/api/rs_core_math.spec
+++ /dev/null
@@ -1,2284 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Mathematical functions
-description:
- Most mathematical functions can be applied to scalars and vectors.
- When applied to vectors, a vector of the function applied to each entry
- of the input is returned.
-
- For example:<br/>
- <code>
- float3 a, b;<br/>
- // The following call sets<br/>
- //   a.x to sin(b.x),<br/>
- //   a.y to sin(b.y), and<br/>
- //   a.z to sin(b.z).<br/>
- a = sin(b);<br/>
- </code>
-
- A few functions like @distance() and @length() interpret instead the input
- as a single vector in n-dimensional space.
-
- The precision of the mathematical operations is affected by the pragmas
-# TODO Create an anchor for the section of http://developer.android.com/guide/topics/renderscript/compute.html that details rs_fp_* and link them here.
- rs_fp_relaxed and rs_fp_full.
-
- Different precision/speed tradeoffs can be achieved by using three variants
- of common math functions.  Functions with a name starting with<ul>
- <li>native_ may have custom hardware implementations with weaker precision,</li>
- <li>half_ may perform internal computations using 16 bit floats, and</li>
- <li>fast_ are n-dimensional space computations that may use 16 bit floats.
- </ul>
-end:
-
-function: abs
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: i8, i16, i32
-ret: u#2#1
-arg: #2#1 v
-summary: Absolute value of an integer
-description:
- Returns the absolute value of an integer.
-
- For floats, use @fabs().
-end:
-
-function: acos
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse cosine
-description:
- Returns the inverse cosine, in radians.
-
- See also @native_acos().
-end:
-
-function: acosh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Inverse hyperbolic cosine
-description:
- Returns the inverse hyperbolic cosine, in radians.
-
- See also @native_acosh().
-end:
-
-function: acospi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse cosine divided by pi
-description:
- Returns the inverse cosine in radians, divided by pi.
-
- To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>.
-
- See also @native_acospi().
-end:
-
-function: asin
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse sine
-description:
- Returns the inverse sine, in radians.
-
- See also @native_asin().
-end:
-
-function: asinh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Inverse hyperbolic sine
-description:
- Returns the inverse hyperbolic sine, in radians.
-
- See also @native_asinh().
-end:
-
-function: asinpi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse sine divided by pi
-description:
- Returns the inverse sine in radians, divided by pi.
-
- To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
-
- See also @native_asinpi().
-end:
-
-function: atan
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse tangent
-description:
- Returns the inverse tangent, in radians.
-
- See also @native_atan().
-end:
-
-function: atan2
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator, "The numerator"
-arg: #2#1 denominator, "The denominator.  Can be 0."
-summary: Inverse tangent of a ratio
-description:
- Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians.
-
- See also @native_atan2().
-end:
-
-function: atan2pi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator, "The numerator"
-arg: #2#1 denominator, "The denominator.  Can be 0."
-summary: Inverse tangent of a ratio, divided by pi
-description:
- Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi.
-
- To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
-
- See also @native_atan2pi().
-end:
-
-function: atanh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse hyperbolic tangent
-description:
- Returns the inverse hyperbolic tangent, in radians.
-
- See also @native_atanh().
-end:
-
-function: atanpi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Inverse tangent divided by pi
-description:
- Returns the inverse tangent in radians, divided by pi.
-
- To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
-
- See also @native_atanpi().
-end:
-
-function: cbrt
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Cube root
-description:
- Returns the cube root.
-
- See also @native_cbrt().
-end:
-
-function: ceil
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Smallest integer not less than a value
-description:
- Returns the smallest integer not less than a value.
-
- For example, <code>ceil(1.2f)</code> returns 2.f, and <code>ceil(-1.2f)</code> returns -1.f.
-
- See also @floor().
-end:
-
-function: clamp
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 value, "Value to be clamped."
-arg: #2#1 min_value, "Lower bound, a scalar or matching vector."
-arg: #2#1 max_value, above(min_value), "High bound, must match the type of low."
-summary: Restrain a value to a range
-description:
- Clamps a value to a specified high and low bound.  clamp() returns min_value
- if value &lt; min_value, max_value if value &gt; max_value, otherwise value.
-
- There are two variants of clamp: one where the min and max are scalars applied
- to all entries of the value, the other where the min and max are also vectors.
-
- If min_value is greater than max_value, the results are undefined.
-end:
-
-function: clamp
-version: 9
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 value
-arg: #2 min_value
-arg: #2 max_value, above(min_value)
-end:
-
-function: clamp
-version: 19
-attrib: const
-w: 1, 2, 3, 4
-t: u8, u16, u32, u64, i8, i16, i32, i64
-ret: #2#1
-arg: #2#1 value
-arg: #2#1 min_value
-arg: #2#1 max_value, above(min_value)
-end:
-
-function: clamp
-version: 19
-attrib: const
-w: 2, 3, 4
-t: u8, u16, u32, u64, i8, i16, i32, i64
-ret: #2#1
-arg: #2#1 value
-arg: #2 min_value
-arg: #2 max_value, above(min_value)
-end:
-
-function: clz
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: u8, u16, u32, i8, i16, i32
-ret: #2#1
-arg: #2#1 value
-summary: Number of leading 0 bits
-description:
- Returns the number of leading 0-bits in a value.
-
- For example, <code>clz((char)0x03)</code> returns 6.
-end:
-
-function: convert_#3#1
-version: 9
-attrib: const
-w: 2, 3, 4
-t: u8, u16, u32, i8, i16, i32, f32
-t: u8, u16, u32, i8, i16, i32, f32
-ret: #3#1
-arg: #2#1 v, compatible(#3)
-summary: Converts numerical vectors
-description:
- Component wise conversion from a numerical type to another.
-
- Conversions of floating point values to integer will truncate.
-
- Conversions of numbers too large to fit the destination type yield undefined results.
- For example, converting a float that contains 1.0e18 to a short is undefined.
- Use @clamp() to avoid this.
-end:
-
-function: convert_#3#1
-version: 21
-attrib: const
-w: 2, 3, 4
-t: u64, i64, f64
-t: u64, i64, f64
-ret: #3#1
-arg: #2#1 v, compatible(#3)
-end:
-
-function: convert_#3#1
-version: 21
-attrib: const
-w: 2, 3, 4
-t: u64, i64, f64
-t: u8, u16, u32, i8, i16, i32, f32
-ret: #3#1
-arg: #2#1 v, compatible(#3)
-end:
-
-function: convert_#3#1
-version: 21
-attrib: const
-w: 2, 3, 4
-t: u8, u16, u32, i8, i16, i32, f32
-t: u64, i64, f64
-ret: #3#1
-arg: #2#1 v, compatible(#3)
-end:
-
-function: copysign
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 magnitude_value
-arg: #2#1 sign_value
-summary: Copies the sign of a number to another
-description:
- Copies the sign from sign_value to magnitude_value.
-
- The value returned is either magnitude_value or -magnitude_value.
-
- For example, <code>copysign(4.0f, -2.7f)</code> returns -4.0f and <code>copysign(-4.0f, 2.7f)</code> returns 4.0f.
-end:
-
-function: cos
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Cosine
-description:
- Returns the cosine of an angle measured in radians.
-
- See also @native_cos().
-end:
-
-function: cosh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Hypebolic cosine
-description:
- Returns the hypebolic cosine of v, where v is measured in radians.
-
- See also @native_cosh().
-end:
-
-function: cospi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Cosine of a number multiplied by pi
-description:
- Returns the cosine of <code>(v * pi)</code>, where <code>(v * pi)</code> is measured in radians.
-
- To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
-
- See also @native_cospi().
-end:
-
-function: cross
-version: 9
-attrib: const
-w: 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Cross product of two vectors
-description:
- Computes the cross product of two vectors.
-test: vector
-end:
-
-function: degrees
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Converts radians into degrees
-description:
- Converts from radians to degrees.
-end:
-
-function: distance
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Distance between two points
-description:
- Compute the distance between two points.
-
- See also @fast_distance(), @native_distance().
-test: vector
-end:
-
-function: dot
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Dot product of two vectors
-description:
- Computes the dot product of two vectors.
-test: vector
-end:
-
-function: erf
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Mathematical error function
-description:
- Returns the error function.
-end:
-
-function: erfc
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Mathematical complementary error function
-description:
- Returns the complementary error function.
-end:
-
-function: exp
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: e raised to a number
-description:
- Returns e raised to v, i.e. e ^ v.
-
- See also @native_exp().
-end:
-
-function: exp10
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: 10 raised to a number
-description:
- Returns 10 raised to v, i.e. 10.f ^ v.
-
- See also @native_exp10().
-end:
-
-function: exp2
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: 2 raised to a number
-description:
- Returns 2 raised to v, i.e. 2.f ^ v.
-
- See also @native_exp2().
-end:
-
-function: expm1
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: e raised to a number minus one
-description:
- Returns e raised to v minus 1, i.e. (e ^ v) - 1.
-
- See also @native_expm1().
-end:
-
-function: fabs
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Absolute value of a float
-description:
- Returns the absolute value of the float v.
-
- For integers, use @abs().
-end:
-
-function: fast_distance
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Approximate distance between two points
-description:
- Computes the approximate distance between two points.
-
- The precision is what would be expected from doing the computation using 16 bit floating point values.
-
- See also @distance(), @native_distance().
-test: vector
-end:
-
-function: fast_length
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 v
-summary: Approximate length of a vector
-description:
- Computes the approximate length of a vector.
-
- The precision is what would be expected from doing the computation using 16 bit floating point values.
-
- See also @length(), @native_length().
-test: vector
-end:
-
-function: fast_normalize
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate normalized vector
-description:
- Approximately normalizes a vector.
-
- For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
-
- The precision is what would be expected from doing the computation using 16 bit floating point values.
-
- See also @normalize(), @native_normalize().
-test: vector
-end:
-
-function: fdim
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Positive difference between two values
-description:
- Returns the positive difference between two values.
-
- If a &gt; b, returns (a - b) otherwise returns 0f.
-end:
-
-function: floor
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Smallest integer not greater than a value
-description:
- Returns the smallest integer not greater than a value.
-
- For example, <code>floor(1.2f)</code> returns 1.f, and <code>floor(-1.2f)</code> returns -2.f.
-
- See also @ceil().
-end:
-
-function: fma
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 multiplicand1
-arg: #2#1 multiplicand2
-arg: #2#1 offset
-summary: Multiply and add
-description:
- Multiply and add.  Returns <code>(multiplicand1 * multiplicand2) + offset</code>.
-
- This function is similar to @mad().  fma() retains full precision of the
- multiplied result and rounds only after the addition.  @mad() rounds after the
- multiplication and the addition.  This extra precision is not guaranteed in
- rs_fp_relaxed mode.
-end:
-
-function: fmax
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Maximum of two floats
-description:
- Returns the maximum of a and b, i.e. <code>(a &lt; b ? b : a)</code>.
-
- The @max() function returns identical results but can be applied to more data types.
-end:
-
-function: fmax
-version: 9
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2 b
-end:
-
-function: fmin
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Minimum of two floats
-description:
- Returns the minimum of a and b, i.e. <code>(a &gt; b ? b : a)</code>.
-
- The @min() function returns identical results but can be applied to more data types.
-end:
-
-function: fmin
-version: 9
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2 b
-end:
-
-function: fmod
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator
-arg: #2#1 denominator
-summary: Modulo
-description:
- Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
-
- The function @remainder() is similar but rounds toward the closest interger.
- For example, <code>fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
- while <code>@remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
-end:
-
-function: fract
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, "Input value."
-arg: #2#1* floor, "If floor is not null, *floor will be set to the floor of v."
-summary: Positive fractional part
-description:
- Returns the positive fractional part of v, i.e. <code>v - floor(v)</code>.
-
- For example, <code>fract(1.3f, &val)</code> returns 0.3f and sets val to 1.f.
- <code>fract(-1.3f, &val)</code> returns 0.7f and sets val to -2.f.
-end:
-
-function: fract
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-inline:
- #2#1 unused;
- return fract(v, &unused);
-end:
-
-function: frexp
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, "Input value."
-arg: int#1* exponent, "If exponent is not null, *exponent will be set to the exponent of v."
-summary: Binary mantissa and exponent
-description:
- Returns the binary mantissa and exponent of v, i.e. <code>v == mantissa * 2 ^ exponent</code>.
-
- The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
-
- See @ldexp() for the reverse operation.  See also @logb() and @ilogb().
-end:
-
-function: half_recip
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Reciprocal computed to 16 bit precision
-description:
- Returns the approximate reciprocal of a value.
-
- The precision is that of a 16 bit floating point value.
-
- See also @native_recip().
-end:
-
-function: half_rsqrt
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Reciprocal of a square root computed to 16 bit precision
-description:
- Returns the approximate value of <code>(1.f / sqrt(value))</code>.
-
- The precision is that of a 16 bit floating point value.
-
- See also @rsqrt(), @native_rsqrt().
-end:
-
-function: half_sqrt
-version: 17
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Square root computed to 16 bit precision
-description:
- Returns the approximate square root of a value.
-
- The precision is that of a 16 bit floating point value.
-
- See also @sqrt(), @native_sqrt().
-end:
-
-function: hypot
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Hypotenuse
-description:
- Returns the hypotenuse, i.e. <code>sqrt(a * a + b * b)</code>.
-
- See also @native_hypot().
-end:
-
-function: ilogb
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: int#1
-arg: float#1 v
-summary: Base two exponent
-description:
- Returns the base two exponent of a value, where the mantissa is between
- 1.f (inclusive) and 2.f (exclusive).
-
- For example, <code>ilogb(8.5f)</code> returns 3.
-
- Because of the difference in mantissa, this number is one less than
- is returned by @frexp().
-
- @logb() is similar but returns a float.
-test: custom
-end:
-
-function: ldexp
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-ret: float#1
-arg: float#1 mantissa, "The mantissa"
-arg: int#1 exponent, "The exponent, a single component or matching vector."
-summary: Creates a floating point from mantissa and exponent
-description:
- Returns the floating point created from the mantissa and exponent,
- i.e. (mantissa * 2 ^ exponent).
-
- See @frexp() for the reverse operation.
-end:
-
-function: ldexp
-version: 9
-attrib: const
-w: 2, 3, 4
-ret: float#1
-arg: float#1 mantissa
-arg: int exponent
-end:
-
-function: length
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 v
-summary: Length of a vector
-description:
- Computes the length of a vector.
-
- See also @fast_length(), @native_length().
-test: vector
-end:
-
-function: lgamma
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Natural logarithm of the gamma function
-description:
- Returns the natural logarithm of the absolute value of the gamma function,
- i.e. <code>@log(@fabs(@tgamma(v)))</code>.
-
- See also @tgamma().
-end:
-
-function: lgamma
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-arg: int#1* sign_of_gamma, "If sign_of_gamma is not null, *sign_of_gamma will be set to -1.f if the gamma of v is negative, otherwise to 1.f."
-test: custom
-#TODO Temporary until bionic & associated drivers are fixed
-end:
-
-function: log
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Natural logarithm
-description:
- Returns the natural logarithm.
-
- See also @native_log().
-end:
-
-function: log10
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Base 10 logarithm
-description:
- Returns the base 10 logarithm.
-
- See also @native_log10().
-end:
-
-function: log1p
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Natural logarithm of a value plus 1
-description:
- Returns the natural logarithm of <code>(v + 1.f)</code>.
-
- See also @native_log1p().
-end:
-
-function: log2
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Base 2 logarithm
-description:
- Returns the base 2 logarithm.
-
- See also @native_log2().
-end:
-
-function: logb
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Base two exponent
-description:
- Returns the base two exponent of a value, where the mantissa is between
- 1.f (inclusive) and 2.f (exclusive).
-
- For example, <code>logb(8.5f)</code> returns 3.f.
-
- Because of the difference in mantissa, this number is one less than
- is returned by frexp().
-
- @ilogb() is similar but returns an integer.
-end:
-
-function: mad
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 multiplicand1
-arg: #2#1 multiplicand2
-arg: #2#1 offset
-summary: Multiply and add
-description:
- Multiply and add.  Returns <code>(multiplicand1 * multiplicand2) + offset</code>.
-
- This function is similar to @fma().  @fma() retains full precision of the
- multiplied result and rounds only after the addition.  mad() rounds after the
- multiplication and the addition.  In rs_fp_relaxed mode, mad() may not do the
- rounding after multiplicaiton.
-end:
-
-function: max
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Maximum
-description:
- Returns the maximum value of two arguments.
-end:
-
-function: max
-version: 9 20
-attrib: const
-w: 1
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- return (a > b ? a : b);
-end:
-
-function: max
-version: 9 20
-attrib: const
-w: 2
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x > b.x ? a.x : b.x);
- tmp.y = (a.y > b.y ? a.y : b.y);
- return tmp;
-end:
-
-function: max
-version: 9 20
-attrib: const
-w: 3
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x > b.x ? a.x : b.x);
- tmp.y = (a.y > b.y ? a.y : b.y);
- tmp.z = (a.z > b.z ? a.z : b.z);
- return tmp;
-end:
-
-function: max
-version: 9 20
-attrib: const
-w: 4
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x > b.x ? a.x : b.x);
- tmp.y = (a.y > b.y ? a.y : b.y);
- tmp.z = (a.z > b.z ? a.z : b.z);
- tmp.w = (a.w > b.w ? a.w : b.w);
- return tmp;
-end:
-
-function: max
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: i8, i16, i32, i64, u8, u16, u32, u64
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-end:
-
-function: min
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Minimum
-description:
- Returns the minimum value of two arguments.
-end:
-
-function: min
-version: 9 20
-attrib: const
-w: 1
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- return (a < b ? a : b);
-end:
-
-function: min
-version: 9 20
-attrib: const
-w: 2
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x < b.x ? a.x : b.x);
- tmp.y = (a.y < b.y ? a.y : b.y);
- return tmp;
-end:
-
-function: min
-version: 9 20
-attrib: const
-w: 3
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x < b.x ? a.x : b.x);
- tmp.y = (a.y < b.y ? a.y : b.y);
- tmp.z = (a.z < b.z ? a.z : b.z);
- return tmp;
-end:
-
-function: min
-version: 9 20
-attrib: const
-w: 4
-t: i8, i16, i32, u8, u16, u32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-inline:
- #2#1 tmp;
- tmp.x = (a.x < b.x ? a.x : b.x);
- tmp.y = (a.y < b.y ? a.y : b.y);
- tmp.z = (a.z < b.z ? a.z : b.z);
- tmp.w = (a.w < b.w ? a.w : b.w);
- return tmp;
-end:
-
-function: min
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: i8, i16, i32, i64, u8, u16, u32, u64
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-end:
-
-function: mix
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 start
-arg: #2#1 stop
-arg: #2#1 fraction
-summary: Mixes two values
-description:
- Returns start + ((stop - start) * fraction).
-
- This can be useful for mixing two values.  For example, to create a new color that is 40% color1 and 60% color2, use <code>mix(color1, color2, 0.6f)</code>.
-end:
-
-function: mix
-version: 9
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 start
-arg: #2#1 stop
-arg: #2 fraction
-end:
-
-function: modf
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1, "The floating point portion of the value."
-arg: #2#1 v, "Source value"
-arg: #2#1* integral_part, "*integral_part will be set to the integral portion of the number."
-summary: Integral and fractional components
-description:
- Returns the integral and fractional components of a number.
-
- Both components will have the same sign as x.  For example, for an input of -3.72f, iret will be set to -3.f and .72f will be returned.
-end:
-
-function: nan
-version: 9
-attrib: const
-w: 1
-t: f32
-ret: #2#1
-arg: uint#1 v, "Not used."
-#TODO We're not using the argument.  Once we do, add this documentation line:
-# The argument is embedded into the return value and can be used to distinguish various NaNs.
-summary: Not a Number
-description:
- Returns a NaN value (Not a Number).
-end:
-
-function: native_acos
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse cosine
-description:
- Returns the approximate inverse cosine, in radians.
-
- This function yields undefined results from input values less than -1 or greater
- than 1.
-
- See also @acos().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_acosh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate inverse hyperbolic cosine
-description:
- Returns the approximate inverse hyperbolic cosine, in radians.
-
- See also @acosh().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_acospi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse cosine divided by pi
-description:
- Returns the approximate inverse cosine in radians, divided by pi.
-
- To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>.
-
- This function yields undefined results from input values less than -1 or greater
- than 1.
-
- See also @acospi().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_asin
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse sine
-description:
- Returns the approximate inverse sine, in radians.
-
- This function yields undefined results from input values less than -1 or greater
- than 1.
-
- See also @asin().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_asinh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate inverse hyperbolic sine
-description:
- Returns the approximate inverse hyperbolic sine, in radians.
-
- See also @asinh().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_asinpi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse sine divided by pi
-description:
- Returns the approximate inverse sine in radians, divided by pi.
-
- To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
-
- This function yields undefined results from input values less than -1 or greater
- than 1.
-
- See also @asinpi().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_atan
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse tangent
-description:
- Returns the approximate inverse tangent, in radians.
-
- See also @atan().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_atan2
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator, "The numerator"
-arg: #2#1 denominator, "The denominator.  Can be 0."
-summary: Approximate inverse tangent of a ratio
-description:
- Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians.
-
- See also @atan2().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_atan2pi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator, "The numerator"
-arg: #2#1 denominator, "The denominator.  Can be 0."
-summary: Approximate inverse tangent of a ratio, divided by pi
-description:
- Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi.
-
- To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
-
- See also @atan2pi().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_atanh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse hyperbolic tangent
-description:
- Returns the approximate inverse hyperbolic tangent, in radians.
-
- See also @atanh().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_atanpi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-1,1)
-summary: Approximate inverse tangent divided by pi
-description:
- Returns the approximate inverse tangent in radians, divided by pi.
-
- To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
-
- See also @atanpi().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_cbrt
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate cube root
-description:
- Returns the approximate cubic root.
-
- See also @cbrt().
-end:
-
-function: native_cos
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate cosine
-description:
- Returns the approximate cosine of an angle measured in radians.
-
- See also @cos().
-end:
-
-function: native_cosh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate hypebolic cosine
-description:
- Returns the approximate hypebolic cosine.
-
- See also @cosh().
-end:
-
-function: native_cospi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate cosine of a number multiplied by pi
-description:
- Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
-
- To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
-
- See also @cospi().
-end:
-
-function: native_distance
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Approximate distance between two points
-description:
- Computes the approximate distance between two points.
-
- See also @distance(), @fast_distance().
-test: vector
-end:
-
-function: native_divide
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 left_vector
-arg: #2#1 right_vector
-summary: Approximate division
-description:
- Computes the approximate division of two values.
-end:
-
-function: native_exp
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-86,86)
-summary: Approximate e raised to a number
-description:
- Fast approximate exp.
-
- It is valid for inputs from -86.f to 86.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
-
- See also @exp().
-test: limited
-end:
-
-function: native_exp10
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-37,37)
-summary: Approximate 10 raised to a number
-description:
- Fast approximate exp10.
-
- It is valid for inputs from -37.f to 37.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
-
- See also @exp10().
-test: limited
-end:
-
-function: native_exp2
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(-125,125)
-summary: Approximate 2 raised to a number
-description:
- Fast approximate exp2.
-
- It is valid for inputs from -125.f to 125.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
-
- See also @exp2().
-test: limited
-end:
-
-function: native_expm1
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate e raised to a number minus one
-description:
- Returns the approximate (e ^ v) - 1.
-
- See also @expm1().
-end:
-
-function: native_hypot
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 a
-arg: #2#1 b
-summary: Approximate hypotenuse
-description:
- Returns the approximate native_sqrt(a * a + b * b)
-
- See also @hypot().
-end:
-
-function: native_length
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2
-arg: #2#1 v
-summary: Approximate length of a vector
-description:
- Compute the approximate length of a vector.
-
- See also @length(), @fast_length().
-test: vector
-end:
-
-function: native_log
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(10e-10,10e10)
-summary: Approximate natural logarithm
-description:
- Fast approximate log.
-
- It is not accurate for values very close to zero.
-
- See also @log().
-test: limited
-end:
-
-function: native_log10
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(10e-10,10e10)
-summary: Approximate base 10 logarithm
-description:
- Fast approximate log10.
-
- It is not accurate for values very close to zero.
-
- See also @log10().
-test: limited
-end:
-
-function: native_log1p
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate natural logarithm of a value plus 1
-description:
- Returns the approximate natural logarithm of (v + 1.0f)
-
- See also @log1p().
-end:
-
-function: native_log2
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v, range(10e-10,10e10)
-summary: Approximate base 2 logarithm
-description:
- Fast approximate log2.
-
- It is not accurate for values very close to zero.
-
- See also @log2().
-test: limited
-end:
-
-function: native_normalize
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary:  Approximately normalize a vector
-description:
- Approximately normalizes a vector.
-
- See also @normalize(), @fast_normalize().
-test: vector
-end:
-
-function: native_powr
-version: 18
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 base, range(0,256), "Must be between 0.f and 256.f.  The function is not accurate for values very close to zero."
-arg: #2#1 exponent, range(-15,15), "Must be between -15.f and 15.f."
-summary: Approximate positive base raised to an exponent
-description:
- Fast approximate (base ^ exponent).
-
- See also @powr().
-test: limited
-end:
-
-function: native_recip
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate reciprocal
-description:
- Returns the approximate approximate reciprocal of a value.
-
- See also @half_recip().
-end:
-
-function: native_rootn
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-arg: int#1 n
-summary: Approximate nth root
-description:
- Compute the approximate Nth root of a value.
-
- See also @rootn().
-end:
-
-function: native_rsqrt
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate reciprocal of a square root
-description:
- Returns approximate (1 / sqrt(v)).
-
- See also @rsqrt(), @half_rsqrt().
-end:
-
-function: native_sin
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate sine
-description:
- Returns the approximate sine of an angle measured in radians.
-
- See also @sin().
-end:
-
-function: native_sincos
-version: 21
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1, "sine"
-arg: #2#1 v, "The incoming value in radians."
-arg: #2#1* cos, "*cos will be set to the cosine value."
-summary: Approximate sine and cosine
-description:
- Returns the approximate sine and cosine of a value.
-
- See also @sincos().
-# TODO Temporary
-test: limited(0.0005)
-end:
-
-function: native_sinh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate hyperbolic sine
-description:
- Returns the approximate hyperbolic sine of a value specified in radians.
-
- See also @sinh().
-end:
-
-function: native_sinpi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate sine of a number multiplied by pi
-description:
- Returns the approximate sine of (v * pi), where (v * pi) is measured in radians.
-
- To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>.
-
- See also @sinpi().
-end:
-
-function: native_sqrt
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate square root
-description:
- Returns the approximate sqrt(v).
-
- See also @sqrt(), @half_sqrt().
-end:
-
-function: native_tan
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate tangent
-description:
- Returns the approximate tangent of an angle measured in radians.
-end:
-
-function: native_tanh
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate hyperbolic tangent
-description:
- Returns the approximate hyperbolic tangent of a value.
-
- See also @tanh().
-end:
-
-function: native_tanpi
-version: 21
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Approximate tangent of a number multiplied by pi
-description:
- Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians.
-
- To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>.
-
- See also @tanpi().
-end:
-
-function: nextafter
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-arg: #2#1 target
-summary: Next floating point number
-description:
- Returns the next representable floating point number from v towards target.
-
- In rs_fp_relaxed mode, a denormalized input value may not yield the next
- denormalized  value, as support of denormalized values is optional in
- relaxed mode.
-end:
-
-function: normalize
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Normalize a vector
-description:
- Normalize a vector.
-
- For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
-
- See also @fast_normalize(), @native_normalize().
-test: vector
-end:
-
-function: pow
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 base
-arg: #2#1 exponent
-summary: Base raised to an exponent
-description:
- Returns base raised to the power exponent, i.e. base ^ exponent.
-
- @pown() and @powr() are similar.  @pown() takes an integer exponent. @powr() assumes the base to be non-negative.
-end:
-
-function: pown
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 base
-arg: int#1 exponent
-summary: Base raised to an integer exponent
-description:
- Returns base raised to the power exponent, i.e. base ^ exponent.
-
- @pow() and @powr() are similar.  The both take a float exponent. @powr() also assumes the base to be non-negative.
-end:
-
-function: powr
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 base, range(0,3000)
-arg: #2#1 exponent
-summary: Positive base raised to an exponent
-description:
- Returns base raised to the power exponent, i.e. base ^ exponent.  base must be &gt;= 0.
-
- @pow() and @pown() are similar.  They both make no assumptions about the base.  @pow() takes a float exponent while @pown() take an integer.
-
- See also @native_powr().
-end:
-
-function: radians
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Converts degrees into radians
-description:
- Converts from degrees to radians.
-end:
-
-function: remainder
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 numerator
-arg: #2#1 denominator
-summary: Remainder of a division
-description:
- Returns the remainder of (numerator / denominator), where the quotient is rounded towards the nearest integer.
-
- The function @fmod() is similar but rounds toward the closest interger.
- For example, <code>@fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
- while <code>remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
-end:
-
-function: remquo
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1, "The remainder, precise only for the low three bits."
-arg: #2#1 numerator, "The numerator."
-arg: #2#1 denominator, "The denominator."
-arg: int#1* quotient, "*quotient will be set to the integer quotient."
-summary: Remainder and quotient of a division
-description:
- Returns the quotient and the remainder of (numerator / denominator).
-
- Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
-
- This function is useful for implementing periodic functions.  The low three bits of the quotient gives the quadrant and the remainder the distance within the quadrant.  For example, an implementation of @sin(x) could call <code>remquo(x, PI / 2.f, &quadrant)</code> to reduce very large value of x to something within a limited range.
-
- Example: <code>remquo(-23.5f, 8.f, &quot)</code> sets the lowest three bits of quot to 3 and the sign negative.  It returns 0.5f.
-test: custom
-end:
-
-function: rint
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Round to even
-description:
- Rounds to the nearest integral value.
-
- rint() rounds half values to even.  For example, <code>rint(0.5f)</code> returns 0.f and <code>rint(1.5f)</code> returns 2.f.  Similarly, <code>rint(-0.5f)</code> returns -0.f and <code>rint(-1.5f)</code> returns -2.f.
-
- @round() is similar but rounds away from zero.  @trunc() truncates the decimal fraction.
-end:
-
-function: rootn
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-arg: int#1 n
-summary: Nth root
-description:
- Compute the Nth root of a value.
-
- See also @native_rootn().
-end:
-
-function: round
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Round away from zero
-description:
- Round to the nearest integral value.
-
- round() rounds half values away from zero.  For example, <code>round(0.5f)</code> returns 1.f and <code>round(1.5f)</code> returns 2.f.  Similarly, <code>round(-0.5f)</code> returns -1.f and <code>round(-1.5f)</code> returns -2.f.
-
- @rint() is similar but rounds half values toward even.  @trunc() truncates the decimal fraction.
-end:
-
-function: rsqrt
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Reciprocal of a square root
-description:
- Returns (1 / sqrt(v)).
-
- See also @half_rsqrt(), @native_rsqrt().
-end:
-
-function: sign
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Sign of a value
-description:
- Returns the sign of a value.
-
- if (v &lt; 0) return -1.f;
- else if (v &gt; 0) return 1.f;
- else return 0.f;
-end:
-
-function: sin
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Sine
-description:
- Returns the sine of an angle measured in radians.
-
- See also @native_sin().
-end:
-
-function: sincos
-version: 9
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1, "sine of v"
-arg: #2#1 v, "The incoming value in radians"
-arg: #2#1* cos, "*cos will be set to the cosine value."
-summary: Sine and cosine
-description:
- Returns the sine and cosine of a value.
-
- See also @native_sincos().
-end:
-
-function: sinh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Hyperbolic sine
-description:
- Returns the hyperbolic sine of v, where v is measured in radians.
-
- See also @native_sinh().
-end:
-
-function: sinpi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Sine of a number multiplied by pi
-description:
- Returns the sine of (v * pi), where (v * pi) is measured in radians.
-
- To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>.
-
- See also @native_sinpi().
-end:
-
-function: sqrt
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Square root
-description:
- Returns the square root of a value.
-
- See also @half_sqrt(), @native_sqrt().
-end:
-
-function: step
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 edge
-arg: #2#1 v
-summary: 0 if less than a value, 0 otherwise
-description:
- Returns 0.f if v &lt; edge, 1.f otherwise.
-
- This can be useful to create conditional computations without using loops and branching instructions.  For example, instead of computing <code>(a[i] &lt; b[i]) ? 0.f : @atan2(a[i], b[i])</code> for the corresponding elements of a vector, you could instead use <code>step(a, b) * @atan2(a, b)</code>.
-end:
-
-function: step
-version: 9
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 edge
-arg: #2 v
-end:
-
-function: step
-version: 21
-attrib: const
-w: 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2 edge
-arg: #2#1 v
-end:
-
-function: tan
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Tangent
-description:
- Returns the tangent of an angle measured in radians.
-
- See also @native_tan().
-end:
-
-function: tanh
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Hyperbolic tangent
-description:
- Returns the hyperbolic tangent of a value.
-
- See also @native_tanh().
-end:
-
-function: tanpi
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Tangent of a number multiplied by pi
-description:
- Returns the tangent of (v * pi), where (v * pi) is measured in radians.
-
- To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>.
-
- See also @native_tanpi().
-end:
-
-function: tgamma
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Gamma function
-description:
- Returns the gamma function of a value.
-
- See also @lgamma().
-end:
-
-function: trunc
-version: 9
-attrib: const
-w: 1, 2, 3, 4
-t: f32
-ret: #2#1
-arg: #2#1 v
-summary: Truncates a floating point
-description:
- Rounds to integral using truncation.
-
- For example, <code>trunc(1.7f)</code> returns 1.f and <code>trunc(-1.7f)</code> returns -1.f.
-
- See @rint() and @round() for other rounding options.
-end:
diff --git a/api/rs_for_each.spec b/api/rs_for_each.spec
new file mode 100644
index 0000000..a16da5f
--- /dev/null
+++ b/api/rs_for_each.spec
@@ -0,0 +1,346 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: TODO Add documentation
+description:
+ TODO Add documentation
+end:
+
+type: rs_for_each_strategy_t
+enum: rs_for_each_strategy
+value: RS_FOR_EACH_STRATEGY_SERIAL = 0
+value: RS_FOR_EACH_STRATEGY_DONT_CARE = 1
+value: RS_FOR_EACH_STRATEGY_DST_LINEAR = 2
+value: RS_FOR_EACH_STRATEGY_TILE_SMALL = 3
+value: RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4
+value: RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
+summary: Launch order hint for rsForEach calls
+description:
+ Launch order hint for rsForEach calls.  This provides a hint to the system to
+ determine in which order the root function of the target is called with each
+ cell of the allocation.
+
+ This is a hint and implementations may not obey the order.
+end:
+
+type: rs_kernel_context
+version: 23
+simple: const struct rs_kernel_context_t *
+summary: Opaque handle to RenderScript kernel invocation context
+description:
+ TODO
+end:
+
+type: rs_script_call_t
+struct: rs_script_call
+field: rs_for_each_strategy_t strategy
+field: uint32_t xStart
+field: uint32_t xEnd
+field: uint32_t yStart
+field: uint32_t yEnd
+field: uint32_t zStart
+field: uint32_t zEnd
+field: uint32_t arrayStart
+field: uint32_t arrayEnd
+summary: Provides extra information to a rsForEach call
+description:
+ Structure to provide extra information to a rsForEach call.  Primarly used to
+ restrict the call to a subset of cells in the allocation.
+end:
+
+function: rsForEach
+version: 9 13
+ret: void
+arg: rs_script script, "The target script to call"
+arg: rs_allocation input, "The allocation to source data from"
+arg: rs_allocation output, "the allocation to write date into"
+arg: const void* usrData, "The user defined params to pass to the root script.  May be NULL."
+arg: const rs_script_call_t* sc, "Extra control infomation used to select a sub-region of the allocation to be processed or suggest a walking strategy.  May be NULL."
+summary:
+description:
+ Make a script to script call to launch work. One of the input or output is
+ required to be a valid object. The input and output must be of the same
+ dimensions.
+test: none
+end:
+
+function: rsForEach
+version: 9 13
+ret: void
+arg: rs_script script
+arg: rs_allocation input
+arg: rs_allocation output
+arg: const void* usrData
+test: none
+end:
+
+function: rsForEach
+version: 14 20
+ret: void
+arg: rs_script script
+arg: rs_allocation input
+arg: rs_allocation output
+arg: const void* usrData
+arg: size_t usrDataLen, "The size of the userData structure.  This will be used to perform a shallow copy of the data if necessary."
+arg: const rs_script_call_t* sc
+test: none
+end:
+
+function: rsForEach
+version: 14 20
+ret: void
+arg: rs_script script
+arg: rs_allocation input
+arg: rs_allocation output
+arg: const void* usrData
+arg: size_t usrDataLen
+test: none
+end:
+
+function: rsForEach
+version: 14
+ret: void
+arg: rs_script script
+arg: rs_allocation input
+arg: rs_allocation output
+test: none
+end:
+
+function: rsGetArray0
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Index in the Array0 dimension for the specified context
+description:
+ Returns the index in the Array0 dimension of the cell being processed,
+ as specified by the supplied context.
+
+ This context is created when a kernel is launched and updated at each
+ iteration.  It contains common characteristics of the allocations being
+ iterated over and rarely used indexes, like the Array0 index.
+
+ You can access the context by adding a rs_kernel_context argument to your
+ kernel function.  E.g.<br/>
+ <code>short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {<br/>
+ &nbsp;&nbsp;// The current index in the common x, y, z, w dimensions are accessed by<br/>
+ &nbsp;&nbsp;// adding these variables as arguments.  For the more rarely used indexes<br/>
+ &nbsp;&nbsp;// to the other dimensions, extract them from the context:<br/>
+ &nbsp;&nbsp;uint32_t index_a0 = rsGetArray0(context);<br/>
+ &nbsp;&nbsp;//...<br/>
+ }<br/></code>
+
+ This function returns 0 if the Array0 dimension is not present.
+test: none
+end:
+
+function: rsGetArray1
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Index in the Array1 dimension for the specified context
+description:
+ Returns the index in the Array1 dimension of the cell being processed,
+ as specified by the supplied context.  See @rsGetArray0() for an explanation
+ of the context.
+
+ Returns 0 if the Array1 dimension is not present.
+test: none
+end:
+
+function: rsGetArray2
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Index in the Array2 dimension for the specified context
+description:
+ Returns the index in the Array2 dimension of the cell being processed,
+ as specified by the supplied context.  See @rsGetArray0() for an explanation
+ of the context.
+
+ Returns 0 if the Array2 dimension is not present.
+test: none
+end:
+
+function: rsGetArray3
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Index in the Array3 dimension for the specified context
+description:
+ Returns the index in the Array3 dimension of the cell being processed,
+ as specified by the supplied context.  See @rsGetArray0() for an explanation
+ of the context.
+
+ Returns 0 if the Array3 dimension is not present.
+test: none
+end:
+
+function: rsGetDimArray0
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Array0 dimension for the specified context
+description:
+ Returns the size of the Array0 dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Array0 dimension is not present.
+#TODO Add an hyperlink to something that explains Array0/1/2/3
+# for the relevant functions.
+test: none
+end:
+
+function: rsGetDimArray1
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Array1 dimension for the specified context
+description:
+ Returns the size of the Array1 dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Array1 dimension is not present.
+test: none
+end:
+
+function: rsGetDimArray2
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Array2 dimension for the specified context
+description:
+ Returns the size of the Array2 dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Array2 dimension is not present.
+test: none
+end:
+
+function: rsGetDimArray3
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Array3 dimension for the specified context
+description:
+ Returns the size of the Array3 dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Array3 dimension is not present.
+test: none
+end:
+
+function: rsGetDimHasFaces
+version: 23
+ret: bool, "Returns true if more than one face is present, false otherwise."
+arg: rs_kernel_context ctxt
+summary: Presence of more than one face for the specified context
+description:
+ If the context refers to a cubemap, this function returns true if there's
+ more than one face present.  In all other cases, it returns false.
+ See @rsGetDimX() for an explanation of the context.
+
+ @rsAllocationGetDimFaces() is similar but returns 0 or 1 instead of a bool.
+test: none
+end:
+
+function: rsGetDimLod
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Number of levels of detail for the specified context
+description:
+ Returns the number of levels of detail for the specified context.
+ This is useful for mipmaps.  See @rsGetDimX() for an explanation of the context.
+ Returns 0 if Level of Detail is not used.
+
+ @rsAllocationGetDimLOD() is similar but returns 0 or 1 instead the actual
+ number of levels.
+test: none
+end:
+
+function: rsGetDimX
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the X dimension for the specified context
+description:
+ Returns the size of the X dimension for the specified context.
+
+ This context is created when a kernel is launched.  It contains common
+ characteristics of the allocations being iterated over by the kernel in
+ a very efficient structure.  It also contains rarely used indexes.
+
+ You can access it by adding a rs_kernel_context argument to your kernel
+ function.  E.g.<br/>
+ <code>int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {<br/>
+ &nbsp;&nbsp;uint32_t size = rsGetDimX(context); //...<br/></code>
+test: none
+end:
+
+function: rsGetDimY
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Y dimension for the specified context
+description:
+ Returns the size of the X dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Y dimension is not present.
+test: none
+end:
+
+function: rsGetDimZ
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Size of the Z dimension for the specified context
+description:
+ Returns the size of the Z dimension for the specified context.
+ See @rsGetDimX() for an explanation of the context.
+
+ Returns 0 if the Z dimension is not present.
+test: none
+end:
+
+function: rsGetFace
+version: 23
+ret: rs_allocation_cubemap_face
+arg: rs_kernel_context ctxt
+summary: Coordinate of the Face for the specified context
+description:
+ Returns the face on which the cell being processed is found, as specified
+ by the supplied context.  See @rsGetArray0() for an explanation of the context.
+
+ Returns RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X if the face dimension is not
+ present.
+test: none
+end:
+
+function: rsGetLod
+version: 23
+ret: uint32_t
+arg: rs_kernel_context ctxt
+summary: Index in the Levels of Detail dimension for the specified context.
+description:
+ Returns the index in the Levels of Detail dimension of the cell being
+ processed, as specified by the supplied context.  See @rsGetArray0() for
+ an explanation of the context.
+
+ Returns 0 if the Levels of Detail dimension is not present.
+test: none
+end:
diff --git a/api/rs_graphics.spec b/api/rs_graphics.spec
index 37d421f..f90a4f4 100644
--- a/api/rs_graphics.spec
+++ b/api/rs_graphics.spec
@@ -17,15 +17,178 @@
 header:
 summary: RenderScript graphics API
 description:
+ NOTE: RenderScript Graphics has been deprecated.  Do not use.
+
  A set of graphics functions used by RenderScript.
 include:
  #ifdef __LP64__
  // TODO We need to fix some of the builds before enabling this error:
  // #error "RenderScript graphics is deprecated and not supported in 64bit mode."
- #else
- #include "rs_mesh.rsh"
- #include "rs_program.rsh"
  #endif
+
+ // TODO we seem to assume order for the other headers too.
+ #include "rs_object_types.rsh"
+end:
+
+type: rs_blend_src_func
+version: 16
+size: 32
+enum:
+value: RS_BLEND_SRC_ZERO                   = 0
+value: RS_BLEND_SRC_ONE                    = 1
+value: RS_BLEND_SRC_DST_COLOR              = 2
+value: RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3
+value: RS_BLEND_SRC_SRC_ALPHA              = 4
+value: RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5
+value: RS_BLEND_SRC_DST_ALPHA              = 6
+value: RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7
+value: RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8
+value: RS_BLEND_SRC_INVALID                = 100
+summary: Blend source function
+description:
+end:
+
+type: rs_blend_dst_func
+version: 16
+size: 32
+enum:
+value: RS_BLEND_DST_ZERO                   = 0
+value: RS_BLEND_DST_ONE                    = 1
+value: RS_BLEND_DST_SRC_COLOR              = 2
+value: RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3
+value: RS_BLEND_DST_SRC_ALPHA              = 4
+value: RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5
+value: RS_BLEND_DST_DST_ALPHA              = 6
+value: RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7
+value: RS_BLEND_DST_INVALID                = 100
+summary: Blend destination function
+description:
+end:
+
+type: rs_cull_mode
+version: 16
+size: 32
+enum:
+value: RS_CULL_BACK     = 0
+value: RS_CULL_FRONT    = 1
+value: RS_CULL_NONE     = 2
+value: RS_CULL_INVALID  = 100
+summary: Culling mode
+description:
+end:
+
+type: rs_depth_func
+version: 16
+size: 32
+enum:
+value: RS_DEPTH_FUNC_ALWAYS        = 0, "Always drawn"
+value: RS_DEPTH_FUNC_LESS          = 1, "Drawn if the incoming depth value is less than that in the depth buffer"
+value: RS_DEPTH_FUNC_LEQUAL        = 2, "Drawn if the incoming depth value is less or equal to that in the depth buffer"
+value: RS_DEPTH_FUNC_GREATER       = 3, "Drawn if the incoming depth value is greater than that in the depth buffer"
+value: RS_DEPTH_FUNC_GEQUAL        = 4, "Drawn if the incoming depth value is greater or equal to that in the depth buffer"
+value: RS_DEPTH_FUNC_EQUAL         = 5, "Drawn if the incoming depth value is equal to that in the depth buffer"
+value: RS_DEPTH_FUNC_NOTEQUAL      = 6, "Drawn if the incoming depth value is not equal to that in the depth buffer"
+value: RS_DEPTH_FUNC_INVALID       = 100, "Invalid depth function"
+summary: Depth function
+description:
+ Specifies conditional drawing depending on the comparison of the incoming
+ depth to that found in the depth buffer.
+end:
+
+type: rs_primitive
+version: 16
+size: 32
+enum:
+value: RS_PRIMITIVE_POINT = 0, "Vertex data will be rendered as a series of points"
+value: RS_PRIMITIVE_LINE = 1, "Vertex pairs will be rendered as lines"
+value: RS_PRIMITIVE_LINE_STRIP = 2, "Vertex data will be rendered as a connected line strip"
+value: RS_PRIMITIVE_TRIANGLE = 3, "Vertices will be rendered as individual triangles"
+value: RS_PRIMITIVE_TRIANGLE_STRIP = 4, "Vertices will be rendered as a connected triangle strip defined by the first three vertices with each additional triangle defined by a new vertex"
+value: RS_PRIMITIVE_TRIANGLE_FAN = 5, "Vertices will be rendered as a sequence of triangles that all share first vertex as the origin"
+value: RS_PRIMITIVE_INVALID = 100, "Invalid primitive"
+summary: How to intepret mesh vertex data
+description:
+ Describes the way mesh vertex data is interpreted when rendering
+end:
+
+type: rs_font
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a Font
+description:
+ Opaque handle to a RenderScript font object.
+ See: android.renderscript.Font
+end:
+
+
+type: rs_mesh
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a Mesh
+description:
+ Opaque handle to a RenderScript mesh object.
+ See: android.renderscript.Mesh
+end:
+
+type: rs_program_fragment
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a ProgramFragment
+description:
+ Opaque handle to a RenderScript ProgramFragment object.
+ See: android.renderscript.ProgramFragment
+end:
+
+type: rs_program_vertex
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a ProgramVertex
+description:
+ Opaque handle to a RenderScript ProgramVertex object.
+ See: android.renderscript.ProgramVertex
+end:
+
+type: rs_program_raster
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a ProgramRaster
+description:
+ Opaque handle to a RenderScript ProgramRaster object.
+ See: android.renderscript.ProgramRaster
+end:
+
+type: rs_program_store
+size: 32
+simple: _RS_HANDLE
+summary: Handle to a ProgramStore
+description:
+ Opaque handle to a RenderScript ProgramStore object.
+ See: android.renderscript.ProgramStore
+end:
+
+function: rsClearObject
+size: 32
+t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
+ret: void
+arg: #1* dst
+test: none
+end:
+
+function: rsIsObject
+size: 32
+t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
+ret: bool
+arg: #1 v
+test: none
+end:
+
+function: rsSetObject
+size: 32
+t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
+ret: void
+arg: #1* dst
+arg: #1 src
+test: none
 end:
 
 function: rsgAllocationSyncAll
@@ -471,6 +634,68 @@
 test: none
 end:
 
+function: rsgMeshGetIndexAllocation
+version: 16
+size: 32
+ret: rs_allocation, "allocation containing index data"
+arg: rs_mesh m, "mesh to get data from"
+arg: uint32_t index, "index of the index allocation"
+summary:
+description:
+ Returns an allocation containing index data or a null
+ allocation if only the primitive is specified
+test: none
+end:
+
+function: rsgMeshGetPrimitive
+version: 16
+size: 32
+ret: rs_primitive, "primitive describing how the mesh is rendered"
+arg: rs_mesh m, "mesh to get data from"
+arg: uint32_t index, "index of the primitive"
+summary:
+description:
+ Returns the primitive describing how a part of the mesh is
+ rendered
+test: none
+end:
+
+function: rsgMeshGetPrimitiveCount
+version: 16
+size: 32
+ret: uint32_t, "number of primitive groups in the mesh. This would include simple primitives as well as allocations containing index data"
+arg: rs_mesh m, "mesh to get data from"
+summary:
+description:
+ Meshes could have multiple index sets, this function returns
+ the number.
+test: none
+end:
+
+function: rsgMeshGetVertexAllocation
+version: 16
+size: 32
+ret: rs_allocation, "allocation containing vertex data"
+arg: rs_mesh m, "mesh to get data from"
+arg: uint32_t index, "index of the vertex allocation"
+summary:
+description:
+ Returns an allocation that is part of the mesh and contains
+ vertex data, e.g. positions, normals, texcoords
+test: none
+end:
+
+function: rsgMeshGetVertexAllocationCount
+version: 16
+size: 32
+ret: uint32_t, "number of allocations in the mesh that contain vertex data"
+arg: rs_mesh m, "mesh to get data from"
+summary:
+description:
+ Returns the number of allocations in the mesh that contain
+ vertex data
+test: none
+end:
 
 function: rsgProgramFragmentConstantColor
 size: 32
@@ -534,4 +759,123 @@
 test: none
 end:
 
-#endif //__LP64__
+function: rsgProgramRasterGetCullMode
+version: 16
+size: 32
+ret: rs_cull_mode
+arg: rs_program_raster pr, "program raster to query"
+summary:
+description:
+ Get program raster cull mode
+test: none
+end:
+
+function: rsgProgramRasterIsPointSpriteEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_raster pr, "program raster to query"
+summary:
+description:
+ Get program raster point sprite state
+test: none
+end:
+
+function: rsgProgramStoreGetBlendDstFunc
+version: 16
+size: 32
+ret: rs_blend_dst_func
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store blend destination function
+test: none
+end:
+
+function: rsgProgramStoreGetBlendSrcFunc
+version: 16
+size: 32
+ret: rs_blend_src_func
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store blend source function
+test: none
+end:
+
+function: rsgProgramStoreGetDepthFunc
+version: 16
+size: 32
+ret: rs_depth_func
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store depth function
+test: none
+end:
+
+function: rsgProgramStoreIsColorMaskAlphaEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store alpha component color mask
+test: none
+end:
+
+function: rsgProgramStoreIsColorMaskBlueEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store blur component color mask
+test: none
+end:
+
+function: rsgProgramStoreIsColorMaskGreenEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store green component color mask
+test: none
+end:
+
+function: rsgProgramStoreIsColorMaskRedEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store red component color mask
+test: none
+end:
+
+function: rsgProgramStoreIsDepthMaskEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store depth mask
+test: none
+end:
+
+function: rsgProgramStoreIsDitherEnabled
+version: 16
+size: 32
+ret: bool
+arg: rs_program_store ps, "program store to query"
+summary:
+description:
+ Get program store dither state
+test: none
+end:
diff --git a/api/rs_io.spec b/api/rs_io.spec
new file mode 100644
index 0000000..05722b7
--- /dev/null
+++ b/api/rs_io.spec
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: Input/output functions
+description:
+ TODO Add documentation
+end:
+
+function: rsAllocationIoReceive
+version: 16
+ret: void
+arg: rs_allocation a, "allocation to work on"
+summary: Receive new content from the queue
+description:
+ Receive a new set of contents from the queue.
+test: none
+end:
+
+function: rsAllocationIoSend
+version: 16
+ret: void
+arg: rs_allocation a, "allocation to work on"
+summary: Send new content to the queue
+description:
+ Send the contents of the Allocation to the queue.
+test: none
+end:
+
+function: rsSendToClient
+ret: bool
+arg: int cmdID
+summary:
+description:
+ Send a message back to the client.  Will not block and returns true
+ if the message was sendable and false if the fifo was full.
+ A message ID is required.  Data payload is optional.
+test: none
+end:
+
+function: rsSendToClient
+ret: bool
+arg: int cmdID
+arg: const void* data
+arg: uint len
+test: none
+end:
+
+function: rsSendToClientBlocking
+ret: void
+arg: int cmdID
+summary:
+description:
+ Send a message back to the client, blocking until the message is queued.
+ A message ID is required.  Data payload is optional.
+test: none
+end:
+
+function: rsSendToClientBlocking
+ret: void
+arg: int cmdID
+arg: const void* data
+arg: uint len
+test: none
+end:
diff --git a/api/rs_math.spec b/api/rs_math.spec
index af84461..01bc563 100644
--- a/api/rs_math.spec
+++ b/api/rs_math.spec
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2015 The Android Open Source Project
+# Copyright (C) 2014 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -15,9 +15,2146 @@
 #
 
 header:
-summary: TODO Add documentation
+summary: Mathematical functions
 description:
- TODO Add documentation
+ Most mathematical functions can be applied to scalars and vectors.
+ When applied to vectors, a vector of the function applied to each entry
+ of the input is returned.
+
+ For example:<br/>
+ <code>
+ float3 a, b;<br/>
+ // The following call sets<br/>
+ //   a.x to sin(b.x),<br/>
+ //   a.y to sin(b.y), and<br/>
+ //   a.z to sin(b.z).<br/>
+ a = sin(b);<br/>
+ </code>
+
+# TODO Adjust documentation
+ A few functions like @distance() and @length() interpret instead the input
+ as a single vector in n-dimensional space.
+
+ The precision of the mathematical operations is affected by the pragmas
+# TODO Create an anchor for the section of http://developer.android.com/guide/topics/renderscript/compute.html that details rs_fp_* and link them here.
+ rs_fp_relaxed and rs_fp_full.
+
+ Different precision/speed tradeoffs can be achieved by using three variants
+ of common math functions.  Functions with a name starting with<ul>
+ <li>native_ may have custom hardware implementations with weaker precision,</li>
+ <li>half_ may perform internal computations using 16 bit floats, and</li>
+ <li>fast_ are n-dimensional space computations that may use 16 bit floats.
+ </ul>
+end:
+
+constant: M_1_PI
+value: 0.318309886183790671537767526745028724f
+summary: 1 / pi, as a 32 bit float
+description:
+ The inverse of pi, as a 32 bit float.
+end:
+
+constant: M_2_PI
+value: 0.636619772367581343075535053490057448f
+summary: 2 / pi, as a 32 bit float
+description:
+ 2 divided by pi, as a 32 bit float.
+end:
+
+constant: M_2_PIl
+value: 0.636619772367581343075535053490057448f
+hidden:
+summary: Deprecated.  Use M_2_PI instead.
+description:
+end:
+
+constant: M_2_SQRTPI
+value: 1.128379167095512573896158903121545172f
+summary:  2 / sqrt(pi), as a 32 bit float
+description:
+ 2 divided by the square root of pi, as a 32 bit float.
+end:
+
+constant: M_E
+value: 2.718281828459045235360287471352662498f
+summary: e, as a 32 bit float
+description:
+ The number e, the base of the natural logarithm, as a 32 bit float.
+end:
+
+constant: M_LN10
+value: 2.302585092994045684017991454684364208f
+summary: log_e(10), as a 32 bit float
+description:
+ The natural logarithm of 10, as a 32 bit float.
+end:
+
+constant: M_LN2
+value: 0.693147180559945309417232121458176568f
+summary: log_e(2), as a 32 bit float
+description:
+ The natural logarithm of 2, as a 32 bit float.
+end:
+
+constant: M_LOG10E
+value: 0.434294481903251827651128918916605082f
+summary: log_10(e), as a 32 bit float
+description:
+ The logarithm base 10 of e, as a 32 bit float.
+end:
+
+constant: M_LOG2E
+value: 1.442695040888963407359924681001892137f
+summary: log_2(e), as a 32 bit float
+description:
+ The logarithm base 2 of e, as a 32 bit float.
+end:
+
+constant: M_PI
+value: 3.141592653589793238462643383279502884f
+summary: pi, as a 32 bit float
+description:
+ The constant pi, as a 32 bit float.
+end:
+
+constant: M_PI_2
+value: 1.570796326794896619231321691639751442f
+summary: pi / 2, as a 32 bit float
+description:
+ Pi divided by 2, as a 32 bit float.
+end:
+
+constant: M_PI_4
+value: 0.785398163397448309615660845819875721f
+summary: pi / 4, as a 32 bit float
+description:
+ Pi divided by 4, as a 32 bit float.
+end:
+
+constant: M_SQRT1_2
+value: 0.707106781186547524400844362104849039f
+summary: 1 / sqrt(2), as a 32 bit float
+description:
+ The inverse of the square root of 2, as a 32 bit float.
+end:
+
+constant: M_SQRT2
+value: 1.414213562373095048801688724209698079f
+summary: sqrt(2), as a 32 bit float
+description:
+ The square root of 2, as a 32 bit float.
+end:
+
+function: abs
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: i8, i16, i32
+ret: u#2#1
+arg: #2#1 v
+summary: Absolute value of an integer
+description:
+ Returns the absolute value of an integer.
+
+ For floats, use @fabs().
+end:
+
+function: acos
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse cosine
+description:
+ Returns the inverse cosine, in radians.
+
+ See also @native_acos().
+end:
+
+function: acosh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Inverse hyperbolic cosine
+description:
+ Returns the inverse hyperbolic cosine, in radians.
+
+ See also @native_acosh().
+end:
+
+function: acospi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse cosine divided by pi
+description:
+ Returns the inverse cosine in radians, divided by pi.
+
+ To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>.
+
+ See also @native_acospi().
+end:
+
+function: asin
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse sine
+description:
+ Returns the inverse sine, in radians.
+
+ See also @native_asin().
+end:
+
+function: asinh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Inverse hyperbolic sine
+description:
+ Returns the inverse hyperbolic sine, in radians.
+
+ See also @native_asinh().
+end:
+
+function: asinpi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse sine divided by pi
+description:
+ Returns the inverse sine in radians, divided by pi.
+
+ To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
+
+ See also @native_asinpi().
+end:
+
+function: atan
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse tangent
+description:
+ Returns the inverse tangent, in radians.
+
+ See also @native_atan().
+end:
+
+function: atan2
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator, "The numerator"
+arg: #2#1 denominator, "The denominator.  Can be 0."
+summary: Inverse tangent of a ratio
+description:
+ Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians.
+
+ See also @native_atan2().
+end:
+
+function: atan2pi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator, "The numerator"
+arg: #2#1 denominator, "The denominator.  Can be 0."
+summary: Inverse tangent of a ratio, divided by pi
+description:
+ Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi.
+
+ To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
+
+ See also @native_atan2pi().
+end:
+
+function: atanh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse hyperbolic tangent
+description:
+ Returns the inverse hyperbolic tangent, in radians.
+
+ See also @native_atanh().
+end:
+
+function: atanpi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Inverse tangent divided by pi
+description:
+ Returns the inverse tangent in radians, divided by pi.
+
+ To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
+
+ See also @native_atanpi().
+end:
+
+function: cbrt
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Cube root
+description:
+ Returns the cube root.
+
+ See also @native_cbrt().
+end:
+
+function: ceil
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Smallest integer not less than a value
+description:
+ Returns the smallest integer not less than a value.
+
+ For example, <code>ceil(1.2f)</code> returns 2.f, and <code>ceil(-1.2f)</code> returns -1.f.
+
+ See also @floor().
+end:
+
+function: clamp
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 value, "Value to be clamped."
+arg: #2#1 min_value, "Lower bound, a scalar or matching vector."
+arg: #2#1 max_value, above(min_value), "High bound, must match the type of low."
+summary: Restrain a value to a range
+description:
+ Clamps a value to a specified high and low bound.  clamp() returns min_value
+ if value &lt; min_value, max_value if value &gt; max_value, otherwise value.
+
+ There are two variants of clamp: one where the min and max are scalars applied
+ to all entries of the value, the other where the min and max are also vectors.
+
+ If min_value is greater than max_value, the results are undefined.
+end:
+
+function: clamp
+version: 9
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 value
+arg: #2 min_value
+arg: #2 max_value, above(min_value)
+end:
+
+function: clamp
+version: 19
+attrib: const
+w: 1, 2, 3, 4
+t: u8, u16, u32, u64, i8, i16, i32, i64
+ret: #2#1
+arg: #2#1 value
+arg: #2#1 min_value
+arg: #2#1 max_value, above(min_value)
+end:
+
+function: clamp
+version: 19
+attrib: const
+w: 2, 3, 4
+t: u8, u16, u32, u64, i8, i16, i32, i64
+ret: #2#1
+arg: #2#1 value
+arg: #2 min_value
+arg: #2 max_value, above(min_value)
+end:
+
+function: clz
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: u8, u16, u32, i8, i16, i32
+ret: #2#1
+arg: #2#1 value
+summary: Number of leading 0 bits
+description:
+ Returns the number of leading 0-bits in a value.
+
+ For example, <code>clz((char)0x03)</code> returns 6.
+end:
+
+function: copysign
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 magnitude_value
+arg: #2#1 sign_value
+summary: Copies the sign of a number to another
+description:
+ Copies the sign from sign_value to magnitude_value.
+
+ The value returned is either magnitude_value or -magnitude_value.
+
+ For example, <code>copysign(4.0f, -2.7f)</code> returns -4.0f and <code>copysign(-4.0f, 2.7f)</code> returns 4.0f.
+end:
+
+function: cos
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Cosine
+description:
+ Returns the cosine of an angle measured in radians.
+
+ See also @native_cos().
+end:
+
+function: cosh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Hypebolic cosine
+description:
+ Returns the hypebolic cosine of v, where v is measured in radians.
+
+ See also @native_cosh().
+end:
+
+function: cospi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Cosine of a number multiplied by pi
+description:
+ Returns the cosine of <code>(v * pi)</code>, where <code>(v * pi)</code> is measured in radians.
+
+ To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
+
+ See also @native_cospi().
+end:
+
+function: degrees
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Converts radians into degrees
+description:
+ Converts from radians to degrees.
+end:
+
+function: erf
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Mathematical error function
+description:
+ Returns the error function.
+end:
+
+function: erfc
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Mathematical complementary error function
+description:
+ Returns the complementary error function.
+end:
+
+function: exp
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: e raised to a number
+description:
+ Returns e raised to v, i.e. e ^ v.
+
+ See also @native_exp().
+end:
+
+function: exp10
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: 10 raised to a number
+description:
+ Returns 10 raised to v, i.e. 10.f ^ v.
+
+ See also @native_exp10().
+end:
+
+function: exp2
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: 2 raised to a number
+description:
+ Returns 2 raised to v, i.e. 2.f ^ v.
+
+ See also @native_exp2().
+end:
+
+function: expm1
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: e raised to a number minus one
+description:
+ Returns e raised to v minus 1, i.e. (e ^ v) - 1.
+
+ See also @native_expm1().
+end:
+
+function: fabs
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Absolute value of a float
+description:
+ Returns the absolute value of the float v.
+
+ For integers, use @abs().
+end:
+
+function: fdim
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Positive difference between two values
+description:
+ Returns the positive difference between two values.
+
+ If a &gt; b, returns (a - b) otherwise returns 0f.
+end:
+
+function: floor
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Smallest integer not greater than a value
+description:
+ Returns the smallest integer not greater than a value.
+
+ For example, <code>floor(1.2f)</code> returns 1.f, and <code>floor(-1.2f)</code> returns -2.f.
+
+ See also @ceil().
+end:
+
+function: fma
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 multiplicand1
+arg: #2#1 multiplicand2
+arg: #2#1 offset
+summary: Multiply and add
+description:
+ Multiply and add.  Returns <code>(multiplicand1 * multiplicand2) + offset</code>.
+
+ This function is similar to @mad().  fma() retains full precision of the
+ multiplied result and rounds only after the addition.  @mad() rounds after the
+ multiplication and the addition.  This extra precision is not guaranteed in
+ rs_fp_relaxed mode.
+end:
+
+function: fmax
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Maximum of two floats
+description:
+ Returns the maximum of a and b, i.e. <code>(a &lt; b ? b : a)</code>.
+
+ The @max() function returns identical results but can be applied to more data types.
+end:
+
+function: fmax
+version: 9
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2 b
+end:
+
+function: fmin
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Minimum of two floats
+description:
+ Returns the minimum of a and b, i.e. <code>(a &gt; b ? b : a)</code>.
+
+ The @min() function returns identical results but can be applied to more data types.
+end:
+
+function: fmin
+version: 9
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2 b
+end:
+
+function: fmod
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator
+arg: #2#1 denominator
+summary: Modulo
+description:
+ Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
+
+ The function @remainder() is similar but rounds toward the closest interger.
+ For example, <code>fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
+ while <code>@remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
+end:
+
+function: fract
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, "Input value."
+arg: #2#1* floor, "If floor is not null, *floor will be set to the floor of v."
+summary: Positive fractional part
+description:
+ Returns the positive fractional part of v, i.e. <code>v - floor(v)</code>.
+
+ For example, <code>fract(1.3f, &val)</code> returns 0.3f and sets val to 1.f.
+ <code>fract(-1.3f, &val)</code> returns 0.7f and sets val to -2.f.
+end:
+
+function: fract
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+inline:
+ #2#1 unused;
+ return fract(v, &unused);
+end:
+
+function: frexp
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, "Input value."
+arg: int#1* exponent, "If exponent is not null, *exponent will be set to the exponent of v."
+summary: Binary mantissa and exponent
+description:
+ Returns the binary mantissa and exponent of v, i.e. <code>v == mantissa * 2 ^ exponent</code>.
+
+ The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
+
+ See @ldexp() for the reverse operation.  See also @logb() and @ilogb().
+end:
+
+function: half_recip
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Reciprocal computed to 16 bit precision
+description:
+ Returns the approximate reciprocal of a value.
+
+ The precision is that of a 16 bit floating point value.
+
+ See also @native_recip().
+end:
+
+function: half_rsqrt
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Reciprocal of a square root computed to 16 bit precision
+description:
+ Returns the approximate value of <code>(1.f / sqrt(value))</code>.
+
+ The precision is that of a 16 bit floating point value.
+
+ See also @rsqrt(), @native_rsqrt().
+end:
+
+function: half_sqrt
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Square root computed to 16 bit precision
+description:
+ Returns the approximate square root of a value.
+
+ The precision is that of a 16 bit floating point value.
+
+ See also @sqrt(), @native_sqrt().
+end:
+
+function: hypot
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Hypotenuse
+description:
+ Returns the hypotenuse, i.e. <code>sqrt(a * a + b * b)</code>.
+
+ See also @native_hypot().
+end:
+
+function: ilogb
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: int#1
+arg: float#1 v
+summary: Base two exponent
+description:
+ Returns the base two exponent of a value, where the mantissa is between
+ 1.f (inclusive) and 2.f (exclusive).
+
+ For example, <code>ilogb(8.5f)</code> returns 3.
+
+ Because of the difference in mantissa, this number is one less than
+ is returned by @frexp().
+
+ @logb() is similar but returns a float.
+test: custom
+end:
+
+function: ldexp
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+ret: float#1
+arg: float#1 mantissa, "The mantissa"
+arg: int#1 exponent, "The exponent, a single component or matching vector."
+summary: Creates a floating point from mantissa and exponent
+description:
+ Returns the floating point created from the mantissa and exponent,
+ i.e. (mantissa * 2 ^ exponent).
+
+ See @frexp() for the reverse operation.
+end:
+
+function: ldexp
+version: 9
+attrib: const
+w: 2, 3, 4
+ret: float#1
+arg: float#1 mantissa
+arg: int exponent
+end:
+
+function: lgamma
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Natural logarithm of the gamma function
+description:
+ Returns the natural logarithm of the absolute value of the gamma function,
+ i.e. <code>@log(@fabs(@tgamma(v)))</code>.
+
+ See also @tgamma().
+end:
+
+function: lgamma
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+arg: int#1* sign_of_gamma, "If sign_of_gamma is not null, *sign_of_gamma will be set to -1.f if the gamma of v is negative, otherwise to 1.f."
+test: custom
+#TODO Temporary until bionic & associated drivers are fixed
+end:
+
+function: log
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Natural logarithm
+description:
+ Returns the natural logarithm.
+
+ See also @native_log().
+end:
+
+function: log10
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Base 10 logarithm
+description:
+ Returns the base 10 logarithm.
+
+ See also @native_log10().
+end:
+
+function: log1p
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Natural logarithm of a value plus 1
+description:
+ Returns the natural logarithm of <code>(v + 1.f)</code>.
+
+ See also @native_log1p().
+end:
+
+function: log2
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Base 2 logarithm
+description:
+ Returns the base 2 logarithm.
+
+ See also @native_log2().
+end:
+
+function: logb
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Base two exponent
+description:
+ Returns the base two exponent of a value, where the mantissa is between
+ 1.f (inclusive) and 2.f (exclusive).
+
+ For example, <code>logb(8.5f)</code> returns 3.f.
+
+ Because of the difference in mantissa, this number is one less than
+ is returned by frexp().
+
+ @ilogb() is similar but returns an integer.
+end:
+
+function: mad
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 multiplicand1
+arg: #2#1 multiplicand2
+arg: #2#1 offset
+summary: Multiply and add
+description:
+ Multiply and add.  Returns <code>(multiplicand1 * multiplicand2) + offset</code>.
+
+ This function is similar to @fma().  @fma() retains full precision of the
+ multiplied result and rounds only after the addition.  mad() rounds after the
+ multiplication and the addition.  In rs_fp_relaxed mode, mad() may not do the
+ rounding after multiplicaiton.
+end:
+
+function: max
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Maximum
+description:
+ Returns the maximum value of two arguments.
+end:
+
+function: max
+version: 9 20
+attrib: const
+w: 1
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ return (a > b ? a : b);
+end:
+
+function: max
+version: 9 20
+attrib: const
+w: 2
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x > b.x ? a.x : b.x);
+ tmp.y = (a.y > b.y ? a.y : b.y);
+ return tmp;
+end:
+
+function: max
+version: 9 20
+attrib: const
+w: 3
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x > b.x ? a.x : b.x);
+ tmp.y = (a.y > b.y ? a.y : b.y);
+ tmp.z = (a.z > b.z ? a.z : b.z);
+ return tmp;
+end:
+
+function: max
+version: 9 20
+attrib: const
+w: 4
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x > b.x ? a.x : b.x);
+ tmp.y = (a.y > b.y ? a.y : b.y);
+ tmp.z = (a.z > b.z ? a.z : b.z);
+ tmp.w = (a.w > b.w ? a.w : b.w);
+ return tmp;
+end:
+
+function: max
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: i8, i16, i32, i64, u8, u16, u32, u64
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+end:
+
+function: min
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Minimum
+description:
+ Returns the minimum value of two arguments.
+end:
+
+function: min
+version: 9 20
+attrib: const
+w: 1
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ return (a < b ? a : b);
+end:
+
+function: min
+version: 9 20
+attrib: const
+w: 2
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x < b.x ? a.x : b.x);
+ tmp.y = (a.y < b.y ? a.y : b.y);
+ return tmp;
+end:
+
+function: min
+version: 9 20
+attrib: const
+w: 3
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x < b.x ? a.x : b.x);
+ tmp.y = (a.y < b.y ? a.y : b.y);
+ tmp.z = (a.z < b.z ? a.z : b.z);
+ return tmp;
+end:
+
+function: min
+version: 9 20
+attrib: const
+w: 4
+t: i8, i16, i32, u8, u16, u32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+inline:
+ #2#1 tmp;
+ tmp.x = (a.x < b.x ? a.x : b.x);
+ tmp.y = (a.y < b.y ? a.y : b.y);
+ tmp.z = (a.z < b.z ? a.z : b.z);
+ tmp.w = (a.w < b.w ? a.w : b.w);
+ return tmp;
+end:
+
+function: min
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: i8, i16, i32, i64, u8, u16, u32, u64
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+end:
+
+function: mix
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 start
+arg: #2#1 stop
+arg: #2#1 fraction
+summary: Mixes two values
+description:
+ Returns start + ((stop - start) * fraction).
+
+ This can be useful for mixing two values.  For example, to create a new color that is 40% color1 and 60% color2, use <code>mix(color1, color2, 0.6f)</code>.
+end:
+
+function: mix
+version: 9
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 start
+arg: #2#1 stop
+arg: #2 fraction
+end:
+
+function: modf
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1, "The floating point portion of the value."
+arg: #2#1 v, "Source value"
+arg: #2#1* integral_part, "*integral_part will be set to the integral portion of the number."
+summary: Integral and fractional components
+description:
+ Returns the integral and fractional components of a number.
+
+ Both components will have the same sign as x.  For example, for an input of -3.72f, iret will be set to -3.f and .72f will be returned.
+end:
+
+function: nan
+version: 9
+attrib: const
+w: 1
+t: f32
+ret: #2#1
+arg: uint#1 v, "Not used."
+#TODO We're not using the argument.  Once we do, add this documentation line:
+# The argument is embedded into the return value and can be used to distinguish various NaNs.
+summary: Not a Number
+description:
+ Returns a NaN value (Not a Number).
+end:
+
+function: native_acos
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse cosine
+description:
+ Returns the approximate inverse cosine, in radians.
+
+ This function yields undefined results from input values less than -1 or greater
+ than 1.
+
+ See also @acos().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_acosh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate inverse hyperbolic cosine
+description:
+ Returns the approximate inverse hyperbolic cosine, in radians.
+
+ See also @acosh().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_acospi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse cosine divided by pi
+description:
+ Returns the approximate inverse cosine in radians, divided by pi.
+
+ To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>.
+
+ This function yields undefined results from input values less than -1 or greater
+ than 1.
+
+ See also @acospi().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_asin
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse sine
+description:
+ Returns the approximate inverse sine, in radians.
+
+ This function yields undefined results from input values less than -1 or greater
+ than 1.
+
+ See also @asin().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_asinh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate inverse hyperbolic sine
+description:
+ Returns the approximate inverse hyperbolic sine, in radians.
+
+ See also @asinh().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_asinpi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse sine divided by pi
+description:
+ Returns the approximate inverse sine in radians, divided by pi.
+
+ To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
+
+ This function yields undefined results from input values less than -1 or greater
+ than 1.
+
+ See also @asinpi().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_atan
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse tangent
+description:
+ Returns the approximate inverse tangent, in radians.
+
+ See also @atan().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_atan2
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator, "The numerator"
+arg: #2#1 denominator, "The denominator.  Can be 0."
+summary: Approximate inverse tangent of a ratio
+description:
+ Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians.
+
+ See also @atan2().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_atan2pi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator, "The numerator"
+arg: #2#1 denominator, "The denominator.  Can be 0."
+summary: Approximate inverse tangent of a ratio, divided by pi
+description:
+ Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi.
+
+ To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
+
+ See also @atan2pi().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_atanh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse hyperbolic tangent
+description:
+ Returns the approximate inverse hyperbolic tangent, in radians.
+
+ See also @atanh().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_atanpi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-1,1)
+summary: Approximate inverse tangent divided by pi
+description:
+ Returns the approximate inverse tangent in radians, divided by pi.
+
+ To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
+
+ See also @atanpi().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_cbrt
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate cube root
+description:
+ Returns the approximate cubic root.
+
+ See also @cbrt().
+end:
+
+function: native_cos
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate cosine
+description:
+ Returns the approximate cosine of an angle measured in radians.
+
+ See also @cos().
+end:
+
+function: native_cosh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate hypebolic cosine
+description:
+ Returns the approximate hypebolic cosine.
+
+ See also @cosh().
+end:
+
+function: native_cospi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate cosine of a number multiplied by pi
+description:
+ Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
+
+ To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
+
+ See also @cospi().
+end:
+
+function: native_divide
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Approximate division
+description:
+ Computes the approximate division of two values.
+end:
+
+function: native_exp
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-86,86)
+summary: Approximate e raised to a number
+description:
+ Fast approximate exp.
+
+ It is valid for inputs from -86.f to 86.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+
+ See also @exp().
+test: limited
+end:
+
+function: native_exp10
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-37,37)
+summary: Approximate 10 raised to a number
+description:
+ Fast approximate exp10.
+
+ It is valid for inputs from -37.f to 37.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+
+ See also @exp10().
+test: limited
+end:
+
+function: native_exp2
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(-125,125)
+summary: Approximate 2 raised to a number
+description:
+ Fast approximate exp2.
+
+ It is valid for inputs from -125.f to 125.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+
+ See also @exp2().
+test: limited
+end:
+
+function: native_expm1
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate e raised to a number minus one
+description:
+ Returns the approximate (e ^ v) - 1.
+
+ See also @expm1().
+end:
+
+function: native_hypot
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+summary: Approximate hypotenuse
+description:
+ Returns the approximate native_sqrt(a * a + b * b)
+
+ See also @hypot().
+end:
+
+function: native_log
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(10e-10,10e10)
+summary: Approximate natural logarithm
+description:
+ Fast approximate log.
+
+ It is not accurate for values very close to zero.
+
+ See also @log().
+test: limited
+end:
+
+function: native_log10
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(10e-10,10e10)
+summary: Approximate base 10 logarithm
+description:
+ Fast approximate log10.
+
+ It is not accurate for values very close to zero.
+
+ See also @log10().
+test: limited
+end:
+
+function: native_log1p
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate natural logarithm of a value plus 1
+description:
+ Returns the approximate natural logarithm of (v + 1.0f)
+
+ See also @log1p().
+end:
+
+function: native_log2
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v, range(10e-10,10e10)
+summary: Approximate base 2 logarithm
+description:
+ Fast approximate log2.
+
+ It is not accurate for values very close to zero.
+
+ See also @log2().
+test: limited
+end:
+
+function: native_powr
+version: 18
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 base, range(0,256), "Must be between 0.f and 256.f.  The function is not accurate for values very close to zero."
+arg: #2#1 exponent, range(-15,15), "Must be between -15.f and 15.f."
+summary: Approximate positive base raised to an exponent
+description:
+ Fast approximate (base ^ exponent).
+
+ See also @powr().
+test: limited
+end:
+
+function: native_recip
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate reciprocal
+description:
+ Returns the approximate approximate reciprocal of a value.
+
+ See also @half_recip().
+end:
+
+function: native_rootn
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+arg: int#1 n
+summary: Approximate nth root
+description:
+ Compute the approximate Nth root of a value.
+
+ See also @rootn().
+end:
+
+function: native_rsqrt
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate reciprocal of a square root
+description:
+ Returns approximate (1 / sqrt(v)).
+
+ See also @rsqrt(), @half_rsqrt().
+end:
+
+function: native_sin
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate sine
+description:
+ Returns the approximate sine of an angle measured in radians.
+
+ See also @sin().
+end:
+
+function: native_sincos
+version: 21
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1, "sine"
+arg: #2#1 v, "The incoming value in radians."
+arg: #2#1* cos, "*cos will be set to the cosine value."
+summary: Approximate sine and cosine
+description:
+ Returns the approximate sine and cosine of a value.
+
+ See also @sincos().
+# TODO Temporary
+test: limited(0.0005)
+end:
+
+function: native_sinh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate hyperbolic sine
+description:
+ Returns the approximate hyperbolic sine of a value specified in radians.
+
+ See also @sinh().
+end:
+
+function: native_sinpi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate sine of a number multiplied by pi
+description:
+ Returns the approximate sine of (v * pi), where (v * pi) is measured in radians.
+
+ To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>.
+
+ See also @sinpi().
+end:
+
+function: native_sqrt
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate square root
+description:
+ Returns the approximate sqrt(v).
+
+ See also @sqrt(), @half_sqrt().
+end:
+
+function: native_tan
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate tangent
+description:
+ Returns the approximate tangent of an angle measured in radians.
+end:
+
+function: native_tanh
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate hyperbolic tangent
+description:
+ Returns the approximate hyperbolic tangent of a value.
+
+ See also @tanh().
+end:
+
+function: native_tanpi
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate tangent of a number multiplied by pi
+description:
+ Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians.
+
+ To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>.
+
+ See also @tanpi().
+end:
+
+function: nextafter
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+arg: #2#1 target
+summary: Next floating point number
+description:
+ Returns the next representable floating point number from v towards target.
+
+ In rs_fp_relaxed mode, a denormalized input value may not yield the next
+ denormalized  value, as support of denormalized values is optional in
+ relaxed mode.
+end:
+
+function: pow
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 base
+arg: #2#1 exponent
+summary: Base raised to an exponent
+description:
+ Returns base raised to the power exponent, i.e. base ^ exponent.
+
+ @pown() and @powr() are similar.  @pown() takes an integer exponent. @powr() assumes the base to be non-negative.
+end:
+
+function: pown
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 base
+arg: int#1 exponent
+summary: Base raised to an integer exponent
+description:
+ Returns base raised to the power exponent, i.e. base ^ exponent.
+
+ @pow() and @powr() are similar.  The both take a float exponent. @powr() also assumes the base to be non-negative.
+end:
+
+function: powr
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 base, range(0,3000)
+arg: #2#1 exponent
+summary: Positive base raised to an exponent
+description:
+ Returns base raised to the power exponent, i.e. base ^ exponent.  base must be &gt;= 0.
+
+ @pow() and @pown() are similar.  They both make no assumptions about the base.  @pow() takes a float exponent while @pown() take an integer.
+
+ See also @native_powr().
+end:
+
+function: radians
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Converts degrees into radians
+description:
+ Converts from degrees to radians.
+end:
+
+function: remainder
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 numerator
+arg: #2#1 denominator
+summary: Remainder of a division
+description:
+ Returns the remainder of (numerator / denominator), where the quotient is rounded towards the nearest integer.
+
+ The function @fmod() is similar but rounds toward the closest interger.
+ For example, <code>@fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
+ while <code>remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
+end:
+
+function: remquo
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1, "The remainder, precise only for the low three bits."
+arg: #2#1 numerator, "The numerator."
+arg: #2#1 denominator, "The denominator."
+arg: int#1* quotient, "*quotient will be set to the integer quotient."
+summary: Remainder and quotient of a division
+description:
+ Returns the quotient and the remainder of (numerator / denominator).
+
+ Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
+
+ This function is useful for implementing periodic functions.  The low three bits of the quotient gives the quadrant and the remainder the distance within the quadrant.  For example, an implementation of @sin(x) could call <code>remquo(x, PI / 2.f, &quadrant)</code> to reduce very large value of x to something within a limited range.
+
+ Example: <code>remquo(-23.5f, 8.f, &quot)</code> sets the lowest three bits of quot to 3 and the sign negative.  It returns 0.5f.
+test: custom
+end:
+
+function: rint
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Round to even
+description:
+ Rounds to the nearest integral value.
+
+ rint() rounds half values to even.  For example, <code>rint(0.5f)</code> returns 0.f and <code>rint(1.5f)</code> returns 2.f.  Similarly, <code>rint(-0.5f)</code> returns -0.f and <code>rint(-1.5f)</code> returns -2.f.
+
+ @round() is similar but rounds away from zero.  @trunc() truncates the decimal fraction.
+end:
+
+function: rootn
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+arg: int#1 n
+summary: Nth root
+description:
+ Compute the Nth root of a value.
+
+ See also @native_rootn().
+end:
+
+function: round
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Round away from zero
+description:
+ Round to the nearest integral value.
+
+ round() rounds half values away from zero.  For example, <code>round(0.5f)</code> returns 1.f and <code>round(1.5f)</code> returns 2.f.  Similarly, <code>round(-0.5f)</code> returns -1.f and <code>round(-1.5f)</code> returns -2.f.
+
+ @rint() is similar but rounds half values toward even.  @trunc() truncates the decimal fraction.
+end:
+
+function: rsqrt
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Reciprocal of a square root
+description:
+ Returns (1 / sqrt(v)).
+
+ See also @half_rsqrt(), @native_rsqrt().
+end:
+
+function: sign
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Sign of a value
+description:
+ Returns the sign of a value.
+
+ if (v &lt; 0) return -1.f;
+ else if (v &gt; 0) return 1.f;
+ else return 0.f;
+end:
+
+function: sin
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Sine
+description:
+ Returns the sine of an angle measured in radians.
+
+ See also @native_sin().
+end:
+
+function: sincos
+version: 9
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1, "sine of v"
+arg: #2#1 v, "The incoming value in radians"
+arg: #2#1* cos, "*cos will be set to the cosine value."
+summary: Sine and cosine
+description:
+ Returns the sine and cosine of a value.
+
+ See also @native_sincos().
+end:
+
+function: sinh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Hyperbolic sine
+description:
+ Returns the hyperbolic sine of v, where v is measured in radians.
+
+ See also @native_sinh().
+end:
+
+function: sinpi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Sine of a number multiplied by pi
+description:
+ Returns the sine of (v * pi), where (v * pi) is measured in radians.
+
+ To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>.
+
+ See also @native_sinpi().
+end:
+
+function: sqrt
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Square root
+description:
+ Returns the square root of a value.
+
+ See also @half_sqrt(), @native_sqrt().
+end:
+
+function: step
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 edge
+arg: #2#1 v
+summary: 0 if less than a value, 0 otherwise
+description:
+ Returns 0.f if v &lt; edge, 1.f otherwise.
+
+ This can be useful to create conditional computations without using loops and branching instructions.  For example, instead of computing <code>(a[i] &lt; b[i]) ? 0.f : @atan2(a[i], b[i])</code> for the corresponding elements of a vector, you could instead use <code>step(a, b) * @atan2(a, b)</code>.
+end:
+
+function: step
+version: 9
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 edge
+arg: #2 v
+end:
+
+function: step
+version: 21
+attrib: const
+w: 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2 edge
+arg: #2#1 v
+end:
+
+function: tan
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Tangent
+description:
+ Returns the tangent of an angle measured in radians.
+
+ See also @native_tan().
+end:
+
+function: tanh
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Hyperbolic tangent
+description:
+ Returns the hyperbolic tangent of a value.
+
+ See also @native_tanh().
+end:
+
+function: tanpi
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Tangent of a number multiplied by pi
+description:
+ Returns the tangent of (v * pi), where (v * pi) is measured in radians.
+
+ To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>.
+
+ See also @native_tanpi().
+end:
+
+function: tgamma
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Gamma function
+description:
+ Returns the gamma function of a value.
+
+ See also @lgamma().
+end:
+
+function: trunc
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Truncates a floating point
+description:
+ Rounds to integral using truncation.
+
+ For example, <code>trunc(1.7f)</code> returns 1.f and <code>trunc(-1.7f)</code> returns -1.f.
+
+ See @rint() and @round() for other rounding options.
 end:
 
 function: rsClamp
@@ -36,67 +2173,6 @@
 test: none
 end:
 
-function: rsExtractFrustumPlanes
-# TODO Why always_inline?
-attrib: always_inline
-ret: void
-arg: const rs_matrix4x4* viewProj, "matrix to extract planes from"
-arg: float4* left, "left plane"
-arg: float4* right, "right plane"
-arg: float4* top, "top plane"
-arg: float4* bottom, "bottom plane"
-arg: float4* near, "near plane"
-arg: float4* far, "far plane"
-summary:
-description:
- Computes 6 frustum planes from the view projection matrix
-inline:
- // x y z w = a b c d in the plane equation
- left->x = viewProj->m[3] + viewProj->m[0];
- left->y = viewProj->m[7] + viewProj->m[4];
- left->z = viewProj->m[11] + viewProj->m[8];
- left->w = viewProj->m[15] + viewProj->m[12];
-
- right->x = viewProj->m[3] - viewProj->m[0];
- right->y = viewProj->m[7] - viewProj->m[4];
- right->z = viewProj->m[11] - viewProj->m[8];
- right->w = viewProj->m[15] - viewProj->m[12];
-
- top->x = viewProj->m[3] - viewProj->m[1];
- top->y = viewProj->m[7] - viewProj->m[5];
- top->z = viewProj->m[11] - viewProj->m[9];
- top->w = viewProj->m[15] - viewProj->m[13];
-
- bottom->x = viewProj->m[3] + viewProj->m[1];
- bottom->y = viewProj->m[7] + viewProj->m[5];
- bottom->z = viewProj->m[11] + viewProj->m[9];
- bottom->w = viewProj->m[15] + viewProj->m[13];
-
- near->x = viewProj->m[3] + viewProj->m[2];
- near->y = viewProj->m[7] + viewProj->m[6];
- near->z = viewProj->m[11] + viewProj->m[10];
- near->w = viewProj->m[15] + viewProj->m[14];
-
- far->x = viewProj->m[3] - viewProj->m[2];
- far->y = viewProj->m[7] - viewProj->m[6];
- far->z = viewProj->m[11] - viewProj->m[10];
- far->w = viewProj->m[15] - viewProj->m[14];
-
- float len = length(left->xyz);
- *left /= len;
- len = length(right->xyz);
- *right /= len;
- len = length(top->xyz);
- *top /= len;
- len = length(bottom->xyz);
- *bottom /= len;
- len = length(near->xyz);
- *near /= len;
- len = length(far->xyz);
- *far /= len;
-test: none
-end:
-
 function: rsFrac
 attrib: const
 ret: float
@@ -107,87 +2183,6 @@
 test: none
 end:
 
-function: rsIsSphereInFrustum
-attrib: always_inline
-ret: bool
-arg: float4* sphere, "float4 representing the sphere"
-arg: float4* left, "left plane"
-arg: float4* right, "right plane"
-arg: float4* top, "top plane"
-arg: float4* bottom, "bottom plane"
-arg: float4* near, "near plane"
-arg: float4* far, "far plane"
-summary:
-description:
- Checks if a sphere is withing the 6 frustum planes
-inline:
- float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- distToCenter = dot(right->xyz, sphere->xyz) + right->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- distToCenter = dot(top->xyz, sphere->xyz) + top->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- distToCenter = dot(near->xyz, sphere->xyz) + near->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- distToCenter = dot(far->xyz, sphere->xyz) + far->w;
- if (distToCenter < -sphere->w) {
-     return false;
- }
- return true;
-test: none
-end:
-
-function: rsPackColorTo8888
-attrib: const
-ret: uchar4
-arg: float r
-arg: float g
-arg: float b
-summary:
-description:
- Pack floating point (0-1) RGB values into a uchar4.
-
- For the float3 variant and the variant that only specifies r, g, b,
- the alpha component is set to 255 (1.0).
-test: none
-end:
-
-function: rsPackColorTo8888
-attrib: const
-ret: uchar4
-arg: float r
-arg: float g
-arg: float b
-arg: float a
-test: none
-end:
-
-function: rsPackColorTo8888
-attrib: const
-ret: uchar4
-arg: float3 color
-test: none
-end:
-
-function: rsPackColorTo8888
-attrib: const
-ret: uchar4
-arg: float4 color
-test: none
-end:
-
 function: rsRand
 ret: int
 arg: int max_value
@@ -216,27 +2211,3 @@
 arg: float max_value
 test: none
 end:
-
-function: rsUnpackColor8888
-attrib: =const
-ret: float4
-arg: uchar4 c
-summary:
-description:
- Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
-test: none
-end:
-
-function: rsYuvToRGBA_#2#1
-attrib: const
-w: 4
-t: u8, f32
-ret: #2#1
-arg: uchar y
-arg: uchar u
-arg: uchar v
-summary:
-description:
- Convert from YUV to RGBA.
-test: none
-end:
diff --git a/api/rs_matrix.spec b/api/rs_matrix.spec
index 7afbeff..d69ad1a 100644
--- a/api/rs_matrix.spec
+++ b/api/rs_matrix.spec
@@ -41,6 +41,111 @@
  transformation happens first.  E.g. if you call @rsMatrixTranslate()
  on a matrix that already does a scaling, the resulting matrix when applied
  to a vector will first do the translation then the scaling.
+include:
+ #include "rs_vector_math.rsh"
+end:
+
+function: rsExtractFrustumPlanes
+# TODO Why always_inline?
+attrib: always_inline
+ret: void
+arg: const rs_matrix4x4* viewProj, "matrix to extract planes from"
+arg: float4* left, "left plane"
+arg: float4* right, "right plane"
+arg: float4* top, "top plane"
+arg: float4* bottom, "bottom plane"
+arg: float4* near, "near plane"
+arg: float4* far, "far plane"
+summary:
+description:
+ Computes 6 frustum planes from the view projection matrix
+inline:
+ // x y z w = a b c d in the plane equation
+ left->x = viewProj->m[3] + viewProj->m[0];
+ left->y = viewProj->m[7] + viewProj->m[4];
+ left->z = viewProj->m[11] + viewProj->m[8];
+ left->w = viewProj->m[15] + viewProj->m[12];
+
+ right->x = viewProj->m[3] - viewProj->m[0];
+ right->y = viewProj->m[7] - viewProj->m[4];
+ right->z = viewProj->m[11] - viewProj->m[8];
+ right->w = viewProj->m[15] - viewProj->m[12];
+
+ top->x = viewProj->m[3] - viewProj->m[1];
+ top->y = viewProj->m[7] - viewProj->m[5];
+ top->z = viewProj->m[11] - viewProj->m[9];
+ top->w = viewProj->m[15] - viewProj->m[13];
+
+ bottom->x = viewProj->m[3] + viewProj->m[1];
+ bottom->y = viewProj->m[7] + viewProj->m[5];
+ bottom->z = viewProj->m[11] + viewProj->m[9];
+ bottom->w = viewProj->m[15] + viewProj->m[13];
+
+ near->x = viewProj->m[3] + viewProj->m[2];
+ near->y = viewProj->m[7] + viewProj->m[6];
+ near->z = viewProj->m[11] + viewProj->m[10];
+ near->w = viewProj->m[15] + viewProj->m[14];
+
+ far->x = viewProj->m[3] - viewProj->m[2];
+ far->y = viewProj->m[7] - viewProj->m[6];
+ far->z = viewProj->m[11] - viewProj->m[10];
+ far->w = viewProj->m[15] - viewProj->m[14];
+
+ float len = length(left->xyz);
+ *left /= len;
+ len = length(right->xyz);
+ *right /= len;
+ len = length(top->xyz);
+ *top /= len;
+ len = length(bottom->xyz);
+ *bottom /= len;
+ len = length(near->xyz);
+ *near /= len;
+ len = length(far->xyz);
+ *far /= len;
+test: none
+end:
+
+function: rsIsSphereInFrustum
+attrib: always_inline
+ret: bool
+arg: float4* sphere, "float4 representing the sphere"
+arg: float4* left, "left plane"
+arg: float4* right, "right plane"
+arg: float4* top, "top plane"
+arg: float4* bottom, "bottom plane"
+arg: float4* near, "near plane"
+arg: float4* far, "far plane"
+summary:
+description:
+ Checks if a sphere is withing the 6 frustum planes
+inline:
+ float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ distToCenter = dot(right->xyz, sphere->xyz) + right->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ distToCenter = dot(top->xyz, sphere->xyz) + top->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ distToCenter = dot(near->xyz, sphere->xyz) + near->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ distToCenter = dot(far->xyz, sphere->xyz) + far->w;
+ if (distToCenter < -sphere->w) {
+     return false;
+ }
+ return true;
+test: none
 end:
 
 function: rsMatrixGet
diff --git a/api/rs_mesh.spec b/api/rs_mesh.spec
deleted file mode 100644
index 9fe5e49..0000000
--- a/api/rs_mesh.spec
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Mesh routines
-description:
-end:
-
-function: rsgMeshGetIndexAllocation
-version: 16
-ret: rs_allocation, "allocation containing index data"
-arg: rs_mesh m, "mesh to get data from"
-arg: uint32_t index, "index of the index allocation"
-summary:
-description:
- Returns an allocation containing index data or a null
- allocation if only the primitive is specified
-test: none
-end:
-
-function: rsgMeshGetPrimitive
-version: 16
-ret: rs_primitive, "primitive describing how the mesh is rendered"
-arg: rs_mesh m, "mesh to get data from"
-arg: uint32_t index, "index of the primitive"
-summary:
-description:
- Returns the primitive describing how a part of the mesh is
- rendered
-test: none
-end:
-
-function: rsgMeshGetPrimitiveCount
-version: 16
-ret: uint32_t, "number of primitive groups in the mesh. This would include simple primitives as well as allocations containing index data"
-arg: rs_mesh m, "mesh to get data from"
-summary:
-description:
- Meshes could have multiple index sets, this function returns
- the number.
-test: none
-end:
-
-function: rsgMeshGetVertexAllocation
-version: 16
-ret: rs_allocation, "allocation containing vertex data"
-arg: rs_mesh m, "mesh to get data from"
-arg: uint32_t index, "index of the vertex allocation"
-summary:
-description:
- Returns an allocation that is part of the mesh and contains
- vertex data, e.g. positions, normals, texcoords
-test: none
-end:
-
-function: rsgMeshGetVertexAllocationCount
-version: 16
-ret: uint32_t, "number of allocations in the mesh that contain vertex data"
-arg: rs_mesh m, "mesh to get data from"
-summary:
-description:
- Returns the number of allocations in the mesh that contain
- vertex data
-test: none
-end:
diff --git a/api/rs_object.spec b/api/rs_object.spec
deleted file mode 100644
index bb8b446..0000000
--- a/api/rs_object.spec
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Object routines
-description:
-end:
-
-function: rsClearObject
-t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
-ret: void
-arg: #1* dst
-hidden:
-summary: For internal use.
-description:
-test: none
-end:
-
-function: rsClearObject
-size: 32
-t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
-ret: void
-arg: #1* dst
-test: none
-end:
-
-function: rsIsObject
-t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
-ret: bool
-arg: #1 v
-hidden:
-summary: For internal use.
-description:
-test: none
-end:
-
-function: rsIsObject
-size: 32
-t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
-ret: bool
-arg: #1 v
-test: none
-end:
-
-function: rsSetObject
-t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
-ret: void
-arg: #1* dst
-arg: #1 src
-hidden:
-summary: For internal use.
-description:
-test: none
-end:
-
-function: rsSetObject
-size: 32
-t: rs_mesh, rs_program_fragment, rs_program_vertex, rs_program_raster, rs_program_store, rs_font
-ret: void
-arg: #1* dst
-arg: #1 src
-test: none
-end:
diff --git a/api/rs_element.spec b/api/rs_object_info.spec
similarity index 61%
rename from api/rs_element.spec
rename to api/rs_object_info.spec
index 76abd96..de700ac 100644
--- a/api/rs_element.spec
+++ b/api/rs_object_info.spec
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2015 The Android Open Source Project
+# Copyright (C) 2014 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -38,6 +38,83 @@
  interpret pixel data.
 end:
 
+function: rsAllocationGetDimFaces
+ret: uint32_t, "Returns 1 if more than one face is present, 0 otherwise."
+arg: rs_allocation a
+summary: Presence of more than one face
+description:
+ If the allocation is a cubemap, this function returns 1 if there's more than one
+ face present.  In all other cases, it returns 0.
+test: none
+end:
+
+function: rsAllocationGetDimLOD
+ret: uint32_t, "Returns 1 if more than one LOD is present, 0 otherwise."
+arg: rs_allocation a
+summary: Presence of levels of details
+description:
+ Query an allocation for the presence of more than one Level Of Details.  This is useful for mipmaps.
+test: none
+end:
+
+function: rsAllocationGetDimX
+ret: uint32_t, "The X dimension of the allocation."
+arg: rs_allocation a
+summary: Size of the X dimension
+description:
+ Returns the size of the X dimension of the allocation.
+test: none
+end:
+
+function: rsAllocationGetDimY
+ret: uint32_t, "The Y dimension of the allocation."
+arg: rs_allocation a
+summary: Size of the Y dimension
+description:
+ Returns the size of the Y dimension of the allocation.
+ If the allocation has less than two dimensions, returns 0.
+test: none
+end:
+
+function: rsAllocationGetDimZ
+ret: uint32_t, "The Z dimension of the allocation."
+arg: rs_allocation a
+summary: Size of the Z dimension
+description:
+ Returns the size of the Z dimension of the allocation.
+ If the allocation has less than three dimensions, returns 0.
+test: none
+end:
+
+function: rsAllocationGetElement
+ret: rs_element, "element describing allocation layout"
+arg: rs_allocation a, "allocation to get data from"
+summary:
+description:
+ Get the element object describing the allocation's layout
+test: none
+end:
+
+function: rsClearObject
+t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
+ret: void
+arg: #1* dst
+hidden:
+summary: For internal use.
+description:
+test: none
+end:
+
+function: rsIsObject
+t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
+ret: bool
+arg: #1 v
+hidden:
+summary: For internal use.
+description:
+test: none
+end:
+
 function: rsElementGetBytesSize
 version: 16
 ret: uint32_t
@@ -166,3 +243,78 @@
  Returns the element's vector size
 test: none
 end:
+
+function: rsGetAllocation
+ret: rs_allocation
+arg: const void* p
+summary: Returns the Allocation for a given pointer
+description:
+ Returns the Allocation for a given pointer.  The pointer should point within
+ a valid allocation.  The results are undefined if the pointer is not from a
+ valid allocation.
+
+ This function is deprecated and will be removed from the SDK in a future
+ release.
+test: none
+end:
+
+function: rsSamplerGetAnisotropy
+version: 16
+ret: float, "anisotropy"
+arg: rs_sampler s, "sampler to query"
+summary:
+description:
+  Get sampler anisotropy
+test: none
+end:
+
+function: rsSamplerGetMagnification
+version: 16
+ret: rs_sampler_value, "magnification value"
+arg: rs_sampler s, "sampler to query"
+summary:
+description:
+ Get sampler magnification value
+test: none
+end:
+
+function: rsSamplerGetMinification
+version: 16
+ret: rs_sampler_value, "minification value"
+arg: rs_sampler s, "sampler to query"
+summary:
+description:
+ Get sampler minification value
+test: none
+end:
+
+function: rsSamplerGetWrapS
+version: 16
+ret: rs_sampler_value, "wrap S value"
+arg: rs_sampler s, "sampler to query"
+summary:
+description:
+ Get sampler wrap S value
+test: none
+end:
+
+function: rsSamplerGetWrapT
+version: 16
+ret: rs_sampler_value, "wrap T value"
+arg: rs_sampler s, "sampler to query"
+summary:
+description:
+ Get sampler wrap T value
+test: none
+end:
+
+function: rsSetObject
+t: rs_element, rs_type, rs_allocation, rs_sampler, rs_script
+ret: void
+arg: #1* dst
+arg: #1 src
+hidden:
+summary: For internal use.
+description:
+test: none
+end:
diff --git a/api/rs_object_types.spec b/api/rs_object_types.spec
new file mode 100644
index 0000000..3d912fb
--- /dev/null
+++ b/api/rs_object_types.spec
@@ -0,0 +1,226 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: Standard RenderScript types
+description:
+ TODO desc.
+include:
+ #define NULL ((void *)0)
+
+ // Opaque handle to a RenderScript object. Do not use this directly.
+ #ifndef __LP64__
+ #define _RS_HANDLE \
+ struct {\
+   const int* const p;\
+ } __attribute__((packed, aligned(4)))
+ #else
+ #define _RS_HANDLE \
+ struct {\
+   const long* const p;\
+   const long* const r;\
+   const long* const v1;\
+   const long* const v2;\
+ }
+ #endif
+end:
+
+type: rs_element
+simple: _RS_HANDLE
+summary: Handle to an element
+description:
+ Opaque handle to a RenderScript element.
+ See: android.renderscript.Element
+end:
+
+type: rs_type
+simple: _RS_HANDLE
+summary: Handle to a Type
+description:
+ Opaque handle to a RenderScript type.
+ See: android.renderscript.Type
+end:
+
+type: rs_allocation
+simple: _RS_HANDLE
+summary: Handle to an allocation
+description:
+ Opaque handle to a RenderScript allocation.
+ See: android.renderscript.Allocation
+end:
+
+type: rs_sampler
+simple: _RS_HANDLE
+summary: Handle to a Sampler
+description:
+ Opaque handle to a RenderScript sampler object.
+ See: android.renderscript.Sampler
+end:
+
+type: rs_script
+simple: _RS_HANDLE
+summary: Handle to a Script
+description:
+ Opaque handle to a RenderScript script object.
+ See: android.renderscript.ScriptC
+end:
+
+type: rs_matrix4x4
+struct:
+field: float m[16]
+summary: 4x4 matrix of 32 bit floats
+description:
+ Native holder for RS matrix.  Elements are stored in the array at the
+ location [row*4 + col]
+end:
+
+type: rs_matrix3x3
+struct:
+field: float m[9]
+summary: 3x3 matrix of 32 bit floats
+description:
+ Native holder for RS matrix.  Elements are stored in the array at the
+ location [row*3 + col]
+end:
+
+type: rs_matrix2x2
+struct:
+field: float m[4]
+summary: 2x2 matrix of 32 bit floats
+description:
+ Native holder for RS matrix.  Elements are stored in the array at the
+ location [row*2 + col]
+end:
+
+type: rs_quaternion
+simple: float4
+summary: Quarternion
+description:
+ Quaternion type for use with the quaternion functions
+end:
+
+type: rs_allocation_cubemap_face
+version: 14
+enum:
+value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0
+value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1
+value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2
+value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3
+value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4
+value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
+summary: Enum for selecting cube map faces
+description:
+end:
+
+type: rs_allocation_usage_type
+version: 14
+enum:
+value: RS_ALLOCATION_USAGE_SCRIPT = 0x0001
+value: RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, "Deprecated."
+value: RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, "Deprecated."
+value: RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, "Deprecated."
+value: RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010, "Deprecated."
+summary: Bitfield to specify the usage types for an allocation
+description:
+ These values are ORed together to specify which usages or memory spaces are
+ relevant to an allocation or an operation on an allocation.
+end:
+
+type: rs_data_type
+version: 16
+enum:
+value: RS_TYPE_NONE             = 0
+value: RS_TYPE_FLOAT_32         = 2
+value: RS_TYPE_FLOAT_64         = 3
+value: RS_TYPE_SIGNED_8         = 4
+value: RS_TYPE_SIGNED_16        = 5
+value: RS_TYPE_SIGNED_32        = 6
+value: RS_TYPE_SIGNED_64        = 7
+value: RS_TYPE_UNSIGNED_8       = 8
+value: RS_TYPE_UNSIGNED_16      = 9
+value: RS_TYPE_UNSIGNED_32      = 10
+value: RS_TYPE_UNSIGNED_64      = 11
+value: RS_TYPE_BOOLEAN          = 12
+value: RS_TYPE_UNSIGNED_5_6_5   = 13
+value: RS_TYPE_UNSIGNED_5_5_5_1 = 14
+value: RS_TYPE_UNSIGNED_4_4_4_4 = 15
+value: RS_TYPE_MATRIX_4X4       = 16
+value: RS_TYPE_MATRIX_3X3       = 17
+value: RS_TYPE_MATRIX_2X2       = 18
+value: RS_TYPE_ELEMENT          = 1000
+value: RS_TYPE_TYPE             = 1001
+value: RS_TYPE_ALLOCATION       = 1002
+value: RS_TYPE_SAMPLER          = 1003
+value: RS_TYPE_SCRIPT           = 1004
+value: RS_TYPE_MESH             = 1005
+value: RS_TYPE_PROGRAM_FRAGMENT = 1006
+value: RS_TYPE_PROGRAM_VERTEX   = 1007
+value: RS_TYPE_PROGRAM_RASTER   = 1008
+value: RS_TYPE_PROGRAM_STORE    = 1009
+value: RS_TYPE_FONT             = 1010
+value: RS_TYPE_INVALID          = 10000
+summary: Element data types
+description:
+ DataType represents the basic type information for a basic element.  The
+ naming convention follows.  For numeric types it is FLOAT,
+ SIGNED, or UNSIGNED followed by the _BITS where BITS is the
+ size of the data.  BOOLEAN is a true / false (1,0)
+ represented in an 8 bit container.  The UNSIGNED variants
+ with multiple bit definitions are for packed graphical data
+ formats and represent vectors with per vector member sizes
+ which are treated as a single unit for packing and alignment
+ purposes.
+
+ MATRIX the three matrix types contain FLOAT_32 elements and are treated
+ as 32 bits for alignment purposes.
+
+ RS_* objects.  32 bit opaque handles.
+end:
+
+type: rs_data_kind
+version: 16
+enum:
+value: RS_KIND_USER         = 0
+value: RS_KIND_PIXEL_L      = 7
+value: RS_KIND_PIXEL_A      = 8
+value: RS_KIND_PIXEL_LA     = 9
+value: RS_KIND_PIXEL_RGB    = 10
+value: RS_KIND_PIXEL_RGBA   = 11
+value: RS_KIND_PIXEL_DEPTH  = 12
+value: RS_KIND_PIXEL_YUV    = 13
+value: RS_KIND_INVALID      = 100
+summary: Element data kind
+description:
+ The special interpretation of the data if required.  This is primarly
+ useful for graphical data.  USER indicates no special interpretation is
+ expected.  PIXEL is used in conjunction with the standard data types for
+ representing texture formats.
+end:
+
+type: rs_sampler_value
+version: 16
+enum:
+value: RS_SAMPLER_NEAREST              = 0
+value: RS_SAMPLER_LINEAR               = 1
+value: RS_SAMPLER_LINEAR_MIP_LINEAR    = 2
+value: RS_SAMPLER_WRAP                 = 3
+value: RS_SAMPLER_CLAMP                = 4
+value: RS_SAMPLER_LINEAR_MIP_NEAREST   = 5
+value: RS_SAMPLER_MIRRORED_REPEAT      = 6
+value: RS_SAMPLER_INVALID              = 100
+summary: Sampler wrap T value
+description:
+end:
diff --git a/api/rs_program.spec b/api/rs_program.spec
deleted file mode 100644
index a2c39a9..0000000
--- a/api/rs_program.spec
+++ /dev/null
@@ -1,130 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Program object routines
-description:
-end:
-
-function: rsgProgramRasterGetCullMode
-version: 16
-ret: rs_cull_mode
-arg: rs_program_raster pr, "program raster to query"
-summary:
-description:
- Get program raster cull mode
-test: none
-end:
-
-function: rsgProgramRasterIsPointSpriteEnabled
-version: 16
-ret: bool
-arg: rs_program_raster pr, "program raster to query"
-summary:
-description:
- Get program raster point sprite state
-test: none
-end:
-
-function: rsgProgramStoreGetBlendDstFunc
-version: 16
-ret: rs_blend_dst_func
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store blend destination function
-test: none
-end:
-
-function: rsgProgramStoreGetBlendSrcFunc
-version: 16
-ret: rs_blend_src_func
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store blend source function
-test: none
-end:
-
-function: rsgProgramStoreGetDepthFunc
-version: 16
-ret: rs_depth_func
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store depth function
-test: none
-end:
-
-function: rsgProgramStoreIsColorMaskAlphaEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store alpha component color mask
-test: none
-end:
-
-function: rsgProgramStoreIsColorMaskBlueEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store blur component color mask
-test: none
-end:
-
-function: rsgProgramStoreIsColorMaskGreenEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store green component color mask
-test: none
-end:
-
-function: rsgProgramStoreIsColorMaskRedEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store red component color mask
-test: none
-end:
-
-function: rsgProgramStoreIsDepthMaskEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store depth mask
-test: none
-end:
-
-function: rsgProgramStoreIsDitherEnabled
-version: 16
-ret: bool
-arg: rs_program_store ps, "program store to query"
-summary:
-description:
- Get program store dither state
-test: none
-end:
diff --git a/api/rs_sampler.spec b/api/rs_sampler.spec
deleted file mode 100644
index 35ab612..0000000
--- a/api/rs_sampler.spec
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Sampler routines
-description:
-end:
-
-function: rsSamplerGetAnisotropy
-version: 16
-ret: float, "anisotropy"
-arg: rs_sampler s, "sampler to query"
-summary:
-description:
-  Get sampler anisotropy
-test: none
-end:
-
-function: rsSamplerGetMagnification
-version: 16
-ret: rs_sampler_value, "magnification value"
-arg: rs_sampler s, "sampler to query"
-summary:
-description:
- Get sampler magnification value
-test: none
-end:
-
-function: rsSamplerGetMinification
-version: 16
-ret: rs_sampler_value, "minification value"
-arg: rs_sampler s, "sampler to query"
-summary:
-description:
- Get sampler minification value
-test: none
-end:
-
-function: rsSamplerGetWrapS
-version: 16
-ret: rs_sampler_value, "wrap S value"
-arg: rs_sampler s, "sampler to query"
-summary:
-description:
- Get sampler wrap S value
-test: none
-end:
-
-function: rsSamplerGetWrapT
-version: 16
-ret: rs_sampler_value, "wrap T value"
-arg: rs_sampler s, "sampler to query"
-summary:
-description:
- Get sampler wrap T value
-test: none
-end:
diff --git a/api/rs_types.spec b/api/rs_types.spec
deleted file mode 100644
index 0eeac5b..0000000
--- a/api/rs_types.spec
+++ /dev/null
@@ -1,849 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-header:
-summary: Standard RenderScript types
-description:
-  Integers:<ul>
-  <li>8 bit: char, int8_t</li>
-  <li>16 bit: short, int16_t</li>
-  <li>32 bit: int, in32_t</li>
-  <li>64 bit: long, long long, int64_t</li></ul>
-
-  Unsigned integers:<ul>
-  <li>8 bit: uchar, uint8_t</li>
-  <li>16 bit: ushort, uint16_t</li>
-  <li>32 bit: uint, uint32_t</li>
-  <li>64 bit: ulong, uint64_t</li></ul>
-
-  Floating point:<ul>
-  <li>32 bit: float</li>
-  <li>64 bit: double</li></ul>
-
-  Vectors of length 2, 3, and 4 are supported for all the types above.
-include:
- #include "stdbool.h"
-
- #define RS_PACKED __attribute__((packed, aligned(4)))
- #define NULL ((void *)0)
-
- // Opaque handle to a RenderScript object. Do not use this directly.
- #ifndef __LP64__
- #define _RS_HANDLE \
- struct {\
-   const int* const p;\
- } __attribute__((packed, aligned(4)))
- #else
- #define _RS_HANDLE \
- struct {\
-   const long* const p;\
-   const long* const r;\
-   const long* const v1;\
-   const long* const v2;\
- }
- #endif
-end:
-
-constant: M_1_PI
-value: 0.318309886183790671537767526745028724f
-summary: 1 / pi, as a 32 bit float
-description:
- The inverse of pi, as a 32 bit float.
-end:
-
-constant: M_2_PI
-value: 0.636619772367581343075535053490057448f
-summary: 2 / pi, as a 32 bit float
-description:
- 2 divided by pi, as a 32 bit float.
-end:
-
-constant: M_2_PIl
-value: 0.636619772367581343075535053490057448f
-hidden:
-summary: Deprecated.  Use M_2_PI instead.
-description:
-end:
-
-constant: M_2_SQRTPI
-value: 1.128379167095512573896158903121545172f
-summary:  2 / sqrt(pi), as a 32 bit float
-description:
- 2 divided by the square root of pi, as a 32 bit float.
-end:
-
-constant: M_E
-value: 2.718281828459045235360287471352662498f
-summary: e, as a 32 bit float
-description:
- The number e, the base of the natural logarithm, as a 32 bit float.
-end:
-
-constant: M_LN10
-value: 2.302585092994045684017991454684364208f
-summary: log_e(10), as a 32 bit float
-description:
- The natural logarithm of 10, as a 32 bit float.
-end:
-
-constant: M_LN2
-value: 0.693147180559945309417232121458176568f
-summary: log_e(2), as a 32 bit float
-description:
- The natural logarithm of 2, as a 32 bit float.
-end:
-
-constant: M_LOG10E
-value: 0.434294481903251827651128918916605082f
-summary: log_10(e), as a 32 bit float
-description:
- The logarithm base 10 of e, as a 32 bit float.
-end:
-
-constant: M_LOG2E
-value: 1.442695040888963407359924681001892137f
-summary: log_2(e), as a 32 bit float
-description:
- The logarithm base 2 of e, as a 32 bit float.
-end:
-
-constant: M_PI
-value: 3.141592653589793238462643383279502884f
-summary: pi, as a 32 bit float
-description:
- The constant pi, as a 32 bit float.
-end:
-
-constant: M_PI_2
-value: 1.570796326794896619231321691639751442f
-summary: pi / 2, as a 32 bit float
-description:
- Pi divided by 2, as a 32 bit float.
-end:
-
-constant: M_PI_4
-value: 0.785398163397448309615660845819875721f
-summary: pi / 4, as a 32 bit float
-description:
- Pi divided by 4, as a 32 bit float.
-end:
-
-constant: M_SQRT1_2
-value: 0.707106781186547524400844362104849039f
-summary: 1 / sqrt(2), as a 32 bit float
-description:
- The inverse of the square root of 2, as a 32 bit float.
-end:
-
-constant: M_SQRT2
-value: 1.414213562373095048801688724209698079f
-summary: sqrt(2), as a 32 bit float
-description:
- The square root of 2, as a 32 bit float.
-end:
-
-type: int8_t
-simple: char
-summary: 8 bit signed integer
-description:
- 8 bit integer type
-end:
-
-type: int16_t
-simple: short
-summary: 16 bit signed integer
-description:
- 16 bit integer type
-end:
-
-type: int32_t
-simple: int
-summary: 32 bit signed integer
-description:
- 32 bit integer type
-end:
-
-type: int64_t
-version: 9 20
-simple: long long
-summary: 64 bit signed integer
-description:
- 64 bit integer type
-end:
-
-type: int64_t
-version: 21
-simple: long
-end:
-
-type: uint8_t
-simple: unsigned char
-summary: 8 bit unsigned integer
-description:
- 8 bit unsigned integer type
-end:
-
-type: uint16_t
-simple: unsigned short
-summary: 16 bit unsigned integer
-description:
- 16 bit unsigned integer type
-end:
-
-type: uint32_t
-simple: unsigned int
-summary: 32 bit unsigned integer
-description:
- 32 bit unsigned integer type
-end:
-
-type: uint64_t
-version: 9 20
-simple: unsigned long long
-summary: 64 bit unsigned integer
-description:
- 64 bit unsigned integer type
-end:
-
-type: uint64_t
-version: 21
-simple: unsigned long
-end:
-
-type: uchar
-simple: uint8_t
-summary: 8 bit unsigned integer
-description:
- 8 bit unsigned integer type
-end:
-
-type: ushort
-simple: uint16_t
-summary: 16 bit unsigned integer
-description:
- 16 bit unsigned integer type
-end:
-
-type: uint
-simple: uint32_t
-summary: 32 bit unsigned integer
-description:
- 32 bit unsigned integer type
-end:
-
-type: ulong
-simple: uint64_t
-summary: 64 bit unsigned integer
-description:
- Typedef for unsigned long (use for 64-bit unsigned integers)
-end:
-
-type: size_t
-size: 64
-simple: uint64_t
-summary: Unsigned size type
-description:
- Typedef for size_t
-end:
-
-type: size_t
-size: 32
-simple: uint32_t
-end:
-
-type: ssize_t
-size: 64
-simple: int64_t
-summary: Signed size type
-description:
- Typedef for ssize_t
-end:
-
-type: ssize_t
-size: 32
-simple: int32_t
-end:
-
-type: rs_element
-simple: _RS_HANDLE
-summary: Handle to an element
-description:
- Opaque handle to a RenderScript element.
- See: android.renderscript.Element
-end:
-
-type: rs_type
-simple: _RS_HANDLE
-summary: Handle to a Type
-description:
- Opaque handle to a RenderScript type.
- See: android.renderscript.Type
-end:
-
-type: rs_allocation
-simple: _RS_HANDLE
-summary: Handle to an allocation
-description:
- Opaque handle to a RenderScript allocation.
- See: android.renderscript.Allocation
-end:
-
-type: rs_sampler
-simple: _RS_HANDLE
-summary: Handle to a Sampler
-description:
- Opaque handle to a RenderScript sampler object.
- See: android.renderscript.Sampler
-end:
-
-type: rs_script
-simple: _RS_HANDLE
-summary: Handle to a Script
-description:
- Opaque handle to a RenderScript script object.
- See: android.renderscript.ScriptC
-end:
-
-
-type: rs_mesh
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a Mesh
-description:
- Opaque handle to a RenderScript mesh object.
- See: android.renderscript.Mesh
-end:
-
-type: rs_program_fragment
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a ProgramFragment
-description:
- Opaque handle to a RenderScript ProgramFragment object.
- See: android.renderscript.ProgramFragment
-end:
-
-type: rs_program_vertex
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a ProgramVertex
-description:
- Opaque handle to a RenderScript ProgramVertex object.
- See: android.renderscript.ProgramVertex
-end:
-
-type: rs_program_raster
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a ProgramRaster
-description:
- Opaque handle to a RenderScript ProgramRaster object.
- See: android.renderscript.ProgramRaster
-end:
-
-type: rs_program_store
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a ProgramStore
-description:
- Opaque handle to a RenderScript ProgramStore object.
- See: android.renderscript.ProgramStore
-end:
-
-type: rs_font
-size: 32
-simple: _RS_HANDLE
-summary: Handle to a Font
-description:
- Opaque handle to a RenderScript font object.
- See: android.renderscript.Font
-end:
-
-type: float2
-simple: float __attribute__((ext_vector_type(2)))
-summary: Two 32 bit floats
-description:
- Vector version of the basic float type.
- Provides two float fields packed into a single 64 bit field with 64 bit alignment.
-end:
-
-type: float3
-simple: float __attribute__((ext_vector_type(3)))
-summary: Three 32 bit floats
-description:
- Vector version of the basic float type.
- Provides three float fields packed into a single 128 bit field with 128 bit alignment.
-end:
-
-type: float4
-simple: float __attribute__((ext_vector_type(4)))
-summary: Four 32 bit floats
-description:
- Vector version of the basic float type.
- Provides four float fields packed into a single 128 bit field with 128 bit alignment.
-end:
-
-
-type: double2
-simple: double __attribute__((ext_vector_type(2)))
-summary: Two 64 bit floats
-description:
- Vector version of the basic double type. Provides two double fields packed
- into a single 128 bit field with 128 bit alignment.
-end:
-
-type: double3
-simple: double __attribute__((ext_vector_type(3)))
-summary: Three 64 bit floats
-description:
- Vector version of the basic double type. Provides three double fields packed
- into a single 256 bit field with 256 bit alignment.
-end:
-
-type: double4
-simple: double __attribute__((ext_vector_type(4)))
-summary: Four 64 bit floats
-description:
- Vector version of the basic double type. Provides four double fields packed
- into a single 256 bit field with 256 bit alignment.
-end:
-
-
-type: uchar2
-simple: uchar __attribute__((ext_vector_type(2)))
-summary: Two 8 bit unsigned integers
-description:
- Vector version of the basic uchar type. Provides two uchar fields packed
- into a single 16 bit field with 16 bit alignment.
-end:
-
-type: uchar3
-simple: uchar __attribute__((ext_vector_type(3)))
-summary: Three 8 bit unsigned integers
-description:
- Vector version of the basic uchar type. Provides three uchar fields packed
- into a single 32 bit field with 32 bit alignment.
-end:
-
-type: uchar4
-simple: uchar __attribute__((ext_vector_type(4)))
-summary: Four 8 bit unsigned integers
-description:
- Vector version of the basic uchar type. Provides four uchar fields packed
- into a single 32 bit field with 32 bit alignment.
-end:
-
-
-type: ushort2
-simple: ushort __attribute__((ext_vector_type(2)))
-summary: Two 16 bit unsigned integers
-description:
- Vector version of the basic ushort type. Provides two ushort fields packed
- into a single 32 bit field with 32 bit alignment.
-end:
-
-type: ushort3
-simple: ushort __attribute__((ext_vector_type(3)))
-summary: Three 16 bit unsigned integers
-description:
- Vector version of the basic ushort type. Provides three ushort fields packed
- into a single 64 bit field with 64 bit alignment.
-end:
-
-type: ushort4
-simple: ushort __attribute__((ext_vector_type(4)))
-summary: Four 16 bit unsigned integers
-description:
- Vector version of the basic ushort type. Provides four ushort fields packed
- into a single 64 bit field with 64 bit alignment.
-end:
-
-
-type: uint2
-simple: uint __attribute__((ext_vector_type(2)))
-summary: Two 32 bit unsigned integers
-description:
- Vector version of the basic uint type. Provides two uint fields packed into a
- single 64 bit field with 64 bit alignment.
-end:
-
-type: uint3
-simple: uint __attribute__((ext_vector_type(3)))
-summary: Three 32 bit unsigned integers
-description:
- Vector version of the basic uint type. Provides three uint fields packed into
- a single 128 bit field with 128 bit alignment.
-end:
-
-type: uint4
-simple: uint __attribute__((ext_vector_type(4)))
-summary: Four 32 bit unsigned integers
-description:
- Vector version of the basic uint type. Provides four uint fields packed into
- a single 128 bit field with 128 bit alignment.
-end:
-
-
-type: ulong2
-simple: ulong __attribute__((ext_vector_type(2)))
-summary: Two 64 bit unsigned integers
-description:
- Vector version of the basic ulong type. Provides two ulong fields packed into
- a single 128 bit field with 128 bit alignment.
-end:
-
-type: ulong3
-simple: ulong __attribute__((ext_vector_type(3)))
-summary: Three 64 bit unsigned integers
-description:
- Vector version of the basic ulong type. Provides three ulong fields packed
- into a single 256 bit field with 256 bit alignment.
-end:
-
-type: ulong4
-simple: ulong __attribute__((ext_vector_type(4)))
-summary: Four 64 bit unsigned integers
-description:
- Vector version of the basic ulong type. Provides four ulong fields packed
- into a single 256 bit field with 256 bit alignment.
-end:
-
-
-type: char2
-simple: char __attribute__((ext_vector_type(2)))
-summary: Two 8 bit signed integers
-description:
- Vector version of the basic char type. Provides two char fields packed into a
- single 16 bit field with 16 bit alignment.
-end:
-
-type: char3
-simple: char __attribute__((ext_vector_type(3)))
-summary: Three 8 bit signed integers
-description:
- Vector version of the basic char type. Provides three char fields packed into
- a single 32 bit field with 32 bit alignment.
-end:
-
-type: char4
-simple: char __attribute__((ext_vector_type(4)))
-summary: Four 8 bit signed integers
-description:
- Vector version of the basic char type. Provides four char fields packed into
- a single 32 bit field with 32 bit alignment.
-end:
-
-type: short2
-simple: short __attribute__((ext_vector_type(2)))
-summary: Two 16 bit signed integers
-description:
- Vector version of the basic short type. Provides two short fields packed into
- a single 32 bit field with 32 bit alignment.
-end:
-
-type: short3
-simple: short __attribute__((ext_vector_type(3)))
-summary: Three 16 bit signed integers
-description:
- Vector version of the basic short type. Provides three short fields packed
- into a single 64 bit field with 64 bit alignment.
-end:
-
-type: short4
-simple: short __attribute__((ext_vector_type(4)))
-summary: Four 16 bit signed integers
-description:
- Vector version of the basic short type. Provides four short fields packed
- into a single 64 bit field with 64 bit alignment.
-end:
-
-
-type: int2
-simple: int __attribute__((ext_vector_type(2)))
-summary: Two 32 bit signed integers
-description:
- Vector version of the basic int type. Provides two int fields packed into a
- single 64 bit field with 64 bit alignment.
-end:
-
-type: int3
-simple: int __attribute__((ext_vector_type(3)))
-summary: Three 32 bit signed integers
-description:
- Vector version of the basic int type. Provides three int fields packed into a
- single 128 bit field with 128 bit alignment.
-end:
-
-type: int4
-simple: int __attribute__((ext_vector_type(4)))
-summary: Four 32 bit signed integers
-description:
- Vector version of the basic int type. Provides two four fields packed into a
- single 128 bit field with 128 bit alignment.
-end:
-
-
-type: long2
-simple: long __attribute__((ext_vector_type(2)))
-summary: Two 64 bit signed integers
-description:
- Vector version of the basic long type. Provides two long fields packed into a
- single 128 bit field with 128 bit alignment.
-end:
-
-type: long3
-simple: long __attribute__((ext_vector_type(3)))
-summary: Three 64 bit signed integers
-description:
- Vector version of the basic long type. Provides three long fields packed into
- a single 256 bit field with 256 bit alignment.
-end:
-
-type: long4
-simple: long __attribute__((ext_vector_type(4)))
-summary: Four 64 bit signed integers
-description:
- Vector version of the basic long type. Provides four long fields packed into
- a single 256 bit field with 256 bit alignment.
-end:
-
-type: rs_matrix4x4
-struct:
-field: float m[16]
-summary: 4x4 matrix of 32 bit floats
-description:
- Native holder for RS matrix.  Elements are stored in the array at the
- location [row*4 + col]
-end:
-
-type: rs_matrix3x3
-struct:
-field: float m[9]
-summary: 3x3 matrix of 32 bit floats
-description:
- Native holder for RS matrix.  Elements are stored in the array at the
- location [row*3 + col]
-end:
-
-type: rs_matrix2x2
-struct:
-field: float m[4]
-summary: 2x2 matrix of 32 bit floats
-description:
- Native holder for RS matrix.  Elements are stored in the array at the
- location [row*2 + col]
-end:
-
-type: rs_quaternion
-simple: float4
-summary: Quarternion
-description:
- Quaternion type for use with the quaternion functions
-end:
-
-type: rs_allocation_cubemap_face
-version: 14
-enum:
-value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0
-value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1
-value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2
-value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3
-value: RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4
-value: RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-summary: Enum for selecting cube map faces
-description:
-end:
-
-type: rs_allocation_usage_type
-version: 14
-enum:
-value: RS_ALLOCATION_USAGE_SCRIPT = 0x0001
-value: RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, "Deprecated."
-value: RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, "Deprecated."
-value: RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, "Deprecated."
-value: RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010, "Deprecated."
-summary: Bitfield to specify the usage types for an allocation
-description:
- These values are ORed together to specify which usages or memory spaces are
- relevant to an allocation or an operation on an allocation.
-end:
-
-type: rs_primitive
-version: 16
-size: 32
-enum:
-value: RS_PRIMITIVE_POINT = 0, "Vertex data will be rendered as a series of points"
-value: RS_PRIMITIVE_LINE = 1, "Vertex pairs will be rendered as lines"
-value: RS_PRIMITIVE_LINE_STRIP = 2, "Vertex data will be rendered as a connected line strip"
-value: RS_PRIMITIVE_TRIANGLE = 3, "Vertices will be rendered as individual triangles"
-value: RS_PRIMITIVE_TRIANGLE_STRIP = 4, "Vertices will be rendered as a connected triangle strip defined by the first three vertices with each additional triangle defined by a new vertex"
-value: RS_PRIMITIVE_TRIANGLE_FAN = 5, "Vertices will be rendered as a sequence of triangles that all share first vertex as the origin"
-value: RS_PRIMITIVE_INVALID = 100, "Invalid primitive"
-summary: How to intepret mesh vertex data
-description:
- Describes the way mesh vertex data is interpreted when rendering
-end:
-
-type: rs_data_type
-version: 16
-enum:
-value: RS_TYPE_NONE             = 0
-value: RS_TYPE_FLOAT_32         = 2
-value: RS_TYPE_FLOAT_64         = 3
-value: RS_TYPE_SIGNED_8         = 4
-value: RS_TYPE_SIGNED_16        = 5
-value: RS_TYPE_SIGNED_32        = 6
-value: RS_TYPE_SIGNED_64        = 7
-value: RS_TYPE_UNSIGNED_8       = 8
-value: RS_TYPE_UNSIGNED_16      = 9
-value: RS_TYPE_UNSIGNED_32      = 10
-value: RS_TYPE_UNSIGNED_64      = 11
-value: RS_TYPE_BOOLEAN          = 12
-value: RS_TYPE_UNSIGNED_5_6_5   = 13
-value: RS_TYPE_UNSIGNED_5_5_5_1 = 14
-value: RS_TYPE_UNSIGNED_4_4_4_4 = 15
-value: RS_TYPE_MATRIX_4X4       = 16
-value: RS_TYPE_MATRIX_3X3       = 17
-value: RS_TYPE_MATRIX_2X2       = 18
-value: RS_TYPE_ELEMENT          = 1000
-value: RS_TYPE_TYPE             = 1001
-value: RS_TYPE_ALLOCATION       = 1002
-value: RS_TYPE_SAMPLER          = 1003
-value: RS_TYPE_SCRIPT           = 1004
-value: RS_TYPE_MESH             = 1005
-value: RS_TYPE_PROGRAM_FRAGMENT = 1006
-value: RS_TYPE_PROGRAM_VERTEX   = 1007
-value: RS_TYPE_PROGRAM_RASTER   = 1008
-value: RS_TYPE_PROGRAM_STORE    = 1009
-value: RS_TYPE_FONT             = 1010
-value: RS_TYPE_INVALID          = 10000
-summary: Element data types
-description:
- DataType represents the basic type information for a basic element.  The
- naming convention follows.  For numeric types it is FLOAT,
- SIGNED, or UNSIGNED followed by the _BITS where BITS is the
- size of the data.  BOOLEAN is a true / false (1,0)
- represented in an 8 bit container.  The UNSIGNED variants
- with multiple bit definitions are for packed graphical data
- formats and represent vectors with per vector member sizes
- which are treated as a single unit for packing and alignment
- purposes.
-
- MATRIX the three matrix types contain FLOAT_32 elements and are treated
- as 32 bits for alignment purposes.
-
- RS_* objects.  32 bit opaque handles.
-end:
-
-type: rs_data_kind
-version: 16
-enum:
-value: RS_KIND_USER         = 0
-value: RS_KIND_PIXEL_L      = 7
-value: RS_KIND_PIXEL_A      = 8
-value: RS_KIND_PIXEL_LA     = 9
-value: RS_KIND_PIXEL_RGB    = 10
-value: RS_KIND_PIXEL_RGBA   = 11
-value: RS_KIND_PIXEL_DEPTH  = 12
-value: RS_KIND_PIXEL_YUV    = 13
-value: RS_KIND_INVALID      = 100
-summary: Element data kind
-description:
- The special interpretation of the data if required.  This is primarly
- useful for graphical data.  USER indicates no special interpretation is
- expected.  PIXEL is used in conjunction with the standard data types for
- representing texture formats.
-end:
-
-type: rs_depth_func
-version: 16
-size: 32
-enum:
-value: RS_DEPTH_FUNC_ALWAYS        = 0, "Always drawn"
-value: RS_DEPTH_FUNC_LESS          = 1, "Drawn if the incoming depth value is less than that in the depth buffer"
-value: RS_DEPTH_FUNC_LEQUAL        = 2, "Drawn if the incoming depth value is less or equal to that in the depth buffer"
-value: RS_DEPTH_FUNC_GREATER       = 3, "Drawn if the incoming depth value is greater than that in the depth buffer"
-value: RS_DEPTH_FUNC_GEQUAL        = 4, "Drawn if the incoming depth value is greater or equal to that in the depth buffer"
-value: RS_DEPTH_FUNC_EQUAL         = 5, "Drawn if the incoming depth value is equal to that in the depth buffer"
-value: RS_DEPTH_FUNC_NOTEQUAL      = 6, "Drawn if the incoming depth value is not equal to that in the depth buffer"
-value: RS_DEPTH_FUNC_INVALID       = 100, "Invalid depth function"
-summary: Depth function
-description:
- Specifies conditional drawing depending on the comparison of the incoming
- depth to that found in the depth buffer.
-end:
-
-type: rs_blend_src_func
-version: 16
-size: 32
-enum:
-value: RS_BLEND_SRC_ZERO                   = 0
-value: RS_BLEND_SRC_ONE                    = 1
-value: RS_BLEND_SRC_DST_COLOR              = 2
-value: RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3
-value: RS_BLEND_SRC_SRC_ALPHA              = 4
-value: RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5
-value: RS_BLEND_SRC_DST_ALPHA              = 6
-value: RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7
-value: RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8
-value: RS_BLEND_SRC_INVALID                = 100
-summary: Blend source function
-description:
-end:
-
-type: rs_blend_dst_func
-version: 16
-size: 32
-enum:
-value: RS_BLEND_DST_ZERO                   = 0
-value: RS_BLEND_DST_ONE                    = 1
-value: RS_BLEND_DST_SRC_COLOR              = 2
-value: RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3
-value: RS_BLEND_DST_SRC_ALPHA              = 4
-value: RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5
-value: RS_BLEND_DST_DST_ALPHA              = 6
-value: RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7
-value: RS_BLEND_DST_INVALID                = 100
-summary: Blend destination function
-description:
-end:
-
-type: rs_cull_mode
-version: 16
-size: 32
-enum:
-value: RS_CULL_BACK     = 0
-value: RS_CULL_FRONT    = 1
-value: RS_CULL_NONE     = 2
-value: RS_CULL_INVALID  = 100
-summary: Culling mode
-description:
-end:
-
-type: rs_sampler_value
-version: 16
-enum:
-value: RS_SAMPLER_NEAREST              = 0
-value: RS_SAMPLER_LINEAR               = 1
-value: RS_SAMPLER_LINEAR_MIP_LINEAR    = 2
-value: RS_SAMPLER_WRAP                 = 3
-value: RS_SAMPLER_CLAMP                = 4
-value: RS_SAMPLER_LINEAR_MIP_NEAREST   = 5
-value: RS_SAMPLER_MIRRORED_REPEAT      = 6
-value: RS_SAMPLER_INVALID              = 100
-summary: Sampler wrap T value
-description:
-end:
diff --git a/api/rs_value_types.spec b/api/rs_value_types.spec
new file mode 100644
index 0000000..1e6eeed
--- /dev/null
+++ b/api/rs_value_types.spec
@@ -0,0 +1,407 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: Standard RenderScript types
+description:
+  Integers:<ul>
+  <li>8 bit: char, int8_t</li>
+  <li>16 bit: short, int16_t</li>
+  <li>32 bit: int, in32_t</li>
+  <li>64 bit: long, long long, int64_t</li></ul>
+
+  Unsigned integers:<ul>
+  <li>8 bit: uchar, uint8_t</li>
+  <li>16 bit: ushort, uint16_t</li>
+  <li>32 bit: uint, uint32_t</li>
+  <li>64 bit: ulong, uint64_t</li></ul>
+
+  Floating point:<ul>
+  <li>32 bit: float</li>
+  <li>64 bit: double</li></ul>
+
+  Vectors of length 2, 3, and 4 are supported for all the types above.
+end:
+
+type: int8_t
+simple: char
+summary: 8 bit signed integer
+description:
+ 8 bit integer type
+end:
+
+type: int16_t
+simple: short
+summary: 16 bit signed integer
+description:
+ 16 bit integer type
+end:
+
+type: int32_t
+simple: int
+summary: 32 bit signed integer
+description:
+ 32 bit integer type
+end:
+
+type: int64_t
+version: 9 20
+simple: long long
+summary: 64 bit signed integer
+description:
+ 64 bit integer type
+end:
+
+type: int64_t
+version: 21
+simple: long
+end:
+
+type: uint8_t
+simple: unsigned char
+summary: 8 bit unsigned integer
+description:
+ 8 bit unsigned integer type
+end:
+
+type: uint16_t
+simple: unsigned short
+summary: 16 bit unsigned integer
+description:
+ 16 bit unsigned integer type
+end:
+
+type: uint32_t
+simple: unsigned int
+summary: 32 bit unsigned integer
+description:
+ 32 bit unsigned integer type
+end:
+
+type: uint64_t
+version: 9 20
+simple: unsigned long long
+summary: 64 bit unsigned integer
+description:
+ 64 bit unsigned integer type
+end:
+
+type: uint64_t
+version: 21
+simple: unsigned long
+end:
+
+type: uchar
+simple: uint8_t
+summary: 8 bit unsigned integer
+description:
+ 8 bit unsigned integer type
+end:
+
+type: ushort
+simple: uint16_t
+summary: 16 bit unsigned integer
+description:
+ 16 bit unsigned integer type
+end:
+
+type: uint
+simple: uint32_t
+summary: 32 bit unsigned integer
+description:
+ 32 bit unsigned integer type
+end:
+
+type: ulong
+simple: uint64_t
+summary: 64 bit unsigned integer
+description:
+ Typedef for unsigned long (use for 64-bit unsigned integers)
+end:
+
+type: size_t
+size: 64
+simple: uint64_t
+summary: Unsigned size type
+description:
+ Typedef for size_t
+end:
+
+type: size_t
+size: 32
+simple: uint32_t
+end:
+
+type: ssize_t
+size: 64
+simple: int64_t
+summary: Signed size type
+description:
+ Typedef for ssize_t
+end:
+
+type: ssize_t
+size: 32
+simple: int32_t
+end:
+
+type: float2
+simple: float __attribute__((ext_vector_type(2)))
+summary: Two 32 bit floats
+description:
+ Vector version of the basic float type.
+ Provides two float fields packed into a single 64 bit field with 64 bit alignment.
+end:
+
+type: float3
+simple: float __attribute__((ext_vector_type(3)))
+summary: Three 32 bit floats
+description:
+ Vector version of the basic float type.
+ Provides three float fields packed into a single 128 bit field with 128 bit alignment.
+end:
+
+type: float4
+simple: float __attribute__((ext_vector_type(4)))
+summary: Four 32 bit floats
+description:
+ Vector version of the basic float type.
+ Provides four float fields packed into a single 128 bit field with 128 bit alignment.
+end:
+
+
+type: double2
+simple: double __attribute__((ext_vector_type(2)))
+summary: Two 64 bit floats
+description:
+ Vector version of the basic double type. Provides two double fields packed
+ into a single 128 bit field with 128 bit alignment.
+end:
+
+type: double3
+simple: double __attribute__((ext_vector_type(3)))
+summary: Three 64 bit floats
+description:
+ Vector version of the basic double type. Provides three double fields packed
+ into a single 256 bit field with 256 bit alignment.
+end:
+
+type: double4
+simple: double __attribute__((ext_vector_type(4)))
+summary: Four 64 bit floats
+description:
+ Vector version of the basic double type. Provides four double fields packed
+ into a single 256 bit field with 256 bit alignment.
+end:
+
+
+type: uchar2
+simple: uchar __attribute__((ext_vector_type(2)))
+summary: Two 8 bit unsigned integers
+description:
+ Vector version of the basic uchar type. Provides two uchar fields packed
+ into a single 16 bit field with 16 bit alignment.
+end:
+
+type: uchar3
+simple: uchar __attribute__((ext_vector_type(3)))
+summary: Three 8 bit unsigned integers
+description:
+ Vector version of the basic uchar type. Provides three uchar fields packed
+ into a single 32 bit field with 32 bit alignment.
+end:
+
+type: uchar4
+simple: uchar __attribute__((ext_vector_type(4)))
+summary: Four 8 bit unsigned integers
+description:
+ Vector version of the basic uchar type. Provides four uchar fields packed
+ into a single 32 bit field with 32 bit alignment.
+end:
+
+
+type: ushort2
+simple: ushort __attribute__((ext_vector_type(2)))
+summary: Two 16 bit unsigned integers
+description:
+ Vector version of the basic ushort type. Provides two ushort fields packed
+ into a single 32 bit field with 32 bit alignment.
+end:
+
+type: ushort3
+simple: ushort __attribute__((ext_vector_type(3)))
+summary: Three 16 bit unsigned integers
+description:
+ Vector version of the basic ushort type. Provides three ushort fields packed
+ into a single 64 bit field with 64 bit alignment.
+end:
+
+type: ushort4
+simple: ushort __attribute__((ext_vector_type(4)))
+summary: Four 16 bit unsigned integers
+description:
+ Vector version of the basic ushort type. Provides four ushort fields packed
+ into a single 64 bit field with 64 bit alignment.
+end:
+
+
+type: uint2
+simple: uint __attribute__((ext_vector_type(2)))
+summary: Two 32 bit unsigned integers
+description:
+ Vector version of the basic uint type. Provides two uint fields packed into a
+ single 64 bit field with 64 bit alignment.
+end:
+
+type: uint3
+simple: uint __attribute__((ext_vector_type(3)))
+summary: Three 32 bit unsigned integers
+description:
+ Vector version of the basic uint type. Provides three uint fields packed into
+ a single 128 bit field with 128 bit alignment.
+end:
+
+type: uint4
+simple: uint __attribute__((ext_vector_type(4)))
+summary: Four 32 bit unsigned integers
+description:
+ Vector version of the basic uint type. Provides four uint fields packed into
+ a single 128 bit field with 128 bit alignment.
+end:
+
+
+type: ulong2
+simple: ulong __attribute__((ext_vector_type(2)))
+summary: Two 64 bit unsigned integers
+description:
+ Vector version of the basic ulong type. Provides two ulong fields packed into
+ a single 128 bit field with 128 bit alignment.
+end:
+
+type: ulong3
+simple: ulong __attribute__((ext_vector_type(3)))
+summary: Three 64 bit unsigned integers
+description:
+ Vector version of the basic ulong type. Provides three ulong fields packed
+ into a single 256 bit field with 256 bit alignment.
+end:
+
+type: ulong4
+simple: ulong __attribute__((ext_vector_type(4)))
+summary: Four 64 bit unsigned integers
+description:
+ Vector version of the basic ulong type. Provides four ulong fields packed
+ into a single 256 bit field with 256 bit alignment.
+end:
+
+
+type: char2
+simple: char __attribute__((ext_vector_type(2)))
+summary: Two 8 bit signed integers
+description:
+ Vector version of the basic char type. Provides two char fields packed into a
+ single 16 bit field with 16 bit alignment.
+end:
+
+type: char3
+simple: char __attribute__((ext_vector_type(3)))
+summary: Three 8 bit signed integers
+description:
+ Vector version of the basic char type. Provides three char fields packed into
+ a single 32 bit field with 32 bit alignment.
+end:
+
+type: char4
+simple: char __attribute__((ext_vector_type(4)))
+summary: Four 8 bit signed integers
+description:
+ Vector version of the basic char type. Provides four char fields packed into
+ a single 32 bit field with 32 bit alignment.
+end:
+
+type: short2
+simple: short __attribute__((ext_vector_type(2)))
+summary: Two 16 bit signed integers
+description:
+ Vector version of the basic short type. Provides two short fields packed into
+ a single 32 bit field with 32 bit alignment.
+end:
+
+type: short3
+simple: short __attribute__((ext_vector_type(3)))
+summary: Three 16 bit signed integers
+description:
+ Vector version of the basic short type. Provides three short fields packed
+ into a single 64 bit field with 64 bit alignment.
+end:
+
+type: short4
+simple: short __attribute__((ext_vector_type(4)))
+summary: Four 16 bit signed integers
+description:
+ Vector version of the basic short type. Provides four short fields packed
+ into a single 64 bit field with 64 bit alignment.
+end:
+
+
+type: int2
+simple: int __attribute__((ext_vector_type(2)))
+summary: Two 32 bit signed integers
+description:
+ Vector version of the basic int type. Provides two int fields packed into a
+ single 64 bit field with 64 bit alignment.
+end:
+
+type: int3
+simple: int __attribute__((ext_vector_type(3)))
+summary: Three 32 bit signed integers
+description:
+ Vector version of the basic int type. Provides three int fields packed into a
+ single 128 bit field with 128 bit alignment.
+end:
+
+type: int4
+simple: int __attribute__((ext_vector_type(4)))
+summary: Four 32 bit signed integers
+description:
+ Vector version of the basic int type. Provides two four fields packed into a
+ single 128 bit field with 128 bit alignment.
+end:
+
+
+type: long2
+simple: long __attribute__((ext_vector_type(2)))
+summary: Two 64 bit signed integers
+description:
+ Vector version of the basic long type. Provides two long fields packed into a
+ single 128 bit field with 128 bit alignment.
+end:
+
+type: long3
+simple: long __attribute__((ext_vector_type(3)))
+summary: Three 64 bit signed integers
+description:
+ Vector version of the basic long type. Provides three long fields packed into
+ a single 256 bit field with 256 bit alignment.
+end:
+
+type: long4
+simple: long __attribute__((ext_vector_type(4)))
+summary: Four 64 bit signed integers
+description:
+ Vector version of the basic long type. Provides four long fields packed into
+ a single 256 bit field with 256 bit alignment.
+end:
diff --git a/api/rs_vector_math.spec b/api/rs_vector_math.spec
new file mode 100644
index 0000000..d25bb17
--- /dev/null
+++ b/api/rs_vector_math.spec
@@ -0,0 +1,197 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: TODO Add documentation
+description:
+ TODO Add documentation
+end:
+
+function: cross
+version: 9
+attrib: const
+w: 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Cross product of two vectors
+description:
+ Computes the cross product of two vectors.
+test: vector
+end:
+
+function: distance
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Distance between two points
+description:
+ Compute the distance between two points.
+
+ See also @fast_distance(), @native_distance().
+test: vector
+end:
+
+function: dot
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Dot product of two vectors
+description:
+ Computes the dot product of two vectors.
+test: vector
+end:
+
+function: fast_distance
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Approximate distance between two points
+description:
+ Computes the approximate distance between two points.
+
+ The precision is what would be expected from doing the computation using 16 bit floating point values.
+
+ See also @distance(), @native_distance().
+test: vector
+end:
+
+function: fast_length
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 v
+summary: Approximate length of a vector
+description:
+ Computes the approximate length of a vector.
+
+ The precision is what would be expected from doing the computation using 16 bit floating point values.
+
+ See also @length(), @native_length().
+test: vector
+end:
+
+function: fast_normalize
+version: 17
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Approximate normalized vector
+description:
+ Approximately normalizes a vector.
+
+ For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
+
+ The precision is what would be expected from doing the computation using 16 bit floating point values.
+
+ See also @normalize(), @native_normalize().
+test: vector
+end:
+
+function: length
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 v
+summary: Length of a vector
+description:
+ Computes the length of a vector.
+
+ See also @fast_length(), @native_length().
+test: vector
+end:
+
+function: native_distance
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 left_vector
+arg: #2#1 right_vector
+summary: Approximate distance between two points
+description:
+ Computes the approximate distance between two points.
+
+ See also @distance(), @fast_distance().
+test: vector
+end:
+
+function: native_length
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2
+arg: #2#1 v
+summary: Approximate length of a vector
+description:
+ Compute the approximate length of a vector.
+
+ See also @length(), @fast_length().
+test: vector
+end:
+
+function: native_normalize
+version: 21
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary:  Approximately normalize a vector
+description:
+ Approximately normalizes a vector.
+
+ See also @normalize(), @fast_normalize().
+test: vector
+end:
+
+function: normalize
+version: 9
+attrib: const
+w: 1, 2, 3, 4
+t: f32
+ret: #2#1
+arg: #2#1 v
+summary: Normalize a vector
+description:
+ Normalize a vector.
+
+ For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
+
+ See also @fast_normalize(), @native_normalize().
+test: vector
+end:
diff --git a/driver/runtime/arch/clamp.c b/driver/runtime/arch/clamp.c
index fc8f248..86d6f96 100644
--- a/driver/runtime/arch/clamp.c
+++ b/driver/runtime/arch/clamp.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "rs_types.rsh"
+#include "rs_core.rsh"
 
 typedef unsigned long long ull;
 typedef unsigned long long ull2 __attribute__((ext_vector_type(2)));
@@ -106,4 +106,3 @@
 V_CLAMP(ull);
 
 #undef _CLAMP
-
diff --git a/driver/runtime/arch/generic.c b/driver/runtime/arch/generic.c
index c7a717f..e178ed5 100644
--- a/driver/runtime/arch/generic.c
+++ b/driver/runtime/arch/generic.c
@@ -15,7 +15,7 @@
  */
 
 
-#include "rs_types.rsh"
+#include "rs_core.rsh"
 
 extern short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
 extern uchar4 __attribute__((overloadable)) convert_uchar4(short4);
diff --git a/driver/runtime/rs_cl.c b/driver/runtime/rs_cl.c
index a79ad2a..3296eed 100644
--- a/driver/runtime/rs_cl.c
+++ b/driver/runtime/rs_cl.c
@@ -1,4 +1,4 @@
-#include "rs_types.rsh"
+#include "rs_core.rsh"
 
 extern float2 __attribute__((overloadable)) convert_float2(int2 c);
 extern float3 __attribute__((overloadable)) convert_float3(int3 c);
diff --git a/driver/runtime/rs_core.c b/driver/runtime/rs_core.c
index 856c42b..bd0b2a1 100644
--- a/driver/runtime/rs_core.c
+++ b/driver/runtime/rs_core.c
@@ -1,5 +1,4 @@
 #include "rs_core.rsh"
-#include "rs_types.rsh"
 #include "rs_structs.h"
 
 #include "rsCpuCoreRuntime.h"
diff --git a/driver/runtime/rs_structs.h b/driver/runtime/rs_structs.h
index 76c2156..2d66190 100644
--- a/driver/runtime/rs_structs.h
+++ b/driver/runtime/rs_structs.h
@@ -1,6 +1,9 @@
 #ifndef _RS_STRUCTS_H_
 #define _RS_STRUCTS_H_
 
+#include "rs_core.rsh"
+#include "rs_graphics.rsh"
+
 /*****************************************************************************
  * CAUTION
  *
diff --git a/java/tests/RsCameraDemo/Android.mk b/java/tests/RsCameraDemo/Android.mk
new file mode 100644
index 0000000..877d2d2
--- /dev/null
+++ b/java/tests/RsCameraDemo/Android.mk
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+LOCAL_SDK_VERSION := 21
+
+LOCAL_PACKAGE_NAME := RsCameraDemo
+
+include $(BUILD_PACKAGE)
diff --git a/java/tests/RsCameraDemo/AndroidManifest.xml b/java/tests/RsCameraDemo/AndroidManifest.xml
new file mode 100644
index 0000000..2dd259d
--- /dev/null
+++ b/java/tests/RsCameraDemo/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>

+<manifest xmlns:android="http://schemas.android.com/apk/res/android"

+    package="com.android.example.rscamera.rscamera" >

+    <uses-feature android:name="android.hardware.camera" />

+    <uses-feature

+        android:name="android.hardware.camera.front"

+        android:required="false" />

+

+    <uses-permission android:name="android.permission.CAMERA" />

+    <uses-permission android:name="android.permission.RECORD_AUDIO" />

+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

+

+

+    <application

+        android:allowBackup="true"

+        android:icon="@drawable/camera"

+        android:label="@string/app_name"

+        android:theme="@style/AppTheme" >

+        <activity

+            android:name="com.android.example.rscamera.MainActivity"

+            android:label="@string/app_name" >

+            <intent-filter>

+                <action android:name="android.intent.action.MAIN" />

+

+                <category android:name="android.intent.category.LAUNCHER" />

+            </intent-filter>

+        </activity>

+    </application>

+

+</manifest>

diff --git a/java/tests/RsCameraDemo/_index.html b/java/tests/RsCameraDemo/_index.html
new file mode 100644
index 0000000..5f8c5f7
--- /dev/null
+++ b/java/tests/RsCameraDemo/_index.html
@@ -0,0 +1,6 @@
+<h1>RenderScript Camera Demo</h1>
+<h2>Am example camera with live processing in RenderScript</h2>
+<p> 
+This demonstrates focus peaking implemented in RenderScript
+</p>
+
diff --git a/java/tests/RsCameraDemo/res/anim/slide_in_from_left.xml b/java/tests/RsCameraDemo/res/anim/slide_in_from_left.xml
new file mode 100644
index 0000000..75d05bb
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/anim/slide_in_from_left.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shareInterpolator="false">
+
+    <translate
+        android:fromXDelta="-100%"
+        android:toXDelta="0%"
+        android:fromYDelta="0%"
+        android:toYDelta="0%"
+        android:duration="500" />
+
+</set>
diff --git a/java/tests/RsCameraDemo/res/anim/slide_out_to_right.xml b/java/tests/RsCameraDemo/res/anim/slide_out_to_right.xml
new file mode 100644
index 0000000..20ee06f
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/anim/slide_out_to_right.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shareInterpolator="false">
+    <translate
+    android:fromXDelta="0%"
+    android:toXDelta="100%"
+    android:fromYDelta="0%"
+    android:toYDelta="0%"
+    android:duration="500"/>
+
+</set>
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/res/drawable-hdpi/camera.png b/java/tests/RsCameraDemo/res/drawable-hdpi/camera.png
new file mode 100644
index 0000000..59908a6
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable-hdpi/camera.png
Binary files differ
diff --git a/java/tests/RsCameraDemo/res/drawable-mdpi/camera.png b/java/tests/RsCameraDemo/res/drawable-mdpi/camera.png
new file mode 100644
index 0000000..228cb96
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable-mdpi/camera.png
Binary files differ
diff --git a/java/tests/RsCameraDemo/res/drawable-xhdpi/camera.png b/java/tests/RsCameraDemo/res/drawable-xhdpi/camera.png
new file mode 100644
index 0000000..ca6c9f8
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable-xhdpi/camera.png
Binary files differ
diff --git a/java/tests/RsCameraDemo/res/drawable-xxhdpi/camera.png b/java/tests/RsCameraDemo/res/drawable-xxhdpi/camera.png
new file mode 100644
index 0000000..6534f06
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable-xxhdpi/camera.png
Binary files differ
diff --git a/java/tests/RsCameraDemo/res/drawable/ic_back.xml b/java/tests/RsCameraDemo/res/drawable/ic_back.xml
new file mode 100644
index 0000000..1cbfdb2
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable/ic_back.xml
@@ -0,0 +1,27 @@
+<!--
+Copyright (C) 2014 The Android Open Source Project
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0"
+    android:autoMirrored="true"
+     >
+    <!--android:tint="?attr/colorControlNormal">-->
+    <path
+        android:pathData="M20,11L7.8,11l5.6,-5.6L12,4l-8,8l8,8l1.4,-1.4L7.8,13L20,13L20,11z"
+        android:fillColor="@android:color/black"/>
+</vector>
diff --git a/java/tests/RsCameraDemo/res/drawable/ic_cam.xml b/java/tests/RsCameraDemo/res/drawable/ic_cam.xml
new file mode 100644
index 0000000..fbeedc6
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/drawable/ic_cam.xml
@@ -0,0 +1,28 @@
+<!--
+Copyright (C) 2014 The Android Open Source Project
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24.0dp"
+    android:height="24.0dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M12.0,12.0m-3.2,0.0a3.2,3.2 0.0,1.0 1.0,6.4 0.0a3.2,3.2 0.0,1.0 1.0,-6.4 0.0"/>
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M9.0,2.0l-1.83,2.0l-3.17,0.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,12.0c0.0,1.0 0.9,2.0 2.0,2.0l16.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0l0.0,-12.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0l-3.17,0.0l-1.83,-2.0l-6.0,0.0zm3.0,15.0c-2.76,0.0 -5.0,-2.24 -5.0,-5.0s2.24,-5.0 5.0,-5.0 5.0,2.24 5.0,5.0 -2.24,5.0 -5.0,5.0z"/>
+
+</vector>
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/res/layout/activity_main.xml b/java/tests/RsCameraDemo/res/layout/activity_main.xml
new file mode 100644
index 0000000..8ad2c0e
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/layout/activity_main.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!-- Copyright (C) 2015 The Android Open Source Project

+

+     Licensed under the Apache License, Version 2.0 (the "License");

+     you may not use this file except in compliance with the License.

+     You may obtain a copy of the License at

+

+          http://www.apache.org/licenses/LICENSE-2.0

+

+     Unless required by applicable law or agreed to in writing, software

+     distributed under the License is distributed on an "AS IS" BASIS,

+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+     See the License for the specific language governing permissions and

+     limitations under the License.

+-->

+

+<LinearLayout

+    android:orientation="horizontal"

+    android:layout_height="match_parent"

+    android:layout_width="match_parent"

+    xmlns:tools="http://schemas.android.com/tools"

+    xmlns:custom="http://schemas.android.com/apk/res-auto"

+    xmlns:android="http://schemas.android.com/apk/res/android"

+    android:id="@+id/panels">

+

+    <com.android.example.rscamera.CameraView

+        android:layout_height="wrap_content"

+        android:layout_width="0dp"

+        android:id="@+id/preview"

+        custom:aspectRatio="1.333"

+        android:layout_weight="4"

+        android:layout_gravity="center_vertical" />

+

+

+    <ViewFlipper

+        android:layout_height="match_parent"

+        android:layout_width="0px"

+        android:id="@+id/viewFlipper"

+        android:layout_weight="1">

+

+        <LinearLayout

+            android:orientation="vertical"

+            android:layout_height="match_parent"

+            android:layout_width="match_parent"

+            android:id="@+id/control_bar_contents">

+

+            <Button

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:id="@+id/iso"

+                android:layout_gravity="center_horizontal"

+                android:onClick="setISO"

+                android:text="A ISO 1600" />

+

+            <Button

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:id="@+id/speed"

+                android:layout_gravity="center_horizontal"

+                android:onClick="setShutterSpeed"

+                android:text="A 1/30 s" />

+

+            <Button

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:id="@+id/focus"

+                android:layout_gravity="center_horizontal"

+                android:onClick="setFocus"

+                android:text="A 12.0m" />

+

+            <ImageButton

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:layout_gravity="center_horizontal"

+                android:onClick="capture"

+                android:src="@drawable/ic_cam" />

+

+        </LinearLayout>

+

+        <LinearLayout

+            android:orientation="vertical"

+            android:layout_height="match_parent"

+            android:layout_width="match_parent"

+            android:id="@+id/slide">

+

+            <ImageButton

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:id="@+id/back"

+                android:layout_gravity="center_horizontal"

+                android:onClick="back"

+                android:src="@drawable/ic_back"

+                />

+

+            <ImageButton

+                android:layout_height="wrap_content"

+                android:layout_width="match_parent"

+                android:id="@+id/capture"

+                android:layout_gravity="center_horizontal"

+                android:onClick="capture"

+                android:src="@drawable/ic_cam" />

+

+            <RelativeLayout

+                android:layout_height="match_parent"

+                android:layout_width="match_parent">

+

+                <com.android.example.rscamera.VerticalSeekBar

+                    android:layout_height="match_parent"

+                    android:layout_width="wrap_content"

+                    android:id="@+id/focusbar"

+                    android:layout_alignParentTop="true"

+                    android:layout_centerInParent="true" />

+

+            </RelativeLayout>

+

+        </LinearLayout>

+

+    </ViewFlipper>

+

+</LinearLayout>
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/res/values-v21/styles.xml b/java/tests/RsCameraDemo/res/values-v21/styles.xml
new file mode 100644
index 0000000..f9166cc
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values-v21/styles.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>

+<!-- Copyright (C) 2015 The Android Open Source Project

+

+     Licensed under the Apache License, Version 2.0 (the "License");

+     you may not use this file except in compliance with the License.

+     You may obtain a copy of the License at

+

+          http://www.apache.org/licenses/LICENSE-2.0

+

+     Unless required by applicable law or agreed to in writing, software

+     distributed under the License is distributed on an "AS IS" BASIS,

+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+     See the License for the specific language governing permissions and

+     limitations under the License.

+-->

+<resources>

+    <style name="AppTheme" parent="android:Theme.Material.Light">

+    </style>

+</resources>

diff --git a/java/tests/RsCameraDemo/res/values-w820dp/dimens.xml b/java/tests/RsCameraDemo/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..62df187
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>

+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml

+         (such as screen margins) for screens with more than 820dp of available width. This

+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->

+    <dimen name="activity_horizontal_margin">64dp</dimen>

+</resources>

diff --git a/java/tests/RsCameraDemo/res/values/attrs.xml b/java/tests/RsCameraDemo/res/values/attrs.xml
new file mode 100644
index 0000000..9221607
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values/attrs.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+    <declare-styleable name="FixedAspectSurfaceView">
+        <attr name="aspectRatio" format="float"/>
+    </declare-styleable>
+</resources>
diff --git a/java/tests/RsCameraDemo/res/values/base-strings.xml b/java/tests/RsCameraDemo/res/values/base-strings.xml
new file mode 100644
index 0000000..d8f8952
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values/base-strings.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+    <string name="app_name">RS Camera</string>
+    <string name="intro_message">
+        <![CDATA[
+        
+            
+            This demo implements a real-time high-dynamic-range camera viewfinder, by alternating
+            the sensor\'s exposure time between two exposure values on even and odd frames, and then
+            compositing together the latest two frames whenever a new frame is captured.
+            
+        
+        ]]>
+    </string>
+</resources>
diff --git a/java/tests/RsCameraDemo/res/values/strings.xml b/java/tests/RsCameraDemo/res/values/strings.xml
new file mode 100644
index 0000000..21838d5
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values/strings.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+     Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <string name="help_button">Help</string>
+
+    <string-array name="mode_label_array">
+        <!-- must be in same order as ViewfinderProcessor.MODE_ ints -->
+        <item>Mode: Normal</item>
+        <item>Mode: Split</item>
+        <item>Mode: HDR</item>
+    </string-array>
+
+    <string name="auto_exposure_label">Auto exp. time:</string>
+    <string name="even_exposure_label">Even exp. time:</string>
+    <string name="odd_exposure_label">Odd exp. time:</string>
+
+    <string name="help_text">
+      <b>HDR Viewfinder Demo:</b>\n\n
+
+      Tap viewfinder to switch modes.\n\n
+
+      <b>Normal:</b> Standard camera preview\n
+      <b>Split:</b> Manual exposure control\n
+      <b>HDR:</b> Fused HDR viewfinder\n\n
+
+      Swipe up/down in Split/HDR modes to change manual exposure
+      values.\n\n
+
+      The left half of the viewfinder controls exposure time for
+      even-numbered frames, and the right half of the viewfinder
+      controls exposure time for odd-numbered frames
+    </string>
+
+    <string name="info">Info</string>
+
+    <string name="camera_no_good">No back-facing sufficiently capable camera available!</string>
+    <string name="camera_disabled">Camera is disabled by device policy</string>
+    <string name="camera_disconnected">Camera was disconnected before it was opened</string>
+    <string name="camera_error">Camera service reported an error</string>
+    <string name="camera_unknown">Unknown camera error: %s</string>
+
+</resources>
diff --git a/java/tests/RsCameraDemo/res/values/template-dimens.xml b/java/tests/RsCameraDemo/res/values/template-dimens.xml
new file mode 100644
index 0000000..291c495
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values/template-dimens.xml
@@ -0,0 +1,31 @@
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <!-- Define standard dimensions to comply with Holo-style grids and rhythm. -->
+
+    <dimen name="margin_tiny">4dp</dimen>
+    <dimen name="margin_small">8dp</dimen>
+    <dimen name="margin_medium">16dp</dimen>
+    <dimen name="margin_large">32dp</dimen>
+    <dimen name="margin_huge">64dp</dimen>
+
+    <!-- Semantic definitions -->
+
+    <dimen name="horizontal_page_margin">@dimen/margin_medium</dimen>
+    <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
+
+</resources>
diff --git a/java/tests/RsCameraDemo/res/values/template-styles.xml b/java/tests/RsCameraDemo/res/values/template-styles.xml
new file mode 100644
index 0000000..c6dc473
--- /dev/null
+++ b/java/tests/RsCameraDemo/res/values/template-styles.xml
@@ -0,0 +1,36 @@
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <!-- Activity themes -->
+
+    <style name="Theme.Base" parent="android:Theme.Light" />
+
+    <style name="Theme.Sample" parent="Theme.Base" />
+
+    <style name="AppTheme" parent="Theme.Sample" />
+    <!-- Widget styling -->
+
+    <style name="Widget" />
+
+    <style name="Widget.SampleMessage">
+        <item name="android:textAppearance">?android:textAppearanceMedium</item>
+        <item name="android:lineSpacingMultiplier">1.1</item>
+    </style>
+
+
+
+</resources>
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraOps.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraOps.java
new file mode 100644
index 0000000..d9ea9e8
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraOps.java
@@ -0,0 +1,671 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.rscamera;
+
+import android.content.ContentResolver;
+import android.graphics.ImageFormat;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.TotalCaptureResult;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.Image;
+import android.media.ImageReader;
+import android.os.ConditionVariable;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.util.Log;
+import android.util.Range;
+import android.util.Size;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.widget.Toast;
+
+import com.android.example.rscamera.rscamera.R;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Simple interface for operating the camera, with major camera operations
+ * all performed on a background handler thread.
+ */
+public class CameraOps {
+
+    private static final String TAG = "CameraOps";
+    private static final long ONE_SECOND = 1000000000;
+    public static final long CAMERA_CLOSE_TIMEOUT = 2000; // ms
+
+    private final CameraManager mCameraManager;
+    private CameraDevice mCameraDevice;
+    private CameraCaptureSession mCameraSession;
+    private List<Surface> mSurfaces;
+
+    private final ConditionVariable mCloseWaiter = new ConditionVariable();
+
+    private HandlerThread mCameraThread;
+    private Handler mCameraHandler;
+
+    private final ErrorDisplayer mErrorDisplayer;
+
+    private final CameraReadyListener mReadyListener;
+    private final Handler mReadyHandler;
+
+    private int mISOmax;
+    private int mISOmin;
+    private long mExpMax;
+    private long mExpMin;
+    private float mFocusMin;
+    private float mFocusDist = 0;
+    private int mIso;
+    boolean mAutoExposure = true;
+    boolean mAutoFocus = true;
+    private long mExposure = ONE_SECOND / 33;
+
+    private Object mAutoExposureTag = new Object();
+
+    private ImageReader mImageReader;
+    private Handler mBackgroundHandler;
+    private CameraCharacteristics mCameraInfo;
+    private HandlerThread mBackgroundThread;
+    CaptureRequest.Builder mHdrBuilder;
+    private Surface mProcessingNormalSurface;
+    CaptureRequest mPreviewRequest;
+    private String mSaveFileName;
+    private ContentResolver mContentResolver;
+
+    public String resume() {
+        String errorMessage = "Unknown error";
+        boolean foundCamera = false;
+        try {
+            // Find first back-facing camera that has necessary capability
+            String[] cameraIds = mCameraManager.getCameraIdList();
+            for (String id : cameraIds) {
+                CameraCharacteristics info = mCameraManager.getCameraCharacteristics(id);
+                int facing = info.get(CameraCharacteristics.LENS_FACING);
+
+                int level = info.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+                boolean hasFullLevel
+                        = (level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
+
+                int[] capabilities = info.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
+                int syncLatency = info.get(CameraCharacteristics.SYNC_MAX_LATENCY);
+                boolean hasManualControl = hasCapability(capabilities,
+                        CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR);
+                boolean hasEnoughCapability = hasManualControl &&
+                        syncLatency == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL;
+                Range<Integer> irange;
+                Range<Long> lrange;
+
+                irange = info.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
+                mISOmax = irange.getUpper();
+                mISOmin = irange.getLower();
+                lrange = info.get(CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE);
+                mExpMax = lrange.getUpper();
+                mExpMin = lrange.getLower();
+                mFocusMin = info.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+
+                mFocusDist = mFocusMin;
+                StreamConfigurationMap map = info.get(
+                        CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+                Size[] sizes = map.getOutputSizes(ImageFormat.JPEG);
+                Size largest = Collections.max(Arrays.asList(sizes), new Comparator<Size>() {
+                    @Override
+                    public int compare(Size lhs, Size rhs) {
+                        int leftArea = lhs.getHeight() * lhs.getWidth();
+                        int rightArea = lhs.getHeight() * lhs.getWidth();
+                        return Integer.compare(leftArea, rightArea);
+                    }
+                });
+                mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(),
+                        ImageFormat.JPEG, /*maxImages*/2);
+                mImageReader.setOnImageAvailableListener(
+                        mOnImageAvailableListener, mBackgroundHandler);
+
+                if (facing == CameraCharacteristics.LENS_FACING_BACK &&
+                        (hasFullLevel || hasEnoughCapability)) {
+                    // Found suitable camera - get info, open, and set up outputs
+                    mCameraInfo = info;
+                    openCamera(id);
+                    foundCamera = true;
+                    break;
+                }
+            }
+            if (!foundCamera) {
+                errorMessage = "no back camera";
+            }
+        } catch (CameraAccessException e) {
+            errorMessage = e.getMessage();
+        }
+        // startBackgroundThread
+        mBackgroundThread = new HandlerThread("CameraBackground");
+        mBackgroundThread.start();
+        mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
+        return (foundCamera) ? null : errorMessage;
+    }
+
+
+    private boolean hasCapability(int[] capabilities, int capability) {
+        for (int c : capabilities) {
+            if (c == capability) return true;
+        }
+        return false;
+    }
+
+    private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
+            = new ImageReader.OnImageAvailableListener() {
+
+        @Override
+        public void onImageAvailable(ImageReader reader) {
+            mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mSaveFileName, mContentResolver));
+        }
+
+    };
+
+    /**
+     * Saves a JPEG {@link android.media.Image} into the specified {@link java.io.File}.
+     */
+    private static class ImageSaver implements Runnable {
+        private final Image mImage;
+        private final String mName;
+        ContentResolver mContentResolver;
+
+        public ImageSaver(Image image, String fileName, ContentResolver contentResolver) {
+            mImage = image;
+            mName = fileName;
+            mContentResolver = contentResolver;
+        }
+
+        @Override
+        public void run() {
+            Log.v(TAG, "SAVING...");
+            MediaStoreSaver.insertImage(mContentResolver, new MediaStoreSaver.StreamWriter() {
+                @Override
+                public void write(OutputStream imageOut) throws IOException {
+                    try {
+                        ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
+                        byte[] bytes = new byte[buffer.remaining()];
+                        buffer.get(bytes);
+                        imageOut.write(bytes);
+                    } finally {
+                        mImage.close();
+                    }
+                }
+            }, mName, "Saved from Simple Camera Demo");
+        }
+    }
+
+    /**
+     * Create a new camera ops thread.
+     *
+     * @param errorDisplayer listener for displaying error messages
+     * @param readyListener  listener for notifying when camera is ready for requests
+     */
+    CameraOps(CameraManager manager, ErrorDisplayer errorDisplayer,
+              CameraReadyListener readyListener) {
+        mReadyHandler = new Handler(Looper.getMainLooper());
+
+        mCameraThread = new HandlerThread("CameraOpsThread");
+        mCameraThread.start();
+
+        if (manager == null || errorDisplayer == null ||
+                readyListener == null || mReadyHandler == null) {
+            throw new IllegalArgumentException("Need valid displayer, listener, handler");
+        }
+
+        mCameraManager = manager;
+        mErrorDisplayer = errorDisplayer;
+        mReadyListener = readyListener;
+
+    }
+
+    /**
+     * Open the first backfacing camera listed by the camera manager.
+     * Displays a dialog if it cannot open a camera.
+     */
+    public void openCamera(final String cameraId) {
+        mCameraHandler = new Handler(mCameraThread.getLooper());
+
+        mCameraHandler.post(new Runnable() {
+            public void run() {
+                if (mCameraDevice != null) {
+                    throw new IllegalStateException("Camera already open");
+                }
+                try {
+
+                    mCameraManager.openCamera(cameraId, mCameraDeviceListener, mCameraHandler);
+                } catch (CameraAccessException e) {
+                    String errorMessage = mErrorDisplayer.getErrorString(e);
+                    mErrorDisplayer.showErrorDialog(errorMessage);
+                }
+            }
+        });
+    }
+
+    public void pause() {
+        closeCameraAndWait();
+        mBackgroundThread.quitSafely();
+        try {
+            mBackgroundThread.join();
+            mBackgroundThread = null;
+            mBackgroundHandler = null;
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public Size getBestSize() {
+        // Find a good size for output - largest 16:9 aspect ratio that's less than 720p
+        final int MAX_WIDTH = 1280;
+        final float TARGET_ASPECT = 16.f / 9.f;
+        final float ASPECT_TOLERANCE = 0.1f;
+
+
+        StreamConfigurationMap configs =
+                mCameraInfo.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+
+        Size[] outputSizes = configs.getOutputSizes(SurfaceHolder.class);
+
+        Size outputSize = outputSizes[0];
+        float outputAspect = (float) outputSize.getWidth() / outputSize.getHeight();
+        for (Size candidateSize : outputSizes) {
+            if (candidateSize.getWidth() > MAX_WIDTH) continue;
+            float candidateAspect = (float) candidateSize.getWidth() / candidateSize.getHeight();
+            boolean goodCandidateAspect =
+                    Math.abs(candidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
+            boolean goodOutputAspect =
+                    Math.abs(outputAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
+            if ((goodCandidateAspect && !goodOutputAspect) ||
+                    candidateSize.getWidth() > outputSize.getWidth()) {
+                outputSize = candidateSize;
+                outputAspect = candidateAspect;
+            }
+        }
+        return outputSize;
+    }
+
+    /**
+     * Close the camera and wait for the close callback to be called in the camera thread.
+     * Times out after @{value CAMERA_CLOSE_TIMEOUT} ms.
+     */
+    public void closeCameraAndWait() {
+        mCloseWaiter.close();
+        mCameraHandler.post(mCloseCameraRunnable);
+        boolean closed = mCloseWaiter.block(CAMERA_CLOSE_TIMEOUT);
+        if (!closed) {
+            Log.e(TAG, "Timeout closing camera");
+        }
+    }
+
+    private Runnable mCloseCameraRunnable = new Runnable() {
+        public void run() {
+            if (mCameraDevice != null) {
+                mCameraDevice.close();
+            }
+            mCameraDevice = null;
+            mCameraSession = null;
+            mSurfaces = null;
+        }
+    };
+
+    /**
+     * Set the output Surfaces, and finish configuration if otherwise ready.
+     */
+    public void setSurface(Surface surface) {
+        final List<Surface> surfaceList = new ArrayList<Surface>();
+        surfaceList.add(surface);
+        surfaceList.add(mImageReader.getSurface());
+
+        mCameraHandler.post(new Runnable() {
+            public void run() {
+                mSurfaces = surfaceList;
+                startCameraSession();
+            }
+        });
+    }
+
+    /**
+     * Get a request builder for the current camera.
+     */
+    public CaptureRequest.Builder createCaptureRequest(int template) throws CameraAccessException {
+        CameraDevice device = mCameraDevice;
+        if (device == null) {
+            throw new IllegalStateException("Can't get requests when no camera is open");
+        }
+        return device.createCaptureRequest(template);
+    }
+
+    /**
+     * Set a repeating request.
+     */
+    public void setRepeatingRequest(final CaptureRequest request,
+                                    final CameraCaptureSession.CaptureCallback listener,
+                                    final Handler handler) {
+        mCameraHandler.post(new Runnable() {
+            public void run() {
+                try {
+                    mCameraSession.setRepeatingRequest(request, listener, handler);
+                } catch (CameraAccessException e) {
+                    String errorMessage = mErrorDisplayer.getErrorString(e);
+                    mErrorDisplayer.showErrorDialog(errorMessage);
+                }
+            }
+        });
+    }
+
+    /**
+     * Set a repeating request.
+     */
+    public void setRepeatingBurst(final List<CaptureRequest> requests,
+                                  final CameraCaptureSession.CaptureCallback listener,
+                                  final Handler handler) {
+        mCameraHandler.post(new Runnable() {
+            public void run() {
+                try {
+                    mCameraSession.setRepeatingBurst(requests, listener, handler);
+
+                } catch (CameraAccessException e) {
+                    String errorMessage = mErrorDisplayer.getErrorString(e);
+                    mErrorDisplayer.showErrorDialog(errorMessage);
+                }
+            }
+        });
+    }
+
+    /**
+     * Configure the camera session.
+     */
+    private void startCameraSession() {
+        // Wait until both the camera device is open and the SurfaceView is ready
+        if (mCameraDevice == null || mSurfaces == null) return;
+
+        try {
+
+            mCameraDevice.createCaptureSession(
+                    mSurfaces, mCameraSessionListener, mCameraHandler);
+        } catch (CameraAccessException e) {
+            String errorMessage = mErrorDisplayer.getErrorString(e);
+            mErrorDisplayer.showErrorDialog(errorMessage);
+            mCameraDevice.close();
+            mCameraDevice = null;
+        }
+    }
+
+    /**
+     * Main listener for camera session events
+     * Invoked on mCameraThread
+     */
+    private CameraCaptureSession.StateCallback mCameraSessionListener =
+            new CameraCaptureSession.StateCallback() {
+
+                @Override
+                public void onConfigured(CameraCaptureSession session) {
+                    mCameraSession = session;
+                    mReadyHandler.post(new Runnable() {
+                        public void run() {
+                            // This can happen when the screen is turned off and turned back on.
+                            if (null == mCameraDevice) {
+                                return;
+                            }
+
+                            mReadyListener.onCameraReady();
+                        }
+                    });
+
+                }
+
+                @Override
+                public void onConfigureFailed(CameraCaptureSession session) {
+                    mErrorDisplayer.showErrorDialog("Unable to configure the capture session");
+                    mCameraDevice.close();
+                    mCameraDevice = null;
+                }
+            };
+
+    /**
+     * Main listener for camera device events.
+     * Invoked on mCameraThread
+     */
+    private CameraDevice.StateCallback mCameraDeviceListener = new CameraDevice.StateCallback() {
+
+        @Override
+        public void onOpened(CameraDevice camera) {
+            mCameraDevice = camera;
+            startCameraSession();
+        }
+
+        @Override
+        public void onClosed(CameraDevice camera) {
+            mCloseWaiter.open();
+        }
+
+        @Override
+        public void onDisconnected(CameraDevice camera) {
+            mErrorDisplayer.showErrorDialog("The camera device has been disconnected.");
+            camera.close();
+            mCameraDevice = null;
+        }
+
+        @Override
+        public void onError(CameraDevice camera, int error) {
+            mErrorDisplayer.showErrorDialog("The camera encountered an error:" + error);
+            camera.close();
+            mCameraDevice = null;
+        }
+
+    };
+
+    public void captureStillPicture(int currentJpegRotation, String name, ContentResolver resolver) {
+        mSaveFileName = name;
+        mContentResolver = resolver;
+        try {
+            // TODO call lock focus if we are in "AF-S(One-Shot AF) mode"
+            // TODO call precapture if we are using flash
+            // This is the CaptureRequest.Builder that we use to take a picture.
+            final CaptureRequest.Builder captureBuilder =
+                    createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
+            Log.v(TAG, " Target " + mImageReader.getWidth() + "," + mImageReader.getHeight());
+
+            captureBuilder.addTarget(mImageReader.getSurface());
+
+            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, currentJpegRotation);
+
+            CameraCaptureSession.CaptureCallback captureCallback
+                    = new CameraCaptureSession.CaptureCallback() {
+
+                @Override
+                public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+                                               TotalCaptureResult result) {
+                    Log.v(TAG, " onCaptureCompleted");
+                    setParameters();
+                }
+            };
+
+
+            setRequest(captureBuilder.build(), captureCallback, null);
+        } catch (CameraAccessException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Set a repeating request.
+     */
+    private void setRequest(final CaptureRequest request,
+                            final CameraCaptureSession.CaptureCallback listener,
+                            final Handler handler) {
+        mCameraHandler.post(new Runnable() {
+            public void run() {
+                try {
+                    mCameraSession.stopRepeating();
+                    mCameraSession.capture(request, listener, handler);
+                } catch (CameraAccessException e) {
+                    String errorMessage = mErrorDisplayer.getErrorString(e);
+                    mErrorDisplayer.showErrorDialog(errorMessage);
+                }
+            }
+        });
+    }
+
+    public void setUpCamera(Surface processingNormalSurface) {
+        mProcessingNormalSurface = processingNormalSurface;
+        // Ready to send requests in, so set them up
+        try {
+            CaptureRequest.Builder previewBuilder =
+                    createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+            previewBuilder.addTarget(mProcessingNormalSurface);
+            previewBuilder.setTag(mAutoExposureTag);
+            mPreviewRequest = previewBuilder.build();
+            mHdrBuilder = createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+            mHdrBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+                    CaptureRequest.CONTROL_AE_MODE_OFF);
+            mHdrBuilder.addTarget(mProcessingNormalSurface);
+            setParameters();
+
+        } catch (CameraAccessException e) {
+            String errorMessage = e.getMessage();
+            // MessageDialogFragment.newInstance(errorMessage).show(getFragmentManager(), FRAGMENT_DIALOG);
+        }
+    }
+
+    /**
+     * Start running an HDR burst on a configured camera session
+     */
+    public void setParameters() {
+        if (mHdrBuilder == null) {
+            Log.v(TAG," Camera not set up");
+            return;
+        }
+        if (mAutoExposure) {
+            mHdrBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, ONE_SECOND / 30);
+            mHdrBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, getExposure());
+            mHdrBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
+        } else {
+            mHdrBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
+            mHdrBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, ONE_SECOND / 30);
+            mHdrBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, getExposure());
+            mHdrBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, getIso());
+        }
+        if (mAutoFocus) {
+            mHdrBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
+            mHdrBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
+        } else {
+            mHdrBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+            mHdrBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, getFocusDistance());
+            mHdrBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
+        }
+
+        setRepeatingRequest(mHdrBuilder.build(), mCaptureCallback, mReadyHandler);
+    }
+
+    private CameraCaptureSession.CaptureCallback mCaptureCallback
+            = new CameraCaptureSession.CaptureCallback() {
+
+        public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+                                       TotalCaptureResult result) {
+        }
+    };
+
+    /**
+     * Simple listener for main code to know the camera is ready for requests, or failed to
+     * start.
+     */
+    public interface CameraReadyListener {
+        public void onCameraReady();
+    }
+
+    /**
+     * Simple listener for displaying error messages
+     */
+    public interface ErrorDisplayer {
+        public void showErrorDialog(String errorMessage);
+        public String getErrorString(CameraAccessException e);
+    }
+
+    public float getFocusDistance() {
+        return mFocusDist;
+    }
+
+    public void setFocusDistance(float focusDistance) {
+        mFocusDist = focusDistance;
+    }
+
+    public void setIso(int iso) {
+        mIso = iso;
+    }
+
+    public boolean isAutoExposure() {
+        return mAutoExposure;
+    }
+
+    public void setAutoExposure(boolean autoExposure) {
+        mAutoExposure = autoExposure;
+    }
+
+    public boolean isAutoFocus() {
+        return mAutoFocus;
+    }
+
+    public void setAutoFocus(boolean autoFocus) {
+        mAutoFocus = autoFocus;
+    }
+
+    public int getIso() {
+        return mIso;
+    }
+
+    public long getExposure() {
+        return mExposure;
+    }
+
+    public void setExposure(long exposure) {
+        mExposure = exposure;
+    }
+
+    public int getIsoMax() {
+        return mISOmax;
+    }
+
+    public int getIsoMin() {
+        return mISOmin;
+    }
+
+    public long getExpMax() {
+        return mExpMax;
+    }
+
+    public long getExpMin() {
+        return mExpMin;
+    }
+
+    public float getFocusMin() {
+        return mFocusMin;
+    }
+}
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraView.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraView.java
new file mode 100644
index 0000000..3f79ba7
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/CameraView.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.rscamera;
+
+import android.app.Activity;
+import android.content.Context;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.TotalCaptureResult;
+import android.renderscript.RenderScript;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.Size;
+import android.view.MotionEvent;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.View;
+
+import com.android.example.rscamera.rscamera.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by hoford on 2/27/15.
+ */
+public class CameraView extends FixedAspectSurfaceView {
+    private static final String TAG = "CameraPreView";
+
+    private static final long MICRO_SECOND = 1000;
+    private static final long MILLI_SECOND = MICRO_SECOND * 1000;
+    private static final long ONE_SECOND = MILLI_SECOND * 1000;
+
+    private Surface mPreviewSurface;
+    ViewfinderProcessor mProcessor;
+    private Surface mProcessingNormalSurface;
+    CameraOps mCameraOps;
+    CameraManager mCameraManager;
+    Activity mActivity;
+    Context mContext;
+    byte mode = 0;
+    public static final byte MODE_NONE = 0;
+    public static final byte MODE_SPEED = 1;
+    public static final byte MODE_FOCUS = 2;
+    public static final byte MODE_ISO = 3;
+    RenderScript mRS;
+    ErrorCallback mErrorCallback;
+    ParametersChangedCallback mParametersChangedCallback;
+
+    public CameraView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        mContext = context;
+
+        mRS = RenderScript.create(mContext);
+        SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
+            @Override
+            public void surfaceCreated(SurfaceHolder holder) {
+            }
+
+            @Override
+            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+                mPreviewSurface = holder.getSurface();
+                setupProcessor();
+            }
+
+            @Override
+            public void surfaceDestroyed(SurfaceHolder holder) {
+                mPreviewSurface = null;
+            }
+        };
+        getHolder().addCallback(callback);
+        mCameraManager = (CameraManager) mContext.getSystemService(mContext.CAMERA_SERVICE);
+
+        CameraOps.ErrorDisplayer errorDisplayer = new CameraOps.ErrorDisplayer() {
+
+            @Override
+            public void showErrorDialog(String errorMessage) {
+                Log.v(TAG, "ERROR");
+                if (mErrorCallback != null) {
+                    mErrorCallback.showError(errorMessage);
+                }
+                //MessageDialogFragment.newInstance(errorMessage).show(getFragmentManager(), FRAGMENT_DIALOG);
+            }
+
+            @Override
+            public String getErrorString(CameraAccessException e) {
+                switch (e.getReason()) {
+                    case CameraAccessException.CAMERA_DISABLED:
+                        return mContext.getString(R.string.camera_disabled);
+                    case CameraAccessException.CAMERA_DISCONNECTED:
+                        return mContext.getString(R.string.camera_disconnected);
+                    case CameraAccessException.CAMERA_ERROR:
+                        return mContext.getString(R.string.camera_error);
+                    default:
+                        return mContext.getString(R.string.camera_unknown, e.getReason());
+
+                }
+            }
+        };
+
+        CameraOps.CameraReadyListener cameraReadyListener = new CameraOps.CameraReadyListener() {
+            @Override
+            public void onCameraReady() {
+                mCameraOps.setUpCamera(mProcessingNormalSurface);
+            }
+        };
+        setOnTouchListener(new View.OnTouchListener() {
+            @Override
+            public boolean onTouch(View v, MotionEvent event) {
+                return touchScreen(event);
+            }
+        });
+        mCameraOps = new CameraOps(mCameraManager,
+                errorDisplayer,
+                cameraReadyListener);
+    }
+
+    public void resume(Activity activity) {
+        mActivity = activity;
+
+        String errorMessage = mCameraOps.resume();
+        if (errorMessage != null) {
+            if (mErrorCallback != null) {
+                mErrorCallback.showError(errorMessage);
+            }
+        } else {
+
+            Size outputSize = mCameraOps.getBestSize();
+            mProcessor = new ViewfinderProcessor(mRS, outputSize);
+            // Configure the output view - this will fire surfaceChanged
+            setAspectRatio((float) outputSize.getWidth() / outputSize.getHeight());
+            getHolder().setFixedSize(outputSize.getWidth(), outputSize.getHeight());
+        }
+    }
+
+    public void pause() {
+        mCameraOps.pause();
+    }
+
+    /**
+     * Once camera is open and output surfaces are ready, configure the RS processing
+     * and the camera device inputs/outputs.
+     */
+    private void setupProcessor() {
+        if (mProcessor == null || mPreviewSurface == null) return;
+        mProcessor.setOutputSurface(mPreviewSurface);
+        mProcessingNormalSurface = mProcessor.getInputSurface();
+        mCameraOps.setSurface(mProcessingNormalSurface);
+    }
+
+    public void takePicture() {
+        // Orientation
+        int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
+        int jpegRotation = Surface.ROTATION_0;
+        switch (rotation) {
+            case 90:
+                jpegRotation = Surface.ROTATION_0;
+                break;
+            case 0:
+                jpegRotation = Surface.ROTATION_90;
+                break;
+            case 180:
+                jpegRotation = Surface.ROTATION_270;
+                break;
+            case 270:
+                jpegRotation = Surface.ROTATION_180;
+                break;
+        }
+        String name = "Simple" + System.currentTimeMillis() + ".jpg";
+        mCameraOps.captureStillPicture(jpegRotation, name, mContext.getContentResolver());
+    }
+
+    private CameraCaptureSession.CaptureCallback mPhotoCallback
+            = new CameraCaptureSession.CaptureCallback() {
+
+        public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+                                       TotalCaptureResult result) {
+            Log.v(TAG, "onCaptureCompleted " + result.toString());
+        }
+    };
+
+    float mDownY;
+    long mExposureDown;
+    float mFocusDistDown;
+
+    public boolean touchScreen(MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_DOWN) {
+            mDownY = event.getY();
+            mExposureDown = mCameraOps.getExposure();
+            mFocusDistDown = mCameraOps.getFocusDistance();
+            if (mFocusDistDown == 0.0) {
+                mFocusDistDown = 0.01f;
+            }
+        }
+        float distanceY = event.getY() - mDownY;
+        float width = getWidth();
+        float height = getHeight();
+
+        float yDistNorm = distanceY / height;
+
+        float ACCELERATION_FACTOR = 8;
+        float scaleFactor = (float) Math.pow(2.f, yDistNorm * ACCELERATION_FACTOR);
+
+        switch (mode) {
+            case MODE_SPEED:
+                long exp = (long) (mExposureDown * scaleFactor);
+                exp = Math.min(mCameraOps.getExpMax(), exp);
+                mCameraOps.setExposure(Math.max(mCameraOps.getExpMin(), exp));
+                Log.v(TAG, "mExposure =" + mCameraOps.getExposure());
+                break;
+            case MODE_FOCUS:
+                float focusDist = mFocusDistDown * scaleFactor;
+                focusDist = Math.max(0.0f, Math.min(mCameraOps.getFocusMin(), focusDist));
+                if (focusDist < 0.01) focusDist = 0;
+                mCameraOps.setFocusDistance(focusDist);
+                Log.v(TAG, "mFocusDist =" + focusDist);
+                break;
+            case MODE_ISO:
+                ACCELERATION_FACTOR = 2;
+                scaleFactor = (float) Math.pow(2.f, yDistNorm * ACCELERATION_FACTOR);
+                int iso = (int) (getIso() * scaleFactor);
+                iso = Math.min(mCameraOps.getIsoMax(), iso);
+                mCameraOps.setIso(Math.max(mCameraOps.getIsoMin(), iso));
+                break;
+        }
+
+        if (mParametersChangedCallback != null) {
+            mParametersChangedCallback.parametersChanged();
+        }
+        mCameraOps.setParameters();
+
+        return true;
+    }
+
+    public void setMode(byte mode) {
+        this.mode = mode;
+    }
+
+    public byte getMode() {
+        return mode;
+    }
+
+    public int getIso() {
+        return mCameraOps.getIso();
+    }
+
+    public void setIso(int iso) {
+        mCameraOps.setIso(iso);
+        if (mParametersChangedCallback != null) {
+            mParametersChangedCallback.parametersChanged();
+        }
+        mCameraOps.setParameters();
+    }
+
+    public long getExposure() {
+        return mCameraOps.getExposure();
+    }
+
+    public void setExposure(long exposure) {
+        mCameraOps.setExposure(exposure);
+        if (mParametersChangedCallback != null) {
+            mParametersChangedCallback.parametersChanged();
+        }
+        mCameraOps.setParameters();
+    }
+
+    public float getFocusDist() {
+        return mCameraOps.getFocusDistance();
+    }
+
+    public void setFocusInMeters(float dist) {
+        float min = mCameraOps.getFocusMin();
+        float d = 10 / (dist + 10 / min);
+        setFocusDist(d);
+    }
+
+    public void setFocusDist(float dist) {
+        mCameraOps.setFocusDistance(dist);
+        mCameraOps.setParameters();
+    }
+
+    public float getMinFocusDistance() {
+        return mCameraOps.getFocusMin();
+    }
+
+    public void setAutofocus(boolean autofocus) {
+        mCameraOps.setAutoFocus(autofocus);
+        mCameraOps.setParameters();
+    }
+
+    public boolean isAutoExposure() {
+        return mCameraOps.isAutoExposure();
+    }
+
+    public boolean isAutofocus() {
+        return mCameraOps.isAutoFocus();
+    }
+
+    public void setAutoExposure(boolean autoExposure) {
+        mCameraOps.setAutoExposure(autoExposure);
+        mCameraOps.setParameters();
+    }
+
+    public static interface ErrorCallback {
+        public void showError(String errorMessage);
+    }
+
+    public void setErrorCallback(ErrorCallback errorCallback) {
+        mErrorCallback = errorCallback;
+    }
+
+    public static interface ParametersChangedCallback {
+        public void parametersChanged();
+    }
+
+    public void setParametersChangedCallback(ParametersChangedCallback parametersChangedCallback) {
+        mParametersChangedCallback = parametersChangedCallback;
+    }
+
+    float getFps() {
+        return mProcessor.getmFps();
+    }
+}
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/FixedAspectSurfaceView.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/FixedAspectSurfaceView.java
new file mode 100644
index 0000000..dd72c86
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/FixedAspectSurfaceView.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.example.rscamera;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+
+import com.android.example.rscamera.rscamera.R;
+
+/**
+ * A SurfaceView that maintains its aspect ratio to be a desired target value.
+ * <p/>
+ * <p>Depending on the layout, the FixedAspectSurfaceView may not be able to maintain the
+ * requested aspect ratio. This can happen if both the width and the height are exactly
+ * determined by the layout.  To avoid this, ensure that either the height or the width is
+ * adjustable by the view; for example, by setting the layout parameters to be WRAP_CONTENT for
+ * the dimension that is best adjusted to maintain the aspect ratio.</p>
+ */
+public class FixedAspectSurfaceView extends SurfaceView {
+
+    /**
+     * Desired width/height ratio
+     */
+    private float mAspectRatio;
+
+    private GestureDetector mGestureDetector;
+
+    public FixedAspectSurfaceView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+
+        // Get initial aspect ratio from custom attributes
+        TypedArray a =
+                context.getTheme().obtainStyledAttributes(attrs,
+                        R.styleable.FixedAspectSurfaceView, 0, 0);
+        setAspectRatio(a.getFloat(
+                R.styleable.FixedAspectSurfaceView_aspectRatio, 1.f));
+        a.recycle();
+    }
+
+    /**
+     * Set the desired aspect ratio for this view.
+     *
+     * @param aspect the desired width/height ratio in the current UI orientation. Must be a
+     *               positive value.
+     */
+    public void setAspectRatio(float aspect) {
+        if (aspect <= 0) {
+            throw new IllegalArgumentException("Aspect ratio must be positive");
+        }
+        mAspectRatio = aspect;
+        requestLayout();
+    }
+
+    /**
+     * Set a gesture listener to listen for touch events
+     */
+    public void setGestureListener(Context context, GestureDetector.OnGestureListener listener) {
+        if (listener == null) {
+            mGestureDetector = null;
+        } else {
+            mGestureDetector = new GestureDetector(context, listener);
+        }
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+
+        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+        int width = MeasureSpec.getSize(widthMeasureSpec);
+        int height = MeasureSpec.getSize(heightMeasureSpec);
+
+        // General goal: Adjust dimensions to maintain the requested aspect ratio as much
+        // as possible. Depending on the measure specs handed down, this may not be possible
+
+        // Only set one of these to true
+        boolean scaleWidth = false;
+        boolean scaleHeight = false;
+
+        // Sort out which dimension to scale, if either can be. There are 9 combinations of
+        // possible measure specs; a few cases below handle multiple combinations
+        if (widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY) {
+            // Can't adjust sizes at all, do nothing
+        } else if (widthMode == MeasureSpec.EXACTLY) {
+            // Width is fixed, heightMode either AT_MOST or UNSPECIFIED, so adjust height
+            scaleHeight = true;
+        } else if (heightMode == MeasureSpec.EXACTLY) {
+            // Height is fixed, widthMode either AT_MOST or UNSPECIFIED, so adjust width
+            scaleWidth = true;
+        } else if (widthMode == MeasureSpec.AT_MOST && heightMode == MeasureSpec.AT_MOST) {
+            // Need to fit into box <= [width, height] in size.
+            // Maximize the View's area while maintaining aspect ratio
+            // This means keeping one dimension as large as possible and shrinking the other
+            float boxAspectRatio = width / (float) height;
+            if (boxAspectRatio > mAspectRatio) {
+                // Box is wider than requested aspect; pillarbox
+                scaleWidth = true;
+            } else {
+                // Box is narrower than requested aspect; letterbox
+                scaleHeight = true;
+            }
+        } else if (widthMode == MeasureSpec.AT_MOST) {
+            // Maximize width, heightSpec is UNSPECIFIED
+            scaleHeight = true;
+        } else if (heightMode == MeasureSpec.AT_MOST) {
+            // Maximize height, widthSpec is UNSPECIFIED
+            scaleWidth = true;
+        } else {
+            // Both MeasureSpecs are UNSPECIFIED. This is probably a pathological layout,
+            // with width == height == 0
+            // but arbitrarily scale height anyway
+            scaleHeight = true;
+        }
+
+        // Do the scaling
+        if (scaleWidth) {
+            width = (int) (height * mAspectRatio);
+        } else if (scaleHeight) {
+            height = (int) (width / mAspectRatio);
+        }
+
+        // Override width/height if needed for EXACTLY and AT_MOST specs
+        width = View.resolveSizeAndState(width, widthMeasureSpec, 0);
+        height = View.resolveSizeAndState(height, heightMeasureSpec, 0);
+
+        // Finally set the calculated dimensions
+        setMeasuredDimension(width, height);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (mGestureDetector != null) {
+            return mGestureDetector.onTouchEvent(event);
+        }
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/MainActivity.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/MainActivity.java
new file mode 100644
index 0000000..777fec6
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/MainActivity.java
@@ -0,0 +1,176 @@
+/*

+ * Copyright (C) 2015 The Android Open Source Project

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+package com.android.example.rscamera;

+

+import android.app.Activity;

+import android.os.Bundle;

+import android.view.View;

+import android.widget.Button;

+import android.widget.SeekBar;

+import android.widget.ViewFlipper;

+

+import com.android.example.rscamera.rscamera.R;

+

+import java.text.DecimalFormat;

+import java.util.Timer;

+import java.util.TimerTask;

+

+/**

+ * Main Activity for this app

+ * It presents a ui for setting ISO, Shutter speed, and focus

+ */

+public class MainActivity extends Activity {

+    private static final String TAG = "MainActivity";

+    private static final long ONE_SECOND = 1000000000;

+    private CameraView mPreviewView;

+    private ViewFlipper mViewFlipper;

+    private Button mSpeedButton;

+    private Button mISOButton;

+    private Button mFocusButton;

+    private Timer mTimer;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.activity_main);

+        mSpeedButton = (Button) findViewById(R.id.speed);

+        mISOButton = (Button) findViewById(R.id.iso);

+        mFocusButton = (Button) findViewById(R.id.focus);

+        mPreviewView = (CameraView) findViewById(R.id.preview);

+        mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);

+        SeekBar seekBar = (SeekBar) findViewById(R.id.focusbar);

+        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

+            @Override

+            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

+                mPreviewView.setFocusInMeters(seekBar.getProgress() / 10.f);

+            }

+

+            @Override

+            public void onStartTrackingTouch(SeekBar seekBar) {

+

+            }

+

+            @Override

+            public void onStopTrackingTouch(SeekBar seekBar) {

+

+            }

+        });

+        mPreviewView.setParametersChangedCallback(new CameraView.ParametersChangedCallback() {

+            @Override

+            public void parametersChanged() {

+                update_buttons();

+            }

+        });

+        mTimer = new Timer();

+

+        mTimer.scheduleAtFixedRate(new TimerTask() {

+

+            @Override

+            public void run() {

+                // TODO Auto-generated method stub

+                runOnUiThread(new Runnable() {

+                    public void run() {

+                        setTitle("RS Camera (" + mPreviewView.getFps() + "fps)");

+                    }

+                });

+

+            }

+        }, 250, 250);

+    }

+

+    @Override

+    protected void onResume() {

+        super.onResume();

+        mPreviewView.resume(this);

+    }

+

+    @Override

+    protected void onPause() {

+        super.onPause();

+        mPreviewView.pause();

+    }

+

+    public void setShutterSpeed(View v) {

+        if (mPreviewView.isAutoExposure()) {

+            mPreviewView.setAutoExposure(false);

+            mPreviewView.setMode(CameraView.MODE_SPEED);

+        } else {

+            mPreviewView.setMode(CameraView.MODE_NONE);

+            mPreviewView.setAutoExposure(true);

+        }

+        update_buttons();

+    }

+

+    public void setISO(View v) {

+        if (mPreviewView.isAutoExposure()) {

+            mPreviewView.setAutoExposure(false);

+            mPreviewView.setMode(CameraView.MODE_ISO);

+        } else {

+            mPreviewView.setMode(CameraView.MODE_NONE);

+            mPreviewView.setAutoExposure(true);

+        }

+        update_buttons();

+    }

+

+    public void setFocus(View v) {

+        if (mPreviewView.isAutofocus()) {

+            mPreviewView.setAutofocus(false);

+            mPreviewView.setMode(CameraView.MODE_FOCUS);

+            mViewFlipper.setInAnimation(this, R.anim.slide_in_from_left);

+            mViewFlipper.setOutAnimation(this, R.anim.slide_out_to_right);

+            mViewFlipper.showNext();

+        } else {

+            mPreviewView.setMode(CameraView.MODE_NONE);

+            mPreviewView.setAutofocus(true);

+        }

+        update_buttons();

+    }

+

+    public void back(View v) {

+        mViewFlipper.setInAnimation(this, R.anim.slide_in_from_left);

+        mViewFlipper.setOutAnimation(this, R.anim.slide_out_to_right);

+        mViewFlipper.showNext();

+    }

+

+    public void capture(View v) {

+        mPreviewView.takePicture();

+    }

+

+    private void update_buttons() {

+        byte mode = mPreviewView.getMode();

+        mSpeedButton.setElevation(mode == CameraView.MODE_SPEED ? 20 : 0);

+        mFocusButton.setElevation(mode == CameraView.MODE_FOCUS ? 20 : 0);

+        mISOButton.setElevation(mode == CameraView.MODE_ISO ? 20 : 0);

+

+        String a;

+        a = (mPreviewView.isAutoExposure()) ? "A " : "  ";

+        if (ONE_SECOND > mPreviewView.getExposure()) {

+            mSpeedButton.setText(a + 1 + "/" + (ONE_SECOND / mPreviewView.getExposure()) + "s");

+        } else {

+            mSpeedButton.setText(a + (mPreviewView.getExposure() / ONE_SECOND) + "\"s");

+

+        }

+        a = (mPreviewView.isAutofocus()) ? "A " : "  ";

+        DecimalFormat df = new DecimalFormat("#.###");

+        float d = mPreviewView.getFocusDist();

+        if (d < 0.01) {

+            d = 0;

+        }

+        mFocusButton.setText(a + df.format(0.1 / d) + " m");

+        a = (mPreviewView.isAutoExposure()) ? "A ISO " : "  ISO ";

+        mISOButton.setText(a + mPreviewView.getIso() + " M");

+    }

+}

diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/MediaStoreSaver.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/MediaStoreSaver.java
new file mode 100644
index 0000000..36f0f8d
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/MediaStoreSaver.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.rscamera;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.graphics.Bitmap;
+import android.graphics.Matrix;
+import android.net.Uri;
+import android.provider.MediaStore;
+import android.provider.MediaStore.Images;
+
+/**
+ * Utility class to save images into android image database
+ */
+public class MediaStoreSaver {
+    public static interface StreamWriter {
+        void write(OutputStream imageOut) throws IOException;
+    }
+
+    public static final String insertImage(ContentResolver contentResolver,
+                                           Bitmap image,
+                                           String title,
+                                           String description) {
+        final Bitmap source = image;
+        StreamWriter streamWriter = new StreamWriter() {
+            public void write(OutputStream imageOut) {
+                source.compress(Bitmap.CompressFormat.JPEG, 50, imageOut);
+            }
+        };
+        return insertImage(contentResolver, streamWriter, title, description);
+    }
+
+
+    public static final String insertImage(ContentResolver cr,
+                                           StreamWriter source,
+                                           String title,
+                                           String description) {
+
+        ContentValues values = new ContentValues();
+        values.put(Images.Media.TITLE, title);
+        values.put(Images.Media.DISPLAY_NAME, title);
+        values.put(Images.Media.DESCRIPTION, description);
+        values.put(Images.Media.MIME_TYPE, "image/jpeg");
+        // Add the date meta data to ensure the image is added at the front of the gallery
+        values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
+        values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
+
+        Uri url = null;
+        String stringUrl = null;    /* value to be returned */
+
+        try {
+            url = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+
+            if (source != null) {
+                OutputStream imageOut = cr.openOutputStream(url);
+                try {
+                    source.write(imageOut);
+                } finally {
+                    imageOut.close();
+                }
+
+                long id = ContentUris.parseId(url);
+                // Wait until MINI_KIND thumbnail is generated.
+                Bitmap miniThumb = Images.Thumbnails.getThumbnail(cr, id, Images.Thumbnails.MINI_KIND, null);
+                // This is for backward compatibility.
+                storeThumbnail(cr, miniThumb, id, 50F, 50F, Images.Thumbnails.MICRO_KIND);
+            } else {
+                cr.delete(url, null, null);
+                url = null;
+            }
+        } catch (Exception e) {
+            if (url != null) {
+                cr.delete(url, null, null);
+                url = null;
+            }
+        }
+
+        if (url != null) {
+            stringUrl = url.toString();
+        }
+
+        return stringUrl;
+    }
+
+    /**
+     * A copy of the Android internals StoreThumbnail method, it used with the insertImage to
+     * populate the android.provider.MediaStore.Images.Media#insertImage with all the correct
+     * meta data. The StoreThumbnail method is private so it must be duplicated here.
+     *
+     * @see android.provider.MediaStore.Images.Media (StoreThumbnail private method)
+     */
+    private static final Bitmap storeThumbnail(
+            ContentResolver cr,
+            Bitmap source,
+            long id,
+            float width,
+            float height,
+            int kind) {
+
+        // create the matrix to scale it
+        Matrix matrix = new Matrix();
+
+        float scaleX = width / source.getWidth();
+        float scaleY = height / source.getHeight();
+
+        matrix.setScale(scaleX, scaleY);
+
+        Bitmap thumb = Bitmap.createBitmap(source, 0, 0,
+                source.getWidth(),
+                source.getHeight(), matrix,
+                true
+        );
+
+        ContentValues values = new ContentValues(4);
+        values.put(Images.Thumbnails.KIND, kind);
+        values.put(Images.Thumbnails.IMAGE_ID, (int) id);
+        values.put(Images.Thumbnails.HEIGHT, thumb.getHeight());
+        values.put(Images.Thumbnails.WIDTH, thumb.getWidth());
+
+        Uri url = cr.insert(Images.Thumbnails.EXTERNAL_CONTENT_URI, values);
+
+        try {
+            OutputStream thumbOut = cr.openOutputStream(url);
+            thumb.compress(Bitmap.CompressFormat.JPEG, 100, thumbOut);
+            thumbOut.close();
+            return thumb;
+        } catch (FileNotFoundException ex) {
+            return null;
+        } catch (IOException ex) {
+            return null;
+        }
+    }
+
+
+}
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/VerticalSeekBar.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/VerticalSeekBar.java
new file mode 100644
index 0000000..1473e0b
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/VerticalSeekBar.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.rscamera;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.SeekBar;
+
+/**
+ * Class to create a vertical slider
+ */
+public class VerticalSeekBar extends SeekBar {
+
+    public VerticalSeekBar(Context context) {
+        super(context);
+    }
+
+    public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    public VerticalSeekBar(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(h, w, oldh, oldw);
+    }
+
+    @Override
+    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
+        setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
+    }
+
+    protected void onDraw(Canvas c) {
+        c.rotate(-90);
+        c.translate(-getHeight(), 0);
+
+        super.onDraw(c);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (!isEnabled()) {
+            return false;
+        }
+
+        switch (event.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+            case MotionEvent.ACTION_MOVE:
+            case MotionEvent.ACTION_UP:
+                setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
+                onSizeChanged(getWidth(), getHeight(), 0, 0);
+                break;
+
+            case MotionEvent.ACTION_CANCEL:
+                break;
+        }
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/ViewfinderProcessor.java b/java/tests/RsCameraDemo/src/com/android/example/rscamera/ViewfinderProcessor.java
new file mode 100644
index 0000000..e012e92
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/ViewfinderProcessor.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.rscamera;
+
+import android.graphics.ImageFormat;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.Type;
+import android.util.Size;
+import android.view.Surface;
+
+/**
+ * Renderscript-based Focus peaking viewfinder
+ */
+public class ViewfinderProcessor {
+    int mCount;
+    long mLastTime;
+    float mFps;
+    private Allocation mInputAllocation;
+    private Allocation mOutputAllocation;
+    private HandlerThread mProcessingThread;
+    private Handler mProcessingHandler;
+    private ScriptC_focus_peak mScriptFocusPeak;
+    public ProcessingTask mProcessingTask;
+
+    public ViewfinderProcessor(RenderScript rs, Size dimensions) {
+        Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.YUV(rs));
+        yuvTypeBuilder.setX(dimensions.getWidth());
+        yuvTypeBuilder.setY(dimensions.getHeight());
+        yuvTypeBuilder.setYuvFormat(ImageFormat.YUV_420_888);
+
+        mInputAllocation = Allocation.createTyped(rs, yuvTypeBuilder.create(),
+                Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
+
+        Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
+        rgbTypeBuilder.setX(dimensions.getWidth());
+        rgbTypeBuilder.setY(dimensions.getHeight());
+
+        mOutputAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
+                Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);
+
+        mProcessingThread = new HandlerThread("ViewfinderProcessor");
+        mProcessingThread.start();
+        mProcessingHandler = new Handler(mProcessingThread.getLooper());
+        mScriptFocusPeak = new ScriptC_focus_peak(rs);
+        mProcessingTask = new ProcessingTask(mInputAllocation);
+    }
+
+    public Surface getInputSurface() {
+        return mInputAllocation.getSurface();
+    }
+
+    public void setOutputSurface(Surface output) {
+        mOutputAllocation.setSurface(output);
+    }
+
+    public float getmFps() {
+        return mFps;
+    }
+
+    /**
+     * Class to process buffer from camera and output to buffer to screen
+     */
+    class ProcessingTask implements Runnable, Allocation.OnBufferAvailableListener {
+        private int mPendingFrames = 0;
+
+        private Allocation mInputAllocation;
+
+        public ProcessingTask(Allocation input) {
+            mInputAllocation = input;
+            mInputAllocation.setOnBufferAvailableListener(this);
+        }
+
+        @Override
+        public void onBufferAvailable(Allocation a) {
+            synchronized (this) {
+                mPendingFrames++;
+                mProcessingHandler.post(this);
+            }
+        }
+
+        @Override
+        public void run() {
+            // Find out how many frames have arrived
+            int pendingFrames;
+            synchronized (this) {
+                pendingFrames = mPendingFrames;
+                mPendingFrames = 0;
+
+                // Discard extra messages in case processing is slower than frame rate
+                mProcessingHandler.removeCallbacks(this);
+            }
+
+            // Get to newest input
+            for (int i = 0; i < pendingFrames; i++) {
+                mInputAllocation.ioReceive();
+            }
+            mCount++;
+            mScriptFocusPeak.set_gCurrentFrame(mInputAllocation);
+            long time = System.currentTimeMillis() - mLastTime;
+            if (time > 1000) {
+                mLastTime += time;
+                mFps = mCount * 1000 / (float) (time);
+                mCount = 0;
+            }
+            // Run processing pass
+            mScriptFocusPeak.forEach_peak(mOutputAllocation);
+            mOutputAllocation.ioSend();
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/tests/RsCameraDemo/src/com/android/example/rscamera/focus_peak.rs b/java/tests/RsCameraDemo/src/com/android/example/rscamera/focus_peak.rs
new file mode 100644
index 0000000..6513bc1
--- /dev/null
+++ b/java/tests/RsCameraDemo/src/com/android/example/rscamera/focus_peak.rs
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.example.rscamera)
+#pragma rs_fp_relaxed
+
+rs_allocation gCurrentFrame;
+
+uchar4 __attribute__((kernel)) peak(uint32_t x, uint32_t y) {
+
+    uchar4 curPixel;
+    curPixel.r = rsGetElementAtYuv_uchar_Y(gCurrentFrame, x, y);
+    curPixel.g = rsGetElementAtYuv_uchar_U(gCurrentFrame, x, y);
+    curPixel.b = rsGetElementAtYuv_uchar_V(gCurrentFrame, x, y);
+
+    int dx = x + ((x == 0) ? 1 : -1);
+    int sum = 0;
+    int tmp;
+
+    tmp = rsGetElementAtYuv_uchar_Y(gCurrentFrame, dx, y) - curPixel.r;
+    sum += tmp * tmp;
+    tmp = rsGetElementAtYuv_uchar_U(gCurrentFrame, dx, y) - curPixel.g;
+    sum += tmp * tmp;
+    tmp = rsGetElementAtYuv_uchar_V(gCurrentFrame, dx, y) - curPixel.b;
+    sum += tmp * tmp;
+
+
+    int dy = y + ((y == 0) ? 1 : -1);
+    tmp = rsGetElementAtYuv_uchar_Y(gCurrentFrame, x, dy) - curPixel.r;
+    sum += tmp * tmp;
+    tmp = rsGetElementAtYuv_uchar_U(gCurrentFrame, x, dy) - curPixel.g;
+    sum += tmp * tmp;
+    tmp = rsGetElementAtYuv_uchar_V(gCurrentFrame, x, dy) - curPixel.b;
+    sum += tmp * tmp;
+
+    sum >>= 9;
+    sum *= sum * sum;
+
+    curPixel.a = 255;
+
+    uchar4 mergedPixel = curPixel;
+
+    int4 rgb;
+    rgb.r = mergedPixel.r +
+            mergedPixel.b * 1436 / 1024 - 179 + sum;
+    rgb.g = mergedPixel.r -
+            mergedPixel.g * 46549 / 131072 + 44 -
+            mergedPixel.b * 93604 / 131072 + 91 + sum;
+    rgb.b = mergedPixel.r +
+            mergedPixel.g * 1814 / 1024 - 227;
+    rgb.a = 255;
+
+    // Write out merged HDR result
+    uchar4 out = convert_uchar4(clamp(rgb, 0, 255));
+
+    return out;
+}
\ No newline at end of file
diff --git a/scriptc/rs_allocation.rsh b/scriptc/rs_allocation_data.rsh
similarity index 95%
rename from scriptc/rs_allocation.rsh
rename to scriptc/rs_allocation_data.rsh
index 2cc2a82..12d62a0 100644
--- a/scriptc/rs_allocation.rsh
+++ b/scriptc/rs_allocation_data.rsh
@@ -14,16 +14,19 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
- * rs_allocation.rsh: Allocation routines
+ * rs_allocation_data.rsh: Allocation routines
+ *
+ * TODO Adjust documentation.
  *
  * Functions that can be used to query the characteristics of an allocation,
  * to set and get elements of the allocation.
  */
-#ifndef RENDERSCRIPT_RS_ALLOCATION_RSH
-#define RENDERSCRIPT_RS_ALLOCATION_RSH
+
+#ifndef RENDERSCRIPT_RS_ALLOCATION_DATA_RSH
+#define RENDERSCRIPT_RS_ALLOCATION_DATA_RSH
 
 /*
  * rsAllocationCopy1DRange: Copy consecutive values between allocations
@@ -34,13 +37,13 @@
  * the same allocation yields undefined results.
  *
  * Parameters:
- *   dstAlloc Allocation to copy data into.
- *   dstOff The offset of the first element to be copied in the destination allocation.
- *   dstMip Mip level in the destination allocation.
- *   count The number of elements to be copied.
- *   srcAlloc The source data allocation.
- *   srcOff The offset of the first element in data to be copied in the source allocation.
- *   srcMip Mip level in the source allocation.
+ *   dstAlloc: Allocation to copy data into.
+ *   dstOff: The offset of the first element to be copied in the destination allocation.
+ *   dstMip: Mip level in the destination allocation.
+ *   count: The number of elements to be copied.
+ *   srcAlloc: The source data allocation.
+ *   srcOff: The offset of the first element in data to be copied in the source allocation.
+ *   srcMip: Mip level in the source allocation.
  */
 #if (defined(RS_VERSION) && (RS_VERSION >= 14))
 extern void __attribute__((overloadable))
@@ -57,18 +60,18 @@
  * the same allocation yields undefined results.
  *
  * Parameters:
- *   dstAlloc Allocation to copy data into.
- *   dstXoff X offset of the region to update in the destination allocation.
- *   dstYoff Y offset of the region to update in the destination allocation.
- *   dstMip Mip level in the destination allocation.
- *   dstFace Cubemap face of the destination allocation, ignored for allocations that aren't cubemaps.
- *   width Width of the incoming region to update.
- *   height Height of the incoming region to update.
- *   srcAlloc The source data allocation.
- *   srcXoff X offset in data of the source allocation.
- *   srcYoff Y offset in data of the source allocation.
- *   srcMip Mip level in the source allocation.
- *   srcFace Cubemap face of the source allocation, ignored for allocations that aren't cubemaps.
+ *   dstAlloc: Allocation to copy data into.
+ *   dstXoff: X offset of the region to update in the destination allocation.
+ *   dstYoff: Y offset of the region to update in the destination allocation.
+ *   dstMip: Mip level in the destination allocation.
+ *   dstFace: Cubemap face of the destination allocation, ignored for allocations that aren't cubemaps.
+ *   width: Width of the incoming region to update.
+ *   height: Height of the incoming region to update.
+ *   srcAlloc: The source data allocation.
+ *   srcXoff: X offset in data of the source allocation.
+ *   srcYoff: Y offset in data of the source allocation.
+ *   srcMip: Mip level in the source allocation.
+ *   srcFace: Cubemap face of the source allocation, ignored for allocations that aren't cubemaps.
  */
 #if (defined(RS_VERSION) && (RS_VERSION >= 14))
 extern void __attribute__((overloadable))
@@ -79,96 +82,6 @@
 #endif
 
 /*
- * rsAllocationGetDimFaces: Presence of more than one face
- *
- * If the allocation is a cubemap, this function returns 1 if there's more than one
- * face present.  In all other cases, it returns 0.
- *
- * Returns: Returns 1 if more than one face is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimFaces(rs_allocation a);
-
-/*
- * rsAllocationGetDimLOD: Presence of levels of details
- *
- * Query an allocation for the presence of more than one Level Of Details.  This is useful for mipmaps.
- *
- * Returns: Returns 1 if more than one LOD is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimLOD(rs_allocation a);
-
-/*
- * rsAllocationGetDimX: Size of the X dimension
- *
- * Returns the size of the X dimension of the allocation.
- *
- * Returns: The X dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimX(rs_allocation a);
-
-/*
- * rsAllocationGetDimY: Size of the Y dimension
- *
- * Returns the size of the Y dimension of the allocation.
- * If the allocation has less than two dimensions, returns 0.
- *
- * Returns: The Y dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimY(rs_allocation a);
-
-/*
- * rsAllocationGetDimZ: Size of the Z dimension
- *
- * Returns the size of the Z dimension of the allocation.
- * If the allocation has less than three dimensions, returns 0.
- *
- * Returns: The Z dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimZ(rs_allocation a);
-
-/*
- * Get the element object describing the allocation's layout
- *
- * Parameters:
- *   a allocation to get data from
- *
- * Returns: element describing allocation layout
- */
-extern rs_element __attribute__((overloadable))
-    rsAllocationGetElement(rs_allocation a);
-
-/*
- * rsAllocationIoReceive: Receive new content from the queue
- *
- * Receive a new set of contents from the queue.
- *
- * Parameters:
- *   a allocation to work on
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern void __attribute__((overloadable))
-    rsAllocationIoReceive(rs_allocation a);
-#endif
-
-/*
- * rsAllocationIoSend: Send new content to the queue
- *
- * Send the contents of the Allocation to the queue.
- *
- * Parameters:
- *   a allocation to work on
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern void __attribute__((overloadable))
-    rsAllocationIoSend(rs_allocation a);
-#endif
-
-/*
  * Get a single element from an allocation.
  */
 #if (defined(RS_VERSION) && (RS_VERSION >= 22))
@@ -1075,19 +988,6 @@
 #endif
 
 /*
- * rsGetAllocation: Returns the Allocation for a given pointer
- *
- * Returns the Allocation for a given pointer.  The pointer should point within
- * a valid allocation.  The results are undefined if the pointer is not from a
- * valid allocation.
- *
- * This function is deprecated and will be removed from the SDK in a future
- * release.
- */
-extern rs_allocation __attribute__((overloadable))
-    rsGetAllocation(const void* p);
-
-/*
  * rsGetElementAt: Get an element
  *
  * Extract a single element from an allocation.
@@ -2576,10 +2476,10 @@
  * For 2D, use the float2 variant.
  *
  * Parameters:
- *   a allocation to sample from
- *   s sampler state
- *   location location to sample from
- *   lod mip level to sample from, for fractional values mip levels will be interpolated if RS_SAMPLER_LINEAR_MIP_LINEAR is used
+ *   a: allocation to sample from
+ *   s: sampler state
+ *   location: location to sample from
+ *   lod: mip level to sample from, for fractional values mip levels will be interpolated if RS_SAMPLER_LINEAR_MIP_LINEAR is used
  */
 #if (defined(RS_VERSION) && (RS_VERSION >= 16))
 extern float4 __attribute__((overloadable))
@@ -3216,4 +3116,4 @@
     rsSetElementAt_ulong4(rs_allocation a, ulong4 val, uint32_t x, uint32_t y, uint32_t z);
 #endif
 
-#endif // RENDERSCRIPT_RS_ALLOCATION_RSH
+#endif // RENDERSCRIPT_RS_ALLOCATION_DATA_RSH
diff --git a/scriptc/rs_atomic.rsh b/scriptc/rs_atomic.rsh
index 29c294a..58ce130 100644
--- a/scriptc/rs_atomic.rsh
+++ b/scriptc/rs_atomic.rsh
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_atomic.rsh: Atomic routines
@@ -32,6 +32,7 @@
  * threads.  Updating globals should be done with atomic functions.  If possible,
  * modify your algorithm to avoid them altogether.
  */
+
 #ifndef RENDERSCRIPT_RS_ATOMIC_RSH
 #define RENDERSCRIPT_RS_ATOMIC_RSH
 
@@ -41,8 +42,8 @@
  * Atomicly adds a value to the value at addr, i.e. *addr += value.
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Amount to add
+ *   addr: Address of the value to modify
+ *   value: Amount to add
  *
  * Returns: Old value
  */
@@ -63,8 +64,8 @@
  * i.e. *addr &= value
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Value to and with
+ *   addr: Address of the value to modify
+ *   value: Value to and with
  *
  * Returns: Old value
  */
@@ -88,9 +89,9 @@
  * by rsAtomicCas is compareValue.
  *
  * Parameters:
- *   addr The address to compare and replace if the compare passes.
- *   compareValue The value to test *addr against.
- *   newValue The value to write if the test passes.
+ *   addr: The address to compare and replace if the compare passes.
+ *   compareValue: The value to test *addr against.
+ *   newValue: The value to write if the test passes.
  *
  * Returns: Old value
  */
@@ -110,7 +111,7 @@
  * Atomicly subtracts one from the value at addr.  Equal to rsAtomicSub(addr, 1)
  *
  * Parameters:
- *   addr Address of the value to decrement
+ *   addr: Address of the value to decrement
  *
  * Returns: Old value
  */
@@ -130,7 +131,7 @@
  * Atomicly adds one to the value at addr.  Equal to rsAtomicAdd(addr, 1)
  *
  * Parameters:
- *   addr Address of the value to increment
+ *   addr: Address of the value to increment
  *
  * Returns: Old value
  */
@@ -151,8 +152,8 @@
  * *addr = max(*addr, value)
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Comparison value
+ *   addr: Address of the value to modify
+ *   value: Comparison value
  *
  * Returns: Old value
  */
@@ -173,8 +174,8 @@
  * *addr = min(*addr, value)
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Comparison value
+ *   addr: Address of the value to modify
+ *   value: Comparison value
  *
  * Returns: Old value
  */
@@ -195,8 +196,8 @@
  * i.e. *addr |= value
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Value to or with
+ *   addr: Address of the value to modify
+ *   value: Value to or with
  *
  * Returns: Old value
  */
@@ -216,8 +217,8 @@
  * Atomicly subtracts a value from the value at addr, i.e. *addr -= value
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Amount to subtract
+ *   addr: Address of the value to modify
+ *   value: Amount to subtract
  *
  * Returns: Old value
  */
@@ -238,8 +239,8 @@
  * i.e. *addr ^= value
  *
  * Parameters:
- *   addr Address of the value to modify
- *   value Value to xor with
+ *   addr: Address of the value to modify
+ *   value: Value to xor with
  *
  * Returns: Old value
  */
diff --git a/scriptc/rs_convert.rsh b/scriptc/rs_convert.rsh
new file mode 100644
index 0000000..eaa6c1a
--- /dev/null
+++ b/scriptc/rs_convert.rsh
@@ -0,0 +1,1278 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_convert.rsh: Conversion functions
+ *
+ * TODO Add desc.
+ */
+
+#ifndef RENDERSCRIPT_RS_CONVERT_RSH
+#define RENDERSCRIPT_RS_CONVERT_RSH
+
+/*
+ * convert: Converts numerical vectors
+ *
+ * Component wise conversion from a numerical type to another.
+ *
+ * Conversions of floating point values to integer will truncate.
+ *
+ * Conversions of numbers too large to fit the destination type yield undefined results.
+ * For example, converting a float that contains 1.0e18 to a short is undefined.
+ * Use clamp() to avoid this.
+ */
+extern float2 __attribute__((const, overloadable))
+    convert_float2(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(float4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(char2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(char3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(char4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(uchar2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(uchar3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(uchar4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(short2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(short3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(short4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(ushort2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(ushort3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(ushort4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(int2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(int3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(int4 v);
+
+extern float2 __attribute__((const, overloadable))
+    convert_float2(uint2 v);
+
+extern float3 __attribute__((const, overloadable))
+    convert_float3(uint3 v);
+
+extern float4 __attribute__((const, overloadable))
+    convert_float4(uint4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(float2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(float3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(float4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(char2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(char3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(char4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(uchar2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(uchar3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(uchar4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(short2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(short3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(short4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(ushort2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(ushort3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(ushort4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(int2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(int3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(int4 v);
+
+extern char2 __attribute__((const, overloadable))
+    convert_char2(uint2 v);
+
+extern char3 __attribute__((const, overloadable))
+    convert_char3(uint3 v);
+
+extern char4 __attribute__((const, overloadable))
+    convert_char4(uint4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(float2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(float3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(float4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(char2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(char3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(char4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(uchar2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(uchar3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(uchar4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(short2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(short3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(short4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(ushort2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(ushort3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(ushort4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(int2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(int3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(int4 v);
+
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(uint2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(uint3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(uint4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(float2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(float3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(float4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(char2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(char3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(char4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(uchar2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(uchar3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(uchar4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(short2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(short3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(short4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(ushort2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(ushort3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(ushort4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(int2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(int3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(int4 v);
+
+extern short2 __attribute__((const, overloadable))
+    convert_short2(uint2 v);
+
+extern short3 __attribute__((const, overloadable))
+    convert_short3(uint3 v);
+
+extern short4 __attribute__((const, overloadable))
+    convert_short4(uint4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(float2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(float3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(float4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(char2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(char3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(char4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(uchar2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(uchar3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(uchar4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(short2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(short3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(short4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(ushort2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(ushort3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(ushort4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(int2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(int3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(int4 v);
+
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(uint2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(uint3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(uint4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(float2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(float3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(float4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(char2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(char3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(char4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(uchar2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(uchar3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(uchar4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(short2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(short3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(short4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(ushort2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(ushort3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(ushort4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(int2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(int3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(int4 v);
+
+extern int2 __attribute__((const, overloadable))
+    convert_int2(uint2 v);
+
+extern int3 __attribute__((const, overloadable))
+    convert_int3(uint3 v);
+
+extern int4 __attribute__((const, overloadable))
+    convert_int4(uint4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(float2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(float3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(float4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(char2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(char3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(char4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(uchar2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(uchar3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(uchar4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(short2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(short3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(short4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(ushort2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(ushort3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(ushort4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(int2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(int3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(int4 v);
+
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(uint2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(uint3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(uint4 v);
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    convert_float2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    convert_float3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    convert_float4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    convert_float2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    convert_float3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    convert_float4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    convert_float2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    convert_float3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    convert_float4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char2 __attribute__((const, overloadable))
+    convert_char2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char3 __attribute__((const, overloadable))
+    convert_char3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char4 __attribute__((const, overloadable))
+    convert_char4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char2 __attribute__((const, overloadable))
+    convert_char2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char3 __attribute__((const, overloadable))
+    convert_char3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char4 __attribute__((const, overloadable))
+    convert_char4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char2 __attribute__((const, overloadable))
+    convert_char2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char3 __attribute__((const, overloadable))
+    convert_char3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char4 __attribute__((const, overloadable))
+    convert_char4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar2 __attribute__((const, overloadable))
+    convert_uchar2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar3 __attribute__((const, overloadable))
+    convert_uchar3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar4 __attribute__((const, overloadable))
+    convert_uchar4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short2 __attribute__((const, overloadable))
+    convert_short2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short3 __attribute__((const, overloadable))
+    convert_short3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short4 __attribute__((const, overloadable))
+    convert_short4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short2 __attribute__((const, overloadable))
+    convert_short2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short3 __attribute__((const, overloadable))
+    convert_short3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short4 __attribute__((const, overloadable))
+    convert_short4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short2 __attribute__((const, overloadable))
+    convert_short2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short3 __attribute__((const, overloadable))
+    convert_short3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short4 __attribute__((const, overloadable))
+    convert_short4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort2 __attribute__((const, overloadable))
+    convert_ushort2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort3 __attribute__((const, overloadable))
+    convert_ushort3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort4 __attribute__((const, overloadable))
+    convert_ushort4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int2 __attribute__((const, overloadable))
+    convert_int2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int3 __attribute__((const, overloadable))
+    convert_int3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int4 __attribute__((const, overloadable))
+    convert_int4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int2 __attribute__((const, overloadable))
+    convert_int2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int3 __attribute__((const, overloadable))
+    convert_int3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int4 __attribute__((const, overloadable))
+    convert_int4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int2 __attribute__((const, overloadable))
+    convert_int2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int3 __attribute__((const, overloadable))
+    convert_int3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int4 __attribute__((const, overloadable))
+    convert_int4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(double2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(double3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(double4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(long2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(long3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(long4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint2 __attribute__((const, overloadable))
+    convert_uint2(ulong2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint3 __attribute__((const, overloadable))
+    convert_uint3(ulong3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint4 __attribute__((const, overloadable))
+    convert_uint4(ulong4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(float4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(char2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(char3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(char4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(uchar2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(uchar3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(uchar4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(short2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(short3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(short4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(ushort2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(ushort3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(ushort4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(int2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(int3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(int4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double2 __attribute__((const, overloadable))
+    convert_double2(uint2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double3 __attribute__((const, overloadable))
+    convert_double3(uint3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern double4 __attribute__((const, overloadable))
+    convert_double4(uint4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(float4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(char2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(char3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(char4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(uchar2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(uchar3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(uchar4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(short2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(short3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(short4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(ushort2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(ushort3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(ushort4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(int2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(int3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(int4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    convert_long2(uint2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    convert_long3(uint3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    convert_long4(uint4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(float4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(char2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(char3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(char4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(uchar2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(uchar3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(uchar4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(short2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(short3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(short4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(ushort2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(ushort3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(ushort4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(int2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(int3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(int4 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    convert_ulong2(uint2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    convert_ulong3(uint3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    convert_ulong4(uint4 v);
+#endif
+
+/*
+ * Pack floating point (0-1) RGB values into a uchar4.
+ *
+ * For the float3 variant and the variant that only specifies r, g, b,
+ * the alpha component is set to 255 (1.0).
+ */
+extern uchar4 __attribute__((const, overloadable))
+    rsPackColorTo8888(float r, float g, float b);
+
+extern uchar4 __attribute__((const, overloadable))
+    rsPackColorTo8888(float r, float g, float b, float a);
+
+extern uchar4 __attribute__((const, overloadable))
+    rsPackColorTo8888(float3 color);
+
+extern uchar4 __attribute__((const, overloadable))
+    rsPackColorTo8888(float4 color);
+
+/*
+ * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
+ */
+extern float4 __attribute__((const))
+    rsUnpackColor8888(uchar4 c);
+
+/*
+ * Convert from YUV to RGBA.
+ */
+extern float4 __attribute__((const, overloadable))
+    rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
+
+extern uchar4 __attribute__((const, overloadable))
+    rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
+
+#endif // RENDERSCRIPT_RS_CONVERT_RSH
diff --git a/scriptc/rs_core.rsh b/scriptc/rs_core.rsh
index c86d23e..029667a 100644
--- a/scriptc/rs_core.rsh
+++ b/scriptc/rs_core.rsh
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_core.rsh: TODO
@@ -33,354 +33,28 @@
  * Android framework APIs interact, see the RenderScript developer guide
  * and the RenderScript samples.
  */
+
 #ifndef RENDERSCRIPT_RS_CORE_RSH
 #define RENDERSCRIPT_RS_CORE_RSH
 
 #define RS_KERNEL __attribute__((kernel))
 
-#include "rs_types.rsh"
-#include "rs_allocation.rsh"
+#include "stdbool.h"
+
+#include "rs_value_types.rsh"
+#include "rs_object_types.rsh"
+
+#include "rs_allocation_data.rsh"
 #include "rs_atomic.rsh"
-#include "rs_core_math.rsh"
+#include "rs_convert.rsh"
 #include "rs_debug.rsh"
-#include "rs_element.rsh"
+#include "rs_for_each.rsh"
+#include "rs_io.rsh"
 #include "rs_math.rsh"
 #include "rs_matrix.rsh"
-#include "rs_object.rsh"
+#include "rs_object_info.rsh"
 #include "rs_quaternion.rsh"
-#include "rs_sampler.rsh"
 #include "rs_time.rsh"
-
-/*
- * rs_for_each_strategy_t: Launch order hint for rsForEach calls
- *
- * Launch order hint for rsForEach calls.  This provides a hint to the system to
- * determine in which order the root function of the target is called with each
- * cell of the allocation.
- *
- * This is a hint and implementations may not obey the order.
- */
-typedef enum rs_for_each_strategy {
-    RS_FOR_EACH_STRATEGY_SERIAL = 0,
-    RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
-    RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
-    RS_FOR_EACH_STRATEGY_TILE_SMALL = 3,
-    RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
-    RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
-} rs_for_each_strategy_t;
-
-/*
- * rs_kernel_context: Opaque handle to RenderScript kernel invocation context
- *
- * TODO
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-typedef const struct rs_kernel_context_t * rs_kernel_context;
-#endif
-
-/*
- * rs_script_call_t: Provides extra information to a rsForEach call
- *
- * Structure to provide extra information to a rsForEach call.  Primarly used to
- * restrict the call to a subset of cells in the allocation.
- */
-typedef struct rs_script_call {
-    rs_for_each_strategy_t strategy;
-    uint32_t xStart;
-    uint32_t xEnd;
-    uint32_t yStart;
-    uint32_t yEnd;
-    uint32_t zStart;
-    uint32_t zEnd;
-    uint32_t arrayStart;
-    uint32_t arrayEnd;
-} rs_script_call_t;
-
-/*
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- *
- * Parameters:
- *   script The target script to call
- *   input The allocation to source data from
- *   output the allocation to write date into
- *   usrData The user defined params to pass to the root script.  May be NULL.
- *   sc Extra control infomation used to select a sub-region of the allocation to be processed or suggest a walking strategy.  May be NULL.
- *   usrDataLen The size of the userData structure.  This will be used to perform a shallow copy of the data if necessary.
- */
-#if !defined(RS_VERSION) || (RS_VERSION <= 13)
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
-              const rs_script_call_t* sc);
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 13)
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
-              size_t usrDataLen, const rs_script_call_t* sc);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
-              size_t usrDataLen);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output);
-#endif
-
-/*
- * Send a message back to the client.  Will not block and returns true
- * if the message was sendable and false if the fifo was full.
- * A message ID is required.  Data payload is optional.
- */
-extern bool __attribute__((overloadable))
-    rsSendToClient(int cmdID);
-
-extern bool __attribute__((overloadable))
-    rsSendToClient(int cmdID, const void* data, uint len);
-
-/*
- * Send a message back to the client, blocking until the message is queued.
- * A message ID is required.  Data payload is optional.
- */
-extern void __attribute__((overloadable))
-    rsSendToClientBlocking(int cmdID);
-
-extern void __attribute__((overloadable))
-    rsSendToClientBlocking(int cmdID, const void* data, uint len);
-
-/*
- * rsGetArray0: Index in the Array0 dimension for the specified context
- *
- * Returns the index in the Array0 dimension of the cell being processed,
- * as specified by the supplied context.
- *
- * This context is created when a kernel is launched and updated at each
- * iteration.  It contains common characteristics of the allocations being
- * iterated over and rarely used indexes, like the Array0 index.
- *
- * You can access the context by adding a rs_kernel_context argument to your
- * kernel function.  E.g.
- * short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {
- *   // The current index in the common x, y, z, w dimensions are accessed by
- *   // adding these variables as arguments.  For the more rarely used indexes
- *   // to the other dimensions, extract them from the context:
- *   uint32_t index_a0 = rsGetArray0(context);
- *   //...
- * }
- *
- * This function returns 0 if the Array0 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetArray0(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetArray1: Index in the Array1 dimension for the specified context
- *
- * Returns the index in the Array1 dimension of the cell being processed,
- * as specified by the supplied context.  See rsGetArray0() for an explanation
- * of the context.
- *
- * Returns 0 if the Array1 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetArray1(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetArray2: Index in the Array2 dimension for the specified context
- *
- * Returns the index in the Array2 dimension of the cell being processed,
- * as specified by the supplied context.  See rsGetArray0() for an explanation
- * of the context.
- *
- * Returns 0 if the Array2 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetArray2(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetArray3: Index in the Array3 dimension for the specified context
- *
- * Returns the index in the Array3 dimension of the cell being processed,
- * as specified by the supplied context.  See rsGetArray0() for an explanation
- * of the context.
- *
- * Returns 0 if the Array3 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetArray3(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimArray0: Size of the Array0 dimension for the specified context
- *
- * Returns the size of the Array0 dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Array0 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimArray0(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimArray1: Size of the Array1 dimension for the specified context
- *
- * Returns the size of the Array1 dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Array1 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimArray1(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimArray2: Size of the Array2 dimension for the specified context
- *
- * Returns the size of the Array2 dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Array2 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimArray2(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimArray3: Size of the Array3 dimension for the specified context
- *
- * Returns the size of the Array3 dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Array3 dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimArray3(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimHasFaces: Presence of more than one face for the specified context
- *
- * If the context refers to a cubemap, this function returns true if there's
- * more than one face present.  In all other cases, it returns false.
- * See rsGetDimX() for an explanation of the context.
- *
- * rsAllocationGetDimFaces() is similar but returns 0 or 1 instead of a bool.
- *
- * Returns: Returns true if more than one face is present, false otherwise.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern bool __attribute__((overloadable))
-    rsGetDimHasFaces(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimLod: Number of levels of detail for the specified context
- *
- * Returns the number of levels of detail for the specified context.
- * This is useful for mipmaps.  See rsGetDimX() for an explanation of the context.
- * Returns 0 if Level of Detail is not used.
- *
- * rsAllocationGetDimLOD() is similar but returns 0 or 1 instead the actual
- * number of levels.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimLod(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimX: Size of the X dimension for the specified context
- *
- * Returns the size of the X dimension for the specified context.
- *
- * This context is created when a kernel is launched.  It contains common
- * characteristics of the allocations being iterated over by the kernel in
- * a very efficient structure.  It also contains rarely used indexes.
- *
- * You can access it by adding a rs_kernel_context argument to your kernel
- * function.  E.g.
- * int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {
- *   uint32_t size = rsGetDimX(context); //...
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimX(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimY: Size of the Y dimension for the specified context
- *
- * Returns the size of the X dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Y dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimY(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetDimZ: Size of the Z dimension for the specified context
- *
- * Returns the size of the Z dimension for the specified context.
- * See rsGetDimX() for an explanation of the context.
- *
- * Returns 0 if the Z dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetDimZ(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetFace: Coordinate of the Face for the specified context
- *
- * Returns the face on which the cell being processed is found, as specified
- * by the supplied context.  See rsGetArray0() for an explanation of the context.
- *
- * Returns RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X if the face dimension is not
- * present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern rs_allocation_cubemap_face __attribute__((overloadable))
-    rsGetFace(rs_kernel_context ctxt);
-#endif
-
-/*
- * rsGetLod: Index in the Levels of Detail dimension for the specified context.
- *
- * Returns the index in the Levels of Detail dimension of the cell being
- * processed, as specified by the supplied context.  See rsGetArray0() for
- * an explanation of the context.
- *
- * Returns 0 if the Levels of Detail dimension is not present.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 23))
-extern uint32_t __attribute__((overloadable))
-    rsGetLod(rs_kernel_context ctxt);
-#endif
+#include "rs_vector_math.rsh"
 
 #endif // RENDERSCRIPT_RS_CORE_RSH
diff --git a/scriptc/rs_core_math.rsh b/scriptc/rs_core_math.rsh
deleted file mode 100644
index afa3638..0000000
--- a/scriptc/rs_core_math.rsh
+++ /dev/null
@@ -1,5433 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_core_math.rsh: Mathematical functions
- *
- * Most mathematical functions can be applied to scalars and vectors.
- * When applied to vectors, a vector of the function applied to each entry
- * of the input is returned.
- *
- * For example:
- *
- * float3 a, b;
- * // The following call sets
- * //   a.x to sin(b.x),
- * //   a.y to sin(b.y), and
- * //   a.z to sin(b.z).
- * a = sin(b);
- *
- *
- * A few functions like distance() and length() interpret instead the input
- * as a single vector in n-dimensional space.
- *
- * The precision of the mathematical operations is affected by the pragmas
- * rs_fp_relaxed and rs_fp_full.
- *
- * Different precision/speed tradeoffs can be achieved by using three variants
- * of common math functions.  Functions with a name starting with
- * native_ may have custom hardware implementations with weaker precision,
- * half_ may perform internal computations using 16 bit floats, and
- * fast_ are n-dimensional space computations that may use 16 bit floats.
- *
- */
-#ifndef RENDERSCRIPT_RS_CORE_MATH_RSH
-#define RENDERSCRIPT_RS_CORE_MATH_RSH
-
-/*
- * abs: Absolute value of an integer
- *
- * Returns the absolute value of an integer.
- *
- * For floats, use fabs().
- */
-extern uchar __attribute__((const, overloadable))
-    abs(char v);
-
-extern uchar2 __attribute__((const, overloadable))
-    abs(char2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    abs(char3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    abs(char4 v);
-
-extern ushort __attribute__((const, overloadable))
-    abs(short v);
-
-extern ushort2 __attribute__((const, overloadable))
-    abs(short2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    abs(short3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    abs(short4 v);
-
-extern uint __attribute__((const, overloadable))
-    abs(int v);
-
-extern uint2 __attribute__((const, overloadable))
-    abs(int2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    abs(int3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    abs(int4 v);
-
-/*
- * acos: Inverse cosine
- *
- * Returns the inverse cosine, in radians.
- *
- * See also native_acos().
- */
-extern float __attribute__((const, overloadable))
-    acos(float v);
-
-extern float2 __attribute__((const, overloadable))
-    acos(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    acos(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    acos(float4 v);
-
-/*
- * acosh: Inverse hyperbolic cosine
- *
- * Returns the inverse hyperbolic cosine, in radians.
- *
- * See also native_acosh().
- */
-extern float __attribute__((const, overloadable))
-    acosh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    acosh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    acosh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    acosh(float4 v);
-
-/*
- * acospi: Inverse cosine divided by pi
- *
- * Returns the inverse cosine in radians, divided by pi.
- *
- * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
- *
- * See also native_acospi().
- */
-extern float __attribute__((const, overloadable))
-    acospi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    acospi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    acospi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    acospi(float4 v);
-
-/*
- * asin: Inverse sine
- *
- * Returns the inverse sine, in radians.
- *
- * See also native_asin().
- */
-extern float __attribute__((const, overloadable))
-    asin(float v);
-
-extern float2 __attribute__((const, overloadable))
-    asin(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    asin(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    asin(float4 v);
-
-/*
- * asinh: Inverse hyperbolic sine
- *
- * Returns the inverse hyperbolic sine, in radians.
- *
- * See also native_asinh().
- */
-extern float __attribute__((const, overloadable))
-    asinh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    asinh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    asinh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    asinh(float4 v);
-
-/*
- * asinpi: Inverse sine divided by pi
- *
- * Returns the inverse sine in radians, divided by pi.
- *
- * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
- *
- * See also native_asinpi().
- */
-extern float __attribute__((const, overloadable))
-    asinpi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    asinpi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    asinpi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    asinpi(float4 v);
-
-/*
- * atan: Inverse tangent
- *
- * Returns the inverse tangent, in radians.
- *
- * See also native_atan().
- */
-extern float __attribute__((const, overloadable))
-    atan(float v);
-
-extern float2 __attribute__((const, overloadable))
-    atan(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    atan(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    atan(float4 v);
-
-/*
- * atan2: Inverse tangent of a ratio
- *
- * Returns the inverse tangent of (numerator / denominator), in radians.
- *
- * See also native_atan2().
- *
- * Parameters:
- *   numerator The numerator
- *   denominator The denominator.  Can be 0.
- */
-extern float __attribute__((const, overloadable))
-    atan2(float numerator, float denominator);
-
-extern float2 __attribute__((const, overloadable))
-    atan2(float2 numerator, float2 denominator);
-
-extern float3 __attribute__((const, overloadable))
-    atan2(float3 numerator, float3 denominator);
-
-extern float4 __attribute__((const, overloadable))
-    atan2(float4 numerator, float4 denominator);
-
-/*
- * atan2pi: Inverse tangent of a ratio, divided by pi
- *
- * Returns the inverse tangent of (numerator / denominator), in radians, divided by pi.
- *
- * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
- *
- * See also native_atan2pi().
- *
- * Parameters:
- *   numerator The numerator
- *   denominator The denominator.  Can be 0.
- */
-extern float __attribute__((const, overloadable))
-    atan2pi(float numerator, float denominator);
-
-extern float2 __attribute__((const, overloadable))
-    atan2pi(float2 numerator, float2 denominator);
-
-extern float3 __attribute__((const, overloadable))
-    atan2pi(float3 numerator, float3 denominator);
-
-extern float4 __attribute__((const, overloadable))
-    atan2pi(float4 numerator, float4 denominator);
-
-/*
- * atanh: Inverse hyperbolic tangent
- *
- * Returns the inverse hyperbolic tangent, in radians.
- *
- * See also native_atanh().
- */
-extern float __attribute__((const, overloadable))
-    atanh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    atanh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    atanh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    atanh(float4 v);
-
-/*
- * atanpi: Inverse tangent divided by pi
- *
- * Returns the inverse tangent in radians, divided by pi.
- *
- * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
- *
- * See also native_atanpi().
- */
-extern float __attribute__((const, overloadable))
-    atanpi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    atanpi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    atanpi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    atanpi(float4 v);
-
-/*
- * cbrt: Cube root
- *
- * Returns the cube root.
- *
- * See also native_cbrt().
- */
-extern float __attribute__((const, overloadable))
-    cbrt(float v);
-
-extern float2 __attribute__((const, overloadable))
-    cbrt(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    cbrt(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    cbrt(float4 v);
-
-/*
- * ceil: Smallest integer not less than a value
- *
- * Returns the smallest integer not less than a value.
- *
- * For example, ceil(1.2f) returns 2.f, and ceil(-1.2f) returns -1.f.
- *
- * See also floor().
- */
-extern float __attribute__((const, overloadable))
-    ceil(float v);
-
-extern float2 __attribute__((const, overloadable))
-    ceil(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    ceil(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    ceil(float4 v);
-
-/*
- * clamp: Restrain a value to a range
- *
- * Clamps a value to a specified high and low bound.  clamp() returns min_value
- * if value < min_value, max_value if value > max_value, otherwise value.
- *
- * There are two variants of clamp: one where the min and max are scalars applied
- * to all entries of the value, the other where the min and max are also vectors.
- *
- * If min_value is greater than max_value, the results are undefined.
- *
- * Parameters:
- *   value Value to be clamped.
- *   min_value Lower bound, a scalar or matching vector.
- *   max_value High bound, must match the type of low.
- */
-extern float __attribute__((const, overloadable))
-    clamp(float value, float min_value, float max_value);
-
-extern float2 __attribute__((const, overloadable))
-    clamp(float2 value, float2 min_value, float2 max_value);
-
-extern float3 __attribute__((const, overloadable))
-    clamp(float3 value, float3 min_value, float3 max_value);
-
-extern float4 __attribute__((const, overloadable))
-    clamp(float4 value, float4 min_value, float4 max_value);
-
-extern float2 __attribute__((const, overloadable))
-    clamp(float2 value, float min_value, float max_value);
-
-extern float3 __attribute__((const, overloadable))
-    clamp(float3 value, float min_value, float max_value);
-
-extern float4 __attribute__((const, overloadable))
-    clamp(float4 value, float min_value, float max_value);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char __attribute__((const, overloadable))
-    clamp(char value, char min_value, char max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char2 __attribute__((const, overloadable))
-    clamp(char2 value, char2 min_value, char2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char3 __attribute__((const, overloadable))
-    clamp(char3 value, char3 min_value, char3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char4 __attribute__((const, overloadable))
-    clamp(char4 value, char4 min_value, char4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar __attribute__((const, overloadable))
-    clamp(uchar value, uchar min_value, uchar max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar2 __attribute__((const, overloadable))
-    clamp(uchar2 value, uchar2 min_value, uchar2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar3 __attribute__((const, overloadable))
-    clamp(uchar3 value, uchar3 min_value, uchar3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar4 __attribute__((const, overloadable))
-    clamp(uchar4 value, uchar4 min_value, uchar4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short __attribute__((const, overloadable))
-    clamp(short value, short min_value, short max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short2 __attribute__((const, overloadable))
-    clamp(short2 value, short2 min_value, short2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short3 __attribute__((const, overloadable))
-    clamp(short3 value, short3 min_value, short3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short4 __attribute__((const, overloadable))
-    clamp(short4 value, short4 min_value, short4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort __attribute__((const, overloadable))
-    clamp(ushort value, ushort min_value, ushort max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort2 __attribute__((const, overloadable))
-    clamp(ushort2 value, ushort2 min_value, ushort2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort3 __attribute__((const, overloadable))
-    clamp(ushort3 value, ushort3 min_value, ushort3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort4 __attribute__((const, overloadable))
-    clamp(ushort4 value, ushort4 min_value, ushort4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int __attribute__((const, overloadable))
-    clamp(int value, int min_value, int max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int2 __attribute__((const, overloadable))
-    clamp(int2 value, int2 min_value, int2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int3 __attribute__((const, overloadable))
-    clamp(int3 value, int3 min_value, int3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int4 __attribute__((const, overloadable))
-    clamp(int4 value, int4 min_value, int4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint __attribute__((const, overloadable))
-    clamp(uint value, uint min_value, uint max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint2 __attribute__((const, overloadable))
-    clamp(uint2 value, uint2 min_value, uint2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint3 __attribute__((const, overloadable))
-    clamp(uint3 value, uint3 min_value, uint3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint4 __attribute__((const, overloadable))
-    clamp(uint4 value, uint4 min_value, uint4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long __attribute__((const, overloadable))
-    clamp(long value, long min_value, long max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long2 __attribute__((const, overloadable))
-    clamp(long2 value, long2 min_value, long2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long3 __attribute__((const, overloadable))
-    clamp(long3 value, long3 min_value, long3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long4 __attribute__((const, overloadable))
-    clamp(long4 value, long4 min_value, long4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong __attribute__((const, overloadable))
-    clamp(ulong value, ulong min_value, ulong max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong2 __attribute__((const, overloadable))
-    clamp(ulong2 value, ulong2 min_value, ulong2 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong3 __attribute__((const, overloadable))
-    clamp(ulong3 value, ulong3 min_value, ulong3 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong4 __attribute__((const, overloadable))
-    clamp(ulong4 value, ulong4 min_value, ulong4 max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char2 __attribute__((const, overloadable))
-    clamp(char2 value, char min_value, char max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char3 __attribute__((const, overloadable))
-    clamp(char3 value, char min_value, char max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern char4 __attribute__((const, overloadable))
-    clamp(char4 value, char min_value, char max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar2 __attribute__((const, overloadable))
-    clamp(uchar2 value, uchar min_value, uchar max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar3 __attribute__((const, overloadable))
-    clamp(uchar3 value, uchar min_value, uchar max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uchar4 __attribute__((const, overloadable))
-    clamp(uchar4 value, uchar min_value, uchar max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short2 __attribute__((const, overloadable))
-    clamp(short2 value, short min_value, short max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short3 __attribute__((const, overloadable))
-    clamp(short3 value, short min_value, short max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern short4 __attribute__((const, overloadable))
-    clamp(short4 value, short min_value, short max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort2 __attribute__((const, overloadable))
-    clamp(ushort2 value, ushort min_value, ushort max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort3 __attribute__((const, overloadable))
-    clamp(ushort3 value, ushort min_value, ushort max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ushort4 __attribute__((const, overloadable))
-    clamp(ushort4 value, ushort min_value, ushort max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int2 __attribute__((const, overloadable))
-    clamp(int2 value, int min_value, int max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int3 __attribute__((const, overloadable))
-    clamp(int3 value, int min_value, int max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern int4 __attribute__((const, overloadable))
-    clamp(int4 value, int min_value, int max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint2 __attribute__((const, overloadable))
-    clamp(uint2 value, uint min_value, uint max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint3 __attribute__((const, overloadable))
-    clamp(uint3 value, uint min_value, uint max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern uint4 __attribute__((const, overloadable))
-    clamp(uint4 value, uint min_value, uint max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long2 __attribute__((const, overloadable))
-    clamp(long2 value, long min_value, long max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long3 __attribute__((const, overloadable))
-    clamp(long3 value, long min_value, long max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern long4 __attribute__((const, overloadable))
-    clamp(long4 value, long min_value, long max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong2 __attribute__((const, overloadable))
-    clamp(ulong2 value, ulong min_value, ulong max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong3 __attribute__((const, overloadable))
-    clamp(ulong3 value, ulong min_value, ulong max_value);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 19))
-extern ulong4 __attribute__((const, overloadable))
-    clamp(ulong4 value, ulong min_value, ulong max_value);
-#endif
-
-/*
- * clz: Number of leading 0 bits
- *
- * Returns the number of leading 0-bits in a value.
- *
- * For example, clz((char)0x03) returns 6.
- */
-extern char __attribute__((const, overloadable))
-    clz(char value);
-
-extern char2 __attribute__((const, overloadable))
-    clz(char2 value);
-
-extern char3 __attribute__((const, overloadable))
-    clz(char3 value);
-
-extern char4 __attribute__((const, overloadable))
-    clz(char4 value);
-
-extern uchar __attribute__((const, overloadable))
-    clz(uchar value);
-
-extern uchar2 __attribute__((const, overloadable))
-    clz(uchar2 value);
-
-extern uchar3 __attribute__((const, overloadable))
-    clz(uchar3 value);
-
-extern uchar4 __attribute__((const, overloadable))
-    clz(uchar4 value);
-
-extern short __attribute__((const, overloadable))
-    clz(short value);
-
-extern short2 __attribute__((const, overloadable))
-    clz(short2 value);
-
-extern short3 __attribute__((const, overloadable))
-    clz(short3 value);
-
-extern short4 __attribute__((const, overloadable))
-    clz(short4 value);
-
-extern ushort __attribute__((const, overloadable))
-    clz(ushort value);
-
-extern ushort2 __attribute__((const, overloadable))
-    clz(ushort2 value);
-
-extern ushort3 __attribute__((const, overloadable))
-    clz(ushort3 value);
-
-extern ushort4 __attribute__((const, overloadable))
-    clz(ushort4 value);
-
-extern int __attribute__((const, overloadable))
-    clz(int value);
-
-extern int2 __attribute__((const, overloadable))
-    clz(int2 value);
-
-extern int3 __attribute__((const, overloadable))
-    clz(int3 value);
-
-extern int4 __attribute__((const, overloadable))
-    clz(int4 value);
-
-extern uint __attribute__((const, overloadable))
-    clz(uint value);
-
-extern uint2 __attribute__((const, overloadable))
-    clz(uint2 value);
-
-extern uint3 __attribute__((const, overloadable))
-    clz(uint3 value);
-
-extern uint4 __attribute__((const, overloadable))
-    clz(uint4 value);
-
-/*
- * convert: Converts numerical vectors
- *
- * Component wise conversion from a numerical type to another.
- *
- * Conversions of floating point values to integer will truncate.
- *
- * Conversions of numbers too large to fit the destination type yield undefined results.
- * For example, converting a float that contains 1.0e18 to a short is undefined.
- * Use clamp() to avoid this.
- */
-extern float2 __attribute__((const, overloadable))
-    convert_float2(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(float4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(char2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(char3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(char4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(uchar2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(uchar3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(uchar4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(short2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(short3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(short4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(ushort2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(ushort3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(ushort4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(int2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(int3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(int4 v);
-
-extern float2 __attribute__((const, overloadable))
-    convert_float2(uint2 v);
-
-extern float3 __attribute__((const, overloadable))
-    convert_float3(uint3 v);
-
-extern float4 __attribute__((const, overloadable))
-    convert_float4(uint4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(float2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(float3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(float4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(char2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(char3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(char4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(uchar2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(uchar3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(uchar4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(short2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(short3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(short4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(ushort2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(ushort3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(ushort4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(int2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(int3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(int4 v);
-
-extern char2 __attribute__((const, overloadable))
-    convert_char2(uint2 v);
-
-extern char3 __attribute__((const, overloadable))
-    convert_char3(uint3 v);
-
-extern char4 __attribute__((const, overloadable))
-    convert_char4(uint4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(float2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(float3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(float4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(char2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(char3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(char4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(uchar2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(uchar3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(uchar4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(short2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(short3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(short4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(ushort2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(ushort3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(ushort4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(int2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(int3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(int4 v);
-
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(uint2 v);
-
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(uint3 v);
-
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(uint4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(float2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(float3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(float4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(char2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(char3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(char4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(uchar2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(uchar3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(uchar4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(short2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(short3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(short4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(ushort2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(ushort3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(ushort4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(int2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(int3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(int4 v);
-
-extern short2 __attribute__((const, overloadable))
-    convert_short2(uint2 v);
-
-extern short3 __attribute__((const, overloadable))
-    convert_short3(uint3 v);
-
-extern short4 __attribute__((const, overloadable))
-    convert_short4(uint4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(float2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(float3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(float4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(char2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(char3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(char4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(uchar2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(uchar3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(uchar4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(short2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(short3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(short4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(ushort2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(ushort3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(ushort4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(int2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(int3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(int4 v);
-
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(uint2 v);
-
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(uint3 v);
-
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(uint4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(float2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(float3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(float4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(char2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(char3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(char4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(uchar2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(uchar3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(uchar4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(short2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(short3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(short4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(ushort2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(ushort3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(ushort4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(int2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(int3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(int4 v);
-
-extern int2 __attribute__((const, overloadable))
-    convert_int2(uint2 v);
-
-extern int3 __attribute__((const, overloadable))
-    convert_int3(uint3 v);
-
-extern int4 __attribute__((const, overloadable))
-    convert_int4(uint4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(float2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(float3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(float4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(char2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(char3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(char4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(uchar2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(uchar3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(uchar4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(short2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(short3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(short4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(ushort2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(ushort3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(ushort4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(int2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(int3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(int4 v);
-
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(uint2 v);
-
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(uint3 v);
-
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(uint4 v);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    convert_float2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    convert_float3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    convert_float4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    convert_float2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    convert_float3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    convert_float4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    convert_float2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    convert_float3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    convert_float4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char2 __attribute__((const, overloadable))
-    convert_char2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char3 __attribute__((const, overloadable))
-    convert_char3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char4 __attribute__((const, overloadable))
-    convert_char4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char2 __attribute__((const, overloadable))
-    convert_char2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char3 __attribute__((const, overloadable))
-    convert_char3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char4 __attribute__((const, overloadable))
-    convert_char4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char2 __attribute__((const, overloadable))
-    convert_char2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char3 __attribute__((const, overloadable))
-    convert_char3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char4 __attribute__((const, overloadable))
-    convert_char4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar2 __attribute__((const, overloadable))
-    convert_uchar2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar3 __attribute__((const, overloadable))
-    convert_uchar3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar4 __attribute__((const, overloadable))
-    convert_uchar4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short2 __attribute__((const, overloadable))
-    convert_short2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short3 __attribute__((const, overloadable))
-    convert_short3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short4 __attribute__((const, overloadable))
-    convert_short4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short2 __attribute__((const, overloadable))
-    convert_short2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short3 __attribute__((const, overloadable))
-    convert_short3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short4 __attribute__((const, overloadable))
-    convert_short4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short2 __attribute__((const, overloadable))
-    convert_short2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short3 __attribute__((const, overloadable))
-    convert_short3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short4 __attribute__((const, overloadable))
-    convert_short4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort2 __attribute__((const, overloadable))
-    convert_ushort2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort3 __attribute__((const, overloadable))
-    convert_ushort3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort4 __attribute__((const, overloadable))
-    convert_ushort4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int2 __attribute__((const, overloadable))
-    convert_int2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int3 __attribute__((const, overloadable))
-    convert_int3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int4 __attribute__((const, overloadable))
-    convert_int4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int2 __attribute__((const, overloadable))
-    convert_int2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int3 __attribute__((const, overloadable))
-    convert_int3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int4 __attribute__((const, overloadable))
-    convert_int4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int2 __attribute__((const, overloadable))
-    convert_int2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int3 __attribute__((const, overloadable))
-    convert_int3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int4 __attribute__((const, overloadable))
-    convert_int4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(double2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(double3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(double4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(long2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(long3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(long4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint2 __attribute__((const, overloadable))
-    convert_uint2(ulong2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint3 __attribute__((const, overloadable))
-    convert_uint3(ulong3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint4 __attribute__((const, overloadable))
-    convert_uint4(ulong4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(float4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(char2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(char3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(char4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(uchar2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(uchar3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(uchar4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(short2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(short3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(short4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(ushort2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(ushort3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(ushort4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(int2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(int3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(int4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double2 __attribute__((const, overloadable))
-    convert_double2(uint2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double3 __attribute__((const, overloadable))
-    convert_double3(uint3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern double4 __attribute__((const, overloadable))
-    convert_double4(uint4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(float4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(char2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(char3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(char4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(uchar2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(uchar3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(uchar4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(short2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(short3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(short4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(ushort2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(ushort3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(ushort4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(int2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(int3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(int4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    convert_long2(uint2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    convert_long3(uint3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    convert_long4(uint4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(float4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(char2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(char3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(char4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(uchar2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(uchar3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(uchar4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(short2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(short3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(short4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(ushort2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(ushort3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(ushort4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(int2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(int3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(int4 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    convert_ulong2(uint2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    convert_ulong3(uint3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    convert_ulong4(uint4 v);
-#endif
-
-/*
- * copysign: Copies the sign of a number to another
- *
- * Copies the sign from sign_value to magnitude_value.
- *
- * The value returned is either magnitude_value or -magnitude_value.
- *
- * For example, copysign(4.0f, -2.7f) returns -4.0f and copysign(-4.0f, 2.7f) returns 4.0f.
- */
-extern float __attribute__((const, overloadable))
-    copysign(float magnitude_value, float sign_value);
-
-extern float2 __attribute__((const, overloadable))
-    copysign(float2 magnitude_value, float2 sign_value);
-
-extern float3 __attribute__((const, overloadable))
-    copysign(float3 magnitude_value, float3 sign_value);
-
-extern float4 __attribute__((const, overloadable))
-    copysign(float4 magnitude_value, float4 sign_value);
-
-/*
- * cos: Cosine
- *
- * Returns the cosine of an angle measured in radians.
- *
- * See also native_cos().
- */
-extern float __attribute__((const, overloadable))
-    cos(float v);
-
-extern float2 __attribute__((const, overloadable))
-    cos(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    cos(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    cos(float4 v);
-
-/*
- * cosh: Hypebolic cosine
- *
- * Returns the hypebolic cosine of v, where v is measured in radians.
- *
- * See also native_cosh().
- */
-extern float __attribute__((const, overloadable))
-    cosh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    cosh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    cosh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    cosh(float4 v);
-
-/*
- * cospi: Cosine of a number multiplied by pi
- *
- * Returns the cosine of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
- *
- * See also native_cospi().
- */
-extern float __attribute__((const, overloadable))
-    cospi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    cospi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    cospi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    cospi(float4 v);
-
-/*
- * cross: Cross product of two vectors
- *
- * Computes the cross product of two vectors.
- */
-extern float3 __attribute__((const, overloadable))
-    cross(float3 left_vector, float3 right_vector);
-
-extern float4 __attribute__((const, overloadable))
-    cross(float4 left_vector, float4 right_vector);
-
-/*
- * degrees: Converts radians into degrees
- *
- * Converts from radians to degrees.
- */
-extern float __attribute__((const, overloadable))
-    degrees(float v);
-
-extern float2 __attribute__((const, overloadable))
-    degrees(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    degrees(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    degrees(float4 v);
-
-/*
- * distance: Distance between two points
- *
- * Compute the distance between two points.
- *
- * See also fast_distance(), native_distance().
- */
-extern float __attribute__((const, overloadable))
-    distance(float left_vector, float right_vector);
-
-extern float __attribute__((const, overloadable))
-    distance(float2 left_vector, float2 right_vector);
-
-extern float __attribute__((const, overloadable))
-    distance(float3 left_vector, float3 right_vector);
-
-extern float __attribute__((const, overloadable))
-    distance(float4 left_vector, float4 right_vector);
-
-/*
- * dot: Dot product of two vectors
- *
- * Computes the dot product of two vectors.
- */
-extern float __attribute__((const, overloadable))
-    dot(float left_vector, float right_vector);
-
-extern float __attribute__((const, overloadable))
-    dot(float2 left_vector, float2 right_vector);
-
-extern float __attribute__((const, overloadable))
-    dot(float3 left_vector, float3 right_vector);
-
-extern float __attribute__((const, overloadable))
-    dot(float4 left_vector, float4 right_vector);
-
-/*
- * erf: Mathematical error function
- *
- * Returns the error function.
- */
-extern float __attribute__((const, overloadable))
-    erf(float v);
-
-extern float2 __attribute__((const, overloadable))
-    erf(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    erf(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    erf(float4 v);
-
-/*
- * erfc: Mathematical complementary error function
- *
- * Returns the complementary error function.
- */
-extern float __attribute__((const, overloadable))
-    erfc(float v);
-
-extern float2 __attribute__((const, overloadable))
-    erfc(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    erfc(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    erfc(float4 v);
-
-/*
- * exp: e raised to a number
- *
- * Returns e raised to v, i.e. e ^ v.
- *
- * See also native_exp().
- */
-extern float __attribute__((const, overloadable))
-    exp(float v);
-
-extern float2 __attribute__((const, overloadable))
-    exp(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    exp(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    exp(float4 v);
-
-/*
- * exp10: 10 raised to a number
- *
- * Returns 10 raised to v, i.e. 10.f ^ v.
- *
- * See also native_exp10().
- */
-extern float __attribute__((const, overloadable))
-    exp10(float v);
-
-extern float2 __attribute__((const, overloadable))
-    exp10(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    exp10(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    exp10(float4 v);
-
-/*
- * exp2: 2 raised to a number
- *
- * Returns 2 raised to v, i.e. 2.f ^ v.
- *
- * See also native_exp2().
- */
-extern float __attribute__((const, overloadable))
-    exp2(float v);
-
-extern float2 __attribute__((const, overloadable))
-    exp2(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    exp2(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    exp2(float4 v);
-
-/*
- * expm1: e raised to a number minus one
- *
- * Returns e raised to v minus 1, i.e. (e ^ v) - 1.
- *
- * See also native_expm1().
- */
-extern float __attribute__((const, overloadable))
-    expm1(float v);
-
-extern float2 __attribute__((const, overloadable))
-    expm1(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    expm1(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    expm1(float4 v);
-
-/*
- * fabs: Absolute value of a float
- *
- * Returns the absolute value of the float v.
- *
- * For integers, use abs().
- */
-extern float __attribute__((const, overloadable))
-    fabs(float v);
-
-extern float2 __attribute__((const, overloadable))
-    fabs(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    fabs(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    fabs(float4 v);
-
-/*
- * fast_distance: Approximate distance between two points
- *
- * Computes the approximate distance between two points.
- *
- * The precision is what would be expected from doing the computation using 16 bit floating point values.
- *
- * See also distance(), native_distance().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_distance(float left_vector, float right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_distance(float2 left_vector, float2 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_distance(float3 left_vector, float3 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_distance(float4 left_vector, float4 right_vector);
-#endif
-
-/*
- * fast_length: Approximate length of a vector
- *
- * Computes the approximate length of a vector.
- *
- * The precision is what would be expected from doing the computation using 16 bit floating point values.
- *
- * See also length(), native_length().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_length(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_length(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_length(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_length(float4 v);
-#endif
-
-/*
- * fast_normalize: Approximate normalized vector
- *
- * Approximately normalizes a vector.
- *
- * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
- *
- * The precision is what would be expected from doing the computation using 16 bit floating point values.
- *
- * See also normalize(), native_normalize().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    fast_normalize(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float2 __attribute__((const, overloadable))
-    fast_normalize(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float3 __attribute__((const, overloadable))
-    fast_normalize(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float4 __attribute__((const, overloadable))
-    fast_normalize(float4 v);
-#endif
-
-/*
- * fdim: Positive difference between two values
- *
- * Returns the positive difference between two values.
- *
- * If a > b, returns (a - b) otherwise returns 0f.
- */
-extern float __attribute__((const, overloadable))
-    fdim(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    fdim(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    fdim(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    fdim(float4 a, float4 b);
-
-/*
- * floor: Smallest integer not greater than a value
- *
- * Returns the smallest integer not greater than a value.
- *
- * For example, floor(1.2f) returns 1.f, and floor(-1.2f) returns -2.f.
- *
- * See also ceil().
- */
-extern float __attribute__((const, overloadable))
-    floor(float v);
-
-extern float2 __attribute__((const, overloadable))
-    floor(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    floor(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    floor(float4 v);
-
-/*
- * fma: Multiply and add
- *
- * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
- *
- * This function is similar to mad().  fma() retains full precision of the
- * multiplied result and rounds only after the addition.  mad() rounds after the
- * multiplication and the addition.  This extra precision is not guaranteed in
- * rs_fp_relaxed mode.
- */
-extern float __attribute__((const, overloadable))
-    fma(float multiplicand1, float multiplicand2, float offset);
-
-extern float2 __attribute__((const, overloadable))
-    fma(float2 multiplicand1, float2 multiplicand2, float2 offset);
-
-extern float3 __attribute__((const, overloadable))
-    fma(float3 multiplicand1, float3 multiplicand2, float3 offset);
-
-extern float4 __attribute__((const, overloadable))
-    fma(float4 multiplicand1, float4 multiplicand2, float4 offset);
-
-/*
- * fmax: Maximum of two floats
- *
- * Returns the maximum of a and b, i.e. (a < b ? b : a).
- *
- * The max() function returns identical results but can be applied to more data types.
- */
-extern float __attribute__((const, overloadable))
-    fmax(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    fmax(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    fmax(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    fmax(float4 a, float4 b);
-
-extern float2 __attribute__((const, overloadable))
-    fmax(float2 a, float b);
-
-extern float3 __attribute__((const, overloadable))
-    fmax(float3 a, float b);
-
-extern float4 __attribute__((const, overloadable))
-    fmax(float4 a, float b);
-
-/*
- * fmin: Minimum of two floats
- *
- * Returns the minimum of a and b, i.e. (a > b ? b : a).
- *
- * The min() function returns identical results but can be applied to more data types.
- */
-extern float __attribute__((const, overloadable))
-    fmin(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    fmin(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    fmin(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    fmin(float4 a, float4 b);
-
-extern float2 __attribute__((const, overloadable))
-    fmin(float2 a, float b);
-
-extern float3 __attribute__((const, overloadable))
-    fmin(float3 a, float b);
-
-extern float4 __attribute__((const, overloadable))
-    fmin(float4 a, float b);
-
-/*
- * fmod: Modulo
- *
- * Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
- *
- * The function remainder() is similar but rounds toward the closest interger.
- * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
- * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
- */
-extern float __attribute__((const, overloadable))
-    fmod(float numerator, float denominator);
-
-extern float2 __attribute__((const, overloadable))
-    fmod(float2 numerator, float2 denominator);
-
-extern float3 __attribute__((const, overloadable))
-    fmod(float3 numerator, float3 denominator);
-
-extern float4 __attribute__((const, overloadable))
-    fmod(float4 numerator, float4 denominator);
-
-/*
- * fract: Positive fractional part
- *
- * Returns the positive fractional part of v, i.e. v - floor(v).
- *
- * For example, fract(1.3f, &val) returns 0.3f and sets val to 1.f.
- * fract(-1.3f, &val) returns 0.7f and sets val to -2.f.
- *
- * Parameters:
- *   v Input value.
- *   floor If floor is not null, *floor will be set to the floor of v.
- */
-extern float __attribute__((overloadable))
-    fract(float v, float* floor);
-
-extern float2 __attribute__((overloadable))
-    fract(float2 v, float2* floor);
-
-extern float3 __attribute__((overloadable))
-    fract(float3 v, float3* floor);
-
-extern float4 __attribute__((overloadable))
-    fract(float4 v, float4* floor);
-
-static inline float __attribute__((const, overloadable))
-    fract(float v) {
-    float unused;
-    return fract(v, &unused);
-}
-
-static inline float2 __attribute__((const, overloadable))
-    fract(float2 v) {
-    float2 unused;
-    return fract(v, &unused);
-}
-
-static inline float3 __attribute__((const, overloadable))
-    fract(float3 v) {
-    float3 unused;
-    return fract(v, &unused);
-}
-
-static inline float4 __attribute__((const, overloadable))
-    fract(float4 v) {
-    float4 unused;
-    return fract(v, &unused);
-}
-
-/*
- * frexp: Binary mantissa and exponent
- *
- * Returns the binary mantissa and exponent of v, i.e. v == mantissa * 2 ^ exponent.
- *
- * The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
- *
- * See ldexp() for the reverse operation.  See also logb() and ilogb().
- *
- * Parameters:
- *   v Input value.
- *   exponent If exponent is not null, *exponent will be set to the exponent of v.
- */
-extern float __attribute__((overloadable))
-    frexp(float v, int* exponent);
-
-extern float2 __attribute__((overloadable))
-    frexp(float2 v, int2* exponent);
-
-extern float3 __attribute__((overloadable))
-    frexp(float3 v, int3* exponent);
-
-extern float4 __attribute__((overloadable))
-    frexp(float4 v, int4* exponent);
-
-/*
- * half_recip: Reciprocal computed to 16 bit precision
- *
- * Returns the approximate reciprocal of a value.
- *
- * The precision is that of a 16 bit floating point value.
- *
- * See also native_recip().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    half_recip(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float2 __attribute__((const, overloadable))
-    half_recip(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float3 __attribute__((const, overloadable))
-    half_recip(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float4 __attribute__((const, overloadable))
-    half_recip(float4 v);
-#endif
-
-/*
- * half_rsqrt: Reciprocal of a square root computed to 16 bit precision
- *
- * Returns the approximate value of (1.f / sqrt(value)).
- *
- * The precision is that of a 16 bit floating point value.
- *
- * See also rsqrt(), native_rsqrt().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    half_rsqrt(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float2 __attribute__((const, overloadable))
-    half_rsqrt(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float3 __attribute__((const, overloadable))
-    half_rsqrt(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float4 __attribute__((const, overloadable))
-    half_rsqrt(float4 v);
-#endif
-
-/*
- * half_sqrt: Square root computed to 16 bit precision
- *
- * Returns the approximate square root of a value.
- *
- * The precision is that of a 16 bit floating point value.
- *
- * See also sqrt(), native_sqrt().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float __attribute__((const, overloadable))
-    half_sqrt(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float2 __attribute__((const, overloadable))
-    half_sqrt(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float3 __attribute__((const, overloadable))
-    half_sqrt(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-extern float4 __attribute__((const, overloadable))
-    half_sqrt(float4 v);
-#endif
-
-/*
- * hypot: Hypotenuse
- *
- * Returns the hypotenuse, i.e. sqrt(a * a + b * b).
- *
- * See also native_hypot().
- */
-extern float __attribute__((const, overloadable))
-    hypot(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    hypot(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    hypot(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    hypot(float4 a, float4 b);
-
-/*
- * ilogb: Base two exponent
- *
- * Returns the base two exponent of a value, where the mantissa is between
- * 1.f (inclusive) and 2.f (exclusive).
- *
- * For example, ilogb(8.5f) returns 3.
- *
- * Because of the difference in mantissa, this number is one less than
- * is returned by frexp().
- *
- * logb() is similar but returns a float.
- */
-extern int __attribute__((const, overloadable))
-    ilogb(float v);
-
-extern int2 __attribute__((const, overloadable))
-    ilogb(float2 v);
-
-extern int3 __attribute__((const, overloadable))
-    ilogb(float3 v);
-
-extern int4 __attribute__((const, overloadable))
-    ilogb(float4 v);
-
-/*
- * ldexp: Creates a floating point from mantissa and exponent
- *
- * Returns the floating point created from the mantissa and exponent,
- * i.e. (mantissa * 2 ^ exponent).
- *
- * See frexp() for the reverse operation.
- *
- * Parameters:
- *   mantissa The mantissa
- *   exponent The exponent, a single component or matching vector.
- */
-extern float __attribute__((const, overloadable))
-    ldexp(float mantissa, int exponent);
-
-extern float2 __attribute__((const, overloadable))
-    ldexp(float2 mantissa, int2 exponent);
-
-extern float3 __attribute__((const, overloadable))
-    ldexp(float3 mantissa, int3 exponent);
-
-extern float4 __attribute__((const, overloadable))
-    ldexp(float4 mantissa, int4 exponent);
-
-extern float2 __attribute__((const, overloadable))
-    ldexp(float2 mantissa, int exponent);
-
-extern float3 __attribute__((const, overloadable))
-    ldexp(float3 mantissa, int exponent);
-
-extern float4 __attribute__((const, overloadable))
-    ldexp(float4 mantissa, int exponent);
-
-/*
- * length: Length of a vector
- *
- * Computes the length of a vector.
- *
- * See also fast_length(), native_length().
- */
-extern float __attribute__((const, overloadable))
-    length(float v);
-
-extern float __attribute__((const, overloadable))
-    length(float2 v);
-
-extern float __attribute__((const, overloadable))
-    length(float3 v);
-
-extern float __attribute__((const, overloadable))
-    length(float4 v);
-
-/*
- * lgamma: Natural logarithm of the gamma function
- *
- * Returns the natural logarithm of the absolute value of the gamma function,
- * i.e. log(fabs(tgamma(v))).
- *
- * See also tgamma().
- *
- * Parameters:
- *   sign_of_gamma If sign_of_gamma is not null, *sign_of_gamma will be set to -1.f if the gamma of v is negative, otherwise to 1.f.
- */
-extern float __attribute__((const, overloadable))
-    lgamma(float v);
-
-extern float2 __attribute__((const, overloadable))
-    lgamma(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    lgamma(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    lgamma(float4 v);
-
-extern float __attribute__((overloadable))
-    lgamma(float v, int* sign_of_gamma);
-
-extern float2 __attribute__((overloadable))
-    lgamma(float2 v, int2* sign_of_gamma);
-
-extern float3 __attribute__((overloadable))
-    lgamma(float3 v, int3* sign_of_gamma);
-
-extern float4 __attribute__((overloadable))
-    lgamma(float4 v, int4* sign_of_gamma);
-
-/*
- * log: Natural logarithm
- *
- * Returns the natural logarithm.
- *
- * See also native_log().
- */
-extern float __attribute__((const, overloadable))
-    log(float v);
-
-extern float2 __attribute__((const, overloadable))
-    log(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    log(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    log(float4 v);
-
-/*
- * log10: Base 10 logarithm
- *
- * Returns the base 10 logarithm.
- *
- * See also native_log10().
- */
-extern float __attribute__((const, overloadable))
-    log10(float v);
-
-extern float2 __attribute__((const, overloadable))
-    log10(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    log10(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    log10(float4 v);
-
-/*
- * log1p: Natural logarithm of a value plus 1
- *
- * Returns the natural logarithm of (v + 1.f).
- *
- * See also native_log1p().
- */
-extern float __attribute__((const, overloadable))
-    log1p(float v);
-
-extern float2 __attribute__((const, overloadable))
-    log1p(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    log1p(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    log1p(float4 v);
-
-/*
- * log2: Base 2 logarithm
- *
- * Returns the base 2 logarithm.
- *
- * See also native_log2().
- */
-extern float __attribute__((const, overloadable))
-    log2(float v);
-
-extern float2 __attribute__((const, overloadable))
-    log2(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    log2(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    log2(float4 v);
-
-/*
- * logb: Base two exponent
- *
- * Returns the base two exponent of a value, where the mantissa is between
- * 1.f (inclusive) and 2.f (exclusive).
- *
- * For example, logb(8.5f) returns 3.f.
- *
- * Because of the difference in mantissa, this number is one less than
- * is returned by frexp().
- *
- * ilogb() is similar but returns an integer.
- */
-extern float __attribute__((const, overloadable))
-    logb(float v);
-
-extern float2 __attribute__((const, overloadable))
-    logb(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    logb(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    logb(float4 v);
-
-/*
- * mad: Multiply and add
- *
- * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
- *
- * This function is similar to fma().  fma() retains full precision of the
- * multiplied result and rounds only after the addition.  mad() rounds after the
- * multiplication and the addition.  In rs_fp_relaxed mode, mad() may not do the
- * rounding after multiplicaiton.
- */
-extern float __attribute__((const, overloadable))
-    mad(float multiplicand1, float multiplicand2, float offset);
-
-extern float2 __attribute__((const, overloadable))
-    mad(float2 multiplicand1, float2 multiplicand2, float2 offset);
-
-extern float3 __attribute__((const, overloadable))
-    mad(float3 multiplicand1, float3 multiplicand2, float3 offset);
-
-extern float4 __attribute__((const, overloadable))
-    mad(float4 multiplicand1, float4 multiplicand2, float4 offset);
-
-/*
- * max: Maximum
- *
- * Returns the maximum value of two arguments.
- */
-extern float __attribute__((const, overloadable))
-    max(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    max(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    max(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    max(float4 a, float4 b);
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char __attribute__((const, overloadable))
-    max(char a, char b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar __attribute__((const, overloadable))
-    max(uchar a, uchar b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short __attribute__((const, overloadable))
-    max(short a, short b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort __attribute__((const, overloadable))
-    max(ushort a, ushort b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int __attribute__((const, overloadable))
-    max(int a, int b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint __attribute__((const, overloadable))
-    max(uint a, uint b) {
-    return (a > b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char2 __attribute__((const, overloadable))
-    max(char2 a, char2 b) {
-    char2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar2 __attribute__((const, overloadable))
-    max(uchar2 a, uchar2 b) {
-    uchar2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short2 __attribute__((const, overloadable))
-    max(short2 a, short2 b) {
-    short2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort2 __attribute__((const, overloadable))
-    max(ushort2 a, ushort2 b) {
-    ushort2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int2 __attribute__((const, overloadable))
-    max(int2 a, int2 b) {
-    int2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint2 __attribute__((const, overloadable))
-    max(uint2 a, uint2 b) {
-    uint2 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char3 __attribute__((const, overloadable))
-    max(char3 a, char3 b) {
-    char3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar3 __attribute__((const, overloadable))
-    max(uchar3 a, uchar3 b) {
-    uchar3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short3 __attribute__((const, overloadable))
-    max(short3 a, short3 b) {
-    short3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort3 __attribute__((const, overloadable))
-    max(ushort3 a, ushort3 b) {
-    ushort3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int3 __attribute__((const, overloadable))
-    max(int3 a, int3 b) {
-    int3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint3 __attribute__((const, overloadable))
-    max(uint3 a, uint3 b) {
-    uint3 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char4 __attribute__((const, overloadable))
-    max(char4 a, char4 b) {
-    char4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar4 __attribute__((const, overloadable))
-    max(uchar4 a, uchar4 b) {
-    uchar4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short4 __attribute__((const, overloadable))
-    max(short4 a, short4 b) {
-    short4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort4 __attribute__((const, overloadable))
-    max(ushort4 a, ushort4 b) {
-    ushort4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int4 __attribute__((const, overloadable))
-    max(int4 a, int4 b) {
-    int4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint4 __attribute__((const, overloadable))
-    max(uint4 a, uint4 b) {
-    uint4 tmp;
-    tmp.x = (a.x > b.x ? a.x : b.x);
-    tmp.y = (a.y > b.y ? a.y : b.y);
-    tmp.z = (a.z > b.z ? a.z : b.z);
-    tmp.w = (a.w > b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char __attribute__((const, overloadable))
-    max(char a, char b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char2 __attribute__((const, overloadable))
-    max(char2 a, char2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char3 __attribute__((const, overloadable))
-    max(char3 a, char3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char4 __attribute__((const, overloadable))
-    max(char4 a, char4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar __attribute__((const, overloadable))
-    max(uchar a, uchar b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar2 __attribute__((const, overloadable))
-    max(uchar2 a, uchar2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar3 __attribute__((const, overloadable))
-    max(uchar3 a, uchar3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar4 __attribute__((const, overloadable))
-    max(uchar4 a, uchar4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short __attribute__((const, overloadable))
-    max(short a, short b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short2 __attribute__((const, overloadable))
-    max(short2 a, short2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short3 __attribute__((const, overloadable))
-    max(short3 a, short3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short4 __attribute__((const, overloadable))
-    max(short4 a, short4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort __attribute__((const, overloadable))
-    max(ushort a, ushort b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort2 __attribute__((const, overloadable))
-    max(ushort2 a, ushort2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort3 __attribute__((const, overloadable))
-    max(ushort3 a, ushort3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort4 __attribute__((const, overloadable))
-    max(ushort4 a, ushort4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int __attribute__((const, overloadable))
-    max(int a, int b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int2 __attribute__((const, overloadable))
-    max(int2 a, int2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int3 __attribute__((const, overloadable))
-    max(int3 a, int3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int4 __attribute__((const, overloadable))
-    max(int4 a, int4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint __attribute__((const, overloadable))
-    max(uint a, uint b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint2 __attribute__((const, overloadable))
-    max(uint2 a, uint2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint3 __attribute__((const, overloadable))
-    max(uint3 a, uint3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint4 __attribute__((const, overloadable))
-    max(uint4 a, uint4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long __attribute__((const, overloadable))
-    max(long a, long b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    max(long2 a, long2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    max(long3 a, long3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    max(long4 a, long4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong __attribute__((const, overloadable))
-    max(ulong a, ulong b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    max(ulong2 a, ulong2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    max(ulong3 a, ulong3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    max(ulong4 a, ulong4 b);
-#endif
-
-/*
- * min: Minimum
- *
- * Returns the minimum value of two arguments.
- */
-extern float __attribute__((const, overloadable))
-    min(float a, float b);
-
-extern float2 __attribute__((const, overloadable))
-    min(float2 a, float2 b);
-
-extern float3 __attribute__((const, overloadable))
-    min(float3 a, float3 b);
-
-extern float4 __attribute__((const, overloadable))
-    min(float4 a, float4 b);
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char __attribute__((const, overloadable))
-    min(char a, char b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar __attribute__((const, overloadable))
-    min(uchar a, uchar b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short __attribute__((const, overloadable))
-    min(short a, short b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort __attribute__((const, overloadable))
-    min(ushort a, ushort b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int __attribute__((const, overloadable))
-    min(int a, int b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint __attribute__((const, overloadable))
-    min(uint a, uint b) {
-    return (a < b ? a : b);
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char2 __attribute__((const, overloadable))
-    min(char2 a, char2 b) {
-    char2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar2 __attribute__((const, overloadable))
-    min(uchar2 a, uchar2 b) {
-    uchar2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short2 __attribute__((const, overloadable))
-    min(short2 a, short2 b) {
-    short2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort2 __attribute__((const, overloadable))
-    min(ushort2 a, ushort2 b) {
-    ushort2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int2 __attribute__((const, overloadable))
-    min(int2 a, int2 b) {
-    int2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint2 __attribute__((const, overloadable))
-    min(uint2 a, uint2 b) {
-    uint2 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char3 __attribute__((const, overloadable))
-    min(char3 a, char3 b) {
-    char3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar3 __attribute__((const, overloadable))
-    min(uchar3 a, uchar3 b) {
-    uchar3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short3 __attribute__((const, overloadable))
-    min(short3 a, short3 b) {
-    short3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort3 __attribute__((const, overloadable))
-    min(ushort3 a, ushort3 b) {
-    ushort3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int3 __attribute__((const, overloadable))
-    min(int3 a, int3 b) {
-    int3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint3 __attribute__((const, overloadable))
-    min(uint3 a, uint3 b) {
-    uint3 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline char4 __attribute__((const, overloadable))
-    min(char4 a, char4 b) {
-    char4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uchar4 __attribute__((const, overloadable))
-    min(uchar4 a, uchar4 b) {
-    uchar4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline short4 __attribute__((const, overloadable))
-    min(short4 a, short4 b) {
-    short4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline ushort4 __attribute__((const, overloadable))
-    min(ushort4 a, ushort4 b) {
-    ushort4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline int4 __attribute__((const, overloadable))
-    min(int4 a, int4 b) {
-    int4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-static inline uint4 __attribute__((const, overloadable))
-    min(uint4 a, uint4 b) {
-    uint4 tmp;
-    tmp.x = (a.x < b.x ? a.x : b.x);
-    tmp.y = (a.y < b.y ? a.y : b.y);
-    tmp.z = (a.z < b.z ? a.z : b.z);
-    tmp.w = (a.w < b.w ? a.w : b.w);
-    return tmp;
-}
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char __attribute__((const, overloadable))
-    min(char a, char b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char2 __attribute__((const, overloadable))
-    min(char2 a, char2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char3 __attribute__((const, overloadable))
-    min(char3 a, char3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern char4 __attribute__((const, overloadable))
-    min(char4 a, char4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar __attribute__((const, overloadable))
-    min(uchar a, uchar b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar2 __attribute__((const, overloadable))
-    min(uchar2 a, uchar2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar3 __attribute__((const, overloadable))
-    min(uchar3 a, uchar3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uchar4 __attribute__((const, overloadable))
-    min(uchar4 a, uchar4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short __attribute__((const, overloadable))
-    min(short a, short b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short2 __attribute__((const, overloadable))
-    min(short2 a, short2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short3 __attribute__((const, overloadable))
-    min(short3 a, short3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern short4 __attribute__((const, overloadable))
-    min(short4 a, short4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort __attribute__((const, overloadable))
-    min(ushort a, ushort b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort2 __attribute__((const, overloadable))
-    min(ushort2 a, ushort2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort3 __attribute__((const, overloadable))
-    min(ushort3 a, ushort3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ushort4 __attribute__((const, overloadable))
-    min(ushort4 a, ushort4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int __attribute__((const, overloadable))
-    min(int a, int b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int2 __attribute__((const, overloadable))
-    min(int2 a, int2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int3 __attribute__((const, overloadable))
-    min(int3 a, int3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern int4 __attribute__((const, overloadable))
-    min(int4 a, int4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint __attribute__((const, overloadable))
-    min(uint a, uint b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint2 __attribute__((const, overloadable))
-    min(uint2 a, uint2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint3 __attribute__((const, overloadable))
-    min(uint3 a, uint3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern uint4 __attribute__((const, overloadable))
-    min(uint4 a, uint4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long __attribute__((const, overloadable))
-    min(long a, long b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long2 __attribute__((const, overloadable))
-    min(long2 a, long2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long3 __attribute__((const, overloadable))
-    min(long3 a, long3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern long4 __attribute__((const, overloadable))
-    min(long4 a, long4 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong __attribute__((const, overloadable))
-    min(ulong a, ulong b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong2 __attribute__((const, overloadable))
-    min(ulong2 a, ulong2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong3 __attribute__((const, overloadable))
-    min(ulong3 a, ulong3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern ulong4 __attribute__((const, overloadable))
-    min(ulong4 a, ulong4 b);
-#endif
-
-/*
- * mix: Mixes two values
- *
- * Returns start + ((stop - start) * fraction).
- *
- * This can be useful for mixing two values.  For example, to create a new color that is 40% color1 and 60% color2, use mix(color1, color2, 0.6f).
- */
-extern float __attribute__((const, overloadable))
-    mix(float start, float stop, float fraction);
-
-extern float2 __attribute__((const, overloadable))
-    mix(float2 start, float2 stop, float2 fraction);
-
-extern float3 __attribute__((const, overloadable))
-    mix(float3 start, float3 stop, float3 fraction);
-
-extern float4 __attribute__((const, overloadable))
-    mix(float4 start, float4 stop, float4 fraction);
-
-extern float2 __attribute__((const, overloadable))
-    mix(float2 start, float2 stop, float fraction);
-
-extern float3 __attribute__((const, overloadable))
-    mix(float3 start, float3 stop, float fraction);
-
-extern float4 __attribute__((const, overloadable))
-    mix(float4 start, float4 stop, float fraction);
-
-/*
- * modf: Integral and fractional components
- *
- * Returns the integral and fractional components of a number.
- *
- * Both components will have the same sign as x.  For example, for an input of -3.72f, iret will be set to -3.f and .72f will be returned.
- *
- * Parameters:
- *   v Source value
- *   integral_part *integral_part will be set to the integral portion of the number.
- *
- * Returns: The floating point portion of the value.
- */
-extern float __attribute__((overloadable))
-    modf(float v, float* integral_part);
-
-extern float2 __attribute__((overloadable))
-    modf(float2 v, float2* integral_part);
-
-extern float3 __attribute__((overloadable))
-    modf(float3 v, float3* integral_part);
-
-extern float4 __attribute__((overloadable))
-    modf(float4 v, float4* integral_part);
-
-/*
- * nan: Not a Number
- *
- * Returns a NaN value (Not a Number).
- *
- * Parameters:
- *   v Not used.
- */
-extern float __attribute__((const, overloadable))
-    nan(uint v);
-
-/*
- * native_acos: Approximate inverse cosine
- *
- * Returns the approximate inverse cosine, in radians.
- *
- * This function yields undefined results from input values less than -1 or greater
- * than 1.
- *
- * See also acos().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_acos(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_acos(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_acos(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_acos(float4 v);
-#endif
-
-/*
- * native_acosh: Approximate inverse hyperbolic cosine
- *
- * Returns the approximate inverse hyperbolic cosine, in radians.
- *
- * See also acosh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_acosh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_acosh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_acosh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_acosh(float4 v);
-#endif
-
-/*
- * native_acospi: Approximate inverse cosine divided by pi
- *
- * Returns the approximate inverse cosine in radians, divided by pi.
- *
- * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
- *
- * This function yields undefined results from input values less than -1 or greater
- * than 1.
- *
- * See also acospi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_acospi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_acospi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_acospi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_acospi(float4 v);
-#endif
-
-/*
- * native_asin: Approximate inverse sine
- *
- * Returns the approximate inverse sine, in radians.
- *
- * This function yields undefined results from input values less than -1 or greater
- * than 1.
- *
- * See also asin().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_asin(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_asin(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_asin(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_asin(float4 v);
-#endif
-
-/*
- * native_asinh: Approximate inverse hyperbolic sine
- *
- * Returns the approximate inverse hyperbolic sine, in radians.
- *
- * See also asinh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_asinh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_asinh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_asinh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_asinh(float4 v);
-#endif
-
-/*
- * native_asinpi: Approximate inverse sine divided by pi
- *
- * Returns the approximate inverse sine in radians, divided by pi.
- *
- * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
- *
- * This function yields undefined results from input values less than -1 or greater
- * than 1.
- *
- * See also asinpi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_asinpi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_asinpi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_asinpi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_asinpi(float4 v);
-#endif
-
-/*
- * native_atan: Approximate inverse tangent
- *
- * Returns the approximate inverse tangent, in radians.
- *
- * See also atan().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_atan(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_atan(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_atan(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_atan(float4 v);
-#endif
-
-/*
- * native_atan2: Approximate inverse tangent of a ratio
- *
- * Returns the approximate inverse tangent of (numerator / denominator), in radians.
- *
- * See also atan2().
- *
- * Parameters:
- *   numerator The numerator
- *   denominator The denominator.  Can be 0.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_atan2(float numerator, float denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_atan2(float2 numerator, float2 denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_atan2(float3 numerator, float3 denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_atan2(float4 numerator, float4 denominator);
-#endif
-
-/*
- * native_atan2pi: Approximate inverse tangent of a ratio, divided by pi
- *
- * Returns the approximate inverse tangent of (numerator / denominator), in radians, divided by pi.
- *
- * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
- *
- * See also atan2pi().
- *
- * Parameters:
- *   numerator The numerator
- *   denominator The denominator.  Can be 0.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_atan2pi(float numerator, float denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_atan2pi(float2 numerator, float2 denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_atan2pi(float3 numerator, float3 denominator);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_atan2pi(float4 numerator, float4 denominator);
-#endif
-
-/*
- * native_atanh: Approximate inverse hyperbolic tangent
- *
- * Returns the approximate inverse hyperbolic tangent, in radians.
- *
- * See also atanh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_atanh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_atanh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_atanh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_atanh(float4 v);
-#endif
-
-/*
- * native_atanpi: Approximate inverse tangent divided by pi
- *
- * Returns the approximate inverse tangent in radians, divided by pi.
- *
- * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
- *
- * See also atanpi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_atanpi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_atanpi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_atanpi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_atanpi(float4 v);
-#endif
-
-/*
- * native_cbrt: Approximate cube root
- *
- * Returns the approximate cubic root.
- *
- * See also cbrt().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_cbrt(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_cbrt(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_cbrt(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_cbrt(float4 v);
-#endif
-
-/*
- * native_cos: Approximate cosine
- *
- * Returns the approximate cosine of an angle measured in radians.
- *
- * See also cos().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_cos(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_cos(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_cos(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_cos(float4 v);
-#endif
-
-/*
- * native_cosh: Approximate hypebolic cosine
- *
- * Returns the approximate hypebolic cosine.
- *
- * See also cosh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_cosh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_cosh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_cosh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_cosh(float4 v);
-#endif
-
-/*
- * native_cospi: Approximate cosine of a number multiplied by pi
- *
- * Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
- *
- * See also cospi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_cospi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_cospi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_cospi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_cospi(float4 v);
-#endif
-
-/*
- * native_distance: Approximate distance between two points
- *
- * Computes the approximate distance between two points.
- *
- * See also distance(), fast_distance().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_distance(float left_vector, float right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_distance(float2 left_vector, float2 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_distance(float3 left_vector, float3 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_distance(float4 left_vector, float4 right_vector);
-#endif
-
-/*
- * native_divide: Approximate division
- *
- * Computes the approximate division of two values.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_divide(float left_vector, float right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_divide(float2 left_vector, float2 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_divide(float3 left_vector, float3 right_vector);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_divide(float4 left_vector, float4 right_vector);
-#endif
-
-/*
- * native_exp: Approximate e raised to a number
- *
- * Fast approximate exp.
- *
- * It is valid for inputs from -86.f to 86.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
- *
- * See also exp().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_exp(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_exp(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_exp(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_exp(float4 v);
-#endif
-
-/*
- * native_exp10: Approximate 10 raised to a number
- *
- * Fast approximate exp10.
- *
- * It is valid for inputs from -37.f to 37.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
- *
- * See also exp10().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_exp10(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_exp10(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_exp10(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_exp10(float4 v);
-#endif
-
-/*
- * native_exp2: Approximate 2 raised to a number
- *
- * Fast approximate exp2.
- *
- * It is valid for inputs from -125.f to 125.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
- *
- * See also exp2().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_exp2(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_exp2(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_exp2(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_exp2(float4 v);
-#endif
-
-/*
- * native_expm1: Approximate e raised to a number minus one
- *
- * Returns the approximate (e ^ v) - 1.
- *
- * See also expm1().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_expm1(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_expm1(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_expm1(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_expm1(float4 v);
-#endif
-
-/*
- * native_hypot: Approximate hypotenuse
- *
- * Returns the approximate native_sqrt(a * a + b * b)
- *
- * See also hypot().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_hypot(float a, float b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_hypot(float2 a, float2 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_hypot(float3 a, float3 b);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_hypot(float4 a, float4 b);
-#endif
-
-/*
- * native_length: Approximate length of a vector
- *
- * Compute the approximate length of a vector.
- *
- * See also length(), fast_length().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_length(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_length(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_length(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_length(float4 v);
-#endif
-
-/*
- * native_log: Approximate natural logarithm
- *
- * Fast approximate log.
- *
- * It is not accurate for values very close to zero.
- *
- * See also log().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_log(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_log(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_log(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_log(float4 v);
-#endif
-
-/*
- * native_log10: Approximate base 10 logarithm
- *
- * Fast approximate log10.
- *
- * It is not accurate for values very close to zero.
- *
- * See also log10().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_log10(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_log10(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_log10(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_log10(float4 v);
-#endif
-
-/*
- * native_log1p: Approximate natural logarithm of a value plus 1
- *
- * Returns the approximate natural logarithm of (v + 1.0f)
- *
- * See also log1p().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_log1p(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_log1p(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_log1p(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_log1p(float4 v);
-#endif
-
-/*
- * native_log2: Approximate base 2 logarithm
- *
- * Fast approximate log2.
- *
- * It is not accurate for values very close to zero.
- *
- * See also log2().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_log2(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_log2(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_log2(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_log2(float4 v);
-#endif
-
-/*
- * native_normalize: Approximately normalize a vector
- *
- * Approximately normalizes a vector.
- *
- * See also normalize(), fast_normalize().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_normalize(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_normalize(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_normalize(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_normalize(float4 v);
-#endif
-
-/*
- * native_powr: Approximate positive base raised to an exponent
- *
- * Fast approximate (base ^ exponent).
- *
- * See also powr().
- *
- * Parameters:
- *   base Must be between 0.f and 256.f.  The function is not accurate for values very close to zero.
- *   exponent Must be between -15.f and 15.f.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float __attribute__((const, overloadable))
-    native_powr(float base, float exponent);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float2 __attribute__((const, overloadable))
-    native_powr(float2 base, float2 exponent);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float3 __attribute__((const, overloadable))
-    native_powr(float3 base, float3 exponent);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 18))
-extern float4 __attribute__((const, overloadable))
-    native_powr(float4 base, float4 exponent);
-#endif
-
-/*
- * native_recip: Approximate reciprocal
- *
- * Returns the approximate approximate reciprocal of a value.
- *
- * See also half_recip().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_recip(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_recip(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_recip(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_recip(float4 v);
-#endif
-
-/*
- * native_rootn: Approximate nth root
- *
- * Compute the approximate Nth root of a value.
- *
- * See also rootn().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_rootn(float v, int n);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_rootn(float2 v, int2 n);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_rootn(float3 v, int3 n);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_rootn(float4 v, int4 n);
-#endif
-
-/*
- * native_rsqrt: Approximate reciprocal of a square root
- *
- * Returns approximate (1 / sqrt(v)).
- *
- * See also rsqrt(), half_rsqrt().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_rsqrt(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_rsqrt(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_rsqrt(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_rsqrt(float4 v);
-#endif
-
-/*
- * native_sin: Approximate sine
- *
- * Returns the approximate sine of an angle measured in radians.
- *
- * See also sin().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_sin(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_sin(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_sin(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_sin(float4 v);
-#endif
-
-/*
- * native_sincos: Approximate sine and cosine
- *
- * Returns the approximate sine and cosine of a value.
- *
- * See also sincos().
- *
- * Parameters:
- *   v The incoming value in radians.
- *   cos *cos will be set to the cosine value.
- *
- * Returns: sine
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((overloadable))
-    native_sincos(float v, float* cos);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((overloadable))
-    native_sincos(float2 v, float2* cos);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((overloadable))
-    native_sincos(float3 v, float3* cos);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((overloadable))
-    native_sincos(float4 v, float4* cos);
-#endif
-
-/*
- * native_sinh: Approximate hyperbolic sine
- *
- * Returns the approximate hyperbolic sine of a value specified in radians.
- *
- * See also sinh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_sinh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_sinh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_sinh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_sinh(float4 v);
-#endif
-
-/*
- * native_sinpi: Approximate sine of a number multiplied by pi
- *
- * Returns the approximate sine of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
- *
- * See also sinpi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_sinpi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_sinpi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_sinpi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_sinpi(float4 v);
-#endif
-
-/*
- * native_sqrt: Approximate square root
- *
- * Returns the approximate sqrt(v).
- *
- * See also sqrt(), half_sqrt().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_sqrt(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_sqrt(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_sqrt(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_sqrt(float4 v);
-#endif
-
-/*
- * native_tan: Approximate tangent
- *
- * Returns the approximate tangent of an angle measured in radians.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_tan(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_tan(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_tan(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_tan(float4 v);
-#endif
-
-/*
- * native_tanh: Approximate hyperbolic tangent
- *
- * Returns the approximate hyperbolic tangent of a value.
- *
- * See also tanh().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_tanh(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_tanh(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_tanh(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_tanh(float4 v);
-#endif
-
-/*
- * native_tanpi: Approximate tangent of a number multiplied by pi
- *
- * Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
- *
- * See also tanpi().
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float __attribute__((const, overloadable))
-    native_tanpi(float v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    native_tanpi(float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    native_tanpi(float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    native_tanpi(float4 v);
-#endif
-
-/*
- * nextafter: Next floating point number
- *
- * Returns the next representable floating point number from v towards target.
- *
- * In rs_fp_relaxed mode, a denormalized input value may not yield the next
- * denormalized  value, as support of denormalized values is optional in
- * relaxed mode.
- */
-extern float __attribute__((const, overloadable))
-    nextafter(float v, float target);
-
-extern float2 __attribute__((const, overloadable))
-    nextafter(float2 v, float2 target);
-
-extern float3 __attribute__((const, overloadable))
-    nextafter(float3 v, float3 target);
-
-extern float4 __attribute__((const, overloadable))
-    nextafter(float4 v, float4 target);
-
-/*
- * normalize: Normalize a vector
- *
- * Normalize a vector.
- *
- * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
- *
- * See also fast_normalize(), native_normalize().
- */
-extern float __attribute__((const, overloadable))
-    normalize(float v);
-
-extern float2 __attribute__((const, overloadable))
-    normalize(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    normalize(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    normalize(float4 v);
-
-/*
- * pow: Base raised to an exponent
- *
- * Returns base raised to the power exponent, i.e. base ^ exponent.
- *
- * pown() and powr() are similar.  pown() takes an integer exponent. powr() assumes the base to be non-negative.
- */
-extern float __attribute__((const, overloadable))
-    pow(float base, float exponent);
-
-extern float2 __attribute__((const, overloadable))
-    pow(float2 base, float2 exponent);
-
-extern float3 __attribute__((const, overloadable))
-    pow(float3 base, float3 exponent);
-
-extern float4 __attribute__((const, overloadable))
-    pow(float4 base, float4 exponent);
-
-/*
- * pown: Base raised to an integer exponent
- *
- * Returns base raised to the power exponent, i.e. base ^ exponent.
- *
- * pow() and powr() are similar.  The both take a float exponent. powr() also assumes the base to be non-negative.
- */
-extern float __attribute__((const, overloadable))
-    pown(float base, int exponent);
-
-extern float2 __attribute__((const, overloadable))
-    pown(float2 base, int2 exponent);
-
-extern float3 __attribute__((const, overloadable))
-    pown(float3 base, int3 exponent);
-
-extern float4 __attribute__((const, overloadable))
-    pown(float4 base, int4 exponent);
-
-/*
- * powr: Positive base raised to an exponent
- *
- * Returns base raised to the power exponent, i.e. base ^ exponent.  base must be >= 0.
- *
- * pow() and pown() are similar.  They both make no assumptions about the base.  pow() takes a float exponent while pown() take an integer.
- *
- * See also native_powr().
- */
-extern float __attribute__((const, overloadable))
-    powr(float base, float exponent);
-
-extern float2 __attribute__((const, overloadable))
-    powr(float2 base, float2 exponent);
-
-extern float3 __attribute__((const, overloadable))
-    powr(float3 base, float3 exponent);
-
-extern float4 __attribute__((const, overloadable))
-    powr(float4 base, float4 exponent);
-
-/*
- * radians: Converts degrees into radians
- *
- * Converts from degrees to radians.
- */
-extern float __attribute__((const, overloadable))
-    radians(float v);
-
-extern float2 __attribute__((const, overloadable))
-    radians(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    radians(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    radians(float4 v);
-
-/*
- * remainder: Remainder of a division
- *
- * Returns the remainder of (numerator / denominator), where the quotient is rounded towards the nearest integer.
- *
- * The function fmod() is similar but rounds toward the closest interger.
- * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
- * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
- */
-extern float __attribute__((const, overloadable))
-    remainder(float numerator, float denominator);
-
-extern float2 __attribute__((const, overloadable))
-    remainder(float2 numerator, float2 denominator);
-
-extern float3 __attribute__((const, overloadable))
-    remainder(float3 numerator, float3 denominator);
-
-extern float4 __attribute__((const, overloadable))
-    remainder(float4 numerator, float4 denominator);
-
-/*
- * remquo: Remainder and quotient of a division
- *
- * Returns the quotient and the remainder of (numerator / denominator).
- *
- * Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
- *
- * This function is useful for implementing periodic functions.  The low three bits of the quotient gives the quadrant and the remainder the distance within the quadrant.  For example, an implementation of sin(x) could call remquo(x, PI / 2.f, &quadrant) to reduce very large value of x to something within a limited range.
- *
- * Example: remquo(-23.5f, 8.f, &quot) sets the lowest three bits of quot to 3 and the sign negative.  It returns 0.5f.
- *
- * Parameters:
- *   numerator The numerator.
- *   denominator The denominator.
- *   quotient *quotient will be set to the integer quotient.
- *
- * Returns: The remainder, precise only for the low three bits.
- */
-extern float __attribute__((overloadable))
-    remquo(float numerator, float denominator, int* quotient);
-
-extern float2 __attribute__((overloadable))
-    remquo(float2 numerator, float2 denominator, int2* quotient);
-
-extern float3 __attribute__((overloadable))
-    remquo(float3 numerator, float3 denominator, int3* quotient);
-
-extern float4 __attribute__((overloadable))
-    remquo(float4 numerator, float4 denominator, int4* quotient);
-
-/*
- * rint: Round to even
- *
- * Rounds to the nearest integral value.
- *
- * rint() rounds half values to even.  For example, rint(0.5f) returns 0.f and rint(1.5f) returns 2.f.  Similarly, rint(-0.5f) returns -0.f and rint(-1.5f) returns -2.f.
- *
- * round() is similar but rounds away from zero.  trunc() truncates the decimal fraction.
- */
-extern float __attribute__((const, overloadable))
-    rint(float v);
-
-extern float2 __attribute__((const, overloadable))
-    rint(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    rint(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    rint(float4 v);
-
-/*
- * rootn: Nth root
- *
- * Compute the Nth root of a value.
- *
- * See also native_rootn().
- */
-extern float __attribute__((const, overloadable))
-    rootn(float v, int n);
-
-extern float2 __attribute__((const, overloadable))
-    rootn(float2 v, int2 n);
-
-extern float3 __attribute__((const, overloadable))
-    rootn(float3 v, int3 n);
-
-extern float4 __attribute__((const, overloadable))
-    rootn(float4 v, int4 n);
-
-/*
- * round: Round away from zero
- *
- * Round to the nearest integral value.
- *
- * round() rounds half values away from zero.  For example, round(0.5f) returns 1.f and round(1.5f) returns 2.f.  Similarly, round(-0.5f) returns -1.f and round(-1.5f) returns -2.f.
- *
- * rint() is similar but rounds half values toward even.  trunc() truncates the decimal fraction.
- */
-extern float __attribute__((const, overloadable))
-    round(float v);
-
-extern float2 __attribute__((const, overloadable))
-    round(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    round(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    round(float4 v);
-
-/*
- * rsqrt: Reciprocal of a square root
- *
- * Returns (1 / sqrt(v)).
- *
- * See also half_rsqrt(), native_rsqrt().
- */
-extern float __attribute__((const, overloadable))
-    rsqrt(float v);
-
-extern float2 __attribute__((const, overloadable))
-    rsqrt(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    rsqrt(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    rsqrt(float4 v);
-
-/*
- * sign: Sign of a value
- *
- * Returns the sign of a value.
- *
- * if (v < 0) return -1.f;
- * else if (v > 0) return 1.f;
- * else return 0.f;
- */
-extern float __attribute__((const, overloadable))
-    sign(float v);
-
-extern float2 __attribute__((const, overloadable))
-    sign(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    sign(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    sign(float4 v);
-
-/*
- * sin: Sine
- *
- * Returns the sine of an angle measured in radians.
- *
- * See also native_sin().
- */
-extern float __attribute__((const, overloadable))
-    sin(float v);
-
-extern float2 __attribute__((const, overloadable))
-    sin(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    sin(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    sin(float4 v);
-
-/*
- * sincos: Sine and cosine
- *
- * Returns the sine and cosine of a value.
- *
- * See also native_sincos().
- *
- * Parameters:
- *   v The incoming value in radians
- *   cos *cos will be set to the cosine value.
- *
- * Returns: sine of v
- */
-extern float __attribute__((overloadable))
-    sincos(float v, float* cos);
-
-extern float2 __attribute__((overloadable))
-    sincos(float2 v, float2* cos);
-
-extern float3 __attribute__((overloadable))
-    sincos(float3 v, float3* cos);
-
-extern float4 __attribute__((overloadable))
-    sincos(float4 v, float4* cos);
-
-/*
- * sinh: Hyperbolic sine
- *
- * Returns the hyperbolic sine of v, where v is measured in radians.
- *
- * See also native_sinh().
- */
-extern float __attribute__((const, overloadable))
-    sinh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    sinh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    sinh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    sinh(float4 v);
-
-/*
- * sinpi: Sine of a number multiplied by pi
- *
- * Returns the sine of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
- *
- * See also native_sinpi().
- */
-extern float __attribute__((const, overloadable))
-    sinpi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    sinpi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    sinpi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    sinpi(float4 v);
-
-/*
- * sqrt: Square root
- *
- * Returns the square root of a value.
- *
- * See also half_sqrt(), native_sqrt().
- */
-extern float __attribute__((const, overloadable))
-    sqrt(float v);
-
-extern float2 __attribute__((const, overloadable))
-    sqrt(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    sqrt(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    sqrt(float4 v);
-
-/*
- * step: 0 if less than a value, 0 otherwise
- *
- * Returns 0.f if v < edge, 1.f otherwise.
- *
- * This can be useful to create conditional computations without using loops and branching instructions.  For example, instead of computing (a[i] < b[i]) ? 0.f : atan2(a[i], b[i]) for the corresponding elements of a vector, you could instead use step(a, b) * atan2(a, b).
- */
-extern float __attribute__((const, overloadable))
-    step(float edge, float v);
-
-extern float2 __attribute__((const, overloadable))
-    step(float2 edge, float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    step(float3 edge, float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    step(float4 edge, float4 v);
-
-extern float2 __attribute__((const, overloadable))
-    step(float2 edge, float v);
-
-extern float3 __attribute__((const, overloadable))
-    step(float3 edge, float v);
-
-extern float4 __attribute__((const, overloadable))
-    step(float4 edge, float v);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float2 __attribute__((const, overloadable))
-    step(float edge, float2 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float3 __attribute__((const, overloadable))
-    step(float edge, float3 v);
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-extern float4 __attribute__((const, overloadable))
-    step(float edge, float4 v);
-#endif
-
-/*
- * tan: Tangent
- *
- * Returns the tangent of an angle measured in radians.
- *
- * See also native_tan().
- */
-extern float __attribute__((const, overloadable))
-    tan(float v);
-
-extern float2 __attribute__((const, overloadable))
-    tan(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    tan(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    tan(float4 v);
-
-/*
- * tanh: Hyperbolic tangent
- *
- * Returns the hyperbolic tangent of a value.
- *
- * See also native_tanh().
- */
-extern float __attribute__((const, overloadable))
-    tanh(float v);
-
-extern float2 __attribute__((const, overloadable))
-    tanh(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    tanh(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    tanh(float4 v);
-
-/*
- * tanpi: Tangent of a number multiplied by pi
- *
- * Returns the tangent of (v * pi), where (v * pi) is measured in radians.
- *
- * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
- *
- * See also native_tanpi().
- */
-extern float __attribute__((const, overloadable))
-    tanpi(float v);
-
-extern float2 __attribute__((const, overloadable))
-    tanpi(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    tanpi(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    tanpi(float4 v);
-
-/*
- * tgamma: Gamma function
- *
- * Returns the gamma function of a value.
- *
- * See also lgamma().
- */
-extern float __attribute__((const, overloadable))
-    tgamma(float v);
-
-extern float2 __attribute__((const, overloadable))
-    tgamma(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    tgamma(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    tgamma(float4 v);
-
-/*
- * trunc: Truncates a floating point
- *
- * Rounds to integral using truncation.
- *
- * For example, trunc(1.7f) returns 1.f and trunc(-1.7f) returns -1.f.
- *
- * See rint() and round() for other rounding options.
- */
-extern float __attribute__((const, overloadable))
-    trunc(float v);
-
-extern float2 __attribute__((const, overloadable))
-    trunc(float2 v);
-
-extern float3 __attribute__((const, overloadable))
-    trunc(float3 v);
-
-extern float4 __attribute__((const, overloadable))
-    trunc(float4 v);
-
-#endif // RENDERSCRIPT_RS_CORE_MATH_RSH
diff --git a/scriptc/rs_debug.rsh b/scriptc/rs_debug.rsh
index b6a6fb2..d52590e 100644
--- a/scriptc/rs_debug.rsh
+++ b/scriptc/rs_debug.rsh
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_debug.rsh: Utility debugging routines
@@ -23,6 +23,7 @@
  * not be used in shipping applications.  All print a string and value pair to
  * the standard log.
  */
+
 #ifndef RENDERSCRIPT_RS_DEBUG_RSH
 #define RENDERSCRIPT_RS_DEBUG_RSH
 
diff --git a/scriptc/rs_element.rsh b/scriptc/rs_element.rsh
deleted file mode 100644
index 91233c2..0000000
--- a/scriptc/rs_element.rsh
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_element.rsh: Element functions
- *
- * The term "element" is used a bit ambiguously in RenderScript, as both
- * the type of an item of an allocation and the instantiation of that type:
- *
- * rs_element is a handle to a type specification, and
- *
- * In functions like rsGetElementAt(), "element" means the instantiation
- * of the type, i.e. an item of an allocation.
- *
- * The functions below let you query the characteristics of the type specificiation.
- *
- * To create complex elements, use the Element.Builder Java class.
- * For common elements, in Java you can simply use one of the many predefined elements
- * like F32_2.  You can't create elements from a script.
- *
- * An element can be a simple data type as found in C/C++, a handle type,
- * a structure, or a fixed size vector (of size 2, 3, or 4) of sub-elements.
- *
- * Elements can also have a kind, which is semantic information used mostly to
- * interpret pixel data.
- */
-#ifndef RENDERSCRIPT_RS_ELEMENT_RSH
-#define RENDERSCRIPT_RS_ELEMENT_RSH
-
-/*
- * rsElementGetBytesSize: Return the size of an element
- *
- * Returns the size in bytes that an instantiation of this element will occupy.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetBytesSize(rs_element e);
-#endif
-
-/*
- * rsElementGetDataKind: Return the kind of an element
- *
- * Returns the element's data kind.  This is used to interpret pixel data.
- *
- * See rs_data_kind.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_data_kind __attribute__((overloadable))
-    rsElementGetDataKind(rs_element e);
-#endif
-
-/*
- * rsElementGetDataType: Return the data type of an element
- *
- * Returns the element's base data type.  This can be a type similar to C/C++ (e.g. RS_TYPE_UNSIGNED_8),
- * a handle (e.g. RS_TYPE_ALLOCATION and RS_TYPE_ELEMENT), or a more complex numerical type
- * (e.g.RS_TYPE_UNSIGNED_5_6_5 and RS_TYPE_MATRIX_4X4).
- *
- * If the element describes a vector, this function returns the data type of one of its items.
- *
- * If the element describes a structure, RS_TYPE_NONE is returned.
- *
- * See rs_data_type.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_data_type __attribute__((overloadable))
-    rsElementGetDataType(rs_element e);
-#endif
-
-/*
- * rsElementGetSubElement: Return a sub element of a complex element
- *
- * For the element represents a structure, this function returns the sub-element at
- * the specified index.
- *
- * If the element is not a structure or the index is greater or equal to the number
- * of sub-elements, an invalid handle is returned.
- *
- * Parameters:
- *   e Element to query
- *   index Index of the sub-element to return
- *
- * Returns: Sub-element at the given index
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_element __attribute__((overloadable))
-    rsElementGetSubElement(rs_element e, uint32_t index);
-#endif
-
-/*
- * rsElementGetSubElementArraySize: Return the array size of a sub element of a complex element
- *
- * For complex elements, some sub-elements could be statically
- * sized arrays. This function returns the array size of the
- * sub-element at the index.
- *
- * Parameters:
- *   e Element to query
- *   index Index of the sub-element
- *
- * Returns: Array size of the sub-element at the given index
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetSubElementArraySize(rs_element e, uint32_t index);
-#endif
-
-/*
- * rsElementGetSubElementCount: Return the number of sub-elements
- *
- * Elements could be simple, such as an int or a float, or a
- * structure with multiple sub-elements, such as a collection of
- * floats, float2, float4.  This function returns zero for simple
- * elements or the number of sub-elements otherwise.
- *
- * Parameters:
- *   e Element to get data from
- *
- * Returns: Number of sub-elements in this element
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetSubElementCount(rs_element e);
-#endif
-
-/*
- * rsElementGetSubElementName: Return the name of a sub-element
- *
- * For complex elements, this function returns the name of the sub-element
- * at the specified index.
- *
- * Parameters:
- *   e Element to get data from
- *   index Index of the sub-element
- *   name Array to store the name into
- *   nameLength Length of the provided name array
- *
- * Returns: Number of characters actually written, excluding the null terminator
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetSubElementName(rs_element e, uint32_t index, char* name, uint32_t nameLength);
-#endif
-
-/*
- * rsElementGetSubElementNameLength: Return the length of the name of a sub-element
- *
- * For complex elements, this function will return the length of
- * sub-element name at index
- *
- * Parameters:
- *   e Element to get data from
- *   index Index of the sub-element to return
- *
- * Returns: Length of the sub-element name including the null terminator (size of buffer needed to write the name)
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetSubElementNameLength(rs_element e, uint32_t index);
-#endif
-
-/*
- * This function specifies the location of a sub-element within
- * the element
- *
- * Parameters:
- *   e Element to get data from
- *   index Index of the sub-element
- *
- * Returns: Offset in bytes of sub-element in this element at given index
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
-#endif
-
-/*
- * Returns the element's vector size
- *
- * Parameters:
- *   e Element to get data from
- *
- * Returns: Length of the element vector (for float2, float3, etc.)
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsElementGetVectorSize(rs_element e);
-#endif
-
-#endif // RENDERSCRIPT_RS_ELEMENT_RSH
diff --git a/scriptc/rs_for_each.rsh b/scriptc/rs_for_each.rsh
new file mode 100644
index 0000000..640b530
--- /dev/null
+++ b/scriptc/rs_for_each.rsh
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_for_each.rsh: TODO Add documentation
+ *
+ * TODO Add documentation
+ */
+
+#ifndef RENDERSCRIPT_RS_FOR_EACH_RSH
+#define RENDERSCRIPT_RS_FOR_EACH_RSH
+
+/*
+ * rs_for_each_strategy_t: Launch order hint for rsForEach calls
+ *
+ * Launch order hint for rsForEach calls.  This provides a hint to the system to
+ * determine in which order the root function of the target is called with each
+ * cell of the allocation.
+ *
+ * This is a hint and implementations may not obey the order.
+ */
+typedef enum rs_for_each_strategy {
+    RS_FOR_EACH_STRATEGY_SERIAL = 0,
+    RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
+    RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
+    RS_FOR_EACH_STRATEGY_TILE_SMALL = 3,
+    RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
+    RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
+} rs_for_each_strategy_t;
+
+/*
+ * rs_kernel_context: Opaque handle to RenderScript kernel invocation context
+ *
+ * TODO
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+typedef const struct rs_kernel_context_t * rs_kernel_context;
+#endif
+
+/*
+ * rs_script_call_t: Provides extra information to a rsForEach call
+ *
+ * Structure to provide extra information to a rsForEach call.  Primarly used to
+ * restrict the call to a subset of cells in the allocation.
+ */
+typedef struct rs_script_call {
+    rs_for_each_strategy_t strategy;
+    uint32_t xStart;
+    uint32_t xEnd;
+    uint32_t yStart;
+    uint32_t yEnd;
+    uint32_t zStart;
+    uint32_t zEnd;
+    uint32_t arrayStart;
+    uint32_t arrayEnd;
+} rs_script_call_t;
+
+/*
+ * Make a script to script call to launch work. One of the input or output is
+ * required to be a valid object. The input and output must be of the same
+ * dimensions.
+ *
+ * Parameters:
+ *   script: The target script to call
+ *   input: The allocation to source data from
+ *   output: the allocation to write date into
+ *   usrData: The user defined params to pass to the root script.  May be NULL.
+ *   sc: Extra control infomation used to select a sub-region of the allocation to be processed or suggest a walking strategy.  May be NULL.
+ *   usrDataLen: The size of the userData structure.  This will be used to perform a shallow copy of the data if necessary.
+ */
+#if !defined(RS_VERSION) || (RS_VERSION <= 13)
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
+              const rs_script_call_t* sc);
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 13)
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
+              size_t usrDataLen, const rs_script_call_t* sc);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
+              size_t usrDataLen);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output);
+#endif
+
+/*
+ * rsGetArray0: Index in the Array0 dimension for the specified context
+ *
+ * Returns the index in the Array0 dimension of the cell being processed,
+ * as specified by the supplied context.
+ *
+ * This context is created when a kernel is launched and updated at each
+ * iteration.  It contains common characteristics of the allocations being
+ * iterated over and rarely used indexes, like the Array0 index.
+ *
+ * You can access the context by adding a rs_kernel_context argument to your
+ * kernel function.  E.g.
+ * short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {
+ *   // The current index in the common x, y, z, w dimensions are accessed by
+ *   // adding these variables as arguments.  For the more rarely used indexes
+ *   // to the other dimensions, extract them from the context:
+ *   uint32_t index_a0 = rsGetArray0(context);
+ *   //...
+ * }
+ *
+ * This function returns 0 if the Array0 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetArray0(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetArray1: Index in the Array1 dimension for the specified context
+ *
+ * Returns the index in the Array1 dimension of the cell being processed,
+ * as specified by the supplied context.  See rsGetArray0() for an explanation
+ * of the context.
+ *
+ * Returns 0 if the Array1 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetArray1(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetArray2: Index in the Array2 dimension for the specified context
+ *
+ * Returns the index in the Array2 dimension of the cell being processed,
+ * as specified by the supplied context.  See rsGetArray0() for an explanation
+ * of the context.
+ *
+ * Returns 0 if the Array2 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetArray2(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetArray3: Index in the Array3 dimension for the specified context
+ *
+ * Returns the index in the Array3 dimension of the cell being processed,
+ * as specified by the supplied context.  See rsGetArray0() for an explanation
+ * of the context.
+ *
+ * Returns 0 if the Array3 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetArray3(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimArray0: Size of the Array0 dimension for the specified context
+ *
+ * Returns the size of the Array0 dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Array0 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimArray0(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimArray1: Size of the Array1 dimension for the specified context
+ *
+ * Returns the size of the Array1 dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Array1 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimArray1(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimArray2: Size of the Array2 dimension for the specified context
+ *
+ * Returns the size of the Array2 dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Array2 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimArray2(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimArray3: Size of the Array3 dimension for the specified context
+ *
+ * Returns the size of the Array3 dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Array3 dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimArray3(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimHasFaces: Presence of more than one face for the specified context
+ *
+ * If the context refers to a cubemap, this function returns true if there's
+ * more than one face present.  In all other cases, it returns false.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * rsAllocationGetDimFaces() is similar but returns 0 or 1 instead of a bool.
+ *
+ * Returns: Returns true if more than one face is present, false otherwise.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern bool __attribute__((overloadable))
+    rsGetDimHasFaces(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimLod: Number of levels of detail for the specified context
+ *
+ * Returns the number of levels of detail for the specified context.
+ * This is useful for mipmaps.  See rsGetDimX() for an explanation of the context.
+ * Returns 0 if Level of Detail is not used.
+ *
+ * rsAllocationGetDimLOD() is similar but returns 0 or 1 instead the actual
+ * number of levels.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimLod(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimX: Size of the X dimension for the specified context
+ *
+ * Returns the size of the X dimension for the specified context.
+ *
+ * This context is created when a kernel is launched.  It contains common
+ * characteristics of the allocations being iterated over by the kernel in
+ * a very efficient structure.  It also contains rarely used indexes.
+ *
+ * You can access it by adding a rs_kernel_context argument to your kernel
+ * function.  E.g.
+ * int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {
+ *   uint32_t size = rsGetDimX(context); //...
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimX(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimY: Size of the Y dimension for the specified context
+ *
+ * Returns the size of the X dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Y dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimY(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetDimZ: Size of the Z dimension for the specified context
+ *
+ * Returns the size of the Z dimension for the specified context.
+ * See rsGetDimX() for an explanation of the context.
+ *
+ * Returns 0 if the Z dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetDimZ(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetFace: Coordinate of the Face for the specified context
+ *
+ * Returns the face on which the cell being processed is found, as specified
+ * by the supplied context.  See rsGetArray0() for an explanation of the context.
+ *
+ * Returns RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X if the face dimension is not
+ * present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern rs_allocation_cubemap_face __attribute__((overloadable))
+    rsGetFace(rs_kernel_context ctxt);
+#endif
+
+/*
+ * rsGetLod: Index in the Levels of Detail dimension for the specified context.
+ *
+ * Returns the index in the Levels of Detail dimension of the cell being
+ * processed, as specified by the supplied context.  See rsGetArray0() for
+ * an explanation of the context.
+ *
+ * Returns 0 if the Levels of Detail dimension is not present.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 23))
+extern uint32_t __attribute__((overloadable))
+    rsGetLod(rs_kernel_context ctxt);
+#endif
+
+#endif // RENDERSCRIPT_RS_FOR_EACH_RSH
diff --git a/scriptc/rs_graphics.rsh b/scriptc/rs_graphics.rsh
index 1f74518..190ec4d 100644
--- a/scriptc/rs_graphics.rsh
+++ b/scriptc/rs_graphics.rsh
@@ -14,22 +14,283 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_graphics.rsh: RenderScript graphics API
  *
+ * NOTE: RenderScript Graphics has been deprecated.  Do not use.
+ *
  * A set of graphics functions used by RenderScript.
  */
+
 #ifndef RENDERSCRIPT_RS_GRAPHICS_RSH
 #define RENDERSCRIPT_RS_GRAPHICS_RSH
 
 #ifdef __LP64__
 // TODO We need to fix some of the builds before enabling this error:
 // #error "RenderScript graphics is deprecated and not supported in 64bit mode."
-#else
-#include "rs_mesh.rsh"
-#include "rs_program.rsh"
+#endif
+
+// TODO we seem to assume order for the other headers too.
+#include "rs_object_types.rsh"
+
+/*
+ * rs_blend_src_func: Blend source function
+ *
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_BLEND_SRC_ZERO                   = 0,
+    RS_BLEND_SRC_ONE                    = 1,
+    RS_BLEND_SRC_DST_COLOR              = 2,
+    RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3,
+    RS_BLEND_SRC_SRC_ALPHA              = 4,
+    RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5,
+    RS_BLEND_SRC_DST_ALPHA              = 6,
+    RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7,
+    RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8,
+    RS_BLEND_SRC_INVALID                = 100
+} rs_blend_src_func;
+#endif
+#endif
+
+/*
+ * rs_blend_dst_func: Blend destination function
+ *
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_BLEND_DST_ZERO                   = 0,
+    RS_BLEND_DST_ONE                    = 1,
+    RS_BLEND_DST_SRC_COLOR              = 2,
+    RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3,
+    RS_BLEND_DST_SRC_ALPHA              = 4,
+    RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5,
+    RS_BLEND_DST_DST_ALPHA              = 6,
+    RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7,
+    RS_BLEND_DST_INVALID                = 100
+} rs_blend_dst_func;
+#endif
+#endif
+
+/*
+ * rs_cull_mode: Culling mode
+ *
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_CULL_BACK     = 0,
+    RS_CULL_FRONT    = 1,
+    RS_CULL_NONE     = 2,
+    RS_CULL_INVALID  = 100
+} rs_cull_mode;
+#endif
+#endif
+
+/*
+ * rs_depth_func: Depth function
+ *
+ * Specifies conditional drawing depending on the comparison of the incoming
+ * depth to that found in the depth buffer.
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_DEPTH_FUNC_ALWAYS        = 0, // Always drawn
+    RS_DEPTH_FUNC_LESS          = 1, // Drawn if the incoming depth value is less than that in the depth buffer
+    RS_DEPTH_FUNC_LEQUAL        = 2, // Drawn if the incoming depth value is less or equal to that in the depth buffer
+    RS_DEPTH_FUNC_GREATER       = 3, // Drawn if the incoming depth value is greater than that in the depth buffer
+    RS_DEPTH_FUNC_GEQUAL        = 4, // Drawn if the incoming depth value is greater or equal to that in the depth buffer
+    RS_DEPTH_FUNC_EQUAL         = 5, // Drawn if the incoming depth value is equal to that in the depth buffer
+    RS_DEPTH_FUNC_NOTEQUAL      = 6, // Drawn if the incoming depth value is not equal to that in the depth buffer
+    RS_DEPTH_FUNC_INVALID       = 100 // Invalid depth function
+} rs_depth_func;
+#endif
+#endif
+
+/*
+ * rs_primitive: How to intepret mesh vertex data
+ *
+ * Describes the way mesh vertex data is interpreted when rendering
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_PRIMITIVE_POINT = 0, // Vertex data will be rendered as a series of points
+    RS_PRIMITIVE_LINE = 1, // Vertex pairs will be rendered as lines
+    RS_PRIMITIVE_LINE_STRIP = 2, // Vertex data will be rendered as a connected line strip
+    RS_PRIMITIVE_TRIANGLE = 3, // Vertices will be rendered as individual triangles
+    RS_PRIMITIVE_TRIANGLE_STRIP = 4, // Vertices will be rendered as a connected triangle strip defined by the first three vertices with each additional triangle defined by a new vertex
+    RS_PRIMITIVE_TRIANGLE_FAN = 5, // Vertices will be rendered as a sequence of triangles that all share first vertex as the origin
+    RS_PRIMITIVE_INVALID = 100 // Invalid primitive
+} rs_primitive;
+#endif
+#endif
+
+/*
+ * rs_font: Handle to a Font
+ *
+ * Opaque handle to a RenderScript font object.
+ * See: android.renderscript.Font
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_font;
+#endif
+
+/*
+ * rs_mesh: Handle to a Mesh
+ *
+ * Opaque handle to a RenderScript mesh object.
+ * See: android.renderscript.Mesh
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_mesh;
+#endif
+
+/*
+ * rs_program_fragment: Handle to a ProgramFragment
+ *
+ * Opaque handle to a RenderScript ProgramFragment object.
+ * See: android.renderscript.ProgramFragment
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_program_fragment;
+#endif
+
+/*
+ * rs_program_vertex: Handle to a ProgramVertex
+ *
+ * Opaque handle to a RenderScript ProgramVertex object.
+ * See: android.renderscript.ProgramVertex
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_program_vertex;
+#endif
+
+/*
+ * rs_program_raster: Handle to a ProgramRaster
+ *
+ * Opaque handle to a RenderScript ProgramRaster object.
+ * See: android.renderscript.ProgramRaster
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_program_raster;
+#endif
+
+/*
+ * rs_program_store: Handle to a ProgramStore
+ *
+ * Opaque handle to a RenderScript ProgramStore object.
+ * See: android.renderscript.ProgramStore
+ */
+#ifndef __LP64__
+typedef _RS_HANDLE rs_program_store;
+#endif
+
+/*
+ * rsClearObject: For internal use.
+ *
+ */
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_mesh* dst);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_fragment* dst);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_vertex* dst);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_raster* dst);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_store* dst);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsClearObject(rs_font* dst);
+#endif
+
+/*
+ * rsIsObject: For internal use.
+ *
+ */
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_mesh v);
+#endif
+
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_fragment v);
+#endif
+
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_vertex v);
+#endif
+
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_raster v);
+#endif
+
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_store v);
+#endif
+
+#ifndef __LP64__
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_font v);
+#endif
+
+/*
+ * rsSetObject: For internal use.
+ *
+ */
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_mesh* dst, rs_mesh src);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_fragment* dst, rs_program_fragment src);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_vertex* dst, rs_program_vertex src);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_raster* dst, rs_program_raster src);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_store* dst, rs_program_store src);
+#endif
+
+#ifndef __LP64__
+extern void __attribute__((overloadable))
+    rsSetObject(rs_font* dst, rs_font src);
 #endif
 
 /*
@@ -67,10 +328,10 @@
  * The Allocation must be a valid constant input for the Program.
  *
  * Parameters:
- *   ps program fragment object
- *   slot index of the constant buffer on the program
- *   c constants to bind
- *   pv program vertex object
+ *   ps: program fragment object
+ *   slot: index of the constant buffer on the program
+ *   c: constants to bind
+ *   pv: program vertex object
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -96,7 +357,7 @@
  * Binds the font object to be used for all subsequent font rendering calls
  *
  * Parameters:
- *   font object to bind
+ *   font: object to bind
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -212,10 +473,10 @@
  * Otherwise the whole mesh is rendered.
  *
  * Parameters:
- *   ism mesh object to render
- *   primitiveIndex for meshes that contain multiple primitive groups this parameter specifies the index of the group to draw.
- *   start starting index in the range
- *   len number of indices to draw
+ *   ism: mesh object to render
+ *   primitiveIndex: for meshes that contain multiple primitive groups this parameter specifies the index of the group to draw.
+ *   start: starting index in the range
+ *   len: number of indices to draw
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -300,10 +561,10 @@
  * Sets the font color for all subsequent rendering calls
  *
  * Parameters:
- *   r red component
- *   g green component
- *   b blue component
- *   a alpha component
+ *   r: red component
+ *   g: green component
+ *   b: blue component
+ *   a: alpha component
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -364,6 +625,89 @@
 #endif
 
 /*
+ * Returns an allocation containing index data or a null
+ * allocation if only the primitive is specified
+ *
+ * Parameters:
+ *   m: mesh to get data from
+ *   index: index of the index allocation
+ *
+ * Returns: allocation containing index data
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_allocation __attribute__((overloadable))
+    rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
+#endif
+#endif
+
+/*
+ * Returns the primitive describing how a part of the mesh is
+ * rendered
+ *
+ * Parameters:
+ *   m: mesh to get data from
+ *   index: index of the primitive
+ *
+ * Returns: primitive describing how the mesh is rendered
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_primitive __attribute__((overloadable))
+    rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
+#endif
+#endif
+
+/*
+ * Meshes could have multiple index sets, this function returns
+ * the number.
+ *
+ * Parameters:
+ *   m: mesh to get data from
+ *
+ * Returns: number of primitive groups in the mesh. This would include simple primitives as well as allocations containing index data
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsgMeshGetPrimitiveCount(rs_mesh m);
+#endif
+#endif
+
+/*
+ * Returns an allocation that is part of the mesh and contains
+ * vertex data, e.g. positions, normals, texcoords
+ *
+ * Parameters:
+ *   m: mesh to get data from
+ *   index: index of the vertex allocation
+ *
+ * Returns: allocation containing vertex data
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_allocation __attribute__((overloadable))
+    rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
+#endif
+#endif
+
+/*
+ * Returns the number of allocations in the mesh that contain
+ * vertex data
+ *
+ * Parameters:
+ *   m: mesh to get data from
+ *
+ * Returns: number of allocations in the mesh that contain vertex data
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsgMeshGetVertexAllocationCount(rs_mesh m);
+#endif
+#endif
+
+/*
  * Set the constant color for a fixed function emulation program.
  */
 #ifndef __LP64__
@@ -377,7 +721,7 @@
  * would result in an error.
  *
  * Parameters:
- *   proj matrix to store the current projection matrix into
+ *   proj: matrix to store the current projection matrix into
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -390,7 +734,7 @@
  * would result in an error.
  *
  * Parameters:
- *   model model matrix
+ *   model: model matrix
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -403,7 +747,7 @@
  * would result in an error.
  *
  * Parameters:
- *   proj projection matrix
+ *   proj: projection matrix
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
@@ -416,11 +760,154 @@
  * would result in an error.
  *
  * Parameters:
- *   tex texture matrix
+ *   tex: texture matrix
  */
 #ifndef __LP64__
 extern void __attribute__((overloadable))
     rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4* tex);
 #endif
 
+/*
+ * Get program raster cull mode
+ *
+ * Parameters:
+ *   pr: program raster to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_cull_mode __attribute__((overloadable))
+    rsgProgramRasterGetCullMode(rs_program_raster pr);
+#endif
+#endif
+
+/*
+ * Get program raster point sprite state
+ *
+ * Parameters:
+ *   pr: program raster to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramRasterIsPointSpriteEnabled(rs_program_raster pr);
+#endif
+#endif
+
+/*
+ * Get program store blend destination function
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_blend_dst_func __attribute__((overloadable))
+    rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store blend source function
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_blend_src_func __attribute__((overloadable))
+    rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store depth function
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_depth_func __attribute__((overloadable))
+    rsgProgramStoreGetDepthFunc(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store alpha component color mask
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsColorMaskAlphaEnabled(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store blur component color mask
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsColorMaskBlueEnabled(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store green component color mask
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsColorMaskGreenEnabled(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store red component color mask
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsColorMaskRedEnabled(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store depth mask
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsDepthMaskEnabled(rs_program_store ps);
+#endif
+#endif
+
+/*
+ * Get program store dither state
+ *
+ * Parameters:
+ *   ps: program store to query
+ */
+#ifndef __LP64__
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern bool __attribute__((overloadable))
+    rsgProgramStoreIsDitherEnabled(rs_program_store ps);
+#endif
+#endif
+
 #endif // RENDERSCRIPT_RS_GRAPHICS_RSH
diff --git a/scriptc/rs_io.rsh b/scriptc/rs_io.rsh
new file mode 100644
index 0000000..7bb7a49
--- /dev/null
+++ b/scriptc/rs_io.rsh
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_io.rsh: Input/output functions
+ *
+ * TODO Add documentation
+ */
+
+#ifndef RENDERSCRIPT_RS_IO_RSH
+#define RENDERSCRIPT_RS_IO_RSH
+
+/*
+ * rsAllocationIoReceive: Receive new content from the queue
+ *
+ * Receive a new set of contents from the queue.
+ *
+ * Parameters:
+ *   a: allocation to work on
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern void __attribute__((overloadable))
+    rsAllocationIoReceive(rs_allocation a);
+#endif
+
+/*
+ * rsAllocationIoSend: Send new content to the queue
+ *
+ * Send the contents of the Allocation to the queue.
+ *
+ * Parameters:
+ *   a: allocation to work on
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern void __attribute__((overloadable))
+    rsAllocationIoSend(rs_allocation a);
+#endif
+
+/*
+ * Send a message back to the client.  Will not block and returns true
+ * if the message was sendable and false if the fifo was full.
+ * A message ID is required.  Data payload is optional.
+ */
+extern bool __attribute__((overloadable))
+    rsSendToClient(int cmdID);
+
+extern bool __attribute__((overloadable))
+    rsSendToClient(int cmdID, const void* data, uint len);
+
+/*
+ * Send a message back to the client, blocking until the message is queued.
+ * A message ID is required.  Data payload is optional.
+ */
+extern void __attribute__((overloadable))
+    rsSendToClientBlocking(int cmdID);
+
+extern void __attribute__((overloadable))
+    rsSendToClientBlocking(int cmdID, const void* data, uint len);
+
+#endif // RENDERSCRIPT_RS_IO_RSH
diff --git a/scriptc/rs_math.rsh b/scriptc/rs_math.rsh
index b6b6ee0..f78a0e1 100644
--- a/scriptc/rs_math.rsh
+++ b/scriptc/rs_math.rsh
@@ -14,17 +14,4047 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
- * rs_math.rsh: TODO Add documentation
+ * rs_math.rsh: Mathematical functions
  *
- * TODO Add documentation
+ * Most mathematical functions can be applied to scalars and vectors.
+ * When applied to vectors, a vector of the function applied to each entry
+ * of the input is returned.
+ *
+ * For example:
+ *
+ * float3 a, b;
+ * // The following call sets
+ * //   a.x to sin(b.x),
+ * //   a.y to sin(b.y), and
+ * //   a.z to sin(b.z).
+ * a = sin(b);
+ *
+ *
+ * A few functions like distance() and length() interpret instead the input
+ * as a single vector in n-dimensional space.
+ *
+ * The precision of the mathematical operations is affected by the pragmas
+ * rs_fp_relaxed and rs_fp_full.
+ *
+ * Different precision/speed tradeoffs can be achieved by using three variants
+ * of common math functions.  Functions with a name starting with
+ * - native_ may have custom hardware implementations with weaker precision,
+ * - half_ may perform internal computations using 16 bit floats, and
+ * - fast_ are n-dimensional space computations that may use 16 bit floats.
+ *
  */
+
 #ifndef RENDERSCRIPT_RS_MATH_RSH
 #define RENDERSCRIPT_RS_MATH_RSH
 
 /*
+ * M_1_PI: 1 / pi, as a 32 bit float
+ *
+ * The inverse of pi, as a 32 bit float.
+ */
+#define M_1_PI 0.318309886183790671537767526745028724f
+
+/*
+ * M_2_PI: 2 / pi, as a 32 bit float
+ *
+ * 2 divided by pi, as a 32 bit float.
+ */
+#define M_2_PI 0.636619772367581343075535053490057448f
+
+/*
+ * M_2_PIl: Deprecated.  Use M_2_PI instead.
+ *
+ */
+#define M_2_PIl 0.636619772367581343075535053490057448f
+
+/*
+ * M_2_SQRTPI: 2 / sqrt(pi), as a 32 bit float
+ *
+ * 2 divided by the square root of pi, as a 32 bit float.
+ */
+#define M_2_SQRTPI 1.128379167095512573896158903121545172f
+
+/*
+ * M_E: e, as a 32 bit float
+ *
+ * The number e, the base of the natural logarithm, as a 32 bit float.
+ */
+#define M_E 2.718281828459045235360287471352662498f
+
+/*
+ * M_LN10: log_e(10), as a 32 bit float
+ *
+ * The natural logarithm of 10, as a 32 bit float.
+ */
+#define M_LN10 2.302585092994045684017991454684364208f
+
+/*
+ * M_LN2: log_e(2), as a 32 bit float
+ *
+ * The natural logarithm of 2, as a 32 bit float.
+ */
+#define M_LN2 0.693147180559945309417232121458176568f
+
+/*
+ * M_LOG10E: log_10(e), as a 32 bit float
+ *
+ * The logarithm base 10 of e, as a 32 bit float.
+ */
+#define M_LOG10E 0.434294481903251827651128918916605082f
+
+/*
+ * M_LOG2E: log_2(e), as a 32 bit float
+ *
+ * The logarithm base 2 of e, as a 32 bit float.
+ */
+#define M_LOG2E 1.442695040888963407359924681001892137f
+
+/*
+ * M_PI: pi, as a 32 bit float
+ *
+ * The constant pi, as a 32 bit float.
+ */
+#define M_PI 3.141592653589793238462643383279502884f
+
+/*
+ * M_PI_2: pi / 2, as a 32 bit float
+ *
+ * Pi divided by 2, as a 32 bit float.
+ */
+#define M_PI_2 1.570796326794896619231321691639751442f
+
+/*
+ * M_PI_4: pi / 4, as a 32 bit float
+ *
+ * Pi divided by 4, as a 32 bit float.
+ */
+#define M_PI_4 0.785398163397448309615660845819875721f
+
+/*
+ * M_SQRT1_2: 1 / sqrt(2), as a 32 bit float
+ *
+ * The inverse of the square root of 2, as a 32 bit float.
+ */
+#define M_SQRT1_2 0.707106781186547524400844362104849039f
+
+/*
+ * M_SQRT2: sqrt(2), as a 32 bit float
+ *
+ * The square root of 2, as a 32 bit float.
+ */
+#define M_SQRT2 1.414213562373095048801688724209698079f
+
+/*
+ * abs: Absolute value of an integer
+ *
+ * Returns the absolute value of an integer.
+ *
+ * For floats, use fabs().
+ */
+extern uchar __attribute__((const, overloadable))
+    abs(char v);
+
+extern uchar2 __attribute__((const, overloadable))
+    abs(char2 v);
+
+extern uchar3 __attribute__((const, overloadable))
+    abs(char3 v);
+
+extern uchar4 __attribute__((const, overloadable))
+    abs(char4 v);
+
+extern ushort __attribute__((const, overloadable))
+    abs(short v);
+
+extern ushort2 __attribute__((const, overloadable))
+    abs(short2 v);
+
+extern ushort3 __attribute__((const, overloadable))
+    abs(short3 v);
+
+extern ushort4 __attribute__((const, overloadable))
+    abs(short4 v);
+
+extern uint __attribute__((const, overloadable))
+    abs(int v);
+
+extern uint2 __attribute__((const, overloadable))
+    abs(int2 v);
+
+extern uint3 __attribute__((const, overloadable))
+    abs(int3 v);
+
+extern uint4 __attribute__((const, overloadable))
+    abs(int4 v);
+
+/*
+ * acos: Inverse cosine
+ *
+ * Returns the inverse cosine, in radians.
+ *
+ * See also native_acos().
+ */
+extern float __attribute__((const, overloadable))
+    acos(float v);
+
+extern float2 __attribute__((const, overloadable))
+    acos(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    acos(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    acos(float4 v);
+
+/*
+ * acosh: Inverse hyperbolic cosine
+ *
+ * Returns the inverse hyperbolic cosine, in radians.
+ *
+ * See also native_acosh().
+ */
+extern float __attribute__((const, overloadable))
+    acosh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    acosh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    acosh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    acosh(float4 v);
+
+/*
+ * acospi: Inverse cosine divided by pi
+ *
+ * Returns the inverse cosine in radians, divided by pi.
+ *
+ * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
+ *
+ * See also native_acospi().
+ */
+extern float __attribute__((const, overloadable))
+    acospi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    acospi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    acospi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    acospi(float4 v);
+
+/*
+ * asin: Inverse sine
+ *
+ * Returns the inverse sine, in radians.
+ *
+ * See also native_asin().
+ */
+extern float __attribute__((const, overloadable))
+    asin(float v);
+
+extern float2 __attribute__((const, overloadable))
+    asin(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    asin(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    asin(float4 v);
+
+/*
+ * asinh: Inverse hyperbolic sine
+ *
+ * Returns the inverse hyperbolic sine, in radians.
+ *
+ * See also native_asinh().
+ */
+extern float __attribute__((const, overloadable))
+    asinh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    asinh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    asinh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    asinh(float4 v);
+
+/*
+ * asinpi: Inverse sine divided by pi
+ *
+ * Returns the inverse sine in radians, divided by pi.
+ *
+ * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
+ *
+ * See also native_asinpi().
+ */
+extern float __attribute__((const, overloadable))
+    asinpi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    asinpi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    asinpi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    asinpi(float4 v);
+
+/*
+ * atan: Inverse tangent
+ *
+ * Returns the inverse tangent, in radians.
+ *
+ * See also native_atan().
+ */
+extern float __attribute__((const, overloadable))
+    atan(float v);
+
+extern float2 __attribute__((const, overloadable))
+    atan(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    atan(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    atan(float4 v);
+
+/*
+ * atan2: Inverse tangent of a ratio
+ *
+ * Returns the inverse tangent of (numerator / denominator), in radians.
+ *
+ * See also native_atan2().
+ *
+ * Parameters:
+ *   numerator: The numerator
+ *   denominator: The denominator.  Can be 0.
+ */
+extern float __attribute__((const, overloadable))
+    atan2(float numerator, float denominator);
+
+extern float2 __attribute__((const, overloadable))
+    atan2(float2 numerator, float2 denominator);
+
+extern float3 __attribute__((const, overloadable))
+    atan2(float3 numerator, float3 denominator);
+
+extern float4 __attribute__((const, overloadable))
+    atan2(float4 numerator, float4 denominator);
+
+/*
+ * atan2pi: Inverse tangent of a ratio, divided by pi
+ *
+ * Returns the inverse tangent of (numerator / denominator), in radians, divided by pi.
+ *
+ * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
+ *
+ * See also native_atan2pi().
+ *
+ * Parameters:
+ *   numerator: The numerator
+ *   denominator: The denominator.  Can be 0.
+ */
+extern float __attribute__((const, overloadable))
+    atan2pi(float numerator, float denominator);
+
+extern float2 __attribute__((const, overloadable))
+    atan2pi(float2 numerator, float2 denominator);
+
+extern float3 __attribute__((const, overloadable))
+    atan2pi(float3 numerator, float3 denominator);
+
+extern float4 __attribute__((const, overloadable))
+    atan2pi(float4 numerator, float4 denominator);
+
+/*
+ * atanh: Inverse hyperbolic tangent
+ *
+ * Returns the inverse hyperbolic tangent, in radians.
+ *
+ * See also native_atanh().
+ */
+extern float __attribute__((const, overloadable))
+    atanh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    atanh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    atanh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    atanh(float4 v);
+
+/*
+ * atanpi: Inverse tangent divided by pi
+ *
+ * Returns the inverse tangent in radians, divided by pi.
+ *
+ * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
+ *
+ * See also native_atanpi().
+ */
+extern float __attribute__((const, overloadable))
+    atanpi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    atanpi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    atanpi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    atanpi(float4 v);
+
+/*
+ * cbrt: Cube root
+ *
+ * Returns the cube root.
+ *
+ * See also native_cbrt().
+ */
+extern float __attribute__((const, overloadable))
+    cbrt(float v);
+
+extern float2 __attribute__((const, overloadable))
+    cbrt(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    cbrt(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    cbrt(float4 v);
+
+/*
+ * ceil: Smallest integer not less than a value
+ *
+ * Returns the smallest integer not less than a value.
+ *
+ * For example, ceil(1.2f) returns 2.f, and ceil(-1.2f) returns -1.f.
+ *
+ * See also floor().
+ */
+extern float __attribute__((const, overloadable))
+    ceil(float v);
+
+extern float2 __attribute__((const, overloadable))
+    ceil(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    ceil(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    ceil(float4 v);
+
+/*
+ * clamp: Restrain a value to a range
+ *
+ * Clamps a value to a specified high and low bound.  clamp() returns min_value
+ * if value < min_value, max_value if value > max_value, otherwise value.
+ *
+ * There are two variants of clamp: one where the min and max are scalars applied
+ * to all entries of the value, the other where the min and max are also vectors.
+ *
+ * If min_value is greater than max_value, the results are undefined.
+ *
+ * Parameters:
+ *   value: Value to be clamped.
+ *   min_value: Lower bound, a scalar or matching vector.
+ *   max_value: High bound, must match the type of low.
+ */
+extern float __attribute__((const, overloadable))
+    clamp(float value, float min_value, float max_value);
+
+extern float2 __attribute__((const, overloadable))
+    clamp(float2 value, float2 min_value, float2 max_value);
+
+extern float3 __attribute__((const, overloadable))
+    clamp(float3 value, float3 min_value, float3 max_value);
+
+extern float4 __attribute__((const, overloadable))
+    clamp(float4 value, float4 min_value, float4 max_value);
+
+extern float2 __attribute__((const, overloadable))
+    clamp(float2 value, float min_value, float max_value);
+
+extern float3 __attribute__((const, overloadable))
+    clamp(float3 value, float min_value, float max_value);
+
+extern float4 __attribute__((const, overloadable))
+    clamp(float4 value, float min_value, float max_value);
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char __attribute__((const, overloadable))
+    clamp(char value, char min_value, char max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char2 __attribute__((const, overloadable))
+    clamp(char2 value, char2 min_value, char2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char3 __attribute__((const, overloadable))
+    clamp(char3 value, char3 min_value, char3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char4 __attribute__((const, overloadable))
+    clamp(char4 value, char4 min_value, char4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar __attribute__((const, overloadable))
+    clamp(uchar value, uchar min_value, uchar max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar2 __attribute__((const, overloadable))
+    clamp(uchar2 value, uchar2 min_value, uchar2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar3 __attribute__((const, overloadable))
+    clamp(uchar3 value, uchar3 min_value, uchar3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar4 __attribute__((const, overloadable))
+    clamp(uchar4 value, uchar4 min_value, uchar4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short __attribute__((const, overloadable))
+    clamp(short value, short min_value, short max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short2 __attribute__((const, overloadable))
+    clamp(short2 value, short2 min_value, short2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short3 __attribute__((const, overloadable))
+    clamp(short3 value, short3 min_value, short3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short4 __attribute__((const, overloadable))
+    clamp(short4 value, short4 min_value, short4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort __attribute__((const, overloadable))
+    clamp(ushort value, ushort min_value, ushort max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort2 __attribute__((const, overloadable))
+    clamp(ushort2 value, ushort2 min_value, ushort2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort3 __attribute__((const, overloadable))
+    clamp(ushort3 value, ushort3 min_value, ushort3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort4 __attribute__((const, overloadable))
+    clamp(ushort4 value, ushort4 min_value, ushort4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int __attribute__((const, overloadable))
+    clamp(int value, int min_value, int max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int2 __attribute__((const, overloadable))
+    clamp(int2 value, int2 min_value, int2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int3 __attribute__((const, overloadable))
+    clamp(int3 value, int3 min_value, int3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int4 __attribute__((const, overloadable))
+    clamp(int4 value, int4 min_value, int4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint __attribute__((const, overloadable))
+    clamp(uint value, uint min_value, uint max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint2 __attribute__((const, overloadable))
+    clamp(uint2 value, uint2 min_value, uint2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint3 __attribute__((const, overloadable))
+    clamp(uint3 value, uint3 min_value, uint3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint4 __attribute__((const, overloadable))
+    clamp(uint4 value, uint4 min_value, uint4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long __attribute__((const, overloadable))
+    clamp(long value, long min_value, long max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long2 __attribute__((const, overloadable))
+    clamp(long2 value, long2 min_value, long2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long3 __attribute__((const, overloadable))
+    clamp(long3 value, long3 min_value, long3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long4 __attribute__((const, overloadable))
+    clamp(long4 value, long4 min_value, long4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong __attribute__((const, overloadable))
+    clamp(ulong value, ulong min_value, ulong max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong2 __attribute__((const, overloadable))
+    clamp(ulong2 value, ulong2 min_value, ulong2 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong3 __attribute__((const, overloadable))
+    clamp(ulong3 value, ulong3 min_value, ulong3 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong4 __attribute__((const, overloadable))
+    clamp(ulong4 value, ulong4 min_value, ulong4 max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char2 __attribute__((const, overloadable))
+    clamp(char2 value, char min_value, char max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char3 __attribute__((const, overloadable))
+    clamp(char3 value, char min_value, char max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern char4 __attribute__((const, overloadable))
+    clamp(char4 value, char min_value, char max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar2 __attribute__((const, overloadable))
+    clamp(uchar2 value, uchar min_value, uchar max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar3 __attribute__((const, overloadable))
+    clamp(uchar3 value, uchar min_value, uchar max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uchar4 __attribute__((const, overloadable))
+    clamp(uchar4 value, uchar min_value, uchar max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short2 __attribute__((const, overloadable))
+    clamp(short2 value, short min_value, short max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short3 __attribute__((const, overloadable))
+    clamp(short3 value, short min_value, short max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern short4 __attribute__((const, overloadable))
+    clamp(short4 value, short min_value, short max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort2 __attribute__((const, overloadable))
+    clamp(ushort2 value, ushort min_value, ushort max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort3 __attribute__((const, overloadable))
+    clamp(ushort3 value, ushort min_value, ushort max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ushort4 __attribute__((const, overloadable))
+    clamp(ushort4 value, ushort min_value, ushort max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int2 __attribute__((const, overloadable))
+    clamp(int2 value, int min_value, int max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int3 __attribute__((const, overloadable))
+    clamp(int3 value, int min_value, int max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern int4 __attribute__((const, overloadable))
+    clamp(int4 value, int min_value, int max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint2 __attribute__((const, overloadable))
+    clamp(uint2 value, uint min_value, uint max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint3 __attribute__((const, overloadable))
+    clamp(uint3 value, uint min_value, uint max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern uint4 __attribute__((const, overloadable))
+    clamp(uint4 value, uint min_value, uint max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long2 __attribute__((const, overloadable))
+    clamp(long2 value, long min_value, long max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long3 __attribute__((const, overloadable))
+    clamp(long3 value, long min_value, long max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern long4 __attribute__((const, overloadable))
+    clamp(long4 value, long min_value, long max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong2 __attribute__((const, overloadable))
+    clamp(ulong2 value, ulong min_value, ulong max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong3 __attribute__((const, overloadable))
+    clamp(ulong3 value, ulong min_value, ulong max_value);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 19))
+extern ulong4 __attribute__((const, overloadable))
+    clamp(ulong4 value, ulong min_value, ulong max_value);
+#endif
+
+/*
+ * clz: Number of leading 0 bits
+ *
+ * Returns the number of leading 0-bits in a value.
+ *
+ * For example, clz((char)0x03) returns 6.
+ */
+extern char __attribute__((const, overloadable))
+    clz(char value);
+
+extern char2 __attribute__((const, overloadable))
+    clz(char2 value);
+
+extern char3 __attribute__((const, overloadable))
+    clz(char3 value);
+
+extern char4 __attribute__((const, overloadable))
+    clz(char4 value);
+
+extern uchar __attribute__((const, overloadable))
+    clz(uchar value);
+
+extern uchar2 __attribute__((const, overloadable))
+    clz(uchar2 value);
+
+extern uchar3 __attribute__((const, overloadable))
+    clz(uchar3 value);
+
+extern uchar4 __attribute__((const, overloadable))
+    clz(uchar4 value);
+
+extern short __attribute__((const, overloadable))
+    clz(short value);
+
+extern short2 __attribute__((const, overloadable))
+    clz(short2 value);
+
+extern short3 __attribute__((const, overloadable))
+    clz(short3 value);
+
+extern short4 __attribute__((const, overloadable))
+    clz(short4 value);
+
+extern ushort __attribute__((const, overloadable))
+    clz(ushort value);
+
+extern ushort2 __attribute__((const, overloadable))
+    clz(ushort2 value);
+
+extern ushort3 __attribute__((const, overloadable))
+    clz(ushort3 value);
+
+extern ushort4 __attribute__((const, overloadable))
+    clz(ushort4 value);
+
+extern int __attribute__((const, overloadable))
+    clz(int value);
+
+extern int2 __attribute__((const, overloadable))
+    clz(int2 value);
+
+extern int3 __attribute__((const, overloadable))
+    clz(int3 value);
+
+extern int4 __attribute__((const, overloadable))
+    clz(int4 value);
+
+extern uint __attribute__((const, overloadable))
+    clz(uint value);
+
+extern uint2 __attribute__((const, overloadable))
+    clz(uint2 value);
+
+extern uint3 __attribute__((const, overloadable))
+    clz(uint3 value);
+
+extern uint4 __attribute__((const, overloadable))
+    clz(uint4 value);
+
+/*
+ * copysign: Copies the sign of a number to another
+ *
+ * Copies the sign from sign_value to magnitude_value.
+ *
+ * The value returned is either magnitude_value or -magnitude_value.
+ *
+ * For example, copysign(4.0f, -2.7f) returns -4.0f and copysign(-4.0f, 2.7f) returns 4.0f.
+ */
+extern float __attribute__((const, overloadable))
+    copysign(float magnitude_value, float sign_value);
+
+extern float2 __attribute__((const, overloadable))
+    copysign(float2 magnitude_value, float2 sign_value);
+
+extern float3 __attribute__((const, overloadable))
+    copysign(float3 magnitude_value, float3 sign_value);
+
+extern float4 __attribute__((const, overloadable))
+    copysign(float4 magnitude_value, float4 sign_value);
+
+/*
+ * cos: Cosine
+ *
+ * Returns the cosine of an angle measured in radians.
+ *
+ * See also native_cos().
+ */
+extern float __attribute__((const, overloadable))
+    cos(float v);
+
+extern float2 __attribute__((const, overloadable))
+    cos(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    cos(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    cos(float4 v);
+
+/*
+ * cosh: Hypebolic cosine
+ *
+ * Returns the hypebolic cosine of v, where v is measured in radians.
+ *
+ * See also native_cosh().
+ */
+extern float __attribute__((const, overloadable))
+    cosh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    cosh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    cosh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    cosh(float4 v);
+
+/*
+ * cospi: Cosine of a number multiplied by pi
+ *
+ * Returns the cosine of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
+ *
+ * See also native_cospi().
+ */
+extern float __attribute__((const, overloadable))
+    cospi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    cospi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    cospi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    cospi(float4 v);
+
+/*
+ * degrees: Converts radians into degrees
+ *
+ * Converts from radians to degrees.
+ */
+extern float __attribute__((const, overloadable))
+    degrees(float v);
+
+extern float2 __attribute__((const, overloadable))
+    degrees(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    degrees(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    degrees(float4 v);
+
+/*
+ * erf: Mathematical error function
+ *
+ * Returns the error function.
+ */
+extern float __attribute__((const, overloadable))
+    erf(float v);
+
+extern float2 __attribute__((const, overloadable))
+    erf(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    erf(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    erf(float4 v);
+
+/*
+ * erfc: Mathematical complementary error function
+ *
+ * Returns the complementary error function.
+ */
+extern float __attribute__((const, overloadable))
+    erfc(float v);
+
+extern float2 __attribute__((const, overloadable))
+    erfc(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    erfc(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    erfc(float4 v);
+
+/*
+ * exp: e raised to a number
+ *
+ * Returns e raised to v, i.e. e ^ v.
+ *
+ * See also native_exp().
+ */
+extern float __attribute__((const, overloadable))
+    exp(float v);
+
+extern float2 __attribute__((const, overloadable))
+    exp(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    exp(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    exp(float4 v);
+
+/*
+ * exp10: 10 raised to a number
+ *
+ * Returns 10 raised to v, i.e. 10.f ^ v.
+ *
+ * See also native_exp10().
+ */
+extern float __attribute__((const, overloadable))
+    exp10(float v);
+
+extern float2 __attribute__((const, overloadable))
+    exp10(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    exp10(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    exp10(float4 v);
+
+/*
+ * exp2: 2 raised to a number
+ *
+ * Returns 2 raised to v, i.e. 2.f ^ v.
+ *
+ * See also native_exp2().
+ */
+extern float __attribute__((const, overloadable))
+    exp2(float v);
+
+extern float2 __attribute__((const, overloadable))
+    exp2(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    exp2(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    exp2(float4 v);
+
+/*
+ * expm1: e raised to a number minus one
+ *
+ * Returns e raised to v minus 1, i.e. (e ^ v) - 1.
+ *
+ * See also native_expm1().
+ */
+extern float __attribute__((const, overloadable))
+    expm1(float v);
+
+extern float2 __attribute__((const, overloadable))
+    expm1(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    expm1(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    expm1(float4 v);
+
+/*
+ * fabs: Absolute value of a float
+ *
+ * Returns the absolute value of the float v.
+ *
+ * For integers, use abs().
+ */
+extern float __attribute__((const, overloadable))
+    fabs(float v);
+
+extern float2 __attribute__((const, overloadable))
+    fabs(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    fabs(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    fabs(float4 v);
+
+/*
+ * fdim: Positive difference between two values
+ *
+ * Returns the positive difference between two values.
+ *
+ * If a > b, returns (a - b) otherwise returns 0f.
+ */
+extern float __attribute__((const, overloadable))
+    fdim(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    fdim(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    fdim(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    fdim(float4 a, float4 b);
+
+/*
+ * floor: Smallest integer not greater than a value
+ *
+ * Returns the smallest integer not greater than a value.
+ *
+ * For example, floor(1.2f) returns 1.f, and floor(-1.2f) returns -2.f.
+ *
+ * See also ceil().
+ */
+extern float __attribute__((const, overloadable))
+    floor(float v);
+
+extern float2 __attribute__((const, overloadable))
+    floor(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    floor(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    floor(float4 v);
+
+/*
+ * fma: Multiply and add
+ *
+ * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
+ *
+ * This function is similar to mad().  fma() retains full precision of the
+ * multiplied result and rounds only after the addition.  mad() rounds after the
+ * multiplication and the addition.  This extra precision is not guaranteed in
+ * rs_fp_relaxed mode.
+ */
+extern float __attribute__((const, overloadable))
+    fma(float multiplicand1, float multiplicand2, float offset);
+
+extern float2 __attribute__((const, overloadable))
+    fma(float2 multiplicand1, float2 multiplicand2, float2 offset);
+
+extern float3 __attribute__((const, overloadable))
+    fma(float3 multiplicand1, float3 multiplicand2, float3 offset);
+
+extern float4 __attribute__((const, overloadable))
+    fma(float4 multiplicand1, float4 multiplicand2, float4 offset);
+
+/*
+ * fmax: Maximum of two floats
+ *
+ * Returns the maximum of a and b, i.e. (a < b ? b : a).
+ *
+ * The max() function returns identical results but can be applied to more data types.
+ */
+extern float __attribute__((const, overloadable))
+    fmax(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    fmax(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    fmax(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    fmax(float4 a, float4 b);
+
+extern float2 __attribute__((const, overloadable))
+    fmax(float2 a, float b);
+
+extern float3 __attribute__((const, overloadable))
+    fmax(float3 a, float b);
+
+extern float4 __attribute__((const, overloadable))
+    fmax(float4 a, float b);
+
+/*
+ * fmin: Minimum of two floats
+ *
+ * Returns the minimum of a and b, i.e. (a > b ? b : a).
+ *
+ * The min() function returns identical results but can be applied to more data types.
+ */
+extern float __attribute__((const, overloadable))
+    fmin(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    fmin(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    fmin(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    fmin(float4 a, float4 b);
+
+extern float2 __attribute__((const, overloadable))
+    fmin(float2 a, float b);
+
+extern float3 __attribute__((const, overloadable))
+    fmin(float3 a, float b);
+
+extern float4 __attribute__((const, overloadable))
+    fmin(float4 a, float b);
+
+/*
+ * fmod: Modulo
+ *
+ * Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
+ *
+ * The function remainder() is similar but rounds toward the closest interger.
+ * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
+ * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
+ */
+extern float __attribute__((const, overloadable))
+    fmod(float numerator, float denominator);
+
+extern float2 __attribute__((const, overloadable))
+    fmod(float2 numerator, float2 denominator);
+
+extern float3 __attribute__((const, overloadable))
+    fmod(float3 numerator, float3 denominator);
+
+extern float4 __attribute__((const, overloadable))
+    fmod(float4 numerator, float4 denominator);
+
+/*
+ * fract: Positive fractional part
+ *
+ * Returns the positive fractional part of v, i.e. v - floor(v).
+ *
+ * For example, fract(1.3f, &val) returns 0.3f and sets val to 1.f.
+ * fract(-1.3f, &val) returns 0.7f and sets val to -2.f.
+ *
+ * Parameters:
+ *   v: Input value.
+ *   floor: If floor is not null, *floor will be set to the floor of v.
+ */
+extern float __attribute__((overloadable))
+    fract(float v, float* floor);
+
+extern float2 __attribute__((overloadable))
+    fract(float2 v, float2* floor);
+
+extern float3 __attribute__((overloadable))
+    fract(float3 v, float3* floor);
+
+extern float4 __attribute__((overloadable))
+    fract(float4 v, float4* floor);
+
+static inline float __attribute__((const, overloadable))
+    fract(float v) {
+    float unused;
+    return fract(v, &unused);
+}
+
+static inline float2 __attribute__((const, overloadable))
+    fract(float2 v) {
+    float2 unused;
+    return fract(v, &unused);
+}
+
+static inline float3 __attribute__((const, overloadable))
+    fract(float3 v) {
+    float3 unused;
+    return fract(v, &unused);
+}
+
+static inline float4 __attribute__((const, overloadable))
+    fract(float4 v) {
+    float4 unused;
+    return fract(v, &unused);
+}
+
+/*
+ * frexp: Binary mantissa and exponent
+ *
+ * Returns the binary mantissa and exponent of v, i.e. v == mantissa * 2 ^ exponent.
+ *
+ * The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
+ *
+ * See ldexp() for the reverse operation.  See also logb() and ilogb().
+ *
+ * Parameters:
+ *   v: Input value.
+ *   exponent: If exponent is not null, *exponent will be set to the exponent of v.
+ */
+extern float __attribute__((overloadable))
+    frexp(float v, int* exponent);
+
+extern float2 __attribute__((overloadable))
+    frexp(float2 v, int2* exponent);
+
+extern float3 __attribute__((overloadable))
+    frexp(float3 v, int3* exponent);
+
+extern float4 __attribute__((overloadable))
+    frexp(float4 v, int4* exponent);
+
+/*
+ * half_recip: Reciprocal computed to 16 bit precision
+ *
+ * Returns the approximate reciprocal of a value.
+ *
+ * The precision is that of a 16 bit floating point value.
+ *
+ * See also native_recip().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    half_recip(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float2 __attribute__((const, overloadable))
+    half_recip(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float3 __attribute__((const, overloadable))
+    half_recip(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float4 __attribute__((const, overloadable))
+    half_recip(float4 v);
+#endif
+
+/*
+ * half_rsqrt: Reciprocal of a square root computed to 16 bit precision
+ *
+ * Returns the approximate value of (1.f / sqrt(value)).
+ *
+ * The precision is that of a 16 bit floating point value.
+ *
+ * See also rsqrt(), native_rsqrt().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    half_rsqrt(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float2 __attribute__((const, overloadable))
+    half_rsqrt(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float3 __attribute__((const, overloadable))
+    half_rsqrt(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float4 __attribute__((const, overloadable))
+    half_rsqrt(float4 v);
+#endif
+
+/*
+ * half_sqrt: Square root computed to 16 bit precision
+ *
+ * Returns the approximate square root of a value.
+ *
+ * The precision is that of a 16 bit floating point value.
+ *
+ * See also sqrt(), native_sqrt().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    half_sqrt(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float2 __attribute__((const, overloadable))
+    half_sqrt(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float3 __attribute__((const, overloadable))
+    half_sqrt(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float4 __attribute__((const, overloadable))
+    half_sqrt(float4 v);
+#endif
+
+/*
+ * hypot: Hypotenuse
+ *
+ * Returns the hypotenuse, i.e. sqrt(a * a + b * b).
+ *
+ * See also native_hypot().
+ */
+extern float __attribute__((const, overloadable))
+    hypot(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    hypot(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    hypot(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    hypot(float4 a, float4 b);
+
+/*
+ * ilogb: Base two exponent
+ *
+ * Returns the base two exponent of a value, where the mantissa is between
+ * 1.f (inclusive) and 2.f (exclusive).
+ *
+ * For example, ilogb(8.5f) returns 3.
+ *
+ * Because of the difference in mantissa, this number is one less than
+ * is returned by frexp().
+ *
+ * logb() is similar but returns a float.
+ */
+extern int __attribute__((const, overloadable))
+    ilogb(float v);
+
+extern int2 __attribute__((const, overloadable))
+    ilogb(float2 v);
+
+extern int3 __attribute__((const, overloadable))
+    ilogb(float3 v);
+
+extern int4 __attribute__((const, overloadable))
+    ilogb(float4 v);
+
+/*
+ * ldexp: Creates a floating point from mantissa and exponent
+ *
+ * Returns the floating point created from the mantissa and exponent,
+ * i.e. (mantissa * 2 ^ exponent).
+ *
+ * See frexp() for the reverse operation.
+ *
+ * Parameters:
+ *   mantissa: The mantissa
+ *   exponent: The exponent, a single component or matching vector.
+ */
+extern float __attribute__((const, overloadable))
+    ldexp(float mantissa, int exponent);
+
+extern float2 __attribute__((const, overloadable))
+    ldexp(float2 mantissa, int2 exponent);
+
+extern float3 __attribute__((const, overloadable))
+    ldexp(float3 mantissa, int3 exponent);
+
+extern float4 __attribute__((const, overloadable))
+    ldexp(float4 mantissa, int4 exponent);
+
+extern float2 __attribute__((const, overloadable))
+    ldexp(float2 mantissa, int exponent);
+
+extern float3 __attribute__((const, overloadable))
+    ldexp(float3 mantissa, int exponent);
+
+extern float4 __attribute__((const, overloadable))
+    ldexp(float4 mantissa, int exponent);
+
+/*
+ * lgamma: Natural logarithm of the gamma function
+ *
+ * Returns the natural logarithm of the absolute value of the gamma function,
+ * i.e. log(fabs(tgamma(v))).
+ *
+ * See also tgamma().
+ *
+ * Parameters:
+ *   sign_of_gamma: If sign_of_gamma is not null, *sign_of_gamma will be set to -1.f if the gamma of v is negative, otherwise to 1.f.
+ */
+extern float __attribute__((const, overloadable))
+    lgamma(float v);
+
+extern float2 __attribute__((const, overloadable))
+    lgamma(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    lgamma(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    lgamma(float4 v);
+
+extern float __attribute__((overloadable))
+    lgamma(float v, int* sign_of_gamma);
+
+extern float2 __attribute__((overloadable))
+    lgamma(float2 v, int2* sign_of_gamma);
+
+extern float3 __attribute__((overloadable))
+    lgamma(float3 v, int3* sign_of_gamma);
+
+extern float4 __attribute__((overloadable))
+    lgamma(float4 v, int4* sign_of_gamma);
+
+/*
+ * log: Natural logarithm
+ *
+ * Returns the natural logarithm.
+ *
+ * See also native_log().
+ */
+extern float __attribute__((const, overloadable))
+    log(float v);
+
+extern float2 __attribute__((const, overloadable))
+    log(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    log(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    log(float4 v);
+
+/*
+ * log10: Base 10 logarithm
+ *
+ * Returns the base 10 logarithm.
+ *
+ * See also native_log10().
+ */
+extern float __attribute__((const, overloadable))
+    log10(float v);
+
+extern float2 __attribute__((const, overloadable))
+    log10(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    log10(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    log10(float4 v);
+
+/*
+ * log1p: Natural logarithm of a value plus 1
+ *
+ * Returns the natural logarithm of (v + 1.f).
+ *
+ * See also native_log1p().
+ */
+extern float __attribute__((const, overloadable))
+    log1p(float v);
+
+extern float2 __attribute__((const, overloadable))
+    log1p(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    log1p(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    log1p(float4 v);
+
+/*
+ * log2: Base 2 logarithm
+ *
+ * Returns the base 2 logarithm.
+ *
+ * See also native_log2().
+ */
+extern float __attribute__((const, overloadable))
+    log2(float v);
+
+extern float2 __attribute__((const, overloadable))
+    log2(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    log2(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    log2(float4 v);
+
+/*
+ * logb: Base two exponent
+ *
+ * Returns the base two exponent of a value, where the mantissa is between
+ * 1.f (inclusive) and 2.f (exclusive).
+ *
+ * For example, logb(8.5f) returns 3.f.
+ *
+ * Because of the difference in mantissa, this number is one less than
+ * is returned by frexp().
+ *
+ * ilogb() is similar but returns an integer.
+ */
+extern float __attribute__((const, overloadable))
+    logb(float v);
+
+extern float2 __attribute__((const, overloadable))
+    logb(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    logb(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    logb(float4 v);
+
+/*
+ * mad: Multiply and add
+ *
+ * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
+ *
+ * This function is similar to fma().  fma() retains full precision of the
+ * multiplied result and rounds only after the addition.  mad() rounds after the
+ * multiplication and the addition.  In rs_fp_relaxed mode, mad() may not do the
+ * rounding after multiplicaiton.
+ */
+extern float __attribute__((const, overloadable))
+    mad(float multiplicand1, float multiplicand2, float offset);
+
+extern float2 __attribute__((const, overloadable))
+    mad(float2 multiplicand1, float2 multiplicand2, float2 offset);
+
+extern float3 __attribute__((const, overloadable))
+    mad(float3 multiplicand1, float3 multiplicand2, float3 offset);
+
+extern float4 __attribute__((const, overloadable))
+    mad(float4 multiplicand1, float4 multiplicand2, float4 offset);
+
+/*
+ * max: Maximum
+ *
+ * Returns the maximum value of two arguments.
+ */
+extern float __attribute__((const, overloadable))
+    max(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    max(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    max(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    max(float4 a, float4 b);
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char __attribute__((const, overloadable))
+    max(char a, char b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar __attribute__((const, overloadable))
+    max(uchar a, uchar b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short __attribute__((const, overloadable))
+    max(short a, short b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort __attribute__((const, overloadable))
+    max(ushort a, ushort b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int __attribute__((const, overloadable))
+    max(int a, int b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint __attribute__((const, overloadable))
+    max(uint a, uint b) {
+    return (a > b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char2 __attribute__((const, overloadable))
+    max(char2 a, char2 b) {
+    char2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar2 __attribute__((const, overloadable))
+    max(uchar2 a, uchar2 b) {
+    uchar2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short2 __attribute__((const, overloadable))
+    max(short2 a, short2 b) {
+    short2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort2 __attribute__((const, overloadable))
+    max(ushort2 a, ushort2 b) {
+    ushort2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int2 __attribute__((const, overloadable))
+    max(int2 a, int2 b) {
+    int2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint2 __attribute__((const, overloadable))
+    max(uint2 a, uint2 b) {
+    uint2 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char3 __attribute__((const, overloadable))
+    max(char3 a, char3 b) {
+    char3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar3 __attribute__((const, overloadable))
+    max(uchar3 a, uchar3 b) {
+    uchar3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short3 __attribute__((const, overloadable))
+    max(short3 a, short3 b) {
+    short3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort3 __attribute__((const, overloadable))
+    max(ushort3 a, ushort3 b) {
+    ushort3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int3 __attribute__((const, overloadable))
+    max(int3 a, int3 b) {
+    int3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint3 __attribute__((const, overloadable))
+    max(uint3 a, uint3 b) {
+    uint3 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char4 __attribute__((const, overloadable))
+    max(char4 a, char4 b) {
+    char4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar4 __attribute__((const, overloadable))
+    max(uchar4 a, uchar4 b) {
+    uchar4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short4 __attribute__((const, overloadable))
+    max(short4 a, short4 b) {
+    short4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort4 __attribute__((const, overloadable))
+    max(ushort4 a, ushort4 b) {
+    ushort4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int4 __attribute__((const, overloadable))
+    max(int4 a, int4 b) {
+    int4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint4 __attribute__((const, overloadable))
+    max(uint4 a, uint4 b) {
+    uint4 tmp;
+    tmp.x = (a.x > b.x ? a.x : b.x);
+    tmp.y = (a.y > b.y ? a.y : b.y);
+    tmp.z = (a.z > b.z ? a.z : b.z);
+    tmp.w = (a.w > b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char __attribute__((const, overloadable))
+    max(char a, char b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char2 __attribute__((const, overloadable))
+    max(char2 a, char2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char3 __attribute__((const, overloadable))
+    max(char3 a, char3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char4 __attribute__((const, overloadable))
+    max(char4 a, char4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar __attribute__((const, overloadable))
+    max(uchar a, uchar b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar2 __attribute__((const, overloadable))
+    max(uchar2 a, uchar2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar3 __attribute__((const, overloadable))
+    max(uchar3 a, uchar3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar4 __attribute__((const, overloadable))
+    max(uchar4 a, uchar4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short __attribute__((const, overloadable))
+    max(short a, short b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short2 __attribute__((const, overloadable))
+    max(short2 a, short2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short3 __attribute__((const, overloadable))
+    max(short3 a, short3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short4 __attribute__((const, overloadable))
+    max(short4 a, short4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort __attribute__((const, overloadable))
+    max(ushort a, ushort b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort2 __attribute__((const, overloadable))
+    max(ushort2 a, ushort2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort3 __attribute__((const, overloadable))
+    max(ushort3 a, ushort3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort4 __attribute__((const, overloadable))
+    max(ushort4 a, ushort4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int __attribute__((const, overloadable))
+    max(int a, int b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int2 __attribute__((const, overloadable))
+    max(int2 a, int2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int3 __attribute__((const, overloadable))
+    max(int3 a, int3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int4 __attribute__((const, overloadable))
+    max(int4 a, int4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint __attribute__((const, overloadable))
+    max(uint a, uint b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint2 __attribute__((const, overloadable))
+    max(uint2 a, uint2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint3 __attribute__((const, overloadable))
+    max(uint3 a, uint3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint4 __attribute__((const, overloadable))
+    max(uint4 a, uint4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long __attribute__((const, overloadable))
+    max(long a, long b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    max(long2 a, long2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    max(long3 a, long3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    max(long4 a, long4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong __attribute__((const, overloadable))
+    max(ulong a, ulong b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    max(ulong2 a, ulong2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    max(ulong3 a, ulong3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    max(ulong4 a, ulong4 b);
+#endif
+
+/*
+ * min: Minimum
+ *
+ * Returns the minimum value of two arguments.
+ */
+extern float __attribute__((const, overloadable))
+    min(float a, float b);
+
+extern float2 __attribute__((const, overloadable))
+    min(float2 a, float2 b);
+
+extern float3 __attribute__((const, overloadable))
+    min(float3 a, float3 b);
+
+extern float4 __attribute__((const, overloadable))
+    min(float4 a, float4 b);
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char __attribute__((const, overloadable))
+    min(char a, char b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar __attribute__((const, overloadable))
+    min(uchar a, uchar b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short __attribute__((const, overloadable))
+    min(short a, short b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort __attribute__((const, overloadable))
+    min(ushort a, ushort b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int __attribute__((const, overloadable))
+    min(int a, int b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint __attribute__((const, overloadable))
+    min(uint a, uint b) {
+    return (a < b ? a : b);
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char2 __attribute__((const, overloadable))
+    min(char2 a, char2 b) {
+    char2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar2 __attribute__((const, overloadable))
+    min(uchar2 a, uchar2 b) {
+    uchar2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short2 __attribute__((const, overloadable))
+    min(short2 a, short2 b) {
+    short2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort2 __attribute__((const, overloadable))
+    min(ushort2 a, ushort2 b) {
+    ushort2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int2 __attribute__((const, overloadable))
+    min(int2 a, int2 b) {
+    int2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint2 __attribute__((const, overloadable))
+    min(uint2 a, uint2 b) {
+    uint2 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char3 __attribute__((const, overloadable))
+    min(char3 a, char3 b) {
+    char3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar3 __attribute__((const, overloadable))
+    min(uchar3 a, uchar3 b) {
+    uchar3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short3 __attribute__((const, overloadable))
+    min(short3 a, short3 b) {
+    short3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort3 __attribute__((const, overloadable))
+    min(ushort3 a, ushort3 b) {
+    ushort3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int3 __attribute__((const, overloadable))
+    min(int3 a, int3 b) {
+    int3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint3 __attribute__((const, overloadable))
+    min(uint3 a, uint3 b) {
+    uint3 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline char4 __attribute__((const, overloadable))
+    min(char4 a, char4 b) {
+    char4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uchar4 __attribute__((const, overloadable))
+    min(uchar4 a, uchar4 b) {
+    uchar4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline short4 __attribute__((const, overloadable))
+    min(short4 a, short4 b) {
+    short4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline ushort4 __attribute__((const, overloadable))
+    min(ushort4 a, ushort4 b) {
+    ushort4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline int4 __attribute__((const, overloadable))
+    min(int4 a, int4 b) {
+    int4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+static inline uint4 __attribute__((const, overloadable))
+    min(uint4 a, uint4 b) {
+    uint4 tmp;
+    tmp.x = (a.x < b.x ? a.x : b.x);
+    tmp.y = (a.y < b.y ? a.y : b.y);
+    tmp.z = (a.z < b.z ? a.z : b.z);
+    tmp.w = (a.w < b.w ? a.w : b.w);
+    return tmp;
+}
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char __attribute__((const, overloadable))
+    min(char a, char b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char2 __attribute__((const, overloadable))
+    min(char2 a, char2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char3 __attribute__((const, overloadable))
+    min(char3 a, char3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern char4 __attribute__((const, overloadable))
+    min(char4 a, char4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar __attribute__((const, overloadable))
+    min(uchar a, uchar b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar2 __attribute__((const, overloadable))
+    min(uchar2 a, uchar2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar3 __attribute__((const, overloadable))
+    min(uchar3 a, uchar3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uchar4 __attribute__((const, overloadable))
+    min(uchar4 a, uchar4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short __attribute__((const, overloadable))
+    min(short a, short b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short2 __attribute__((const, overloadable))
+    min(short2 a, short2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short3 __attribute__((const, overloadable))
+    min(short3 a, short3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern short4 __attribute__((const, overloadable))
+    min(short4 a, short4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort __attribute__((const, overloadable))
+    min(ushort a, ushort b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort2 __attribute__((const, overloadable))
+    min(ushort2 a, ushort2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort3 __attribute__((const, overloadable))
+    min(ushort3 a, ushort3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ushort4 __attribute__((const, overloadable))
+    min(ushort4 a, ushort4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int __attribute__((const, overloadable))
+    min(int a, int b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int2 __attribute__((const, overloadable))
+    min(int2 a, int2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int3 __attribute__((const, overloadable))
+    min(int3 a, int3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern int4 __attribute__((const, overloadable))
+    min(int4 a, int4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint __attribute__((const, overloadable))
+    min(uint a, uint b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint2 __attribute__((const, overloadable))
+    min(uint2 a, uint2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint3 __attribute__((const, overloadable))
+    min(uint3 a, uint3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern uint4 __attribute__((const, overloadable))
+    min(uint4 a, uint4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long __attribute__((const, overloadable))
+    min(long a, long b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long2 __attribute__((const, overloadable))
+    min(long2 a, long2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long3 __attribute__((const, overloadable))
+    min(long3 a, long3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern long4 __attribute__((const, overloadable))
+    min(long4 a, long4 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong __attribute__((const, overloadable))
+    min(ulong a, ulong b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong2 __attribute__((const, overloadable))
+    min(ulong2 a, ulong2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong3 __attribute__((const, overloadable))
+    min(ulong3 a, ulong3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern ulong4 __attribute__((const, overloadable))
+    min(ulong4 a, ulong4 b);
+#endif
+
+/*
+ * mix: Mixes two values
+ *
+ * Returns start + ((stop - start) * fraction).
+ *
+ * This can be useful for mixing two values.  For example, to create a new color that is 40% color1 and 60% color2, use mix(color1, color2, 0.6f).
+ */
+extern float __attribute__((const, overloadable))
+    mix(float start, float stop, float fraction);
+
+extern float2 __attribute__((const, overloadable))
+    mix(float2 start, float2 stop, float2 fraction);
+
+extern float3 __attribute__((const, overloadable))
+    mix(float3 start, float3 stop, float3 fraction);
+
+extern float4 __attribute__((const, overloadable))
+    mix(float4 start, float4 stop, float4 fraction);
+
+extern float2 __attribute__((const, overloadable))
+    mix(float2 start, float2 stop, float fraction);
+
+extern float3 __attribute__((const, overloadable))
+    mix(float3 start, float3 stop, float fraction);
+
+extern float4 __attribute__((const, overloadable))
+    mix(float4 start, float4 stop, float fraction);
+
+/*
+ * modf: Integral and fractional components
+ *
+ * Returns the integral and fractional components of a number.
+ *
+ * Both components will have the same sign as x.  For example, for an input of -3.72f, iret will be set to -3.f and .72f will be returned.
+ *
+ * Parameters:
+ *   v: Source value
+ *   integral_part: *integral_part will be set to the integral portion of the number.
+ *
+ * Returns: The floating point portion of the value.
+ */
+extern float __attribute__((overloadable))
+    modf(float v, float* integral_part);
+
+extern float2 __attribute__((overloadable))
+    modf(float2 v, float2* integral_part);
+
+extern float3 __attribute__((overloadable))
+    modf(float3 v, float3* integral_part);
+
+extern float4 __attribute__((overloadable))
+    modf(float4 v, float4* integral_part);
+
+/*
+ * nan: Not a Number
+ *
+ * Returns a NaN value (Not a Number).
+ *
+ * Parameters:
+ *   v: Not used.
+ */
+extern float __attribute__((const, overloadable))
+    nan(uint v);
+
+/*
+ * native_acos: Approximate inverse cosine
+ *
+ * Returns the approximate inverse cosine, in radians.
+ *
+ * This function yields undefined results from input values less than -1 or greater
+ * than 1.
+ *
+ * See also acos().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_acos(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_acos(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_acos(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_acos(float4 v);
+#endif
+
+/*
+ * native_acosh: Approximate inverse hyperbolic cosine
+ *
+ * Returns the approximate inverse hyperbolic cosine, in radians.
+ *
+ * See also acosh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_acosh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_acosh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_acosh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_acosh(float4 v);
+#endif
+
+/*
+ * native_acospi: Approximate inverse cosine divided by pi
+ *
+ * Returns the approximate inverse cosine in radians, divided by pi.
+ *
+ * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
+ *
+ * This function yields undefined results from input values less than -1 or greater
+ * than 1.
+ *
+ * See also acospi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_acospi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_acospi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_acospi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_acospi(float4 v);
+#endif
+
+/*
+ * native_asin: Approximate inverse sine
+ *
+ * Returns the approximate inverse sine, in radians.
+ *
+ * This function yields undefined results from input values less than -1 or greater
+ * than 1.
+ *
+ * See also asin().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_asin(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_asin(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_asin(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_asin(float4 v);
+#endif
+
+/*
+ * native_asinh: Approximate inverse hyperbolic sine
+ *
+ * Returns the approximate inverse hyperbolic sine, in radians.
+ *
+ * See also asinh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_asinh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_asinh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_asinh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_asinh(float4 v);
+#endif
+
+/*
+ * native_asinpi: Approximate inverse sine divided by pi
+ *
+ * Returns the approximate inverse sine in radians, divided by pi.
+ *
+ * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
+ *
+ * This function yields undefined results from input values less than -1 or greater
+ * than 1.
+ *
+ * See also asinpi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_asinpi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_asinpi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_asinpi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_asinpi(float4 v);
+#endif
+
+/*
+ * native_atan: Approximate inverse tangent
+ *
+ * Returns the approximate inverse tangent, in radians.
+ *
+ * See also atan().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_atan(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_atan(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_atan(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_atan(float4 v);
+#endif
+
+/*
+ * native_atan2: Approximate inverse tangent of a ratio
+ *
+ * Returns the approximate inverse tangent of (numerator / denominator), in radians.
+ *
+ * See also atan2().
+ *
+ * Parameters:
+ *   numerator: The numerator
+ *   denominator: The denominator.  Can be 0.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_atan2(float numerator, float denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_atan2(float2 numerator, float2 denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_atan2(float3 numerator, float3 denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_atan2(float4 numerator, float4 denominator);
+#endif
+
+/*
+ * native_atan2pi: Approximate inverse tangent of a ratio, divided by pi
+ *
+ * Returns the approximate inverse tangent of (numerator / denominator), in radians, divided by pi.
+ *
+ * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
+ *
+ * See also atan2pi().
+ *
+ * Parameters:
+ *   numerator: The numerator
+ *   denominator: The denominator.  Can be 0.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_atan2pi(float numerator, float denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_atan2pi(float2 numerator, float2 denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_atan2pi(float3 numerator, float3 denominator);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_atan2pi(float4 numerator, float4 denominator);
+#endif
+
+/*
+ * native_atanh: Approximate inverse hyperbolic tangent
+ *
+ * Returns the approximate inverse hyperbolic tangent, in radians.
+ *
+ * See also atanh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_atanh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_atanh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_atanh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_atanh(float4 v);
+#endif
+
+/*
+ * native_atanpi: Approximate inverse tangent divided by pi
+ *
+ * Returns the approximate inverse tangent in radians, divided by pi.
+ *
+ * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
+ *
+ * See also atanpi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_atanpi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_atanpi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_atanpi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_atanpi(float4 v);
+#endif
+
+/*
+ * native_cbrt: Approximate cube root
+ *
+ * Returns the approximate cubic root.
+ *
+ * See also cbrt().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_cbrt(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_cbrt(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_cbrt(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_cbrt(float4 v);
+#endif
+
+/*
+ * native_cos: Approximate cosine
+ *
+ * Returns the approximate cosine of an angle measured in radians.
+ *
+ * See also cos().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_cos(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_cos(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_cos(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_cos(float4 v);
+#endif
+
+/*
+ * native_cosh: Approximate hypebolic cosine
+ *
+ * Returns the approximate hypebolic cosine.
+ *
+ * See also cosh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_cosh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_cosh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_cosh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_cosh(float4 v);
+#endif
+
+/*
+ * native_cospi: Approximate cosine of a number multiplied by pi
+ *
+ * Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
+ *
+ * See also cospi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_cospi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_cospi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_cospi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_cospi(float4 v);
+#endif
+
+/*
+ * native_divide: Approximate division
+ *
+ * Computes the approximate division of two values.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_divide(float left_vector, float right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_divide(float2 left_vector, float2 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_divide(float3 left_vector, float3 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_divide(float4 left_vector, float4 right_vector);
+#endif
+
+/*
+ * native_exp: Approximate e raised to a number
+ *
+ * Fast approximate exp.
+ *
+ * It is valid for inputs from -86.f to 86.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+ *
+ * See also exp().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_exp(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_exp(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_exp(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_exp(float4 v);
+#endif
+
+/*
+ * native_exp10: Approximate 10 raised to a number
+ *
+ * Fast approximate exp10.
+ *
+ * It is valid for inputs from -37.f to 37.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+ *
+ * See also exp10().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_exp10(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_exp10(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_exp10(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_exp10(float4 v);
+#endif
+
+/*
+ * native_exp2: Approximate 2 raised to a number
+ *
+ * Fast approximate exp2.
+ *
+ * It is valid for inputs from -125.f to 125.f.  The precision is no worse than what would be expected from using 16 bit floating point values.
+ *
+ * See also exp2().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_exp2(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_exp2(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_exp2(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_exp2(float4 v);
+#endif
+
+/*
+ * native_expm1: Approximate e raised to a number minus one
+ *
+ * Returns the approximate (e ^ v) - 1.
+ *
+ * See also expm1().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_expm1(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_expm1(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_expm1(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_expm1(float4 v);
+#endif
+
+/*
+ * native_hypot: Approximate hypotenuse
+ *
+ * Returns the approximate native_sqrt(a * a + b * b)
+ *
+ * See also hypot().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_hypot(float a, float b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_hypot(float2 a, float2 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_hypot(float3 a, float3 b);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_hypot(float4 a, float4 b);
+#endif
+
+/*
+ * native_log: Approximate natural logarithm
+ *
+ * Fast approximate log.
+ *
+ * It is not accurate for values very close to zero.
+ *
+ * See also log().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_log(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_log(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_log(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_log(float4 v);
+#endif
+
+/*
+ * native_log10: Approximate base 10 logarithm
+ *
+ * Fast approximate log10.
+ *
+ * It is not accurate for values very close to zero.
+ *
+ * See also log10().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_log10(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_log10(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_log10(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_log10(float4 v);
+#endif
+
+/*
+ * native_log1p: Approximate natural logarithm of a value plus 1
+ *
+ * Returns the approximate natural logarithm of (v + 1.0f)
+ *
+ * See also log1p().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_log1p(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_log1p(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_log1p(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_log1p(float4 v);
+#endif
+
+/*
+ * native_log2: Approximate base 2 logarithm
+ *
+ * Fast approximate log2.
+ *
+ * It is not accurate for values very close to zero.
+ *
+ * See also log2().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_log2(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_log2(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_log2(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_log2(float4 v);
+#endif
+
+/*
+ * native_powr: Approximate positive base raised to an exponent
+ *
+ * Fast approximate (base ^ exponent).
+ *
+ * See also powr().
+ *
+ * Parameters:
+ *   base: Must be between 0.f and 256.f.  The function is not accurate for values very close to zero.
+ *   exponent: Must be between -15.f and 15.f.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float __attribute__((const, overloadable))
+    native_powr(float base, float exponent);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float2 __attribute__((const, overloadable))
+    native_powr(float2 base, float2 exponent);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float3 __attribute__((const, overloadable))
+    native_powr(float3 base, float3 exponent);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 18))
+extern float4 __attribute__((const, overloadable))
+    native_powr(float4 base, float4 exponent);
+#endif
+
+/*
+ * native_recip: Approximate reciprocal
+ *
+ * Returns the approximate approximate reciprocal of a value.
+ *
+ * See also half_recip().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_recip(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_recip(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_recip(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_recip(float4 v);
+#endif
+
+/*
+ * native_rootn: Approximate nth root
+ *
+ * Compute the approximate Nth root of a value.
+ *
+ * See also rootn().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_rootn(float v, int n);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_rootn(float2 v, int2 n);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_rootn(float3 v, int3 n);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_rootn(float4 v, int4 n);
+#endif
+
+/*
+ * native_rsqrt: Approximate reciprocal of a square root
+ *
+ * Returns approximate (1 / sqrt(v)).
+ *
+ * See also rsqrt(), half_rsqrt().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_rsqrt(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_rsqrt(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_rsqrt(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_rsqrt(float4 v);
+#endif
+
+/*
+ * native_sin: Approximate sine
+ *
+ * Returns the approximate sine of an angle measured in radians.
+ *
+ * See also sin().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_sin(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_sin(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_sin(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_sin(float4 v);
+#endif
+
+/*
+ * native_sincos: Approximate sine and cosine
+ *
+ * Returns the approximate sine and cosine of a value.
+ *
+ * See also sincos().
+ *
+ * Parameters:
+ *   v: The incoming value in radians.
+ *   cos: *cos will be set to the cosine value.
+ *
+ * Returns: sine
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((overloadable))
+    native_sincos(float v, float* cos);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((overloadable))
+    native_sincos(float2 v, float2* cos);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((overloadable))
+    native_sincos(float3 v, float3* cos);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((overloadable))
+    native_sincos(float4 v, float4* cos);
+#endif
+
+/*
+ * native_sinh: Approximate hyperbolic sine
+ *
+ * Returns the approximate hyperbolic sine of a value specified in radians.
+ *
+ * See also sinh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_sinh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_sinh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_sinh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_sinh(float4 v);
+#endif
+
+/*
+ * native_sinpi: Approximate sine of a number multiplied by pi
+ *
+ * Returns the approximate sine of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
+ *
+ * See also sinpi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_sinpi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_sinpi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_sinpi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_sinpi(float4 v);
+#endif
+
+/*
+ * native_sqrt: Approximate square root
+ *
+ * Returns the approximate sqrt(v).
+ *
+ * See also sqrt(), half_sqrt().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_sqrt(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_sqrt(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_sqrt(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_sqrt(float4 v);
+#endif
+
+/*
+ * native_tan: Approximate tangent
+ *
+ * Returns the approximate tangent of an angle measured in radians.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_tan(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_tan(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_tan(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_tan(float4 v);
+#endif
+
+/*
+ * native_tanh: Approximate hyperbolic tangent
+ *
+ * Returns the approximate hyperbolic tangent of a value.
+ *
+ * See also tanh().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_tanh(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_tanh(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_tanh(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_tanh(float4 v);
+#endif
+
+/*
+ * native_tanpi: Approximate tangent of a number multiplied by pi
+ *
+ * Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
+ *
+ * See also tanpi().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_tanpi(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_tanpi(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_tanpi(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_tanpi(float4 v);
+#endif
+
+/*
+ * nextafter: Next floating point number
+ *
+ * Returns the next representable floating point number from v towards target.
+ *
+ * In rs_fp_relaxed mode, a denormalized input value may not yield the next
+ * denormalized  value, as support of denormalized values is optional in
+ * relaxed mode.
+ */
+extern float __attribute__((const, overloadable))
+    nextafter(float v, float target);
+
+extern float2 __attribute__((const, overloadable))
+    nextafter(float2 v, float2 target);
+
+extern float3 __attribute__((const, overloadable))
+    nextafter(float3 v, float3 target);
+
+extern float4 __attribute__((const, overloadable))
+    nextafter(float4 v, float4 target);
+
+/*
+ * pow: Base raised to an exponent
+ *
+ * Returns base raised to the power exponent, i.e. base ^ exponent.
+ *
+ * pown() and powr() are similar.  pown() takes an integer exponent. powr() assumes the base to be non-negative.
+ */
+extern float __attribute__((const, overloadable))
+    pow(float base, float exponent);
+
+extern float2 __attribute__((const, overloadable))
+    pow(float2 base, float2 exponent);
+
+extern float3 __attribute__((const, overloadable))
+    pow(float3 base, float3 exponent);
+
+extern float4 __attribute__((const, overloadable))
+    pow(float4 base, float4 exponent);
+
+/*
+ * pown: Base raised to an integer exponent
+ *
+ * Returns base raised to the power exponent, i.e. base ^ exponent.
+ *
+ * pow() and powr() are similar.  The both take a float exponent. powr() also assumes the base to be non-negative.
+ */
+extern float __attribute__((const, overloadable))
+    pown(float base, int exponent);
+
+extern float2 __attribute__((const, overloadable))
+    pown(float2 base, int2 exponent);
+
+extern float3 __attribute__((const, overloadable))
+    pown(float3 base, int3 exponent);
+
+extern float4 __attribute__((const, overloadable))
+    pown(float4 base, int4 exponent);
+
+/*
+ * powr: Positive base raised to an exponent
+ *
+ * Returns base raised to the power exponent, i.e. base ^ exponent.  base must be >= 0.
+ *
+ * pow() and pown() are similar.  They both make no assumptions about the base.  pow() takes a float exponent while pown() take an integer.
+ *
+ * See also native_powr().
+ */
+extern float __attribute__((const, overloadable))
+    powr(float base, float exponent);
+
+extern float2 __attribute__((const, overloadable))
+    powr(float2 base, float2 exponent);
+
+extern float3 __attribute__((const, overloadable))
+    powr(float3 base, float3 exponent);
+
+extern float4 __attribute__((const, overloadable))
+    powr(float4 base, float4 exponent);
+
+/*
+ * radians: Converts degrees into radians
+ *
+ * Converts from degrees to radians.
+ */
+extern float __attribute__((const, overloadable))
+    radians(float v);
+
+extern float2 __attribute__((const, overloadable))
+    radians(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    radians(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    radians(float4 v);
+
+/*
+ * remainder: Remainder of a division
+ *
+ * Returns the remainder of (numerator / denominator), where the quotient is rounded towards the nearest integer.
+ *
+ * The function fmod() is similar but rounds toward the closest interger.
+ * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
+ * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
+ */
+extern float __attribute__((const, overloadable))
+    remainder(float numerator, float denominator);
+
+extern float2 __attribute__((const, overloadable))
+    remainder(float2 numerator, float2 denominator);
+
+extern float3 __attribute__((const, overloadable))
+    remainder(float3 numerator, float3 denominator);
+
+extern float4 __attribute__((const, overloadable))
+    remainder(float4 numerator, float4 denominator);
+
+/*
+ * remquo: Remainder and quotient of a division
+ *
+ * Returns the quotient and the remainder of (numerator / denominator).
+ *
+ * Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
+ *
+ * This function is useful for implementing periodic functions.  The low three bits of the quotient gives the quadrant and the remainder the distance within the quadrant.  For example, an implementation of sin(x) could call remquo(x, PI / 2.f, &quadrant) to reduce very large value of x to something within a limited range.
+ *
+ * Example: remquo(-23.5f, 8.f, &quot) sets the lowest three bits of quot to 3 and the sign negative.  It returns 0.5f.
+ *
+ * Parameters:
+ *   numerator: The numerator.
+ *   denominator: The denominator.
+ *   quotient: *quotient will be set to the integer quotient.
+ *
+ * Returns: The remainder, precise only for the low three bits.
+ */
+extern float __attribute__((overloadable))
+    remquo(float numerator, float denominator, int* quotient);
+
+extern float2 __attribute__((overloadable))
+    remquo(float2 numerator, float2 denominator, int2* quotient);
+
+extern float3 __attribute__((overloadable))
+    remquo(float3 numerator, float3 denominator, int3* quotient);
+
+extern float4 __attribute__((overloadable))
+    remquo(float4 numerator, float4 denominator, int4* quotient);
+
+/*
+ * rint: Round to even
+ *
+ * Rounds to the nearest integral value.
+ *
+ * rint() rounds half values to even.  For example, rint(0.5f) returns 0.f and rint(1.5f) returns 2.f.  Similarly, rint(-0.5f) returns -0.f and rint(-1.5f) returns -2.f.
+ *
+ * round() is similar but rounds away from zero.  trunc() truncates the decimal fraction.
+ */
+extern float __attribute__((const, overloadable))
+    rint(float v);
+
+extern float2 __attribute__((const, overloadable))
+    rint(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    rint(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    rint(float4 v);
+
+/*
+ * rootn: Nth root
+ *
+ * Compute the Nth root of a value.
+ *
+ * See also native_rootn().
+ */
+extern float __attribute__((const, overloadable))
+    rootn(float v, int n);
+
+extern float2 __attribute__((const, overloadable))
+    rootn(float2 v, int2 n);
+
+extern float3 __attribute__((const, overloadable))
+    rootn(float3 v, int3 n);
+
+extern float4 __attribute__((const, overloadable))
+    rootn(float4 v, int4 n);
+
+/*
+ * round: Round away from zero
+ *
+ * Round to the nearest integral value.
+ *
+ * round() rounds half values away from zero.  For example, round(0.5f) returns 1.f and round(1.5f) returns 2.f.  Similarly, round(-0.5f) returns -1.f and round(-1.5f) returns -2.f.
+ *
+ * rint() is similar but rounds half values toward even.  trunc() truncates the decimal fraction.
+ */
+extern float __attribute__((const, overloadable))
+    round(float v);
+
+extern float2 __attribute__((const, overloadable))
+    round(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    round(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    round(float4 v);
+
+/*
+ * rsqrt: Reciprocal of a square root
+ *
+ * Returns (1 / sqrt(v)).
+ *
+ * See also half_rsqrt(), native_rsqrt().
+ */
+extern float __attribute__((const, overloadable))
+    rsqrt(float v);
+
+extern float2 __attribute__((const, overloadable))
+    rsqrt(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    rsqrt(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    rsqrt(float4 v);
+
+/*
+ * sign: Sign of a value
+ *
+ * Returns the sign of a value.
+ *
+ * if (v < 0) return -1.f;
+ * else if (v > 0) return 1.f;
+ * else return 0.f;
+ */
+extern float __attribute__((const, overloadable))
+    sign(float v);
+
+extern float2 __attribute__((const, overloadable))
+    sign(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    sign(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    sign(float4 v);
+
+/*
+ * sin: Sine
+ *
+ * Returns the sine of an angle measured in radians.
+ *
+ * See also native_sin().
+ */
+extern float __attribute__((const, overloadable))
+    sin(float v);
+
+extern float2 __attribute__((const, overloadable))
+    sin(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    sin(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    sin(float4 v);
+
+/*
+ * sincos: Sine and cosine
+ *
+ * Returns the sine and cosine of a value.
+ *
+ * See also native_sincos().
+ *
+ * Parameters:
+ *   v: The incoming value in radians
+ *   cos: *cos will be set to the cosine value.
+ *
+ * Returns: sine of v
+ */
+extern float __attribute__((overloadable))
+    sincos(float v, float* cos);
+
+extern float2 __attribute__((overloadable))
+    sincos(float2 v, float2* cos);
+
+extern float3 __attribute__((overloadable))
+    sincos(float3 v, float3* cos);
+
+extern float4 __attribute__((overloadable))
+    sincos(float4 v, float4* cos);
+
+/*
+ * sinh: Hyperbolic sine
+ *
+ * Returns the hyperbolic sine of v, where v is measured in radians.
+ *
+ * See also native_sinh().
+ */
+extern float __attribute__((const, overloadable))
+    sinh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    sinh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    sinh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    sinh(float4 v);
+
+/*
+ * sinpi: Sine of a number multiplied by pi
+ *
+ * Returns the sine of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
+ *
+ * See also native_sinpi().
+ */
+extern float __attribute__((const, overloadable))
+    sinpi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    sinpi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    sinpi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    sinpi(float4 v);
+
+/*
+ * sqrt: Square root
+ *
+ * Returns the square root of a value.
+ *
+ * See also half_sqrt(), native_sqrt().
+ */
+extern float __attribute__((const, overloadable))
+    sqrt(float v);
+
+extern float2 __attribute__((const, overloadable))
+    sqrt(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    sqrt(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    sqrt(float4 v);
+
+/*
+ * step: 0 if less than a value, 0 otherwise
+ *
+ * Returns 0.f if v < edge, 1.f otherwise.
+ *
+ * This can be useful to create conditional computations without using loops and branching instructions.  For example, instead of computing (a[i] < b[i]) ? 0.f : atan2(a[i], b[i]) for the corresponding elements of a vector, you could instead use step(a, b) * atan2(a, b).
+ */
+extern float __attribute__((const, overloadable))
+    step(float edge, float v);
+
+extern float2 __attribute__((const, overloadable))
+    step(float2 edge, float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    step(float3 edge, float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    step(float4 edge, float4 v);
+
+extern float2 __attribute__((const, overloadable))
+    step(float2 edge, float v);
+
+extern float3 __attribute__((const, overloadable))
+    step(float3 edge, float v);
+
+extern float4 __attribute__((const, overloadable))
+    step(float4 edge, float v);
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    step(float edge, float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    step(float edge, float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    step(float edge, float4 v);
+#endif
+
+/*
+ * tan: Tangent
+ *
+ * Returns the tangent of an angle measured in radians.
+ *
+ * See also native_tan().
+ */
+extern float __attribute__((const, overloadable))
+    tan(float v);
+
+extern float2 __attribute__((const, overloadable))
+    tan(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    tan(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    tan(float4 v);
+
+/*
+ * tanh: Hyperbolic tangent
+ *
+ * Returns the hyperbolic tangent of a value.
+ *
+ * See also native_tanh().
+ */
+extern float __attribute__((const, overloadable))
+    tanh(float v);
+
+extern float2 __attribute__((const, overloadable))
+    tanh(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    tanh(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    tanh(float4 v);
+
+/*
+ * tanpi: Tangent of a number multiplied by pi
+ *
+ * Returns the tangent of (v * pi), where (v * pi) is measured in radians.
+ *
+ * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
+ *
+ * See also native_tanpi().
+ */
+extern float __attribute__((const, overloadable))
+    tanpi(float v);
+
+extern float2 __attribute__((const, overloadable))
+    tanpi(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    tanpi(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    tanpi(float4 v);
+
+/*
+ * tgamma: Gamma function
+ *
+ * Returns the gamma function of a value.
+ *
+ * See also lgamma().
+ */
+extern float __attribute__((const, overloadable))
+    tgamma(float v);
+
+extern float2 __attribute__((const, overloadable))
+    tgamma(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    tgamma(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    tgamma(float4 v);
+
+/*
+ * trunc: Truncates a floating point
+ *
+ * Rounds to integral using truncation.
+ *
+ * For example, trunc(1.7f) returns 1.f and trunc(-1.7f) returns -1.f.
+ *
+ * See rint() and round() for other rounding options.
+ */
+extern float __attribute__((const, overloadable))
+    trunc(float v);
+
+extern float2 __attribute__((const, overloadable))
+    trunc(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    trunc(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    trunc(float4 v);
+
+/*
  * rsClamp: Restrain a value to a range
  *
  * Clamp a value between low and high.
@@ -32,9 +4062,9 @@
  * Deprecated.  Use clamp() instead.
  *
  * Parameters:
- *   amount The value to clamp
- *   low Lower bound
- *   high Upper bound
+ *   amount: The value to clamp
+ *   low: Lower bound
+ *   high: Upper bound
  */
 extern char __attribute__((const, always_inline, overloadable))
     rsClamp(char amount, char low, char high);
@@ -55,132 +4085,12 @@
     rsClamp(uint amount, uint low, uint high);
 
 /*
- * Computes 6 frustum planes from the view projection matrix
- *
- * Parameters:
- *   viewProj matrix to extract planes from
- *   left left plane
- *   right right plane
- *   top top plane
- *   bottom bottom plane
- *   near near plane
- *   far far plane
- */
-static inline void __attribute__((always_inline, overloadable))
-    rsExtractFrustumPlanes(const rs_matrix4x4* viewProj, float4* left, float4* right, float4* top,
-                           float4* bottom, float4* near, float4* far) {
-    // x y z w = a b c d in the plane equation
-    left->x = viewProj->m[3] + viewProj->m[0];
-    left->y = viewProj->m[7] + viewProj->m[4];
-    left->z = viewProj->m[11] + viewProj->m[8];
-    left->w = viewProj->m[15] + viewProj->m[12];
-
-    right->x = viewProj->m[3] - viewProj->m[0];
-    right->y = viewProj->m[7] - viewProj->m[4];
-    right->z = viewProj->m[11] - viewProj->m[8];
-    right->w = viewProj->m[15] - viewProj->m[12];
-
-    top->x = viewProj->m[3] - viewProj->m[1];
-    top->y = viewProj->m[7] - viewProj->m[5];
-    top->z = viewProj->m[11] - viewProj->m[9];
-    top->w = viewProj->m[15] - viewProj->m[13];
-
-    bottom->x = viewProj->m[3] + viewProj->m[1];
-    bottom->y = viewProj->m[7] + viewProj->m[5];
-    bottom->z = viewProj->m[11] + viewProj->m[9];
-    bottom->w = viewProj->m[15] + viewProj->m[13];
-
-    near->x = viewProj->m[3] + viewProj->m[2];
-    near->y = viewProj->m[7] + viewProj->m[6];
-    near->z = viewProj->m[11] + viewProj->m[10];
-    near->w = viewProj->m[15] + viewProj->m[14];
-
-    far->x = viewProj->m[3] - viewProj->m[2];
-    far->y = viewProj->m[7] - viewProj->m[6];
-    far->z = viewProj->m[11] - viewProj->m[10];
-    far->w = viewProj->m[15] - viewProj->m[14];
-
-    float len = length(left->xyz);
-    *left /= len;
-    len = length(right->xyz);
-    *right /= len;
-    len = length(top->xyz);
-    *top /= len;
-    len = length(bottom->xyz);
-    *bottom /= len;
-    len = length(near->xyz);
-    *near /= len;
-    len = length(far->xyz);
-    *far /= len;
-}
-
-/*
  * Returns the fractional part of a float
  */
 extern float __attribute__((const, overloadable))
     rsFrac(float v);
 
 /*
- * Checks if a sphere is withing the 6 frustum planes
- *
- * Parameters:
- *   sphere float4 representing the sphere
- *   left left plane
- *   right right plane
- *   top top plane
- *   bottom bottom plane
- *   near near plane
- *   far far plane
- */
-static inline bool __attribute__((always_inline, overloadable))
-    rsIsSphereInFrustum(float4* sphere, float4* left, float4* right, float4* top, float4* bottom,
-                        float4* near, float4* far) {
-    float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(right->xyz, sphere->xyz) + right->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(top->xyz, sphere->xyz) + top->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(near->xyz, sphere->xyz) + near->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(far->xyz, sphere->xyz) + far->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    return true;
-}
-
-/*
- * Pack floating point (0-1) RGB values into a uchar4.
- *
- * For the float3 variant and the variant that only specifies r, g, b,
- * the alpha component is set to 255 (1.0).
- */
-extern uchar4 __attribute__((const, overloadable))
-    rsPackColorTo8888(float r, float g, float b);
-
-extern uchar4 __attribute__((const, overloadable))
-    rsPackColorTo8888(float r, float g, float b, float a);
-
-extern uchar4 __attribute__((const, overloadable))
-    rsPackColorTo8888(float3 color);
-
-extern uchar4 __attribute__((const, overloadable))
-    rsPackColorTo8888(float4 color);
-
-/*
  * Return a random value between 0 (or min_value) and max_malue.
  */
 extern int __attribute__((overloadable))
@@ -195,19 +4105,4 @@
 extern float __attribute__((overloadable))
     rsRand(float min_value, float max_value);
 
-/*
- * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
- */
-extern float4 __attribute__((const))
-    rsUnpackColor8888(uchar4 c);
-
-/*
- * Convert from YUV to RGBA.
- */
-extern float4 __attribute__((const, overloadable))
-    rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
-
-extern uchar4 __attribute__((const, overloadable))
-    rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
-
 #endif // RENDERSCRIPT_RS_MATH_RSH
diff --git a/scriptc/rs_matrix.rsh b/scriptc/rs_matrix.rsh
index 3ed35a4..169d2b2 100644
--- a/scriptc/rs_matrix.rsh
+++ b/scriptc/rs_matrix.rsh
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_matrix.rsh: Matrix functions
@@ -44,9 +44,114 @@
  * on a matrix that already does a scaling, the resulting matrix when applied
  * to a vector will first do the translation then the scaling.
  */
+
 #ifndef RENDERSCRIPT_RS_MATRIX_RSH
 #define RENDERSCRIPT_RS_MATRIX_RSH
 
+#include "rs_vector_math.rsh"
+
+/*
+ * Computes 6 frustum planes from the view projection matrix
+ *
+ * Parameters:
+ *   viewProj: matrix to extract planes from
+ *   left: left plane
+ *   right: right plane
+ *   top: top plane
+ *   bottom: bottom plane
+ *   near: near plane
+ *   far: far plane
+ */
+static inline void __attribute__((always_inline, overloadable))
+    rsExtractFrustumPlanes(const rs_matrix4x4* viewProj, float4* left, float4* right, float4* top,
+                           float4* bottom, float4* near, float4* far) {
+    // x y z w = a b c d in the plane equation
+    left->x = viewProj->m[3] + viewProj->m[0];
+    left->y = viewProj->m[7] + viewProj->m[4];
+    left->z = viewProj->m[11] + viewProj->m[8];
+    left->w = viewProj->m[15] + viewProj->m[12];
+
+    right->x = viewProj->m[3] - viewProj->m[0];
+    right->y = viewProj->m[7] - viewProj->m[4];
+    right->z = viewProj->m[11] - viewProj->m[8];
+    right->w = viewProj->m[15] - viewProj->m[12];
+
+    top->x = viewProj->m[3] - viewProj->m[1];
+    top->y = viewProj->m[7] - viewProj->m[5];
+    top->z = viewProj->m[11] - viewProj->m[9];
+    top->w = viewProj->m[15] - viewProj->m[13];
+
+    bottom->x = viewProj->m[3] + viewProj->m[1];
+    bottom->y = viewProj->m[7] + viewProj->m[5];
+    bottom->z = viewProj->m[11] + viewProj->m[9];
+    bottom->w = viewProj->m[15] + viewProj->m[13];
+
+    near->x = viewProj->m[3] + viewProj->m[2];
+    near->y = viewProj->m[7] + viewProj->m[6];
+    near->z = viewProj->m[11] + viewProj->m[10];
+    near->w = viewProj->m[15] + viewProj->m[14];
+
+    far->x = viewProj->m[3] - viewProj->m[2];
+    far->y = viewProj->m[7] - viewProj->m[6];
+    far->z = viewProj->m[11] - viewProj->m[10];
+    far->w = viewProj->m[15] - viewProj->m[14];
+
+    float len = length(left->xyz);
+    *left /= len;
+    len = length(right->xyz);
+    *right /= len;
+    len = length(top->xyz);
+    *top /= len;
+    len = length(bottom->xyz);
+    *bottom /= len;
+    len = length(near->xyz);
+    *near /= len;
+    len = length(far->xyz);
+    *far /= len;
+}
+
+/*
+ * Checks if a sphere is withing the 6 frustum planes
+ *
+ * Parameters:
+ *   sphere: float4 representing the sphere
+ *   left: left plane
+ *   right: right plane
+ *   top: top plane
+ *   bottom: bottom plane
+ *   near: near plane
+ *   far: far plane
+ */
+static inline bool __attribute__((always_inline, overloadable))
+    rsIsSphereInFrustum(float4* sphere, float4* left, float4* right, float4* top, float4* bottom,
+                        float4* near, float4* far) {
+    float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    distToCenter = dot(right->xyz, sphere->xyz) + right->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    distToCenter = dot(top->xyz, sphere->xyz) + top->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    distToCenter = dot(near->xyz, sphere->xyz) + near->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    distToCenter = dot(far->xyz, sphere->xyz) + far->w;
+    if (distToCenter < -sphere->w) {
+        return false;
+    }
+    return true;
+}
+
 /*
  * rsMatrixGet: Get one element
  *
@@ -55,9 +160,9 @@
  * Warning: The order of the column and row parameters may be unexpected.
  *
  * Parameters:
- *   m The matrix to extract the element from.
- *   col The zero-based column of the element to be extracted.
- *   row The zero-based row of the element to extracted.
+ *   m: The matrix to extract the element from.
+ *   col: The zero-based column of the element to be extracted.
+ *   row: The zero-based row of the element to extracted.
  */
 extern float __attribute__((overloadable))
     rsMatrixGet(const rs_matrix4x4* m, uint32_t col, uint32_t row);
@@ -74,7 +179,7 @@
  * Returns true if the matrix was successfully inverted.
  *
  * Parameters:
- *   m The matrix to invert.
+ *   m: The matrix to invert.
  */
 extern bool __attribute__((overloadable))
     rsMatrixInverse(rs_matrix4x4* m);
@@ -86,7 +191,7 @@
  * Returns true if the matrix was successfully inverted.
  *
  * Parameters:
- *   m The matrix to modify.
+ *   m: The matrix to modify.
  */
 extern bool __attribute__((overloadable))
     rsMatrixInverseTranspose(rs_matrix4x4* m);
@@ -111,9 +216,9 @@
  *
  *
  * Parameters:
- *   destination The matrix to set.
- *   array The array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size.
- *   source The source matrix.
+ *   destination: The matrix to set.
+ *   array: The array of values to set the matrix to. These arrays should be 4, 9, or 16 floats long, depending on the matrix size.
+ *   source: The source matrix.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoad(rs_matrix4x4* destination, const float* array);
@@ -150,7 +255,7 @@
  * created matrix using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to set.
+ *   m: The matrix to set.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadFrustum(rs_matrix4x4* m, float left, float right, float bottom, float top,
@@ -162,7 +267,7 @@
  * Set the elements of a matrix to the identity matrix.
  *
  * Parameters:
- *   m The matrix to set.
+ *   m: The matrix to set.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadIdentity(rs_matrix4x4* m);
@@ -189,9 +294,9 @@
  * rsMatrixLoadMultiply (&m2l, &m2r, &m2l) works as expected.
  *
  * Parameters:
- *   m The matrix to set.
- *   lhs The left matrix of the product.
- *   rhs The right matrix of the product.
+ *   m: The matrix to set.
+ *   lhs: The left matrix of the product.
+ *   rhs: The right matrix of the product.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadMultiply(rs_matrix4x4* m, const rs_matrix4x4* lhs, const rs_matrix4x4* rhs);
@@ -216,7 +321,7 @@
  * See https://en.wikipedia.org/wiki/Orthographic_projection .
  *
  * Parameters:
- *   m The matrix to set.
+ *   m: The matrix to set.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadOrtho(rs_matrix4x4* m, float left, float right, float bottom, float top, float near,
@@ -231,11 +336,11 @@
  * created matrix using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to set.
- *   fovy Field of view, in degrees along the Y axis.
- *   aspect Ratio of x / y.
- *   near The near clipping plane.
- *   far The far clipping plane.
+ *   m: The matrix to set.
+ *   fovy: Field of view, in degrees along the Y axis.
+ *   aspect: Ratio of x / y.
+ *   near: The near clipping plane.
+ *   far: The far clipping plane.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
@@ -252,11 +357,11 @@
  * See http://en.wikipedia.org/wiki/Rotation_matrix .
  *
  * Parameters:
- *   m The matrix to set.
- *   rot How much rotation to do, in degrees.
- *   x The x component of the vector that is the axis of rotation.
- *   y The y component of the vector that is the axis of rotation.
- *   z The z component of the vector that is the axis of rotation.
+ *   m: The matrix to set.
+ *   rot: How much rotation to do, in degrees.
+ *   x: The x component of the vector that is the axis of rotation.
+ *   y: The y component of the vector that is the axis of rotation.
+ *   z: The z component of the vector that is the axis of rotation.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadRotate(rs_matrix4x4* m, float rot, float x, float y, float z);
@@ -271,10 +376,10 @@
  * using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to set.
- *   x The multiple to scale the x components by.
- *   y The multiple to scale the y components by.
- *   z The multiple to scale the z components by.
+ *   m: The matrix to set.
+ *   x: The multiple to scale the x components by.
+ *   y: The multiple to scale the y components by.
+ *   z: The multiple to scale the z components by.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadScale(rs_matrix4x4* m, float x, float y, float z);
@@ -289,10 +394,10 @@
  * using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to set.
- *   x The number to add to each x component.
- *   y The number to add to each y component.
- *   z The number to add to each z component.
+ *   m: The matrix to set.
+ *   x: The number to add to each x component.
+ *   y: The number to add to each y component.
+ *   z: The number to add to each z component.
  */
 extern void __attribute__((overloadable))
     rsMatrixLoadTranslate(rs_matrix4x4* m, float x, float y, float z);
@@ -318,8 +423,8 @@
  * Starting with API 14, this function takes a const matrix as the first argument.
  *
  * Parameters:
- *   m The left matrix of the product and the matrix to be set.
- *   rhs The right matrix of the product.
+ *   m: The left matrix of the product and the matrix to be set.
+ *   rhs: The right matrix of the product.
  */
 extern void __attribute__((overloadable))
     rsMatrixMultiply(rs_matrix4x4* m, const rs_matrix4x4* rhs);
@@ -402,11 +507,11 @@
  * the vector by the created matrix using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to modify.
- *   rot How much rotation to do, in degrees.
- *   x The x component of the vector that is the axis of rotation.
- *   y The y component of the vector that is the axis of rotation.
- *   z The z component of the vector that is the axis of rotation.
+ *   m: The matrix to modify.
+ *   rot: How much rotation to do, in degrees.
+ *   x: The x component of the vector that is the axis of rotation.
+ *   y: The y component of the vector that is the axis of rotation.
+ *   z: The z component of the vector that is the axis of rotation.
  */
 extern void __attribute__((overloadable))
     rsMatrixRotate(rs_matrix4x4* m, float rot, float x, float y, float z);
@@ -424,10 +529,10 @@
  * the vector by the created matrix using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to modify.
- *   x The multiple to scale the x components by.
- *   y The multiple to scale the y components by.
- *   z The multiple to scale the z components by.
+ *   m: The matrix to modify.
+ *   x: The multiple to scale the x components by.
+ *   y: The multiple to scale the y components by.
+ *   z: The multiple to scale the z components by.
  */
 extern void __attribute__((overloadable))
     rsMatrixScale(rs_matrix4x4* m, float x, float y, float z);
@@ -440,10 +545,10 @@
  * Warning: The order of the column and row parameters may be unexpected.
  *
  * Parameters:
- *   m The matrix that will be modified.
- *   col The zero-based column of the element to be set.
- *   row The zero-based row of the element to be set.
- *   v The value to set.
+ *   m: The matrix that will be modified.
+ *   col: The zero-based column of the element to be set.
+ *   row: The zero-based row of the element to be set.
+ *   v: The value to set.
  */
 extern void __attribute__((overloadable))
     rsMatrixSet(rs_matrix4x4* m, uint32_t col, uint32_t row, float v);
@@ -467,10 +572,10 @@
  * the vector by the created matrix using rsMatrixMultiply().
  *
  * Parameters:
- *   m The matrix to modify.
- *   x The number to add to each x component.
- *   y The number to add to each y component.
- *   z The number to add to each z component.
+ *   m: The matrix to modify.
+ *   x: The number to add to each x component.
+ *   y: The number to add to each y component.
+ *   z: The number to add to each z component.
  */
 extern void __attribute__((overloadable))
     rsMatrixTranslate(rs_matrix4x4* m, float x, float y, float z);
@@ -481,7 +586,7 @@
  * Transpose the matrix m in place.
  *
  * Parameters:
- *   m The matrix to transpose.
+ *   m: The matrix to transpose.
  */
 extern void __attribute__((overloadable))
     rsMatrixTranspose(rs_matrix4x4* m);
diff --git a/scriptc/rs_mesh.rsh b/scriptc/rs_mesh.rsh
deleted file mode 100644
index c404a5f..0000000
--- a/scriptc/rs_mesh.rsh
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_mesh.rsh: Mesh routines
- *
- */
-#ifndef RENDERSCRIPT_RS_MESH_RSH
-#define RENDERSCRIPT_RS_MESH_RSH
-
-/*
- * Returns an allocation containing index data or a null
- * allocation if only the primitive is specified
- *
- * Parameters:
- *   m mesh to get data from
- *   index index of the index allocation
- *
- * Returns: allocation containing index data
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_allocation __attribute__((overloadable))
-    rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
-#endif
-
-/*
- * Returns the primitive describing how a part of the mesh is
- * rendered
- *
- * Parameters:
- *   m mesh to get data from
- *   index index of the primitive
- *
- * Returns: primitive describing how the mesh is rendered
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_primitive __attribute__((overloadable))
-    rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
-#endif
-
-/*
- * Meshes could have multiple index sets, this function returns
- * the number.
- *
- * Parameters:
- *   m mesh to get data from
- *
- * Returns: number of primitive groups in the mesh. This would include simple primitives as well as allocations containing index data
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsgMeshGetPrimitiveCount(rs_mesh m);
-#endif
-
-/*
- * Returns an allocation that is part of the mesh and contains
- * vertex data, e.g. positions, normals, texcoords
- *
- * Parameters:
- *   m mesh to get data from
- *   index index of the vertex allocation
- *
- * Returns: allocation containing vertex data
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_allocation __attribute__((overloadable))
-    rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
-#endif
-
-/*
- * Returns the number of allocations in the mesh that contain
- * vertex data
- *
- * Parameters:
- *   m mesh to get data from
- *
- * Returns: number of allocations in the mesh that contain vertex data
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern uint32_t __attribute__((overloadable))
-    rsgMeshGetVertexAllocationCount(rs_mesh m);
-#endif
-
-#endif // RENDERSCRIPT_RS_MESH_RSH
diff --git a/scriptc/rs_object.rsh b/scriptc/rs_object.rsh
deleted file mode 100644
index c7205e3..0000000
--- a/scriptc/rs_object.rsh
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_object.rsh: Object routines
- *
- */
-#ifndef RENDERSCRIPT_RS_OBJECT_RSH
-#define RENDERSCRIPT_RS_OBJECT_RSH
-
-/*
- * rsClearObject: For internal use.
- *
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_element* dst);
-
-extern void __attribute__((overloadable))
-    rsClearObject(rs_type* dst);
-
-extern void __attribute__((overloadable))
-    rsClearObject(rs_allocation* dst);
-
-extern void __attribute__((overloadable))
-    rsClearObject(rs_sampler* dst);
-
-extern void __attribute__((overloadable))
-    rsClearObject(rs_script* dst);
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_mesh* dst);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_fragment* dst);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_vertex* dst);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_raster* dst);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_store* dst);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsClearObject(rs_font* dst);
-#endif
-
-/*
- * rsIsObject: For internal use.
- *
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_element v);
-
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_type v);
-
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_allocation v);
-
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_sampler v);
-
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_script v);
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_mesh v);
-#endif
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_fragment v);
-#endif
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_vertex v);
-#endif
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_raster v);
-#endif
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_store v);
-#endif
-
-#ifndef __LP64__
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_font v);
-#endif
-
-/*
- * rsSetObject: For internal use.
- *
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_element* dst, rs_element src);
-
-extern void __attribute__((overloadable))
-    rsSetObject(rs_type* dst, rs_type src);
-
-extern void __attribute__((overloadable))
-    rsSetObject(rs_allocation* dst, rs_allocation src);
-
-extern void __attribute__((overloadable))
-    rsSetObject(rs_sampler* dst, rs_sampler src);
-
-extern void __attribute__((overloadable))
-    rsSetObject(rs_script* dst, rs_script src);
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_mesh* dst, rs_mesh src);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_fragment* dst, rs_program_fragment src);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_vertex* dst, rs_program_vertex src);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_raster* dst, rs_program_raster src);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_store* dst, rs_program_store src);
-#endif
-
-#ifndef __LP64__
-extern void __attribute__((overloadable))
-    rsSetObject(rs_font* dst, rs_font src);
-#endif
-
-#endif // RENDERSCRIPT_RS_OBJECT_RSH
diff --git a/scriptc/rs_object_info.rsh b/scriptc/rs_object_info.rsh
new file mode 100644
index 0000000..16828a3
--- /dev/null
+++ b/scriptc/rs_object_info.rsh
@@ -0,0 +1,405 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_object_info.rsh: Element functions
+ *
+ * The term "element" is used a bit ambiguously in RenderScript, as both
+ * the type of an item of an allocation and the instantiation of that type:
+ *
+ * - rs_element is a handle to a type specification, and
+ *
+ * - In functions like rsGetElementAt(), "element" means the instantiation
+ * of the type, i.e. an item of an allocation.
+ *
+ * The functions below let you query the characteristics of the type specificiation.
+ *
+ * To create complex elements, use the Element.Builder Java class.
+ * For common elements, in Java you can simply use one of the many predefined elements
+ * like F32_2.  You can't create elements from a script.
+ *
+ * An element can be a simple data type as found in C/C++, a handle type,
+ * a structure, or a fixed size vector (of size 2, 3, or 4) of sub-elements.
+ *
+ * Elements can also have a kind, which is semantic information used mostly to
+ * interpret pixel data.
+ */
+
+#ifndef RENDERSCRIPT_RS_OBJECT_INFO_RSH
+#define RENDERSCRIPT_RS_OBJECT_INFO_RSH
+
+/*
+ * rsAllocationGetDimFaces: Presence of more than one face
+ *
+ * If the allocation is a cubemap, this function returns 1 if there's more than one
+ * face present.  In all other cases, it returns 0.
+ *
+ * Returns: Returns 1 if more than one face is present, 0 otherwise.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimFaces(rs_allocation a);
+
+/*
+ * rsAllocationGetDimLOD: Presence of levels of details
+ *
+ * Query an allocation for the presence of more than one Level Of Details.  This is useful for mipmaps.
+ *
+ * Returns: Returns 1 if more than one LOD is present, 0 otherwise.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimLOD(rs_allocation a);
+
+/*
+ * rsAllocationGetDimX: Size of the X dimension
+ *
+ * Returns the size of the X dimension of the allocation.
+ *
+ * Returns: The X dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimX(rs_allocation a);
+
+/*
+ * rsAllocationGetDimY: Size of the Y dimension
+ *
+ * Returns the size of the Y dimension of the allocation.
+ * If the allocation has less than two dimensions, returns 0.
+ *
+ * Returns: The Y dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimY(rs_allocation a);
+
+/*
+ * rsAllocationGetDimZ: Size of the Z dimension
+ *
+ * Returns the size of the Z dimension of the allocation.
+ * If the allocation has less than three dimensions, returns 0.
+ *
+ * Returns: The Z dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimZ(rs_allocation a);
+
+/*
+ * Get the element object describing the allocation's layout
+ *
+ * Parameters:
+ *   a: allocation to get data from
+ *
+ * Returns: element describing allocation layout
+ */
+extern rs_element __attribute__((overloadable))
+    rsAllocationGetElement(rs_allocation a);
+
+/*
+ * rsClearObject: For internal use.
+ *
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_element* dst);
+
+extern void __attribute__((overloadable))
+    rsClearObject(rs_type* dst);
+
+extern void __attribute__((overloadable))
+    rsClearObject(rs_allocation* dst);
+
+extern void __attribute__((overloadable))
+    rsClearObject(rs_sampler* dst);
+
+extern void __attribute__((overloadable))
+    rsClearObject(rs_script* dst);
+
+/*
+ * rsIsObject: For internal use.
+ *
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_element v);
+
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_type v);
+
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_allocation v);
+
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_sampler v);
+
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_script v);
+
+/*
+ * rsElementGetBytesSize: Return the size of an element
+ *
+ * Returns the size in bytes that an instantiation of this element will occupy.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetBytesSize(rs_element e);
+#endif
+
+/*
+ * rsElementGetDataKind: Return the kind of an element
+ *
+ * Returns the element's data kind.  This is used to interpret pixel data.
+ *
+ * See rs_data_kind.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_data_kind __attribute__((overloadable))
+    rsElementGetDataKind(rs_element e);
+#endif
+
+/*
+ * rsElementGetDataType: Return the data type of an element
+ *
+ * Returns the element's base data type.  This can be a type similar to C/C++ (e.g. RS_TYPE_UNSIGNED_8),
+ * a handle (e.g. RS_TYPE_ALLOCATION and RS_TYPE_ELEMENT), or a more complex numerical type
+ * (e.g.RS_TYPE_UNSIGNED_5_6_5 and RS_TYPE_MATRIX_4X4).
+ *
+ * If the element describes a vector, this function returns the data type of one of its items.
+ *
+ * If the element describes a structure, RS_TYPE_NONE is returned.
+ *
+ * See rs_data_type.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_data_type __attribute__((overloadable))
+    rsElementGetDataType(rs_element e);
+#endif
+
+/*
+ * rsElementGetSubElement: Return a sub element of a complex element
+ *
+ * For the element represents a structure, this function returns the sub-element at
+ * the specified index.
+ *
+ * If the element is not a structure or the index is greater or equal to the number
+ * of sub-elements, an invalid handle is returned.
+ *
+ * Parameters:
+ *   e: Element to query
+ *   index: Index of the sub-element to return
+ *
+ * Returns: Sub-element at the given index
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_element __attribute__((overloadable))
+    rsElementGetSubElement(rs_element e, uint32_t index);
+#endif
+
+/*
+ * rsElementGetSubElementArraySize: Return the array size of a sub element of a complex element
+ *
+ * For complex elements, some sub-elements could be statically
+ * sized arrays. This function returns the array size of the
+ * sub-element at the index.
+ *
+ * Parameters:
+ *   e: Element to query
+ *   index: Index of the sub-element
+ *
+ * Returns: Array size of the sub-element at the given index
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetSubElementArraySize(rs_element e, uint32_t index);
+#endif
+
+/*
+ * rsElementGetSubElementCount: Return the number of sub-elements
+ *
+ * Elements could be simple, such as an int or a float, or a
+ * structure with multiple sub-elements, such as a collection of
+ * floats, float2, float4.  This function returns zero for simple
+ * elements or the number of sub-elements otherwise.
+ *
+ * Parameters:
+ *   e: Element to get data from
+ *
+ * Returns: Number of sub-elements in this element
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetSubElementCount(rs_element e);
+#endif
+
+/*
+ * rsElementGetSubElementName: Return the name of a sub-element
+ *
+ * For complex elements, this function returns the name of the sub-element
+ * at the specified index.
+ *
+ * Parameters:
+ *   e: Element to get data from
+ *   index: Index of the sub-element
+ *   name: Array to store the name into
+ *   nameLength: Length of the provided name array
+ *
+ * Returns: Number of characters actually written, excluding the null terminator
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetSubElementName(rs_element e, uint32_t index, char* name, uint32_t nameLength);
+#endif
+
+/*
+ * rsElementGetSubElementNameLength: Return the length of the name of a sub-element
+ *
+ * For complex elements, this function will return the length of
+ * sub-element name at index
+ *
+ * Parameters:
+ *   e: Element to get data from
+ *   index: Index of the sub-element to return
+ *
+ * Returns: Length of the sub-element name including the null terminator (size of buffer needed to write the name)
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetSubElementNameLength(rs_element e, uint32_t index);
+#endif
+
+/*
+ * This function specifies the location of a sub-element within
+ * the element
+ *
+ * Parameters:
+ *   e: Element to get data from
+ *   index: Index of the sub-element
+ *
+ * Returns: Offset in bytes of sub-element in this element at given index
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
+#endif
+
+/*
+ * Returns the element's vector size
+ *
+ * Parameters:
+ *   e: Element to get data from
+ *
+ * Returns: Length of the element vector (for float2, float3, etc.)
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern uint32_t __attribute__((overloadable))
+    rsElementGetVectorSize(rs_element e);
+#endif
+
+/*
+ * rsGetAllocation: Returns the Allocation for a given pointer
+ *
+ * Returns the Allocation for a given pointer.  The pointer should point within
+ * a valid allocation.  The results are undefined if the pointer is not from a
+ * valid allocation.
+ *
+ * This function is deprecated and will be removed from the SDK in a future
+ * release.
+ */
+extern rs_allocation __attribute__((overloadable))
+    rsGetAllocation(const void* p);
+
+/*
+ *  Get sampler anisotropy
+ *
+ * Parameters:
+ *   s: sampler to query
+ *
+ * Returns: anisotropy
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern float __attribute__((overloadable))
+    rsSamplerGetAnisotropy(rs_sampler s);
+#endif
+
+/*
+ * Get sampler magnification value
+ *
+ * Parameters:
+ *   s: sampler to query
+ *
+ * Returns: magnification value
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_sampler_value __attribute__((overloadable))
+    rsSamplerGetMagnification(rs_sampler s);
+#endif
+
+/*
+ * Get sampler minification value
+ *
+ * Parameters:
+ *   s: sampler to query
+ *
+ * Returns: minification value
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_sampler_value __attribute__((overloadable))
+    rsSamplerGetMinification(rs_sampler s);
+#endif
+
+/*
+ * Get sampler wrap S value
+ *
+ * Parameters:
+ *   s: sampler to query
+ *
+ * Returns: wrap S value
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_sampler_value __attribute__((overloadable))
+    rsSamplerGetWrapS(rs_sampler s);
+#endif
+
+/*
+ * Get sampler wrap T value
+ *
+ * Parameters:
+ *   s: sampler to query
+ *
+ * Returns: wrap T value
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+extern rs_sampler_value __attribute__((overloadable))
+    rsSamplerGetWrapT(rs_sampler s);
+#endif
+
+/*
+ * rsSetObject: For internal use.
+ *
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_element* dst, rs_element src);
+
+extern void __attribute__((overloadable))
+    rsSetObject(rs_type* dst, rs_type src);
+
+extern void __attribute__((overloadable))
+    rsSetObject(rs_allocation* dst, rs_allocation src);
+
+extern void __attribute__((overloadable))
+    rsSetObject(rs_sampler* dst, rs_sampler src);
+
+extern void __attribute__((overloadable))
+    rsSetObject(rs_script* dst, rs_script src);
+
+#endif // RENDERSCRIPT_RS_OBJECT_INFO_RSH
diff --git a/scriptc/rs_object_types.rsh b/scriptc/rs_object_types.rsh
new file mode 100644
index 0000000..7df0561
--- /dev/null
+++ b/scriptc/rs_object_types.rsh
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_object_types.rsh: Standard RenderScript types
+ *
+ * TODO desc.
+ */
+
+#ifndef RENDERSCRIPT_RS_OBJECT_TYPES_RSH
+#define RENDERSCRIPT_RS_OBJECT_TYPES_RSH
+
+#define NULL ((void *)0)
+
+// Opaque handle to a RenderScript object. Do not use this directly.
+#ifndef __LP64__
+#define _RS_HANDLE \
+struct {\
+  const int* const p;\
+} __attribute__((packed, aligned(4)))
+#else
+#define _RS_HANDLE \
+struct {\
+  const long* const p;\
+  const long* const r;\
+  const long* const v1;\
+  const long* const v2;\
+}
+#endif
+
+/*
+ * rs_element: Handle to an element
+ *
+ * Opaque handle to a RenderScript element.
+ * See: android.renderscript.Element
+ */
+typedef _RS_HANDLE rs_element;
+
+/*
+ * rs_type: Handle to a Type
+ *
+ * Opaque handle to a RenderScript type.
+ * See: android.renderscript.Type
+ */
+typedef _RS_HANDLE rs_type;
+
+/*
+ * rs_allocation: Handle to an allocation
+ *
+ * Opaque handle to a RenderScript allocation.
+ * See: android.renderscript.Allocation
+ */
+typedef _RS_HANDLE rs_allocation;
+
+/*
+ * rs_sampler: Handle to a Sampler
+ *
+ * Opaque handle to a RenderScript sampler object.
+ * See: android.renderscript.Sampler
+ */
+typedef _RS_HANDLE rs_sampler;
+
+/*
+ * rs_script: Handle to a Script
+ *
+ * Opaque handle to a RenderScript script object.
+ * See: android.renderscript.ScriptC
+ */
+typedef _RS_HANDLE rs_script;
+
+/*
+ * rs_matrix4x4: 4x4 matrix of 32 bit floats
+ *
+ * Native holder for RS matrix.  Elements are stored in the array at the
+ * location [row*4 + col]
+ */
+typedef struct {
+    float m[16];
+} rs_matrix4x4;
+
+/*
+ * rs_matrix3x3: 3x3 matrix of 32 bit floats
+ *
+ * Native holder for RS matrix.  Elements are stored in the array at the
+ * location [row*3 + col]
+ */
+typedef struct {
+    float m[9];
+} rs_matrix3x3;
+
+/*
+ * rs_matrix2x2: 2x2 matrix of 32 bit floats
+ *
+ * Native holder for RS matrix.  Elements are stored in the array at the
+ * location [row*2 + col]
+ */
+typedef struct {
+    float m[4];
+} rs_matrix2x2;
+
+/*
+ * rs_quaternion: Quarternion
+ *
+ * Quaternion type for use with the quaternion functions
+ */
+typedef float4 rs_quaternion;
+
+/*
+ * rs_allocation_cubemap_face: Enum for selecting cube map faces
+ *
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
+typedef enum {
+    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
+    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
+    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
+    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
+    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
+    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
+} rs_allocation_cubemap_face;
+#endif
+
+/*
+ * rs_allocation_usage_type: Bitfield to specify the usage types for an allocation
+ *
+ * These values are ORed together to specify which usages or memory spaces are
+ * relevant to an allocation or an operation on an allocation.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
+typedef enum {
+    RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
+    RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, // Deprecated.
+    RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, // Deprecated.
+    RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, // Deprecated.
+    RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010 // Deprecated.
+} rs_allocation_usage_type;
+#endif
+
+/*
+ * rs_data_type: Element data types
+ *
+ * DataType represents the basic type information for a basic element.  The
+ * naming convention follows.  For numeric types it is FLOAT,
+ * SIGNED, or UNSIGNED followed by the _BITS where BITS is the
+ * size of the data.  BOOLEAN is a true / false (1,0)
+ * represented in an 8 bit container.  The UNSIGNED variants
+ * with multiple bit definitions are for packed graphical data
+ * formats and represent vectors with per vector member sizes
+ * which are treated as a single unit for packing and alignment
+ * purposes.
+ *
+ * MATRIX the three matrix types contain FLOAT_32 elements and are treated
+ * as 32 bits for alignment purposes.
+ *
+ * RS_* objects.  32 bit opaque handles.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_TYPE_NONE             = 0,
+    RS_TYPE_FLOAT_32         = 2,
+    RS_TYPE_FLOAT_64         = 3,
+    RS_TYPE_SIGNED_8         = 4,
+    RS_TYPE_SIGNED_16        = 5,
+    RS_TYPE_SIGNED_32        = 6,
+    RS_TYPE_SIGNED_64        = 7,
+    RS_TYPE_UNSIGNED_8       = 8,
+    RS_TYPE_UNSIGNED_16      = 9,
+    RS_TYPE_UNSIGNED_32      = 10,
+    RS_TYPE_UNSIGNED_64      = 11,
+    RS_TYPE_BOOLEAN          = 12,
+    RS_TYPE_UNSIGNED_5_6_5   = 13,
+    RS_TYPE_UNSIGNED_5_5_5_1 = 14,
+    RS_TYPE_UNSIGNED_4_4_4_4 = 15,
+    RS_TYPE_MATRIX_4X4       = 16,
+    RS_TYPE_MATRIX_3X3       = 17,
+    RS_TYPE_MATRIX_2X2       = 18,
+    RS_TYPE_ELEMENT          = 1000,
+    RS_TYPE_TYPE             = 1001,
+    RS_TYPE_ALLOCATION       = 1002,
+    RS_TYPE_SAMPLER          = 1003,
+    RS_TYPE_SCRIPT           = 1004,
+    RS_TYPE_MESH             = 1005,
+    RS_TYPE_PROGRAM_FRAGMENT = 1006,
+    RS_TYPE_PROGRAM_VERTEX   = 1007,
+    RS_TYPE_PROGRAM_RASTER   = 1008,
+    RS_TYPE_PROGRAM_STORE    = 1009,
+    RS_TYPE_FONT             = 1010,
+    RS_TYPE_INVALID          = 10000
+} rs_data_type;
+#endif
+
+/*
+ * rs_data_kind: Element data kind
+ *
+ * The special interpretation of the data if required.  This is primarly
+ * useful for graphical data.  USER indicates no special interpretation is
+ * expected.  PIXEL is used in conjunction with the standard data types for
+ * representing texture formats.
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_KIND_USER         = 0,
+    RS_KIND_PIXEL_L      = 7,
+    RS_KIND_PIXEL_A      = 8,
+    RS_KIND_PIXEL_LA     = 9,
+    RS_KIND_PIXEL_RGB    = 10,
+    RS_KIND_PIXEL_RGBA   = 11,
+    RS_KIND_PIXEL_DEPTH  = 12,
+    RS_KIND_PIXEL_YUV    = 13,
+    RS_KIND_INVALID      = 100
+} rs_data_kind;
+#endif
+
+/*
+ * rs_sampler_value: Sampler wrap T value
+ *
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 16))
+typedef enum {
+    RS_SAMPLER_NEAREST              = 0,
+    RS_SAMPLER_LINEAR               = 1,
+    RS_SAMPLER_LINEAR_MIP_LINEAR    = 2,
+    RS_SAMPLER_WRAP                 = 3,
+    RS_SAMPLER_CLAMP                = 4,
+    RS_SAMPLER_LINEAR_MIP_NEAREST   = 5,
+    RS_SAMPLER_MIRRORED_REPEAT      = 6,
+    RS_SAMPLER_INVALID              = 100
+} rs_sampler_value;
+#endif
+
+#endif // RENDERSCRIPT_RS_OBJECT_TYPES_RSH
diff --git a/scriptc/rs_program.rsh b/scriptc/rs_program.rsh
deleted file mode 100644
index 78a9848..0000000
--- a/scriptc/rs_program.rsh
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_program.rsh: Program object routines
- *
- */
-#ifndef RENDERSCRIPT_RS_PROGRAM_RSH
-#define RENDERSCRIPT_RS_PROGRAM_RSH
-
-/*
- * Get program raster cull mode
- *
- * Parameters:
- *   pr program raster to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_cull_mode __attribute__((overloadable))
-    rsgProgramRasterGetCullMode(rs_program_raster pr);
-#endif
-
-/*
- * Get program raster point sprite state
- *
- * Parameters:
- *   pr program raster to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramRasterIsPointSpriteEnabled(rs_program_raster pr);
-#endif
-
-/*
- * Get program store blend destination function
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_blend_dst_func __attribute__((overloadable))
-    rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
-#endif
-
-/*
- * Get program store blend source function
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_blend_src_func __attribute__((overloadable))
-    rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
-#endif
-
-/*
- * Get program store depth function
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_depth_func __attribute__((overloadable))
-    rsgProgramStoreGetDepthFunc(rs_program_store ps);
-#endif
-
-/*
- * Get program store alpha component color mask
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsColorMaskAlphaEnabled(rs_program_store ps);
-#endif
-
-/*
- * Get program store blur component color mask
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsColorMaskBlueEnabled(rs_program_store ps);
-#endif
-
-/*
- * Get program store green component color mask
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsColorMaskGreenEnabled(rs_program_store ps);
-#endif
-
-/*
- * Get program store red component color mask
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsColorMaskRedEnabled(rs_program_store ps);
-#endif
-
-/*
- * Get program store depth mask
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsDepthMaskEnabled(rs_program_store ps);
-#endif
-
-/*
- * Get program store dither state
- *
- * Parameters:
- *   ps program store to query
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern bool __attribute__((overloadable))
-    rsgProgramStoreIsDitherEnabled(rs_program_store ps);
-#endif
-
-#endif // RENDERSCRIPT_RS_PROGRAM_RSH
diff --git a/scriptc/rs_quaternion.rsh b/scriptc/rs_quaternion.rsh
index c6ece96..a9321c9 100644
--- a/scriptc/rs_quaternion.rsh
+++ b/scriptc/rs_quaternion.rsh
@@ -14,12 +14,13 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_quaternion.rsh: Quaternion routines
  *
  */
+
 #ifndef RENDERSCRIPT_RS_QUATERNION_RSH
 #define RENDERSCRIPT_RS_QUATERNION_RSH
 
@@ -27,8 +28,8 @@
  * Add two quaternions
  *
  * Parameters:
- *   q destination quaternion to add to
- *   rhs right hand side quaternion to add
+ *   q: destination quaternion to add to
+ *   rhs: right hand side quaternion to add
  */
 static inline void __attribute__((overloadable))
     rsQuaternionAdd(rs_quaternion* q, const rs_quaternion* rhs) {
@@ -42,7 +43,7 @@
  * Conjugates the quaternion
  *
  * Parameters:
- *   q quaternion to conjugate
+ *   q: quaternion to conjugate
  */
 static inline void __attribute__((overloadable))
     rsQuaternionConjugate(rs_quaternion* q) {
@@ -55,8 +56,8 @@
  * Dot product of two quaternions
  *
  * Parameters:
- *   q0 first quaternion
- *   q1 second quaternion
+ *   q0: first quaternion
+ *   q1: second quaternion
  *
  * Returns: dot product between q0 and q1
  */
@@ -69,8 +70,8 @@
  * Computes rotation matrix from the normalized quaternion
  *
  * Parameters:
- *   m resulting matrix
- *   q normalized quaternion
+ *   m: resulting matrix
+ *   q: normalized quaternion
  */
 static inline void __attribute__((overloadable))
     rsQuaternionGetMatrixUnit(rs_matrix4x4* m, const rs_quaternion* q) {
@@ -101,11 +102,11 @@
  * Loads a quaternion that represents a rotation about an arbitrary unit vector
  *
  * Parameters:
- *   q quaternion to set
- *   rot rot angle to rotate by
- *   x component of a vector
- *   y component of a vector
- *   z component of a vector
+ *   q: quaternion to set
+ *   rot: rot angle to rotate by
+ *   x: component of a vector
+ *   y: component of a vector
+ *   z: component of a vector
  */
 static inline void __attribute__((overloadable))
     rsQuaternionLoadRotateUnit(rs_quaternion* q, float rot, float x, float y, float z) {
@@ -123,12 +124,12 @@
  * Set the quaternion from components or from another quaternion.
  *
  * Parameters:
- *   q destination quaternion
- *   w component
- *   x component
- *   y component
- *   z component
- *   rhs source quaternion
+ *   q: destination quaternion
+ *   w: component
+ *   x: component
+ *   y: component
+ *   z: component
+ *   rhs: source quaternion
  */
 static inline void __attribute__((overloadable))
     rsQuaternionSet(rs_quaternion* q, float w, float x, float y, float z) {
@@ -151,11 +152,11 @@
  * (doesn't have to be unit)
  *
  * Parameters:
- *   q quaternion to set
- *   rot angle to rotate by
- *   x component of a vector
- *   y component of a vector
- *   z component of a vector
+ *   q: quaternion to set
+ *   rot: angle to rotate by
+ *   x: component of a vector
+ *   y: component of a vector
+ *   z: component of a vector
  */
 static inline void __attribute__((overloadable))
     rsQuaternionLoadRotate(rs_quaternion* q, float rot, float x, float y, float z) {
@@ -173,7 +174,7 @@
  * Normalizes the quaternion
  *
  * Parameters:
- *   q quaternion to normalize
+ *   q: quaternion to normalize
  */
 static inline void __attribute__((overloadable))
     rsQuaternionNormalize(rs_quaternion* q) {
@@ -191,9 +192,9 @@
  * Multiply quaternion by a scalar or another quaternion
  *
  * Parameters:
- *   q destination quaternion
- *   s scalar
- *   rhs right hand side quaternion to multiply by
+ *   q: destination quaternion
+ *   s: scalar
+ *   rhs: right hand side quaternion to multiply by
  */
 static inline void __attribute__((overloadable))
     rsQuaternionMultiply(rs_quaternion* q, float s) {
@@ -219,10 +220,10 @@
  * Performs spherical linear interpolation between two quaternions
  *
  * Parameters:
- *   q result quaternion from interpolation
- *   q0 first param
- *   q1 second param
- *   t how much to interpolate by
+ *   q: result quaternion from interpolation
+ *   q0: first param
+ *   q1: second param
+ *   t: how much to interpolate by
  */
 static inline void __attribute__((overloadable))
     rsQuaternionSlerp(rs_quaternion* q, const rs_quaternion* q0, const rs_quaternion* q1, float t) {
diff --git a/scriptc/rs_sampler.rsh b/scriptc/rs_sampler.rsh
deleted file mode 100644
index 4b1b778..0000000
--- a/scriptc/rs_sampler.rsh
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_sampler.rsh: Sampler routines
- *
- */
-#ifndef RENDERSCRIPT_RS_SAMPLER_RSH
-#define RENDERSCRIPT_RS_SAMPLER_RSH
-
-/*
- *  Get sampler anisotropy
- *
- * Parameters:
- *   s sampler to query
- *
- * Returns: anisotropy
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern float __attribute__((overloadable))
-    rsSamplerGetAnisotropy(rs_sampler s);
-#endif
-
-/*
- * Get sampler magnification value
- *
- * Parameters:
- *   s sampler to query
- *
- * Returns: magnification value
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_sampler_value __attribute__((overloadable))
-    rsSamplerGetMagnification(rs_sampler s);
-#endif
-
-/*
- * Get sampler minification value
- *
- * Parameters:
- *   s sampler to query
- *
- * Returns: minification value
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_sampler_value __attribute__((overloadable))
-    rsSamplerGetMinification(rs_sampler s);
-#endif
-
-/*
- * Get sampler wrap S value
- *
- * Parameters:
- *   s sampler to query
- *
- * Returns: wrap S value
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_sampler_value __attribute__((overloadable))
-    rsSamplerGetWrapS(rs_sampler s);
-#endif
-
-/*
- * Get sampler wrap T value
- *
- * Parameters:
- *   s sampler to query
- *
- * Returns: wrap T value
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-extern rs_sampler_value __attribute__((overloadable))
-    rsSamplerGetWrapT(rs_sampler s);
-#endif
-
-#endif // RENDERSCRIPT_RS_SAMPLER_RSH
diff --git a/scriptc/rs_time.rsh b/scriptc/rs_time.rsh
index 3a4acf2..5f8721a 100644
--- a/scriptc/rs_time.rsh
+++ b/scriptc/rs_time.rsh
@@ -14,13 +14,14 @@
  * limitations under the License.
  */
 
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
 
 /*
  * rs_time.rsh: RenderScript time routines
  *
  * This file contains RenderScript functions relating to time and date manipulation.
  */
+
 #ifndef RENDERSCRIPT_RS_TIME_RSH
 #define RENDERSCRIPT_RS_TIME_RSH
 
@@ -70,8 +71,8 @@
  * is NULL, this function does nothing and returns NULL.
  *
  * Parameters:
- *   local Broken-down time.
- *   timer Input time as calendar time.
+ *   local: Broken-down time.
+ *   timer: Input time as calendar time.
  *
  * Returns: Pointer to broken-down time (same as input p local).
  */
@@ -84,7 +85,7 @@
  * pointed to by this variable. If an error occurs, a value of -1 is returned.
  *
  * Parameters:
- *   timer Location to also store the returned calendar time.
+ *   timer: Location to also store the returned calendar time.
  *
  * Returns: Seconds since the Epoch.
  */
diff --git a/scriptc/rs_types.rsh b/scriptc/rs_types.rsh
deleted file mode 100644
index b174933..0000000
--- a/scriptc/rs_types.rsh
+++ /dev/null
@@ -1,879 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
-
-/*
- * rs_types.rsh: Standard RenderScript types
- *
- *  Integers:
- *  8 bit: char, int8_t
- *  16 bit: short, int16_t
- *  32 bit: int, in32_t
- *  64 bit: long, long long, int64_t
- *
- *  Unsigned integers:
- *  8 bit: uchar, uint8_t
- *  16 bit: ushort, uint16_t
- *  32 bit: uint, uint32_t
- *  64 bit: ulong, uint64_t
- *
- *  Floating point:
- *  32 bit: float
- *  64 bit: double
- *
- *  Vectors of length 2, 3, and 4 are supported for all the types above.
- */
-#ifndef RENDERSCRIPT_RS_TYPES_RSH
-#define RENDERSCRIPT_RS_TYPES_RSH
-
-#include "stdbool.h"
-
-#define RS_PACKED __attribute__((packed, aligned(4)))
-#define NULL ((void *)0)
-
-// Opaque handle to a RenderScript object. Do not use this directly.
-#ifndef __LP64__
-#define _RS_HANDLE \
-struct {\
-  const int* const p;\
-} __attribute__((packed, aligned(4)))
-#else
-#define _RS_HANDLE \
-struct {\
-  const long* const p;\
-  const long* const r;\
-  const long* const v1;\
-  const long* const v2;\
-}
-#endif
-
-/*
- * M_1_PI: 1 / pi, as a 32 bit float
- *
- * The inverse of pi, as a 32 bit float.
- */
-#define M_1_PI 0.318309886183790671537767526745028724f
-
-/*
- * M_2_PI: 2 / pi, as a 32 bit float
- *
- * 2 divided by pi, as a 32 bit float.
- */
-#define M_2_PI 0.636619772367581343075535053490057448f
-
-/*
- * M_2_PIl: Deprecated.  Use M_2_PI instead.
- *
- */
-#define M_2_PIl 0.636619772367581343075535053490057448f
-
-/*
- * M_2_SQRTPI: 2 / sqrt(pi), as a 32 bit float
- *
- * 2 divided by the square root of pi, as a 32 bit float.
- */
-#define M_2_SQRTPI 1.128379167095512573896158903121545172f
-
-/*
- * M_E: e, as a 32 bit float
- *
- * The number e, the base of the natural logarithm, as a 32 bit float.
- */
-#define M_E 2.718281828459045235360287471352662498f
-
-/*
- * M_LN10: log_e(10), as a 32 bit float
- *
- * The natural logarithm of 10, as a 32 bit float.
- */
-#define M_LN10 2.302585092994045684017991454684364208f
-
-/*
- * M_LN2: log_e(2), as a 32 bit float
- *
- * The natural logarithm of 2, as a 32 bit float.
- */
-#define M_LN2 0.693147180559945309417232121458176568f
-
-/*
- * M_LOG10E: log_10(e), as a 32 bit float
- *
- * The logarithm base 10 of e, as a 32 bit float.
- */
-#define M_LOG10E 0.434294481903251827651128918916605082f
-
-/*
- * M_LOG2E: log_2(e), as a 32 bit float
- *
- * The logarithm base 2 of e, as a 32 bit float.
- */
-#define M_LOG2E 1.442695040888963407359924681001892137f
-
-/*
- * M_PI: pi, as a 32 bit float
- *
- * The constant pi, as a 32 bit float.
- */
-#define M_PI 3.141592653589793238462643383279502884f
-
-/*
- * M_PI_2: pi / 2, as a 32 bit float
- *
- * Pi divided by 2, as a 32 bit float.
- */
-#define M_PI_2 1.570796326794896619231321691639751442f
-
-/*
- * M_PI_4: pi / 4, as a 32 bit float
- *
- * Pi divided by 4, as a 32 bit float.
- */
-#define M_PI_4 0.785398163397448309615660845819875721f
-
-/*
- * M_SQRT1_2: 1 / sqrt(2), as a 32 bit float
- *
- * The inverse of the square root of 2, as a 32 bit float.
- */
-#define M_SQRT1_2 0.707106781186547524400844362104849039f
-
-/*
- * M_SQRT2: sqrt(2), as a 32 bit float
- *
- * The square root of 2, as a 32 bit float.
- */
-#define M_SQRT2 1.414213562373095048801688724209698079f
-
-/*
- * int8_t: 8 bit signed integer
- *
- * 8 bit integer type
- */
-typedef char int8_t;
-
-/*
- * int16_t: 16 bit signed integer
- *
- * 16 bit integer type
- */
-typedef short int16_t;
-
-/*
- * int32_t: 32 bit signed integer
- *
- * 32 bit integer type
- */
-typedef int int32_t;
-
-/*
- * int64_t: 64 bit signed integer
- *
- * 64 bit integer type
- */
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-typedef long long int64_t;
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-typedef long int64_t;
-#endif
-
-/*
- * uint8_t: 8 bit unsigned integer
- *
- * 8 bit unsigned integer type
- */
-typedef unsigned char uint8_t;
-
-/*
- * uint16_t: 16 bit unsigned integer
- *
- * 16 bit unsigned integer type
- */
-typedef unsigned short uint16_t;
-
-/*
- * uint32_t: 32 bit unsigned integer
- *
- * 32 bit unsigned integer type
- */
-typedef unsigned int uint32_t;
-
-/*
- * uint64_t: 64 bit unsigned integer
- *
- * 64 bit unsigned integer type
- */
-#if !defined(RS_VERSION) || (RS_VERSION <= 20)
-typedef unsigned long long uint64_t;
-#endif
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 21))
-typedef unsigned long uint64_t;
-#endif
-
-/*
- * uchar: 8 bit unsigned integer
- *
- * 8 bit unsigned integer type
- */
-typedef uint8_t uchar;
-
-/*
- * ushort: 16 bit unsigned integer
- *
- * 16 bit unsigned integer type
- */
-typedef uint16_t ushort;
-
-/*
- * uint: 32 bit unsigned integer
- *
- * 32 bit unsigned integer type
- */
-typedef uint32_t uint;
-
-/*
- * ulong: 64 bit unsigned integer
- *
- * Typedef for unsigned long (use for 64-bit unsigned integers)
- */
-typedef uint64_t ulong;
-
-/*
- * size_t: Unsigned size type
- *
- * Typedef for size_t
- */
-#ifdef __LP64__
-typedef uint64_t size_t;
-#endif
-
-#ifndef __LP64__
-typedef uint32_t size_t;
-#endif
-
-/*
- * ssize_t: Signed size type
- *
- * Typedef for ssize_t
- */
-#ifdef __LP64__
-typedef int64_t ssize_t;
-#endif
-
-#ifndef __LP64__
-typedef int32_t ssize_t;
-#endif
-
-/*
- * rs_element: Handle to an element
- *
- * Opaque handle to a RenderScript element.
- * See: android.renderscript.Element
- */
-typedef _RS_HANDLE rs_element;
-
-/*
- * rs_type: Handle to a Type
- *
- * Opaque handle to a RenderScript type.
- * See: android.renderscript.Type
- */
-typedef _RS_HANDLE rs_type;
-
-/*
- * rs_allocation: Handle to an allocation
- *
- * Opaque handle to a RenderScript allocation.
- * See: android.renderscript.Allocation
- */
-typedef _RS_HANDLE rs_allocation;
-
-/*
- * rs_sampler: Handle to a Sampler
- *
- * Opaque handle to a RenderScript sampler object.
- * See: android.renderscript.Sampler
- */
-typedef _RS_HANDLE rs_sampler;
-
-/*
- * rs_script: Handle to a Script
- *
- * Opaque handle to a RenderScript script object.
- * See: android.renderscript.ScriptC
- */
-typedef _RS_HANDLE rs_script;
-
-/*
- * rs_mesh: Handle to a Mesh
- *
- * Opaque handle to a RenderScript mesh object.
- * See: android.renderscript.Mesh
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_mesh;
-#endif
-
-/*
- * rs_program_fragment: Handle to a ProgramFragment
- *
- * Opaque handle to a RenderScript ProgramFragment object.
- * See: android.renderscript.ProgramFragment
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_program_fragment;
-#endif
-
-/*
- * rs_program_vertex: Handle to a ProgramVertex
- *
- * Opaque handle to a RenderScript ProgramVertex object.
- * See: android.renderscript.ProgramVertex
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_program_vertex;
-#endif
-
-/*
- * rs_program_raster: Handle to a ProgramRaster
- *
- * Opaque handle to a RenderScript ProgramRaster object.
- * See: android.renderscript.ProgramRaster
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_program_raster;
-#endif
-
-/*
- * rs_program_store: Handle to a ProgramStore
- *
- * Opaque handle to a RenderScript ProgramStore object.
- * See: android.renderscript.ProgramStore
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_program_store;
-#endif
-
-/*
- * rs_font: Handle to a Font
- *
- * Opaque handle to a RenderScript font object.
- * See: android.renderscript.Font
- */
-#ifndef __LP64__
-typedef _RS_HANDLE rs_font;
-#endif
-
-/*
- * float2: Two 32 bit floats
- *
- * Vector version of the basic float type.
- * Provides two float fields packed into a single 64 bit field with 64 bit alignment.
- */
-typedef float __attribute__((ext_vector_type(2))) float2;
-
-/*
- * float3: Three 32 bit floats
- *
- * Vector version of the basic float type.
- * Provides three float fields packed into a single 128 bit field with 128 bit alignment.
- */
-typedef float __attribute__((ext_vector_type(3))) float3;
-
-/*
- * float4: Four 32 bit floats
- *
- * Vector version of the basic float type.
- * Provides four float fields packed into a single 128 bit field with 128 bit alignment.
- */
-typedef float __attribute__((ext_vector_type(4))) float4;
-
-/*
- * double2: Two 64 bit floats
- *
- * Vector version of the basic double type. Provides two double fields packed
- * into a single 128 bit field with 128 bit alignment.
- */
-typedef double __attribute__((ext_vector_type(2))) double2;
-
-/*
- * double3: Three 64 bit floats
- *
- * Vector version of the basic double type. Provides three double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double __attribute__((ext_vector_type(3))) double3;
-
-/*
- * double4: Four 64 bit floats
- *
- * Vector version of the basic double type. Provides four double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double __attribute__((ext_vector_type(4))) double4;
-
-/*
- * uchar2: Two 8 bit unsigned integers
- *
- * Vector version of the basic uchar type. Provides two uchar fields packed
- * into a single 16 bit field with 16 bit alignment.
- */
-typedef uchar __attribute__((ext_vector_type(2))) uchar2;
-
-/*
- * uchar3: Three 8 bit unsigned integers
- *
- * Vector version of the basic uchar type. Provides three uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar __attribute__((ext_vector_type(3))) uchar3;
-
-/*
- * uchar4: Four 8 bit unsigned integers
- *
- * Vector version of the basic uchar type. Provides four uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar __attribute__((ext_vector_type(4))) uchar4;
-
-/*
- * ushort2: Two 16 bit unsigned integers
- *
- * Vector version of the basic ushort type. Provides two ushort fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef ushort __attribute__((ext_vector_type(2))) ushort2;
-
-/*
- * ushort3: Three 16 bit unsigned integers
- *
- * Vector version of the basic ushort type. Provides three ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort __attribute__((ext_vector_type(3))) ushort3;
-
-/*
- * ushort4: Four 16 bit unsigned integers
- *
- * Vector version of the basic ushort type. Provides four ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort __attribute__((ext_vector_type(4))) ushort4;
-
-/*
- * uint2: Two 32 bit unsigned integers
- *
- * Vector version of the basic uint type. Provides two uint fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef uint __attribute__((ext_vector_type(2))) uint2;
-
-/*
- * uint3: Three 32 bit unsigned integers
- *
- * Vector version of the basic uint type. Provides three uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint __attribute__((ext_vector_type(3))) uint3;
-
-/*
- * uint4: Four 32 bit unsigned integers
- *
- * Vector version of the basic uint type. Provides four uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint __attribute__((ext_vector_type(4))) uint4;
-
-/*
- * ulong2: Two 64 bit unsigned integers
- *
- * Vector version of the basic ulong type. Provides two ulong fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef ulong __attribute__((ext_vector_type(2))) ulong2;
-
-/*
- * ulong3: Three 64 bit unsigned integers
- *
- * Vector version of the basic ulong type. Provides three ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong __attribute__((ext_vector_type(3))) ulong3;
-
-/*
- * ulong4: Four 64 bit unsigned integers
- *
- * Vector version of the basic ulong type. Provides four ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong __attribute__((ext_vector_type(4))) ulong4;
-
-/*
- * char2: Two 8 bit signed integers
- *
- * Vector version of the basic char type. Provides two char fields packed into a
- * single 16 bit field with 16 bit alignment.
- */
-typedef char __attribute__((ext_vector_type(2))) char2;
-
-/*
- * char3: Three 8 bit signed integers
- *
- * Vector version of the basic char type. Provides three char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char __attribute__((ext_vector_type(3))) char3;
-
-/*
- * char4: Four 8 bit signed integers
- *
- * Vector version of the basic char type. Provides four char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char __attribute__((ext_vector_type(4))) char4;
-
-/*
- * short2: Two 16 bit signed integers
- *
- * Vector version of the basic short type. Provides two short fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef short __attribute__((ext_vector_type(2))) short2;
-
-/*
- * short3: Three 16 bit signed integers
- *
- * Vector version of the basic short type. Provides three short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short __attribute__((ext_vector_type(3))) short3;
-
-/*
- * short4: Four 16 bit signed integers
- *
- * Vector version of the basic short type. Provides four short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short __attribute__((ext_vector_type(4))) short4;
-
-/*
- * int2: Two 32 bit signed integers
- *
- * Vector version of the basic int type. Provides two int fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef int __attribute__((ext_vector_type(2))) int2;
-
-/*
- * int3: Three 32 bit signed integers
- *
- * Vector version of the basic int type. Provides three int fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int __attribute__((ext_vector_type(3))) int3;
-
-/*
- * int4: Four 32 bit signed integers
- *
- * Vector version of the basic int type. Provides two four fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int __attribute__((ext_vector_type(4))) int4;
-
-/*
- * long2: Two 64 bit signed integers
- *
- * Vector version of the basic long type. Provides two long fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef long __attribute__((ext_vector_type(2))) long2;
-
-/*
- * long3: Three 64 bit signed integers
- *
- * Vector version of the basic long type. Provides three long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long __attribute__((ext_vector_type(3))) long3;
-
-/*
- * long4: Four 64 bit signed integers
- *
- * Vector version of the basic long type. Provides four long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long __attribute__((ext_vector_type(4))) long4;
-
-/*
- * rs_matrix4x4: 4x4 matrix of 32 bit floats
- *
- * Native holder for RS matrix.  Elements are stored in the array at the
- * location [row*4 + col]
- */
-typedef struct {
-    float m[16];
-} rs_matrix4x4;
-
-/*
- * rs_matrix3x3: 3x3 matrix of 32 bit floats
- *
- * Native holder for RS matrix.  Elements are stored in the array at the
- * location [row*3 + col]
- */
-typedef struct {
-    float m[9];
-} rs_matrix3x3;
-
-/*
- * rs_matrix2x2: 2x2 matrix of 32 bit floats
- *
- * Native holder for RS matrix.  Elements are stored in the array at the
- * location [row*2 + col]
- */
-typedef struct {
-    float m[4];
-} rs_matrix2x2;
-
-/*
- * rs_quaternion: Quarternion
- *
- * Quaternion type for use with the quaternion functions
- */
-typedef float4 rs_quaternion;
-
-/*
- * rs_allocation_cubemap_face: Enum for selecting cube map faces
- *
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-typedef enum {
-    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
-    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
-    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
-    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
-    RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
-    RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-} rs_allocation_cubemap_face;
-#endif
-
-/*
- * rs_allocation_usage_type: Bitfield to specify the usage types for an allocation
- *
- * These values are ORed together to specify which usages or memory spaces are
- * relevant to an allocation or an operation on an allocation.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-typedef enum {
-    RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
-    RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, // Deprecated.
-    RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, // Deprecated.
-    RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, // Deprecated.
-    RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010 // Deprecated.
-} rs_allocation_usage_type;
-#endif
-
-/*
- * rs_primitive: How to intepret mesh vertex data
- *
- * Describes the way mesh vertex data is interpreted when rendering
- */
-#ifndef __LP64__
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_PRIMITIVE_POINT = 0, // Vertex data will be rendered as a series of points
-    RS_PRIMITIVE_LINE = 1, // Vertex pairs will be rendered as lines
-    RS_PRIMITIVE_LINE_STRIP = 2, // Vertex data will be rendered as a connected line strip
-    RS_PRIMITIVE_TRIANGLE = 3, // Vertices will be rendered as individual triangles
-    RS_PRIMITIVE_TRIANGLE_STRIP = 4, // Vertices will be rendered as a connected triangle strip defined by the first three vertices with each additional triangle defined by a new vertex
-    RS_PRIMITIVE_TRIANGLE_FAN = 5, // Vertices will be rendered as a sequence of triangles that all share first vertex as the origin
-    RS_PRIMITIVE_INVALID = 100 // Invalid primitive
-} rs_primitive;
-#endif
-#endif
-
-/*
- * rs_data_type: Element data types
- *
- * DataType represents the basic type information for a basic element.  The
- * naming convention follows.  For numeric types it is FLOAT,
- * SIGNED, or UNSIGNED followed by the _BITS where BITS is the
- * size of the data.  BOOLEAN is a true / false (1,0)
- * represented in an 8 bit container.  The UNSIGNED variants
- * with multiple bit definitions are for packed graphical data
- * formats and represent vectors with per vector member sizes
- * which are treated as a single unit for packing and alignment
- * purposes.
- *
- * MATRIX the three matrix types contain FLOAT_32 elements and are treated
- * as 32 bits for alignment purposes.
- *
- * RS_* objects.  32 bit opaque handles.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_TYPE_NONE             = 0,
-    RS_TYPE_FLOAT_32         = 2,
-    RS_TYPE_FLOAT_64         = 3,
-    RS_TYPE_SIGNED_8         = 4,
-    RS_TYPE_SIGNED_16        = 5,
-    RS_TYPE_SIGNED_32        = 6,
-    RS_TYPE_SIGNED_64        = 7,
-    RS_TYPE_UNSIGNED_8       = 8,
-    RS_TYPE_UNSIGNED_16      = 9,
-    RS_TYPE_UNSIGNED_32      = 10,
-    RS_TYPE_UNSIGNED_64      = 11,
-    RS_TYPE_BOOLEAN          = 12,
-    RS_TYPE_UNSIGNED_5_6_5   = 13,
-    RS_TYPE_UNSIGNED_5_5_5_1 = 14,
-    RS_TYPE_UNSIGNED_4_4_4_4 = 15,
-    RS_TYPE_MATRIX_4X4       = 16,
-    RS_TYPE_MATRIX_3X3       = 17,
-    RS_TYPE_MATRIX_2X2       = 18,
-    RS_TYPE_ELEMENT          = 1000,
-    RS_TYPE_TYPE             = 1001,
-    RS_TYPE_ALLOCATION       = 1002,
-    RS_TYPE_SAMPLER          = 1003,
-    RS_TYPE_SCRIPT           = 1004,
-    RS_TYPE_MESH             = 1005,
-    RS_TYPE_PROGRAM_FRAGMENT = 1006,
-    RS_TYPE_PROGRAM_VERTEX   = 1007,
-    RS_TYPE_PROGRAM_RASTER   = 1008,
-    RS_TYPE_PROGRAM_STORE    = 1009,
-    RS_TYPE_FONT             = 1010,
-    RS_TYPE_INVALID          = 10000
-} rs_data_type;
-#endif
-
-/*
- * rs_data_kind: Element data kind
- *
- * The special interpretation of the data if required.  This is primarly
- * useful for graphical data.  USER indicates no special interpretation is
- * expected.  PIXEL is used in conjunction with the standard data types for
- * representing texture formats.
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_KIND_USER         = 0,
-    RS_KIND_PIXEL_L      = 7,
-    RS_KIND_PIXEL_A      = 8,
-    RS_KIND_PIXEL_LA     = 9,
-    RS_KIND_PIXEL_RGB    = 10,
-    RS_KIND_PIXEL_RGBA   = 11,
-    RS_KIND_PIXEL_DEPTH  = 12,
-    RS_KIND_PIXEL_YUV    = 13,
-    RS_KIND_INVALID      = 100
-} rs_data_kind;
-#endif
-
-/*
- * rs_depth_func: Depth function
- *
- * Specifies conditional drawing depending on the comparison of the incoming
- * depth to that found in the depth buffer.
- */
-#ifndef __LP64__
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_DEPTH_FUNC_ALWAYS        = 0, // Always drawn
-    RS_DEPTH_FUNC_LESS          = 1, // Drawn if the incoming depth value is less than that in the depth buffer
-    RS_DEPTH_FUNC_LEQUAL        = 2, // Drawn if the incoming depth value is less or equal to that in the depth buffer
-    RS_DEPTH_FUNC_GREATER       = 3, // Drawn if the incoming depth value is greater than that in the depth buffer
-    RS_DEPTH_FUNC_GEQUAL        = 4, // Drawn if the incoming depth value is greater or equal to that in the depth buffer
-    RS_DEPTH_FUNC_EQUAL         = 5, // Drawn if the incoming depth value is equal to that in the depth buffer
-    RS_DEPTH_FUNC_NOTEQUAL      = 6, // Drawn if the incoming depth value is not equal to that in the depth buffer
-    RS_DEPTH_FUNC_INVALID       = 100 // Invalid depth function
-} rs_depth_func;
-#endif
-#endif
-
-/*
- * rs_blend_src_func: Blend source function
- *
- */
-#ifndef __LP64__
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_BLEND_SRC_ZERO                   = 0,
-    RS_BLEND_SRC_ONE                    = 1,
-    RS_BLEND_SRC_DST_COLOR              = 2,
-    RS_BLEND_SRC_ONE_MINUS_DST_COLOR    = 3,
-    RS_BLEND_SRC_SRC_ALPHA              = 4,
-    RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA    = 5,
-    RS_BLEND_SRC_DST_ALPHA              = 6,
-    RS_BLEND_SRC_ONE_MINUS_DST_ALPHA    = 7,
-    RS_BLEND_SRC_SRC_ALPHA_SATURATE     = 8,
-    RS_BLEND_SRC_INVALID                = 100
-} rs_blend_src_func;
-#endif
-#endif
-
-/*
- * rs_blend_dst_func: Blend destination function
- *
- */
-#ifndef __LP64__
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_BLEND_DST_ZERO                   = 0,
-    RS_BLEND_DST_ONE                    = 1,
-    RS_BLEND_DST_SRC_COLOR              = 2,
-    RS_BLEND_DST_ONE_MINUS_SRC_COLOR    = 3,
-    RS_BLEND_DST_SRC_ALPHA              = 4,
-    RS_BLEND_DST_ONE_MINUS_SRC_ALPHA    = 5,
-    RS_BLEND_DST_DST_ALPHA              = 6,
-    RS_BLEND_DST_ONE_MINUS_DST_ALPHA    = 7,
-    RS_BLEND_DST_INVALID                = 100
-} rs_blend_dst_func;
-#endif
-#endif
-
-/*
- * rs_cull_mode: Culling mode
- *
- */
-#ifndef __LP64__
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_CULL_BACK     = 0,
-    RS_CULL_FRONT    = 1,
-    RS_CULL_NONE     = 2,
-    RS_CULL_INVALID  = 100
-} rs_cull_mode;
-#endif
-#endif
-
-/*
- * rs_sampler_value: Sampler wrap T value
- *
- */
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-typedef enum {
-    RS_SAMPLER_NEAREST              = 0,
-    RS_SAMPLER_LINEAR               = 1,
-    RS_SAMPLER_LINEAR_MIP_LINEAR    = 2,
-    RS_SAMPLER_WRAP                 = 3,
-    RS_SAMPLER_CLAMP                = 4,
-    RS_SAMPLER_LINEAR_MIP_NEAREST   = 5,
-    RS_SAMPLER_MIRRORED_REPEAT      = 6,
-    RS_SAMPLER_INVALID              = 100
-} rs_sampler_value;
-#endif
-
-#endif // RENDERSCRIPT_RS_TYPES_RSH
diff --git a/scriptc/rs_value_types.rsh b/scriptc/rs_value_types.rsh
new file mode 100644
index 0000000..b64d7d7
--- /dev/null
+++ b/scriptc/rs_value_types.rsh
@@ -0,0 +1,406 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_value_types.rsh: Standard RenderScript types
+ *
+ *  Integers:
+ *  - 8 bit: char, int8_t
+ *  - 16 bit: short, int16_t
+ *  - 32 bit: int, in32_t
+ *  - 64 bit: long, long long, int64_t
+ *
+ *  Unsigned integers:
+ *  - 8 bit: uchar, uint8_t
+ *  - 16 bit: ushort, uint16_t
+ *  - 32 bit: uint, uint32_t
+ *  - 64 bit: ulong, uint64_t
+ *
+ *  Floating point:
+ *  - 32 bit: float
+ *  - 64 bit: double
+ *
+ *  Vectors of length 2, 3, and 4 are supported for all the types above.
+ */
+
+#ifndef RENDERSCRIPT_RS_VALUE_TYPES_RSH
+#define RENDERSCRIPT_RS_VALUE_TYPES_RSH
+
+/*
+ * int8_t: 8 bit signed integer
+ *
+ * 8 bit integer type
+ */
+typedef char int8_t;
+
+/*
+ * int16_t: 16 bit signed integer
+ *
+ * 16 bit integer type
+ */
+typedef short int16_t;
+
+/*
+ * int32_t: 32 bit signed integer
+ *
+ * 32 bit integer type
+ */
+typedef int int32_t;
+
+/*
+ * int64_t: 64 bit signed integer
+ *
+ * 64 bit integer type
+ */
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+typedef long long int64_t;
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+typedef long int64_t;
+#endif
+
+/*
+ * uint8_t: 8 bit unsigned integer
+ *
+ * 8 bit unsigned integer type
+ */
+typedef unsigned char uint8_t;
+
+/*
+ * uint16_t: 16 bit unsigned integer
+ *
+ * 16 bit unsigned integer type
+ */
+typedef unsigned short uint16_t;
+
+/*
+ * uint32_t: 32 bit unsigned integer
+ *
+ * 32 bit unsigned integer type
+ */
+typedef unsigned int uint32_t;
+
+/*
+ * uint64_t: 64 bit unsigned integer
+ *
+ * 64 bit unsigned integer type
+ */
+#if !defined(RS_VERSION) || (RS_VERSION <= 20)
+typedef unsigned long long uint64_t;
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+typedef unsigned long uint64_t;
+#endif
+
+/*
+ * uchar: 8 bit unsigned integer
+ *
+ * 8 bit unsigned integer type
+ */
+typedef uint8_t uchar;
+
+/*
+ * ushort: 16 bit unsigned integer
+ *
+ * 16 bit unsigned integer type
+ */
+typedef uint16_t ushort;
+
+/*
+ * uint: 32 bit unsigned integer
+ *
+ * 32 bit unsigned integer type
+ */
+typedef uint32_t uint;
+
+/*
+ * ulong: 64 bit unsigned integer
+ *
+ * Typedef for unsigned long (use for 64-bit unsigned integers)
+ */
+typedef uint64_t ulong;
+
+/*
+ * size_t: Unsigned size type
+ *
+ * Typedef for size_t
+ */
+#ifdef __LP64__
+typedef uint64_t size_t;
+#endif
+
+#ifndef __LP64__
+typedef uint32_t size_t;
+#endif
+
+/*
+ * ssize_t: Signed size type
+ *
+ * Typedef for ssize_t
+ */
+#ifdef __LP64__
+typedef int64_t ssize_t;
+#endif
+
+#ifndef __LP64__
+typedef int32_t ssize_t;
+#endif
+
+/*
+ * float2: Two 32 bit floats
+ *
+ * Vector version of the basic float type.
+ * Provides two float fields packed into a single 64 bit field with 64 bit alignment.
+ */
+typedef float __attribute__((ext_vector_type(2))) float2;
+
+/*
+ * float3: Three 32 bit floats
+ *
+ * Vector version of the basic float type.
+ * Provides three float fields packed into a single 128 bit field with 128 bit alignment.
+ */
+typedef float __attribute__((ext_vector_type(3))) float3;
+
+/*
+ * float4: Four 32 bit floats
+ *
+ * Vector version of the basic float type.
+ * Provides four float fields packed into a single 128 bit field with 128 bit alignment.
+ */
+typedef float __attribute__((ext_vector_type(4))) float4;
+
+/*
+ * double2: Two 64 bit floats
+ *
+ * Vector version of the basic double type. Provides two double fields packed
+ * into a single 128 bit field with 128 bit alignment.
+ */
+typedef double __attribute__((ext_vector_type(2))) double2;
+
+/*
+ * double3: Three 64 bit floats
+ *
+ * Vector version of the basic double type. Provides three double fields packed
+ * into a single 256 bit field with 256 bit alignment.
+ */
+typedef double __attribute__((ext_vector_type(3))) double3;
+
+/*
+ * double4: Four 64 bit floats
+ *
+ * Vector version of the basic double type. Provides four double fields packed
+ * into a single 256 bit field with 256 bit alignment.
+ */
+typedef double __attribute__((ext_vector_type(4))) double4;
+
+/*
+ * uchar2: Two 8 bit unsigned integers
+ *
+ * Vector version of the basic uchar type. Provides two uchar fields packed
+ * into a single 16 bit field with 16 bit alignment.
+ */
+typedef uchar __attribute__((ext_vector_type(2))) uchar2;
+
+/*
+ * uchar3: Three 8 bit unsigned integers
+ *
+ * Vector version of the basic uchar type. Provides three uchar fields packed
+ * into a single 32 bit field with 32 bit alignment.
+ */
+typedef uchar __attribute__((ext_vector_type(3))) uchar3;
+
+/*
+ * uchar4: Four 8 bit unsigned integers
+ *
+ * Vector version of the basic uchar type. Provides four uchar fields packed
+ * into a single 32 bit field with 32 bit alignment.
+ */
+typedef uchar __attribute__((ext_vector_type(4))) uchar4;
+
+/*
+ * ushort2: Two 16 bit unsigned integers
+ *
+ * Vector version of the basic ushort type. Provides two ushort fields packed
+ * into a single 32 bit field with 32 bit alignment.
+ */
+typedef ushort __attribute__((ext_vector_type(2))) ushort2;
+
+/*
+ * ushort3: Three 16 bit unsigned integers
+ *
+ * Vector version of the basic ushort type. Provides three ushort fields packed
+ * into a single 64 bit field with 64 bit alignment.
+ */
+typedef ushort __attribute__((ext_vector_type(3))) ushort3;
+
+/*
+ * ushort4: Four 16 bit unsigned integers
+ *
+ * Vector version of the basic ushort type. Provides four ushort fields packed
+ * into a single 64 bit field with 64 bit alignment.
+ */
+typedef ushort __attribute__((ext_vector_type(4))) ushort4;
+
+/*
+ * uint2: Two 32 bit unsigned integers
+ *
+ * Vector version of the basic uint type. Provides two uint fields packed into a
+ * single 64 bit field with 64 bit alignment.
+ */
+typedef uint __attribute__((ext_vector_type(2))) uint2;
+
+/*
+ * uint3: Three 32 bit unsigned integers
+ *
+ * Vector version of the basic uint type. Provides three uint fields packed into
+ * a single 128 bit field with 128 bit alignment.
+ */
+typedef uint __attribute__((ext_vector_type(3))) uint3;
+
+/*
+ * uint4: Four 32 bit unsigned integers
+ *
+ * Vector version of the basic uint type. Provides four uint fields packed into
+ * a single 128 bit field with 128 bit alignment.
+ */
+typedef uint __attribute__((ext_vector_type(4))) uint4;
+
+/*
+ * ulong2: Two 64 bit unsigned integers
+ *
+ * Vector version of the basic ulong type. Provides two ulong fields packed into
+ * a single 128 bit field with 128 bit alignment.
+ */
+typedef ulong __attribute__((ext_vector_type(2))) ulong2;
+
+/*
+ * ulong3: Three 64 bit unsigned integers
+ *
+ * Vector version of the basic ulong type. Provides three ulong fields packed
+ * into a single 256 bit field with 256 bit alignment.
+ */
+typedef ulong __attribute__((ext_vector_type(3))) ulong3;
+
+/*
+ * ulong4: Four 64 bit unsigned integers
+ *
+ * Vector version of the basic ulong type. Provides four ulong fields packed
+ * into a single 256 bit field with 256 bit alignment.
+ */
+typedef ulong __attribute__((ext_vector_type(4))) ulong4;
+
+/*
+ * char2: Two 8 bit signed integers
+ *
+ * Vector version of the basic char type. Provides two char fields packed into a
+ * single 16 bit field with 16 bit alignment.
+ */
+typedef char __attribute__((ext_vector_type(2))) char2;
+
+/*
+ * char3: Three 8 bit signed integers
+ *
+ * Vector version of the basic char type. Provides three char fields packed into
+ * a single 32 bit field with 32 bit alignment.
+ */
+typedef char __attribute__((ext_vector_type(3))) char3;
+
+/*
+ * char4: Four 8 bit signed integers
+ *
+ * Vector version of the basic char type. Provides four char fields packed into
+ * a single 32 bit field with 32 bit alignment.
+ */
+typedef char __attribute__((ext_vector_type(4))) char4;
+
+/*
+ * short2: Two 16 bit signed integers
+ *
+ * Vector version of the basic short type. Provides two short fields packed into
+ * a single 32 bit field with 32 bit alignment.
+ */
+typedef short __attribute__((ext_vector_type(2))) short2;
+
+/*
+ * short3: Three 16 bit signed integers
+ *
+ * Vector version of the basic short type. Provides three short fields packed
+ * into a single 64 bit field with 64 bit alignment.
+ */
+typedef short __attribute__((ext_vector_type(3))) short3;
+
+/*
+ * short4: Four 16 bit signed integers
+ *
+ * Vector version of the basic short type. Provides four short fields packed
+ * into a single 64 bit field with 64 bit alignment.
+ */
+typedef short __attribute__((ext_vector_type(4))) short4;
+
+/*
+ * int2: Two 32 bit signed integers
+ *
+ * Vector version of the basic int type. Provides two int fields packed into a
+ * single 64 bit field with 64 bit alignment.
+ */
+typedef int __attribute__((ext_vector_type(2))) int2;
+
+/*
+ * int3: Three 32 bit signed integers
+ *
+ * Vector version of the basic int type. Provides three int fields packed into a
+ * single 128 bit field with 128 bit alignment.
+ */
+typedef int __attribute__((ext_vector_type(3))) int3;
+
+/*
+ * int4: Four 32 bit signed integers
+ *
+ * Vector version of the basic int type. Provides two four fields packed into a
+ * single 128 bit field with 128 bit alignment.
+ */
+typedef int __attribute__((ext_vector_type(4))) int4;
+
+/*
+ * long2: Two 64 bit signed integers
+ *
+ * Vector version of the basic long type. Provides two long fields packed into a
+ * single 128 bit field with 128 bit alignment.
+ */
+typedef long __attribute__((ext_vector_type(2))) long2;
+
+/*
+ * long3: Three 64 bit signed integers
+ *
+ * Vector version of the basic long type. Provides three long fields packed into
+ * a single 256 bit field with 256 bit alignment.
+ */
+typedef long __attribute__((ext_vector_type(3))) long3;
+
+/*
+ * long4: Four 64 bit signed integers
+ *
+ * Vector version of the basic long type. Provides four long fields packed into
+ * a single 256 bit field with 256 bit alignment.
+ */
+typedef long __attribute__((ext_vector_type(4))) long4;
+
+#endif // RENDERSCRIPT_RS_VALUE_TYPES_RSH
diff --git a/scriptc/rs_vector_math.rsh b/scriptc/rs_vector_math.rsh
new file mode 100644
index 0000000..d6c35b9
--- /dev/null
+++ b/scriptc/rs_vector_math.rsh
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
+
+/*
+ * rs_vector_math.rsh: TODO Add documentation
+ *
+ * TODO Add documentation
+ */
+
+#ifndef RENDERSCRIPT_RS_VECTOR_MATH_RSH
+#define RENDERSCRIPT_RS_VECTOR_MATH_RSH
+
+/*
+ * cross: Cross product of two vectors
+ *
+ * Computes the cross product of two vectors.
+ */
+extern float3 __attribute__((const, overloadable))
+    cross(float3 left_vector, float3 right_vector);
+
+extern float4 __attribute__((const, overloadable))
+    cross(float4 left_vector, float4 right_vector);
+
+/*
+ * distance: Distance between two points
+ *
+ * Compute the distance between two points.
+ *
+ * See also fast_distance(), native_distance().
+ */
+extern float __attribute__((const, overloadable))
+    distance(float left_vector, float right_vector);
+
+extern float __attribute__((const, overloadable))
+    distance(float2 left_vector, float2 right_vector);
+
+extern float __attribute__((const, overloadable))
+    distance(float3 left_vector, float3 right_vector);
+
+extern float __attribute__((const, overloadable))
+    distance(float4 left_vector, float4 right_vector);
+
+/*
+ * dot: Dot product of two vectors
+ *
+ * Computes the dot product of two vectors.
+ */
+extern float __attribute__((const, overloadable))
+    dot(float left_vector, float right_vector);
+
+extern float __attribute__((const, overloadable))
+    dot(float2 left_vector, float2 right_vector);
+
+extern float __attribute__((const, overloadable))
+    dot(float3 left_vector, float3 right_vector);
+
+extern float __attribute__((const, overloadable))
+    dot(float4 left_vector, float4 right_vector);
+
+/*
+ * fast_distance: Approximate distance between two points
+ *
+ * Computes the approximate distance between two points.
+ *
+ * The precision is what would be expected from doing the computation using 16 bit floating point values.
+ *
+ * See also distance(), native_distance().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_distance(float left_vector, float right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_distance(float2 left_vector, float2 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_distance(float3 left_vector, float3 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_distance(float4 left_vector, float4 right_vector);
+#endif
+
+/*
+ * fast_length: Approximate length of a vector
+ *
+ * Computes the approximate length of a vector.
+ *
+ * The precision is what would be expected from doing the computation using 16 bit floating point values.
+ *
+ * See also length(), native_length().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_length(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_length(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_length(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_length(float4 v);
+#endif
+
+/*
+ * fast_normalize: Approximate normalized vector
+ *
+ * Approximately normalizes a vector.
+ *
+ * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
+ *
+ * The precision is what would be expected from doing the computation using 16 bit floating point values.
+ *
+ * See also normalize(), native_normalize().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float __attribute__((const, overloadable))
+    fast_normalize(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float2 __attribute__((const, overloadable))
+    fast_normalize(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float3 __attribute__((const, overloadable))
+    fast_normalize(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 17))
+extern float4 __attribute__((const, overloadable))
+    fast_normalize(float4 v);
+#endif
+
+/*
+ * length: Length of a vector
+ *
+ * Computes the length of a vector.
+ *
+ * See also fast_length(), native_length().
+ */
+extern float __attribute__((const, overloadable))
+    length(float v);
+
+extern float __attribute__((const, overloadable))
+    length(float2 v);
+
+extern float __attribute__((const, overloadable))
+    length(float3 v);
+
+extern float __attribute__((const, overloadable))
+    length(float4 v);
+
+/*
+ * native_distance: Approximate distance between two points
+ *
+ * Computes the approximate distance between two points.
+ *
+ * See also distance(), fast_distance().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_distance(float left_vector, float right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_distance(float2 left_vector, float2 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_distance(float3 left_vector, float3 right_vector);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_distance(float4 left_vector, float4 right_vector);
+#endif
+
+/*
+ * native_length: Approximate length of a vector
+ *
+ * Compute the approximate length of a vector.
+ *
+ * See also length(), fast_length().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_length(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_length(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_length(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_length(float4 v);
+#endif
+
+/*
+ * native_normalize: Approximately normalize a vector
+ *
+ * Approximately normalizes a vector.
+ *
+ * See also normalize(), fast_normalize().
+ */
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float __attribute__((const, overloadable))
+    native_normalize(float v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float2 __attribute__((const, overloadable))
+    native_normalize(float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float3 __attribute__((const, overloadable))
+    native_normalize(float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 21))
+extern float4 __attribute__((const, overloadable))
+    native_normalize(float4 v);
+#endif
+
+/*
+ * normalize: Normalize a vector
+ *
+ * Normalize a vector.
+ *
+ * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
+ *
+ * See also fast_normalize(), native_normalize().
+ */
+extern float __attribute__((const, overloadable))
+    normalize(float v);
+
+extern float2 __attribute__((const, overloadable))
+    normalize(float2 v);
+
+extern float3 __attribute__((const, overloadable))
+    normalize(float3 v);
+
+extern float4 __attribute__((const, overloadable))
+    normalize(float4 v);
+
+#endif // RENDERSCRIPT_RS_VECTOR_MATH_RSH