Пример #1
0
static void WriteCC4Encoder(char*& p, const char* comp, APIType ApiType,
                            const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::RA4, ApiType);
  WRITE(p, "  float2 texSample;\n");
  WRITE(p, "  float4 color0;\n");
  WRITE(p, "  float4 color1;\n");

  WriteSampleColor(p, comp, "texSample", 0, ApiType, params);
  WRITE(p, "  color0.b = texSample.x;\n");
  WRITE(p, "  color1.b = texSample.y;\n");

  WriteSampleColor(p, comp, "texSample", 1, ApiType, params);
  WRITE(p, "  color0.g = texSample.x;\n");
  WRITE(p, "  color1.g = texSample.y;\n");

  WriteSampleColor(p, comp, "texSample", 2, ApiType, params);
  WRITE(p, "  color0.r = texSample.x;\n");
  WRITE(p, "  color1.r = texSample.y;\n");

  WriteSampleColor(p, comp, "texSample", 3, ApiType, params);
  WRITE(p, "  color0.a = texSample.x;\n");
  WRITE(p, "  color1.a = texSample.y;\n");

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

  WRITE(p, "  ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
  WriteEncoderEnd(p);
}
void WriteRGBA4443Encoder(char* p,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_RGB5A3,ApiType);

	WRITE(p, "  float4 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, "rgba", "texSample",ApiType);
	WriteToBitDepth(p, 3, "texSample.a", "color0.b");
	WriteToBitDepth(p, 4, "texSample.r", "color1.b");
	WriteToBitDepth(p, 4, "texSample.g", "color0.g");
	WriteToBitDepth(p, 4, "texSample.b", "color1.g");

	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, "rgba", "texSample",ApiType);
	WriteToBitDepth(p, 3, "texSample.a", "color0.r");
	WriteToBitDepth(p, 4, "texSample.r", "color1.r");
	WriteToBitDepth(p, 4, "texSample.g", "color0.a");
	WriteToBitDepth(p, 4, "texSample.b", "color1.a");

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

	WRITE(p, "  float depth;\n");
	WRITE(p, "  float3 expanded;\n");

	// byte order is reversed

	WriteSampleColor(p, "b", "depth", 0, ApiType);

	WRITE(p, "  depth *= 16777215.0;\n");
	WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
	WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
	WRITE(p, "  expanded.g = floor(depth / 256.0);\n");
	WRITE(p, "  depth -= expanded.g * 256.0;\n");
	WRITE(p, "  expanded.b = depth;\n");

	WRITE(p, "  ocol0.b = expanded.b / 255.0;\n");
	WRITE(p, "  ocol0.g = expanded.g / 255.0;\n");

	WriteSampleColor(p, "b", "depth", 1, ApiType);

	WRITE(p, "  depth *= 16777215.0;\n");
	WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
	WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
	WRITE(p, "  expanded.g = floor(depth / 256.0);\n");
	WRITE(p, "  depth -= expanded.g * 256.0;\n");
	WRITE(p, "  expanded.b = depth;\n");

	WRITE(p, "  ocol0.r = expanded.b / 255.0;\n");
	WRITE(p, "  ocol0.a = expanded.g / 255.0;\n");

	WriteEncoderEnd(p, ApiType);
}
Пример #4
0
static void WriteZ16LEncoder(char*& p, APIType ApiType, const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::GB8, ApiType);

  WRITE(p, "  float depth;\n");
  WRITE(p, "  float3 expanded;\n");

  // byte order is reversed

  WriteSampleColor(p, "r", "depth", 0, ApiType, params);

  WRITE(p, "  depth *= 16777216.0;\n");
  WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
  WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
  WRITE(p, "  expanded.g = floor(depth / 256.0);\n");
  WRITE(p, "  depth -= expanded.g * 256.0;\n");
  WRITE(p, "  expanded.b = depth;\n");

  WRITE(p, "  ocol0.b = expanded.b / 255.0;\n");
  WRITE(p, "  ocol0.g = expanded.g / 255.0;\n");

  WriteSampleColor(p, "r", "depth", 1, ApiType, params);

  WRITE(p, "  depth *= 16777216.0;\n");
  WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
  WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
  WRITE(p, "  expanded.g = floor(depth / 256.0);\n");
  WRITE(p, "  depth -= expanded.g * 256.0;\n");
  WRITE(p, "  expanded.b = depth;\n");

  WRITE(p, "  ocol0.r = expanded.b / 255.0;\n");
  WRITE(p, "  ocol0.a = expanded.g / 255.0;\n");

  WriteEncoderEnd(p);
}
void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_RGBA8, ApiType);

	WRITE(p, "  bool first = xb == (halfxb * 2);\n");

	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");
	WRITE(p, "  color0.g = texSample.r;\n");
	WRITE(p, "  color1.b = texSample.g;\n");
	WRITE(p, "  color1.g = texSample.b;\n");

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

	WRITE(p, "  ocol0 = first ? color0 : color1;\n");

	WriteEncoderEnd(p, ApiType);
}
Пример #6
0
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 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);
}
Пример #8
0
static void WriteZ16Encoder(char*& p,API_TYPE ApiType)
{
    WriteSwizzler(p, GX_TF_Z16, ApiType);

    WRITE(p, "  float depth;\n");
    WRITE(p, "  float3 expanded;\n");

    // byte order is reversed

    WriteSampleColor(p, "r", "depth", 0, ApiType);
    if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");

    WRITE(p, "  depth *= 16777216.0;\n");
    WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
    WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
    WRITE(p, "  expanded.g = floor(depth / 256.0);\n");

    WRITE(p, "  ocol0.b = expanded.g / 255.0;\n");
    WRITE(p, "  ocol0.g = expanded.r / 255.0;\n");

    WriteSampleColor(p, "r", "depth", 1, ApiType);
    if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");

    WRITE(p, "  depth *= 16777216.0;\n");
    WRITE(p, "  expanded.r = floor(depth / (256.0 * 256.0));\n");
    WRITE(p, "  depth -= expanded.r * 256.0 * 256.0;\n");
    WRITE(p, "  expanded.g = floor(depth / 256.0);\n");

    WRITE(p, "  ocol0.r = expanded.g / 255.0;\n");
    WRITE(p, "  ocol0.a = expanded.r / 255.0;\n");

    WriteEncoderEnd(p);
}
static void WriteCC4Encoder(char*& p, const char* comp,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_RA4, ApiType);
	WRITE(p, "  float2 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, comp, "texSample", 0, ApiType);
	WRITE(p, "  color0.b = texSample.x;\n");
	WRITE(p, "  color1.b = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 1, ApiType);
	WRITE(p, "  color0.g = texSample.x;\n");
	WRITE(p, "  color1.g = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 2, ApiType);
	WRITE(p, "  color0.r = texSample.x;\n");
	WRITE(p, "  color1.r = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 3, ApiType);
	WRITE(p, "  color0.a = texSample.x;\n");
	WRITE(p, "  color1.a = texSample.y;\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 WriteZ16LEncoder(char* p)
{
	WriteSwizzler(p, GX_CTF_Z16L);

	WRITE(p, "  float depth;\n");
	WRITE(p, "  float3 expanded;\n");

	// byte order is reversed

	WriteSampleColor(p, "b", "depth", 0);
	WRITE(p, " depth = 1.0f - depth;\n");
	WRITE(p, "  depth *= 16777215.0f;\n");
	WRITE(p, "  expanded.r = floor(depth / (256.0f * 256.0f));\n");
	WRITE(p, "  depth -= expanded.r * 256.0f * 256.0f;\n");
	WRITE(p, "  expanded.g = floor(depth / 256.0f);\n");
	WRITE(p, "  depth -= expanded.g * 256.0f;\n");
	WRITE(p, "  expanded.b = depth;\n");

	WRITE(p, "  ocol0.b = expanded.b / 255.0f;\n");
	WRITE(p, "  ocol0.g = expanded.g / 255.0f;\n");
	
	WriteSampleColor(p, "b", "depth", 1);
	WRITE(p, " depth = 1.0f - depth;\n");
	WRITE(p, "  depth *= 16777215.0f;\n");
	WRITE(p, "  expanded.r = floor(depth / (256.0f * 256.0f));\n");
	WRITE(p, "  depth -= expanded.r * 256.0f * 256.0f;\n");
	WRITE(p, "  expanded.g = floor(depth / 256.0f);\n");
	WRITE(p, "  depth -= expanded.g * 256.0f;\n");
	WRITE(p, "  expanded.b = depth;\n");

	WRITE(p, "  ocol0.r = expanded.b / 255.0f;\n");
	WRITE(p, "  ocol0.a = expanded.g / 255.0f;\n");

	WriteEncoderEnd(p);
}
void WriteCC4Encoder(char* p, const char* comp)
{
	WriteSwizzler(p, GX_CTF_RA4);
	WRITE(p, "  float2 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, comp, "texSample", 0);
	WRITE(p, "  color0.b = texSample.x;\n");
	WRITE(p, "  color1.b = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 1);
	WRITE(p, "  color0.g = texSample.x;\n");
	WRITE(p, "  color1.g = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 2);
	WRITE(p, "  color0.r = texSample.x;\n");
	WRITE(p, "  color1.r = texSample.y;\n");

	WriteSampleColor(p, comp, "texSample", 3);
	WRITE(p, "  color0.a = texSample.x;\n");
	WRITE(p, "  color1.a = texSample.y;\n");

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

	WRITE(p, "  ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
	WriteEncoderEnd(p);
}
void WriteRGBA8Encoder(char* p)
{
	Write32BitSwizzler(p, GX_TF_RGBA8);

	WRITE(p, "  float cl1 = xb - (halfxb * 2.0f);\n");
	WRITE(p, "  float cl0 = 1.0f - cl1;\n");

	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");
	WRITE(p, "  color0.g = texSample.r;\n");
	WRITE(p, "  color1.b = texSample.g;\n");
	WRITE(p, "  color1.g = texSample.b;\n");

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

	WRITE(p, "  ocol0 = (cl0 * color0) + (cl1 * color1);\n");

	WriteEncoderEnd(p);
}
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);
}
void WriteZ16Encoder(char* p,API_TYPE ApiType)
{
    WriteSwizzler(p, GX_TF_Z16,ApiType);

    WRITE(p, "  float depth;\n");
    WRITE(p, "  float3 expanded;\n");

    // byte order is reversed

    WriteSampleColor(p, "b", "depth",ApiType);

    WRITE(p, "  depth *= 16777215.0f;\n");
    WRITE(p, "  expanded.r = floor(depth / (256 * 256));\n");
    WRITE(p, "  depth -= expanded.r * 256 * 256;\n");
    WRITE(p, "  expanded.g = floor(depth / 256);\n");

    WRITE(p, "  ocol0.b = expanded.g / 255;\n");
    WRITE(p, "  ocol0.g = expanded.r / 255;\n");

    WriteIncrementSampleX(p,ApiType);

    WriteSampleColor(p, "b", "depth",ApiType);

    WRITE(p, "  depth *= 16777215.0f;\n");
    WRITE(p, "  expanded.r = floor(depth / (256 * 256));\n");
    WRITE(p, "  depth -= expanded.r * 256 * 256;\n");
    WRITE(p, "  expanded.g = floor(depth / 256);\n");

    WRITE(p, "  ocol0.r = expanded.g / 255;\n");
    WRITE(p, "  ocol0.a = expanded.r / 255;\n");    

    WriteEncoderEnd(p);
}
void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
{
	Write32BitSwizzler(p, GX_TF_RGBA8,ApiType);

	WRITE(p, "  float cl1 = xb - (halfxb * 2);\n");
	WRITE(p, "  float cl0 = 1.0f - cl1;\n");

	WRITE(p, "  float4 texSample;\n");
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

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

	WriteIncrementSampleX(p,ApiType);

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

	WRITE(p, "  ocol0 = (cl0 * color0) + (cl1 * color1);\n");

	WriteEncoderEnd(p);
}
void WriteCC8Encoder(char* p, const char* comp)
{
	WriteSwizzler(p, GX_CTF_RA8);

	WriteSampleColor(p, comp, "ocol0.bg", 0);
	WriteSampleColor(p, comp, "ocol0.ra", 1);

	WriteEncoderEnd(p);
}
static void WriteCC8Encoder(char*& p, const char* comp, API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_RA8, ApiType);

	WriteSampleColor(p, comp, "ocol0.bg", 0, ApiType);
	WriteSampleColor(p, comp, "ocol0.ra", 1, ApiType);

	WriteEncoderEnd(p, ApiType);
}
Пример #18
0
static void WriteCC8Encoder(char*& p, const char* comp, APIType ApiType,
                            const EFBCopyParams& params)
{
  WriteSwizzler(p, EFBCopyFormat::RA8, ApiType);

  WriteSampleColor(p, comp, "ocol0.bg", 0, ApiType, params);
  WriteSampleColor(p, comp, "ocol0.ra", 1, ApiType, params);

  WriteEncoderEnd(p);
}
void WriteC8Encoder(char* p, const char* comp,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_R8, ApiType);

	WriteSampleColor(p, comp, "ocol0.b", 0, ApiType);
	WriteSampleColor(p, comp, "ocol0.g", 1, ApiType);
	WriteSampleColor(p, comp, "ocol0.r", 2, ApiType);
	WriteSampleColor(p, comp, "ocol0.a", 3, ApiType);

	WriteEncoderEnd(p, ApiType);
}
void WriteC8Encoder(char* p, const char* comp)
{
	WriteSwizzler(p, GX_CTF_R8);

	WriteSampleColor(p, comp, "ocol0.b", 0);
	WriteSampleColor(p, comp, "ocol0.g", 1);
	WriteSampleColor(p, comp, "ocol0.r", 2);
	WriteSampleColor(p, comp, "ocol0.a", 3);

	WriteEncoderEnd(p);
}
Пример #21
0
static void WriteC8Encoder(char*& p, const char* comp, APIType ApiType, bool depth = false)
{
  WriteSwizzler(p, GX_CTF_R8, ApiType);

  WriteSampleColor(p, comp, "ocol0.b", 0, ApiType, depth);
  WriteSampleColor(p, comp, "ocol0.g", 1, ApiType, depth);
  WriteSampleColor(p, comp, "ocol0.r", 2, ApiType, depth);
  WriteSampleColor(p, comp, "ocol0.a", 3, ApiType, depth);

  WriteEncoderEnd(p);
}
void WriteCC8Encoder(char* p, const char* comp, API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_RA8,ApiType);

	WriteSampleColor(p, comp, "ocol0.bg",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "ocol0.ra",ApiType);

	WriteEncoderEnd(p);
}
void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_R4,ApiType);
	WRITE(p, "  float4 color0;\n");
	WRITE(p, "  float4 color1;\n");

	WriteSampleColor(p, comp, "color0.b",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color1.b",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color0.g",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color1.g",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color0.r",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color1.r",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color0.a",ApiType);
	WriteIncrementSampleX(p,ApiType);

	WriteSampleColor(p, comp, "color1.a",ApiType);

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

	WRITE(p, "  ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
	WriteEncoderEnd(p);
}
Пример #24
0
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);
}
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,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 WriteZ24Encoder(char* p)
{
	Write32BitSwizzler(p, GX_TF_Z24X8);

	WRITE(p, "  float cl = xb - (halfxb * 2.0f);\n");

	WRITE(p, "  float depth0;\n");
	WRITE(p, "  float depth1;\n");
	WRITE(p, "  float3 expanded0;\n");
	WRITE(p, "  float3 expanded1;\n");

	WriteSampleColor(p, "b", "depth0", 0);
	WRITE(p, " depth0 = 1.0f - depth0;\n");
	WriteSampleColor(p, "b", "depth1", 1);
	WRITE(p, " depth1 = 1.0f - depth1;\n");

	for (int i = 0; i < 2; i++)
	{
		WRITE(p, "  depth%i *= 16777215.0f;\n", i);

		WRITE(p, "  expanded%i.r = floor(depth%i / (256.0f * 256.0f));\n", i, i);
		WRITE(p, "  depth%i -= expanded%i.r * 256.0f * 256.0f;\n", i, i);
		WRITE(p, "  expanded%i.g = floor(depth%i / 256.0f);\n", i, i);
		WRITE(p, "  depth%i -= expanded%i.g * 256.0f;\n", i, i);
		WRITE(p, "  expanded%i.b = depth%i;\n", i, i);
	}

	WRITE(p, "  if(cl > 0.5f) {\n");
	// upper 16
	WRITE(p, "     ocol0.b = expanded0.g / 255.0f;\n");
	WRITE(p, "     ocol0.g = expanded0.b / 255.0f;\n");
	WRITE(p, "     ocol0.r = expanded1.g / 255.0f;\n");
	WRITE(p, "     ocol0.a = expanded1.b / 255.0f;\n");
	WRITE(p, "  } else {\n");
	// lower 8
	WRITE(p, "     ocol0.b = 1.0f;\n");
	WRITE(p, "     ocol0.g = expanded0.r / 255.0f;\n");
	WRITE(p, "     ocol0.r = 1.0f;\n");
	WRITE(p, "     ocol0.a = expanded1.r / 255.0f;\n");
	WRITE(p, "  }\n");

	WriteEncoderEnd(p);
}
void WriteZ24Encoder(char* p, API_TYPE ApiType)
{
	Write32BitSwizzler(p, GX_TF_Z24X8,ApiType);

	WRITE(p, "  float cl = xb - (halfxb * 2);\n");

	WRITE(p, "  float depth0;\n");
    WRITE(p, "  float depth1;\n");
    WRITE(p, "  float3 expanded0;\n");
    WRITE(p, "  float3 expanded1;\n");

	WriteSampleColor(p, "b", "depth0",ApiType);
    WriteIncrementSampleX(p,ApiType);
    WriteSampleColor(p, "b", "depth1",ApiType);

    for (int i = 0; i < 2; i++)
    {
        WRITE(p, "  depth%i *= 16777215.0f;\n", i);

        WRITE(p, "  expanded%i.r = floor(depth%i / (256 * 256));\n", i, i);
        WRITE(p, "  depth%i -= expanded%i.r * 256 * 256;\n", i, i);
        WRITE(p, "  expanded%i.g = floor(depth%i / 256);\n", i, i);
        WRITE(p, "  depth%i -= expanded%i.g * 256;\n", i, i);
        WRITE(p, "  expanded%i.b = depth%i;\n", i, i);
    }

    WRITE(p, "  if(cl > 0.5f) {\n");
    // upper 16
    WRITE(p, "     ocol0.b = expanded0.g / 255;\n");
    WRITE(p, "     ocol0.g = expanded0.b / 255;\n");
    WRITE(p, "     ocol0.r = expanded1.g / 255;\n");
    WRITE(p, "     ocol0.a = expanded1.b / 255;\n");
    WRITE(p, "  } else {\n");
    // lower 8
    WRITE(p, "     ocol0.b = 1.0f;\n");
    WRITE(p, "     ocol0.g = expanded0.r / 255;\n");
    WRITE(p, "     ocol0.r = 1.0f;\n");
    WRITE(p, "     ocol0.a = expanded1.r / 255;\n");
    WRITE(p, "  }\n");

    WriteEncoderEnd(p);
}
static void WriteZ8Encoder(char*& p, const char* multiplier,API_TYPE ApiType)
{
	WriteSwizzler(p, GX_CTF_Z8M, ApiType);

	WRITE(p, " float depth;\n");

	WriteSampleColor(p, "b", "depth", 0, ApiType);
	WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier);

	WriteSampleColor(p, "b", "depth", 1, ApiType);
	WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier);

	WriteSampleColor(p, "b", "depth", 2, ApiType);
	WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier);

	WriteSampleColor(p, "b", "depth", 3, ApiType);
	WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);

	WriteEncoderEnd(p, ApiType);
}
void WriteZ24Encoder(char* p, API_TYPE ApiType)
{
	WriteSwizzler(p, GX_TF_Z24X8, ApiType);

	WRITE(p, "  bool first = xb == (halfxb * 2);\n");

	WRITE(p, "  float depth0;\n");
	WRITE(p, "  float depth1;\n");
	WRITE(p, "  float3 expanded0;\n");
	WRITE(p, "  float3 expanded1;\n");

	WriteSampleColor(p, "b", "depth0", 0, ApiType);
	WriteSampleColor(p, "b", "depth1", 1, ApiType);

	for (int i = 0; i < 2; i++)
	{
		WRITE(p, "  depth%i *= 16777215.0;\n", i);

		WRITE(p, "  expanded%i.r = floor(depth%i / (256.0 * 256.0));\n", i, i);
		WRITE(p, "  depth%i -= expanded%i.r * 256.0 * 256.0;\n", i, i);
		WRITE(p, "  expanded%i.g = floor(depth%i / 256.0);\n", i, i);
		WRITE(p, "  depth%i -= expanded%i.g * 256.0;\n", i, i);
		WRITE(p, "  expanded%i.b = depth%i;\n", i, i);
	}

	WRITE(p, "  if(!first) {\n");
	// upper 16
	WRITE(p, "     ocol0.b = expanded0.g / 255.0;\n");
	WRITE(p, "     ocol0.g = expanded0.b / 255.0;\n");
	WRITE(p, "     ocol0.r = expanded1.g / 255.0;\n");
	WRITE(p, "     ocol0.a = expanded1.b / 255.0;\n");
	WRITE(p, "  } else {\n");
	// lower 8
	WRITE(p, "     ocol0.b = 1.0;\n");
	WRITE(p, "     ocol0.g = expanded0.r / 255.0;\n");
	WRITE(p, "     ocol0.r = 1.0;\n");
	WRITE(p, "     ocol0.a = expanded1.r / 255.0;\n");
	WRITE(p, "  }\n");

	WriteEncoderEnd(p, ApiType);
}