[D3D12] Replicate the last texture component into non-existent ones

This commit is contained in:
Triang3l 2019-10-23 23:47:17 +03:00
parent 4623b41023
commit b622e894d6
1 changed files with 26 additions and 24 deletions

View File

@ -97,10 +97,14 @@ constexpr uint32_t TextureCache::kScaledResolveBufferSize;
constexpr uint32_t TextureCache::kScaledResolveHeapSizeLog2;
constexpr uint32_t TextureCache::kScaledResolveHeapSize;
// Assuming all single-component textures have its only component replicated.
// For DXT3A and DXT5A, this is according to:
// For formats with less than 4 components, assuming the last component is
// replicated into the non-existent ones, similar to what is done for unused
// components of operands in shaders.
// For DXT3A and DXT5A, RRRR swizzle is specified in:
// http://fileadmin.cs.lth.se/cs/Personal/Michael_Doggett/talks/unc-xenos-doggett.pdf
// Halo 3 also expects replicated components in k_8 sprites.
// DXN is read as RG in Halo 3, but as RA in Call of Duty.
// TODO(Triang3l): Find out the correct contents of unused texture components.
const TextureCache::HostFormat TextureCache::host_formats_[64] = {
// k_1_REVERSE
{DXGI_FORMAT_UNKNOWN,
@ -158,7 +162,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_B5G6R5_UNORM,
ResolveTileMode::k16bpp,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_6_5_5
// On the host, green bits in blue, blue bits in green.
{DXGI_FORMAT_B5G6R5_UNORM,
@ -170,7 +174,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_B5G6R5_UNORM,
ResolveTileMode::k16bpp,
{0, 2, 1, 3}},
{0, 2, 1, 1}},
// k_8_8_8_8
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
@ -225,7 +229,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R8G8_UNORM,
ResolveTileMode::k16bpp,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_Cr_Y1_Cb_Y0_REP
// Red and blue probably must be swapped, similar to k_Y1_Cr_Y0_Cb_REP.
{DXGI_FORMAT_G8R8_G8B8_UNORM,
@ -265,7 +269,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_8_8_8_8_A
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -299,7 +303,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16B16A16_UNORM,
ResolveTileMode::kR11G11B10AsRGBA16,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_11_11_10
{DXGI_FORMAT_R16G16B16A16_TYPELESS,
DXGI_FORMAT_R16G16B16A16_UNORM,
@ -310,7 +314,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16B16A16_UNORM,
ResolveTileMode::kR10G11B11AsRGBA16,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_DXT1
{DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM,
@ -403,7 +407,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16_UNORM,
ResolveTileMode::k32bpp,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_16_16_16_16
// The resolve format being unorm is correct (with snorm distortion effects
// in Halo 3 cause stretching of one corner of the screen).
@ -438,7 +442,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16_FLOAT,
ResolveTileMode::k32bpp,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_16_16_16_16_EXPAND
{DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_FLOAT,
@ -471,7 +475,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16_FLOAT,
ResolveTileMode::k32bpp,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_16_16_16_16_FLOAT
{DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_FLOAT,
@ -504,7 +508,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_32_32_32_32
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -537,7 +541,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R32G32_FLOAT,
ResolveTileMode::k64bpp,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_32_32_32_32_FLOAT
{DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_FLOAT,
@ -570,7 +574,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_16_MPEG
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -592,7 +596,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_8_INTERLACED
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -625,7 +629,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_16_INTERLACED
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -658,10 +662,8 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_DXN
// Appears to be luminance-alpha, like ATI 3Dc and LATC in OpenGL. Call of
// Duty 4 reads this with XW swizzle in the shader.
{DXGI_FORMAT_BC5_UNORM,
DXGI_FORMAT_BC5_UNORM,
LoadMode::k128bpb,
@ -671,7 +673,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kDXNToRG8,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 0, 0, 1}},
{0, 1, 1, 1}},
// k_8_8_8_8_AS_16_16_16_16
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
@ -737,7 +739,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16B16A16_UNORM,
ResolveTileMode::kR11G11B10AsRGBA16,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_11_11_10_AS_16_16_16_16
{DXGI_FORMAT_R16G16B16A16_TYPELESS,
DXGI_FORMAT_R16G16B16A16_UNORM,
@ -748,7 +750,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_R16G16B16A16_UNORM,
ResolveTileMode::kR10G11B11AsRGBA16,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_32_32_32_FLOAT
{DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
@ -759,7 +761,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 2, 2}},
// k_DXT3A
// R8_UNORM has the same size as BC2, but doesn't have the 4x4 size
// alignment requirement.
@ -794,7 +796,7 @@ const TextureCache::HostFormat TextureCache::host_formats_[64] = {
LoadMode::kUnknown,
DXGI_FORMAT_UNKNOWN,
ResolveTileMode::kUnknown,
{0, 1, 2, 3}},
{0, 1, 1, 1}},
// k_DXT3A_AS_1_1_1_1
{DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,