Commit ce20c7f1 by Jamie Madill

Retrieve render colorbuffers as a single vector.

Making all our render methods query FBO attachments for rendering in one place will allow us to easily control the MRT peformance workaround, and simplify the implementation. BUG=angle:705 Change-Id: I6c476d45b81228d6ffe8831347443994237e3593 Reviewed-on: https://chromium-review.googlesource.com/215843Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent 04668675
......@@ -668,6 +668,29 @@ bool Framebuffer::hasValidDepthStencil() const
mDepthbuffer->id() == mStencilbuffer->id());
}
ColorbufferInfo Framebuffer::getColorbuffersForRender() const
{
ColorbufferInfo colorbuffersForRender;
for (size_t colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; ++colorAttachment)
{
GLenum drawBufferState = mDrawBufferStates[colorAttachment];
FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment];
if (colorbuffer != NULL && drawBufferState != GL_NONE)
{
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
colorbuffersForRender.push_back(colorbuffer);
}
else
{
colorbuffersForRender.push_back(NULL);
}
}
return colorbuffersForRender;
}
GLenum DefaultFramebuffer::completeness() const
{
// The default framebuffer *must* always be complete, though it may not be
......
......@@ -10,6 +10,8 @@
#ifndef LIBGLESV2_FRAMEBUFFER_H_
#define LIBGLESV2_FRAMEBUFFER_H_
#include <vector>
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "constants.h"
......@@ -28,6 +30,8 @@ class Stencilbuffer;
class DepthStencilbuffer;
struct Caps;
typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
class Framebuffer
{
public:
......@@ -72,6 +76,11 @@ class Framebuffer
void invalidateSub(const Caps &caps, GLsizei numAttachments, const GLenum *attachments,
GLint x, GLint y, GLsizei width, GLsizei height);
// Use this method to retrieve the color buffer map when doing rendering.
// It will apply a workaround for poor shader performance on some systems
// by compacting the list to skip NULL values.
ColorbufferInfo getColorbuffersForRender() const;
protected:
rx::Renderer *mRenderer;
......
......@@ -89,29 +89,27 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::Framebuffer *framebu
bool mrt = false;
const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender();
BlendStateKey key = { 0 };
key.blendState = blendState;
for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{
const gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(i);
const gl::FramebufferAttachment *attachment = colorbuffers[colorAttachment];
auto rtChannels = key.rtChannels[colorAttachment];
if (attachment)
{
if (i > 0)
if (colorAttachment > 0)
{
mrt = true;
}
key.rtChannels[i][0] = attachment->getRedSize() > 0;
key.rtChannels[i][1] = attachment->getGreenSize() > 0;
key.rtChannels[i][2] = attachment->getBlueSize() > 0;
key.rtChannels[i][3] = attachment->getAlphaSize() > 0;
}
else
{
key.rtChannels[i][0] = false;
key.rtChannels[i][1] = false;
key.rtChannels[i][2] = false;
key.rtChannels[i][3] = false;
rtChannels[0] = attachment->getRedSize() > 0;
rtChannels[1] = attachment->getGreenSize() > 0;
rtChannels[2] = attachment->getBlueSize() > 0;
rtChannels[3] = attachment->getAlphaSize() > 0;
}
}
......
......@@ -793,15 +793,15 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
ID3D11RenderTargetView* framebufferRTVs[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL};
bool missingColorRenderTarget = true;
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender();
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{
const GLenum drawBufferState = framebuffer->getDrawBufferState(colorAttachment);
gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(colorAttachment);
gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment];
if (colorbuffer && drawBufferState != GL_NONE)
if (colorbuffer)
{
// the draw buffer must be either "none", "back" for the default buffer or the same index as this color (in order)
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
// check for zero-sized default framebuffer, which is a special case.
// in this case we do not wish to modify any state and just silently return false.
......
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