Commit 17b10a9a by Jamie Madill Committed by Commit Bot

D3D11: Store more format info by-reference.

This CL stores the d3d11::TextureFormat by reference in the texture storage. Adding the internalFormat to the TextureFormat allows us to store a single ref instead of three per TextureStorage11. Also store the format sets in a d3d11::TextureFormat by-ref instead of by-pointer, making the code a bit cleaner. BUG=angleproject:1455 Change-Id: I3c0e966d948c694435577d7d45dc0cd156480cdb Reviewed-on: https://chromium-review.googlesource.com/365412Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 3416ff3e
......@@ -44,8 +44,8 @@ class SwapChainD3D : angle::NonCopyable
virtual RenderTargetD3D *getColorRenderTarget() = 0;
virtual RenderTargetD3D *getDepthStencilRenderTarget() = 0;
GLenum GetRenderTargetInternalFormat() const { return mOffscreenRenderTargetFormat; }
GLenum GetDepthBufferInternalFormat() const { return mDepthBufferFormat; }
GLenum getRenderTargetInternalFormat() const { return mOffscreenRenderTargetFormat; }
GLenum getDepthBufferInternalFormat() const { return mDepthBufferFormat; }
HANDLE getShareHandle() { return mShareHandle; }
virtual void *getKeyedMutex() = 0;
......
......@@ -68,7 +68,7 @@ gl::Error Image11::generateMipmap(Image11 *dest,
uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData);
auto mipGenerationFunction = d3d11::GetTextureFormatInfo(src->getInternalFormat(), rendererCaps)
.formatSet->mipGenerationFunction;
.formatSet.mipGenerationFunction;
mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(), sourceData,
srcMapped.RowPitch, srcMapped.DepthPitch, destData, destMapped.RowPitch,
destMapped.DepthPitch);
......@@ -222,8 +222,8 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &
// compute the d3d format that will be used
const d3d11::TextureFormat &formatInfo =
d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps());
mDXGIFormat = formatInfo.formatSet->texFormat;
mRenderable = (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
mDXGIFormat = formatInfo.formatSet.texFormat;
mRenderable = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN);
releaseStagingTexture();
mDirty = (formatInfo.dataInitializerFunction != NULL);
......@@ -360,7 +360,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const auto &d3d11Format =
d3d11::GetTextureFormatInfo(sourceInternalFormat, mRenderer->getRenderer11DeviceCaps());
if (d3d11Format.formatSet->texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
if (d3d11Format.formatSet.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
{
RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
......
......@@ -197,7 +197,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.formatSet->srvFormat;
DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet.srvFormat;
ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
Buffer11 *bufferStorage11 = GetAs<Buffer11>(sourceBuffer.getImplementation());
ID3D11ShaderResourceView *bufferSRV = nullptr;
......
......@@ -182,17 +182,17 @@ unsigned int GetDSVSubresourceIndex(ID3D11Resource *resource, ID3D11DepthStencil
GLenum GetSurfaceRTFormat(bool depth, SwapChain11 *swapChain)
{
return (depth ? swapChain->GetDepthBufferInternalFormat()
: swapChain->GetRenderTargetInternalFormat());
return (depth ? swapChain->getDepthBufferInternalFormat()
: swapChain->getRenderTargetInternalFormat());
}
const d3d11::ANGLEFormatSet &GetSurfaceFormatSet(bool depth,
SwapChain11 *swapChain,
Renderer11 *renderer)
{
return *d3d11::GetTextureFormatInfo(GetSurfaceRTFormat(depth, swapChain),
renderer->getRenderer11DeviceCaps())
.formatSet;
return d3d11::GetTextureFormatInfo(GetSurfaceRTFormat(depth, swapChain),
renderer->getRenderer11DeviceCaps())
.formatSet;
}
} // anonymous namespace
......
......@@ -3136,7 +3136,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
desc.Height = height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = formatInfo.formatSet->texFormat;
desc.Format = formatInfo.formatSet.texFormat;
desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
......@@ -3147,9 +3147,9 @@ 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.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN);
bindSRV = (formatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN);
bindRTV = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN);
bindSRV = (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN);
desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
(bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) |
......@@ -3171,7 +3171,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindSRV)
{
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = formatInfo.formatSet->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;
......@@ -3184,10 +3184,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target shader resource view, result: 0x%X.", result);
}
if (formatInfo.formatSet->blitSRVFormat != formatInfo.formatSet->srvFormat)
if (formatInfo.formatSet.blitSRVFormat != formatInfo.formatSet.srvFormat)
{
D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc;
blitSRVDesc.Format = formatInfo.formatSet->blitSRVFormat;
blitSRVDesc.Format = formatInfo.formatSet.blitSRVFormat;
blitSRVDesc.ViewDimension = (supportedSamples == 0)
? D3D11_SRV_DIMENSION_TEXTURE2D
: D3D11_SRV_DIMENSION_TEXTURE2DMS;
......@@ -3216,7 +3216,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindDSV)
{
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = formatInfo.formatSet->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;
......@@ -3232,7 +3232,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result);
}
*outRT = new TextureRenderTarget11(dsv, texture, srv, format, *formatInfo.formatSet,
*outRT = new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet,
width, height, 1, supportedSamples);
SafeRelease(dsv);
......@@ -3240,7 +3240,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
else if (bindRTV)
{
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = formatInfo.formatSet->rtvFormat;
rtvDesc.Format = formatInfo.formatSet.rtvFormat;
rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS;
rtvDesc.Texture2D.MipSlice = 0;
......@@ -3262,7 +3262,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
}
*outRT =
new TextureRenderTarget11(rtv, texture, srv, blitSRV, format, *formatInfo.formatSet,
new TextureRenderTarget11(rtv, texture, srv, blitSRV, format, formatInfo.formatSet,
width, height, 1, supportedSamples);
SafeRelease(rtv);
......@@ -3526,7 +3526,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
}
// We cannot support direct copies to non-color-renderable formats
if (d3d11FormatInfo.formatSet->rtvFormat == DXGI_FORMAT_UNKNOWN)
if (d3d11FormatInfo.formatSet.rtvFormat == DXGI_FORMAT_UNKNOWN)
{
return false;
}
......@@ -3538,7 +3538,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
}
// We don't support formats which we can't represent without conversion
if (d3d11FormatInfo.formatSet->glInternalFormat != internalFormat)
if (d3d11FormatInfo.formatSet.glInternalFormat != internalFormat)
{
return false;
}
......
......@@ -209,7 +209,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
if (offscreenTextureDesc.Width != (UINT)backbufferWidth ||
offscreenTextureDesc.Height != (UINT)backbufferHeight ||
offscreenTextureDesc.Format != backbufferFormatInfo.formatSet->texFormat ||
offscreenTextureDesc.Format != backbufferFormatInfo.formatSet.texFormat ||
offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1)
{
ERR("Invalid texture parameters in the shared offscreen texture pbuffer");
......@@ -225,7 +225,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
offscreenTextureDesc.Width = backbufferWidth;
offscreenTextureDesc.Height = backbufferHeight;
offscreenTextureDesc.Format = backbufferFormatInfo.formatSet->texFormat;
offscreenTextureDesc.Format = backbufferFormatInfo.formatSet.texFormat;
offscreenTextureDesc.MipLevels = 1;
offscreenTextureDesc.ArraySize = 1;
offscreenTextureDesc.SampleDesc.Count = 1;
......@@ -283,7 +283,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
mKeyedMutex = d3d11::DynamicCastComObject<IDXGIKeyedMutex>(mOffscreenTexture);
D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc;
offscreenRTVDesc.Format = backbufferFormatInfo.formatSet->rtvFormat;
offscreenRTVDesc.Format = backbufferFormatInfo.formatSet.rtvFormat;
offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
offscreenRTVDesc.Texture2D.MipSlice = 0;
......@@ -292,7 +292,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.formatSet->srvFormat;
offscreenSRVDesc.Format = backbufferFormatInfo.formatSet.srvFormat;
offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
offscreenSRVDesc.Texture2D.MostDetailedMip = 0;
offscreenSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
......@@ -339,7 +339,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
depthStencilTextureDesc.Width = backbufferWidth;
depthStencilTextureDesc.Height = backbufferHeight;
depthStencilTextureDesc.Format = depthBufferFormatInfo.formatSet->texFormat;
depthStencilTextureDesc.Format = depthBufferFormatInfo.formatSet.texFormat;
depthStencilTextureDesc.MipLevels = 1;
depthStencilTextureDesc.ArraySize = 1;
depthStencilTextureDesc.SampleDesc.Count = 1;
......@@ -347,7 +347,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
if (depthBufferFormatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN)
{
depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
}
......@@ -375,7 +375,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture");
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
depthStencilDesc.Format = depthBufferFormatInfo.formatSet->dsvFormat;
depthStencilDesc.Format = depthBufferFormatInfo.formatSet.dsvFormat;
depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilDesc.Flags = 0;
depthStencilDesc.Texture2D.MipSlice = 0;
......@@ -384,10 +384,10 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
ASSERT(SUCCEEDED(result));
d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view");
if (depthBufferFormatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN)
{
D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet->srvFormat;
depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet.srvFormat;
depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
depthStencilSRVDesc.Texture2D.MostDetailedMip = 0;
depthStencilSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
......@@ -489,7 +489,7 @@ DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const
return (mOffscreenRenderTargetFormat == GL_BGRA8_EXT) ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM;
}
EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swapInterval)
EGLint SwapChain11::reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval)
{
mSwapInterval = static_cast<unsigned int>(swapInterval);
if (mSwapInterval > 4)
......@@ -876,4 +876,4 @@ void SwapChain11::recreate()
// possibly should use this method instead of reset
}
}
} // namespace rx
......@@ -18,7 +18,7 @@ namespace rx
class Renderer11;
class NativeWindow11;
class SwapChain11 : public SwapChainD3D
class SwapChain11 final : public SwapChainD3D
{
public:
SwapChain11(Renderer11 *renderer,
......@@ -30,20 +30,20 @@ class SwapChain11 : public SwapChainD3D
virtual ~SwapChain11();
EGLint resize(EGLint backbufferWidth, EGLint backbufferHeight);
virtual EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval);
virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
virtual void recreate();
EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval) override;
EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height) override;
void recreate() override;
RenderTargetD3D *getColorRenderTarget() override { return &mColorRenderTarget; }
RenderTargetD3D *getDepthStencilRenderTarget() override { return &mDepthStencilRenderTarget; }
virtual ID3D11Texture2D *getOffscreenTexture();
virtual ID3D11RenderTargetView *getRenderTarget();
virtual ID3D11ShaderResourceView *getRenderTargetShaderResource();
ID3D11Texture2D *getOffscreenTexture();
ID3D11RenderTargetView *getRenderTarget();
ID3D11ShaderResourceView *getRenderTargetShaderResource();
virtual ID3D11Texture2D *getDepthStencilTexture();
virtual ID3D11DepthStencilView *getDepthStencil();
virtual ID3D11ShaderResourceView *getDepthStencilShaderResource();
ID3D11Texture2D *getDepthStencilTexture();
ID3D11DepthStencilView *getDepthStencil();
ID3D11ShaderResourceView *getDepthStencilShaderResource();
EGLint getWidth() const { return mWidth; }
EGLint getHeight() const { return mHeight; }
......@@ -103,5 +103,5 @@ class SwapChain11 : public SwapChainD3D
SurfaceRenderTarget11 mDepthStencilRenderTarget;
};
}
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_
......@@ -82,7 +82,7 @@ class TextureStorage11 : public TextureStorage
const d3d11::ANGLEFormatSet &getFormatSet() const;
protected:
TextureStorage11(Renderer11 *renderer, UINT bindFlags, UINT miscFlags);
TextureStorage11(Renderer11 *renderer, UINT bindFlags, UINT miscFlags, GLenum internalFormat);
int getLevelWidth(int mipLevel) const;
int getLevelHeight(int mipLevel) const;
int getLevelDepth(int mipLevel) const;
......@@ -107,9 +107,7 @@ class TextureStorage11 : public TextureStorage
int mTopLevel;
unsigned int mMipLevels;
GLenum mInternalFormat;
const d3d11::ANGLEFormatSet *mTextureFormatSet;
const d3d11::ANGLEFormatSet *mSwizzleFormatSet;
const d3d11::TextureFormat &mFormatInfo;
unsigned int mTextureWidth;
unsigned int mTextureHeight;
unsigned int mTextureDepth;
......
......@@ -364,21 +364,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
}
}
textureCaps.texturable = support.query(formatInfo.formatSet->texFormat, texSupportMask);
textureCaps.texturable = support.query(formatInfo.formatSet.texFormat, texSupportMask);
textureCaps.filterable =
support.query(formatInfo.formatSet->srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
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));
(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.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN)
if (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.formatSet->dsvFormat;
renderFormat = formatInfo.formatSet.dsvFormat;
}
else if (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN)
else if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN)
{
renderFormat = formatInfo.formatSet->rtvFormat;
renderFormat = formatInfo.formatSet.rtvFormat;
}
if (renderFormat != DXGI_FORMAT_UNKNOWN &&
support.query(renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
......@@ -1372,7 +1372,7 @@ void GenerateInitialTextureData(GLint internalFormat,
ASSERT(d3dFormatInfo.dataInitializerFunction != NULL);
const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet->texFormat);
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet.texFormat);
outSubresourceData->resize(mipLevels);
outData->resize(mipLevels);
......
......@@ -63,15 +63,13 @@ TextureFormat::TextureFormat(GLenum internalFormat,
const ANGLEFormat angleFormat,
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps)
: dataInitializerFunction(internalFormatInitializer)
: internalFormat(internalFormat),
formatSet(GetANGLEFormatSet(angleFormat, deviceCaps)),
swizzleFormatSet(GetANGLEFormatSet(formatSet.swizzleFormat, deviceCaps)),
dataInitializerFunction(internalFormatInitializer),
loadFunctions(GetLoadFunctionsMap(internalFormat, formatSet.texFormat))
{
formatSet = &GetANGLEFormatSet(angleFormat, deviceCaps);
swizzleFormatSet = &GetANGLEFormatSet(formatSet->swizzleFormat, deviceCaps);
// Gather all the load functions for this internal format
loadFunctions = GetLoadFunctionsMap(internalFormat, formatSet->texFormat);
ASSERT(loadFunctions.size() != 0 || angleFormat == ANGLE_FORMAT_NONE);
ASSERT(!loadFunctions.empty() || angleFormat == ANGLE_FORMAT_NONE);
}
} // namespace d3d11
......
......@@ -84,8 +84,9 @@ struct TextureFormat : public angle::NonCopyable
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps);
const ANGLEFormatSet *formatSet;
const ANGLEFormatSet *swizzleFormatSet;
GLenum internalFormat;
const ANGLEFormatSet &formatSet;
const ANGLEFormatSet &swizzleFormatSet;
InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
......
......@@ -130,7 +130,8 @@ GLsizei SurfaceRenderTarget9::getDepth() const
GLenum SurfaceRenderTarget9::getInternalFormat() const
{
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetRenderTargetInternalFormat());
return (mDepth ? mSwapChain->getDepthBufferInternalFormat()
: mSwapChain->getRenderTargetInternalFormat());
}
GLsizei SurfaceRenderTarget9::getSamples() const
......
......@@ -107,7 +107,7 @@ TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchai
mTexture = surfaceTexture;
mMipLevels = surfaceTexture->GetLevelCount();
mInternalFormat = swapchain->GetRenderTargetInternalFormat();
mInternalFormat = swapchain->getRenderTargetInternalFormat();
D3DSURFACE_DESC surfaceDesc;
surfaceTexture->GetLevelDesc(0, &surfaceDesc);
......
......@@ -67,14 +67,14 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
UINT texSupport;
bool texSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet->texFormat, &texSupport));
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.formatSet->srvFormat, &filterSupport));
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet.srvFormat, &filterSupport));
bool filterable = filterSuccess && ((filterSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0);
EXPECT_EQ(filterable, textureInfo.filterable);
......@@ -84,25 +84,25 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0)
{
renderFormat = formatInfo.formatSet->dsvFormat;
renderFormat = formatInfo.formatSet.dsvFormat;
bool depthSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet->dsvFormat, &renderSupport));
device->CheckFormatSupport(formatInfo.formatSet.dsvFormat, &renderSupport));
renderable =
depthSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet->dsvFormat);
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet.dsvFormat);
}
}
else
{
renderFormat = formatInfo.formatSet->rtvFormat;
renderFormat = formatInfo.formatSet.rtvFormat;
bool rtSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet->rtvFormat, &renderSupport));
device->CheckFormatSupport(formatInfo.formatSet.rtvFormat, &renderSupport));
renderable = rtSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0);
if (renderable)
{
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet->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