Commit 6151af8c by Olli Etuaho Committed by Commit Bot

Remove renderFormat from TextureFormat structure

The renderFormat is only ever needed in renderer11_utils when determining which multisample sample counts a format supports. Determine the renderFormat in the context where it is needed instead of storing it in the TextureFormat structure. Extra fallbacks can also be removed from the code. The D3D11FormatTablesTest is restructured so that it doesn't need to use the renderFormat field. This refactoring is done to make it simpler to expand usage of the ANGLE format enumeration in the C++ code. BUG=angleproject:1244 TEST=angle_end2end_tests, dEQP-GLES3.functional.fbo.* (no regressions) Change-Id: I980152eb2f3fdaaa1cc5b08e3c9b695c1625e9e5 Reviewed-on: https://chromium-review.googlesource.com/328680Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 8fd2ca41
...@@ -128,26 +128,6 @@ const TextureFormat GetD3D11FormatInfo(GLenum internalFormat, ...@@ -128,26 +128,6 @@ const TextureFormat GetD3D11FormatInfo(GLenum internalFormat,
info.dsvFormat = dsvFormat; info.dsvFormat = dsvFormat;
info.dataInitializerFunction = internalFormatInitializer; info.dataInitializerFunction = internalFormatInitializer;
// Given a GL internal format, the renderFormat is the DSV format if it is depth- or
// stencil-renderable,
// the RTV format if it is color-renderable, and the (nonrenderable) texture format otherwise.
if (dsvFormat != DXGI_FORMAT_UNKNOWN)
{{
info.renderFormat = dsvFormat;
}}
else if (rtvFormat != DXGI_FORMAT_UNKNOWN)
{{
info.renderFormat = rtvFormat;
}}
else if (texFormat != DXGI_FORMAT_UNKNOWN)
{{
info.renderFormat = texFormat;
}}
else
{{
info.renderFormat = DXGI_FORMAT_UNKNOWN;
}}
// Compute the swizzle formats // Compute the swizzle formats
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0) if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0)
...@@ -213,7 +193,6 @@ TextureFormat::TextureFormat() ...@@ -213,7 +193,6 @@ TextureFormat::TextureFormat()
srvFormat(DXGI_FORMAT_UNKNOWN), srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN), rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN), dsvFormat(DXGI_FORMAT_UNKNOWN),
renderFormat(DXGI_FORMAT_UNKNOWN),
swizzleTexFormat(DXGI_FORMAT_UNKNOWN), swizzleTexFormat(DXGI_FORMAT_UNKNOWN),
swizzleSRVFormat(DXGI_FORMAT_UNKNOWN), swizzleSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzleRTVFormat(DXGI_FORMAT_UNKNOWN), swizzleRTVFormat(DXGI_FORMAT_UNKNOWN),
......
...@@ -363,7 +363,17 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum ...@@ -363,7 +363,17 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
textureCaps.renderable = (support.query(formatInfo.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) || textureCaps.renderable = (support.query(formatInfo.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) ||
(support.query(formatInfo.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)); (support.query(formatInfo.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL));
if (support.query(formatInfo.renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET)) DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.dsvFormat;
}
else if (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.rtvFormat;
}
if (renderFormat != DXGI_FORMAT_UNKNOWN &&
support.query(renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
{ {
// Assume 1x // Assume 1x
textureCaps.sampleCounts.insert(1); textureCaps.sampleCounts.insert(1);
...@@ -372,7 +382,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum ...@@ -372,7 +382,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
sampleCount *= 2) sampleCount *= 2)
{ {
UINT qualityCount = 0; UINT qualityCount = 0;
if (SUCCEEDED(device->CheckMultisampleQualityLevels(formatInfo.renderFormat, sampleCount, &qualityCount))) if (SUCCEEDED(device->CheckMultisampleQualityLevels(renderFormat, sampleCount,
&qualityCount)))
{ {
// Assume we always support lower sample counts // Assume we always support lower sample counts
if (qualityCount == 0) if (qualityCount == 0)
......
...@@ -42,7 +42,6 @@ struct TextureFormat ...@@ -42,7 +42,6 @@ struct TextureFormat
DXGI_FORMAT srvFormat; DXGI_FORMAT srvFormat;
DXGI_FORMAT rtvFormat; DXGI_FORMAT rtvFormat;
DXGI_FORMAT dsvFormat; DXGI_FORMAT dsvFormat;
DXGI_FORMAT renderFormat;
DXGI_FORMAT swizzleTexFormat; DXGI_FORMAT swizzleTexFormat;
DXGI_FORMAT swizzleSRVFormat; DXGI_FORMAT swizzleSRVFormat;
......
...@@ -115,26 +115,6 @@ const TextureFormat GetD3D11FormatInfo(GLenum internalFormat, ...@@ -115,26 +115,6 @@ const TextureFormat GetD3D11FormatInfo(GLenum internalFormat,
info.dsvFormat = dsvFormat; info.dsvFormat = dsvFormat;
info.dataInitializerFunction = internalFormatInitializer; info.dataInitializerFunction = internalFormatInitializer;
// Given a GL internal format, the renderFormat is the DSV format if it is depth- or
// stencil-renderable,
// the RTV format if it is color-renderable, and the (nonrenderable) texture format otherwise.
if (dsvFormat != DXGI_FORMAT_UNKNOWN)
{
info.renderFormat = dsvFormat;
}
else if (rtvFormat != DXGI_FORMAT_UNKNOWN)
{
info.renderFormat = rtvFormat;
}
else if (texFormat != DXGI_FORMAT_UNKNOWN)
{
info.renderFormat = texFormat;
}
else
{
info.renderFormat = DXGI_FORMAT_UNKNOWN;
}
// Compute the swizzle formats // Compute the swizzle formats
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0) if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0)
...@@ -200,7 +180,6 @@ TextureFormat::TextureFormat() ...@@ -200,7 +180,6 @@ TextureFormat::TextureFormat()
srvFormat(DXGI_FORMAT_UNKNOWN), srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN), rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN), dsvFormat(DXGI_FORMAT_UNKNOWN),
renderFormat(DXGI_FORMAT_UNKNOWN),
swizzleTexFormat(DXGI_FORMAT_UNKNOWN), swizzleTexFormat(DXGI_FORMAT_UNKNOWN),
swizzleSRVFormat(DXGI_FORMAT_UNKNOWN), swizzleSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzleRTVFormat(DXGI_FORMAT_UNKNOWN), swizzleRTVFormat(DXGI_FORMAT_UNKNOWN),
......
...@@ -30,7 +30,8 @@ class D3D11FormatTablesTest : public ANGLETest ...@@ -30,7 +30,8 @@ class D3D11FormatTablesTest : public ANGLETest
// using it as a texture, a render target, and sampling from it in the shader. It // using it as a texture, a render target, and sampling from it in the shader. It
// checks this against our speed-optimized baked tables, and validates they would // checks this against our speed-optimized baked tables, and validates they would
// give the same result. // give the same result.
// TODO(jmadill): Find out why in 9_3, some format queries return an error // TODO(jmadill): Find out why in 9_3, some format queries return an error.
// The error seems to appear for formats that are not supported on 9_3.
TEST_P(D3D11FormatTablesTest, TestFormatSupport) TEST_P(D3D11FormatTablesTest, TestFormatSupport)
{ {
ASSERT_EQ(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, GetParam().getRenderer()); ASSERT_EQ(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, GetParam().getRenderer());
...@@ -75,39 +76,57 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -75,39 +76,57 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
// Bits for renderable // Bits for renderable
bool renderable = false; bool renderable = false;
UINT renderSupport = 0u;
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0) if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0)
{ {
UINT depthSupport; renderFormat = formatInfo.dsvFormat;
bool depthSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.dsvFormat, &depthSupport)); bool depthSuccess =
renderable = depthSuccess && ((depthSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0); SUCCEEDED(device->CheckFormatSupport(formatInfo.dsvFormat, &renderSupport));
renderable =
depthSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.dsvFormat);
}
} }
else else
{ {
UINT rtSupport; renderFormat = formatInfo.rtvFormat;
bool rtSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.rtvFormat, &rtSupport)); bool rtSuccess =
renderable = rtSuccess && ((rtSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0); SUCCEEDED(device->CheckFormatSupport(formatInfo.rtvFormat, &renderSupport));
renderable = rtSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.rtvFormat);
}
} }
EXPECT_EQ(renderable, textureInfo.renderable); EXPECT_EQ(renderable, textureInfo.renderable);
if (!textureInfo.sampleCounts.empty())
{
EXPECT_TRUE(renderable);
}
// Multisample counts // Multisample counts
UINT renderSupport = false; if (renderable)
bool renderSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.renderFormat, &renderSupport));
if (renderSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET) != 0))
{ {
EXPECT_TRUE(!textureInfo.sampleCounts.empty()); if ((renderSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET) != 0)
for (unsigned int sampleCount = 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT;
sampleCount *= 2)
{ {
UINT qualityCount = 0; EXPECT_TRUE(!textureInfo.sampleCounts.empty());
bool sampleSuccess = SUCCEEDED(device->CheckMultisampleQualityLevels(formatInfo.renderFormat, sampleCount, &qualityCount)); for (unsigned int sampleCount = 1;
GLuint expectedCount = (!sampleSuccess || qualityCount == 0) ? 0 : 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount *= 2)
EXPECT_EQ(expectedCount, textureInfo.sampleCounts.count(sampleCount)); {
UINT qualityCount = 0;
bool sampleSuccess = SUCCEEDED(device->CheckMultisampleQualityLevels(
renderFormat, sampleCount, &qualityCount));
GLuint expectedCount = (!sampleSuccess || qualityCount == 0) ? 0 : 1;
EXPECT_EQ(expectedCount, textureInfo.sampleCounts.count(sampleCount));
}
}
else
{
EXPECT_TRUE(textureInfo.sampleCounts.empty());
} }
}
else
{
EXPECT_TRUE(textureInfo.sampleCounts.empty());
} }
} }
} }
......
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