| Index: gpu/command_buffer/service/framebuffer_manager.cc
|
| diff --git a/gpu/command_buffer/service/framebuffer_manager.cc b/gpu/command_buffer/service/framebuffer_manager.cc
|
| index ccd593aac225d52313867ba0472f7b9312fd0adc..7b471e2a7ef7978022f7e9d6d5997175f1bce30e 100644
|
| --- a/gpu/command_buffer/service/framebuffer_manager.cc
|
| +++ b/gpu/command_buffer/service/framebuffer_manager.cc
|
| @@ -129,6 +129,10 @@ class RenderbufferAttachment
|
| return false;
|
| }
|
|
|
| + bool EmulatingRGB() const override { return false; }
|
| + bool Initialized() const override { return true; }
|
| + void SetInitialized(bool initialized) override {}
|
| +
|
| protected:
|
| ~RenderbufferAttachment() override {}
|
|
|
| @@ -141,15 +145,17 @@ class RenderbufferAttachment
|
| class TextureAttachment
|
| : public Framebuffer::Attachment {
|
| public:
|
| - TextureAttachment(
|
| - TextureRef* texture_ref, GLenum target, GLint level,
|
| - GLsizei samples, GLint layer)
|
| + TextureAttachment(TextureRef* texture_ref,
|
| + GLenum target,
|
| + GLint level,
|
| + GLsizei samples,
|
| + GLint layer)
|
| : texture_ref_(texture_ref),
|
| target_(target),
|
| level_(level),
|
| samples_(samples),
|
| - layer_(layer) {
|
| - }
|
| + layer_(layer),
|
| + initialized_(false) {}
|
|
|
| GLsizei width() const override {
|
| GLsizei temp_width = 0;
|
| @@ -250,6 +256,8 @@ class TextureAttachment
|
| DCHECK_NE(0u, need);
|
| uint32_t have = GLES2Util::GetChannelsForFormat(internal_format);
|
|
|
| + have |= EmulatingRGB() ? GLES2Util::ChannelBits::kAlpha : 0;
|
| +
|
| // Workaround for NVIDIA drivers that incorrectly expose these formats as
|
| // renderable:
|
| if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA ||
|
| @@ -277,6 +285,13 @@ class TextureAttachment
|
| return texture == texture_ref_.get() && level == level_;
|
| }
|
|
|
| + bool EmulatingRGB() const override {
|
| + return texture_ref_->texture()->EmulatingRGB();
|
| + }
|
| +
|
| + bool Initialized() const override { return initialized_; }
|
| + void SetInitialized(bool initialized) override { initialized_ = initialized; }
|
| +
|
| protected:
|
| ~TextureAttachment() override {}
|
|
|
| @@ -286,6 +301,7 @@ class TextureAttachment
|
| GLint level_;
|
| GLsizei samples_;
|
| GLint layer_;
|
| + bool initialized_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
|
| };
|
| @@ -400,6 +416,40 @@ bool Framebuffer::HasUnclearedColorAttachments() const {
|
| return false;
|
| }
|
|
|
| +bool Framebuffer::HasUninitializedDrawBuffers() const {
|
| + for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
|
| + if (draw_buffers_[i] != GL_NONE) {
|
| + const Attachment* attachment = GetAttachment(draw_buffers_[i]);
|
| + if (!attachment)
|
| + continue;
|
| + if (!attachment->EmulatingRGB())
|
| + continue;
|
| + if (attachment->Initialized())
|
| + continue;
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +void Framebuffer::SetDrawBuffersAsInitialized() {
|
| + for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
|
| + if (draw_buffers_[i] != GL_NONE) {
|
| + AttachmentMap::iterator it = attachments_.find(draw_buffers_[i]);
|
| + if (it == attachments_.end())
|
| + continue;
|
| + Attachment* attachment = it->second.get();
|
| + if (!attachment)
|
| + continue;
|
| + if (!attachment->EmulatingRGB())
|
| + continue;
|
| + if (attachment->Initialized())
|
| + continue;
|
| + attachment->SetInitialized(true);
|
| + }
|
| + }
|
| +}
|
| +
|
| bool Framebuffer::HasUnclearedIntRenderbufferAttachments() const {
|
| for (AttachmentMap::const_iterator it = attachments_.begin();
|
| it != attachments_.end(); ++it) {
|
| @@ -537,6 +587,16 @@ GLenum Framebuffer::GetReadBufferInternalFormat() const {
|
| return 0;
|
| }
|
| const Attachment* attachment = it->second.get();
|
| + if (attachment->EmulatingRGB()) {
|
| + switch (attachment->internal_format()) {
|
| + case GL_RGBA:
|
| + return GL_RGB;
|
| + case GL_BGRA_EXT:
|
| + return GL_BGR_EXT;
|
| + default:
|
| + break;
|
| + }
|
| + }
|
| return attachment->internal_format();
|
| }
|
|
|
| @@ -662,6 +722,8 @@ bool Framebuffer::HasAlphaMRT() const {
|
| const Attachment* attachment = GetAttachment(draw_buffers_[i]);
|
| if (!attachment)
|
| continue;
|
| + if (attachment->EmulatingRGB())
|
| + return false;
|
| if ((GLES2Util::GetChannelsForFormat(
|
| attachment->internal_format()) & 0x0008) != 0)
|
| return true;
|
| @@ -670,6 +732,19 @@ bool Framebuffer::HasAlphaMRT() const {
|
| return false;
|
| }
|
|
|
| +bool Framebuffer::EmulatingRGB() const {
|
| + for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
|
| + if (draw_buffers_[i] != GL_NONE) {
|
| + const Attachment* attachment = GetAttachment(draw_buffers_[i]);
|
| + if (!attachment)
|
| + continue;
|
| + if (attachment->EmulatingRGB())
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| bool Framebuffer::HasSameInternalFormatsMRT() const {
|
| GLenum internal_format = 0;
|
| for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
|
|
|