"Fossies" - the Fresh Open Source Software Archive

Member "aqsis-1.8.2/prototypes/shaderVM_codegen/applyDerivs.h" (24 Aug 2012, 1307 Bytes) of package /linux/privat/aqsis-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #ifndef APPLYDERIVS_H_INCLUDED
    2 #define APPLYDERIVS_H_INCLUDED
    3 
    4 #include "binduniform.h"
    5 
    6 template<typename SVarT, bool needsDiff>
    7 struct ApplyDiff
    8 {
    9     static DiffSVar<SVarT> apply(const SVarT& sVar)
   10     {
   11         return DiffSVar<SVarT>(sVar);
   12     }
   13 };
   14 
   15 template<typename SVarT>
   16 struct ApplyDiff<SVarT, false>
   17 {
   18     static const SVarT& apply(const SVarT& sVar)
   19     {
   20         return sVar;
   21     }
   22 };
   23 
   24 template<>
   25 struct ApplyDiff<SVarUniform, true>
   26 {
   27     static SVarUniform apply(const SVarUniform& sVar)
   28     {
   29         return SVarUniform(0);
   30     }
   31 };
   32 
   33 template<>
   34 struct ApplyDiff<SVarUniform, false>
   35 {
   36     static const SVarUniform& apply(const SVarUniform& sVar)
   37     {
   38         return sVar;
   39     }
   40 };
   41 
   42 
   43 // Apply difference operators to those arguments which need them.
   44 template<typename FunctionalT, typename SVarT1, typename SVarResT>
   45 void applyDiffs(const FunctionalT& fxn, const SVarT1& a, SVarResT& result)
   46 {
   47     bindUniform(fxn,
   48             ApplyDiff<SVarT1, FunctionalT::arg1NeedsDiff>::apply(a),
   49             result);
   50 }
   51 
   52 template<typename FunctionalT, typename SVarT1, typename SVarT2, typename SVarResT>
   53 void applyDiffs(const FunctionalT& fxn, const SVarT1& a, const SVarT2& b,
   54         SVarResT& result)
   55 {
   56     bindUniform(fxn,
   57             ApplyDiff<SVarT1, FunctionalT::arg1NeedsDiff>::apply(a),
   58             ApplyDiff<SVarT2, FunctionalT::arg2NeedsDiff>::apply(b),
   59             result);
   60 }
   61 
   62 #endif // APPLYDERIVS_H_INCLUDED