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