arrow_back_ios Back to List

Accessing Global Variables

Offload KB - features

Old Content Alert

Please note that this is a old document archive and the will most likely be out-dated or superseded by various other products and is purely here for historical purposes.

Any coder who has written an SPU job before knows the problems of trying to access global PPU variables from the SPU. Offload provides a much simpler mechanism for accessing PPU globals.

#include <liboffload>
#include <RendererDebug.h>
extern RendererDebugState gDbgRenderer;
int global = 42;

static void func()
{
	__blockingoffload()
	{
		int local = global; // local has the value 42!
		if (gDbgRenderer.drawState)
		{
			Renderer::DrawLine(....);
			//.....
		}
	};
}

Any global variables that the Offload compiler can see can be linked against, including extern variables defined in other translation units.