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

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

Issue 12545014: Implement EXT_draw_buffers WebGL extention support in command buffer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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
Index: gpu/command_buffer/service/framebuffer_manager.cc
===================================================================
--- gpu/command_buffer/service/framebuffer_manager.cc (revision 187725)
+++ gpu/command_buffer/service/framebuffer_manager.cc (working copy)
@@ -75,9 +75,10 @@
// Nothing to do for renderbuffers.
}
- virtual bool ValidForAttachmentType(GLenum attachment_type) OVERRIDE {
+ virtual bool ValidForAttachmentType(
+ GLenum attachment_type, uint32 max_color_attachments) OVERRIDE {
uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
- attachment_type);
+ attachment_type, max_color_attachments);
uint32 have = GLES2Util::GetChannelsForFormat(internal_format());
return (need & have) != 0;
}
@@ -169,14 +170,15 @@
texture_->DetachFromFramebuffer();
}
- virtual bool ValidForAttachmentType(GLenum attachment_type) OVERRIDE {
+ virtual bool ValidForAttachmentType(
+ GLenum attachment_type, uint32 max_color_attachments) OVERRIDE {
GLenum type = 0;
GLenum internal_format = 0;
if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) {
return false;
}
uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
- attachment_type);
+ attachment_type, max_color_attachments);
uint32 have = GLES2Util::GetChannelsForFormat(internal_format);
return (need & have) != 0;
}
@@ -198,10 +200,15 @@
DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
};
-FramebufferManager::FramebufferManager()
+FramebufferManager::FramebufferManager(
+ uint32 max_draw_buffers, uint32 max_color_attachments)
: framebuffer_state_change_count_(1),
framebuffer_count_(0),
- have_context_(true) {
+ have_context_(true),
+ max_draw_buffers_(max_draw_buffers),
+ max_color_attachments_(max_color_attachments) {
+ DCHECK_GT(max_draw_buffers_, 0u);
+ DCHECK_GT(max_color_attachments_, 0u);
}
FramebufferManager::~FramebufferManager() {
@@ -254,6 +261,11 @@
has_been_bound_(false),
framebuffer_complete_state_count_id_(0) {
manager->StartTracking(this);
+ DCHECK_GT(manager->max_draw_buffers_, 0u);
+ draw_buffers_.reset(new GLenum[manager->max_draw_buffers_]);
+ draw_buffers_[0] = GL_COLOR_ATTACHMENT0;
+ for (uint32 i = 1; i < manager->max_draw_buffers_; ++i)
+ draw_buffers_[i] = GL_NONE;
}
Framebuffer::~Framebuffer() {
@@ -337,7 +349,8 @@
it != attachments_.end(); ++it) {
GLenum attachment_type = it->first;
Attachment* attachment = it->second;
- if (!attachment->ValidForAttachmentType(attachment_type)) {
+ if (!attachment->ValidForAttachmentType(
+ attachment_type, manager_->max_color_attachments_)) {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (width < 0) {
@@ -402,6 +415,20 @@
return true;
}
+GLenum Framebuffer::GetDrawBuffer(GLenum draw_buffer) const {
+ GLsizei index = static_cast<GLsizei>(
+ draw_buffer - GL_DRAW_BUFFER0_ARB);
+ CHECK(index >= 0 &&
+ index < static_cast<GLsizei>(manager_->max_draw_buffers_));
+ return draw_buffers_[index];
+}
+
+void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) {
+ DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_));
+ for (GLsizei i = 0; i < n; ++i)
+ draw_buffers_[i] = bufs[i];
+}
+
void Framebuffer::UnbindRenderbuffer(
GLenum target, Renderbuffer* renderbuffer) {
bool done;
@@ -456,10 +483,6 @@
void Framebuffer::AttachRenderbuffer(
GLenum attachment, Renderbuffer* renderbuffer) {
- DCHECK(attachment == GL_COLOR_ATTACHMENT0 ||
- attachment == GL_DEPTH_ATTACHMENT ||
- attachment == GL_STENCIL_ATTACHMENT ||
- attachment == GL_DEPTH_STENCIL_ATTACHMENT);
const Attachment* a = GetAttachment(attachment);
if (a)
a->DetachFromFramebuffer();
@@ -475,10 +498,6 @@
void Framebuffer::AttachTexture(
GLenum attachment, Texture* texture, GLenum target,
GLint level) {
- DCHECK(attachment == GL_COLOR_ATTACHMENT0 ||
- attachment == GL_DEPTH_ATTACHMENT ||
- attachment == GL_STENCIL_ATTACHMENT ||
- attachment == GL_DEPTH_STENCIL_ATTACHMENT);
const Attachment* a = GetAttachment(attachment);
if (a)
a->DetachFromFramebuffer();
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/framebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698