Grokking 2MGFX Errors

The Problem:  2MGFX was producing the following error when I tried to build an HLSL shader I found on the net:

~/Projects/2mgfx-mg$ wine 2MGFX.exe water.fx water.mgfxo /Profile:OpenGL

water.fx(20,32) : Unexpected token ',' found. Expected Identifier

Failed to parse 'water.fx'!

Line 20 contained this:

sum = tex2D(samplerState, tex);

where samplerState was defined at the beginning of the .fx file as:

sampler samplerState;

The Fix:  After a little bit of playing around, it appears “samplerState” is a reserved word as far as 2MGFX is concerned.  Changing the variable name (I used “s0”) allows the shader to compile without issue.