| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 util_.set_num_compressed_texture_formats( | 238 util_.set_num_compressed_texture_formats( |
| 239 capabilities_.num_compressed_texture_formats); | 239 capabilities_.num_compressed_texture_formats); |
| 240 util_.set_num_shader_binary_formats(capabilities_.num_shader_binary_formats); | 240 util_.set_num_shader_binary_formats(capabilities_.num_shader_binary_formats); |
| 241 | 241 |
| 242 texture_units_.reset( | 242 texture_units_.reset( |
| 243 new TextureUnit[capabilities_.max_combined_texture_image_units]); | 243 new TextureUnit[capabilities_.max_combined_texture_image_units]); |
| 244 | 244 |
| 245 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); | 245 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); |
| 246 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); | 246 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); |
| 247 | 247 |
| 248 query_id_allocator_.reset(new IdAllocator()); | 248 for (int i = 0; i < static_cast<int>(IdNamespaces::kNumIdNamespaces); ++i) |
| 249 id_allocators_[i].reset(new IdAllocator()); |
| 250 |
| 249 if (support_client_side_arrays_) { | 251 if (support_client_side_arrays_) { |
| 250 GetIdHandler(id_namespaces::kBuffers)->MakeIds( | 252 GetIdHandler(SharedIdNamespaces::kBuffers) |
| 251 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); | 253 ->MakeIds(this, kClientSideArrayId, arraysize(reserved_ids_), |
| 254 &reserved_ids_[0]); |
| 252 } | 255 } |
| 253 | 256 |
| 254 vertex_array_object_manager_.reset(new VertexArrayObjectManager( | 257 vertex_array_object_manager_.reset(new VertexArrayObjectManager( |
| 255 capabilities_.max_vertex_attribs, reserved_ids_[0], reserved_ids_[1], | 258 capabilities_.max_vertex_attribs, reserved_ids_[0], reserved_ids_[1], |
| 256 support_client_side_arrays_)); | 259 support_client_side_arrays_)); |
| 257 | 260 |
| 258 // GL_BIND_GENERATES_RESOURCE_CHROMIUM state must be the same | 261 // GL_BIND_GENERATES_RESOURCE_CHROMIUM state must be the same |
| 259 // on Client & Service. | 262 // on Client & Service. |
| 260 if (capabilities_.bind_generates_resource_chromium != | 263 if (capabilities_.bind_generates_resource_chromium != |
| 261 (share_group_->bind_generates_resource() ? 1 : 0)) { | 264 (share_group_->bind_generates_resource() ? 1 : 0)) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 299 |
| 297 // The gpu_control_ outlives this class, so clear the client on it before we | 300 // The gpu_control_ outlives this class, so clear the client on it before we |
| 298 // self-destruct. | 301 // self-destruct. |
| 299 gpu_control_->SetGpuControlClient(nullptr); | 302 gpu_control_->SetGpuControlClient(nullptr); |
| 300 } | 303 } |
| 301 | 304 |
| 302 GLES2CmdHelper* GLES2Implementation::helper() const { | 305 GLES2CmdHelper* GLES2Implementation::helper() const { |
| 303 return helper_; | 306 return helper_; |
| 304 } | 307 } |
| 305 | 308 |
| 306 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const { | 309 IdHandlerInterface* GLES2Implementation::GetIdHandler( |
| 310 SharedIdNamespaces namespace_id) const { |
| 307 return share_group_->GetIdHandler(namespace_id); | 311 return share_group_->GetIdHandler(namespace_id); |
| 308 } | 312 } |
| 309 | 313 |
| 310 RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler( | 314 RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler( |
| 311 int namespace_id) const { | 315 int namespace_id) const { |
| 312 return share_group_->GetRangeIdHandler(namespace_id); | 316 return share_group_->GetRangeIdHandler(namespace_id); |
| 313 } | 317 } |
| 314 | 318 |
| 315 IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { | 319 IdAllocator* GLES2Implementation::GetIdAllocator( |
| 316 if (namespace_id == id_namespaces::kQueries) | 320 IdNamespaces namespace_id) const { |
| 317 return query_id_allocator_.get(); | 321 return id_allocators_[static_cast<int>(namespace_id)].get(); |
| 318 NOTREACHED(); | |
| 319 return NULL; | |
| 320 } | 322 } |
| 321 | 323 |
| 322 void GLES2Implementation::OnGpuControlLostContext() { | 324 void GLES2Implementation::OnGpuControlLostContext() { |
| 323 // This should never occur more than once. | 325 // This should never occur more than once. |
| 324 DCHECK(!lost_context_callback_run_); | 326 DCHECK(!lost_context_callback_run_); |
| 325 lost_context_callback_run_ = true; | 327 lost_context_callback_run_ = true; |
| 326 share_group_->Lose(); | 328 share_group_->Lose(); |
| 327 if (!lost_context_callback_.is_null()) | 329 if (!lost_context_callback_.is_null()) |
| 328 lost_context_callback_.Run(); | 330 lost_context_callback_.Run(); |
| 329 } | 331 } |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 } | 1592 } |
| 1591 GPU_CLIENT_LOG_CODE_BLOCK({ | 1593 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 1592 for (int32_t i = 0; i < num_results; ++i) { | 1594 for (int32_t i = 0; i < num_results; ++i) { |
| 1593 GPU_CLIENT_LOG(" " << i << ": " << ptr[i]); | 1595 GPU_CLIENT_LOG(" " << i << ": " << ptr[i]); |
| 1594 } | 1596 } |
| 1595 }); | 1597 }); |
| 1596 CheckGLError(); | 1598 CheckGLError(); |
| 1597 } | 1599 } |
| 1598 | 1600 |
| 1599 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { | 1601 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { |
| 1600 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( | 1602 if (!GetIdHandler(SharedIdNamespaces::kProgramsAndShaders) |
| 1601 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) { | 1603 ->FreeIds(this, 1, &program, |
| 1604 &GLES2Implementation::DeleteProgramStub)) { |
| 1602 SetGLError( | 1605 SetGLError( |
| 1603 GL_INVALID_VALUE, | 1606 GL_INVALID_VALUE, |
| 1604 "glDeleteProgram", "id not created by this context."); | 1607 "glDeleteProgram", "id not created by this context."); |
| 1605 return false; | 1608 return false; |
| 1606 } | 1609 } |
| 1607 if (program == current_program_) { | 1610 if (program == current_program_) { |
| 1608 current_program_ = 0; | 1611 current_program_ = 0; |
| 1609 } | 1612 } |
| 1610 return true; | 1613 return true; |
| 1611 } | 1614 } |
| 1612 | 1615 |
| 1613 void GLES2Implementation::DeleteProgramStub( | 1616 void GLES2Implementation::DeleteProgramStub( |
| 1614 GLsizei n, const GLuint* programs) { | 1617 GLsizei n, const GLuint* programs) { |
| 1615 DCHECK_EQ(1, n); | 1618 DCHECK_EQ(1, n); |
| 1616 share_group_->program_info_manager()->DeleteInfo(programs[0]); | 1619 share_group_->program_info_manager()->DeleteInfo(programs[0]); |
| 1617 helper_->DeleteProgram(programs[0]); | 1620 helper_->DeleteProgram(programs[0]); |
| 1618 } | 1621 } |
| 1619 | 1622 |
| 1620 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) { | 1623 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) { |
| 1621 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( | 1624 if (!GetIdHandler(SharedIdNamespaces::kProgramsAndShaders) |
| 1622 this, 1, &shader, &GLES2Implementation::DeleteShaderStub)) { | 1625 ->FreeIds(this, 1, &shader, |
| 1626 &GLES2Implementation::DeleteShaderStub)) { |
| 1623 SetGLError( | 1627 SetGLError( |
| 1624 GL_INVALID_VALUE, | 1628 GL_INVALID_VALUE, |
| 1625 "glDeleteShader", "id not created by this context."); | 1629 "glDeleteShader", "id not created by this context."); |
| 1626 return false; | 1630 return false; |
| 1627 } | 1631 } |
| 1628 return true; | 1632 return true; |
| 1629 } | 1633 } |
| 1630 | 1634 |
| 1631 void GLES2Implementation::DeleteShaderStub( | 1635 void GLES2Implementation::DeleteShaderStub( |
| 1632 GLsizei n, const GLuint* shaders) { | 1636 GLsizei n, const GLuint* shaders) { |
| 1633 DCHECK_EQ(1, n); | 1637 DCHECK_EQ(1, n); |
| 1634 share_group_->program_info_manager()->DeleteInfo(shaders[0]); | 1638 share_group_->program_info_manager()->DeleteInfo(shaders[0]); |
| 1635 helper_->DeleteShader(shaders[0]); | 1639 helper_->DeleteShader(shaders[0]); |
| 1636 } | 1640 } |
| 1637 | 1641 |
| 1638 void GLES2Implementation::DeleteSyncHelper(GLsync sync) { | 1642 void GLES2Implementation::DeleteSyncHelper(GLsync sync) { |
| 1639 GLuint sync_uint = ToGLuint(sync); | 1643 GLuint sync_uint = ToGLuint(sync); |
| 1640 if (!GetIdHandler(id_namespaces::kSyncs)->FreeIds( | 1644 if (!GetIdHandler(SharedIdNamespaces::kSyncs) |
| 1641 this, 1, &sync_uint, &GLES2Implementation::DeleteSyncStub)) { | 1645 ->FreeIds(this, 1, &sync_uint, |
| 1646 &GLES2Implementation::DeleteSyncStub)) { |
| 1642 SetGLError( | 1647 SetGLError( |
| 1643 GL_INVALID_VALUE, | 1648 GL_INVALID_VALUE, |
| 1644 "glDeleteSync", "id not created by this context."); | 1649 "glDeleteSync", "id not created by this context."); |
| 1645 } | 1650 } |
| 1646 } | 1651 } |
| 1647 | 1652 |
| 1648 void GLES2Implementation::DeleteSyncStub(GLsizei n, const GLuint* syncs) { | 1653 void GLES2Implementation::DeleteSyncStub(GLsizei n, const GLuint* syncs) { |
| 1649 DCHECK_EQ(1, n); | 1654 DCHECK_EQ(1, n); |
| 1650 helper_->DeleteSync(syncs[0]); | 1655 helper_->DeleteSync(syncs[0]); |
| 1651 } | 1656 } |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4284 bound_uniform_buffer_ = buffer_id; | 4289 bound_uniform_buffer_ = buffer_id; |
| 4285 changed = true; | 4290 changed = true; |
| 4286 } | 4291 } |
| 4287 break; | 4292 break; |
| 4288 default: | 4293 default: |
| 4289 changed = true; | 4294 changed = true; |
| 4290 break; | 4295 break; |
| 4291 } | 4296 } |
| 4292 // TODO(gman): See note #2 above. | 4297 // TODO(gman): See note #2 above. |
| 4293 if (changed) { | 4298 if (changed) { |
| 4294 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 4299 GetIdHandler(SharedIdNamespaces::kBuffers) |
| 4295 this, target, buffer_id, &GLES2Implementation::BindBufferStub); | 4300 ->MarkAsUsedForBind(this, target, buffer_id, |
| 4301 &GLES2Implementation::BindBufferStub); |
| 4296 } | 4302 } |
| 4297 } | 4303 } |
| 4298 | 4304 |
| 4299 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { | 4305 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { |
| 4300 helper_->BindBuffer(target, buffer); | 4306 helper_->BindBuffer(target, buffer); |
| 4301 if (share_group_->bind_generates_resource()) | 4307 if (share_group_->bind_generates_resource()) |
| 4302 helper_->CommandBufferHelper::OrderingBarrier(); | 4308 helper_->CommandBufferHelper::OrderingBarrier(); |
| 4303 } | 4309 } |
| 4304 | 4310 |
| 4305 void GLES2Implementation::BindBufferBaseHelper( | 4311 void GLES2Implementation::BindBufferBaseHelper( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4327 return; | 4333 return; |
| 4328 } | 4334 } |
| 4329 if (bound_uniform_buffer_ != buffer_id) { | 4335 if (bound_uniform_buffer_ != buffer_id) { |
| 4330 bound_uniform_buffer_ = buffer_id; | 4336 bound_uniform_buffer_ = buffer_id; |
| 4331 } | 4337 } |
| 4332 break; | 4338 break; |
| 4333 default: | 4339 default: |
| 4334 SetGLError(GL_INVALID_ENUM, "glBindBufferBase", "invalid target"); | 4340 SetGLError(GL_INVALID_ENUM, "glBindBufferBase", "invalid target"); |
| 4335 return; | 4341 return; |
| 4336 } | 4342 } |
| 4337 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 4343 GetIdHandler(SharedIdNamespaces::kBuffers) |
| 4338 this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); | 4344 ->MarkAsUsedForBind(this, target, index, buffer_id, |
| 4345 &GLES2Implementation::BindBufferBaseStub); |
| 4339 } | 4346 } |
| 4340 | 4347 |
| 4341 void GLES2Implementation::BindBufferBaseStub( | 4348 void GLES2Implementation::BindBufferBaseStub( |
| 4342 GLenum target, GLuint index, GLuint buffer) { | 4349 GLenum target, GLuint index, GLuint buffer) { |
| 4343 helper_->BindBufferBase(target, index, buffer); | 4350 helper_->BindBufferBase(target, index, buffer); |
| 4344 if (share_group_->bind_generates_resource()) | 4351 if (share_group_->bind_generates_resource()) |
| 4345 helper_->CommandBufferHelper::Flush(); | 4352 helper_->CommandBufferHelper::Flush(); |
| 4346 } | 4353 } |
| 4347 | 4354 |
| 4348 void GLES2Implementation::BindBufferRangeHelper( | 4355 void GLES2Implementation::BindBufferRangeHelper( |
| 4349 GLenum target, GLuint index, GLuint buffer_id, | 4356 GLenum target, GLuint index, GLuint buffer_id, |
| 4350 GLintptr offset, GLsizeiptr size) { | 4357 GLintptr offset, GLsizeiptr size) { |
| 4351 // TODO(zmo): See note #1 above. | 4358 // TODO(zmo): See note #1 above. |
| 4352 // TODO(zmo): See note #2 above. | 4359 // TODO(zmo): See note #2 above. |
| 4353 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 4360 GetIdHandler(SharedIdNamespaces::kBuffers) |
| 4354 this, target, index, buffer_id, offset, size, | 4361 ->MarkAsUsedForBind(this, target, index, buffer_id, offset, size, |
| 4355 &GLES2Implementation::BindBufferRangeStub); | 4362 &GLES2Implementation::BindBufferRangeStub); |
| 4356 } | 4363 } |
| 4357 | 4364 |
| 4358 void GLES2Implementation::BindBufferRangeStub( | 4365 void GLES2Implementation::BindBufferRangeStub( |
| 4359 GLenum target, GLuint index, GLuint buffer, | 4366 GLenum target, GLuint index, GLuint buffer, |
| 4360 GLintptr offset, GLsizeiptr size) { | 4367 GLintptr offset, GLsizeiptr size) { |
| 4361 helper_->BindBufferRange(target, index, buffer, offset, size); | 4368 helper_->BindBufferRange(target, index, buffer, offset, size); |
| 4362 if (share_group_->bind_generates_resource()) | 4369 if (share_group_->bind_generates_resource()) |
| 4363 helper_->CommandBufferHelper::Flush(); | 4370 helper_->CommandBufferHelper::Flush(); |
| 4364 } | 4371 } |
| 4365 | 4372 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4391 bound_framebuffer_ = framebuffer; | 4398 bound_framebuffer_ = framebuffer; |
| 4392 changed = true; | 4399 changed = true; |
| 4393 } | 4400 } |
| 4394 break; | 4401 break; |
| 4395 default: | 4402 default: |
| 4396 SetGLErrorInvalidEnum("glBindFramebuffer", target, "target"); | 4403 SetGLErrorInvalidEnum("glBindFramebuffer", target, "target"); |
| 4397 return; | 4404 return; |
| 4398 } | 4405 } |
| 4399 | 4406 |
| 4400 if (changed) { | 4407 if (changed) { |
| 4401 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind( | 4408 if (framebuffer != 0) |
| 4402 this, target, framebuffer, &GLES2Implementation::BindFramebufferStub); | 4409 GetIdAllocator(IdNamespaces::kFramebuffers)->MarkAsUsed(framebuffer); |
| 4410 helper_->BindFramebuffer(target, framebuffer); |
| 4403 } | 4411 } |
| 4404 } | 4412 } |
| 4405 | 4413 |
| 4406 void GLES2Implementation::BindFramebufferStub(GLenum target, | |
| 4407 GLuint framebuffer) { | |
| 4408 helper_->BindFramebuffer(target, framebuffer); | |
| 4409 if (share_group_->bind_generates_resource()) | |
| 4410 helper_->CommandBufferHelper::OrderingBarrier(); | |
| 4411 } | |
| 4412 | |
| 4413 void GLES2Implementation::BindRenderbufferHelper( | 4414 void GLES2Implementation::BindRenderbufferHelper( |
| 4414 GLenum target, GLuint renderbuffer) { | 4415 GLenum target, GLuint renderbuffer) { |
| 4415 // TODO(gman): See note #1 above. | 4416 // TODO(gman): See note #1 above. |
| 4416 bool changed = false; | 4417 bool changed = false; |
| 4417 switch (target) { | 4418 switch (target) { |
| 4418 case GL_RENDERBUFFER: | 4419 case GL_RENDERBUFFER: |
| 4419 if (bound_renderbuffer_ != renderbuffer) { | 4420 if (bound_renderbuffer_ != renderbuffer) { |
| 4420 bound_renderbuffer_ = renderbuffer; | 4421 bound_renderbuffer_ = renderbuffer; |
| 4421 changed = true; | 4422 changed = true; |
| 4422 } | 4423 } |
| 4423 break; | 4424 break; |
| 4424 default: | 4425 default: |
| 4425 changed = true; | 4426 changed = true; |
| 4426 break; | 4427 break; |
| 4427 } | 4428 } |
| 4428 // TODO(zmo): See note #2 above. | 4429 // TODO(zmo): See note #2 above. |
| 4429 if (changed) { | 4430 if (changed) { |
| 4430 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( | 4431 GetIdHandler(SharedIdNamespaces::kRenderbuffers) |
| 4431 this, target, renderbuffer, | 4432 ->MarkAsUsedForBind(this, target, renderbuffer, |
| 4432 &GLES2Implementation::BindRenderbufferStub); | 4433 &GLES2Implementation::BindRenderbufferStub); |
| 4433 } | 4434 } |
| 4434 } | 4435 } |
| 4435 | 4436 |
| 4436 void GLES2Implementation::BindRenderbufferStub(GLenum target, | 4437 void GLES2Implementation::BindRenderbufferStub(GLenum target, |
| 4437 GLuint renderbuffer) { | 4438 GLuint renderbuffer) { |
| 4438 helper_->BindRenderbuffer(target, renderbuffer); | 4439 helper_->BindRenderbuffer(target, renderbuffer); |
| 4439 if (share_group_->bind_generates_resource()) | 4440 if (share_group_->bind_generates_resource()) |
| 4440 helper_->CommandBufferHelper::OrderingBarrier(); | 4441 helper_->CommandBufferHelper::OrderingBarrier(); |
| 4441 } | 4442 } |
| 4442 | 4443 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4469 unit.bound_texture_external_oes = texture; | 4470 unit.bound_texture_external_oes = texture; |
| 4470 changed = true; | 4471 changed = true; |
| 4471 } | 4472 } |
| 4472 break; | 4473 break; |
| 4473 default: | 4474 default: |
| 4474 changed = true; | 4475 changed = true; |
| 4475 break; | 4476 break; |
| 4476 } | 4477 } |
| 4477 // TODO(gman): See note #2 above. | 4478 // TODO(gman): See note #2 above. |
| 4478 if (changed) { | 4479 if (changed) { |
| 4479 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( | 4480 GetIdHandler(SharedIdNamespaces::kTextures) |
| 4480 this, target, texture, &GLES2Implementation::BindTextureStub); | 4481 ->MarkAsUsedForBind(this, target, texture, |
| 4482 &GLES2Implementation::BindTextureStub); |
| 4481 } | 4483 } |
| 4482 } | 4484 } |
| 4483 | 4485 |
| 4484 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { | 4486 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { |
| 4485 helper_->BindTexture(target, texture); | 4487 helper_->BindTexture(target, texture); |
| 4486 if (share_group_->bind_generates_resource()) | 4488 if (share_group_->bind_generates_resource()) |
| 4487 helper_->CommandBufferHelper::OrderingBarrier(); | 4489 helper_->CommandBufferHelper::OrderingBarrier(); |
| 4488 } | 4490 } |
| 4489 | 4491 |
| 4490 void GLES2Implementation::BindTransformFeedbackHelper( | 4492 void GLES2Implementation::BindTransformFeedbackHelper( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4515 helper_->UseProgram(program); | 4517 helper_->UseProgram(program); |
| 4516 } | 4518 } |
| 4517 } | 4519 } |
| 4518 | 4520 |
| 4519 bool GLES2Implementation::IsBufferReservedId(GLuint id) { | 4521 bool GLES2Implementation::IsBufferReservedId(GLuint id) { |
| 4520 return vertex_array_object_manager_->IsReservedId(id); | 4522 return vertex_array_object_manager_->IsReservedId(id); |
| 4521 } | 4523 } |
| 4522 | 4524 |
| 4523 void GLES2Implementation::DeleteBuffersHelper( | 4525 void GLES2Implementation::DeleteBuffersHelper( |
| 4524 GLsizei n, const GLuint* buffers) { | 4526 GLsizei n, const GLuint* buffers) { |
| 4525 if (!GetIdHandler(id_namespaces::kBuffers)->FreeIds( | 4527 if (!GetIdHandler(SharedIdNamespaces::kBuffers) |
| 4526 this, n, buffers, &GLES2Implementation::DeleteBuffersStub)) { | 4528 ->FreeIds(this, n, buffers, |
| 4529 &GLES2Implementation::DeleteBuffersStub)) { |
| 4527 SetGLError( | 4530 SetGLError( |
| 4528 GL_INVALID_VALUE, | 4531 GL_INVALID_VALUE, |
| 4529 "glDeleteBuffers", "id not created by this context."); | 4532 "glDeleteBuffers", "id not created by this context."); |
| 4530 return; | 4533 return; |
| 4531 } | 4534 } |
| 4532 for (GLsizei ii = 0; ii < n; ++ii) { | 4535 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4533 if (buffers[ii] == bound_array_buffer_) { | 4536 if (buffers[ii] == bound_array_buffer_) { |
| 4534 bound_array_buffer_ = 0; | 4537 bound_array_buffer_ = 0; |
| 4535 } | 4538 } |
| 4536 if (buffers[ii] == bound_copy_read_buffer_) { | 4539 if (buffers[ii] == bound_copy_read_buffer_) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4566 } | 4569 } |
| 4567 | 4570 |
| 4568 void GLES2Implementation::DeleteBuffersStub( | 4571 void GLES2Implementation::DeleteBuffersStub( |
| 4569 GLsizei n, const GLuint* buffers) { | 4572 GLsizei n, const GLuint* buffers) { |
| 4570 helper_->DeleteBuffersImmediate(n, buffers); | 4573 helper_->DeleteBuffersImmediate(n, buffers); |
| 4571 } | 4574 } |
| 4572 | 4575 |
| 4573 | 4576 |
| 4574 void GLES2Implementation::DeleteFramebuffersHelper( | 4577 void GLES2Implementation::DeleteFramebuffersHelper( |
| 4575 GLsizei n, const GLuint* framebuffers) { | 4578 GLsizei n, const GLuint* framebuffers) { |
| 4576 if (!GetIdHandler(id_namespaces::kFramebuffers)->FreeIds( | 4579 helper_->DeleteFramebuffersImmediate(n, framebuffers); |
| 4577 this, n, framebuffers, &GLES2Implementation::DeleteFramebuffersStub)) { | 4580 IdAllocator* id_allocator = GetIdAllocator(IdNamespaces::kFramebuffers); |
| 4578 SetGLError( | |
| 4579 GL_INVALID_VALUE, | |
| 4580 "glDeleteFramebuffers", "id not created by this context."); | |
| 4581 return; | |
| 4582 } | |
| 4583 for (GLsizei ii = 0; ii < n; ++ii) { | 4581 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4582 id_allocator->FreeID(framebuffers[ii]); |
| 4584 if (framebuffers[ii] == bound_framebuffer_) { | 4583 if (framebuffers[ii] == bound_framebuffer_) { |
| 4585 bound_framebuffer_ = 0; | 4584 bound_framebuffer_ = 0; |
| 4586 } | 4585 } |
| 4587 if (framebuffers[ii] == bound_read_framebuffer_) { | 4586 if (framebuffers[ii] == bound_read_framebuffer_) { |
| 4588 bound_read_framebuffer_ = 0; | 4587 bound_read_framebuffer_ = 0; |
| 4589 } | 4588 } |
| 4590 } | 4589 } |
| 4591 } | 4590 } |
| 4592 | 4591 |
| 4593 void GLES2Implementation::DeleteFramebuffersStub( | |
| 4594 GLsizei n, const GLuint* framebuffers) { | |
| 4595 helper_->DeleteFramebuffersImmediate(n, framebuffers); | |
| 4596 } | |
| 4597 | |
| 4598 void GLES2Implementation::DeleteRenderbuffersHelper( | 4592 void GLES2Implementation::DeleteRenderbuffersHelper( |
| 4599 GLsizei n, const GLuint* renderbuffers) { | 4593 GLsizei n, const GLuint* renderbuffers) { |
| 4600 if (!GetIdHandler(id_namespaces::kRenderbuffers)->FreeIds( | 4594 if (!GetIdHandler(SharedIdNamespaces::kRenderbuffers) |
| 4601 this, n, renderbuffers, &GLES2Implementation::DeleteRenderbuffersStub)) { | 4595 ->FreeIds(this, n, renderbuffers, |
| 4596 &GLES2Implementation::DeleteRenderbuffersStub)) { |
| 4602 SetGLError( | 4597 SetGLError( |
| 4603 GL_INVALID_VALUE, | 4598 GL_INVALID_VALUE, |
| 4604 "glDeleteRenderbuffers", "id not created by this context."); | 4599 "glDeleteRenderbuffers", "id not created by this context."); |
| 4605 return; | 4600 return; |
| 4606 } | 4601 } |
| 4607 for (GLsizei ii = 0; ii < n; ++ii) { | 4602 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4608 if (renderbuffers[ii] == bound_renderbuffer_) { | 4603 if (renderbuffers[ii] == bound_renderbuffer_) { |
| 4609 bound_renderbuffer_ = 0; | 4604 bound_renderbuffer_ = 0; |
| 4610 } | 4605 } |
| 4611 } | 4606 } |
| 4612 } | 4607 } |
| 4613 | 4608 |
| 4614 void GLES2Implementation::DeleteRenderbuffersStub( | 4609 void GLES2Implementation::DeleteRenderbuffersStub( |
| 4615 GLsizei n, const GLuint* renderbuffers) { | 4610 GLsizei n, const GLuint* renderbuffers) { |
| 4616 helper_->DeleteRenderbuffersImmediate(n, renderbuffers); | 4611 helper_->DeleteRenderbuffersImmediate(n, renderbuffers); |
| 4617 } | 4612 } |
| 4618 | 4613 |
| 4619 void GLES2Implementation::DeleteTexturesHelper( | 4614 void GLES2Implementation::DeleteTexturesHelper( |
| 4620 GLsizei n, const GLuint* textures) { | 4615 GLsizei n, const GLuint* textures) { |
| 4621 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( | 4616 if (!GetIdHandler(SharedIdNamespaces::kTextures) |
| 4622 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { | 4617 ->FreeIds(this, n, textures, |
| 4618 &GLES2Implementation::DeleteTexturesStub)) { |
| 4623 SetGLError( | 4619 SetGLError( |
| 4624 GL_INVALID_VALUE, | 4620 GL_INVALID_VALUE, |
| 4625 "glDeleteTextures", "id not created by this context."); | 4621 "glDeleteTextures", "id not created by this context."); |
| 4626 return; | 4622 return; |
| 4627 } | 4623 } |
| 4628 for (GLsizei ii = 0; ii < n; ++ii) { | 4624 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4629 for (GLint tt = 0; tt < capabilities_.max_combined_texture_image_units; | 4625 for (GLint tt = 0; tt < capabilities_.max_combined_texture_image_units; |
| 4630 ++tt) { | 4626 ++tt) { |
| 4631 TextureUnit& unit = texture_units_[tt]; | 4627 TextureUnit& unit = texture_units_[tt]; |
| 4632 if (textures[ii] == unit.bound_texture_2d) { | 4628 if (textures[ii] == unit.bound_texture_2d) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4643 } | 4639 } |
| 4644 | 4640 |
| 4645 void GLES2Implementation::DeleteTexturesStub(GLsizei n, | 4641 void GLES2Implementation::DeleteTexturesStub(GLsizei n, |
| 4646 const GLuint* textures) { | 4642 const GLuint* textures) { |
| 4647 helper_->DeleteTexturesImmediate(n, textures); | 4643 helper_->DeleteTexturesImmediate(n, textures); |
| 4648 } | 4644 } |
| 4649 | 4645 |
| 4650 void GLES2Implementation::DeleteVertexArraysOESHelper( | 4646 void GLES2Implementation::DeleteVertexArraysOESHelper( |
| 4651 GLsizei n, const GLuint* arrays) { | 4647 GLsizei n, const GLuint* arrays) { |
| 4652 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); | 4648 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); |
| 4653 if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds( | |
| 4654 this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) { | |
| 4655 SetGLError( | |
| 4656 GL_INVALID_VALUE, | |
| 4657 "glDeleteVertexArraysOES", "id not created by this context."); | |
| 4658 return; | |
| 4659 } | |
| 4660 } | |
| 4661 | |
| 4662 void GLES2Implementation::DeleteVertexArraysOESStub( | |
| 4663 GLsizei n, const GLuint* arrays) { | |
| 4664 helper_->DeleteVertexArraysOESImmediate(n, arrays); | 4649 helper_->DeleteVertexArraysOESImmediate(n, arrays); |
| 4650 IdAllocator* id_allocator = GetIdAllocator(IdNamespaces::kVertexArrays); |
| 4651 for (GLsizei ii = 0; ii < n; ++ii) |
| 4652 id_allocator->FreeID(arrays[ii]); |
| 4665 } | 4653 } |
| 4666 | 4654 |
| 4667 void GLES2Implementation::DeleteSamplersStub( | 4655 void GLES2Implementation::DeleteSamplersStub( |
| 4668 GLsizei n, const GLuint* samplers) { | 4656 GLsizei n, const GLuint* samplers) { |
| 4669 helper_->DeleteSamplersImmediate(n, samplers); | 4657 helper_->DeleteSamplersImmediate(n, samplers); |
| 4670 } | 4658 } |
| 4671 | 4659 |
| 4672 void GLES2Implementation::DeleteSamplersHelper( | 4660 void GLES2Implementation::DeleteSamplersHelper( |
| 4673 GLsizei n, const GLuint* samplers) { | 4661 GLsizei n, const GLuint* samplers) { |
| 4674 if (!GetIdHandler(id_namespaces::kSamplers)->FreeIds( | 4662 if (!GetIdHandler(SharedIdNamespaces::kSamplers) |
| 4675 this, n, samplers, &GLES2Implementation::DeleteSamplersStub)) { | 4663 ->FreeIds(this, n, samplers, |
| 4664 &GLES2Implementation::DeleteSamplersStub)) { |
| 4676 SetGLError( | 4665 SetGLError( |
| 4677 GL_INVALID_VALUE, | 4666 GL_INVALID_VALUE, |
| 4678 "glDeleteSamplers", "id not created by this context."); | 4667 "glDeleteSamplers", "id not created by this context."); |
| 4679 return; | 4668 return; |
| 4680 } | 4669 } |
| 4681 } | 4670 } |
| 4682 | 4671 |
| 4683 void GLES2Implementation::DeleteTransformFeedbacksStub( | |
| 4684 GLsizei n, const GLuint* transformfeedbacks) { | |
| 4685 helper_->DeleteTransformFeedbacksImmediate(n, transformfeedbacks); | |
| 4686 } | |
| 4687 | |
| 4688 void GLES2Implementation::DeleteTransformFeedbacksHelper( | 4672 void GLES2Implementation::DeleteTransformFeedbacksHelper( |
| 4689 GLsizei n, const GLuint* transformfeedbacks) { | 4673 GLsizei n, const GLuint* transformfeedbacks) { |
| 4690 if (!GetIdHandler(id_namespaces::kTransformFeedbacks)->FreeIds( | 4674 helper_->DeleteTransformFeedbacksImmediate(n, transformfeedbacks); |
| 4691 this, n, transformfeedbacks, | 4675 IdAllocator* id_allocator = GetIdAllocator(IdNamespaces::kTransformFeedbacks); |
| 4692 &GLES2Implementation::DeleteTransformFeedbacksStub)) { | 4676 for (GLsizei ii = 0; ii < n; ++ii) |
| 4693 SetGLError( | 4677 id_allocator->FreeID(transformfeedbacks[ii]); |
| 4694 GL_INVALID_VALUE, | |
| 4695 "glDeleteTransformFeedbacks", "id not created by this context."); | |
| 4696 return; | |
| 4697 } | |
| 4698 } | 4678 } |
| 4699 | 4679 |
| 4700 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { | 4680 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { |
| 4701 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 4681 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 4702 GPU_CLIENT_LOG( | 4682 GPU_CLIENT_LOG( |
| 4703 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); | 4683 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); |
| 4704 vertex_array_object_manager_->SetAttribEnable(index, false); | 4684 vertex_array_object_manager_->SetAttribEnable(index, false); |
| 4705 helper_->DisableVertexAttribArray(index); | 4685 helper_->DisableVertexAttribArray(index); |
| 4706 CheckGLError(); | 4686 CheckGLError(); |
| 4707 } | 4687 } |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5564 helper_->PostSubBufferCHROMIUM(x, y, width, height); | 5544 helper_->PostSubBufferCHROMIUM(x, y, width, height); |
| 5565 helper_->CommandBufferHelper::Flush(); | 5545 helper_->CommandBufferHelper::Flush(); |
| 5566 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { | 5546 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { |
| 5567 helper_->WaitForToken(swap_buffers_tokens_.front()); | 5547 helper_->WaitForToken(swap_buffers_tokens_.front()); |
| 5568 swap_buffers_tokens_.pop(); | 5548 swap_buffers_tokens_.pop(); |
| 5569 } | 5549 } |
| 5570 } | 5550 } |
| 5571 | 5551 |
| 5572 void GLES2Implementation::DeleteQueriesEXTHelper( | 5552 void GLES2Implementation::DeleteQueriesEXTHelper( |
| 5573 GLsizei n, const GLuint* queries) { | 5553 GLsizei n, const GLuint* queries) { |
| 5554 IdAllocator* id_allocator = GetIdAllocator(IdNamespaces::kQueries); |
| 5574 for (GLsizei ii = 0; ii < n; ++ii) { | 5555 for (GLsizei ii = 0; ii < n; ++ii) { |
| 5575 query_tracker_->RemoveQuery(queries[ii]); | 5556 query_tracker_->RemoveQuery(queries[ii]); |
| 5576 query_id_allocator_->FreeID(queries[ii]); | 5557 id_allocator->FreeID(queries[ii]); |
| 5577 } | 5558 } |
| 5578 | 5559 |
| 5579 helper_->DeleteQueriesEXTImmediate(n, queries); | 5560 helper_->DeleteQueriesEXTImmediate(n, queries); |
| 5580 } | 5561 } |
| 5581 | 5562 |
| 5582 GLboolean GLES2Implementation::IsQueryEXT(GLuint id) { | 5563 GLboolean GLES2Implementation::IsQueryEXT(GLuint id) { |
| 5583 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 5564 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 5584 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] IsQueryEXT(" << id << ")"); | 5565 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] IsQueryEXT(" << id << ")"); |
| 5585 | 5566 |
| 5586 // TODO(gman): To be spec compliant IDs from other contexts sharing | 5567 // TODO(gman): To be spec compliant IDs from other contexts sharing |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5649 SetGLError( | 5630 SetGLError( |
| 5650 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); | 5631 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); |
| 5651 return; | 5632 return; |
| 5652 } | 5633 } |
| 5653 | 5634 |
| 5654 if (id == 0) { | 5635 if (id == 0) { |
| 5655 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); | 5636 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); |
| 5656 return; | 5637 return; |
| 5657 } | 5638 } |
| 5658 | 5639 |
| 5659 if (!query_id_allocator_->InUse(id)) { | 5640 if (!GetIdAllocator(IdNamespaces::kQueries)->InUse(id)) { |
| 5660 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "invalid id"); | 5641 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "invalid id"); |
| 5661 return; | 5642 return; |
| 5662 } | 5643 } |
| 5663 | 5644 |
| 5664 // Extra setups some targets might need. | 5645 // Extra setups some targets might need. |
| 5665 switch (target) { | 5646 switch (target) { |
| 5666 case GL_TIME_ELAPSED_EXT: | 5647 case GL_TIME_ELAPSED_EXT: |
| 5667 if (!query_tracker_->SetDisjointSync(this)) { | 5648 if (!query_tracker_->SetDisjointSync(this)) { |
| 5668 SetGLError(GL_OUT_OF_MEMORY, | 5649 SetGLError(GL_OUT_OF_MEMORY, |
| 5669 "glBeginQueryEXT", | 5650 "glBeginQueryEXT", |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5706 SetGLError( | 5687 SetGLError( |
| 5707 GL_INVALID_ENUM, "glQueryCounterEXT", "unknown query target"); | 5688 GL_INVALID_ENUM, "glQueryCounterEXT", "unknown query target"); |
| 5708 return; | 5689 return; |
| 5709 } | 5690 } |
| 5710 | 5691 |
| 5711 if (id == 0) { | 5692 if (id == 0) { |
| 5712 SetGLError(GL_INVALID_OPERATION, "glQueryCounterEXT", "id is 0"); | 5693 SetGLError(GL_INVALID_OPERATION, "glQueryCounterEXT", "id is 0"); |
| 5713 return; | 5694 return; |
| 5714 } | 5695 } |
| 5715 | 5696 |
| 5716 if (!query_id_allocator_->InUse(id)) { | 5697 if (!GetIdAllocator(IdNamespaces::kQueries)->InUse(id)) { |
| 5717 SetGLError(GL_INVALID_OPERATION, "glQueryCounterEXT", "invalid id"); | 5698 SetGLError(GL_INVALID_OPERATION, "glQueryCounterEXT", "invalid id"); |
| 5718 return; | 5699 return; |
| 5719 } | 5700 } |
| 5720 | 5701 |
| 5721 // Extra setups some targets might need. | 5702 // Extra setups some targets might need. |
| 5722 switch (target) { | 5703 switch (target) { |
| 5723 case GL_TIMESTAMP_EXT: | 5704 case GL_TIMESTAMP_EXT: |
| 5724 if (!query_tracker_->SetDisjointSync(this)) { | 5705 if (!query_tracker_->SetDisjointSync(this)) { |
| 5725 SetGLError(GL_OUT_OF_MEMORY, | 5706 SetGLError(GL_OUT_OF_MEMORY, |
| 5726 "glQueryCounterEXT", | 5707 "glQueryCounterEXT", |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5930 GLuint GLES2Implementation::CreateAndConsumeTextureCHROMIUM( | 5911 GLuint GLES2Implementation::CreateAndConsumeTextureCHROMIUM( |
| 5931 GLenum target, const GLbyte* data) { | 5912 GLenum target, const GLbyte* data) { |
| 5932 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 5913 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 5933 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateAndConsumeTextureCHROMIUM(" | 5914 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateAndConsumeTextureCHROMIUM(" |
| 5934 << static_cast<const void*>(data) << ")"); | 5915 << static_cast<const void*>(data) << ")"); |
| 5935 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 5916 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
| 5936 DCHECK(mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was passed a " | 5917 DCHECK(mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was passed a " |
| 5937 "mailbox that was not generated by " | 5918 "mailbox that was not generated by " |
| 5938 "GenMailboxCHROMIUM."; | 5919 "GenMailboxCHROMIUM."; |
| 5939 GLuint client_id; | 5920 GLuint client_id; |
| 5940 GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &client_id); | 5921 GetIdHandler(SharedIdNamespaces::kTextures)->MakeIds(this, 0, 1, &client_id); |
| 5941 helper_->CreateAndConsumeTextureINTERNALImmediate(target, | 5922 helper_->CreateAndConsumeTextureINTERNALImmediate(target, |
| 5942 client_id, data); | 5923 client_id, data); |
| 5943 if (share_group_->bind_generates_resource()) | 5924 if (share_group_->bind_generates_resource()) |
| 5944 helper_->CommandBufferHelper::Flush(); | 5925 helper_->CommandBufferHelper::Flush(); |
| 5945 CheckGLError(); | 5926 CheckGLError(); |
| 5946 return client_id; | 5927 return client_id; |
| 5947 } | 5928 } |
| 5948 | 5929 |
| 5949 void GLES2Implementation::PushGroupMarkerEXT( | 5930 void GLES2Implementation::PushGroupMarkerEXT( |
| 5950 GLsizei length, const GLchar* marker) { | 5931 GLsizei length, const GLchar* marker) { |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7077 CheckGLError(); | 7058 CheckGLError(); |
| 7078 } | 7059 } |
| 7079 | 7060 |
| 7080 // Include the auto-generated part of this file. We split this because it means | 7061 // Include the auto-generated part of this file. We split this because it means |
| 7081 // we can easily edit the non-auto generated parts right here in this file | 7062 // we can easily edit the non-auto generated parts right here in this file |
| 7082 // instead of having to edit some template or the code generator. | 7063 // instead of having to edit some template or the code generator. |
| 7083 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7064 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 7084 | 7065 |
| 7085 } // namespace gles2 | 7066 } // namespace gles2 |
| 7086 } // namespace gpu | 7067 } // namespace gpu |
| OLD | NEW |