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 ...@@ -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."); 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 // Check if the actual format has a channel that the internal format does not and set them to the
// default values // default values
...@@ -380,7 +381,8 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl ...@@ -380,7 +381,8 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
return error; 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; unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << dxgiFormatInfo.stencilBits) - 1 : 0;
bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked; bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
......
...@@ -225,7 +225,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ...@@ -225,7 +225,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mHeight(height), mHeight(height),
mDepth(depth), mDepth(depth),
mInternalFormat(internalFormat), mInternalFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples), mSamples(samples),
mSubresourceIndex(0), mSubresourceIndex(0),
mTexture(resource), mTexture(resource),
...@@ -251,10 +250,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ...@@ -251,10 +250,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
if (mRenderTarget && mTexture) if (mRenderTarget && mTexture)
{ {
mSubresourceIndex = getRTVSubresourceIndex(mTexture, mRenderTarget); 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); ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || mWidth == 0 || mHeight == 0);
} }
...@@ -273,7 +268,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ...@@ -273,7 +268,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
mHeight(height), mHeight(height),
mDepth(depth), mDepth(depth),
mInternalFormat(internalFormat), mInternalFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples), mSamples(samples),
mSubresourceIndex(0), mSubresourceIndex(0),
mTexture(resource), mTexture(resource),
...@@ -299,10 +293,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ...@@ -299,10 +293,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
if (mDepthStencil && mTexture) if (mDepthStencil && mTexture)
{ {
mSubresourceIndex = getDSVSubresourceIndex(mTexture, mDepthStencil); 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); ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || mWidth == 0 || mHeight == 0);
} }
...@@ -365,11 +355,6 @@ unsigned int TextureRenderTarget11::getSubresourceIndex() const ...@@ -365,11 +355,6 @@ unsigned int TextureRenderTarget11::getSubresourceIndex() const
return mSubresourceIndex; return mSubresourceIndex;
} }
DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const
{
return mDXGIFormat;
}
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain,
Renderer11 *renderer, Renderer11 *renderer,
bool depth) bool depth)
...@@ -446,10 +431,4 @@ unsigned int SurfaceRenderTarget11::getSubresourceIndex() const ...@@ -446,10 +431,4 @@ unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
return 0; return 0;
} }
DXGI_FORMAT SurfaceRenderTarget11::getDXGIFormat() const
{
return d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getRenderer11DeviceCaps())
.formatSet.texFormat;
}
} }
...@@ -33,8 +33,6 @@ class RenderTarget11 : public RenderTargetD3D ...@@ -33,8 +33,6 @@ class RenderTarget11 : public RenderTargetD3D
virtual unsigned int getSubresourceIndex() const = 0; virtual unsigned int getSubresourceIndex() const = 0;
virtual DXGI_FORMAT getDXGIFormat() const = 0;
void addDirtyCallback(const NotificationCallback *callback); void addDirtyCallback(const NotificationCallback *callback);
void removeDirtyCallback(const NotificationCallback *callback); void removeDirtyCallback(const NotificationCallback *callback);
void signalDirty() override; void signalDirty() override;
...@@ -84,14 +82,11 @@ class TextureRenderTarget11 : public RenderTarget11 ...@@ -84,14 +82,11 @@ class TextureRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override; unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private: private:
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLsizei mDepth; GLsizei mDepth;
GLenum mInternalFormat; GLenum mInternalFormat;
DXGI_FORMAT mDXGIFormat;
GLsizei mSamples; GLsizei mSamples;
unsigned int mSubresourceIndex; unsigned int mSubresourceIndex;
...@@ -120,8 +115,6 @@ class SurfaceRenderTarget11 : public RenderTarget11 ...@@ -120,8 +115,6 @@ class SurfaceRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override; unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private: private:
// The internal versions of the functions are needed so that they can be safely called // The internal versions of the functions are needed so that they can be safely called
// from the constructor. // from the constructor.
......
...@@ -3947,7 +3947,9 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, ...@@ -3947,7 +3947,9 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
const auto &destFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat()); const auto &destFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat());
const auto &srcFormatInfo = gl::GetInternalFormatInfo(readRenderTarget->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 // 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. // 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, ...@@ -3985,7 +3987,7 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
gl::Error result(GL_NO_ERROR); gl::Error result(GL_NO_ERROR);
if (readRenderTarget11->getDXGIFormat() == drawRenderTarget11->getDXGIFormat() && if (readRenderTarget11->getANGLEFormat() == drawRenderTarget11->getANGLEFormat() &&
!stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit && !stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit &&
!colorMaskingNeeded && (!(depthBlit || stencilBlit) || wholeBufferCopy)) !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