Commit c46f45d9 by Jamie Madill

Refactor DefaultAttachments.

Instead of using an Impl type for default attachments, store the egl::Surface pointer where possible. BUG=angleproject:963 Change-Id: I3e34849e8b1ccae0c91a79617ec6f64aaaab6b10 Reviewed-on: https://chromium-review.googlesource.com/263483Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 2c919145
...@@ -8,18 +8,20 @@ ...@@ -8,18 +8,20 @@
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105. // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Texture.h" #include "common/utilities.h"
#include "libANGLE/Config.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/ImplFactory.h"
#include "libANGLE/renderer/RenderbufferImpl.h" #include "libANGLE/renderer/RenderbufferImpl.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
#include "common/utilities.h"
namespace gl namespace gl
{ {
...@@ -633,20 +635,17 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -633,20 +635,17 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
DefaultFramebuffer::DefaultFramebuffer(const Caps &caps, rx::ImplFactory *factory, egl::Surface *surface) DefaultFramebuffer::DefaultFramebuffer(const Caps &caps, rx::ImplFactory *factory, egl::Surface *surface)
: Framebuffer(caps, factory, 0) : Framebuffer(caps, factory, 0)
{ {
rx::DefaultAttachmentImpl *colorAttachment = factory->createDefaultAttachment(GL_BACK, surface); const egl::Config *config = surface->getConfig();
rx::DefaultAttachmentImpl *depthAttachment = factory->createDefaultAttachment(GL_DEPTH, surface);
rx::DefaultAttachmentImpl *stencilAttachment = factory->createDefaultAttachment(GL_STENCIL, surface);
ASSERT(colorAttachment); setAttachment(GL_BACK, new DefaultAttachment(GL_BACK, surface));
setAttachment(GL_BACK, new DefaultAttachment(GL_BACK, colorAttachment));
if (depthAttachment) if (config->depthSize > 0)
{ {
setAttachment(GL_DEPTH, new DefaultAttachment(GL_DEPTH, depthAttachment)); setAttachment(GL_DEPTH, new DefaultAttachment(GL_DEPTH, surface));
} }
if (stencilAttachment) if (config->stencilSize > 0)
{ {
setAttachment(GL_STENCIL, new DefaultAttachment(GL_STENCIL, stencilAttachment)); setAttachment(GL_STENCIL, new DefaultAttachment(GL_STENCIL, surface));
} }
GLenum drawBufferState = GL_BACK; GLenum drawBufferState = GL_BACK;
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Config.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/DefaultAttachmentImpl.h" #include "libANGLE/renderer/DefaultAttachmentImpl.h"
...@@ -222,36 +224,37 @@ Renderbuffer *RenderbufferAttachment::getRenderbuffer() const ...@@ -222,36 +224,37 @@ Renderbuffer *RenderbufferAttachment::getRenderbuffer() const
} }
DefaultAttachment::DefaultAttachment(GLenum binding, rx::DefaultAttachmentImpl *impl) DefaultAttachment::DefaultAttachment(GLenum binding, egl::Surface *surface)
: FramebufferAttachment(binding), : FramebufferAttachment(binding)
mImpl(impl)
{ {
ASSERT(mImpl); mSurface.set(surface);
} }
DefaultAttachment::~DefaultAttachment() DefaultAttachment::~DefaultAttachment()
{ {
SafeDelete(mImpl); mSurface.set(nullptr);
} }
GLsizei DefaultAttachment::getWidth() const GLsizei DefaultAttachment::getWidth() const
{ {
return mImpl->getWidth(); return mSurface->getWidth();
} }
GLsizei DefaultAttachment::getHeight() const GLsizei DefaultAttachment::getHeight() const
{ {
return mImpl->getHeight(); return mSurface->getHeight();
} }
GLenum DefaultAttachment::getInternalFormat() const GLenum DefaultAttachment::getInternalFormat() const
{ {
return mImpl->getInternalFormat(); const egl::Config *config = mSurface->getConfig();
return (getBinding() == GL_BACK ? config->renderTargetFormat : config->depthStencilFormat);
} }
GLsizei DefaultAttachment::getSamples() const GLsizei DefaultAttachment::getSamples() const
{ {
return mImpl->getSamples(); const egl::Config *config = mSurface->getConfig();
return config->samples;
} }
GLuint DefaultAttachment::id() const GLuint DefaultAttachment::id() const
...@@ -297,9 +300,4 @@ Renderbuffer *DefaultAttachment::getRenderbuffer() const ...@@ -297,9 +300,4 @@ Renderbuffer *DefaultAttachment::getRenderbuffer() const
return NULL; return NULL;
} }
rx::DefaultAttachmentImpl *DefaultAttachment::getImplementation() const
{
return mImpl;
}
} }
...@@ -129,7 +129,7 @@ class RenderbufferAttachment : public FramebufferAttachment ...@@ -129,7 +129,7 @@ class RenderbufferAttachment : public FramebufferAttachment
class DefaultAttachment : public FramebufferAttachment class DefaultAttachment : public FramebufferAttachment
{ {
public: public:
DefaultAttachment(GLenum binding, rx::DefaultAttachmentImpl *impl); DefaultAttachment(GLenum binding, egl::Surface *surface);
virtual ~DefaultAttachment(); virtual ~DefaultAttachment();
...@@ -148,10 +148,10 @@ class DefaultAttachment : public FramebufferAttachment ...@@ -148,10 +148,10 @@ class DefaultAttachment : public FramebufferAttachment
virtual const ImageIndex *getTextureImageIndex() const; virtual const ImageIndex *getTextureImageIndex() const;
virtual Renderbuffer *getRenderbuffer() const; virtual Renderbuffer *getRenderbuffer() const;
rx::DefaultAttachmentImpl *getImplementation() const; const egl::Surface *getSurface() const { return mSurface.get(); }
private: private:
rx::DefaultAttachmentImpl *mImpl; BindingPointer<egl::Surface> mSurface;
}; };
} }
......
...@@ -7,13 +7,17 @@ ...@@ -7,13 +7,17 @@
// FramebufferD3D.cpp: Implements the DefaultAttachmentD3D and FramebufferD3D classes. // FramebufferD3D.cpp: Implements the DefaultAttachmentD3D and FramebufferD3D classes.
#include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
namespace rx namespace rx
{ {
...@@ -433,10 +437,19 @@ gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, ...@@ -433,10 +437,19 @@ gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment,
else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT)
{ {
const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment);
DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); const egl::Surface *surface = defaultAttachment->getSurface();
ASSERT(defaultAttachmentD3D); ASSERT(surface);
const SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface);
ASSERT(surfaceD3D);
*outRT = defaultAttachmentD3D->getRenderTarget(); if (defaultAttachment->getBinding() == GL_BACK)
{
*outRT = surfaceD3D->getSwapChain()->getColorRenderTarget();
}
else
{
*outRT = surfaceD3D->getSwapChain()->getDepthStencilRenderTarget();
}
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
else else
...@@ -468,9 +481,19 @@ unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment) ...@@ -468,9 +481,19 @@ unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment)
else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT)
{ {
const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment);
DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); const egl::Surface *surface = defaultAttachment->getSurface();
ASSERT(defaultAttachmentD3D); ASSERT(surface);
return defaultAttachmentD3D->getRenderTarget()->getSerial(); const SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface);
ASSERT(surfaceD3D);
if (defaultAttachment->getBinding() == GL_BACK)
{
return surfaceD3D->getSwapChain()->getColorRenderTarget()->getSerial();
}
else
{
return surfaceD3D->getSwapChain()->getDepthStencilRenderTarget()->getSerial();
}
} }
else else
{ {
......
...@@ -40,7 +40,7 @@ SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl:: ...@@ -40,7 +40,7 @@ SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::
mFixedSize(fixedSize == EGL_TRUE), mFixedSize(fixedSize == EGL_TRUE),
mRenderTargetFormat(config->renderTargetFormat), mRenderTargetFormat(config->renderTargetFormat),
mDepthStencilFormat(config->depthStencilFormat), mDepthStencilFormat(config->depthStencilFormat),
mSwapChain(NULL), mSwapChain(nullptr),
mSwapIntervalDirty(true), mSwapIntervalDirty(true),
mWindowSubclassed(false), mWindowSubclassed(false),
mNativeWindow(window), mNativeWindow(window),
......
...@@ -46,8 +46,8 @@ class SurfaceD3D : public SurfaceImpl ...@@ -46,8 +46,8 @@ class SurfaceD3D : public SurfaceImpl
EGLint isPostSubBufferSupported() const override; EGLint isPostSubBufferSupported() const override;
// D3D implementations (some virtual to hack across DLL boundaries) // D3D implementations
virtual SwapChainD3D *getSwapChain() const; SwapChainD3D *getSwapChain() const;
egl::Error resetSwapChain(); egl::Error resetSwapChain();
......
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
#ifndef LIBANGLE_RENDERER_D3D_SWAPCHAIND3D_H_ #ifndef LIBANGLE_RENDERER_D3D_SWAPCHAIND3D_H_
#define LIBANGLE_RENDERER_D3D_SWAPCHAIND3D_H_ #define LIBANGLE_RENDERER_D3D_SWAPCHAIND3D_H_
// TODO: move SwapChain to be d3d only #include <GLES2/gl2.h>
#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" #include <EGL/egl.h>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/platform.h" #include "common/platform.h"
#include <GLES2/gl2.h> // TODO: move out of D3D11
#include <EGL/egl.h> #include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
#if !defined(ANGLE_FORCE_VSYNC_OFF) #if !defined(ANGLE_FORCE_VSYNC_OFF)
#define ANGLE_FORCE_VSYNC_OFF 0 #define ANGLE_FORCE_VSYNC_OFF 0
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
namespace rx namespace rx
{ {
class RenderTargetD3D;
class SwapChainD3D : angle::NonCopyable class SwapChainD3D : angle::NonCopyable
{ {
...@@ -41,10 +42,13 @@ class SwapChainD3D : angle::NonCopyable ...@@ -41,10 +42,13 @@ class SwapChainD3D : angle::NonCopyable
virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height) = 0; virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height) = 0;
virtual void recreate() = 0; virtual void recreate() = 0;
virtual RenderTargetD3D *getColorRenderTarget() = 0;
virtual RenderTargetD3D *getDepthStencilRenderTarget() = 0;
GLenum GetBackBufferInternalFormat() const { return mBackBufferFormat; } GLenum GetBackBufferInternalFormat() const { return mBackBufferFormat; }
GLenum GetDepthBufferInternalFormat() const { return mDepthBufferFormat; } GLenum GetDepthBufferInternalFormat() const { return mDepthBufferFormat; }
virtual HANDLE getShareHandle() {return mShareHandle;}; HANDLE getShareHandle() { return mShareHandle; }
protected: protected:
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for. rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
......
...@@ -24,7 +24,9 @@ namespace rx ...@@ -24,7 +24,9 @@ namespace rx
SwapChain11::SwapChain11(Renderer11 *renderer, NativeWindow nativeWindow, HANDLE shareHandle, SwapChain11::SwapChain11(Renderer11 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat) GLenum backBufferFormat, GLenum depthBufferFormat)
: mRenderer(renderer), : mRenderer(renderer),
SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat) SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat),
mColorRenderTarget(this, renderer, false),
mDepthStencilRenderTarget(this, renderer, true)
{ {
mSwapChain = NULL; mSwapChain = NULL;
mBackBufferTexture = NULL; mBackBufferTexture = NULL;
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
namespace rx namespace rx
{ {
...@@ -29,6 +29,9 @@ class SwapChain11 : public SwapChainD3D ...@@ -29,6 +29,9 @@ class SwapChain11 : public SwapChainD3D
virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height); virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
virtual void recreate(); virtual void recreate();
RenderTargetD3D *getColorRenderTarget() override { return &mColorRenderTarget; }
RenderTargetD3D *getDepthStencilRenderTarget() override { return &mDepthStencilRenderTarget; }
virtual ID3D11Texture2D *getOffscreenTexture(); virtual ID3D11Texture2D *getOffscreenTexture();
virtual ID3D11RenderTargetView *getRenderTarget(); virtual ID3D11RenderTargetView *getRenderTarget();
virtual ID3D11ShaderResourceView *getRenderTargetShaderResource(); virtual ID3D11ShaderResourceView *getRenderTargetShaderResource();
...@@ -73,6 +76,9 @@ class SwapChain11 : public SwapChainD3D ...@@ -73,6 +76,9 @@ class SwapChain11 : public SwapChainD3D
ID3D11InputLayout *mPassThroughIL; ID3D11InputLayout *mPassThroughIL;
ID3D11VertexShader *mPassThroughVS; ID3D11VertexShader *mPassThroughVS;
ID3D11PixelShader *mPassThroughPS; ID3D11PixelShader *mPassThroughPS;
SurfaceRenderTarget11 mColorRenderTarget;
SurfaceRenderTarget11 mDepthStencilRenderTarget;
}; };
} }
......
...@@ -18,7 +18,9 @@ namespace rx ...@@ -18,7 +18,9 @@ namespace rx
SwapChain9::SwapChain9(Renderer9 *renderer, NativeWindow nativeWindow, HANDLE shareHandle, SwapChain9::SwapChain9(Renderer9 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat) GLenum backBufferFormat, GLenum depthBufferFormat)
: mRenderer(renderer), : mRenderer(renderer),
SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat) SwapChainD3D(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat),
mColorRenderTarget(this, false),
mDepthStencilRenderTarget(this, true)
{ {
mSwapChain = NULL; mSwapChain = NULL;
mBackBuffer = NULL; mBackBuffer = NULL;
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_ #define LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
namespace rx namespace rx
{ {
...@@ -29,6 +29,9 @@ class SwapChain9 : public SwapChainD3D ...@@ -29,6 +29,9 @@ class SwapChain9 : public SwapChainD3D
virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height); virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
virtual void recreate(); virtual void recreate();
RenderTargetD3D *getColorRenderTarget() override { return &mColorRenderTarget; }
RenderTargetD3D *getDepthStencilRenderTarget() override { return &mDepthStencilRenderTarget; }
virtual IDirect3DSurface9 *getRenderTarget(); virtual IDirect3DSurface9 *getRenderTarget();
virtual IDirect3DSurface9 *getDepthStencil(); virtual IDirect3DSurface9 *getDepthStencil();
virtual IDirect3DTexture9 *getOffscreenTexture(); virtual IDirect3DTexture9 *getOffscreenTexture();
...@@ -51,6 +54,9 @@ class SwapChain9 : public SwapChainD3D ...@@ -51,6 +54,9 @@ class SwapChain9 : public SwapChainD3D
IDirect3DSurface9 *mRenderTarget; IDirect3DSurface9 *mRenderTarget;
IDirect3DSurface9 *mDepthStencil; IDirect3DSurface9 *mDepthStencil;
IDirect3DTexture9* mOffscreenTexture; IDirect3DTexture9* mOffscreenTexture;
SurfaceRenderTarget9 mColorRenderTarget;
SurfaceRenderTarget9 mDepthStencilRenderTarget;
}; };
} }
......
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