| 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 5684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5695 "currently bound transform feedback is active"); | 5695 "currently bound transform feedback is active"); |
| 5696 return; | 5696 return; |
| 5697 } | 5697 } |
| 5698 LogClientServiceForInfo(transform_feedback, client_id, function_name); | 5698 LogClientServiceForInfo(transform_feedback, client_id, function_name); |
| 5699 transform_feedback->DoBindTransformFeedback(target); | 5699 transform_feedback->DoBindTransformFeedback(target); |
| 5700 state_.bound_transform_feedback = transform_feedback; | 5700 state_.bound_transform_feedback = transform_feedback; |
| 5701 } | 5701 } |
| 5702 | 5702 |
| 5703 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { | 5703 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { |
| 5704 const char* function_name = "glBeginTransformFeedback"; | 5704 const char* function_name = "glBeginTransformFeedback"; |
| 5705 DCHECK(state_.bound_transform_feedback.get()); | 5705 TransformFeedback* transform_feedback = state_.bound_transform_feedback.get(); |
| 5706 if (state_.bound_transform_feedback->active()) { | 5706 DCHECK(transform_feedback); |
| 5707 if (transform_feedback->active()) { |
| 5707 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 5708 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5708 "transform feedback is already active"); | 5709 "transform feedback is already active"); |
| 5709 return; | 5710 return; |
| 5710 } | 5711 } |
| 5711 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode); | 5712 if (!CheckCurrentProgram(function_name)) { |
| 5713 return; |
| 5714 } |
| 5715 Program* program = state_.current_program.get(); |
| 5716 DCHECK(program); |
| 5717 size_t required_buffer_count = |
| 5718 program->effective_transform_feedback_varyings().size(); |
| 5719 if (required_buffer_count == 0) { |
| 5720 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5721 "no active transform feedback varyings"); |
| 5722 return; |
| 5723 } |
| 5724 if (required_buffer_count > 1 && |
| 5725 GL_INTERLEAVED_ATTRIBS == |
| 5726 program->effective_transform_feedback_buffer_mode()) { |
| 5727 required_buffer_count = 1; |
| 5728 } |
| 5729 for (size_t ii = 0; ii < required_buffer_count; ++ii) { |
| 5730 Buffer* buffer = transform_feedback->GetBufferBinding(ii); |
| 5731 if (!buffer) { |
| 5732 std::string msg = base::StringPrintf("missing buffer bound at index %i", |
| 5733 static_cast<int>(ii)); |
| 5734 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, msg.c_str()); |
| 5735 return; |
| 5736 } |
| 5737 if (buffer->GetMappedRange()) { |
| 5738 std::string msg = base::StringPrintf( |
| 5739 "bound buffer bound at index %i is mapped", static_cast<int>(ii)); |
| 5740 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, msg.c_str()); |
| 5741 return; |
| 5742 } |
| 5743 } |
| 5744 transform_feedback->DoBeginTransformFeedback(primitive_mode); |
| 5712 } | 5745 } |
| 5713 | 5746 |
| 5714 void GLES2DecoderImpl::DoEndTransformFeedback() { | 5747 void GLES2DecoderImpl::DoEndTransformFeedback() { |
| 5715 const char* function_name = "glEndTransformFeedback"; | 5748 const char* function_name = "glEndTransformFeedback"; |
| 5716 DCHECK(state_.bound_transform_feedback.get()); | 5749 DCHECK(state_.bound_transform_feedback.get()); |
| 5717 if (!state_.bound_transform_feedback->active()) { | 5750 if (!state_.bound_transform_feedback->active()) { |
| 5718 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 5751 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5719 "transform feedback is not active"); | 5752 "transform feedback is not active"); |
| 5720 return; | 5753 return; |
| 5721 } | 5754 } |
| (...skipping 3767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9489 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 9522 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9490 "mode is not identical with active transformfeedback's primitiveMode"); | 9523 "mode is not identical with active transformfeedback's primitiveMode"); |
| 9491 return error::kNoError; | 9524 return error::kNoError; |
| 9492 } | 9525 } |
| 9493 | 9526 |
| 9494 if (count == 0 || primcount == 0) { | 9527 if (count == 0 || primcount == 0) { |
| 9495 LOCAL_RENDER_WARNING("Render count or primcount is 0."); | 9528 LOCAL_RENDER_WARNING("Render count or primcount is 0."); |
| 9496 return error::kNoError; | 9529 return error::kNoError; |
| 9497 } | 9530 } |
| 9498 | 9531 |
| 9499 if (feature_info_->IsWebGL2OrES3Context() && !AttribsTypeMatch()) { | 9532 if (feature_info_->IsWebGL2OrES3Context()) { |
| 9500 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 9533 if (!AttribsTypeMatch()) { |
| 9501 "vertexAttrib function must match shader attrib type"); | 9534 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9502 return error::kNoError; | 9535 "vertexAttrib function must match shader attrib type"); |
| 9536 return error::kNoError; |
| 9537 } |
| 9538 if (state_.bound_array_buffer.get() && |
| 9539 state_.bound_array_buffer->GetMappedRange()) { |
| 9540 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9541 "bound ARRAY_BUFFER is mapped"); |
| 9542 return error::kNoError; |
| 9543 } |
| 9503 } | 9544 } |
| 9504 | 9545 |
| 9505 base::CheckedNumeric<GLuint> checked_max_vertex = first; | 9546 base::CheckedNumeric<GLuint> checked_max_vertex = first; |
| 9506 checked_max_vertex += count - 1; | 9547 checked_max_vertex += count - 1; |
| 9507 // first and count-1 are both a non-negative int, so their sum fits an | 9548 // first and count-1 are both a non-negative int, so their sum fits an |
| 9508 // unsigned int. | 9549 // unsigned int. |
| 9509 GLuint max_vertex_accessed = checked_max_vertex.ValueOrDie(); | 9550 GLuint max_vertex_accessed = checked_max_vertex.ValueOrDie(); |
| 9510 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) { | 9551 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) { |
| 9511 if (!ClearUnclearedTextures()) { | 9552 if (!ClearUnclearedTextures()) { |
| 9512 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory"); | 9553 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory"); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9627 !state_.bound_transform_feedback->paused()) { | 9668 !state_.bound_transform_feedback->paused()) { |
| 9628 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 9669 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9629 "transformfeedback is active and not paused"); | 9670 "transformfeedback is active and not paused"); |
| 9630 return error::kNoError; | 9671 return error::kNoError; |
| 9631 } | 9672 } |
| 9632 | 9673 |
| 9633 if (count == 0 || primcount == 0) { | 9674 if (count == 0 || primcount == 0) { |
| 9634 return error::kNoError; | 9675 return error::kNoError; |
| 9635 } | 9676 } |
| 9636 | 9677 |
| 9637 if (feature_info_->IsWebGL2OrES3Context() && !AttribsTypeMatch()) { | 9678 if (feature_info_->IsWebGL2OrES3Context()) { |
| 9638 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 9679 if (!AttribsTypeMatch()) { |
| 9639 "vertexAttrib function must match shader attrib type"); | 9680 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9640 return error::kNoError; | 9681 "vertexAttrib function must match shader attrib type"); |
| 9682 return error::kNoError; |
| 9683 } |
| 9684 if (state_.bound_array_buffer.get() && |
| 9685 state_.bound_array_buffer->GetMappedRange()) { |
| 9686 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9687 "bound ARRAY_BUFFER is mapped"); |
| 9688 return error::kNoError; |
| 9689 } |
| 9690 if (state_.vertex_attrib_manager->element_array_buffer() && |
| 9691 state_.vertex_attrib_manager->element_array_buffer() |
| 9692 ->GetMappedRange()) { |
| 9693 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9694 "bound ELEMENT_ARRAY_BUFFER is mapped"); |
| 9695 return error::kNoError; |
| 9696 } |
| 9641 } | 9697 } |
| 9642 | 9698 |
| 9643 GLuint max_vertex_accessed; | 9699 GLuint max_vertex_accessed; |
| 9644 Buffer* element_array_buffer = | 9700 Buffer* element_array_buffer = |
| 9645 state_.vertex_attrib_manager->element_array_buffer(); | 9701 state_.vertex_attrib_manager->element_array_buffer(); |
| 9646 | 9702 |
| 9647 if (!element_array_buffer->GetMaxValueForRange( | 9703 if (!element_array_buffer->GetMaxValueForRange( |
| 9648 offset, count, type, | 9704 offset, count, type, |
| 9649 state_.enable_flags.primitive_restart_fixed_index, | 9705 state_.enable_flags.primitive_restart_fixed_index, |
| 9650 &max_vertex_accessed)) { | 9706 &max_vertex_accessed)) { |
| (...skipping 7266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16917 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 16973 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 16918 "Incompatible access bits with MAP_READ_BIT"); | 16974 "Incompatible access bits with MAP_READ_BIT"); |
| 16919 return error::kNoError; | 16975 return error::kNoError; |
| 16920 } | 16976 } |
| 16921 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) && | 16977 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) && |
| 16922 !AllBitsSet(access, GL_MAP_WRITE_BIT)) { | 16978 !AllBitsSet(access, GL_MAP_WRITE_BIT)) { |
| 16923 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 16979 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 16924 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT"); | 16980 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT"); |
| 16925 return error::kNoError; | 16981 return error::kNoError; |
| 16926 } | 16982 } |
| 16983 if (target == GL_TRANSFORM_FEEDBACK_BUFFER && |
| 16984 state_.bound_transform_feedback->active()) { |
| 16985 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 16986 "transform feedback is active"); |
| 16987 return error::kNoError; |
| 16988 } |
| 16927 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) { | 16989 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) { |
| 16928 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to | 16990 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to |
| 16929 // GL_MAP_INVALIDATE_RANGE_BIT. | 16991 // GL_MAP_INVALIDATE_RANGE_BIT. |
| 16930 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); | 16992 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); |
| 16931 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); | 16993 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); |
| 16932 } | 16994 } |
| 16933 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined | 16995 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined |
| 16934 // behaviors. | 16996 // behaviors. |
| 16935 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); | 16997 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); |
| 16936 if (AllBitsSet(access, GL_MAP_WRITE_BIT) && | 16998 if (AllBitsSet(access, GL_MAP_WRITE_BIT) && |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18246 } | 18308 } |
| 18247 | 18309 |
| 18248 // Include the auto-generated part of this file. We split this because it means | 18310 // Include the auto-generated part of this file. We split this because it means |
| 18249 // we can easily edit the non-auto generated parts right here in this file | 18311 // we can easily edit the non-auto generated parts right here in this file |
| 18250 // instead of having to edit some template or the code generator. | 18312 // instead of having to edit some template or the code generator. |
| 18251 #include "base/macros.h" | 18313 #include "base/macros.h" |
| 18252 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18314 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18253 | 18315 |
| 18254 } // namespace gles2 | 18316 } // namespace gles2 |
| 18255 } // namespace gpu | 18317 } // namespace gpu |
| OLD | NEW |