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

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

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