static void WriteIA4Encoder(char*& p,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_IA4, ApiType);
	WRITE(p, "  float4 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, "rgba", "texSample", 0, ApiType);
	WRITE(p, "  color0.b = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.b");

	WriteSampleColor(p, "rgba", "texSample", 1, ApiType);
	WRITE(p, "  color0.g = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.g");

	WriteSampleColor(p, "rgba", "texSample", 2, ApiType);
	WRITE(p, "  color0.r = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.r");

	WriteSampleColor(p, "rgba", "texSample", 3, ApiType);
	WRITE(p, "  color0.a = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.a");

	WRITE(p, "  color1.rgba += IntensityConst.aaaa;\n");

	WriteToBitDepth(p, 4, "color0", "color0");
	WriteToBitDepth(p, 4, "color1", "color1");

	WRITE(p, "  ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
	WriteEncoderEnd(p, ApiType);
}
void WriteIA4Encoder(char* p)
{
	WriteSwizzler(p, GX_TF_IA4);
	WRITE(p, "  float4 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, "rgba", "texSample", 0);
	WRITE(p, "  color0.b = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.b");

	WriteSampleColor(p, "rgba", "texSample", 1);
	WRITE(p, "  color0.g = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.g");

	WriteSampleColor(p, "rgba", "texSample", 2);
	WRITE(p, "  color0.r = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.r");

	WriteSampleColor(p, "rgba", "texSample", 3);
	WRITE(p, "  color0.a = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "color1.a");

	WRITE(p, "  color1.rgba += IntensityConst.aaaa;\n");

	WriteToBitDepth(p, 4, "color0", "color0");
	WriteToBitDepth(p, 4, "color1", "color1");

	WRITE(p, "  ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
	WriteEncoderEnd(p);
}
static void WriteIA4Encoder(char*& p, APIType ApiType, const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::RA4, ApiType);
  WRITE(p, "  float4 texSample;\n");
  WRITE(p, "  float4 color0;\n");
  WRITE(p, "  float4 color1;\n");

  WriteSampleColor(p, "rgba", "texSample", 0, ApiType, params);
  WRITE(p, "  color0.b = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "color1.b");

  WriteSampleColor(p, "rgba", "texSample", 1, ApiType, params);
  WRITE(p, "  color0.g = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "color1.g");

  WriteSampleColor(p, "rgba", "texSample", 2, ApiType, params);
  WRITE(p, "  color0.r = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "color1.r");

  WriteSampleColor(p, "rgba", "texSample", 3, ApiType, params);
  WRITE(p, "  color0.a = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "color1.a");

  WRITE(p, "  color1.rgba += IntensityConst.aaaa;\n");

  WriteToBitDepth(p, 4, "color0", "color0");
  WriteToBitDepth(p, 4, "color1", "color1");

  WRITE(p, "  ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
  WriteEncoderEnd(p);
}
static void WriteIA8Encoder(char*& p,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_IA8, ApiType);
	WRITE(p, "  float4 texSample;\n");

	WriteSampleColor(p, "rgba", "texSample", 0, ApiType);
	WRITE(p, "  ocol0.b = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "ocol0.g");

	WriteSampleColor(p, "rgba", "texSample", 1, ApiType);
	WRITE(p, "  ocol0.r = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "ocol0.a");

	WRITE(p, "  ocol0.ga += IntensityConst.aa;\n");

	WriteEncoderEnd(p, ApiType);
}
void WriteIA8Encoder(char* p)
{
	WriteSwizzler(p, GX_TF_IA8);
	WRITE(p, "  float4 texSample;\n");	

	WriteSampleColor(p, "rgba", "texSample", 0);
	WRITE(p, "  ocol0.b = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "ocol0.g");

	WriteSampleColor(p, "rgba", "texSample", 1);
	WRITE(p, "  ocol0.r = texSample.a;\n");
	WriteColorToIntensity(p, "texSample", "ocol0.a");

	WRITE(p, "  ocol0.ga += IntensityConst.aa;\n");

	WriteEncoderEnd(p);
}
static void WriteIA8Encoder(char*& p, APIType ApiType, const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::RA8, ApiType);
  WRITE(p, "  float4 texSample;\n");

  WriteSampleColor(p, "rgba", "texSample", 0, ApiType, params);
  WRITE(p, "  ocol0.b = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "ocol0.g");

  WriteSampleColor(p, "rgba", "texSample", 1, ApiType, params);
  WRITE(p, "  ocol0.r = texSample.a;\n");
  WriteColorToIntensity(p, "texSample", "ocol0.a");

  WRITE(p, "  ocol0.ga += IntensityConst.aa;\n");

  WriteEncoderEnd(p);
}
static void WriteI8Encoder(char*& p, API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_I8, ApiType);
	WRITE(p, "  float3 texSample;\n");

	WriteSampleColor(p, "rgb", "texSample", 0, ApiType);
	WriteColorToIntensity(p, "texSample", "ocol0.b");

	WriteSampleColor(p, "rgb", "texSample", 1, ApiType);
	WriteColorToIntensity(p, "texSample", "ocol0.g");

	WriteSampleColor(p, "rgb", "texSample", 2, ApiType);
	WriteColorToIntensity(p, "texSample", "ocol0.r");

	WriteSampleColor(p, "rgb", "texSample", 3, ApiType);
	WriteColorToIntensity(p, "texSample", "ocol0.a");

	WRITE(p, "  ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity

	WriteEncoderEnd(p, ApiType);
}
void WriteI8Encoder(char* p)
{
	WriteSwizzler(p, GX_TF_I8);
	WRITE(p, "  float3 texSample;\n");	

	WriteSampleColor(p, "rgb", "texSample", 0);
	WriteColorToIntensity(p, "texSample", "ocol0.b");	

	WriteSampleColor(p, "rgb", "texSample", 1);
	WriteColorToIntensity(p, "texSample", "ocol0.g");

	WriteSampleColor(p, "rgb", "texSample", 2);
	WriteColorToIntensity(p, "texSample", "ocol0.r");

	WriteSampleColor(p, "rgb", "texSample", 3);
	WriteColorToIntensity(p, "texSample", "ocol0.a");

	WRITE(p, "  ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity

	WriteEncoderEnd(p);
}
static void WriteI8Encoder(char*& p, APIType ApiType, const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::R8, ApiType);
  WRITE(p, "  float3 texSample;\n");

  WriteSampleColor(p, "rgb", "texSample", 0, ApiType, params);
  WriteColorToIntensity(p, "texSample", "ocol0.b");

  WriteSampleColor(p, "rgb", "texSample", 1, ApiType, params);
  WriteColorToIntensity(p, "texSample", "ocol0.g");

  WriteSampleColor(p, "rgb", "texSample", 2, ApiType, params);
  WriteColorToIntensity(p, "texSample", "ocol0.r");

  WriteSampleColor(p, "rgb", "texSample", 3, ApiType, params);
  WriteColorToIntensity(p, "texSample", "ocol0.a");

  WRITE(p, "  ocol0.rgba += IntensityConst.aaaa;\n");  // see WriteColorToIntensity

  WriteEncoderEnd(p);
}
void WriteI4Encoder(char* p, API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_I4,ApiType);
	WRITE(p, "  float3 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color0.b");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color1.b");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color0.g");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color1.g");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color0.r");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color1.r");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color0.a");
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgb", "texSample",ApiType);
	WriteColorToIntensity(p, "texSample", "color1.a");

	WRITE(p, "  color0.rgba += IntensityConst.aaaa;\n");
	WRITE(p, "  color1.rgba += IntensityConst.aaaa;\n");

	WriteToBitDepth(p, 4, "color0", "color0");
	WriteToBitDepth(p, 4, "color1", "color1");

	WRITE(p, "  ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
	WriteEncoderEnd(p);
}