Hash :
888081d5
Author :
Date :
2018-02-27T00:24:46
D3D11: Refactor dependent Framebuffer state changes. Previously, when a state change would cause a Texture to recreate its storage specific to D3D11, we would use a dependent notification from RenderTarget11 to Framebuffer11 to re-check internal dirty bits. In this new method, we instead set dirty bits on the gl::Frambuffer directly. This also means we use fewer internal objects for these notifications, because we share the same structures between the D3D11 back-end notifications and the top-level notifications we use for Robust init and Framebuffer completeness. This also allows us to get rid of one "if" that we check on every draw call in D3D11. This also introduces a dirty bits guard concept - a shadow set of dirty bits that is checked in dependent state changes to ensure that extra bits aren't set inside syncState. This also implements Framebuffer dirty bits for the D3D9 back-end. This has the side effect of cleaning up the "null colorbuffer" D3D9 workaround. Bug: angleproject:2372 Change-Id: Ie346d39030f4f6df583d735685b0babea4e745a8 Reviewed-on: https://chromium-review.googlesource.com/936691 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Renderbuffer.cpp: Implements the renderer-agnostic gl::Renderbuffer class,
// GL renderbuffer objects and related functionality.
// [OpenGL ES 2.0.24] section 4.4.3 page 108.
#include "libANGLE/Renderbuffer.h"
#include "common/utilities.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Image.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
namespace gl
{
// RenderbufferState implementation.
RenderbufferState::RenderbufferState()
: mWidth(0), mHeight(0), mFormat(GL_RGBA4), mSamples(0), mInitState(InitState::MayNeedInit)
{
}
RenderbufferState::~RenderbufferState()
{
}
GLsizei RenderbufferState::getWidth() const
{
return mWidth;
}
GLsizei RenderbufferState::getHeight() const
{
return mHeight;
}
const Format &RenderbufferState::getFormat() const
{
return mFormat;
}
GLsizei RenderbufferState::getSamples() const
{
return mSamples;
}
void RenderbufferState::update(GLsizei width,
GLsizei height,
const Format &format,
GLsizei samples,
InitState initState)
{
mWidth = static_cast<GLsizei>(width);
mHeight = static_cast<GLsizei>(height);
mFormat = format;
mSamples = samples;
mInitState = InitState::MayNeedInit;
}
// Renderbuffer implementation.
Renderbuffer::Renderbuffer(rx::GLImplFactory *implFactory, GLuint id)
: egl::ImageSibling(id),
mState(),
mImplementation(implFactory->createRenderbuffer(mState)),
mLabel()
{
}
Error Renderbuffer::onDestroy(const Context *context)
{
ANGLE_TRY(orphanImages(context));
if (mImplementation)
{
ANGLE_TRY(mImplementation->onDestroy(context));
}
return NoError();
}
Renderbuffer::~Renderbuffer()
{
}
void Renderbuffer::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Renderbuffer::getLabel() const
{
return mLabel;
}
Error Renderbuffer::setStorage(const Context *context,
GLenum internalformat,
size_t width,
size_t height)
{
ANGLE_TRY(orphanImages(context));
ANGLE_TRY(mImplementation->setStorage(context, internalformat, width, height));
mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat),
0, InitState::MayNeedInit);
onStateChange(context);
return NoError();
}
Error Renderbuffer::setStorageMultisample(const Context *context,
size_t samples,
GLenum internalformat,
size_t width,
size_t height)
{
ANGLE_TRY(orphanImages(context));
ANGLE_TRY(
mImplementation->setStorageMultisample(context, samples, internalformat, width, height));
mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat),
static_cast<GLsizei>(samples), InitState::MayNeedInit);
onStateChange(context);
return NoError();
}
Error Renderbuffer::setStorageEGLImageTarget(const Context *context, egl::Image *image)
{
ANGLE_TRY(orphanImages(context));
ANGLE_TRY(mImplementation->setStorageEGLImageTarget(context, image));
setTargetImage(context, image);
mState.update(static_cast<GLsizei>(image->getWidth()), static_cast<GLsizei>(image->getHeight()),
Format(image->getFormat()), 0, image->sourceInitState());
onStateChange(context);
return NoError();
}
rx::RenderbufferImpl *Renderbuffer::getImplementation() const
{
ASSERT(mImplementation);
return mImplementation.get();
}
GLsizei Renderbuffer::getWidth() const
{
return mState.mWidth;
}
GLsizei Renderbuffer::getHeight() const
{
return mState.mHeight;
}
const Format &Renderbuffer::getFormat() const
{
return mState.mFormat;
}
GLsizei Renderbuffer::getSamples() const
{
return mState.mSamples;
}
GLuint Renderbuffer::getRedSize() const
{
return mState.mFormat.info->redBits;
}
GLuint Renderbuffer::getGreenSize() const
{
return mState.mFormat.info->greenBits;
}
GLuint Renderbuffer::getBlueSize() const
{
return mState.mFormat.info->blueBits;
}
GLuint Renderbuffer::getAlphaSize() const
{
return mState.mFormat.info->alphaBits;
}
GLuint Renderbuffer::getDepthSize() const
{
return mState.mFormat.info->depthBits;
}
GLuint Renderbuffer::getStencilSize() const
{
return mState.mFormat.info->stencilBits;
}
void Renderbuffer::onAttach(const Context *context)
{
addRef();
}
void Renderbuffer::onDetach(const Context *context)
{
release(context);
}
GLuint Renderbuffer::getId() const
{
return id();
}
Extents Renderbuffer::getAttachmentSize(const gl::ImageIndex & /*imageIndex*/) const
{
return Extents(mState.mWidth, mState.mHeight, 1);
}
const Format &Renderbuffer::getAttachmentFormat(GLenum /*binding*/,
const ImageIndex & /*imageIndex*/) const
{
return getFormat();
}
GLsizei Renderbuffer::getAttachmentSamples(const ImageIndex & /*imageIndex*/) const
{
return getSamples();
}
InitState Renderbuffer::initState(const gl::ImageIndex & /*imageIndex*/) const
{
if (isEGLImageTarget())
{
return sourceEGLImageInitState();
}
return mState.mInitState;
}
void Renderbuffer::setInitState(const gl::ImageIndex & /*imageIndex*/, InitState initState)
{
if (isEGLImageTarget())
{
setSourceEGLImageInitState(initState);
}
else
{
mState.mInitState = initState;
}
}
rx::FramebufferAttachmentObjectImpl *Renderbuffer::getAttachmentImpl() const
{
return mImplementation.get();
}
} // namespace gl