Commit 804e8436 by Jamie Madill

Query attachment render targets from Impl class.

This allows us to eradicate the GetAttachmentRenderTarget methods. This improves potential performance, at the cost of exposing a Renderer-specific function at the API object level. BUG=angleproject:963 Change-Id: Ifc227b5f42e87bd4deb451d685618cf61fea39f1 Reviewed-on: https://chromium-review.googlesource.com/263491Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 26e1a466
......@@ -12,6 +12,7 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/ImageIndex.h"
#include "libANGLE/RefCountObject.h"
......@@ -20,6 +21,20 @@ namespace egl
class Surface;
}
namespace rx
{
// An implementation-specific object associated with an attachment.
class FramebufferAttachmentRenderTarget : angle::NonCopyable
{
public:
FramebufferAttachmentRenderTarget() {}
virtual ~FramebufferAttachmentRenderTarget() {}
};
class FramebufferAttachmentObjectImpl;
}
namespace gl
{
class FramebufferAttachmentObject;
......@@ -119,7 +134,20 @@ class FramebufferAttachment final
Texture *getTexture() const;
const egl::Surface *getSurface() const;
// "T" must be static_castable from FramebufferAttachmentRenderTarget
template <typename T>
gl::Error getRenderTarget(T **rtOut) const
{
// Cast through the pointer-to-pointer type
rx::FramebufferAttachmentRenderTarget *rtPtr = nullptr;
gl::Error error = getRenderTarget(&rtPtr);
*rtOut = static_cast<T*>(rtPtr);
return error;
}
private:
gl::Error getRenderTarget(rx::FramebufferAttachmentRenderTarget **rtOut) const;
GLenum mType;
Target mTarget;
BindingPointer<FramebufferAttachmentObject> mResource;
......@@ -135,6 +163,12 @@ class FramebufferAttachmentObject : public RefCountObject
virtual GLsizei getAttachmentHeight(const FramebufferAttachment::Target &target) const = 0;
virtual GLenum getAttachmentInternalFormat(const FramebufferAttachment::Target &target) const = 0;
virtual GLsizei getAttachmentSamples(const FramebufferAttachment::Target &target) const = 0;
Error getAttachmentRenderTarget(const FramebufferAttachment::Target &target,
rx::FramebufferAttachmentRenderTarget **rtOut) const;
protected:
virtual rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const = 0;
};
inline GLsizei FramebufferAttachment::getWidth() const
......@@ -157,6 +191,38 @@ inline GLsizei FramebufferAttachment::getSamples() const
return mResource->getAttachmentSamples(mTarget);
}
inline gl::Error FramebufferAttachment::getRenderTarget(rx::FramebufferAttachmentRenderTarget **rtOut) const
{
return mResource->getAttachmentRenderTarget(mTarget, rtOut);
}
} // namespace gl
namespace rx
{
class FramebufferAttachmentObjectImpl : angle::NonCopyable
{
public:
FramebufferAttachmentObjectImpl() {}
virtual ~FramebufferAttachmentObjectImpl() {}
virtual gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) = 0;
};
} // namespace rx
namespace gl
{
inline Error FramebufferAttachmentObject::getAttachmentRenderTarget(
const FramebufferAttachment::Target &target,
rx::FramebufferAttachmentRenderTarget **rtOut) const
{
return getAttachmentImpl()->getAttachmentRenderTarget(target, rtOut);
}
}
#endif // LIBANGLE_FRAMEBUFFERATTACHMENT_H_
......@@ -15,7 +15,6 @@
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/RenderbufferImpl.h"
namespace gl
{
......
......@@ -15,11 +15,7 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
namespace rx
{
class RenderbufferImpl;
}
#include "libANGLE/renderer/RenderbufferImpl.h"
namespace gl
{
......@@ -58,6 +54,8 @@ class Renderbuffer : public FramebufferAttachmentObject
GLsizei getAttachmentSamples(const FramebufferAttachment::Target &/*target*/) const override { return getSamples(); }
private:
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mRenderbuffer; }
rx::RenderbufferImpl *mRenderbuffer;
GLsizei mWidth;
......
......@@ -12,7 +12,6 @@
#include "libANGLE/Config.h"
#include "libANGLE/Texture.h"
#include "libANGLE/renderer/SurfaceImpl.h"
#include <EGL/eglext.h>
......
......@@ -16,17 +16,13 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace gl
{
class Texture;
}
namespace rx
{
class SurfaceImpl;
}
namespace egl
{
class AttributeMap;
......@@ -76,6 +72,7 @@ class Surface final : public gl::FramebufferAttachmentObject
private:
virtual ~Surface();
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mImplementation; }
rx::SurfaceImpl *mImplementation;
......
......@@ -29,6 +29,7 @@ class MockSurfaceImpl : public rx::SurfaceImpl
MOCK_CONST_METHOD0(getWidth, EGLint());
MOCK_CONST_METHOD0(getHeight, EGLint());
MOCK_CONST_METHOD0(isPostSubBufferSupported, EGLint(void));
MOCK_METHOD2(getAttachmentRenderTarget, gl::Error(const gl::FramebufferAttachment::Target &, rx::FramebufferAttachmentRenderTarget **));
MOCK_METHOD0(destroy, void());
};
......
......@@ -14,7 +14,6 @@
#include "libANGLE/Data.h"
#include "libANGLE/Surface.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/TextureImpl.h"
namespace gl
{
......
......@@ -19,17 +19,13 @@
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/TextureImpl.h"
namespace egl
{
class Surface;
}
namespace rx
{
class TextureImpl;
}
namespace gl
{
class Framebuffer;
......@@ -101,6 +97,7 @@ class Texture final : public FramebufferAttachmentObject
GLsizei getAttachmentSamples(const FramebufferAttachment::Target &target) const override;
private:
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mTexture; }
static unsigned int issueTextureSerial();
rx::TextureImpl *mTexture;
......
......@@ -12,11 +12,12 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
namespace rx
{
class RenderbufferImpl : angle::NonCopyable
class RenderbufferImpl : public FramebufferAttachmentObjectImpl
{
public:
RenderbufferImpl();
......
......@@ -11,6 +11,7 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
namespace egl
{
......@@ -21,7 +22,7 @@ struct Config;
namespace rx
{
class SurfaceImpl : angle::NonCopyable
class SurfaceImpl : public FramebufferAttachmentObjectImpl
{
public:
SurfaceImpl();
......
......@@ -14,6 +14,7 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/ImageIndex.h"
namespace egl
......@@ -35,7 +36,7 @@ struct SamplerState;
namespace rx
{
class TextureImpl : angle::NonCopyable
class TextureImpl : public FramebufferAttachmentObjectImpl
{
public:
TextureImpl() {}
......
......@@ -226,7 +226,7 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const
}
RenderTargetD3D *attachmentRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(readAttachment, &attachmentRenderTarget);
gl::Error error = readAttachment->getRenderTarget(&attachmentRenderTarget);
if (error.isError())
{
return GL_NONE;
......@@ -248,7 +248,7 @@ GLenum FramebufferD3D::getImplementationColorReadType() const
}
RenderTargetD3D *attachmentRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(readAttachment, &attachmentRenderTarget);
gl::Error error = readAttachment->getRenderTarget(&attachmentRenderTarget);
if (error.isError())
{
return GL_NONE;
......@@ -376,48 +376,6 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor
return mColorAttachmentsForRender;
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTargetD3D **outRT)
{
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->getRenderTarget(index, outRT);
}
else if (attachment->type() == GL_RENDERBUFFER)
{
gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
ASSERT(renderbuffer);
RenderbufferD3D *renderbufferD3D = GetImplAs<RenderbufferD3D>(renderbuffer);
*outRT = renderbufferD3D->getRenderTarget();
return gl::Error(GL_NO_ERROR);
}
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)
{
*outRT = surfaceD3D->getSwapChain()->getColorRenderTarget();
}
else
{
*outRT = surfaceD3D->getSwapChain()->getDepthStencilRenderTarget();
}
return gl::Error(GL_NO_ERROR);
}
else
{
UNREACHABLE();
return gl::Error(GL_INVALID_OPERATION);
}
}
// Note: RenderTarget serials should ideally be in the RenderTargets themselves.
unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment)
{
......
......@@ -106,7 +106,6 @@ class FramebufferD3D : public FramebufferImpl
virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0;
};
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTargetD3D **outRT);
unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment);
}
......
......@@ -13,6 +13,7 @@
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
namespace rx
{
......@@ -30,11 +31,11 @@ ImageD3D::ImageD3D()
gl::Error ImageD3D::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source)
{
const gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer();
ASSERT(colorbuffer);
const gl::FramebufferAttachment *srcAttachment = source->getReadColorbuffer();
ASSERT(srcAttachment);
RenderTargetD3D *renderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(colorbuffer, &renderTarget);
gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......
......@@ -12,11 +12,12 @@
#include "common/angleutils.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/FramebufferAttachment.h"
namespace rx
{
class RenderTargetD3D : angle::NonCopyable
class RenderTargetD3D : public FramebufferAttachmentRenderTarget
{
public:
RenderTargetD3D();
......
......@@ -75,4 +75,11 @@ unsigned int RenderbufferD3D::getRenderTargetSerial() const
return (mRenderTarget ? mRenderTarget->getSerial() : 0);
}
gl::Error RenderbufferD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut)
{
*rtOut = mRenderTarget;
return gl::Error(GL_NO_ERROR);
}
}
......@@ -32,6 +32,9 @@ class RenderbufferD3D : public RenderbufferImpl
RenderTargetD3D *getRenderTarget();
unsigned int getRenderTargetSerial() const;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override;
private:
RendererD3D *mRenderer;
RenderTargetD3D *mRenderTarget;
......
......@@ -12,6 +12,7 @@
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/d3d/DisplayD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include <tchar.h>
......@@ -360,4 +361,18 @@ egl::Error SurfaceD3D::querySurfacePointerANGLE(EGLint attribute, void **value)
return egl::Error(EGL_SUCCESS);
}
gl::Error SurfaceD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut)
{
if (target.binding() == GL_BACK)
{
*rtOut = mSwapChain->getColorRenderTarget();
}
else
{
*rtOut = mSwapChain->getDepthStencilRenderTarget();
}
return gl::Error(GL_NO_ERROR);
}
}
......@@ -54,6 +54,9 @@ class SurfaceD3D : public SurfaceImpl
// Returns true if swapchain changed due to resize or interval update
bool checkForOutOfDateSwapChain();
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override;
private:
SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::Config *config, EGLint width, EGLint height,
EGLint fixedSize, EGLClientBuffer shareHandle, EGLNativeWindowType window);
......
......@@ -608,6 +608,15 @@ gl::Error TextureD3D::commitRegion(const gl::ImageIndex &index, const gl::Box &r
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureD3D::getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut)
{
RenderTargetD3D *rtD3D = nullptr;
gl::Error error = getRenderTarget(target.textureIndex(), &rtD3D);
*rtOut = static_cast<FramebufferAttachmentRenderTarget *>(rtD3D);
return error;
}
TextureD3D_2D::TextureD3D_2D(RendererD3D *renderer)
: TextureD3D(renderer)
{
......
......@@ -64,6 +64,9 @@ class TextureD3D : public TextureImpl
TextureStorage *getStorage();
ImageD3D *getBaseLevelImage() const;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override;
protected:
gl::Error setImage(const gl::ImageIndex &index, GLenum type,
const gl::PixelUnpackState &unpack, const uint8_t *pixels,
......
......@@ -260,7 +260,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
drawBufferStates[colorAttachment] != GL_NONE)
{
RenderTarget11 *renderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(&attachment, &renderTarget);
gl::Error error = attachment.getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......@@ -349,7 +349,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
ASSERT(attachment != nullptr);
RenderTarget11 *renderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(attachment, &renderTarget);
gl::Error error = attachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......
......@@ -115,7 +115,7 @@ static gl::Error getRenderTargetResource(const gl::FramebufferAttachment *colorb
ASSERT(colorbuffer);
RenderTarget11 *renderTarget = nullptr;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
gl::Error error = colorbuffer->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......@@ -189,7 +189,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
ASSERT(readBuffer);
RenderTargetD3D *readRenderTarget = nullptr;
gl::Error error = GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
gl::Error error = readBuffer->getRenderTarget(&readRenderTarget);
if (error.isError())
{
return error;
......@@ -207,7 +207,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
drawBufferStates[colorAttachment] != GL_NONE)
{
RenderTargetD3D *drawRenderTarget = nullptr;
error = GetAttachmentRenderTarget(&drawBuffer, &drawRenderTarget);
error = drawBuffer.getRenderTarget(&drawRenderTarget);
if (error.isError())
{
return error;
......@@ -230,7 +230,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
ASSERT(readBuffer);
RenderTargetD3D *readRenderTarget = nullptr;
gl::Error error = GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
gl::Error error = readBuffer->getRenderTarget(&readRenderTarget);
if (error.isError())
{
return error;
......@@ -241,7 +241,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
ASSERT(drawBuffer);
RenderTargetD3D *drawRenderTarget = nullptr;
error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
error = drawBuffer->getRenderTarget(&drawRenderTarget);
if (error.isError())
{
return error;
......
......@@ -1290,7 +1290,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
// Extract the render target dimensions and view
RenderTarget11 *renderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
gl::Error error = colorbuffer->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......@@ -1327,7 +1327,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
if (depthStencil)
{
RenderTarget11 *depthStencilRenderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(depthStencil, &depthStencilRenderTarget);
gl::Error error = depthStencil->getRenderTarget(&depthStencilRenderTarget);
if (error.isError())
{
SafeRelease(framebufferRTVs);
......@@ -2423,7 +2423,7 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::
ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
gl::Error error = colorbuffer->getRenderTarget(&sourceRenderTarget);
if (error.isError())
{
return error;
......@@ -2474,7 +2474,7 @@ gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl
ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
gl::Error error = colorbuffer->getRenderTarget(&sourceRenderTarget);
if (error.isError())
{
return error;
......@@ -2525,7 +2525,7 @@ gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::
ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
gl::Error error = colorbuffer->getRenderTarget(&sourceRenderTarget);
if (error.isError())
{
return error;
......@@ -2576,7 +2576,7 @@ gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const
ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL;
gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
gl::Error error = colorbuffer->getRenderTarget(&sourceRenderTarget);
if (error.isError())
{
return error;
......
......@@ -1189,18 +1189,6 @@ HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
#endif
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget11 **outRT)
{
RenderTargetD3D *renderTarget = NULL;
gl::Error error = rx::GetAttachmentRenderTarget(attachment, &renderTarget);
if (error.isError())
{
return error;
}
*outRT = GetAs<RenderTarget11>(renderTarget);
return gl::Error(GL_NO_ERROR);
}
Workarounds GenerateWorkarounds(D3D_FEATURE_LEVEL featureLevel)
{
Workarounds workarounds;
......
......@@ -179,8 +179,6 @@ inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBu
context->Unmap(constantBuffer, 0);
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget11 **outRT);
Workarounds GenerateWorkarounds(D3D_FEATURE_LEVEL featureLevel);
}
......
......@@ -239,8 +239,8 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe
const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = NULL;
error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget9);
RenderTarget9 *renderTarget9 = nullptr;
error = colorbuffer->getRenderTarget(&renderTarget9);
if (error.isError())
{
return error;
......@@ -278,8 +278,8 @@ gl::Error Blit9::copyCube(const gl::Framebuffer *framebuffer, const RECT &source
const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = NULL;
error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget9);
RenderTarget9 *renderTarget9 = nullptr;
error = colorbuffer->getRenderTarget(&renderTarget9);
if (error.isError())
{
return error;
......
......@@ -60,7 +60,7 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe
ASSERT(colorbuffer);
RenderTarget9 *renderTarget = nullptr;
gl::Error error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
gl::Error error = colorbuffer->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......@@ -247,7 +247,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(readBuffer);
RenderTarget9 *readRenderTarget = nullptr;
gl::Error error = d3d9::GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
gl::Error error = readBuffer->getRenderTarget(&readRenderTarget);
if (error.isError())
{
return error;
......@@ -258,7 +258,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(drawBuffer);
RenderTarget9 *drawRenderTarget = nullptr;
error = d3d9::GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
error = drawBuffer->getRenderTarget(&drawRenderTarget);
if (error.isError())
{
return error;
......@@ -373,7 +373,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(readBuffer);
RenderTarget9 *readDepthStencil = nullptr;
gl::Error error = d3d9::GetAttachmentRenderTarget(readBuffer, &readDepthStencil);
gl::Error error = readBuffer->getRenderTarget(&readDepthStencil);
if (error.isError())
{
return error;
......@@ -384,7 +384,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(drawBuffer);
RenderTarget9 *drawDepthStencil = nullptr;
error = d3d9::GetAttachmentRenderTarget(drawBuffer, &drawDepthStencil);
error = drawBuffer->getRenderTarget(&drawDepthStencil);
if (error.isError())
{
return error;
......
......@@ -1312,17 +1312,19 @@ gl::Error Renderer9::getNullColorbuffer(const gl::FramebufferAttachment *depthbu
gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuffer, const gl::FramebufferAttachment *depthStencilBuffer)
{
const gl::FramebufferAttachment *renderAttachment = colorBuffer;
// if there is no color attachment we must synthesize a NULL colorattachment
// to keep the D3D runtime happy. This should only be possible if depth texturing.
if (!colorBuffer)
if (renderAttachment == nullptr)
{
gl::Error error = getNullColorbuffer(depthStencilBuffer, &colorBuffer);
gl::Error error = getNullColorbuffer(depthStencilBuffer, &renderAttachment);
if (error.isError())
{
return error;
}
}
ASSERT(colorBuffer);
ASSERT(renderAttachment != nullptr);
size_t renderTargetWidth = 0;
size_t renderTargetHeight = 0;
......@@ -1333,8 +1335,8 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
if (renderTargetSerial != mAppliedRenderTargetSerial)
{
// Apply the render target on the device
RenderTarget9 *renderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(colorBuffer, &renderTarget);
RenderTarget9 *renderTarget = nullptr;
gl::Error error = renderAttachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
......@@ -1364,8 +1366,8 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
// Apply the depth stencil on the device
if (depthStencilBuffer)
{
RenderTarget9 *depthStencilRenderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencilBuffer, &depthStencilRenderTarget);
RenderTarget9 *depthStencilRenderTarget = nullptr;
gl::Error error = depthStencilBuffer->getRenderTarget(&depthStencilRenderTarget);
if (error.isError())
{
return error;
......@@ -2010,8 +2012,10 @@ gl::Error Renderer9::clear(const ClearParameters &clearParams,
unsigned int stencilUnmasked = 0x0;
if (clearParams.clearStencil && depthStencilBuffer->getStencilSize() > 0)
{
RenderTargetD3D *stencilRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(depthStencilBuffer, &stencilRenderTarget);
ASSERT(depthStencilBuffer != nullptr);
RenderTargetD3D *stencilRenderTarget = nullptr;
gl::Error error = depthStencilBuffer->getRenderTarget(&stencilRenderTarget);
if (error.isError())
{
return error;
......@@ -2031,8 +2035,10 @@ gl::Error Renderer9::clear(const ClearParameters &clearParams,
D3DCOLOR color = D3DCOLOR_ARGB(255, 0, 0, 0);
if (clearColor)
{
ASSERT(colorBuffer != nullptr);
RenderTargetD3D *colorRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(colorBuffer, &colorRenderTarget);
gl::Error error = colorBuffer->getRenderTarget(&colorRenderTarget);
if (error.isError())
{
return error;
......
......@@ -574,18 +574,6 @@ void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsize
*levelOffset = upsampleCount;
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget9 **outRT)
{
RenderTargetD3D *renderTarget = NULL;
gl::Error error = rx::GetAttachmentRenderTarget(attachment, &renderTarget);
if (error.isError())
{
return error;
}
*outRT = GetAs<RenderTarget9>(renderTarget);
return gl::Error(GL_NO_ERROR);
}
Workarounds GenerateWorkarounds()
{
Workarounds workarounds;
......
......@@ -76,7 +76,6 @@ inline bool isDeviceLostError(HRESULT errorCode)
}
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget9 **outRT);
Workarounds GenerateWorkarounds();
}
......
......@@ -33,6 +33,12 @@ class RenderbufferGL : public RenderbufferImpl
GLuint getRenderbufferID() const;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override
{
return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
}
private:
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
......
......@@ -20,6 +20,12 @@ class SurfaceGL : public SurfaceImpl
SurfaceGL();
~SurfaceGL() override;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override
{
return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
}
virtual egl::Error makeCurrent() = 0;
};
......
......@@ -51,6 +51,12 @@ class TextureGL : public TextureImpl
void syncSamplerState(const gl::SamplerState &samplerState) const;
GLuint getTextureID() const;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) override
{
return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
}
private:
GLenum mTextureType;
......
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