Commit f434906c by Olli Etuaho Committed by Commit Bot

Group D3D11 DXGI format info under a struct

This patch refactors how DXGI format info is stored. The goal is to make it easier to make changes that affect both swizzle formats and regular texture formats, and make it easier to pass the format sets around. BUG=angleproject:1244 TEST=angle_end2end_tests Change-Id: I1cc220bccbbdde9200a41829fdc37c8ec123c6a1 Reviewed-on: https://chromium-review.googlesource.com/329072Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 6151af8c
......@@ -89,7 +89,7 @@ bool Image11::isDirty() const
if (mDirty && !mStagingTexture && !mRecoverFromStorage)
{
const Renderer11DeviceCaps &deviceCaps = mRenderer->getRenderer11DeviceCaps();
const d3d11::TextureFormat formatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, deviceCaps);
const auto &formatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, deviceCaps);
if (formatInfo.dataInitializerFunction == nullptr)
{
return false;
......@@ -219,9 +219,10 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &
mTarget = target;
// compute the d3d format that will be used
const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps());
mDXGIFormat = formatInfo.texFormat;
mRenderable = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
const d3d11::TextureFormat &formatInfo =
d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps());
mDXGIFormat = formatInfo.formatSet.texFormat;
mRenderable = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN);
releaseStagingTexture();
mDirty = (formatInfo.dataInitializerFunction != NULL);
......@@ -341,7 +342,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const auto &d3d11Format = d3d11::GetTextureFormatInfo(srcAttachment->getInternalFormat(),
mRenderer->getRenderer11DeviceCaps());
if (d3d11Format.texFormat == mDXGIFormat)
if (d3d11Format.formatSet.texFormat == mDXGIFormat)
{
RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
......
......@@ -205,7 +205,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType);
const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getRenderer11DeviceCaps());
DXGI_FORMAT srvFormat = sourceFormatInfo.srvFormat;
DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet.srvFormat;
ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
Buffer11 *bufferStorage11 = GetAs<Buffer11>(sourceBuffer.getImplementation());
ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat);
......
......@@ -384,7 +384,8 @@ unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
DXGI_FORMAT SurfaceRenderTarget11::getDXGIFormat() const
{
return d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getRenderer11DeviceCaps()).texFormat;
return d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getRenderer11DeviceCaps())
.formatSet.texFormat;
}
}
......@@ -3058,7 +3058,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
desc.Height = height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = formatInfo.texFormat;
desc.Format = formatInfo.formatSet.texFormat;
desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
......@@ -3069,14 +3069,15 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
// we'll flag it to allow binding that way. Shader resource views are a little
// more complicated.
bool bindRTV = false, bindDSV = false, bindSRV = false;
bindRTV = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN);
if (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
bindRTV = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN);
if (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN)
{
// Multisample targets flagged for binding as depth stencil cannot also be
// flagged for binding as SRV, so make certain not to add the SRV flag for
// these targets.
bindSRV = !(formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN && desc.SampleDesc.Count > 1);
bindSRV = !(formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN &&
desc.SampleDesc.Count > 1);
}
desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
......@@ -3098,7 +3099,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindSRV)
{
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = formatInfo.srvFormat;
srvDesc.Format = formatInfo.formatSet.srvFormat;
srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS;
srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Texture2D.MipLevels = 1;
......@@ -3115,7 +3116,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindDSV)
{
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = formatInfo.dsvFormat;
dsvDesc.Format = formatInfo.formatSet.dsvFormat;
dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS;
dsvDesc.Texture2D.MipSlice = 0;
dsvDesc.Flags = 0;
......@@ -3137,7 +3138,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
else if (bindRTV)
{
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = formatInfo.rtvFormat;
rtvDesc.Format = formatInfo.formatSet.rtvFormat;
rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS;
rtvDesc.Texture2D.MipSlice = 0;
......@@ -3448,7 +3449,8 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
const d3d11::TextureFormat &d3d11FormatInfo = d3d11::GetTextureFormatInfo(internalFormat, mRenderer11DeviceCaps);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(d3d11FormatInfo.texFormat);
const d3d11::DXGIFormat &dxgiFormatInfo =
d3d11::GetDXGIFormatInfo(d3d11FormatInfo.formatSet.texFormat);
// sRGB formats do not work with D3D11 buffer SRVs
if (internalFormatInfo.colorEncoding == GL_SRGB)
......@@ -3457,7 +3459,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
}
// We cannot support direct copies to non-color-renderable formats
if (d3d11FormatInfo.rtvFormat == DXGI_FORMAT_UNKNOWN)
if (d3d11FormatInfo.formatSet.rtvFormat == DXGI_FORMAT_UNKNOWN)
{
return false;
}
......
......@@ -208,9 +208,8 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
if (offscreenTextureDesc.Width != (UINT)backbufferWidth ||
offscreenTextureDesc.Height != (UINT)backbufferHeight ||
offscreenTextureDesc.Format != backbufferFormatInfo.texFormat ||
offscreenTextureDesc.MipLevels != 1 ||
offscreenTextureDesc.ArraySize != 1)
offscreenTextureDesc.Format != backbufferFormatInfo.formatSet.texFormat ||
offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1)
{
ERR("Invalid texture parameters in the shared offscreen texture pbuffer");
release();
......@@ -224,7 +223,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
offscreenTextureDesc.Width = backbufferWidth;
offscreenTextureDesc.Height = backbufferHeight;
offscreenTextureDesc.Format = backbufferFormatInfo.texFormat;
offscreenTextureDesc.Format = backbufferFormatInfo.formatSet.texFormat;
offscreenTextureDesc.MipLevels = 1;
offscreenTextureDesc.ArraySize = 1;
offscreenTextureDesc.SampleDesc.Count = 1;
......@@ -282,7 +281,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
mKeyedMutex = d3d11::DynamicCastComObject<IDXGIKeyedMutex>(mOffscreenTexture);
D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc;
offscreenRTVDesc.Format = backbufferFormatInfo.rtvFormat;
offscreenRTVDesc.Format = backbufferFormatInfo.formatSet.rtvFormat;
offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
offscreenRTVDesc.Texture2D.MipSlice = 0;
......@@ -291,7 +290,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
d3d11::SetDebugName(mOffscreenRTView, "Offscreen back buffer render target");
D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc;
offscreenSRVDesc.Format = backbufferFormatInfo.srvFormat;
offscreenSRVDesc.Format = backbufferFormatInfo.formatSet.srvFormat;
offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
offscreenSRVDesc.Texture2D.MostDetailedMip = 0;
offscreenSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
......@@ -338,7 +337,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
depthStencilTextureDesc.Width = backbufferWidth;
depthStencilTextureDesc.Height = backbufferHeight;
depthStencilTextureDesc.Format = depthBufferFormatInfo.texFormat;
depthStencilTextureDesc.Format = depthBufferFormatInfo.formatSet.texFormat;
depthStencilTextureDesc.MipLevels = 1;
depthStencilTextureDesc.ArraySize = 1;
depthStencilTextureDesc.SampleDesc.Count = 1;
......@@ -346,7 +345,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
if (depthBufferFormatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN)
{
depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
}
......@@ -374,7 +373,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture");
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
depthStencilDesc.Format = depthBufferFormatInfo.dsvFormat;
depthStencilDesc.Format = depthBufferFormatInfo.formatSet.dsvFormat;
depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilDesc.Flags = 0;
depthStencilDesc.Texture2D.MipSlice = 0;
......@@ -383,10 +382,10 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
ASSERT(SUCCEEDED(result));
d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view");
if (depthBufferFormatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN)
{
D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
depthStencilSRVDesc.Format = depthBufferFormatInfo.srvFormat;
depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet.srvFormat;
depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
depthStencilSRVDesc.Texture2D.MostDetailedMip = 0;
depthStencilSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
......
......@@ -13,6 +13,7 @@
#include "libANGLE/Texture.h"
#include "libANGLE/Error.h"
#include "libANGLE/renderer/d3d/TextureStorage.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include <map>
......@@ -103,13 +104,8 @@ class TextureStorage11 : public TextureStorage
unsigned int mMipLevels;
GLenum mInternalFormat;
DXGI_FORMAT mTextureFormat;
DXGI_FORMAT mShaderResourceFormat;
DXGI_FORMAT mRenderTargetFormat;
DXGI_FORMAT mDepthStencilFormat;
DXGI_FORMAT mSwizzleTextureFormat;
DXGI_FORMAT mSwizzleShaderResourceFormat;
DXGI_FORMAT mSwizzleRenderTargetFormat;
d3d11::DXGIFormatSet mTextureFormatSet;
d3d11::DXGIFormatSet mSwizzleFormatSet;
unsigned int mTextureWidth;
unsigned int mTextureHeight;
unsigned int mTextureDepth;
......
......@@ -109,24 +109,32 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
}}
// End Format Support Functions
}} // namespace
DXGIFormatSet::DXGIFormatSet()
: texFormat(DXGI_FORMAT_UNKNOWN),
srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN)
{{
}}
// For sized GL internal formats, there are several possible corresponding D3D11 formats depending
// on device capabilities.
// This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format.
const TextureFormat GetD3D11FormatInfo(GLenum internalFormat,
DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
InitializeTextureDataFunction internalFormatInitializer)
TextureFormat::TextureFormat(GLenum internalFormat,
DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
InitializeTextureDataFunction internalFormatInitializer)
: dataInitializerFunction(internalFormatInitializer)
{{
TextureFormat info;
info.texFormat = texFormat;
info.srvFormat = srvFormat;
info.rtvFormat = rtvFormat;
info.dsvFormat = dsvFormat;
info.dataInitializerFunction = internalFormatInitializer;
formatSet.texFormat = texFormat;
formatSet.srvFormat = srvFormat;
formatSet.rtvFormat = rtvFormat;
formatSet.dsvFormat = dsvFormat;
// Compute the swizzle formats
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
......@@ -158,47 +166,28 @@ const TextureFormat GetD3D11FormatInfo(GLenum internalFormat,
const SwizzleFormatInfo &swizzleInfo =
GetSwizzleFormatInfo(maxBits, formatInfo.componentType);
info.swizzleTexFormat = swizzleInfo.mTexFormat;
info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
swizzleFormatSet.texFormat = swizzleInfo.mTexFormat;
swizzleFormatSet.srvFormat = swizzleInfo.mSRVFormat;
swizzleFormatSet.rtvFormat = swizzleInfo.mRTVFormat;
}}
else
{{
// The original texture format is suitable for swizzle operations
info.swizzleTexFormat = texFormat;
info.swizzleSRVFormat = srvFormat;
info.swizzleRTVFormat = rtvFormat;
swizzleFormatSet = formatSet;
}}
}}
else
{{
// Not possible to swizzle with this texture format since it is either unsized or GL_NONE
info.swizzleTexFormat = DXGI_FORMAT_UNKNOWN;
info.swizzleSRVFormat = DXGI_FORMAT_UNKNOWN;
info.swizzleRTVFormat = DXGI_FORMAT_UNKNOWN;
ASSERT(swizzleFormatSet.texFormat == DXGI_FORMAT_UNKNOWN);
ASSERT(swizzleFormatSet.srvFormat == DXGI_FORMAT_UNKNOWN);
ASSERT(swizzleFormatSet.rtvFormat == DXGI_FORMAT_UNKNOWN);
}}
// Gather all the load functions for this internal format
info.loadFunctions = GetLoadFunctionsMap(internalFormat, texFormat);
ASSERT(info.loadFunctions.size() != 0 || internalFormat == GL_NONE);
loadFunctions = GetLoadFunctionsMap(internalFormat, texFormat);
return info;
}}
}} // namespace
TextureFormat::TextureFormat()
: texFormat(DXGI_FORMAT_UNKNOWN),
srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN),
swizzleTexFormat(DXGI_FORMAT_UNKNOWN),
swizzleSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzleRTVFormat(DXGI_FORMAT_UNKNOWN),
dataInitializerFunction(NULL),
loadFunctions()
{{
ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE);
}}
const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
......@@ -213,7 +202,8 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}}
// clang-format on
static const TextureFormat defaultInfo;
static const TextureFormat defaultInfo(GL_NONE, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, nullptr);
return defaultInfo;
}} // GetTextureFormatInfo
......@@ -312,12 +302,12 @@ def get_texture_format_item(idx, internal_format, requirements_fn, angle_format)
table_data += ' {\n'
indent += ' '
table_data += indent + 'static const TextureFormat textureFormat = GetD3D11FormatInfo(internalFormat,\n'
table_data += indent + ' ' + tex_format + ',\n'
table_data += indent + ' ' + srv_format + ',\n'
table_data += indent + ' ' + rtv_format + ',\n'
table_data += indent + ' ' + dsv_format + ',\n'
table_data += indent + ' ' + internal_format_initializer + ');\n'
table_data += indent + 'static const TextureFormat textureFormat(internalFormat,\n'
table_data += indent + ' ' + tex_format + ',\n'
table_data += indent + ' ' + srv_format + ',\n'
table_data += indent + ' ' + rtv_format + ',\n'
table_data += indent + ' ' + dsv_format + ',\n'
table_data += indent + ' ' + internal_format_initializer + ');\n'
table_data += indent + 'return textureFormat;\n'
if requirements_fn != None:
......
......@@ -358,19 +358,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
}
}
textureCaps.texturable = support.query(formatInfo.texFormat, texSupportMask);
textureCaps.filterable = support.query(formatInfo.srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
textureCaps.renderable = (support.query(formatInfo.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) ||
(support.query(formatInfo.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL));
textureCaps.texturable = support.query(formatInfo.formatSet.texFormat, texSupportMask);
textureCaps.filterable =
support.query(formatInfo.formatSet.srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
textureCaps.renderable =
(support.query(formatInfo.formatSet.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) ||
(support.query(formatInfo.formatSet.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL));
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
if (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.dsvFormat;
renderFormat = formatInfo.formatSet.dsvFormat;
}
else if (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
else if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.rtvFormat;
renderFormat = formatInfo.formatSet.rtvFormat;
}
if (renderFormat != DXGI_FORMAT_UNKNOWN &&
support.query(renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
......@@ -1364,7 +1366,7 @@ void GenerateInitialTextureData(GLint internalFormat,
ASSERT(d3dFormatInfo.dataInitializerFunction != NULL);
const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.texFormat);
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet.texFormat);
outSubresourceData->resize(mipLevels);
outData->resize(mipLevels);
......
......@@ -34,18 +34,29 @@ struct LoadImageFunctionInfo
bool requiresConversion;
};
struct TextureFormat
struct DXGIFormatSet
{
TextureFormat();
DXGIFormatSet();
DXGIFormatSet(const DXGIFormatSet &) = default;
DXGIFormatSet &operator=(const DXGIFormatSet &) = default;
DXGI_FORMAT texFormat;
DXGI_FORMAT srvFormat;
DXGI_FORMAT rtvFormat;
DXGI_FORMAT dsvFormat;
};
DXGI_FORMAT swizzleTexFormat;
DXGI_FORMAT swizzleSRVFormat;
DXGI_FORMAT swizzleRTVFormat;
struct TextureFormat : public angle::NonCopyable
{
TextureFormat(GLenum internalFormat,
DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
InitializeTextureDataFunction internalFormatInitializer);
DXGIFormatSet formatSet;
DXGIFormatSet swizzleFormatSet;
InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,13 +64,15 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
}
UINT texSupport;
bool texSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.texFormat, &texSupport));
bool texSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet.texFormat, &texSupport));
bool textureable = texSuccess && ((texSupport & texSupportMask) == texSupportMask);
EXPECT_EQ(textureable, textureInfo.texturable);
// Bits for filtering
UINT filterSupport;
bool filterSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.srvFormat, &filterSupport));
bool filterSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet.srvFormat, &filterSupport));
bool filterable = filterSuccess && ((filterSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0);
EXPECT_EQ(filterable, textureInfo.filterable);
......@@ -80,25 +82,25 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0)
{
renderFormat = formatInfo.dsvFormat;
bool depthSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.dsvFormat, &renderSupport));
renderFormat = formatInfo.formatSet.dsvFormat;
bool depthSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet.dsvFormat, &renderSupport));
renderable =
depthSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.dsvFormat);
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet.dsvFormat);
}
}
else
{
renderFormat = formatInfo.rtvFormat;
bool rtSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.rtvFormat, &renderSupport));
renderFormat = formatInfo.formatSet.rtvFormat;
bool rtSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet.rtvFormat, &renderSupport));
renderable = rtSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.rtvFormat);
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet.rtvFormat);
}
}
EXPECT_EQ(renderable, textureInfo.renderable);
......
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