| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1613 |
| 1614 GLES2Decoder* GLES2Decoder::Create(SurfaceManager* surface_manager, | 1614 GLES2Decoder* GLES2Decoder::Create(SurfaceManager* surface_manager, |
| 1615 ContextGroup* group) { | 1615 ContextGroup* group) { |
| 1616 return new GLES2DecoderImpl(surface_manager, group); | 1616 return new GLES2DecoderImpl(surface_manager, group); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 GLES2DecoderImpl::GLES2DecoderImpl(SurfaceManager* surface_manager, | 1619 GLES2DecoderImpl::GLES2DecoderImpl(SurfaceManager* surface_manager, |
| 1620 ContextGroup* group) | 1620 ContextGroup* group) |
| 1621 : GLES2Decoder(), | 1621 : GLES2Decoder(), |
| 1622 surface_manager_(surface_manager), | 1622 surface_manager_(surface_manager), |
| 1623 group_(ContextGroup::Ref(group ? group : new ContextGroup())), | 1623 group_(group), |
| 1624 error_bits_(0), | 1624 error_bits_(0), |
| 1625 pack_alignment_(4), | 1625 pack_alignment_(4), |
| 1626 unpack_alignment_(4), | 1626 unpack_alignment_(4), |
| 1627 attrib_0_buffer_id_(0), | 1627 attrib_0_buffer_id_(0), |
| 1628 attrib_0_buffer_matches_value_(true), | 1628 attrib_0_buffer_matches_value_(true), |
| 1629 attrib_0_size_(0), | 1629 attrib_0_size_(0), |
| 1630 fixed_attrib_buffer_id_(0), | 1630 fixed_attrib_buffer_id_(0), |
| 1631 fixed_attrib_buffer_size_(0), | 1631 fixed_attrib_buffer_size_(0), |
| 1632 active_texture_unit_(0), | 1632 active_texture_unit_(0), |
| 1633 clear_red_(0), | 1633 clear_red_(0), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1659 teximage2d_faster_than_texsubimage2d_(true), | 1659 teximage2d_faster_than_texsubimage2d_(true), |
| 1660 bufferdata_faster_than_buffersubdata_(true), | 1660 bufferdata_faster_than_buffersubdata_(true), |
| 1661 current_decoder_error_(error::kNoError), | 1661 current_decoder_error_(error::kNoError), |
| 1662 use_shader_translator_(true), | 1662 use_shader_translator_(true), |
| 1663 validators_(group_->feature_info()->validators()), | 1663 validators_(group_->feature_info()->validators()), |
| 1664 feature_info_(group_->feature_info()), | 1664 feature_info_(group_->feature_info()), |
| 1665 tex_image_2d_failed_(false), | 1665 tex_image_2d_failed_(false), |
| 1666 frame_number_(0), | 1666 frame_number_(0), |
| 1667 has_arb_robustness_(false), | 1667 has_arb_robustness_(false), |
| 1668 reset_status_(GL_NO_ERROR) { | 1668 reset_status_(GL_NO_ERROR) { |
| 1669 DCHECK(group); |
| 1670 |
| 1669 attrib_0_value_.v[0] = 0.0f; | 1671 attrib_0_value_.v[0] = 0.0f; |
| 1670 attrib_0_value_.v[1] = 0.0f; | 1672 attrib_0_value_.v[1] = 0.0f; |
| 1671 attrib_0_value_.v[2] = 0.0f; | 1673 attrib_0_value_.v[2] = 0.0f; |
| 1672 attrib_0_value_.v[3] = 1.0f; | 1674 attrib_0_value_.v[3] = 1.0f; |
| 1673 | 1675 |
| 1674 // The shader translator is used for WebGL even when running on EGL | 1676 // The shader translator is used for WebGL even when running on EGL |
| 1675 // because additional restrictions are needed (like only enabling | 1677 // because additional restrictions are needed (like only enabling |
| 1676 // GL_OES_standard_derivatives on demand). It is used for the unit | 1678 // GL_OES_standard_derivatives on demand). It is used for the unit |
| 1677 // tests because | 1679 // tests because |
| 1678 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the | 1680 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { | 2675 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { |
| 2674 BufferManager::BufferInfo* info = NULL; | 2676 BufferManager::BufferInfo* info = NULL; |
| 2675 GLuint service_id = 0; | 2677 GLuint service_id = 0; |
| 2676 if (client_id != 0) { | 2678 if (client_id != 0) { |
| 2677 info = GetBufferInfo(client_id); | 2679 info = GetBufferInfo(client_id); |
| 2678 if (!info) { | 2680 if (!info) { |
| 2679 // It's a new id so make a buffer info for it. | 2681 // It's a new id so make a buffer info for it. |
| 2680 glGenBuffersARB(1, &service_id); | 2682 glGenBuffersARB(1, &service_id); |
| 2681 CreateBufferInfo(client_id, service_id); | 2683 CreateBufferInfo(client_id, service_id); |
| 2682 info = GetBufferInfo(client_id); | 2684 info = GetBufferInfo(client_id); |
| 2683 IdAllocator* id_allocator = | 2685 IdAllocatorInterface* id_allocator = |
| 2684 group_->GetIdAllocator(id_namespaces::kBuffers); | 2686 group_->GetIdAllocator(id_namespaces::kBuffers); |
| 2685 id_allocator->MarkAsUsed(client_id); | 2687 id_allocator->MarkAsUsed(client_id); |
| 2686 } | 2688 } |
| 2687 } | 2689 } |
| 2688 if (info) { | 2690 if (info) { |
| 2689 if (!buffer_manager()->SetTarget(info, target)) { | 2691 if (!buffer_manager()->SetTarget(info, target)) { |
| 2690 SetGLError(GL_INVALID_OPERATION, | 2692 SetGLError(GL_INVALID_OPERATION, |
| 2691 "glBindBuffer: buffer bound to more than 1 target"); | 2693 "glBindBuffer: buffer bound to more than 1 target"); |
| 2692 return; | 2694 return; |
| 2693 } | 2695 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2752 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 2754 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
| 2753 FramebufferManager::FramebufferInfo* info = NULL; | 2755 FramebufferManager::FramebufferInfo* info = NULL; |
| 2754 GLuint service_id = 0; | 2756 GLuint service_id = 0; |
| 2755 if (client_id != 0) { | 2757 if (client_id != 0) { |
| 2756 info = GetFramebufferInfo(client_id); | 2758 info = GetFramebufferInfo(client_id); |
| 2757 if (!info) { | 2759 if (!info) { |
| 2758 // It's a new id so make a framebuffer info for it. | 2760 // It's a new id so make a framebuffer info for it. |
| 2759 glGenFramebuffersEXT(1, &service_id); | 2761 glGenFramebuffersEXT(1, &service_id); |
| 2760 CreateFramebufferInfo(client_id, service_id); | 2762 CreateFramebufferInfo(client_id, service_id); |
| 2761 info = GetFramebufferInfo(client_id); | 2763 info = GetFramebufferInfo(client_id); |
| 2762 IdAllocator* id_allocator = | 2764 IdAllocatorInterface* id_allocator = |
| 2763 group_->GetIdAllocator(id_namespaces::kFramebuffers); | 2765 group_->GetIdAllocator(id_namespaces::kFramebuffers); |
| 2764 id_allocator->MarkAsUsed(client_id); | 2766 id_allocator->MarkAsUsed(client_id); |
| 2765 } else { | 2767 } else { |
| 2766 service_id = info->service_id(); | 2768 service_id = info->service_id(); |
| 2767 } | 2769 } |
| 2768 info->MarkAsValid(); | 2770 info->MarkAsValid(); |
| 2769 } else { | 2771 } else { |
| 2770 service_id = surface_->GetBackingFrameBufferObject(); | 2772 service_id = surface_->GetBackingFrameBufferObject(); |
| 2771 } | 2773 } |
| 2772 | 2774 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2791 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 2793 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
| 2792 RenderbufferManager::RenderbufferInfo* info = NULL; | 2794 RenderbufferManager::RenderbufferInfo* info = NULL; |
| 2793 GLuint service_id = 0; | 2795 GLuint service_id = 0; |
| 2794 if (client_id != 0) { | 2796 if (client_id != 0) { |
| 2795 info = GetRenderbufferInfo(client_id); | 2797 info = GetRenderbufferInfo(client_id); |
| 2796 if (!info) { | 2798 if (!info) { |
| 2797 // It's a new id so make a renderbuffer info for it. | 2799 // It's a new id so make a renderbuffer info for it. |
| 2798 glGenRenderbuffersEXT(1, &service_id); | 2800 glGenRenderbuffersEXT(1, &service_id); |
| 2799 CreateRenderbufferInfo(client_id, service_id); | 2801 CreateRenderbufferInfo(client_id, service_id); |
| 2800 info = GetRenderbufferInfo(client_id); | 2802 info = GetRenderbufferInfo(client_id); |
| 2801 IdAllocator* id_allocator = | 2803 IdAllocatorInterface* id_allocator = |
| 2802 group_->GetIdAllocator(id_namespaces::kRenderbuffers); | 2804 group_->GetIdAllocator(id_namespaces::kRenderbuffers); |
| 2803 id_allocator->MarkAsUsed(client_id); | 2805 id_allocator->MarkAsUsed(client_id); |
| 2804 } else { | 2806 } else { |
| 2805 service_id = info->service_id(); | 2807 service_id = info->service_id(); |
| 2806 } | 2808 } |
| 2807 info->MarkAsValid(); | 2809 info->MarkAsValid(); |
| 2808 } | 2810 } |
| 2809 bound_renderbuffer_ = info; | 2811 bound_renderbuffer_ = info; |
| 2810 glBindRenderbufferEXT(target, service_id); | 2812 glBindRenderbufferEXT(target, service_id); |
| 2811 } | 2813 } |
| 2812 | 2814 |
| 2813 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { | 2815 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { |
| 2814 TextureManager::TextureInfo* info = NULL; | 2816 TextureManager::TextureInfo* info = NULL; |
| 2815 GLuint service_id = 0; | 2817 GLuint service_id = 0; |
| 2816 if (client_id != 0) { | 2818 if (client_id != 0) { |
| 2817 info = GetTextureInfo(client_id); | 2819 info = GetTextureInfo(client_id); |
| 2818 if (!info) { | 2820 if (!info) { |
| 2819 // It's a new id so make a texture info for it. | 2821 // It's a new id so make a texture info for it. |
| 2820 glGenTextures(1, &service_id); | 2822 glGenTextures(1, &service_id); |
| 2821 CreateTextureInfo(client_id, service_id); | 2823 CreateTextureInfo(client_id, service_id); |
| 2822 info = GetTextureInfo(client_id); | 2824 info = GetTextureInfo(client_id); |
| 2823 IdAllocator* id_allocator = | 2825 IdAllocatorInterface* id_allocator = |
| 2824 group_->GetIdAllocator(id_namespaces::kTextures); | 2826 group_->GetIdAllocator(id_namespaces::kTextures); |
| 2825 id_allocator->MarkAsUsed(client_id); | 2827 id_allocator->MarkAsUsed(client_id); |
| 2826 } | 2828 } |
| 2827 } else { | 2829 } else { |
| 2828 info = texture_manager()->GetDefaultTextureInfo(target); | 2830 info = texture_manager()->GetDefaultTextureInfo(target); |
| 2829 } | 2831 } |
| 2830 | 2832 |
| 2831 // Check the texture exists | 2833 // Check the texture exists |
| 2832 // Check that we are not trying to bind it to a different target. | 2834 // Check that we are not trying to bind it to a different target. |
| 2833 if (info->target() != 0 && info->target() != target) { | 2835 if (info->target() != 0 && info->target() != target) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3306 } | 3308 } |
| 3307 } else { | 3309 } else { |
| 3308 SetGLError(GL_INVALID_VALUE, "glDeleteProgram: unknown program"); | 3310 SetGLError(GL_INVALID_VALUE, "glDeleteProgram: unknown program"); |
| 3309 } | 3311 } |
| 3310 } | 3312 } |
| 3311 return error::kNoError; | 3313 return error::kNoError; |
| 3312 } | 3314 } |
| 3313 | 3315 |
| 3314 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM( | 3316 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM( |
| 3315 GLuint namespace_id, GLsizei n, const GLuint* ids) { | 3317 GLuint namespace_id, GLsizei n, const GLuint* ids) { |
| 3316 IdAllocator* id_allocator = group_->GetIdAllocator(namespace_id); | 3318 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); |
| 3317 for (GLsizei ii = 0; ii < n; ++ii) { | 3319 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3318 id_allocator->FreeID(ids[ii]); | 3320 id_allocator->FreeID(ids[ii]); |
| 3319 } | 3321 } |
| 3320 } | 3322 } |
| 3321 | 3323 |
| 3322 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM( | 3324 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM( |
| 3323 uint32 immediate_data_size, const gles2::DeleteSharedIdsCHROMIUM& c) { | 3325 uint32 immediate_data_size, const gles2::DeleteSharedIdsCHROMIUM& c) { |
| 3324 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); | 3326 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); |
| 3325 GLsizei n = static_cast<GLsizei>(c.n); | 3327 GLsizei n = static_cast<GLsizei>(c.n); |
| 3326 uint32 data_size; | 3328 uint32 data_size; |
| 3327 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { | 3329 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { |
| 3328 return error::kOutOfBounds; | 3330 return error::kOutOfBounds; |
| 3329 } | 3331 } |
| 3330 const GLuint* ids = GetSharedMemoryAs<const GLuint*>( | 3332 const GLuint* ids = GetSharedMemoryAs<const GLuint*>( |
| 3331 c.ids_shm_id, c.ids_shm_offset, data_size); | 3333 c.ids_shm_id, c.ids_shm_offset, data_size); |
| 3332 if (n < 0) { | 3334 if (n < 0) { |
| 3333 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM: n < 0"); | 3335 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM: n < 0"); |
| 3334 return error::kNoError; | 3336 return error::kNoError; |
| 3335 } | 3337 } |
| 3336 if (ids == NULL) { | 3338 if (ids == NULL) { |
| 3337 return error::kOutOfBounds; | 3339 return error::kOutOfBounds; |
| 3338 } | 3340 } |
| 3339 DoDeleteSharedIdsCHROMIUM(namespace_id, n, ids); | 3341 DoDeleteSharedIdsCHROMIUM(namespace_id, n, ids); |
| 3340 return error::kNoError; | 3342 return error::kNoError; |
| 3341 } | 3343 } |
| 3342 | 3344 |
| 3343 void GLES2DecoderImpl::DoGenSharedIdsCHROMIUM( | 3345 void GLES2DecoderImpl::DoGenSharedIdsCHROMIUM( |
| 3344 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { | 3346 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { |
| 3345 IdAllocator* id_allocator = group_->GetIdAllocator(namespace_id); | 3347 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); |
| 3346 if (id_offset == 0) { | 3348 if (id_offset == 0) { |
| 3347 for (GLsizei ii = 0; ii < n; ++ii) { | 3349 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3348 ids[ii] = id_allocator->AllocateID(); | 3350 ids[ii] = id_allocator->AllocateID(); |
| 3349 } | 3351 } |
| 3350 } else { | 3352 } else { |
| 3351 for (GLsizei ii = 0; ii < n; ++ii) { | 3353 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3352 ids[ii] = id_allocator->AllocateIDAtOrAbove(id_offset); | 3354 ids[ii] = id_allocator->AllocateIDAtOrAbove(id_offset); |
| 3353 id_offset = ids[ii] + 1; | 3355 id_offset = ids[ii] + 1; |
| 3354 } | 3356 } |
| 3355 } | 3357 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3372 } | 3374 } |
| 3373 if (ids == NULL) { | 3375 if (ids == NULL) { |
| 3374 return error::kOutOfBounds; | 3376 return error::kOutOfBounds; |
| 3375 } | 3377 } |
| 3376 DoGenSharedIdsCHROMIUM(namespace_id, id_offset, n, ids); | 3378 DoGenSharedIdsCHROMIUM(namespace_id, id_offset, n, ids); |
| 3377 return error::kNoError; | 3379 return error::kNoError; |
| 3378 } | 3380 } |
| 3379 | 3381 |
| 3380 void GLES2DecoderImpl::DoRegisterSharedIdsCHROMIUM( | 3382 void GLES2DecoderImpl::DoRegisterSharedIdsCHROMIUM( |
| 3381 GLuint namespace_id, GLsizei n, const GLuint* ids) { | 3383 GLuint namespace_id, GLsizei n, const GLuint* ids) { |
| 3382 IdAllocator* id_allocator = group_->GetIdAllocator(namespace_id); | 3384 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); |
| 3383 for (GLsizei ii = 0; ii < n; ++ii) { | 3385 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3384 if (!id_allocator->MarkAsUsed(ids[ii])) { | 3386 if (!id_allocator->MarkAsUsed(ids[ii])) { |
| 3385 for (GLsizei jj = 0; jj < ii; ++jj) { | 3387 for (GLsizei jj = 0; jj < ii; ++jj) { |
| 3386 id_allocator->FreeID(ids[jj]); | 3388 id_allocator->FreeID(ids[jj]); |
| 3387 } | 3389 } |
| 3388 SetGLError( | 3390 SetGLError( |
| 3389 GL_INVALID_VALUE, | 3391 GL_INVALID_VALUE, |
| 3390 "RegisterSharedIdsCHROMIUM: attempt to register " | 3392 "RegisterSharedIdsCHROMIUM: attempt to register " |
| 3391 "id that already exists"); | 3393 "id that already exists"); |
| 3392 return; | 3394 return; |
| (...skipping 3399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6792 return false; | 6794 return false; |
| 6793 } | 6795 } |
| 6794 | 6796 |
| 6795 // Include the auto-generated part of this file. We split this because it means | 6797 // Include the auto-generated part of this file. We split this because it means |
| 6796 // we can easily edit the non-auto generated parts right here in this file | 6798 // we can easily edit the non-auto generated parts right here in this file |
| 6797 // instead of having to edit some template or the code generator. | 6799 // instead of having to edit some template or the code generator. |
| 6798 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6800 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6799 | 6801 |
| 6800 } // namespace gles2 | 6802 } // namespace gles2 |
| 6801 } // namespace gpu | 6803 } // namespace gpu |
| OLD | NEW |