| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 unpack_alignment_(4), | 92 unpack_alignment_(4), |
| 93 unpack_flip_y_(false), | 93 unpack_flip_y_(false), |
| 94 unpack_row_length_(0), | 94 unpack_row_length_(0), |
| 95 unpack_skip_rows_(0), | 95 unpack_skip_rows_(0), |
| 96 unpack_skip_pixels_(0), | 96 unpack_skip_pixels_(0), |
| 97 pack_reverse_row_order_(false), | 97 pack_reverse_row_order_(false), |
| 98 active_texture_unit_(0), | 98 active_texture_unit_(0), |
| 99 bound_framebuffer_(0), | 99 bound_framebuffer_(0), |
| 100 bound_read_framebuffer_(0), | 100 bound_read_framebuffer_(0), |
| 101 bound_renderbuffer_(0), | 101 bound_renderbuffer_(0), |
| 102 bound_valuebuffer_(0), |
| 102 current_program_(0), | 103 current_program_(0), |
| 103 bound_array_buffer_id_(0), | 104 bound_array_buffer_id_(0), |
| 104 bound_pixel_pack_transfer_buffer_id_(0), | 105 bound_pixel_pack_transfer_buffer_id_(0), |
| 105 bound_pixel_unpack_transfer_buffer_id_(0), | 106 bound_pixel_unpack_transfer_buffer_id_(0), |
| 106 async_upload_token_(0), | 107 async_upload_token_(0), |
| 107 async_upload_sync_(NULL), | 108 async_upload_sync_(NULL), |
| 108 async_upload_sync_shm_id_(0), | 109 async_upload_sync_shm_id_(0), |
| 109 async_upload_sync_shm_offset_(0), | 110 async_upload_sync_shm_offset_(0), |
| 110 error_bits_(0), | 111 error_bits_(0), |
| 111 debug_(false), | 112 debug_(false), |
| (...skipping 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 | 2358 |
| 2358 void GLES2Implementation::GenVertexArraysOESHelper( | 2359 void GLES2Implementation::GenVertexArraysOESHelper( |
| 2359 GLsizei n, const GLuint* arrays) { | 2360 GLsizei n, const GLuint* arrays) { |
| 2360 vertex_array_object_manager_->GenVertexArrays(n, arrays); | 2361 vertex_array_object_manager_->GenVertexArrays(n, arrays); |
| 2361 } | 2362 } |
| 2362 | 2363 |
| 2363 void GLES2Implementation::GenQueriesEXTHelper( | 2364 void GLES2Implementation::GenQueriesEXTHelper( |
| 2364 GLsizei /* n */, const GLuint* /* queries */) { | 2365 GLsizei /* n */, const GLuint* /* queries */) { |
| 2365 } | 2366 } |
| 2366 | 2367 |
| 2368 void GLES2Implementation::GenValuebuffersCHROMIUMHelper( |
| 2369 GLsizei /* n */, |
| 2370 const GLuint* /* valuebuffers */) { |
| 2371 } |
| 2372 |
| 2367 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 2373 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id |
| 2368 // generates a new resource. On newer versions of OpenGL they don't. The code | 2374 // generates a new resource. On newer versions of OpenGL they don't. The code |
| 2369 // related to binding below will need to change if we switch to the new OpenGL | 2375 // related to binding below will need to change if we switch to the new OpenGL |
| 2370 // model. Specifically it assumes a bind will succeed which is always true in | 2376 // model. Specifically it assumes a bind will succeed which is always true in |
| 2371 // the old model but possibly not true in the new model if another context has | 2377 // the old model but possibly not true in the new model if another context has |
| 2372 // deleted the resource. | 2378 // deleted the resource. |
| 2373 | 2379 |
| 2374 bool GLES2Implementation::BindBufferHelper( | 2380 bool GLES2Implementation::BindBufferHelper( |
| 2375 GLenum target, GLuint buffer_id) { | 2381 GLenum target, GLuint buffer_id) { |
| 2376 // TODO(gman): See note #1 above. | 2382 // TODO(gman): See note #1 above. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 GL_INVALID_OPERATION, "glBindVertexArrayOES", | 2512 GL_INVALID_OPERATION, "glBindVertexArrayOES", |
| 2507 "id was not generated with glGenVertexArrayOES"); | 2513 "id was not generated with glGenVertexArrayOES"); |
| 2508 } | 2514 } |
| 2509 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind | 2515 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind |
| 2510 // because unlike other resources VertexArrayObject ids must | 2516 // because unlike other resources VertexArrayObject ids must |
| 2511 // be generated by GenVertexArrays. A random id to Bind will not | 2517 // be generated by GenVertexArrays. A random id to Bind will not |
| 2512 // generate a new object. | 2518 // generate a new object. |
| 2513 return changed; | 2519 return changed; |
| 2514 } | 2520 } |
| 2515 | 2521 |
| 2522 bool GLES2Implementation::BindValuebufferCHROMIUMHelper(GLenum target, |
| 2523 GLuint valuebuffer) { |
| 2524 bool changed = false; |
| 2525 switch (target) { |
| 2526 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: |
| 2527 if (bound_valuebuffer_ != valuebuffer) { |
| 2528 bound_valuebuffer_ = valuebuffer; |
| 2529 changed = true; |
| 2530 } |
| 2531 break; |
| 2532 default: |
| 2533 changed = true; |
| 2534 break; |
| 2535 } |
| 2536 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2537 // used even though it's marked it as used here. |
| 2538 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind(valuebuffer); |
| 2539 return changed; |
| 2540 } |
| 2541 |
| 2516 bool GLES2Implementation::UseProgramHelper(GLuint program) { | 2542 bool GLES2Implementation::UseProgramHelper(GLuint program) { |
| 2517 bool changed = false; | 2543 bool changed = false; |
| 2518 if (current_program_ != program) { | 2544 if (current_program_ != program) { |
| 2519 current_program_ = program; | 2545 current_program_ = program; |
| 2520 changed = true; | 2546 changed = true; |
| 2521 } | 2547 } |
| 2522 return changed; | 2548 return changed; |
| 2523 } | 2549 } |
| 2524 | 2550 |
| 2525 bool GLES2Implementation::IsBufferReservedId(GLuint id) { | 2551 bool GLES2Implementation::IsBufferReservedId(GLuint id) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 if (textures[ii] == unit.bound_texture_cube_map) { | 2648 if (textures[ii] == unit.bound_texture_cube_map) { |
| 2623 unit.bound_texture_cube_map = 0; | 2649 unit.bound_texture_cube_map = 0; |
| 2624 } | 2650 } |
| 2625 if (textures[ii] == unit.bound_texture_external_oes) { | 2651 if (textures[ii] == unit.bound_texture_external_oes) { |
| 2626 unit.bound_texture_external_oes = 0; | 2652 unit.bound_texture_external_oes = 0; |
| 2627 } | 2653 } |
| 2628 } | 2654 } |
| 2629 } | 2655 } |
| 2630 } | 2656 } |
| 2631 | 2657 |
| 2658 void GLES2Implementation::DeleteTexturesStub(GLsizei n, |
| 2659 const GLuint* textures) { |
| 2660 helper_->DeleteTexturesImmediate(n, textures); |
| 2661 } |
| 2662 |
| 2632 void GLES2Implementation::DeleteVertexArraysOESHelper( | 2663 void GLES2Implementation::DeleteVertexArraysOESHelper( |
| 2633 GLsizei n, const GLuint* arrays) { | 2664 GLsizei n, const GLuint* arrays) { |
| 2634 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); | 2665 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); |
| 2635 if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds( | 2666 if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds( |
| 2636 this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) { | 2667 this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) { |
| 2637 SetGLError( | 2668 SetGLError( |
| 2638 GL_INVALID_VALUE, | 2669 GL_INVALID_VALUE, |
| 2639 "glDeleteVertexArraysOES", "id not created by this context."); | 2670 "glDeleteVertexArraysOES", "id not created by this context."); |
| 2640 return; | 2671 return; |
| 2641 } | 2672 } |
| 2642 } | 2673 } |
| 2643 | 2674 |
| 2644 void GLES2Implementation::DeleteVertexArraysOESStub( | 2675 void GLES2Implementation::DeleteVertexArraysOESStub( |
| 2645 GLsizei n, const GLuint* arrays) { | 2676 GLsizei n, const GLuint* arrays) { |
| 2646 helper_->DeleteVertexArraysOESImmediate(n, arrays); | 2677 helper_->DeleteVertexArraysOESImmediate(n, arrays); |
| 2647 } | 2678 } |
| 2648 | 2679 |
| 2649 void GLES2Implementation::DeleteTexturesStub( | 2680 void GLES2Implementation::DeleteValuebuffersCHROMIUMHelper( |
| 2650 GLsizei n, const GLuint* textures) { | 2681 GLsizei n, |
| 2651 helper_->DeleteTexturesImmediate(n, textures); | 2682 const GLuint* valuebuffers) { |
| 2683 if (!GetIdHandler(id_namespaces::kValuebuffers) |
| 2684 ->FreeIds(this, n, valuebuffers, |
| 2685 &GLES2Implementation::DeleteValuebuffersCHROMIUMStub)) { |
| 2686 SetGLError(GL_INVALID_VALUE, "glDeleteValuebuffersCHROMIUM", |
| 2687 "id not created by this context."); |
| 2688 return; |
| 2689 } |
| 2690 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2691 if (valuebuffers[ii] == bound_valuebuffer_) { |
| 2692 bound_valuebuffer_ = 0; |
| 2693 } |
| 2694 } |
| 2695 } |
| 2696 |
| 2697 void GLES2Implementation::DeleteValuebuffersCHROMIUMStub( |
| 2698 GLsizei n, |
| 2699 const GLuint* valuebuffers) { |
| 2700 helper_->DeleteValuebuffersCHROMIUMImmediate(n, valuebuffers); |
| 2652 } | 2701 } |
| 2653 | 2702 |
| 2654 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { | 2703 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { |
| 2655 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2704 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2656 GPU_CLIENT_LOG( | 2705 GPU_CLIENT_LOG( |
| 2657 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); | 2706 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); |
| 2658 vertex_array_object_manager_->SetAttribEnable(index, false); | 2707 vertex_array_object_manager_->SetAttribEnable(index, false); |
| 2659 helper_->DisableVertexAttribArray(index); | 2708 helper_->DisableVertexAttribArray(index); |
| 2660 CheckGLError(); | 2709 CheckGLError(); |
| 2661 } | 2710 } |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4068 return true; | 4117 return true; |
| 4069 } | 4118 } |
| 4070 | 4119 |
| 4071 // Include the auto-generated part of this file. We split this because it means | 4120 // Include the auto-generated part of this file. We split this because it means |
| 4072 // we can easily edit the non-auto generated parts right here in this file | 4121 // we can easily edit the non-auto generated parts right here in this file |
| 4073 // instead of having to edit some template or the code generator. | 4122 // instead of having to edit some template or the code generator. |
| 4074 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4123 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 4075 | 4124 |
| 4076 } // namespace gles2 | 4125 } // namespace gles2 |
| 4077 } // namespace gpu | 4126 } // namespace gpu |
| OLD | NEW |