Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1315 // -1. If the current program is not valid generates the appropriate GL | 1315 // -1. If the current program is not valid generates the appropriate GL |
| 1316 // error. Returns true if the current program is in a usable state and | 1316 // error. Returns true if the current program is in a usable state and |
| 1317 // location is not -1. | 1317 // location is not -1. |
| 1318 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); | 1318 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); |
| 1319 | 1319 |
| 1320 // Checks if the current program samples a texture that is also the color | 1320 // Checks if the current program samples a texture that is also the color |
| 1321 // image of the current bound framebuffer, i.e., the source and destination | 1321 // image of the current bound framebuffer, i.e., the source and destination |
| 1322 // of the draw operation are the same. | 1322 // of the draw operation are the same. |
| 1323 bool CheckDrawingFeedbackLoops(); | 1323 bool CheckDrawingFeedbackLoops(); |
| 1324 | 1324 |
| 1325 // Helper for CheckDrawingFeedbackLoops. Returns true if the attachment is | |
| 1326 // the same one where it samples from during drawing. | |
| 1327 bool CheckDrawingFeedbackLoopsHelper( | |
| 1328 const Framebuffer::Attachment* attachment); | |
| 1329 | |
| 1325 bool SupportsDrawBuffers() const; | 1330 bool SupportsDrawBuffers() const; |
| 1326 | 1331 |
| 1327 // Checks if a draw buffer's format and its corresponding fragment shader | 1332 // Checks if a draw buffer's format and its corresponding fragment shader |
| 1328 // output's type are compatible, i.e., a signed integer typed variable is | 1333 // output's type are compatible, i.e., a signed integer typed variable is |
| 1329 // incompatible with a float or unsigned integer buffer. | 1334 // incompatible with a float or unsigned integer buffer. |
| 1330 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer | 1335 // If incompaticle, generates an INVALID_OPERATION to avoid undefined buffer |
| 1331 // contents and return false. | 1336 // contents and return false. |
| 1332 // Otherwise, filter out the draw buffers that are not written to but are not | 1337 // Otherwise, filter out the draw buffers that are not written to but are not |
| 1333 // NONE through DrawBuffers, to be on the safe side. Return true. | 1338 // NONE through DrawBuffers, to be on the safe side. Return true. |
| 1334 bool ValidateAndAdjustDrawBuffers(const char* function_name); | 1339 bool ValidateAndAdjustDrawBuffers(const char* function_name); |
| (...skipping 7304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8639 | 8644 |
| 8640 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( | 8645 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( |
| 8641 GLint location, const char* function_name) { | 8646 GLint location, const char* function_name) { |
| 8642 if (!CheckCurrentProgram(function_name)) { | 8647 if (!CheckCurrentProgram(function_name)) { |
| 8643 return false; | 8648 return false; |
| 8644 } | 8649 } |
| 8645 return !state_.current_program->IsInactiveUniformLocationByFakeLocation( | 8650 return !state_.current_program->IsInactiveUniformLocationByFakeLocation( |
| 8646 location); | 8651 location); |
| 8647 } | 8652 } |
| 8648 | 8653 |
| 8649 bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() { | 8654 bool GLES2DecoderImpl::CheckDrawingFeedbackLoopsHelper( |
| 8650 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 8655 const Framebuffer::Attachment* attachment) { |
| 8651 if (!framebuffer) | |
| 8652 return false; | |
| 8653 const Framebuffer::Attachment* attachment = | |
| 8654 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); | |
| 8655 if (!attachment) | |
| 8656 return false; | |
| 8657 | |
| 8658 DCHECK(state_.current_program.get()); | 8656 DCHECK(state_.current_program.get()); |
| 8659 const Program::SamplerIndices& sampler_indices = | 8657 const Program::SamplerIndices& sampler_indices = |
| 8660 state_.current_program->sampler_indices(); | 8658 state_.current_program->sampler_indices(); |
| 8661 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 8659 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
| 8662 const Program::UniformInfo* uniform_info = | 8660 const Program::UniformInfo* uniform_info = |
| 8663 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 8661 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
| 8664 DCHECK(uniform_info); | 8662 DCHECK(uniform_info); |
| 8665 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 8663 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
| 8666 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 8664 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
| 8667 if (texture_unit_index >= state_.texture_units.size()) | 8665 if (texture_unit_index >= state_.texture_units.size()) |
| 8668 continue; | 8666 continue; |
| 8669 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 8667 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
| 8670 TextureRef* texture_ref = | 8668 TextureRef* texture_ref = |
| 8671 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 8669 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
| 8672 if (attachment->IsTexture(texture_ref)) | 8670 if (attachment->IsTexture(texture_ref)) |
| 8673 return true; | 8671 return true; |
| 8674 } | 8672 } |
| 8675 } | 8673 } |
| 8676 return false; | 8674 return false; |
| 8677 } | 8675 } |
| 8678 | 8676 |
| 8677 bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() { | |
| 8678 if (feature_info_->IsWebGL1OrES2Context()) { | |
|
Zhenyao Mo
2016/10/31 18:03:46
We are able to expose MRT in WebGL1 through extens
yunchao
2016/11/04 15:30:01
Done.
| |
| 8679 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
| 8680 if (!framebuffer) | |
| 8681 return false; | |
| 8682 const Framebuffer::Attachment* attachment = | |
| 8683 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); | |
| 8684 if (!attachment) | |
| 8685 return false; | |
| 8686 return CheckDrawingFeedbackLoopsHelper(attachment); | |
| 8687 } else { | |
| 8688 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); | |
| 8689 if (!framebuffer) | |
| 8690 return false; | |
| 8691 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | |
|
piman
2016/11/02 02:33:57
Do we need to handle depth attachment vs depth tex
yunchao
2016/11/04 15:30:01
I think so.
| |
| 8692 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + ii); | |
| 8693 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) | |
| 8694 continue; | |
| 8695 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii); | |
| 8696 const Framebuffer::Attachment* draw_buffer = | |
| 8697 framebuffer->GetAttachment(attachment); | |
| 8698 if (!draw_buffer) | |
| 8699 continue; | |
| 8700 if (CheckDrawingFeedbackLoopsHelper(draw_buffer)) | |
|
Zhenyao Mo
2016/10/31 18:03:46
We will want to optimize on this. This is not tri
yunchao
2016/11/01 15:25:22
The cache info is not easy if we try to optimize o
Zhenyao Mo
2016/11/01 22:55:46
I think we just need one state, indicating if a fe
yunchao
2016/11/04 15:30:01
That's a pretty good suggestion. I will update the
| |
| 8701 return true; | |
| 8702 } | |
| 8703 return false; | |
| 8704 } | |
| 8705 } | |
| 8706 | |
| 8679 bool GLES2DecoderImpl::SupportsDrawBuffers() const { | 8707 bool GLES2DecoderImpl::SupportsDrawBuffers() const { |
| 8680 return feature_info_->IsWebGL1OrES2Context() ? | 8708 return feature_info_->IsWebGL1OrES2Context() ? |
| 8681 feature_info_->feature_flags().ext_draw_buffers : true; | 8709 feature_info_->feature_flags().ext_draw_buffers : true; |
| 8682 } | 8710 } |
| 8683 | 8711 |
| 8684 bool GLES2DecoderImpl::ValidateAndAdjustDrawBuffers(const char* func_name) { | 8712 bool GLES2DecoderImpl::ValidateAndAdjustDrawBuffers(const char* func_name) { |
| 8685 if (!SupportsDrawBuffers()) { | 8713 if (!SupportsDrawBuffers()) { |
| 8686 return true; | 8714 return true; |
| 8687 } | 8715 } |
| 8688 Framebuffer* framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); | 8716 Framebuffer* framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); |
| (...skipping 10080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18769 } | 18797 } |
| 18770 | 18798 |
| 18771 // Include the auto-generated part of this file. We split this because it means | 18799 // Include the auto-generated part of this file. We split this because it means |
| 18772 // we can easily edit the non-auto generated parts right here in this file | 18800 // we can easily edit the non-auto generated parts right here in this file |
| 18773 // instead of having to edit some template or the code generator. | 18801 // instead of having to edit some template or the code generator. |
| 18774 #include "base/macros.h" | 18802 #include "base/macros.h" |
| 18775 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18803 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18776 | 18804 |
| 18777 } // namespace gles2 | 18805 } // namespace gles2 |
| 18778 } // namespace gpu | 18806 } // namespace gpu |
| OLD | NEW |