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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2461973002: [Command buffer] Feedback loop detection between texture and framebuffer attachments
Patch Set: Addressed zmo@'s feedback: MRT can be supported in WebGL1 or ES2 by extension Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 // -1. If the current program is not valid generates the appropriate GL 1314 // -1. If the current program is not valid generates the appropriate GL
1315 // error. Returns true if the current program is in a usable state and 1315 // error. Returns true if the current program is in a usable state and
1316 // location is not -1. 1316 // location is not -1.
1317 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); 1317 bool CheckCurrentProgramForUniform(GLint location, const char* function_name);
1318 1318
1319 // Checks if the current program samples a texture that is also the color 1319 // Checks if the current program samples a texture that is also the color
1320 // image of the current bound framebuffer, i.e., the source and destination 1320 // image of the current bound framebuffer, i.e., the source and destination
1321 // of the draw operation are the same. 1321 // of the draw operation are the same.
1322 bool CheckDrawingFeedbackLoops(); 1322 bool CheckDrawingFeedbackLoops();
1323 1323
1324 // Helper for CheckDrawingFeedbackLoops. Returns true if the attachment is
1325 // the same one where it samples from during drawing.
1326 bool CheckDrawingFeedbackLoopsHelper(
1327 const Framebuffer::Attachment* attachment);
1328
1324 bool SupportsDrawBuffers() const; 1329 bool SupportsDrawBuffers() const;
1325 1330
1326 // Checks if a draw buffer's format and its corresponding fragment shader 1331 // Checks if a draw buffer's format and its corresponding fragment shader
1327 // output's type are compatible, i.e., a signed integer typed variable is 1332 // output's type are compatible, i.e., a signed integer typed variable is
1328 // incompatible with a float or unsigned integer buffer. 1333 // incompatible with a float or unsigned integer buffer.
1329 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer 1334 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer
1330 // contents and return false. 1335 // contents and return false.
1331 // Otherwise, filter out the draw buffers that are not written to but are not 1336 // Otherwise, filter out the draw buffers that are not written to but are not
1332 // NONE through DrawBuffers, to be on the safe side. Return true. 1337 // NONE through DrawBuffers, to be on the safe side. Return true.
1333 bool ValidateAndAdjustDrawBuffers(const char* function_name); 1338 bool ValidateAndAdjustDrawBuffers(const char* function_name);
(...skipping 7304 matching lines...) Expand 10 before | Expand all | Expand 10 after
8638 8643
8639 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( 8644 bool GLES2DecoderImpl::CheckCurrentProgramForUniform(
8640 GLint location, const char* function_name) { 8645 GLint location, const char* function_name) {
8641 if (!CheckCurrentProgram(function_name)) { 8646 if (!CheckCurrentProgram(function_name)) {
8642 return false; 8647 return false;
8643 } 8648 }
8644 return !state_.current_program->IsInactiveUniformLocationByFakeLocation( 8649 return !state_.current_program->IsInactiveUniformLocationByFakeLocation(
8645 location); 8650 location);
8646 } 8651 }
8647 8652
8648 bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() { 8653 bool GLES2DecoderImpl::CheckDrawingFeedbackLoopsHelper(
8649 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); 8654 const Framebuffer::Attachment* attachment) {
8650 if (!framebuffer)
8651 return false;
8652 const Framebuffer::Attachment* attachment =
8653 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
8654 if (!attachment)
8655 return false;
8656
8657 DCHECK(state_.current_program.get()); 8655 DCHECK(state_.current_program.get());
8658 const Program::SamplerIndices& sampler_indices = 8656 const Program::SamplerIndices& sampler_indices =
8659 state_.current_program->sampler_indices(); 8657 state_.current_program->sampler_indices();
8660 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 8658 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
8661 const Program::UniformInfo* uniform_info = 8659 const Program::UniformInfo* uniform_info =
8662 state_.current_program->GetUniformInfo(sampler_indices[ii]); 8660 state_.current_program->GetUniformInfo(sampler_indices[ii]);
8663 DCHECK(uniform_info); 8661 DCHECK(uniform_info);
8664 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 8662 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
8665 GLuint texture_unit_index = uniform_info->texture_units[jj]; 8663 GLuint texture_unit_index = uniform_info->texture_units[jj];
8666 if (texture_unit_index >= state_.texture_units.size()) 8664 if (texture_unit_index >= state_.texture_units.size())
8667 continue; 8665 continue;
8668 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 8666 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
8669 TextureRef* texture_ref = 8667 TextureRef* texture_ref =
8670 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 8668 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
8671 if (attachment->IsTexture(texture_ref)) 8669 if (attachment->IsTexture(texture_ref))
8672 return true; 8670 return true;
8673 } 8671 }
8674 } 8672 }
8675 return false; 8673 return false;
8676 } 8674 }
8677 8675
8676 bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() {
8677 if (!SupportsDrawBuffers()) {
8678 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
8679 if (!framebuffer)
8680 return false;
8681 const Framebuffer::Attachment* attachment =
8682 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
8683 if (!attachment)
8684 return false;
8685 return CheckDrawingFeedbackLoopsHelper(attachment);
8686 } else {
8687 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER);
8688 if (!framebuffer)
8689 return false;
8690 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
8691 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + ii);
8692 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE)
8693 continue;
8694 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii);
8695 const Framebuffer::Attachment* draw_buffer =
8696 framebuffer->GetAttachment(attachment);
8697 if (!draw_buffer)
8698 continue;
8699 if (CheckDrawingFeedbackLoopsHelper(draw_buffer))
8700 return true;
8701 }
8702 return false;
8703 }
8704 }
8705
8678 bool GLES2DecoderImpl::SupportsDrawBuffers() const { 8706 bool GLES2DecoderImpl::SupportsDrawBuffers() const {
8679 return feature_info_->IsWebGL1OrES2Context() ? 8707 return feature_info_->IsWebGL1OrES2Context() ?
8680 feature_info_->feature_flags().ext_draw_buffers : true; 8708 feature_info_->feature_flags().ext_draw_buffers : true;
8681 } 8709 }
8682 8710
8683 bool GLES2DecoderImpl::ValidateAndAdjustDrawBuffers(const char* func_name) { 8711 bool GLES2DecoderImpl::ValidateAndAdjustDrawBuffers(const char* func_name) {
8684 if (!SupportsDrawBuffers()) { 8712 if (!SupportsDrawBuffers()) {
8685 return true; 8713 return true;
8686 } 8714 }
8687 Framebuffer* framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); 8715 Framebuffer* framebuffer = framebuffer_state_.bound_draw_framebuffer.get();
(...skipping 10107 matching lines...) Expand 10 before | Expand all | Expand 10 after
18795 } 18823 }
18796 18824
18797 // Include the auto-generated part of this file. We split this because it means 18825 // Include the auto-generated part of this file. We split this because it means
18798 // we can easily edit the non-auto generated parts right here in this file 18826 // we can easily edit the non-auto generated parts right here in this file
18799 // instead of having to edit some template or the code generator. 18827 // instead of having to edit some template or the code generator.
18800 #include "base/macros.h" 18828 #include "base/macros.h"
18801 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18829 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18802 18830
18803 } // namespace gles2 18831 } // namespace gles2
18804 } // namespace gpu 18832 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698