Commit 7147f01a by Jamie Madill

Cleanups to FramebufferD3D.

With the new shared state structure, we can eliminate a lot of the state tracking within the FramebufferD3D implementation. BUG=angleproject:930 Change-Id: I0953e321bae3afe7cde7b73c55af62546665c890 Reviewed-on: https://chromium-review.googlesource.com/254101Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d1405e51
...@@ -54,6 +54,32 @@ Framebuffer::Data::~Data() ...@@ -54,6 +54,32 @@ Framebuffer::Data::~Data()
SafeDelete(mStencilAttachment); SafeDelete(mStencilAttachment);
} }
FramebufferAttachment *Framebuffer::Data::getReadAttachment() const
{
ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15));
size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0));
ASSERT(readIndex < mColorAttachments.size());
return mColorAttachments[readIndex];
}
FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const
{
for (FramebufferAttachment *colorAttachment : mColorAttachments)
{
if (colorAttachment != nullptr)
{
return colorAttachment;
}
}
return nullptr;
}
FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() const
{
return (mDepthAttachment != nullptr ? mDepthAttachment : mStencilAttachment);
}
Framebuffer::Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id) Framebuffer::Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id)
: mData(caps), : mData(caps),
mImpl(renderer->createFramebuffer(mData)), mImpl(renderer->createFramebuffer(mData)),
...@@ -111,34 +137,23 @@ FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const ...@@ -111,34 +137,23 @@ FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
{ {
return (mData.mDepthAttachment != nullptr ? mData.mDepthAttachment : mData.mStencilAttachment); return mData.getDepthOrStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getReadColorbuffer() const FramebufferAttachment *Framebuffer::getReadColorbuffer() const
{ {
size_t readIndex = (mData.mReadBufferState == GL_BACK ? 0 : return mData.getReadAttachment();
static_cast<size_t>(mData.mReadBufferState - GL_COLOR_ATTACHMENT0));
ASSERT(readIndex < mData.mColorAttachments.size());
return mData.mColorAttachments[readIndex];
} }
GLenum Framebuffer::getReadColorbufferType() const GLenum Framebuffer::getReadColorbufferType() const
{ {
FramebufferAttachment *readAttachment = getReadColorbuffer(); FramebufferAttachment *readAttachment = mData.getReadAttachment();
return (readAttachment ? readAttachment->type() : GL_NONE); return (readAttachment ? readAttachment->type() : GL_NONE);
} }
FramebufferAttachment *Framebuffer::getFirstColorbuffer() const FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
{ {
for (FramebufferAttachment *colorAttachment : mData.mColorAttachments) return mData.getFirstColorAttachment();
{
if (colorAttachment != nullptr)
{
return colorAttachment;
}
}
return nullptr;
} }
FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
...@@ -529,27 +544,9 @@ bool Framebuffer::hasValidDepthStencil() const ...@@ -529,27 +544,9 @@ bool Framebuffer::hasValidDepthStencil() const
mData.mDepthAttachment->id() == mData.mStencilAttachment->id()); mData.mDepthAttachment->id() == mData.mStencilAttachment->id());
} }
ColorbufferInfo Framebuffer::getColorbuffersForRender(const rx::Workarounds &workarounds) const AttachmentList Framebuffer::getColorAttachmentsForRender(const rx::Workarounds &workarounds) const
{ {
ColorbufferInfo colorbuffersForRender; return mImpl->getColorAttachmentsForRender(workarounds);
for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex)
{
GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex];
FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex];
if (colorAttachment != nullptr && drawBufferState != GL_NONE)
{
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
colorbuffersForRender.push_back(colorAttachment);
}
else if (!workarounds.mrtPerfWorkaround)
{
colorbuffersForRender.push_back(nullptr);
}
}
return colorbuffersForRender;
} }
void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex) void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex)
......
...@@ -10,13 +10,12 @@ ...@@ -10,13 +10,12 @@
#ifndef LIBANGLE_FRAMEBUFFER_H_ #ifndef LIBANGLE_FRAMEBUFFER_H_
#define LIBANGLE_FRAMEBUFFER_H_ #define LIBANGLE_FRAMEBUFFER_H_
#include "libANGLE/Error.h" #include <vector>
#include "libANGLE/RefCountObject.h"
#include "libANGLE/Constants.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Constants.h"
#include <vector> #include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h"
namespace rx namespace rx
{ {
...@@ -45,7 +44,7 @@ struct Extensions; ...@@ -45,7 +44,7 @@ struct Extensions;
struct ImageIndex; struct ImageIndex;
struct Rectangle; struct Rectangle;
typedef std::vector<FramebufferAttachment *> ColorbufferInfo; typedef std::vector<FramebufferAttachment *> AttachmentList;
class Framebuffer class Framebuffer
{ {
...@@ -57,7 +56,11 @@ class Framebuffer ...@@ -57,7 +56,11 @@ class Framebuffer
Data(const Caps &caps); Data(const Caps &caps);
~Data(); ~Data();
std::vector<FramebufferAttachment *> mColorAttachments; FramebufferAttachment *getReadAttachment() const;
FramebufferAttachment *getFirstColorAttachment() const;
FramebufferAttachment *getDepthOrStencilAttachment() const;
AttachmentList mColorAttachments;
FramebufferAttachment *mDepthAttachment; FramebufferAttachment *mDepthAttachment;
FramebufferAttachment *mStencilAttachment; FramebufferAttachment *mStencilAttachment;
...@@ -125,10 +128,10 @@ class Framebuffer ...@@ -125,10 +128,10 @@ class Framebuffer
Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea,
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer); GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer);
// Use this method to retrieve the color buffer map when doing rendering. // Use this method to retrieve the color attachment map when doing rendering.
// It will apply a workaround for poor shader performance on some systems // It will apply a workaround for poor shader performance on some systems
// by compacting the list to skip NULL values. // by compacting the list to skip NULL values.
ColorbufferInfo getColorbuffersForRender(const rx::Workarounds &workarounds) const; AttachmentList getColorAttachmentsForRender(const rx::Workarounds &workarounds) const;
protected: protected:
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj); void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
......
...@@ -59,6 +59,8 @@ class FramebufferImpl ...@@ -59,6 +59,8 @@ class FramebufferImpl
const gl::Framebuffer::Data &getData() const { return mData; } const gl::Framebuffer::Data &getData() const { return mData; }
virtual const gl::AttachmentList &getColorAttachmentsForRender(const Workarounds &) const { return mData.mColorAttachments; }
protected: protected:
const gl::Framebuffer::Data &mData; const gl::Framebuffer::Data &mData;
......
...@@ -32,7 +32,12 @@ struct Workarounds ...@@ -32,7 +32,12 @@ struct Workarounds
useInstancedPointSpriteEmulation(false) useInstancedPointSpriteEmulation(false)
{} {}
// On some systems, having extra rendertargets than necessary slows down the shader.
// We can fix this by optimizing those out of the shader. At the same time, we can
// work around a bug on some nVidia drivers that they ignore "null" render targets
// in D3D11, by compacting the active color attachments list to omit null entries.
bool mrtPerfWorkaround; bool mrtPerfWorkaround;
bool setDataFasterThanImageUpload; bool setDataFasterThanImageUpload;
// Some renderers can't disable mipmaps on a mipmapped texture (i.e. solely sample from level zero, and ignore the other levels). // Some renderers can't disable mipmaps on a mipmapped texture (i.e. solely sample from level zero, and ignore the other levels).
......
...@@ -60,60 +60,40 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const ...@@ -60,60 +60,40 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const
return mRenderTarget; return mRenderTarget;
} }
FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer) FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer)
: FramebufferImpl(data), : FramebufferImpl(data),
mRenderer(renderer), mRenderer(renderer),
mColorBuffers(renderer->getRendererCaps().maxColorAttachments), mColorAttachmentsForRender(mData.mColorAttachments.size(), nullptr)
mDepthbuffer(nullptr),
mStencilbuffer(nullptr),
mDrawBuffers(renderer->getRendererCaps().maxDrawBuffers),
mReadBuffer(GL_COLOR_ATTACHMENT0)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
std::fill(mColorBuffers.begin(), mColorBuffers.end(), nullptr);
ASSERT(mDrawBuffers.size() > 0);
mDrawBuffers[0] = GL_COLOR_ATTACHMENT0;
std::fill(mDrawBuffers.begin() + 1, mDrawBuffers.end(), GL_NONE);
} }
FramebufferD3D::~FramebufferD3D() FramebufferD3D::~FramebufferD3D()
{ {
} }
void FramebufferD3D::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *)
{ {
ASSERT(index < mColorBuffers.size());
mColorBuffers[index] = attachment;
} }
void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *attachment) void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *)
{ {
mDepthbuffer = attachment;
} }
void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *attachment) void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *)
{ {
mStencilbuffer = attachment;
} }
void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *)
{ {
mDepthbuffer = attachment;
mStencilbuffer = attachment;
} }
void FramebufferD3D::setDrawBuffers(size_t count, const GLenum *buffers) void FramebufferD3D::setDrawBuffers(size_t, const GLenum *)
{ {
std::copy_n(buffers, count, mDrawBuffers.begin());
std::fill(mDrawBuffers.begin() + count, mDrawBuffers.end(), GL_NONE);
} }
void FramebufferD3D::setReadBuffer(GLenum buffer) void FramebufferD3D::setReadBuffer(GLenum)
{ {
mReadBuffer = buffer;
} }
gl::Error FramebufferD3D::invalidate(size_t, const GLenum *) gl::Error FramebufferD3D::invalidate(size_t, const GLenum *)
...@@ -208,17 +188,9 @@ gl::Error FramebufferD3D::clearBufferfi(const gl::State &state, GLenum buffer, G ...@@ -208,17 +188,9 @@ gl::Error FramebufferD3D::clearBufferfi(const gl::State &state, GLenum buffer, G
return clear(state, clearParams); return clear(state, clearParams);
} }
const gl::FramebufferAttachment *FramebufferD3D::getReadAttachment() const
{
ASSERT(mReadBuffer == GL_BACK || (mReadBuffer >= GL_COLOR_ATTACHMENT0 && mReadBuffer <= GL_COLOR_ATTACHMENT15));
size_t readIndex = (mReadBuffer == GL_BACK ? 0 : static_cast<size_t>(mReadBuffer - GL_COLOR_ATTACHMENT0));
ASSERT(readIndex < mColorBuffers.size());
return mColorBuffers[readIndex];
}
GLenum FramebufferD3D::getImplementationColorReadFormat() const GLenum FramebufferD3D::getImplementationColorReadFormat() const
{ {
const gl::FramebufferAttachment *readAttachment = getReadAttachment(); const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment();
if (readAttachment == nullptr) if (readAttachment == nullptr)
{ {
...@@ -240,7 +212,7 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const ...@@ -240,7 +212,7 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const
GLenum FramebufferD3D::getImplementationColorReadType() const GLenum FramebufferD3D::getImplementationColorReadType() const
{ {
const gl::FramebufferAttachment *readAttachment = getReadAttachment(); const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment();
if (readAttachment == nullptr) if (readAttachment == nullptr)
{ {
...@@ -275,7 +247,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -275,7 +247,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
bool blitRenderTarget = false; bool blitRenderTarget = false;
if ((mask & GL_COLOR_BUFFER_BIT) && if ((mask & GL_COLOR_BUFFER_BIT) &&
sourceFramebuffer->getReadColorbuffer() != nullptr && sourceFramebuffer->getReadColorbuffer() != nullptr &&
std::any_of(mColorBuffers.begin(), mColorBuffers.end(), [](const gl::FramebufferAttachment* attachment){ return attachment != nullptr; })) mData.getFirstColorAttachment() != nullptr)
{ {
blitRenderTarget = true; blitRenderTarget = true;
} }
...@@ -283,7 +255,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -283,7 +255,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
bool blitStencil = false; bool blitStencil = false;
if ((mask & GL_STENCIL_BUFFER_BIT) && if ((mask & GL_STENCIL_BUFFER_BIT) &&
sourceFramebuffer->getStencilbuffer() != nullptr && sourceFramebuffer->getStencilbuffer() != nullptr &&
mStencilbuffer != nullptr) mData.mStencilAttachment != nullptr)
{ {
blitStencil = true; blitStencil = true;
} }
...@@ -291,7 +263,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -291,7 +263,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
bool blitDepth = false; bool blitDepth = false;
if ((mask & GL_DEPTH_BUFFER_BIT) && if ((mask & GL_DEPTH_BUFFER_BIT) &&
sourceFramebuffer->getDepthbuffer() != nullptr && sourceFramebuffer->getDepthbuffer() != nullptr &&
mDepthbuffer != nullptr) mData.mDepthAttachment != nullptr)
{ {
blitDepth = true; blitDepth = true;
} }
...@@ -313,14 +285,14 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -313,14 +285,14 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
GLenum FramebufferD3D::checkStatus() const GLenum FramebufferD3D::checkStatus() const
{ {
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (size_t colorAttachment = 0; colorAttachment < mColorBuffers.size(); colorAttachment++) for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); colorAttachment++)
{ {
const gl::FramebufferAttachment *attachment = mColorBuffers[colorAttachment]; const gl::FramebufferAttachment *attachment = mData.mColorAttachments[colorAttachment];
if (attachment != nullptr) if (attachment != nullptr)
{ {
for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++) for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++)
{ {
const gl::FramebufferAttachment *prevAttachment = mColorBuffers[prevColorAttachment]; const gl::FramebufferAttachment *prevAttachment = mData.mColorAttachments[prevColorAttachment];
if (prevAttachment != nullptr && if (prevAttachment != nullptr &&
(attachment->id() == prevAttachment->id() && (attachment->id() == prevAttachment->id() &&
attachment->type() == prevAttachment->type())) attachment->type() == prevAttachment->type()))
...@@ -334,6 +306,30 @@ GLenum FramebufferD3D::checkStatus() const ...@@ -334,6 +306,30 @@ GLenum FramebufferD3D::checkStatus() const
return GL_FRAMEBUFFER_COMPLETE; return GL_FRAMEBUFFER_COMPLETE;
} }
const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const
{
// Does not actually free memory
mColorAttachmentsForRender.clear();
for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex)
{
GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex];
gl::FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex];
if (colorAttachment != nullptr && drawBufferState != GL_NONE)
{
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
mColorAttachmentsForRender.push_back(colorAttachment);
}
else if (!workarounds.mrtPerfWorkaround)
{
mColorAttachmentsForRender.push_back(nullptr);
}
}
return mColorAttachmentsForRender;
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTargetD3D **outRT) gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTargetD3D **outRT)
{ {
if (attachment->type() == GL_TEXTURE) if (attachment->type() == GL_TEXTURE)
......
...@@ -79,15 +79,12 @@ class FramebufferD3D : public FramebufferImpl ...@@ -79,15 +79,12 @@ class FramebufferD3D : public FramebufferImpl
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override; GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override;
GLenum checkStatus() const override; GLenum checkStatus() const override;
const gl::FramebufferAttachment *getReadAttachment() const;
protected: const gl::AttachmentList &getColorAttachmentsForRender(const Workarounds &workarounds) const override;
std::vector<const gl::FramebufferAttachment*> mColorBuffers;
const gl::FramebufferAttachment *mDepthbuffer;
const gl::FramebufferAttachment *mStencilbuffer;
std::vector<GLenum> mDrawBuffers; protected:
GLenum mReadBuffer; // Cache variable
mutable gl::AttachmentList mColorAttachmentsForRender;
private: private:
DISALLOW_COPY_AND_ASSIGN(FramebufferD3D); DISALLOW_COPY_AND_ASSIGN(FramebufferD3D);
......
...@@ -841,7 +841,7 @@ gl::Error ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fb ...@@ -841,7 +841,7 @@ gl::Error ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fb
{ {
std::vector<GLenum> outputs; std::vector<GLenum> outputs;
const gl::ColorbufferInfo &colorbuffers = fbo->getColorbuffersForRender(mRenderer->getWorkarounds()); const gl::AttachmentList &colorbuffers = fbo->getColorAttachmentsForRender(mRenderer->getWorkarounds());
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{ {
......
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
// Clear11.cpp: Framebuffer clear utility class. // Clear11.cpp: Framebuffer clear utility class.
#include "libANGLE/renderer/d3d/d3d11/Clear11.h" #include "libANGLE/renderer/d3d/d3d11/Clear11.h"
#include <algorithm>
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include <algorithm>
// Precompiled shaders // Precompiled shaders
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clearfloat11vs.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clearfloat11vs.h"
...@@ -173,10 +173,13 @@ Clear11::~Clear11() ...@@ -173,10 +173,13 @@ Clear11::~Clear11()
SafeRelease(mRasterizerState); SafeRelease(mRasterizerState);
} }
gl::Error Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, const std::vector<const gl::FramebufferAttachment*> &colorAttachments, gl::Error Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, const gl::Framebuffer::Data &fboData)
const std::vector<GLenum> &drawBufferStates, const gl::FramebufferAttachment *depthAttachment,
const gl::FramebufferAttachment *stencilAttachment)
{ {
const auto &colorAttachments = fboData.mColorAttachments;
const auto &drawBufferStates = fboData.mDrawBufferStates;
const auto *depthAttachment = fboData.mDepthAttachment;
const auto *stencilAttachment = fboData.mStencilAttachment;
ASSERT(colorAttachments.size() == drawBufferStates.size()); ASSERT(colorAttachments.size() == drawBufferStates.size());
// Iterate over the color buffers which require clearing and determine if they can be // Iterate over the color buffers which require clearing and determine if they can be
......
...@@ -11,15 +11,11 @@ ...@@ -11,15 +11,11 @@
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
#include <map> #include <map>
#include <vector> #include <vector>
namespace gl
{
class FramebufferAttachment;
}
namespace rx namespace rx
{ {
class Renderer11; class Renderer11;
...@@ -32,9 +28,7 @@ class Clear11 ...@@ -32,9 +28,7 @@ class Clear11
~Clear11(); ~Clear11();
// Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied. // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
gl::Error clearFramebuffer(const gl::ClearParameters &clearParams, const std::vector<const gl::FramebufferAttachment*> &colorAttachments, gl::Error clearFramebuffer(const gl::ClearParameters &clearParams, const gl::Framebuffer::Data &fboData);
const std::vector<GLenum> &drawBufferStates, const gl::FramebufferAttachment *depthAttachment,
const gl::FramebufferAttachment *stencilAttachment);
private: private:
Renderer11 *mRenderer; Renderer11 *mRenderer;
......
...@@ -64,22 +64,22 @@ static gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *a ...@@ -64,22 +64,22 @@ static gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *a
gl::Error Framebuffer11::invalidateSwizzles() const gl::Error Framebuffer11::invalidateSwizzles() const
{ {
for (size_t i = 0; i < mColorBuffers.size(); i++) for (gl::FramebufferAttachment *colorAttachment : mData.mColorAttachments)
{ {
gl::Error error = InvalidateAttachmentSwizzles(mColorBuffers[i]); gl::Error error = InvalidateAttachmentSwizzles(colorAttachment);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
} }
gl::Error error = InvalidateAttachmentSwizzles(mDepthbuffer); gl::Error error = InvalidateAttachmentSwizzles(mData.mDepthAttachment);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
error = InvalidateAttachmentSwizzles(mStencilbuffer); error = InvalidateAttachmentSwizzles(mData.mStencilAttachment);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -91,8 +91,7 @@ gl::Error Framebuffer11::invalidateSwizzles() const ...@@ -91,8 +91,7 @@ gl::Error Framebuffer11::invalidateSwizzles() const
gl::Error Framebuffer11::clear(const gl::State &state, const gl::ClearParameters &clearParams) gl::Error Framebuffer11::clear(const gl::State &state, const gl::ClearParameters &clearParams)
{ {
Clear11 *clearer = mRenderer->getClearer(); Clear11 *clearer = mRenderer->getClearer();
gl::Error error = clearer->clearFramebuffer(clearParams, mColorBuffers, mDrawBuffers, gl::Error error = clearer->clearFramebuffer(clearParams, mData);
mDepthbuffer, mStencilbuffer);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -138,7 +137,7 @@ gl::Error Framebuffer11::readPixels(const gl::Rectangle &area, GLenum format, GL ...@@ -138,7 +137,7 @@ gl::Error Framebuffer11::readPixels(const gl::Rectangle &area, GLenum format, GL
ID3D11Texture2D *colorBufferTexture = NULL; ID3D11Texture2D *colorBufferTexture = NULL;
unsigned int subresourceIndex = 0; unsigned int subresourceIndex = 0;
const gl::FramebufferAttachment *colorbuffer = getReadAttachment(); const gl::FramebufferAttachment *colorbuffer = mData.getReadAttachment();
ASSERT(colorbuffer); ASSERT(colorbuffer);
gl::Error error = getRenderTargetResource(colorbuffer, &subresourceIndex, &colorBufferTexture); gl::Error error = getRenderTargetResource(colorbuffer, &subresourceIndex, &colorBufferTexture);
...@@ -194,11 +193,12 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang ...@@ -194,11 +193,12 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
} }
ASSERT(readRenderTarget); ASSERT(readRenderTarget);
for (size_t colorAttachment = 0; colorAttachment < mDrawBuffers.size(); colorAttachment++) for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); colorAttachment++)
{ {
if (mColorBuffers[colorAttachment] != nullptr && mDrawBuffers[colorAttachment] != GL_NONE) if (mData.mColorAttachments[colorAttachment] != nullptr &&
mData.mDrawBufferStates[colorAttachment] != GL_NONE)
{ {
const gl::FramebufferAttachment *drawBuffer = mColorBuffers[colorAttachment]; const gl::FramebufferAttachment *drawBuffer = mData.mColorAttachments[colorAttachment];
RenderTargetD3D *drawRenderTarget = NULL; RenderTargetD3D *drawRenderTarget = NULL;
error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget); error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
...@@ -231,8 +231,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang ...@@ -231,8 +231,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
} }
ASSERT(readRenderTarget); ASSERT(readRenderTarget);
const gl::FramebufferAttachment *drawBuffer = (mDepthbuffer != nullptr) ? mDepthbuffer const gl::FramebufferAttachment *drawBuffer = mData.getDepthOrStencilAttachment();
: mStencilbuffer;
ASSERT(drawBuffer); ASSERT(drawBuffer);
RenderTargetD3D *drawRenderTarget = NULL; RenderTargetD3D *drawRenderTarget = NULL;
......
...@@ -92,7 +92,7 @@ gl::Error RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, co ...@@ -92,7 +92,7 @@ gl::Error RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, co
bool mrt = false; bool mrt = false;
const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender(mRenderer->getWorkarounds()); const gl::AttachmentList &colorbuffers = framebuffer->getColorAttachmentsForRender(mRenderer->getWorkarounds());
BlendStateKey key = { 0 }; BlendStateKey key = { 0 };
key.blendState = blendState; key.blendState = blendState;
......
...@@ -1110,7 +1110,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1110,7 +1110,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
ID3D11RenderTargetView* framebufferRTVs[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL}; ID3D11RenderTargetView* framebufferRTVs[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL};
bool missingColorRenderTarget = true; bool missingColorRenderTarget = true;
const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender(getWorkarounds()); const gl::AttachmentList &colorbuffers = framebuffer->getColorAttachmentsForRender(getWorkarounds());
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{ {
......
...@@ -34,11 +34,10 @@ Framebuffer9::~Framebuffer9() ...@@ -34,11 +34,10 @@ Framebuffer9::~Framebuffer9()
gl::Error Framebuffer9::clear(const gl::State &state, const gl::ClearParameters &clearParams) gl::Error Framebuffer9::clear(const gl::State &state, const gl::ClearParameters &clearParams)
{ {
const gl::FramebufferAttachment *colorBuffer = mColorBuffers[0]; const gl::FramebufferAttachment *colorAttachment = mData.mColorAttachments[0];
const gl::FramebufferAttachment *depthStencilBuffer = (mDepthbuffer != nullptr) ? mDepthbuffer const gl::FramebufferAttachment *depthStencilAttachment = mData.getDepthOrStencilAttachment();
: mStencilbuffer;
gl::Error error = mRenderer->applyRenderTarget(colorBuffer, depthStencilBuffer); gl::Error error = mRenderer->applyRenderTarget(colorAttachment, depthStencilAttachment);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -50,14 +49,14 @@ gl::Error Framebuffer9::clear(const gl::State &state, const gl::ClearParameters ...@@ -50,14 +49,14 @@ gl::Error Framebuffer9::clear(const gl::State &state, const gl::ClearParameters
mRenderer->setScissorRectangle(state.getScissor(), state.isScissorTestEnabled()); mRenderer->setScissorRectangle(state.getScissor(), state.isScissorTestEnabled());
return mRenderer->clear(clearParams, mColorBuffers[0], depthStencilBuffer); return mRenderer->clear(clearParams, colorAttachment, depthStencilAttachment);
} }
gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLenum type, size_t outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) const gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLenum type, size_t outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) const
{ {
ASSERT(pack.pixelBuffer.get() == NULL); ASSERT(pack.pixelBuffer.get() == NULL);
const gl::FramebufferAttachment *colorbuffer = mColorBuffers[0]; const gl::FramebufferAttachment *colorbuffer = mData.mColorAttachments[0];
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget9 *renderTarget = NULL; RenderTarget9 *renderTarget = NULL;
...@@ -255,7 +254,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl ...@@ -255,7 +254,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
} }
ASSERT(readRenderTarget); ASSERT(readRenderTarget);
const gl::FramebufferAttachment *drawBuffer = mColorBuffers[0]; const gl::FramebufferAttachment *drawBuffer = mData.mColorAttachments[0];
ASSERT(drawBuffer); ASSERT(drawBuffer);
RenderTarget9 *drawRenderTarget = NULL; RenderTarget9 *drawRenderTarget = NULL;
...@@ -381,8 +380,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl ...@@ -381,8 +380,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
} }
ASSERT(readDepthStencil); ASSERT(readDepthStencil);
const gl::FramebufferAttachment *drawBuffer = (mDepthbuffer != nullptr) ? mDepthbuffer const gl::FramebufferAttachment *drawBuffer = mData.getDepthOrStencilAttachment();
: mStencilbuffer;
ASSERT(drawBuffer); ASSERT(drawBuffer);
RenderTarget9 *drawDepthStencil = NULL; RenderTarget9 *drawDepthStencil = NULL;
......
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