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

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

Issue 2389363002: Move special DEPTH_STENCIL attachment logic from command buffers to WebGL1 (Closed)
Patch Set: Created 4 years, 2 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/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 85b7df82f8ca9908ac73845b9a4515c343df7495..7933a66c4652543755e9ae5646f24705f73bb67b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -5864,9 +5864,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,
@@ -5875,10 +5872,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(),
@@ -7127,19 +7120,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;
@@ -7227,16 +7222,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;
@@ -7382,11 +7375,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;
@@ -7436,8 +7429,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;
}
@@ -7493,6 +7493,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) {
@@ -7602,9 +7617,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)) {
@@ -7613,9 +7628,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)) {

Powered by Google App Engine
This is Rietveld 408576698