Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: gpu/command_buffer/service/framebuffer_manager.cc

Issue 1830453002: WebGL: GL_RGB emulation for IOSurface backed textures. [For reference only] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698