Commit b80a5e9c by Jamie Madill Committed by Commit Bot

Store channel bits info in angle::Format.

This allows us to delete some duplicated code in the D3D11-side. BUG=angleproject:1389 BUG=angleproject:1459 Change-Id: Ifdcfcd4a56e06ff2ae8f5ca0bda72281d52c2964 Reviewed-on: https://chromium-review.googlesource.com/392208 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 91db32c5
......@@ -47,13 +47,25 @@ Format::Format(ID id,
GLenum glFormat,
GLenum fboFormat,
MipGenerationFunction mipGen,
ColorReadFunction colorRead)
ColorReadFunction colorRead,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits)
: id(id),
glInternalFormat(glFormat),
fboImplementationInternalFormat(fboFormat),
mipGenerationFunction(mipGen),
colorReadFunction(colorRead),
fastCopyFunctions(GetFastCopyFunctionsMap(id))
fastCopyFunctions(GetFastCopyFunctionsMap(id)),
redBits(redBits),
greenBits(greenBits),
blueBits(blueBits),
alphaBits(alphaBits),
depthBits(depthBits),
stencilBits(stencilBits)
{
}
......
......@@ -26,7 +26,13 @@ struct Format final : angle::NonCopyable
GLenum glFormat,
GLenum fboFormat,
rx::MipGenerationFunction mipGen,
rx::ColorReadFunction colorRead);
rx::ColorReadFunction colorRead,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits);
static const Format &Get(ID id);
......@@ -46,6 +52,13 @@ struct Format final : angle::NonCopyable
// A map from a gl::FormatType to a fast pixel copy function for this format.
rx::FastCopyFunctionMap fastCopyFunctions;
GLuint redBits;
GLuint greenBits;
GLuint blueBits;
GLuint alphaBits;
GLuint depthBits;
GLuint stencilBits;
};
} // namespace angle
......
......@@ -29,7 +29,8 @@ const Format &Format::Get(ID id)
GL_ALPHA16F_EXT,
GL_ALPHA16F_EXT,
GenerateMip<A16F>,
ReadColor<A16F, GLfloat>);
ReadColor<A16F, GLfloat>,
0, 0, 0, 16, 0, 0);
return info;
}
case ID::A32_FLOAT:
......@@ -38,7 +39,8 @@ const Format &Format::Get(ID id)
GL_ALPHA32F_EXT,
GL_ALPHA32F_EXT,
GenerateMip<A32F>,
ReadColor<A32F, GLfloat>);
ReadColor<A32F, GLfloat>,
0, 0, 0, 32, 0, 0);
return info;
}
case ID::A8_UNORM:
......@@ -47,7 +49,8 @@ const Format &Format::Get(ID id)
GL_ALPHA8_EXT,
GL_ALPHA8_EXT,
GenerateMip<A8>,
ReadColor<A8, GLfloat>);
ReadColor<A8, GLfloat>,
0, 0, 0, 8, 0, 0);
return info;
}
case ID::ASTC_10x10_SRGB_BLOCK:
......@@ -56,7 +59,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x10_UNORM_BLOCK:
......@@ -65,7 +69,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x5_SRGB_BLOCK:
......@@ -74,7 +79,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x5_UNORM_BLOCK:
......@@ -83,7 +89,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x6_SRGB_BLOCK:
......@@ -92,7 +99,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x6_UNORM_BLOCK:
......@@ -101,7 +109,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x8_SRGB_BLOCK:
......@@ -110,7 +119,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_10x8_UNORM_BLOCK:
......@@ -119,7 +129,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_12x10_SRGB_BLOCK:
......@@ -128,7 +139,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_12x10_UNORM_BLOCK:
......@@ -137,7 +149,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_12x12_SRGB_BLOCK:
......@@ -146,7 +159,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_12x12_UNORM_BLOCK:
......@@ -155,7 +169,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_4x4_SRGB_BLOCK:
......@@ -164,7 +179,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_4x4_UNORM_BLOCK:
......@@ -173,7 +189,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_5x4_SRGB_BLOCK:
......@@ -182,7 +199,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_5x4_UNORM_BLOCK:
......@@ -191,7 +209,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_5x5_SRGB_BLOCK:
......@@ -200,7 +219,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_5x5_UNORM_BLOCK:
......@@ -209,7 +229,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_6x5_SRGB_BLOCK:
......@@ -218,7 +239,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_6x5_UNORM_BLOCK:
......@@ -227,7 +249,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_6x6_SRGB_BLOCK:
......@@ -236,7 +259,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_6x6_UNORM_BLOCK:
......@@ -245,7 +269,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x5_SRGB_BLOCK:
......@@ -254,7 +279,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x5_UNORM_BLOCK:
......@@ -263,7 +289,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x6_SRGB_BLOCK:
......@@ -272,7 +299,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x6_UNORM_BLOCK:
......@@ -281,7 +309,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x8_SRGB_BLOCK:
......@@ -290,7 +319,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::ASTC_8x8_UNORM_BLOCK:
......@@ -299,7 +329,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::B4G4R4A4_UNORM:
......@@ -308,7 +339,8 @@ const Format &Format::Get(ID id)
GL_BGRA4_ANGLEX,
GL_RGBA4,
GenerateMip<A4R4G4B4>,
ReadColor<A4R4G4B4, GLfloat>);
ReadColor<A4R4G4B4, GLfloat>,
4, 4, 4, 4, 0, 0);
return info;
}
case ID::B5G5R5A1_UNORM:
......@@ -317,7 +349,8 @@ const Format &Format::Get(ID id)
GL_BGR5_A1_ANGLEX,
GL_RGB5_A1,
GenerateMip<A1R5G5B5>,
ReadColor<A1R5G5B5, GLfloat>);
ReadColor<A1R5G5B5, GLfloat>,
5, 5, 5, 1, 0, 0);
return info;
}
case ID::B5G6R5_UNORM:
......@@ -326,7 +359,8 @@ const Format &Format::Get(ID id)
GL_BGR565_ANGLEX,
GL_RGB565,
GenerateMip<B5G6R5>,
ReadColor<B5G6R5, GLfloat>);
ReadColor<B5G6R5, GLfloat>,
5, 6, 5, 0, 0, 0);
return info;
}
case ID::B8G8R8A8_UNORM:
......@@ -335,7 +369,8 @@ const Format &Format::Get(ID id)
GL_BGRA8_EXT,
GL_BGRA8_EXT,
GenerateMip<B8G8R8A8>,
ReadColor<B8G8R8A8, GLfloat>);
ReadColor<B8G8R8A8, GLfloat>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::B8G8R8X8_UNORM:
......@@ -344,7 +379,8 @@ const Format &Format::Get(ID id)
GL_BGRA8_EXT,
GL_BGRA8_EXT,
GenerateMip<B8G8R8X8>,
ReadColor<B8G8R8X8, GLfloat>);
ReadColor<B8G8R8X8, GLfloat>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::BC1_RGBA_UNORM_BLOCK:
......@@ -353,7 +389,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::BC1_RGB_UNORM_BLOCK:
......@@ -362,7 +399,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::BC2_RGBA_UNORM_BLOCK:
......@@ -371,7 +409,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,
GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::BC3_RGBA_UNORM_BLOCK:
......@@ -380,7 +419,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::D16_UNORM:
......@@ -389,7 +429,8 @@ const Format &Format::Get(ID id)
GL_DEPTH_COMPONENT16,
GL_DEPTH_COMPONENT16,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 16, 0);
return info;
}
case ID::D24_UNORM:
......@@ -398,7 +439,8 @@ const Format &Format::Get(ID id)
GL_DEPTH_COMPONENT24,
GL_DEPTH_COMPONENT24,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 24, 0);
return info;
}
case ID::D24_UNORM_S8_UINT:
......@@ -407,7 +449,8 @@ const Format &Format::Get(ID id)
GL_DEPTH24_STENCIL8,
GL_DEPTH24_STENCIL8,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 24, 8);
return info;
}
case ID::D32_FLOAT:
......@@ -416,7 +459,8 @@ const Format &Format::Get(ID id)
GL_DEPTH_COMPONENT32F,
GL_DEPTH_COMPONENT32F,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 32, 0);
return info;
}
case ID::D32_FLOAT_S8X24_UINT:
......@@ -425,7 +469,8 @@ const Format &Format::Get(ID id)
GL_DEPTH32F_STENCIL8,
GL_DEPTH32F_STENCIL8,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 32, 8);
return info;
}
case ID::D32_UNORM:
......@@ -434,7 +479,8 @@ const Format &Format::Get(ID id)
GL_DEPTH_COMPONENT32_OES,
GL_DEPTH_COMPONENT32_OES,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 32, 0);
return info;
}
case ID::EAC_R11G11_SNORM_BLOCK:
......@@ -443,7 +489,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SIGNED_RG11_EAC,
GL_COMPRESSED_SIGNED_RG11_EAC,
nullptr,
nullptr);
nullptr,
11, 11, 0, 0, 0, 0);
return info;
}
case ID::EAC_R11G11_UNORM_BLOCK:
......@@ -452,7 +499,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RG11_EAC,
GL_COMPRESSED_RG11_EAC,
nullptr,
nullptr);
nullptr,
11, 11, 0, 0, 0, 0);
return info;
}
case ID::EAC_R11_SNORM_BLOCK:
......@@ -461,7 +509,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SIGNED_R11_EAC,
GL_COMPRESSED_SIGNED_R11_EAC,
nullptr,
nullptr);
nullptr,
11, 0, 0, 0, 0, 0);
return info;
}
case ID::EAC_R11_UNORM_BLOCK:
......@@ -470,7 +519,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_R11_EAC,
GL_COMPRESSED_R11_EAC,
nullptr,
nullptr);
nullptr,
11, 0, 0, 0, 0, 0);
return info;
}
case ID::ETC2_R8G8B8A1_SRGB_BLOCK:
......@@ -479,7 +529,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
nullptr,
nullptr);
nullptr,
8, 8, 8, 1, 0, 0);
return info;
}
case ID::ETC2_R8G8B8A1_UNORM_BLOCK:
......@@ -488,7 +539,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
nullptr,
nullptr);
nullptr,
8, 8, 8, 1, 0, 0);
return info;
}
case ID::ETC2_R8G8B8A8_SRGB_BLOCK:
......@@ -497,7 +549,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
nullptr,
nullptr);
nullptr,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::ETC2_R8G8B8A8_UNORM_BLOCK:
......@@ -506,7 +559,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGBA8_ETC2_EAC,
GL_COMPRESSED_RGBA8_ETC2_EAC,
nullptr,
nullptr);
nullptr,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::ETC2_R8G8B8_SRGB_BLOCK:
......@@ -515,7 +569,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_SRGB8_ETC2,
GL_COMPRESSED_SRGB8_ETC2,
nullptr,
nullptr);
nullptr,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::ETC2_R8G8B8_UNORM_BLOCK:
......@@ -524,7 +579,8 @@ const Format &Format::Get(ID id)
GL_COMPRESSED_RGB8_ETC2,
GL_COMPRESSED_RGB8_ETC2,
nullptr,
nullptr);
nullptr,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::L16A16_FLOAT:
......@@ -533,7 +589,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE_ALPHA16F_EXT,
GL_LUMINANCE_ALPHA16F_EXT,
GenerateMip<L16A16F>,
ReadColor<L16A16F, GLfloat>);
ReadColor<L16A16F, GLfloat>,
0, 0, 0, 16, 0, 0);
return info;
}
case ID::L16_FLOAT:
......@@ -542,7 +599,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE16F_EXT,
GL_LUMINANCE16F_EXT,
GenerateMip<L16F>,
ReadColor<L16F, GLfloat>);
ReadColor<L16F, GLfloat>,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::L32A32_FLOAT:
......@@ -551,7 +609,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE_ALPHA32F_EXT,
GL_LUMINANCE_ALPHA32F_EXT,
GenerateMip<L32A32F>,
ReadColor<L32A32F, GLfloat>);
ReadColor<L32A32F, GLfloat>,
0, 0, 0, 32, 0, 0);
return info;
}
case ID::L32_FLOAT:
......@@ -560,7 +619,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE32F_EXT,
GL_LUMINANCE32F_EXT,
GenerateMip<L32F>,
ReadColor<L32F, GLfloat>);
ReadColor<L32F, GLfloat>,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::L8A8_UNORM:
......@@ -569,7 +629,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE8_ALPHA8_EXT,
GL_LUMINANCE8_ALPHA8_EXT,
GenerateMip<L8A8>,
ReadColor<L8A8, GLfloat>);
ReadColor<L8A8, GLfloat>,
0, 0, 0, 8, 0, 0);
return info;
}
case ID::L8_UNORM:
......@@ -578,7 +639,8 @@ const Format &Format::Get(ID id)
GL_LUMINANCE8_EXT,
GL_LUMINANCE8_EXT,
GenerateMip<L8>,
ReadColor<L8, GLfloat>);
ReadColor<L8, GLfloat>,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::NONE:
......@@ -587,7 +649,8 @@ const Format &Format::Get(ID id)
GL_NONE,
GL_NONE,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 0);
return info;
}
case ID::R10G10B10A2_UINT:
......@@ -596,7 +659,8 @@ const Format &Format::Get(ID id)
GL_RGB10_A2UI,
GL_RGB10_A2UI,
GenerateMip<R10G10B10A2>,
ReadColor<R10G10B10A2, GLuint>);
ReadColor<R10G10B10A2, GLuint>,
10, 10, 10, 2, 0, 0);
return info;
}
case ID::R10G10B10A2_UNORM:
......@@ -605,7 +669,8 @@ const Format &Format::Get(ID id)
GL_RGB10_A2,
GL_RGB10_A2,
GenerateMip<R10G10B10A2>,
ReadColor<R10G10B10A2, GLfloat>);
ReadColor<R10G10B10A2, GLfloat>,
10, 10, 10, 2, 0, 0);
return info;
}
case ID::R11G11B10_FLOAT:
......@@ -614,7 +679,8 @@ const Format &Format::Get(ID id)
GL_R11F_G11F_B10F,
GL_R11F_G11F_B10F,
GenerateMip<R11G11B10F>,
ReadColor<R11G11B10F, GLfloat>);
ReadColor<R11G11B10F, GLfloat>,
11, 11, 10, 0, 0, 0);
return info;
}
case ID::R16G16B16A16_FLOAT:
......@@ -623,7 +689,8 @@ const Format &Format::Get(ID id)
GL_RGBA16F,
GL_RGBA16F,
GenerateMip<R16G16B16A16F>,
ReadColor<R16G16B16A16F, GLfloat>);
ReadColor<R16G16B16A16F, GLfloat>,
16, 16, 16, 16, 0, 0);
return info;
}
case ID::R16G16B16A16_SINT:
......@@ -632,7 +699,8 @@ const Format &Format::Get(ID id)
GL_RGBA16I,
GL_RGBA16I,
GenerateMip<R16G16B16A16S>,
ReadColor<R16G16B16A16S, GLint>);
ReadColor<R16G16B16A16S, GLint>,
16, 16, 16, 16, 0, 0);
return info;
}
case ID::R16G16B16A16_SNORM:
......@@ -641,7 +709,8 @@ const Format &Format::Get(ID id)
GL_RGBA16_SNORM_EXT,
GL_RGBA16_SNORM_EXT,
GenerateMip<R16G16B16A16S>,
ReadColor<R16G16B16A16S, GLfloat>);
ReadColor<R16G16B16A16S, GLfloat>,
16, 16, 16, 16, 0, 0);
return info;
}
case ID::R16G16B16A16_UINT:
......@@ -650,7 +719,8 @@ const Format &Format::Get(ID id)
GL_RGBA16UI,
GL_RGBA16UI,
GenerateMip<R16G16B16A16>,
ReadColor<R16G16B16A16, GLuint>);
ReadColor<R16G16B16A16, GLuint>,
16, 16, 16, 16, 0, 0);
return info;
}
case ID::R16G16B16A16_UNORM:
......@@ -659,7 +729,8 @@ const Format &Format::Get(ID id)
GL_RGBA16_EXT,
GL_RGBA16_EXT,
GenerateMip<R16G16B16A16>,
ReadColor<R16G16B16A16, GLfloat>);
ReadColor<R16G16B16A16, GLfloat>,
16, 16, 16, 16, 0, 0);
return info;
}
case ID::R16G16B16_FLOAT:
......@@ -668,7 +739,8 @@ const Format &Format::Get(ID id)
GL_RGB16F,
GL_RGB16F,
GenerateMip<R16G16B16F>,
ReadColor<R16G16B16F, GLfloat>);
ReadColor<R16G16B16F, GLfloat>,
16, 16, 16, 0, 0, 0);
return info;
}
case ID::R16G16B16_SINT:
......@@ -677,7 +749,8 @@ const Format &Format::Get(ID id)
GL_RGB16I,
GL_RGB16I,
GenerateMip<R16G16B16S>,
ReadColor<R16G16B16S, GLint>);
ReadColor<R16G16B16S, GLint>,
16, 16, 16, 0, 0, 0);
return info;
}
case ID::R16G16B16_SNORM:
......@@ -686,7 +759,8 @@ const Format &Format::Get(ID id)
GL_RGB16_SNORM_EXT,
GL_RGB16_SNORM_EXT,
GenerateMip<R16G16B16S>,
ReadColor<R16G16B16S, GLfloat>);
ReadColor<R16G16B16S, GLfloat>,
16, 16, 16, 0, 0, 0);
return info;
}
case ID::R16G16B16_UINT:
......@@ -695,7 +769,8 @@ const Format &Format::Get(ID id)
GL_RGB16UI,
GL_RGB16UI,
GenerateMip<R16G16B16>,
ReadColor<R16G16B16, GLuint>);
ReadColor<R16G16B16, GLuint>,
16, 16, 16, 0, 0, 0);
return info;
}
case ID::R16G16B16_UNORM:
......@@ -704,7 +779,8 @@ const Format &Format::Get(ID id)
GL_RGB16_EXT,
GL_RGB16_EXT,
GenerateMip<R16G16B16>,
ReadColor<R16G16B16, GLfloat>);
ReadColor<R16G16B16, GLfloat>,
16, 16, 16, 0, 0, 0);
return info;
}
case ID::R16G16_FLOAT:
......@@ -713,7 +789,8 @@ const Format &Format::Get(ID id)
GL_RG16F,
GL_RG16F,
GenerateMip<R16G16F>,
ReadColor<R16G16F, GLfloat>);
ReadColor<R16G16F, GLfloat>,
16, 16, 0, 0, 0, 0);
return info;
}
case ID::R16G16_SINT:
......@@ -722,7 +799,8 @@ const Format &Format::Get(ID id)
GL_RG16I,
GL_RG16I,
GenerateMip<R16G16S>,
ReadColor<R16G16S, GLint>);
ReadColor<R16G16S, GLint>,
16, 16, 0, 0, 0, 0);
return info;
}
case ID::R16G16_SNORM:
......@@ -731,7 +809,8 @@ const Format &Format::Get(ID id)
GL_RG16_SNORM_EXT,
GL_RG16_SNORM_EXT,
GenerateMip<R16G16S>,
ReadColor<R16G16S, GLfloat>);
ReadColor<R16G16S, GLfloat>,
16, 16, 0, 0, 0, 0);
return info;
}
case ID::R16G16_UINT:
......@@ -740,7 +819,8 @@ const Format &Format::Get(ID id)
GL_RG16UI,
GL_RG16UI,
GenerateMip<R16G16>,
ReadColor<R16G16, GLuint>);
ReadColor<R16G16, GLuint>,
16, 16, 0, 0, 0, 0);
return info;
}
case ID::R16G16_UNORM:
......@@ -749,7 +829,8 @@ const Format &Format::Get(ID id)
GL_RG16_EXT,
GL_RG16_EXT,
GenerateMip<R16G16>,
ReadColor<R16G16, GLfloat>);
ReadColor<R16G16, GLfloat>,
16, 16, 0, 0, 0, 0);
return info;
}
case ID::R16_FLOAT:
......@@ -758,7 +839,8 @@ const Format &Format::Get(ID id)
GL_R16F,
GL_R16F,
GenerateMip<R16F>,
ReadColor<R16F, GLfloat>);
ReadColor<R16F, GLfloat>,
16, 0, 0, 0, 0, 0);
return info;
}
case ID::R16_SINT:
......@@ -767,7 +849,8 @@ const Format &Format::Get(ID id)
GL_R16I,
GL_R16I,
GenerateMip<R16S>,
ReadColor<R16S, GLint>);
ReadColor<R16S, GLint>,
16, 0, 0, 0, 0, 0);
return info;
}
case ID::R16_SNORM:
......@@ -776,7 +859,8 @@ const Format &Format::Get(ID id)
GL_R16_SNORM_EXT,
GL_R16_SNORM_EXT,
GenerateMip<R16S>,
ReadColor<R16S, GLfloat>);
ReadColor<R16S, GLfloat>,
16, 0, 0, 0, 0, 0);
return info;
}
case ID::R16_UINT:
......@@ -785,7 +869,8 @@ const Format &Format::Get(ID id)
GL_R16UI,
GL_R16UI,
GenerateMip<R16>,
ReadColor<R16, GLuint>);
ReadColor<R16, GLuint>,
16, 0, 0, 0, 0, 0);
return info;
}
case ID::R16_UNORM:
......@@ -794,7 +879,8 @@ const Format &Format::Get(ID id)
GL_R16_EXT,
GL_R16_EXT,
GenerateMip<R16>,
ReadColor<R16, GLfloat>);
ReadColor<R16, GLfloat>,
16, 0, 0, 0, 0, 0);
return info;
}
case ID::R32G32B32A32_FLOAT:
......@@ -803,7 +889,8 @@ const Format &Format::Get(ID id)
GL_RGBA32F,
GL_RGBA32F,
GenerateMip<R32G32B32A32F>,
ReadColor<R32G32B32A32F, GLfloat>);
ReadColor<R32G32B32A32F, GLfloat>,
32, 32, 32, 32, 0, 0);
return info;
}
case ID::R32G32B32A32_SINT:
......@@ -812,7 +899,8 @@ const Format &Format::Get(ID id)
GL_RGBA32I,
GL_RGBA32I,
GenerateMip<R32G32B32A32S>,
ReadColor<R32G32B32A32S, GLint>);
ReadColor<R32G32B32A32S, GLint>,
32, 32, 32, 32, 0, 0);
return info;
}
case ID::R32G32B32A32_UINT:
......@@ -821,7 +909,8 @@ const Format &Format::Get(ID id)
GL_RGBA32UI,
GL_RGBA32UI,
GenerateMip<R32G32B32A32>,
ReadColor<R32G32B32A32, GLuint>);
ReadColor<R32G32B32A32, GLuint>,
32, 32, 32, 32, 0, 0);
return info;
}
case ID::R32G32B32_FLOAT:
......@@ -830,7 +919,8 @@ const Format &Format::Get(ID id)
GL_RGB32F,
GL_RGB32F,
GenerateMip<R32G32B32F>,
ReadColor<R32G32B32F, GLfloat>);
ReadColor<R32G32B32F, GLfloat>,
32, 32, 32, 0, 0, 0);
return info;
}
case ID::R32G32B32_SINT:
......@@ -839,7 +929,8 @@ const Format &Format::Get(ID id)
GL_RGB32I,
GL_RGB32I,
GenerateMip<R32G32B32S>,
ReadColor<R32G32B32S, GLint>);
ReadColor<R32G32B32S, GLint>,
32, 32, 32, 0, 0, 0);
return info;
}
case ID::R32G32B32_UINT:
......@@ -848,7 +939,8 @@ const Format &Format::Get(ID id)
GL_RGB32UI,
GL_RGB32UI,
GenerateMip<R32G32B32>,
ReadColor<R32G32B32, GLuint>);
ReadColor<R32G32B32, GLuint>,
32, 32, 32, 0, 0, 0);
return info;
}
case ID::R32G32_FLOAT:
......@@ -857,7 +949,8 @@ const Format &Format::Get(ID id)
GL_RG32F,
GL_RG32F,
GenerateMip<R32G32F>,
ReadColor<R32G32F, GLfloat>);
ReadColor<R32G32F, GLfloat>,
32, 32, 0, 0, 0, 0);
return info;
}
case ID::R32G32_SINT:
......@@ -866,7 +959,8 @@ const Format &Format::Get(ID id)
GL_RG32I,
GL_RG32I,
GenerateMip<R32G32S>,
ReadColor<R32G32S, GLint>);
ReadColor<R32G32S, GLint>,
32, 32, 0, 0, 0, 0);
return info;
}
case ID::R32G32_UINT:
......@@ -875,7 +969,8 @@ const Format &Format::Get(ID id)
GL_RG32UI,
GL_RG32UI,
GenerateMip<R32G32>,
ReadColor<R32G32, GLuint>);
ReadColor<R32G32, GLuint>,
32, 32, 0, 0, 0, 0);
return info;
}
case ID::R32_FLOAT:
......@@ -884,7 +979,8 @@ const Format &Format::Get(ID id)
GL_R32F,
GL_R32F,
GenerateMip<R32F>,
ReadColor<R32F, GLfloat>);
ReadColor<R32F, GLfloat>,
32, 0, 0, 0, 0, 0);
return info;
}
case ID::R32_SINT:
......@@ -893,7 +989,8 @@ const Format &Format::Get(ID id)
GL_R32I,
GL_R32I,
GenerateMip<R32S>,
ReadColor<R32S, GLint>);
ReadColor<R32S, GLint>,
32, 0, 0, 0, 0, 0);
return info;
}
case ID::R32_UINT:
......@@ -902,7 +999,8 @@ const Format &Format::Get(ID id)
GL_R32UI,
GL_R32UI,
GenerateMip<R32>,
ReadColor<R32, GLuint>);
ReadColor<R32, GLuint>,
32, 0, 0, 0, 0, 0);
return info;
}
case ID::R4G4B4A4_UNORM:
......@@ -911,7 +1009,8 @@ const Format &Format::Get(ID id)
GL_RGBA4,
GL_RGBA4,
GenerateMip<R4G4B4A4>,
ReadColor<R4G4B4A4, GLfloat>);
ReadColor<R4G4B4A4, GLfloat>,
4, 4, 4, 4, 0, 0);
return info;
}
case ID::R5G5B5A1_UNORM:
......@@ -920,7 +1019,8 @@ const Format &Format::Get(ID id)
GL_RGB5_A1,
GL_RGB5_A1,
GenerateMip<R5G5B5A1>,
ReadColor<R5G5B5A1, GLfloat>);
ReadColor<R5G5B5A1, GLfloat>,
5, 5, 5, 1, 0, 0);
return info;
}
case ID::R5G6B5_UNORM:
......@@ -929,7 +1029,8 @@ const Format &Format::Get(ID id)
GL_RGB565,
GL_RGB565,
GenerateMip<R5G6B5>,
ReadColor<R5G6B5, GLfloat>);
ReadColor<R5G6B5, GLfloat>,
5, 6, 5, 0, 0, 0);
return info;
}
case ID::R8G8B8A8_SINT:
......@@ -938,7 +1039,8 @@ const Format &Format::Get(ID id)
GL_RGBA8I,
GL_RGBA8I,
GenerateMip<R8G8B8A8S>,
ReadColor<R8G8B8A8S, GLint>);
ReadColor<R8G8B8A8S, GLint>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::R8G8B8A8_SNORM:
......@@ -947,7 +1049,8 @@ const Format &Format::Get(ID id)
GL_RGBA8_SNORM,
GL_RGBA8_SNORM,
GenerateMip<R8G8B8A8S>,
ReadColor<R8G8B8A8S, GLfloat>);
ReadColor<R8G8B8A8S, GLfloat>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::R8G8B8A8_UINT:
......@@ -956,7 +1059,8 @@ const Format &Format::Get(ID id)
GL_RGBA8UI,
GL_RGBA8UI,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLuint>);
ReadColor<R8G8B8A8, GLuint>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::R8G8B8A8_UNORM:
......@@ -965,7 +1069,8 @@ const Format &Format::Get(ID id)
GL_RGBA8,
GL_RGBA8,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
ReadColor<R8G8B8A8, GLfloat>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::R8G8B8A8_UNORM_SRGB:
......@@ -974,7 +1079,8 @@ const Format &Format::Get(ID id)
GL_SRGB8_ALPHA8,
GL_SRGB8_ALPHA8,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
ReadColor<R8G8B8A8, GLfloat>,
8, 8, 8, 8, 0, 0);
return info;
}
case ID::R8G8B8_SINT:
......@@ -983,7 +1089,8 @@ const Format &Format::Get(ID id)
GL_RGB8I,
GL_RGB8I,
GenerateMip<R8G8B8S>,
ReadColor<R8G8B8S, GLint>);
ReadColor<R8G8B8S, GLint>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::R8G8B8_SNORM:
......@@ -992,7 +1099,8 @@ const Format &Format::Get(ID id)
GL_RGB8_SNORM,
GL_RGB8_SNORM,
GenerateMip<R8G8B8S>,
ReadColor<R8G8B8S, GLfloat>);
ReadColor<R8G8B8S, GLfloat>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::R8G8B8_UINT:
......@@ -1001,7 +1109,8 @@ const Format &Format::Get(ID id)
GL_RGB8UI,
GL_RGB8UI,
GenerateMip<R8G8B8>,
ReadColor<R8G8B8, GLuint>);
ReadColor<R8G8B8, GLuint>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::R8G8B8_UNORM:
......@@ -1010,7 +1119,8 @@ const Format &Format::Get(ID id)
GL_RGB8,
GL_RGB8,
GenerateMip<R8G8B8>,
ReadColor<R8G8B8, GLfloat>);
ReadColor<R8G8B8, GLfloat>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::R8G8B8_UNORM_SRGB:
......@@ -1019,7 +1129,8 @@ const Format &Format::Get(ID id)
GL_SRGB8,
GL_SRGB8,
GenerateMip<R8G8B8>,
ReadColor<R8G8B8, GLfloat>);
ReadColor<R8G8B8, GLfloat>,
8, 8, 8, 0, 0, 0);
return info;
}
case ID::R8G8_SINT:
......@@ -1028,7 +1139,8 @@ const Format &Format::Get(ID id)
GL_RG8I,
GL_RG8I,
GenerateMip<R8G8S>,
ReadColor<R8G8S, GLint>);
ReadColor<R8G8S, GLint>,
8, 8, 0, 0, 0, 0);
return info;
}
case ID::R8G8_SNORM:
......@@ -1037,7 +1149,8 @@ const Format &Format::Get(ID id)
GL_RG8_SNORM,
GL_RG8_SNORM,
GenerateMip<R8G8S>,
ReadColor<R8G8S, GLfloat>);
ReadColor<R8G8S, GLfloat>,
8, 8, 0, 0, 0, 0);
return info;
}
case ID::R8G8_UINT:
......@@ -1046,7 +1159,8 @@ const Format &Format::Get(ID id)
GL_RG8UI,
GL_RG8UI,
GenerateMip<R8G8>,
ReadColor<R8G8, GLuint>);
ReadColor<R8G8, GLuint>,
8, 8, 0, 0, 0, 0);
return info;
}
case ID::R8G8_UNORM:
......@@ -1055,7 +1169,8 @@ const Format &Format::Get(ID id)
GL_RG8,
GL_RG8,
GenerateMip<R8G8>,
ReadColor<R8G8, GLfloat>);
ReadColor<R8G8, GLfloat>,
8, 8, 0, 0, 0, 0);
return info;
}
case ID::R8_SINT:
......@@ -1064,7 +1179,8 @@ const Format &Format::Get(ID id)
GL_R8I,
GL_R8I,
GenerateMip<R8S>,
ReadColor<R8S, GLint>);
ReadColor<R8S, GLint>,
8, 0, 0, 0, 0, 0);
return info;
}
case ID::R8_SNORM:
......@@ -1073,7 +1189,8 @@ const Format &Format::Get(ID id)
GL_R8_SNORM,
GL_R8_SNORM,
GenerateMip<R8S>,
ReadColor<R8S, GLfloat>);
ReadColor<R8S, GLfloat>,
8, 0, 0, 0, 0, 0);
return info;
}
case ID::R8_UINT:
......@@ -1082,7 +1199,8 @@ const Format &Format::Get(ID id)
GL_R8UI,
GL_R8UI,
GenerateMip<R8>,
ReadColor<R8, GLuint>);
ReadColor<R8, GLuint>,
8, 0, 0, 0, 0, 0);
return info;
}
case ID::R8_UNORM:
......@@ -1091,7 +1209,8 @@ const Format &Format::Get(ID id)
GL_R8,
GL_R8,
GenerateMip<R8>,
ReadColor<R8, GLfloat>);
ReadColor<R8, GLfloat>,
8, 0, 0, 0, 0, 0);
return info;
}
case ID::R9G9B9E5_SHAREDEXP:
......@@ -1100,7 +1219,8 @@ const Format &Format::Get(ID id)
GL_RGB9_E5,
GL_RGB9_E5,
GenerateMip<R9G9B9E5>,
ReadColor<R9G9B9E5, GLfloat>);
ReadColor<R9G9B9E5, GLfloat>,
9, 9, 9, 0, 0, 0);
return info;
}
case ID::S8_UINT:
......@@ -1109,7 +1229,8 @@ const Format &Format::Get(ID id)
GL_STENCIL_INDEX8,
GL_STENCIL_INDEX8,
nullptr,
nullptr);
nullptr,
0, 0, 0, 0, 0, 8);
return info;
}
......@@ -1119,7 +1240,7 @@ const Format &Format::Get(ID id)
}
// clang-format on
static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr);
static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr, 0, 0, 0, 0, 0, 0);
return noneInfo;
}
......
......@@ -1459,26 +1459,26 @@ gl::Error Blit11::copyDepthStencilImpl(const TextureHelper11 &source,
const gl::Rectangle *scissor,
bool stencilOnly)
{
auto srcFormat = source.getFormat();
const auto &srcSizeInfo = d3d11::GetDXGIFormatSizeInfo(srcFormat);
auto srcDXGIFormat = source.getFormat();
const auto &srcSizeInfo = d3d11::GetDXGIFormatSizeInfo(srcDXGIFormat);
unsigned int srcPixelSize = srcSizeInfo.pixelBytes;
unsigned int copyOffset = 0;
unsigned int copyOffset = 0;
unsigned int copySize = srcPixelSize;
auto destFormat = dest.getFormat();
const auto &destSizeInfo = d3d11::GetDXGIFormatSizeInfo(destFormat);
auto destDXGIFormat = dest.getFormat();
const auto &destSizeInfo = d3d11::GetDXGIFormatSizeInfo(destDXGIFormat);
unsigned int destPixelSize = destSizeInfo.pixelBytes;
ASSERT(srcFormat == destFormat || destFormat == DXGI_FORMAT_R32_TYPELESS);
ASSERT(srcDXGIFormat == destDXGIFormat || destDXGIFormat == DXGI_FORMAT_R32_TYPELESS);
if (stencilOnly)
{
const d3d11::DXGIFormat &srcDXGIFormat = d3d11::GetDXGIFormatInfo(srcFormat);
const auto &srcFormat = source.getFormatSet().format;
// Stencil channel should be right after the depth channel. Some views to depth/stencil
// resources have red channel for depth, in which case the depth channel bit width is in
// redBits.
ASSERT((srcDXGIFormat.redBits != 0) != (srcDXGIFormat.depthBits != 0));
GLuint depthBits = srcDXGIFormat.redBits + srcDXGIFormat.depthBits;
ASSERT((srcFormat.redBits != 0) != (srcFormat.depthBits != 0));
GLuint depthBits = srcFormat.redBits + srcFormat.depthBits;
// Known formats have either 24 or 32 bits of depth.
ASSERT(depthBits == 24 || depthBits == 32);
copyOffset = depthBits / 8;
......@@ -1487,9 +1487,9 @@ gl::Error Blit11::copyDepthStencilImpl(const TextureHelper11 &source,
copySize = 1;
}
if (srcFormat != destFormat)
if (srcDXGIFormat != destDXGIFormat)
{
if (srcFormat == DXGI_FORMAT_R24G8_TYPELESS)
if (srcDXGIFormat == DXGI_FORMAT_R24G8_TYPELESS)
{
ASSERT(sourceArea == destArea && sourceSize == destSize && scissor == nullptr);
return copyAndConvert(source, sourceSubresource, sourceArea, sourceSize, dest,
......@@ -1497,7 +1497,7 @@ gl::Error Blit11::copyDepthStencilImpl(const TextureHelper11 &source,
copyOffset, copySize, srcPixelSize, destPixelSize,
BlitD24S8ToD32F);
}
ASSERT(srcFormat == DXGI_FORMAT_R32G8X24_TYPELESS);
ASSERT(srcDXGIFormat == DXGI_FORMAT_R32G8X24_TYPELESS);
return copyAndConvert(source, sourceSubresource, sourceArea, sourceSize, dest,
destSubresource, destArea, destSize, scissor, copyOffset, copyOffset,
copySize, srcPixelSize, destPixelSize, BlitD32FS8ToD32F);
......
......@@ -331,27 +331,26 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams,
return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null.");
}
const auto &dxgiFormatInfo =
d3d11::GetDXGIFormatInfo(renderTarget->getFormatSet().rtvFormat);
const auto &nativeFormat = renderTarget->getFormatSet().format;
// Check if the actual format has a channel that the internal format does not and set them to the
// default values
float clearValues[4] = {
((formatInfo.redBits == 0 && dxgiFormatInfo.redBits > 0)
((formatInfo.redBits == 0 && nativeFormat.redBits > 0)
? 0.0f
: clearParams.colorFClearValue.red),
((formatInfo.greenBits == 0 && dxgiFormatInfo.greenBits > 0)
((formatInfo.greenBits == 0 && nativeFormat.greenBits > 0)
? 0.0f
: clearParams.colorFClearValue.green),
((formatInfo.blueBits == 0 && dxgiFormatInfo.blueBits > 0)
((formatInfo.blueBits == 0 && nativeFormat.blueBits > 0)
? 0.0f
: clearParams.colorFClearValue.blue),
((formatInfo.alphaBits == 0 && dxgiFormatInfo.alphaBits > 0)
((formatInfo.alphaBits == 0 && nativeFormat.alphaBits > 0)
? 1.0f
: clearParams.colorFClearValue.alpha),
};
if (dxgiFormatInfo.alphaBits == 1)
if (formatInfo.alphaBits == 1)
{
// Some drivers do not correctly handle calling Clear() on a format with 1-bit alpha.
// They can incorrectly round all non-zero values up to 1.0f. Note that WARP does not do this.
......@@ -392,10 +391,10 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams,
return error;
}
const auto &dxgiFormatInfo =
d3d11::GetDXGIFormatInfo(renderTarget->getFormatSet().dsvFormat);
const auto &nativeFormat = renderTarget->getFormatSet().format;
unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << dxgiFormatInfo.stencilBits) - 1 : 0;
unsigned int stencilUnmasked =
(stencilAttachment != nullptr) ? (1 << nativeFormat.stencilBits) - 1 : 0;
bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
if (needScissoredClear || needMaskedStencilClear)
......
......@@ -3931,21 +3931,20 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
const auto &destFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat());
const auto &srcFormatInfo = gl::GetInternalFormatInfo(readRenderTarget->getInternalFormat());
const auto &formatSet = drawRenderTarget11->getFormatSet();
const DXGI_FORMAT drawDXGIFormat = colorBlit ? formatSet.rtvFormat : formatSet.dsvFormat;
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(drawDXGIFormat);
const auto &nativeFormat = formatSet.format;
// Some blits require masking off emulated texture channels. eg: from RGBA8 to RGB8, we
// emulate RGB8 with RGBA8, so we need to mask off the alpha channel when we copy.
gl::Color<bool> colorMask;
colorMask.red = (srcFormatInfo.redBits > 0) && (destFormatInfo.redBits == 0) &&
(dxgiFormatInfo.redBits > 0);
colorMask.red =
(srcFormatInfo.redBits > 0) && (destFormatInfo.redBits == 0) && (nativeFormat.redBits > 0);
colorMask.green = (srcFormatInfo.greenBits > 0) && (destFormatInfo.greenBits == 0) &&
(dxgiFormatInfo.greenBits > 0);
(nativeFormat.greenBits > 0);
colorMask.blue = (srcFormatInfo.blueBits > 0) && (destFormatInfo.blueBits == 0) &&
(dxgiFormatInfo.blueBits > 0);
(nativeFormat.blueBits > 0);
colorMask.alpha = (srcFormatInfo.alphaBits > 0) && (destFormatInfo.alphaBits == 0) &&
(dxgiFormatInfo.alphaBits > 0);
(nativeFormat.alphaBits > 0);
// We only currently support masking off the alpha channel.
bool colorMaskingNeeded = colorMask.alpha;
......@@ -3966,7 +3965,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
drawRect.x < 0 || drawRect.x + drawRect.width > drawSize.width ||
drawRect.y < 0 || drawRect.y + drawRect.height > drawSize.height;
bool partialDSBlit = (dxgiFormatInfo.depthBits > 0 && depthBlit) != (dxgiFormatInfo.stencilBits > 0 && stencilBlit);
bool partialDSBlit =
(nativeFormat.depthBits > 0 && depthBlit) != (nativeFormat.stencilBits > 0 && stencilBlit);
if (readRenderTarget11->getFormatSet().format.id ==
drawRenderTarget11->getFormatSet().format.id &&
......
......@@ -217,7 +217,7 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
// 1. the drop stencil workaround is enabled.
bool workaround = mRenderer->getWorkarounds().emulateTinyStencilTextures;
// 2. this is a stencil texture.
bool hasStencil = (d3d11::GetDXGIFormatInfo(mFormatInfo.dsvFormat).stencilBits > 0);
bool hasStencil = (mFormatInfo.format.stencilBits > 0);
// 3. the texture has a 1x1 or 2x2 mip.
bool hasSmallMips = (getLevelWidth(mMipLevels - 1) <= 2 || getLevelHeight(mMipLevels - 1) <= 2);
......@@ -249,8 +249,7 @@ gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key,
if (key.swizzle)
{
ASSERT(!key.dropStencil ||
d3d11::GetDXGIFormatInfo(mFormatInfo.swizzle.dsvFormat).stencilBits == 0);
ASSERT(!key.dropStencil || mFormatInfo.swizzle.format.stencilBits == 0);
ANGLE_TRY(getSwizzleTexture(&texture));
format = mFormatInfo.swizzle.srvFormat;
}
......
......@@ -24,166 +24,9 @@ namespace rx
namespace d3d11
{
struct DXGIColorFormatInfo
{
size_t redBits;
size_t greenBits;
size_t blueBits;
size_t luminanceBits;
size_t alphaBits;
size_t sharedBits;
};
typedef std::map<DXGI_FORMAT, DXGIColorFormatInfo> ColorFormatInfoMap;
typedef std::pair<DXGI_FORMAT, DXGIColorFormatInfo> ColorFormatInfoPair;
static inline void InsertDXGIColorFormatInfo(ColorFormatInfoMap *map, DXGI_FORMAT format, size_t redBits, size_t greenBits,
size_t blueBits, size_t alphaBits, size_t sharedBits)
{
DXGIColorFormatInfo info;
info.redBits = redBits;
info.greenBits = greenBits;
info.blueBits = blueBits;
info.alphaBits = alphaBits;
info.sharedBits = sharedBits;
map->insert(std::make_pair(format, info));
}
static ColorFormatInfoMap BuildColorFormatInfoMap()
{
ColorFormatInfoMap map;
// clang-format off
// | DXGI format | R | G | B | A | S |
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_A8_UNORM, 0, 0, 0, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_UNORM, 8, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_UNORM, 8, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UNORM, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B8G8R8A8_UNORM, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_UNORM, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_UNORM, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_UNORM, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_SNORM, 8, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_SNORM, 8, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_SNORM, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_SNORM, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_SNORM, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_SNORM, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_UINT, 8, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_UINT, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_UINT, 32, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_UINT, 8, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_UINT, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_UINT, 32, 32, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_UINT, 32, 32, 32, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_UINT, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_UINT, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_UINT, 32, 32, 32, 32, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_SINT, 8, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_SINT, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_SINT, 32, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_SINT, 8, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_SINT, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_SINT, 32, 32, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_SINT, 32, 32, 32, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_SINT, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_SINT, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_SINT, 32, 32, 32, 32, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_TYPELESS, 10, 10, 10, 2, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_UNORM, 10, 10, 10, 2, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R10G10B10A2_UINT, 10, 10, 10, 2, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_FLOAT, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_FLOAT, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_FLOAT, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_FLOAT, 32, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_FLOAT, 32, 32, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_FLOAT, 32, 32, 32, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_FLOAT, 32, 32, 32, 32, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 9, 9, 9, 0, 5);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R11G11B10_FLOAT, 11, 11, 10, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B5G6R5_UNORM, 5, 6, 5, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B4G4R4A4_UNORM, 4, 4, 4, 4, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_B5G5R5A1_UNORM, 5, 5, 5, 1, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8_TYPELESS, 8, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16_TYPELESS, 16, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_TYPELESS, 32, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8_TYPELESS, 8, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16_TYPELESS, 16, 16, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32_TYPELESS, 32, 32, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32_TYPELESS, 32, 32, 32, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R8G8B8A8_TYPELESS, 8, 8, 8, 8, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R16G16B16A16_TYPELESS, 16, 16, 16, 16, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G32B32A32_TYPELESS, 32, 32, 32, 32, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R24G8_TYPELESS, 24, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, 24, 0, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32G8X24_TYPELESS, 32, 8, 0, 0, 0);
InsertDXGIColorFormatInfo(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, 32, 0, 0, 0, 0);
// clang-format on
return map;
}
struct DXGIDepthStencilInfo
{
unsigned int depthBits;
unsigned int stencilBits;
};
typedef std::map<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoMap;
typedef std::pair<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoPair;
static inline void InsertDXGIDepthStencilInfo(DepthStencilInfoMap *map,
DXGI_FORMAT format,
unsigned int depthBits,
unsigned int stencilBits)
{
DXGIDepthStencilInfo info;
info.depthBits = depthBits;
info.stencilBits = stencilBits;
map->insert(std::make_pair(format, info));
}
static DepthStencilInfoMap BuildDepthStencilInfoMap()
{
DepthStencilInfoMap map;
// clang-format off
InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D16_UNORM, 16, 0);
InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, 24, 8);
InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT, 32, 0);
InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 32, 8);
// clang-format on
return map;
}
typedef std::map<DXGI_FORMAT, DXGIFormat> DXGIFormatInfoMap;
DXGIFormat::DXGIFormat()
: redBits(0),
greenBits(0),
blueBits(0),
alphaBits(0),
sharedBits(0),
depthBits(0),
stencilBits(0),
componentType(GL_NONE),
nativeMipmapSupport(NULL)
DXGIFormat::DXGIFormat() : componentType(GL_NONE), nativeMipmapSupport(NULL)
{
}
......@@ -205,27 +48,6 @@ void AddDXGIFormat(DXGIFormatInfoMap *map,
{
DXGIFormat info;
static const ColorFormatInfoMap colorInfoMap = BuildColorFormatInfoMap();
ColorFormatInfoMap::const_iterator colorInfoIter = colorInfoMap.find(dxgiFormat);
if (colorInfoIter != colorInfoMap.end())
{
const DXGIColorFormatInfo &colorInfo = colorInfoIter->second;
info.redBits = static_cast<GLuint>(colorInfo.redBits);
info.greenBits = static_cast<GLuint>(colorInfo.greenBits);
info.blueBits = static_cast<GLuint>(colorInfo.blueBits);
info.alphaBits = static_cast<GLuint>(colorInfo.alphaBits);
info.sharedBits = static_cast<GLuint>(colorInfo.sharedBits);
}
static const DepthStencilInfoMap dsInfoMap = BuildDepthStencilInfoMap();
DepthStencilInfoMap::const_iterator dsInfoIter = dsInfoMap.find(dxgiFormat);
if (dsInfoIter != dsInfoMap.end())
{
const DXGIDepthStencilInfo &dsInfo = dsInfoIter->second;
info.depthBits = dsInfo.depthBits;
info.stencilBits = dsInfo.stencilBits;
}
info.componentType = componentType;
info.nativeMipmapSupport = nativeMipmapSupport;
......@@ -1151,6 +973,6 @@ const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType, D
}
}
}
} // namespace d3d11
}
} // namespace rx
......@@ -31,15 +31,6 @@ struct DXGIFormat
{
DXGIFormat();
GLuint redBits;
GLuint greenBits;
GLuint blueBits;
GLuint alphaBits;
GLuint sharedBits;
GLuint depthBits;
GLuint stencilBits;
GLenum componentType;
NativeMipmapGenerationSupportFunction nativeMipmapSupport;
......
......@@ -67,7 +67,7 @@ const Format &Format::Get(ID id)
}}
// clang-format on
static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr);
static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr, 0, 0, 0, 0, 0, 0);
return noneInfo;
}}
......@@ -128,7 +128,8 @@ format_entry_template = """{space}{{
{space} {glInternalFormat},
{space} {fboImplementationInternalFormat},
{space} {mipGenerationFunction},
{space} {colorReadFunction});
{space} {colorReadFunction},
{space} {R}, {G}, {B}, {A}, {D}, {S});
{space} return info;
{space}}}
"""
......@@ -205,6 +206,12 @@ def json_to_table_data(format_id, json, angle_to_gl):
parsed["mipGenerationFunction"] = get_mip_generation_function(parsed)
parsed["colorReadFunction"] = get_color_read_function(parsed)
for channel in "ABDGLRS":
if parsed["bits"] != None and channel in parsed["bits"]:
parsed[channel] = parsed["bits"][channel]
else:
parsed[channel] = "0"
return format_entry_template.format(**parsed)
def parse_json_into_angle_format_switch_string(all_angle, json_data, angle_to_gl):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment