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

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

Issue 2466763002: command buffer: tweak error messages for a few more ES3 commands (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | 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 15260 matching lines...) Expand 10 before | Expand all | Expand 10 after
15271 if (!result) { 15271 if (!result) {
15272 return error::kOutOfBounds; 15272 return error::kOutOfBounds;
15273 } 15273 }
15274 // Check that the client initialized the result. 15274 // Check that the client initialized the result.
15275 if (result->success != 0) { 15275 if (result->success != 0) {
15276 return error::kInvalidArguments; 15276 return error::kInvalidArguments;
15277 } 15277 }
15278 Program* program = GetProgramInfoNotShader( 15278 Program* program = GetProgramInfoNotShader(
15279 program_id, "glGetTransformFeedbackVarying"); 15279 program_id, "glGetTransformFeedbackVarying");
15280 if (!program) { 15280 if (!program) {
15281 // An error is already set.
15281 return error::kNoError; 15282 return error::kNoError;
15282 } 15283 }
15283 GLuint service_id = program->service_id(); 15284 GLuint service_id = program->service_id();
15284 GLint link_status = GL_FALSE; 15285 GLint link_status = GL_FALSE;
15285 glGetProgramiv(service_id, GL_LINK_STATUS, &link_status); 15286 glGetProgramiv(service_id, GL_LINK_STATUS, &link_status);
15286 if (link_status != GL_TRUE) { 15287 if (link_status != GL_TRUE) {
15287 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 15288 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
15288 "glGetTransformFeedbackVarying", "program not linked"); 15289 "glGetTransformFeedbackVarying", "program not linked");
15289 return error::kNoError; 15290 return error::kNoError;
15290 } 15291 }
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
17205 // Force GL_SYNC_FLUSH_COMMANDS_BIT to avoid infinite wait. 17206 // Force GL_SYNC_FLUSH_COMMANDS_BIT to avoid infinite wait.
17206 flags |= GL_SYNC_FLUSH_COMMANDS_BIT; 17207 flags |= GL_SYNC_FLUSH_COMMANDS_BIT;
17207 17208
17208 GLenum status = glClientWaitSync(service_sync, flags, timeout); 17209 GLenum status = glClientWaitSync(service_sync, flags, timeout);
17209 switch (status) { 17210 switch (status) {
17210 case GL_ALREADY_SIGNALED: 17211 case GL_ALREADY_SIGNALED:
17211 case GL_TIMEOUT_EXPIRED: 17212 case GL_TIMEOUT_EXPIRED:
17212 case GL_CONDITION_SATISFIED: 17213 case GL_CONDITION_SATISFIED:
17213 break; 17214 break;
17214 case GL_WAIT_FAILED: 17215 case GL_WAIT_FAILED:
17216 NOTREACHED();
Zhenyao Mo 2016/11/01 02:27:48 This could happen in context lost.
Kai Ninomiya 2016/11/01 03:16:01 Ah, okay. Is it okay that it returns kNoError in t
Zhenyao Mo 2016/11/01 04:49:44 I think the LOSE_CONTEXT gl error will be handled
Kai Ninomiya 2016/11/01 20:28:42 Done.
17215 // Avoid leaking GL errors when using virtual contexts. 17217 // Avoid leaking GL errors when using virtual contexts.
17216 LOCAL_PEEK_GL_ERROR(function_name); 17218 LOCAL_PEEK_GL_ERROR(function_name);
17217 break; 17219 break;
17218 default: 17220 default:
17219 NOTREACHED(); 17221 NOTREACHED();
17220 break; 17222 break;
17221 } 17223 }
17222 *result_dst = status; 17224 *result_dst = status;
17223 return error::kNoError; 17225 return error::kNoError;
17224 } 17226 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
17382 } 17384 }
17383 if (*result != 0) { 17385 if (*result != 0) {
17384 *result = 0; 17386 *result = 0;
17385 return error::kInvalidArguments; 17387 return error::kInvalidArguments;
17386 } 17388 }
17387 if (!validators_->buffer_target.IsValid(target)) { 17389 if (!validators_->buffer_target.IsValid(target)) {
17388 LOCAL_SET_GL_ERROR_INVALID_ENUM(func_name, target, "target"); 17390 LOCAL_SET_GL_ERROR_INVALID_ENUM(func_name, target, "target");
17389 return error::kNoError; 17391 return error::kNoError;
17390 } 17392 }
17391 if (size == 0) { 17393 if (size == 0) {
17392 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, "size is zero"); 17394 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, "length is zero");
17393 return error::kNoError; 17395 return error::kNoError;
17394 } 17396 }
17395 Buffer* buffer = buffer_manager()->RequestBufferAccess( 17397 Buffer* buffer = buffer_manager()->RequestBufferAccess(
17396 &state_, target, offset, size, func_name); 17398 &state_, target, offset, size, func_name);
17397 if (!buffer) { 17399 if (!buffer) {
17400 // An error is already set.
17398 return error::kNoError; 17401 return error::kNoError;
17399 } 17402 }
17400 if (state_.bound_transform_feedback->active() && 17403 if (state_.bound_transform_feedback->active() &&
17401 !state_.bound_transform_feedback->paused()) { 17404 !state_.bound_transform_feedback->paused()) {
17402 size_t used_binding_count = 17405 size_t used_binding_count =
17403 state_.current_program->effective_transform_feedback_varyings().size(); 17406 state_.current_program->effective_transform_feedback_varyings().size();
17404 if (state_.bound_transform_feedback->UsesBuffer( 17407 if (state_.bound_transform_feedback->UsesBuffer(
17405 used_binding_count, buffer)) { 17408 used_binding_count, buffer)) {
17406 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17409 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17407 "active transform feedback is using this buffer"); 17410 "active transform feedback is using this buffer");
(...skipping 10 matching lines...) Expand all
17418 GL_MAP_WRITE_BIT | 17421 GL_MAP_WRITE_BIT |
17419 GL_MAP_INVALIDATE_RANGE_BIT | 17422 GL_MAP_INVALIDATE_RANGE_BIT |
17420 GL_MAP_INVALIDATE_BUFFER_BIT | 17423 GL_MAP_INVALIDATE_BUFFER_BIT |
17421 GL_MAP_FLUSH_EXPLICIT_BIT | 17424 GL_MAP_FLUSH_EXPLICIT_BIT |
17422 GL_MAP_UNSYNCHRONIZED_BIT))) { 17425 GL_MAP_UNSYNCHRONIZED_BIT))) {
17423 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, "invalid access bits"); 17426 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, "invalid access bits");
17424 return error::kNoError; 17427 return error::kNoError;
17425 } 17428 }
17426 if (!AnyBitsSet(access, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) { 17429 if (!AnyBitsSet(access, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) {
17427 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17430 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17428 "neither MAP_READ_BIT nore MAP_WRITE_BIT is set"); 17431 "neither MAP_READ_BIT nor MAP_WRITE_BIT is set");
17429 return error::kNoError; 17432 return error::kNoError;
17430 } 17433 }
17431 if (AllBitsSet(access, GL_MAP_READ_BIT) && 17434 if (AllBitsSet(access, GL_MAP_READ_BIT) &&
17432 AnyBitsSet(access, (GL_MAP_INVALIDATE_RANGE_BIT | 17435 AnyBitsSet(access, (GL_MAP_INVALIDATE_RANGE_BIT |
17433 GL_MAP_INVALIDATE_BUFFER_BIT | 17436 GL_MAP_INVALIDATE_BUFFER_BIT |
17434 GL_MAP_UNSYNCHRONIZED_BIT))) { 17437 GL_MAP_UNSYNCHRONIZED_BIT))) {
17435 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17438 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17436 "Incompatible access bits with MAP_READ_BIT"); 17439 "incompatible access bits with MAP_READ_BIT");
17437 return error::kNoError; 17440 return error::kNoError;
17438 } 17441 }
17439 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) && 17442 if (AllBitsSet(access, GL_MAP_FLUSH_EXPLICIT_BIT) &&
17440 !AllBitsSet(access, GL_MAP_WRITE_BIT)) { 17443 !AllBitsSet(access, GL_MAP_WRITE_BIT)) {
17441 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 17444 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
17442 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT"); 17445 "MAP_FLUSH_EXPLICIT_BIT set without MAP_WRITE_BIT");
17443 return error::kNoError; 17446 return error::kNoError;
17444 } 17447 }
17445 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) { 17448 if (AllBitsSet(access, GL_MAP_INVALIDATE_BUFFER_BIT)) {
17446 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to 17449 // To be on the safe side, always map GL_MAP_INVALIDATE_BUFFER_BIT to
17447 // GL_MAP_INVALIDATE_RANGE_BIT. 17450 // GL_MAP_INVALIDATE_RANGE_BIT.
17448 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); 17451 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT);
17449 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); 17452 access = (access | GL_MAP_INVALIDATE_RANGE_BIT);
17450 } 17453 }
17451 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined 17454 // Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of undefined
17452 // behaviors. 17455 // behaviors.
17453 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); 17456 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT);
17454 if (AllBitsSet(access, GL_MAP_WRITE_BIT) && 17457 if (AllBitsSet(access, GL_MAP_WRITE_BIT) &&
17455 !AllBitsSet(access, GL_MAP_INVALIDATE_RANGE_BIT)) { 17458 !AllBitsSet(access, GL_MAP_INVALIDATE_RANGE_BIT)) {
17456 access = (access | GL_MAP_READ_BIT); 17459 access = (access | GL_MAP_READ_BIT);
17457 } 17460 }
17458 void* ptr = glMapBufferRange(target, offset, size, access); 17461 void* ptr = glMapBufferRange(target, offset, size, access);
17459 if (ptr == nullptr) { 17462 if (ptr == nullptr) {
17463 // This should mean GL_OUT_OF_MEMORY.
Kai Ninomiya 2016/11/01 03:16:01 Can context loss (or anything else) trigger this?
Zhenyao Mo 2016/11/01 04:49:44 In context lost, the behavior (returned value) is
Kai Ninomiya 2016/11/01 20:28:41 Done.
17464 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name);
17460 return error::kNoError; 17465 return error::kNoError;
17461 } 17466 }
17462 buffer->SetMappedRange(offset, size, access, ptr, 17467 buffer->SetMappedRange(offset, size, access, ptr,
17463 GetSharedMemoryBuffer(data_shm_id), 17468 GetSharedMemoryBuffer(data_shm_id),
17464 static_cast<unsigned int>(data_shm_offset)); 17469 static_cast<unsigned int>(data_shm_offset));
17465 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 17470 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
17466 memcpy(mem, ptr, size); 17471 memcpy(mem, ptr, size);
17467 } 17472 }
17468 *result = 1; 17473 *result = 1;
17469 return error::kNoError; 17474 return error::kNoError;
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
18760 } 18765 }
18761 18766
18762 // Include the auto-generated part of this file. We split this because it means 18767 // Include the auto-generated part of this file. We split this because it means
18763 // we can easily edit the non-auto generated parts right here in this file 18768 // we can easily edit the non-auto generated parts right here in this file
18764 // instead of having to edit some template or the code generator. 18769 // instead of having to edit some template or the code generator.
18765 #include "base/macros.h" 18770 #include "base/macros.h"
18766 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18771 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18767 18772
18768 } // namespace gles2 18773 } // namespace gles2
18769 } // namespace gpu 18774 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698