Commit 85a1804d by Jamie Madill

Make getColorAttachmentsForRender D3D-only.

This encapsulates the workaround in the D3D renderer, and also optimizes the workaround to only compute a new set of attachments when there is a change to the state. BUG=angleproject:930 Change-Id: Ibdc15078236e2d19b544fae8e65b7f2554f31844 Reviewed-on: https://chromium-review.googlesource.com/254102Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 7147f01a
...@@ -544,11 +544,6 @@ bool Framebuffer::hasValidDepthStencil() const ...@@ -544,11 +544,6 @@ bool Framebuffer::hasValidDepthStencil() const
mData.mDepthAttachment->id() == mData.mStencilAttachment->id()); mData.mDepthAttachment->id() == mData.mStencilAttachment->id());
} }
AttachmentList Framebuffer::getColorAttachmentsForRender(const rx::Workarounds &workarounds) const
{
return mImpl->getColorAttachmentsForRender(workarounds);
}
void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex) void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex)
{ {
setAttachment(attachment, new TextureAttachment(attachment, texture, imageIndex)); setAttachment(attachment, new TextureAttachment(attachment, texture, imageIndex));
......
...@@ -128,11 +128,6 @@ class Framebuffer ...@@ -128,11 +128,6 @@ 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 attachment map when doing rendering.
// It will apply a workaround for poor shader performance on some systems
// by compacting the list to skip NULL values.
AttachmentList getColorAttachmentsForRender(const rx::Workarounds &workarounds) const;
protected: protected:
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj); void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
void detachResourceById(GLenum resourceType, GLuint resourceId); void detachResourceById(GLenum resourceType, GLuint resourceId);
......
...@@ -59,8 +59,6 @@ class FramebufferImpl ...@@ -59,8 +59,6 @@ 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;
......
...@@ -63,7 +63,8 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const ...@@ -63,7 +63,8 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const
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),
mColorAttachmentsForRender(mData.mColorAttachments.size(), nullptr) mColorAttachmentsForRender(mData.mColorAttachments.size(), nullptr),
mInvalidateColorAttachmentCache(true)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
} }
...@@ -74,6 +75,7 @@ FramebufferD3D::~FramebufferD3D() ...@@ -74,6 +75,7 @@ FramebufferD3D::~FramebufferD3D()
void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *) void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *)
{ {
mInvalidateColorAttachmentCache = true;
} }
void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *) void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *)
...@@ -90,6 +92,7 @@ void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment * ...@@ -90,6 +92,7 @@ void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *
void FramebufferD3D::setDrawBuffers(size_t, const GLenum *) void FramebufferD3D::setDrawBuffers(size_t, const GLenum *)
{ {
mInvalidateColorAttachmentCache = true;
} }
void FramebufferD3D::setReadBuffer(GLenum) void FramebufferD3D::setReadBuffer(GLenum)
...@@ -308,6 +311,16 @@ GLenum FramebufferD3D::checkStatus() const ...@@ -308,6 +311,16 @@ GLenum FramebufferD3D::checkStatus() const
const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const
{ {
if (!workarounds.mrtPerfWorkaround)
{
return mData.mColorAttachments;
}
if (!mInvalidateColorAttachmentCache)
{
return mColorAttachmentsForRender;
}
// Does not actually free memory // Does not actually free memory
mColorAttachmentsForRender.clear(); mColorAttachmentsForRender.clear();
...@@ -321,12 +334,9 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor ...@@ -321,12 +334,9 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex)); ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
mColorAttachmentsForRender.push_back(colorAttachment); mColorAttachmentsForRender.push_back(colorAttachment);
} }
else if (!workarounds.mrtPerfWorkaround)
{
mColorAttachmentsForRender.push_back(nullptr);
}
} }
mInvalidateColorAttachmentCache = false;
return mColorAttachmentsForRender; return mColorAttachmentsForRender;
} }
......
...@@ -80,11 +80,12 @@ class FramebufferD3D : public FramebufferImpl ...@@ -80,11 +80,12 @@ class FramebufferD3D : public FramebufferImpl
GLenum checkStatus() const override; GLenum checkStatus() const override;
const gl::AttachmentList &getColorAttachmentsForRender(const Workarounds &workarounds) const override; const gl::AttachmentList &getColorAttachmentsForRender(const Workarounds &workarounds) const;
protected: protected:
// Cache variable // Cache variable
mutable gl::AttachmentList mColorAttachmentsForRender; mutable gl::AttachmentList mColorAttachmentsForRender;
mutable bool mInvalidateColorAttachmentCache;
private: private:
DISALLOW_COPY_AND_ASSIGN(FramebufferD3D); DISALLOW_COPY_AND_ASSIGN(FramebufferD3D);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/features.h" #include "libANGLE/features.h"
#include "libANGLE/renderer/d3d/DynamicHLSL.h" #include "libANGLE/renderer/d3d/DynamicHLSL.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h" #include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/ShaderExecutableD3D.h" #include "libANGLE/renderer/d3d/ShaderExecutableD3D.h"
...@@ -841,7 +842,8 @@ gl::Error ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fb ...@@ -841,7 +842,8 @@ gl::Error ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fb
{ {
std::vector<GLenum> outputs; std::vector<GLenum> outputs;
const gl::AttachmentList &colorbuffers = fbo->getColorAttachmentsForRender(mRenderer->getWorkarounds()); const FramebufferD3D *fboD3D = GetImplAs<FramebufferD3D>(fbo);
const gl::AttachmentList &colorbuffers = fboD3D->getColorAttachmentsForRender(mRenderer->getWorkarounds());
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{ {
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
// state objects. // state objects.
#include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h" #include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "third_party/murmurhash/MurmurHash3.h" #include "third_party/murmurhash/MurmurHash3.h"
namespace rx namespace rx
...@@ -92,7 +92,8 @@ gl::Error RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, co ...@@ -92,7 +92,8 @@ gl::Error RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, co
bool mrt = false; bool mrt = false;
const gl::AttachmentList &colorbuffers = framebuffer->getColorAttachmentsForRender(mRenderer->getWorkarounds()); const FramebufferD3D *framebufferD3D = GetImplAs<FramebufferD3D>(framebuffer);
const gl::AttachmentList &colorbuffers = framebufferD3D->getColorAttachmentsForRender(mRenderer->getWorkarounds());
BlendStateKey key = { 0 }; BlendStateKey key = { 0 };
key.blendState = blendState; key.blendState = blendState;
......
...@@ -1110,7 +1110,8 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1110,7 +1110,8 @@ 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::AttachmentList &colorbuffers = framebuffer->getColorAttachmentsForRender(getWorkarounds()); const FramebufferD3D *framebufferD3D = GetImplAs<FramebufferD3D>(framebuffer);
const gl::AttachmentList &colorbuffers = framebufferD3D->getColorAttachmentsForRender(getWorkarounds());
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{ {
......
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