| 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/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 unpack_alignment_(4), | 126 unpack_alignment_(4), |
| 127 unpack_row_length_(0), | 127 unpack_row_length_(0), |
| 128 unpack_image_height_(0), | 128 unpack_image_height_(0), |
| 129 unpack_skip_rows_(0), | 129 unpack_skip_rows_(0), |
| 130 unpack_skip_pixels_(0), | 130 unpack_skip_pixels_(0), |
| 131 unpack_skip_images_(0), | 131 unpack_skip_images_(0), |
| 132 active_texture_unit_(0), | 132 active_texture_unit_(0), |
| 133 bound_framebuffer_(0), | 133 bound_framebuffer_(0), |
| 134 bound_read_framebuffer_(0), | 134 bound_read_framebuffer_(0), |
| 135 bound_renderbuffer_(0), | 135 bound_renderbuffer_(0), |
| 136 bound_valuebuffer_(0), | |
| 137 current_program_(0), | 136 current_program_(0), |
| 138 bound_array_buffer_(0), | 137 bound_array_buffer_(0), |
| 139 bound_copy_read_buffer_(0), | 138 bound_copy_read_buffer_(0), |
| 140 bound_copy_write_buffer_(0), | 139 bound_copy_write_buffer_(0), |
| 141 bound_pixel_pack_buffer_(0), | 140 bound_pixel_pack_buffer_(0), |
| 142 bound_pixel_unpack_buffer_(0), | 141 bound_pixel_unpack_buffer_(0), |
| 143 bound_transform_feedback_buffer_(0), | 142 bound_transform_feedback_buffer_(0), |
| 144 bound_uniform_buffer_(0), | 143 bound_uniform_buffer_(0), |
| 145 bound_pixel_pack_transfer_buffer_id_(0), | 144 bound_pixel_pack_transfer_buffer_id_(0), |
| 146 bound_pixel_unpack_transfer_buffer_id_(0), | 145 bound_pixel_unpack_transfer_buffer_id_(0), |
| (...skipping 3828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3975 | 3974 |
| 3976 void GLES2Implementation::GenVertexArraysOESHelper( | 3975 void GLES2Implementation::GenVertexArraysOESHelper( |
| 3977 GLsizei n, const GLuint* arrays) { | 3976 GLsizei n, const GLuint* arrays) { |
| 3978 vertex_array_object_manager_->GenVertexArrays(n, arrays); | 3977 vertex_array_object_manager_->GenVertexArrays(n, arrays); |
| 3979 } | 3978 } |
| 3980 | 3979 |
| 3981 void GLES2Implementation::GenQueriesEXTHelper( | 3980 void GLES2Implementation::GenQueriesEXTHelper( |
| 3982 GLsizei /* n */, const GLuint* /* queries */) { | 3981 GLsizei /* n */, const GLuint* /* queries */) { |
| 3983 } | 3982 } |
| 3984 | 3983 |
| 3985 void GLES2Implementation::GenValuebuffersCHROMIUMHelper( | |
| 3986 GLsizei /* n */, | |
| 3987 const GLuint* /* valuebuffers */) { | |
| 3988 } | |
| 3989 | |
| 3990 void GLES2Implementation::GenSamplersHelper( | 3984 void GLES2Implementation::GenSamplersHelper( |
| 3991 GLsizei /* n */, const GLuint* /* samplers */) { | 3985 GLsizei /* n */, const GLuint* /* samplers */) { |
| 3992 } | 3986 } |
| 3993 | 3987 |
| 3994 void GLES2Implementation::GenTransformFeedbacksHelper( | 3988 void GLES2Implementation::GenTransformFeedbacksHelper( |
| 3995 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { | 3989 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { |
| 3996 } | 3990 } |
| 3997 | 3991 |
| 3998 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 3992 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id |
| 3999 // generates a new resource. On newer versions of OpenGL they don't. The code | 3993 // generates a new resource. On newer versions of OpenGL they don't. The code |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 // generate a new object. | 4277 // generate a new object. |
| 4284 helper_->BindVertexArrayOES(array); | 4278 helper_->BindVertexArrayOES(array); |
| 4285 } | 4279 } |
| 4286 } else { | 4280 } else { |
| 4287 SetGLError( | 4281 SetGLError( |
| 4288 GL_INVALID_OPERATION, "glBindVertexArrayOES", | 4282 GL_INVALID_OPERATION, "glBindVertexArrayOES", |
| 4289 "id was not generated with glGenVertexArrayOES"); | 4283 "id was not generated with glGenVertexArrayOES"); |
| 4290 } | 4284 } |
| 4291 } | 4285 } |
| 4292 | 4286 |
| 4293 void GLES2Implementation::BindValuebufferCHROMIUMHelper(GLenum target, | |
| 4294 GLuint valuebuffer) { | |
| 4295 bool changed = false; | |
| 4296 switch (target) { | |
| 4297 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: | |
| 4298 if (bound_valuebuffer_ != valuebuffer) { | |
| 4299 bound_valuebuffer_ = valuebuffer; | |
| 4300 changed = true; | |
| 4301 } | |
| 4302 break; | |
| 4303 default: | |
| 4304 changed = true; | |
| 4305 break; | |
| 4306 } | |
| 4307 // TODO(gman): See note #2 above. | |
| 4308 if (changed) { | |
| 4309 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( | |
| 4310 this, target, valuebuffer, | |
| 4311 &GLES2Implementation::BindValuebufferCHROMIUMStub); | |
| 4312 } | |
| 4313 } | |
| 4314 | |
| 4315 void GLES2Implementation::BindValuebufferCHROMIUMStub(GLenum target, | |
| 4316 GLuint valuebuffer) { | |
| 4317 helper_->BindValuebufferCHROMIUM(target, valuebuffer); | |
| 4318 if (share_group_->bind_generates_resource()) | |
| 4319 helper_->CommandBufferHelper::OrderingBarrier(); | |
| 4320 } | |
| 4321 | |
| 4322 void GLES2Implementation::UseProgramHelper(GLuint program) { | 4287 void GLES2Implementation::UseProgramHelper(GLuint program) { |
| 4323 if (current_program_ != program) { | 4288 if (current_program_ != program) { |
| 4324 current_program_ = program; | 4289 current_program_ = program; |
| 4325 helper_->UseProgram(program); | 4290 helper_->UseProgram(program); |
| 4326 } | 4291 } |
| 4327 } | 4292 } |
| 4328 | 4293 |
| 4329 bool GLES2Implementation::IsBufferReservedId(GLuint id) { | 4294 bool GLES2Implementation::IsBufferReservedId(GLuint id) { |
| 4330 return vertex_array_object_manager_->IsReservedId(id); | 4295 return vertex_array_object_manager_->IsReservedId(id); |
| 4331 } | 4296 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4467 "glDeleteVertexArraysOES", "id not created by this context."); | 4432 "glDeleteVertexArraysOES", "id not created by this context."); |
| 4468 return; | 4433 return; |
| 4469 } | 4434 } |
| 4470 } | 4435 } |
| 4471 | 4436 |
| 4472 void GLES2Implementation::DeleteVertexArraysOESStub( | 4437 void GLES2Implementation::DeleteVertexArraysOESStub( |
| 4473 GLsizei n, const GLuint* arrays) { | 4438 GLsizei n, const GLuint* arrays) { |
| 4474 helper_->DeleteVertexArraysOESImmediate(n, arrays); | 4439 helper_->DeleteVertexArraysOESImmediate(n, arrays); |
| 4475 } | 4440 } |
| 4476 | 4441 |
| 4477 void GLES2Implementation::DeleteValuebuffersCHROMIUMHelper( | |
| 4478 GLsizei n, | |
| 4479 const GLuint* valuebuffers) { | |
| 4480 if (!GetIdHandler(id_namespaces::kValuebuffers) | |
| 4481 ->FreeIds(this, n, valuebuffers, | |
| 4482 &GLES2Implementation::DeleteValuebuffersCHROMIUMStub)) { | |
| 4483 SetGLError(GL_INVALID_VALUE, "glDeleteValuebuffersCHROMIUM", | |
| 4484 "id not created by this context."); | |
| 4485 return; | |
| 4486 } | |
| 4487 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 4488 if (valuebuffers[ii] == bound_valuebuffer_) { | |
| 4489 bound_valuebuffer_ = 0; | |
| 4490 } | |
| 4491 } | |
| 4492 } | |
| 4493 | |
| 4494 void GLES2Implementation::DeleteSamplersStub( | 4442 void GLES2Implementation::DeleteSamplersStub( |
| 4495 GLsizei n, const GLuint* samplers) { | 4443 GLsizei n, const GLuint* samplers) { |
| 4496 helper_->DeleteSamplersImmediate(n, samplers); | 4444 helper_->DeleteSamplersImmediate(n, samplers); |
| 4497 } | 4445 } |
| 4498 | 4446 |
| 4499 void GLES2Implementation::DeleteSamplersHelper( | 4447 void GLES2Implementation::DeleteSamplersHelper( |
| 4500 GLsizei n, const GLuint* samplers) { | 4448 GLsizei n, const GLuint* samplers) { |
| 4501 if (!GetIdHandler(id_namespaces::kSamplers)->FreeIds( | 4449 if (!GetIdHandler(id_namespaces::kSamplers)->FreeIds( |
| 4502 this, n, samplers, &GLES2Implementation::DeleteSamplersStub)) { | 4450 this, n, samplers, &GLES2Implementation::DeleteSamplersStub)) { |
| 4503 SetGLError( | 4451 SetGLError( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4517 if (!GetIdHandler(id_namespaces::kTransformFeedbacks)->FreeIds( | 4465 if (!GetIdHandler(id_namespaces::kTransformFeedbacks)->FreeIds( |
| 4518 this, n, transformfeedbacks, | 4466 this, n, transformfeedbacks, |
| 4519 &GLES2Implementation::DeleteTransformFeedbacksStub)) { | 4467 &GLES2Implementation::DeleteTransformFeedbacksStub)) { |
| 4520 SetGLError( | 4468 SetGLError( |
| 4521 GL_INVALID_VALUE, | 4469 GL_INVALID_VALUE, |
| 4522 "glDeleteTransformFeedbacks", "id not created by this context."); | 4470 "glDeleteTransformFeedbacks", "id not created by this context."); |
| 4523 return; | 4471 return; |
| 4524 } | 4472 } |
| 4525 } | 4473 } |
| 4526 | 4474 |
| 4527 void GLES2Implementation::DeleteValuebuffersCHROMIUMStub( | |
| 4528 GLsizei n, | |
| 4529 const GLuint* valuebuffers) { | |
| 4530 helper_->DeleteValuebuffersCHROMIUMImmediate(n, valuebuffers); | |
| 4531 } | |
| 4532 | |
| 4533 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { | 4475 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { |
| 4534 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 4476 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 4535 GPU_CLIENT_LOG( | 4477 GPU_CLIENT_LOG( |
| 4536 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); | 4478 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); |
| 4537 vertex_array_object_manager_->SetAttribEnable(index, false); | 4479 vertex_array_object_manager_->SetAttribEnable(index, false); |
| 4538 helper_->DisableVertexAttribArray(index); | 4480 helper_->DisableVertexAttribArray(index); |
| 4539 CheckGLError(); | 4481 CheckGLError(); |
| 4540 } | 4482 } |
| 4541 | 4483 |
| 4542 void GLES2Implementation::EnableVertexAttribArray(GLuint index) { | 4484 void GLES2Implementation::EnableVertexAttribArray(GLuint index) { |
| (...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6877 cached_extensions_.clear(); | 6819 cached_extensions_.clear(); |
| 6878 } | 6820 } |
| 6879 | 6821 |
| 6880 // Include the auto-generated part of this file. We split this because it means | 6822 // Include the auto-generated part of this file. We split this because it means |
| 6881 // we can easily edit the non-auto generated parts right here in this file | 6823 // we can easily edit the non-auto generated parts right here in this file |
| 6882 // instead of having to edit some template or the code generator. | 6824 // instead of having to edit some template or the code generator. |
| 6883 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6825 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6884 | 6826 |
| 6885 } // namespace gles2 | 6827 } // namespace gles2 |
| 6886 } // namespace gpu | 6828 } // namespace gpu |
| OLD | NEW |