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