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

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

Issue 2410343002: [Reland] Add gl tests to make sure when a buffer is unmapped, all access path generates an INVALID_… (Closed)
Patch Set: Skip the test if context creation fails. 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 unified diff | Download patch
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | 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 3957 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 } 3968 }
3969 3969
3970 void GLES2DecoderImpl::DeleteBuffersHelper(GLsizei n, 3970 void GLES2DecoderImpl::DeleteBuffersHelper(GLsizei n,
3971 const volatile GLuint* client_ids) { 3971 const volatile GLuint* client_ids) {
3972 for (GLsizei ii = 0; ii < n; ++ii) { 3972 for (GLsizei ii = 0; ii < n; ++ii) {
3973 GLuint client_id = client_ids[ii]; 3973 GLuint client_id = client_ids[ii];
3974 Buffer* buffer = GetBuffer(client_id); 3974 Buffer* buffer = GetBuffer(client_id);
3975 if (buffer && !buffer->IsDeleted()) { 3975 if (buffer && !buffer->IsDeleted()) {
3976 buffer->RemoveMappedRange(); 3976 buffer->RemoveMappedRange();
3977 state_.RemoveBoundBuffer(buffer); 3977 state_.RemoveBoundBuffer(buffer);
3978 transform_feedback_manager_->RemoveBoundBuffer(buffer);
3979 RemoveBuffer(client_id); 3978 RemoveBuffer(client_id);
3980 } 3979 }
3981 } 3980 }
3982 } 3981 }
3983 3982
3984 void GLES2DecoderImpl::DeleteFramebuffersHelper( 3983 void GLES2DecoderImpl::DeleteFramebuffersHelper(
3985 GLsizei n, 3984 GLsizei n,
3986 const volatile GLuint* client_ids) { 3985 const volatile GLuint* client_ids) {
3987 bool supports_separate_framebuffer_binds = 3986 bool supports_separate_framebuffer_binds =
3988 features().chromium_framebuffer_multisample; 3987 features().chromium_framebuffer_multisample;
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
5747 "currently bound transform feedback is active"); 5746 "currently bound transform feedback is active");
5748 return; 5747 return;
5749 } 5748 }
5750 LogClientServiceForInfo(transform_feedback, client_id, function_name); 5749 LogClientServiceForInfo(transform_feedback, client_id, function_name);
5751 transform_feedback->DoBindTransformFeedback(target); 5750 transform_feedback->DoBindTransformFeedback(target);
5752 state_.bound_transform_feedback = transform_feedback; 5751 state_.bound_transform_feedback = transform_feedback;
5753 } 5752 }
5754 5753
5755 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { 5754 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) {
5756 const char* function_name = "glBeginTransformFeedback"; 5755 const char* function_name = "glBeginTransformFeedback";
5757 DCHECK(state_.bound_transform_feedback.get()); 5756 TransformFeedback* transform_feedback = state_.bound_transform_feedback.get();
5758 if (state_.bound_transform_feedback->active()) { 5757 DCHECK(transform_feedback);
5758 if (transform_feedback->active()) {
5759 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 5759 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5760 "transform feedback is already active"); 5760 "transform feedback is already active");
5761 return; 5761 return;
5762 } 5762 }
5763 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode); 5763 if (!CheckCurrentProgram(function_name)) {
5764 return;
5765 }
5766 Program* program = state_.current_program.get();
5767 DCHECK(program);
5768 size_t required_buffer_count =
5769 program->effective_transform_feedback_varyings().size();
5770 if (required_buffer_count == 0) {
5771 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5772 "no active transform feedback varyings");
5773 return;
5774 }
5775 if (required_buffer_count > 1 &&
5776 GL_INTERLEAVED_ATTRIBS ==
5777 program->effective_transform_feedback_buffer_mode()) {
5778 required_buffer_count = 1;
5779 }
5780 for (size_t ii = 0; ii < required_buffer_count; ++ii) {
5781 Buffer* buffer = transform_feedback->GetBufferBinding(ii);
5782 if (!buffer) {
5783 std::string msg = base::StringPrintf("missing buffer bound at index %i",
5784 static_cast<int>(ii));
5785 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, msg.c_str());
5786 return;
5787 }
5788 if (buffer->GetMappedRange()) {
5789 std::string msg = base::StringPrintf(
5790 "bound buffer bound at index %i is mapped", static_cast<int>(ii));
5791 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, msg.c_str());
5792 return;
5793 }
5794 }
5795 transform_feedback->DoBeginTransformFeedback(primitive_mode);
5764 } 5796 }
5765 5797
5766 void GLES2DecoderImpl::DoEndTransformFeedback() { 5798 void GLES2DecoderImpl::DoEndTransformFeedback() {
5767 const char* function_name = "glEndTransformFeedback"; 5799 const char* function_name = "glEndTransformFeedback";
5768 DCHECK(state_.bound_transform_feedback.get()); 5800 DCHECK(state_.bound_transform_feedback.get());
5769 if (!state_.bound_transform_feedback->active()) { 5801 if (!state_.bound_transform_feedback->active()) {
5770 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 5802 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5771 "transform feedback is not active"); 5803 "transform feedback is not active");
5772 return; 5804 return;
5773 } 5805 }
(...skipping 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after
9696 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 9728 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9697 "mode is not identical with active transformfeedback's primitiveMode"); 9729 "mode is not identical with active transformfeedback's primitiveMode");
9698 return error::kNoError; 9730 return error::kNoError;
9699 } 9731 }
9700 9732
9701 if (count == 0 || primcount == 0) { 9733 if (count == 0 || primcount == 0) {
9702 LOCAL_RENDER_WARNING("Render count or primcount is 0."); 9734 LOCAL_RENDER_WARNING("Render count or primcount is 0.");
9703 return error::kNoError; 9735 return error::kNoError;
9704 } 9736 }
9705 9737
9706 if (feature_info_->IsWebGL2OrES3Context() && !AttribsTypeMatch()) { 9738 if (feature_info_->IsWebGL2OrES3Context()) {
9707 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 9739 if (!AttribsTypeMatch()) {
9708 "vertexAttrib function must match shader attrib type"); 9740 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9709 return error::kNoError; 9741 "vertexAttrib function must match shader attrib type");
9742 return error::kNoError;
9743 }
9744 if (state_.bound_array_buffer.get() &&
9745 state_.bound_array_buffer->GetMappedRange()) {
9746 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9747 "bound ARRAY_BUFFER is mapped");
9748 return error::kNoError;
9749 }
9710 } 9750 }
9711 9751
9712 base::CheckedNumeric<GLuint> checked_max_vertex = first; 9752 base::CheckedNumeric<GLuint> checked_max_vertex = first;
9713 checked_max_vertex += count - 1; 9753 checked_max_vertex += count - 1;
9714 // first and count-1 are both a non-negative int, so their sum fits an 9754 // first and count-1 are both a non-negative int, so their sum fits an
9715 // unsigned int. 9755 // unsigned int.
9716 GLuint max_vertex_accessed = checked_max_vertex.ValueOrDie(); 9756 GLuint max_vertex_accessed = checked_max_vertex.ValueOrDie();
9717 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) { 9757 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) {
9718 if (!ClearUnclearedTextures()) { 9758 if (!ClearUnclearedTextures()) {
9719 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory"); 9759 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory");
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
9834 !state_.bound_transform_feedback->paused()) { 9874 !state_.bound_transform_feedback->paused()) {
9835 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 9875 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9836 "transformfeedback is active and not paused"); 9876 "transformfeedback is active and not paused");
9837 return error::kNoError; 9877 return error::kNoError;
9838 } 9878 }
9839 9879
9840 if (count == 0 || primcount == 0) { 9880 if (count == 0 || primcount == 0) {
9841 return error::kNoError; 9881 return error::kNoError;
9842 } 9882 }
9843 9883
9844 if (feature_info_->IsWebGL2OrES3Context() && !AttribsTypeMatch()) { 9884 if (feature_info_->IsWebGL2OrES3Context()) {
9845 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 9885 if (!AttribsTypeMatch()) {
9846 "vertexAttrib function must match shader attrib type"); 9886 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9847 return error::kNoError; 9887 "vertexAttrib function must match shader attrib type");
9888 return error::kNoError;
9889 }
9890 if (state_.bound_array_buffer.get() &&
9891 state_.bound_array_buffer->GetMappedRange()) {
9892 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9893 "bound ARRAY_BUFFER is mapped");
9894 return error::kNoError;
9895 }
9896 if (state_.vertex_attrib_manager->element_array_buffer() &&
9897 state_.vertex_attrib_manager->element_array_buffer()
9898 ->GetMappedRange()) {
9899 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
9900 "bound ELEMENT_ARRAY_BUFFER is mapped");
9901 return error::kNoError;
9902 }
9848 } 9903 }
9849 9904
9850 GLuint max_vertex_accessed; 9905 GLuint max_vertex_accessed;
9851 Buffer* element_array_buffer = 9906 Buffer* element_array_buffer =
9852 state_.vertex_attrib_manager->element_array_buffer(); 9907 state_.vertex_attrib_manager->element_array_buffer();
9853 9908
9854 if (!element_array_buffer->GetMaxValueForRange( 9909 if (!element_array_buffer->GetMaxValueForRange(
9855 offset, count, type, 9910 offset, count, type,
9856 state_.enable_flags.primitive_restart_fixed_index, 9911 state_.enable_flags.primitive_restart_fixed_index,
9857 &max_vertex_accessed)) { 9912 &max_vertex_accessed)) {
(...skipping 7296 matching lines...) Expand 10 before | Expand all | Expand 10 after
17154 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17209 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17155 "Incompatible access bits with MAP_READ_BIT"); 17210 "Incompatible access bits with MAP_READ_BIT");
17156 return error::kNoError; 17211 return error::kNoError;
17157 } 17212 }
17158 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) && 17213 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) &&
17159 !AllBitsSet(access, GL_MAP_WRITE_BIT)) { 17214 !AllBitsSet(access, GL_MAP_WRITE_BIT)) {
17160 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17215 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17161 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT"); 17216 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT");
17162 return error::kNoError; 17217 return error::kNoError;
17163 } 17218 }
17219 if (target == GL_TRANSFORM_FEEDBACK_BUFFER &&
17220 state_.bound_transform_feedback->active()) {
17221 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17222 "transform feedback is active");
17223 return error::kNoError;
17224 }
17164 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) { 17225 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) {
17165 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to 17226 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to
17166 // GL_MAP_INVALIDATE_RANGE_BIT. 17227 // GL_MAP_INVALIDATE_RANGE_BIT.
17167 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); 17228 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT);
17168 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); 17229 access = (access | GL_MAP_INVALIDATE_RANGE_BIT);
17169 } 17230 }
17170 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined 17231 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined
17171 // behaviors. 17232 // behaviors.
17172 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); 17233 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT);
17173 if (AllBitsSet(access, GL_MAP_WRITE_BIT) && 17234 if (AllBitsSet(access, GL_MAP_WRITE_BIT) &&
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
18483 } 18544 }
18484 18545
18485 // Include the auto-generated part of this file. We split this because it means 18546 // Include the auto-generated part of this file. We split this because it means
18486 // we can easily edit the non-auto generated parts right here in this file 18547 // we can easily edit the non-auto generated parts right here in this file
18487 // instead of having to edit some template or the code generator. 18548 // instead of having to edit some template or the code generator.
18488 #include "base/macros.h" 18549 #include "base/macros.h"
18489 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18550 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18490 18551
18491 } // namespace gles2 18552 } // namespace gles2
18492 } // namespace gpu 18553 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698