Updated applyStateBlock to use a function lookup table, instead of a monolithic switch statement. Also reimplemented state caching. On my gtx660 state caching cuts rendering time by more than half.