Skip to content

How to #include for an AMP compile

Ethatron edited this page Jun 6, 2012 · 3 revisions

In each source-file you may have, you have to make different link-signatures for the included functions, as AMP requires all functions to be available (no external linkage), but also produces regular C++ functions and static variables. Just add the following and embed each individual "invocation" of squish for AMP into a seperate namespace, removing linker clashes.

#define	USE_PRE		// means: we include all sources (a must for AMP & COMPUTE)
#define	USE_AMP		// we request the amp-compatible code

#include "squish/singlecolourlookup_ccr.inl"
#include "squish/degeneracy_ccr.inl"

/* namespace to hide multiple defined symbols (if you have multiple source-files) */
namespace DXT {
#include "squish/maths.cpp"
#include "squish/alpha.cpp"
#include "squish/colourblock.cpp"

#include "squish/colourset.cpp"
#include "squish/colourfit.cpp"
#include "squish/singlecolourfit.cpp"
#include "squish/rangefit.cpp"
#include "squish/clusterfit.cpp"
#include "squish/squish.cpp"
}

using namespace DXT;

You can maintain the LUTs in the global namespace, in a common source-file you can pull the data in like the following. The library automatically references the LUTs from the global namespace.

#define	ONLY_ARRAY
#include "squish/singlecolourlookup_ccr.inl"
#include "squish/degeneracy_ccr.inl"

Clone this wiki locally