Commit a455824c by Geoff Lang

Remove GetAttachmentSerial.

Cascades to remove serials from many objects. BUG=angleproject:970 Change-Id: I0a74a14519da3203cd5df7ae0fa19f83393951ce Reviewed-on: https://chromium-review.googlesource.com/286554Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 35fff1ca
......@@ -370,45 +370,4 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor
return mColorAttachmentsForRender;
}
// Note: RenderTarget serials should ideally be in the RenderTargets themselves.
unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment)
{
if (attachment->type() == GL_TEXTURE)
{
gl::Texture *texture = attachment->getTexture();
ASSERT(texture);
TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture);
const gl::ImageIndex &index = attachment->getTextureImageIndex();
return textureD3D->getRenderTargetSerial(index);
}
else if (attachment->type() == GL_RENDERBUFFER)
{
gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
ASSERT(renderbuffer);
RenderbufferD3D *renderbufferD3D = GetImplAs<RenderbufferD3D>(renderbuffer);
return renderbufferD3D->getRenderTargetSerial();
}
else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT)
{
const egl::Surface *surface = attachment->getSurface();
ASSERT(surface);
const SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface);
ASSERT(surfaceD3D);
if (attachment->getBinding() == GL_BACK)
{
return surfaceD3D->getSwapChain()->getColorRenderTarget()->getSerial();
}
else
{
return surfaceD3D->getSwapChain()->getDepthStencilRenderTarget()->getSerial();
}
}
else
{
UNREACHABLE();
return 0;
}
}
}
......@@ -100,8 +100,6 @@ class FramebufferD3D : public FramebufferImpl
virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0;
};
unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment);
}
#endif // LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
......@@ -70,11 +70,6 @@ RenderTargetD3D *RenderbufferD3D::getRenderTarget()
return mRenderTarget;
}
unsigned int RenderbufferD3D::getRenderTargetSerial() const
{
return (mRenderTarget ? mRenderTarget->getSerial() : 0);
}
gl::Error RenderbufferD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut)
{
......
......@@ -30,7 +30,6 @@ class RenderbufferD3D : public RenderbufferImpl
virtual gl::Error setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height) override;
RenderTargetD3D *getRenderTarget();
unsigned int getRenderTargetSerial() const;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override;
......@@ -39,6 +38,7 @@ class RenderbufferD3D : public RenderbufferImpl
RendererD3D *mRenderer;
RenderTargetD3D *mRenderTarget;
};
}
#endif // LIBANGLE_RENDERER_D3D_RENDERBUFFERD3D_H_
......@@ -981,12 +981,6 @@ void TextureD3D_2D::initMipmapsImages()
}
}
unsigned int TextureD3D_2D::getRenderTargetSerial(const gl::ImageIndex &index)
{
ASSERT(!index.hasLayer());
return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
}
gl::Error TextureD3D_2D::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT)
{
ASSERT(!index.hasLayer());
......@@ -1549,11 +1543,6 @@ void TextureD3D_Cube::initMipmapsImages()
}
}
unsigned int TextureD3D_Cube::getRenderTargetSerial(const gl::ImageIndex &index)
{
return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
}
gl::Error TextureD3D_Cube::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT)
{
ASSERT(gl::IsCubeMapTextureTarget(index.type));
......@@ -2112,11 +2101,6 @@ void TextureD3D_3D::initMipmapsImages()
}
}
unsigned int TextureD3D_3D::getRenderTargetSerial(const gl::ImageIndex &index)
{
return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
}
gl::Error TextureD3D_3D::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT)
{
// ensure the underlying texture is created
......@@ -2666,11 +2650,6 @@ void TextureD3D_2DArray::initMipmapsImages()
}
}
unsigned int TextureD3D_2DArray::getRenderTargetSerial(const gl::ImageIndex &index)
{
return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
}
gl::Error TextureD3D_2DArray::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT)
{
// ensure the underlying texture is created
......
......@@ -50,7 +50,6 @@ class TextureD3D : public TextureImpl
bool isImmutable() const { return mImmutable; }
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) = 0;
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index) = 0;
// Returns an iterator over all "Images" for this particular Texture.
virtual gl::ImageIndexIterator imageIterator() const = 0;
......@@ -149,7 +148,6 @@ class TextureD3D_2D : public TextureD3D
virtual void releaseTexImage();
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
......@@ -212,7 +210,6 @@ class TextureD3D_Cube : public TextureD3D
virtual void releaseTexImage();
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
......@@ -274,7 +271,6 @@ class TextureD3D_3D : public TextureD3D
virtual void releaseTexImage();
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
......@@ -334,7 +330,6 @@ class TextureD3D_2DArray : public TextureD3D
virtual void releaseTexImage();
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
......
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TextureStorage.cpp: Shared members of abstract rx::TextureStorage class.
#include "libANGLE/renderer/d3d/TextureStorage.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/Renderer.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Texture.h"
#include "common/debug.h"
#include "common/mathutil.h"
namespace rx
{
TextureStorage::TextureStorage()
: mFirstRenderTargetSerial(0),
mRenderTargetSerialsLayerStride(0)
{}
void TextureStorage::initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride)
{
mFirstRenderTargetSerial = RenderTargetD3D::issueSerials(rtSerialsToReserve);
mRenderTargetSerialsLayerStride = rtSerialsLayerStride;
}
unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) const
{
unsigned int layerOffset = (index.hasLayer() ? (static_cast<unsigned int>(index.layerIndex) * mRenderTargetSerialsLayerStride) : 0);
return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
}
}
......@@ -33,8 +33,8 @@ class ImageD3D;
class TextureStorage : angle::NonCopyable
{
public:
TextureStorage();
virtual ~TextureStorage() {};
TextureStorage() {}
virtual ~TextureStorage() {}
virtual int getTopLevel() const = 0;
virtual bool isRenderTarget() const = 0;
......@@ -49,18 +49,8 @@ class TextureStorage : angle::NonCopyable
virtual gl::Error setData(const gl::ImageIndex &index, ImageD3D *image, const gl::Box *destBox, GLenum type,
const gl::PixelUnpackState &unpack, const uint8_t *pixelData) = 0;
unsigned int getRenderTargetSerial(const gl::ImageIndex &index) const;
unsigned int getTextureSerial() const;
// This is a no-op for most implementations of TextureStorage. Some (e.g. TextureStorage11_2D) might override it.
virtual gl::Error useLevelZeroWorkaroundTexture(bool useLevelZeroTexture) { return gl::Error(GL_NO_ERROR); }
protected:
void initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride);
private:
unsigned int mFirstRenderTargetSerial;
unsigned int mRenderTargetSerialsLayerStride;
};
}
......
......@@ -717,8 +717,6 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swap
mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
mDepthStencilFormat = DXGI_FORMAT_UNKNOWN;
initializeSerials(1, 1);
}
TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels, bool hintLevelZeroOnly)
......@@ -761,8 +759,6 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, GLenum internalfo
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
mUseLevelZeroTexture = true;
}
initializeSerials(getLevelCount(), 1);
}
TextureStorage11_2D::~TextureStorage11_2D()
......@@ -1360,8 +1356,6 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer, GLenum intern
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
mUseLevelZeroTexture = true;
}
initializeSerials(getLevelCount() * CUBE_FACE_COUNT, CUBE_FACE_COUNT);
}
TextureStorage11_Cube::~TextureStorage11_Cube()
......@@ -2027,8 +2021,6 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer, GLenum internalfo
mTextureWidth = width;
mTextureHeight = height;
mTextureDepth = depth;
initializeSerials(getLevelCount() * depth, depth);
}
TextureStorage11_3D::~TextureStorage11_3D()
......@@ -2407,8 +2399,6 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer, GLenum
mTextureWidth = width;
mTextureHeight = height;
mTextureDepth = depth;
initializeSerials(getLevelCount() * depth, depth);
}
TextureStorage11_2DArray::~TextureStorage11_2DArray()
......
......@@ -1319,19 +1319,19 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorAtt
size_t renderTargetHeight = 0;
D3DFORMAT renderTargetFormat = D3DFMT_UNKNOWN;
RenderTarget9 *renderTarget = nullptr;
gl::Error error = renderAttachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ASSERT(renderTarget);
bool renderTargetChanged = false;
unsigned int renderTargetSerial = GetAttachmentSerial(renderAttachment);
unsigned int renderTargetSerial = renderTarget->getSerial();
if (renderTargetSerial != mAppliedRenderTargetSerial)
{
// Apply the render target on the device
RenderTarget9 *renderTarget = nullptr;
gl::Error error = renderAttachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ASSERT(renderTarget);
IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface();
ASSERT(renderTargetSurface);
......@@ -1346,24 +1346,29 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorAtt
renderTargetChanged = true;
}
unsigned int depthStencilSerial = (depthStencilAttachment != nullptr) ?
GetAttachmentSerial(depthStencilAttachment) : 0;
RenderTarget9 *depthStencilRenderTarget = nullptr;
unsigned int depthStencilSerial = 0;
if (depthStencilAttachment != nullptr)
{
gl::Error error = depthStencilAttachment->getRenderTarget(&depthStencilRenderTarget);
if (error.isError())
{
return error;
}
ASSERT(depthStencilRenderTarget);
depthStencilSerial = depthStencilRenderTarget->getSerial();
}
if (depthStencilSerial != mAppliedDepthStencilSerial || !mDepthStencilInitialized)
{
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
// Apply the depth stencil on the device
if (depthStencilAttachment)
if (depthStencilRenderTarget)
{
RenderTarget9 *depthStencilRenderTarget = nullptr;
gl::Error error = depthStencilAttachment->getRenderTarget(&depthStencilRenderTarget);
if (error.isError())
{
return error;
}
ASSERT(depthStencilRenderTarget);
IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface();
ASSERT(depthStencilSurface);
......
......@@ -114,8 +114,6 @@ TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchai
mTextureFormat = surfaceDesc.Format;
mRenderTarget = NULL;
initializeSerials(1, 1);
}
TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
......@@ -133,8 +131,6 @@ TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, GLenum internalforma
mTextureWidth = width;
mTextureHeight = height;
mMipLevels = mTopLevel + levels;
initializeSerials(getLevelCount(), 1);
}
TextureStorage9_2D::~TextureStorage9_2D()
......@@ -298,8 +294,6 @@ TextureStorage9_Cube::TextureStorage9_Cube(Renderer9 *renderer, GLenum internalf
mTextureWidth = size;
mTextureHeight = size;
mMipLevels = mTopLevel + levels;
initializeSerials(getLevelCount() * CUBE_FACE_COUNT, CUBE_FACE_COUNT);
}
TextureStorage9_Cube::~TextureStorage9_Cube()
......
......@@ -211,7 +211,6 @@
'libANGLE/renderer/d3d/SwapChainD3D.h',
'libANGLE/renderer/d3d/TextureD3D.cpp',
'libANGLE/renderer/d3d/TextureD3D.h',
'libANGLE/renderer/d3d/TextureStorage.cpp',
'libANGLE/renderer/d3d/TextureStorage.h',
'libANGLE/renderer/d3d/TransformFeedbackD3D.cpp',
'libANGLE/renderer/d3d/TransformFeedbackD3D.h',
......
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