| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| index fad05fe6ff9d4458c167d167cc854ca3fcf09400..db0b2f3722b73934335f0ac2a30b8722b6012bce 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -5857,9 +5857,6 @@ void GLES2DecoderImpl::InvalidateFramebufferImpl(
|
| for (GLsizei i = 0; i < validated_count; ++i) {
|
| if (framebuffer) {
|
| if (validated_attachments[i] == GL_DEPTH_STENCIL_ATTACHMENT) {
|
| - // TODO(qiankun.miao@intel.com): We should only mark DEPTH and STENCIL
|
| - // attachments as cleared when command buffer handles DEPTH_STENCIL
|
| - // well. http://crbug.com/630568
|
| framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(),
|
| texture_manager(),
|
| GL_DEPTH_ATTACHMENT,
|
| @@ -5868,10 +5865,6 @@ void GLES2DecoderImpl::InvalidateFramebufferImpl(
|
| texture_manager(),
|
| GL_STENCIL_ATTACHMENT,
|
| false);
|
| - framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(),
|
| - texture_manager(),
|
| - GL_DEPTH_STENCIL_ATTACHMENT,
|
| - false);
|
| } else {
|
| framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(),
|
| texture_manager(),
|
| @@ -7120,19 +7113,21 @@ void GLES2DecoderImpl::DoFramebufferRenderbuffer(
|
| }
|
| service_id = renderbuffer->service_id();
|
| }
|
| - LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer");
|
| + std::vector<GLenum> attachments;
|
| if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
|
| - glFramebufferRenderbufferEXT(
|
| - target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id);
|
| - glFramebufferRenderbufferEXT(
|
| - target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id);
|
| + attachments.push_back(GL_DEPTH_ATTACHMENT);
|
| + attachments.push_back(GL_STENCIL_ATTACHMENT);
|
| } else {
|
| - glFramebufferRenderbufferEXT(
|
| - target, attachment, renderbuffertarget, service_id);
|
| + attachments.push_back(attachment);
|
| }
|
| - GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer");
|
| - if (error == GL_NO_ERROR) {
|
| - framebuffer->AttachRenderbuffer(attachment, renderbuffer);
|
| + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer");
|
| + for (GLenum attachment_point : attachments) {
|
| + glFramebufferRenderbufferEXT(
|
| + target, attachment_point, renderbuffertarget, service_id);
|
| + GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer");
|
| + if (error == GL_NO_ERROR) {
|
| + framebuffer->AttachRenderbuffer(attachment_point, renderbuffer);
|
| + }
|
| }
|
| if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
|
| framebuffer_state_.clear_state_dirty = true;
|
| @@ -7220,16 +7215,14 @@ void GLES2DecoderImpl::ClearUnclearedAttachments(
|
| }
|
| }
|
|
|
| - if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) ||
|
| - framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) {
|
| + if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)) {
|
| glClearStencil(0);
|
| state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
|
| state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
|
| clear_bits |= GL_STENCIL_BUFFER_BIT;
|
| }
|
|
|
| - if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) ||
|
| - framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) {
|
| + if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)) {
|
| glClearDepth(1.0f);
|
| state_.SetDeviceDepthMask(GL_TRUE);
|
| clear_bits |= GL_DEPTH_BUFFER_BIT;
|
| @@ -7375,11 +7368,11 @@ void GLES2DecoderImpl::DoFramebufferTexture2DCommon(
|
| target, attachments[ii], textarget, service_id, level, samples);
|
| }
|
| }
|
| - }
|
| - GLenum error = LOCAL_PEEK_GL_ERROR(name);
|
| - if (error == GL_NO_ERROR) {
|
| - framebuffer->AttachTexture(attachment, texture_ref, textarget, level,
|
| - samples);
|
| + GLenum error = LOCAL_PEEK_GL_ERROR(name);
|
| + if (error == GL_NO_ERROR) {
|
| + framebuffer->AttachTexture(attachments[ii], texture_ref, textarget, level,
|
| + samples);
|
| + }
|
| }
|
| if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
|
| framebuffer_state_.clear_state_dirty = true;
|
| @@ -7429,8 +7422,15 @@ void GLES2DecoderImpl::DoFramebufferTextureLayer(
|
| }
|
| }
|
| glFramebufferTextureLayer(target, attachment, service_id, level, layer);
|
| - framebuffer->AttachTextureLayer(
|
| - attachment, texture_ref, texture_target, level, layer);
|
| + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
|
| + framebuffer->AttachTextureLayer(
|
| + GL_DEPTH_ATTACHMENT, texture_ref, texture_target, level, layer);
|
| + framebuffer->AttachTextureLayer(
|
| + GL_STENCIL_ATTACHMENT, texture_ref, texture_target, level, layer);
|
| + } else {
|
| + framebuffer->AttachTextureLayer(
|
| + attachment, texture_ref, texture_target, level, layer);
|
| + }
|
| if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
|
| framebuffer_state_.clear_state_dirty = true;
|
| }
|
| @@ -7486,6 +7486,21 @@ void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
|
| break;
|
| }
|
| }
|
| + } else {
|
| + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
|
| + const Framebuffer::Attachment* depth =
|
| + framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
|
| + const Framebuffer::Attachment* stencil =
|
| + framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
|
| + if ((!depth && !stencil) ||
|
| + (depth && stencil && depth->IsSameAttachment(stencil))) {
|
| + attachment = GL_DEPTH_ATTACHMENT;
|
| + } else {
|
| + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
|
| + "depth and stencil attachment mismatch");
|
| + return;
|
| + }
|
| + }
|
| }
|
| if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT &&
|
| features().use_img_for_multisampled_render_to_texture) {
|
| @@ -7595,9 +7610,9 @@ void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(
|
| DCHECK(read_framebuffer && draw_framebuffer);
|
| if ((mask & GL_DEPTH_BUFFER_BIT) != 0) {
|
| const Framebuffer::Attachment* depth_buffer_read =
|
| - read_framebuffer->GetDepthAttachment();
|
| + read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
|
| const Framebuffer::Attachment* depth_buffer_draw =
|
| - draw_framebuffer->GetDepthAttachment();
|
| + draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
|
| if (!depth_buffer_draw || !depth_buffer_read) {
|
| mask &= ~GL_DEPTH_BUFFER_BIT;
|
| } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) {
|
| @@ -7606,9 +7621,9 @@ void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(
|
| }
|
| if ((mask & GL_STENCIL_BUFFER_BIT) != 0) {
|
| const Framebuffer::Attachment* stencil_buffer_read =
|
| - read_framebuffer->GetStencilAttachment();
|
| + read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
|
| const Framebuffer::Attachment* stencil_buffer_draw =
|
| - draw_framebuffer->GetStencilAttachment();
|
| + draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
|
| if (!stencil_buffer_draw || !stencil_buffer_read) {
|
| mask &= ~GL_STENCIL_BUFFER_BIT;
|
| } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {
|
|
|