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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1195 // appropriate GL error. Returns true if the current program is in a usable | 1195 // appropriate GL error. Returns true if the current program is in a usable |
1196 // state. | 1196 // state. |
1197 bool CheckCurrentProgram(const char* function_name); | 1197 bool CheckCurrentProgram(const char* function_name); |
1198 | 1198 |
1199 // Checks if the current program exists and is valid and that location is not | 1199 // Checks if the current program exists and is valid and that location is not |
1200 // -1. If the current program is not valid generates the appropriate GL | 1200 // -1. If the current program is not valid generates the appropriate GL |
1201 // error. Returns true if the current program is in a usable state and | 1201 // error. Returns true if the current program is in a usable state and |
1202 // location is not -1. | 1202 // location is not -1. |
1203 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); | 1203 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); |
1204 | 1204 |
1205 // Checks if the current program samples a texture that is also the color | |
1206 // image of the current bound framebuffer, i.e., the source and destination | |
1207 // of the draw operation are the same. | |
1208 bool CheckDrawingFeedbackLoops(); | |
1209 | |
1205 // Gets the type of a uniform for a location in the current program. Sets GL | 1210 // Gets the type of a uniform for a location in the current program. Sets GL |
1206 // errors if the current program is not valid. Returns true if the current | 1211 // errors if the current program is not valid. Returns true if the current |
1207 // program is valid and the location exists. Adjusts count so it | 1212 // program is valid and the location exists. Adjusts count so it |
1208 // does not overflow the uniform. | 1213 // does not overflow the uniform. |
1209 bool PrepForSetUniformByLocation(GLint fake_location, | 1214 bool PrepForSetUniformByLocation(GLint fake_location, |
1210 const char* function_name, | 1215 const char* function_name, |
1211 Program::UniformApiType api_type, | 1216 Program::UniformApiType api_type, |
1212 GLint* real_location, | 1217 GLint* real_location, |
1213 GLenum* type, | 1218 GLenum* type, |
1214 GLsizei* count); | 1219 GLsizei* count); |
(...skipping 4533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5748 } | 5753 } |
5749 | 5754 |
5750 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( | 5755 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( |
5751 GLint location, const char* function_name) { | 5756 GLint location, const char* function_name) { |
5752 if (!CheckCurrentProgram(function_name)) { | 5757 if (!CheckCurrentProgram(function_name)) { |
5753 return false; | 5758 return false; |
5754 } | 5759 } |
5755 return location != -1; | 5760 return location != -1; |
5756 } | 5761 } |
5757 | 5762 |
5763 bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() { | |
Ken Russell (switch to Gerrit)
2014/10/16 21:08:30
Have you checked any benchmarks -- e.g. http://web
| |
5764 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
5765 if (!framebuffer) | |
5766 return false; | |
5767 const Framebuffer::Attachment* attachment = | |
5768 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); | |
5769 if (!attachment) | |
5770 return false; | |
5771 | |
5772 DCHECK(state_.current_program.get()); | |
5773 const Program::SamplerIndices& sampler_indices = | |
5774 state_.current_program->sampler_indices(); | |
5775 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | |
5776 const Program::UniformInfo* uniform_info = | |
5777 state_.current_program->GetUniformInfo(sampler_indices[ii]); | |
5778 DCHECK(uniform_info); | |
5779 if (uniform_info->type != GL_SAMPLER_2D) | |
5780 continue; | |
5781 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | |
5782 GLuint texture_unit_index = uniform_info->texture_units[jj]; | |
5783 if (texture_unit_index >= state_.texture_units.size()) | |
5784 continue; | |
5785 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | |
5786 TextureRef* texture_ref = | |
5787 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); | |
5788 if (attachment->IsTexture(texture_ref)) | |
5789 return true; | |
5790 } | |
5791 } | |
5792 return false; | |
5793 } | |
5794 | |
5758 bool GLES2DecoderImpl::PrepForSetUniformByLocation( | 5795 bool GLES2DecoderImpl::PrepForSetUniformByLocation( |
5759 GLint fake_location, | 5796 GLint fake_location, |
5760 const char* function_name, | 5797 const char* function_name, |
5761 Program::UniformApiType api_type, | 5798 Program::UniformApiType api_type, |
5762 GLint* real_location, | 5799 GLint* real_location, |
5763 GLenum* type, | 5800 GLenum* type, |
5764 GLsizei* count) { | 5801 GLsizei* count) { |
5765 DCHECK(type); | 5802 DCHECK(type); |
5766 DCHECK(count); | 5803 DCHECK(count); |
5767 DCHECK(real_location); | 5804 DCHECK(real_location); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6244 // it could never be invalid since glUseProgram would have failed. While | 6281 // it could never be invalid since glUseProgram would have failed. While |
6245 // glLinkProgram could later mark the program as invalid the previous | 6282 // glLinkProgram could later mark the program as invalid the previous |
6246 // valid program will still function if it is still the current program. | 6283 // valid program will still function if it is still the current program. |
6247 if (!state_.current_program.get()) { | 6284 if (!state_.current_program.get()) { |
6248 // The program does not exist. | 6285 // The program does not exist. |
6249 // But GL says no ERROR. | 6286 // But GL says no ERROR. |
6250 LOCAL_RENDER_WARNING("Drawing with no current shader program."); | 6287 LOCAL_RENDER_WARNING("Drawing with no current shader program."); |
6251 return false; | 6288 return false; |
6252 } | 6289 } |
6253 | 6290 |
6291 if (CheckDrawingFeedbackLoops()) { | |
6292 LOCAL_SET_GL_ERROR( | |
6293 GL_INVALID_OPERATION, function_name, | |
6294 "Source and destination textures of the draw are the same."); | |
6295 return false; | |
6296 } | |
6297 | |
6254 return state_.vertex_attrib_manager | 6298 return state_.vertex_attrib_manager |
6255 ->ValidateBindings(function_name, | 6299 ->ValidateBindings(function_name, |
6256 this, | 6300 this, |
6257 feature_info_.get(), | 6301 feature_info_.get(), |
6258 state_.current_program.get(), | 6302 state_.current_program.get(), |
6259 max_vertex_accessed, | 6303 max_vertex_accessed, |
6260 instanced, | 6304 instanced, |
6261 primcount); | 6305 primcount); |
6262 } | 6306 } |
6263 | 6307 |
(...skipping 4925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11189 } | 11233 } |
11190 } | 11234 } |
11191 | 11235 |
11192 // Include the auto-generated part of this file. We split this because it means | 11236 // Include the auto-generated part of this file. We split this because it means |
11193 // we can easily edit the non-auto generated parts right here in this file | 11237 // we can easily edit the non-auto generated parts right here in this file |
11194 // instead of having to edit some template or the code generator. | 11238 // instead of having to edit some template or the code generator. |
11195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11239 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11196 | 11240 |
11197 } // namespace gles2 | 11241 } // namespace gles2 |
11198 } // namespace gpu | 11242 } // namespace gpu |
OLD | NEW |