Commit 99cdca03 by Olli Etuaho Committed by Commit Bot

Remove getDXGIFormat() function from RenderTarget11

This query would return either the RTV format, the DSV format or the texture format depending on the render target. This made the code hard to understand. getDXGIFormat() calls are replaced by querying the ANGLE format, and explicitly choosing which associated DXGI format to query info for (RTV format or DSV format). This refactoring makes changing some format associations for integer texture formats easier in the future. BUG=angleproject:1244 TEST=angle_end2end_tests, dEQP-GLES3.functional.fbo.blit.* (no regressions) Change-Id: Ibe3c03fc6b7768af1a131d4df3909a1e20a71228 Reviewed-on: https://chromium-review.googlesource.com/329102Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent f706901e
......@@ -327,7 +327,8 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null.");
}
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(renderTarget->getDXGIFormat());
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(
d3d11::GetANGLEFormatSet(renderTarget->getANGLEFormat()).rtvFormat);
// Check if the actual format has a channel that the internal format does not and set them to the
// default values
......@@ -380,7 +381,8 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
return error;
}
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(renderTarget->getDXGIFormat());
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(
d3d11::GetANGLEFormatSet(renderTarget->getANGLEFormat()).dsvFormat);
unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << dxgiFormatInfo.stencilBits) - 1 : 0;
bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
......
......@@ -225,7 +225,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples),
mSubresourceIndex(0),
mTexture(resource),
......@@ -251,10 +250,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
if (mRenderTarget && mTexture)
{
mSubresourceIndex = getRTVSubresourceIndex(mTexture, mRenderTarget);
D3D11_RENDER_TARGET_VIEW_DESC desc;
mRenderTarget->GetDesc(&desc);
mDXGIFormat = desc.Format;
}
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || mWidth == 0 || mHeight == 0);
}
......@@ -273,7 +268,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples),
mSubresourceIndex(0),
mTexture(resource),
......@@ -299,10 +293,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
if (mDepthStencil && mTexture)
{
mSubresourceIndex = getDSVSubresourceIndex(mTexture, mDepthStencil);
D3D11_DEPTH_STENCIL_VIEW_DESC desc;
mDepthStencil->GetDesc(&desc);
mDXGIFormat = desc.Format;
}
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || mWidth == 0 || mHeight == 0);
}
......@@ -365,11 +355,6 @@ unsigned int TextureRenderTarget11::getSubresourceIndex() const
return mSubresourceIndex;
}
DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const
{
return mDXGIFormat;
}
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain,
Renderer11 *renderer,
bool depth)
......@@ -446,10 +431,4 @@ unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
return 0;
}
DXGI_FORMAT SurfaceRenderTarget11::getDXGIFormat() const
{
return d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getRenderer11DeviceCaps())
.formatSet.texFormat;
}
}
......@@ -33,8 +33,6 @@ class RenderTarget11 : public RenderTargetD3D
virtual unsigned int getSubresourceIndex() const = 0;
virtual DXGI_FORMAT getDXGIFormat() const = 0;
void addDirtyCallback(const NotificationCallback *callback);
void removeDirtyCallback(const NotificationCallback *callback);
void signalDirty() override;
......@@ -84,14 +82,11 @@ class TextureRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private:
GLsizei mWidth;
GLsizei mHeight;
GLsizei mDepth;
GLenum mInternalFormat;
DXGI_FORMAT mDXGIFormat;
GLsizei mSamples;
unsigned int mSubresourceIndex;
......@@ -120,8 +115,6 @@ class SurfaceRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private:
// The internal versions of the functions are needed so that they can be safely called
// from the constructor.
......
......@@ -3947,7 +3947,9 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
const auto &destFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat());
const auto &srcFormatInfo = gl::GetInternalFormatInfo(readRenderTarget->getInternalFormat());
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(drawRenderTarget11->getDXGIFormat());
const auto &formatSet = d3d11::GetANGLEFormatSet(drawRenderTarget11->getANGLEFormat());
const DXGI_FORMAT drawDXGIFormat = colorBlit ? formatSet.rtvFormat : formatSet.dsvFormat;
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(drawDXGIFormat);
// 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.
......@@ -3985,7 +3987,7 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
gl::Error result(GL_NO_ERROR);
if (readRenderTarget11->getDXGIFormat() == drawRenderTarget11->getDXGIFormat() &&
if (readRenderTarget11->getANGLEFormat() == drawRenderTarget11->getANGLEFormat() &&
!stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit &&
!colorMaskingNeeded && (!(depthBlit || stencilBlit) || wholeBufferCopy))
{
......
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