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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2665 active_texture_unit_ = texture_index; | 2665 active_texture_unit_ = texture_index; |
2666 glActiveTexture(texture_unit); | 2666 glActiveTexture(texture_unit); |
2667 } | 2667 } |
2668 | 2668 |
2669 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { | 2669 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { |
2670 BufferManager::BufferInfo* info = NULL; | 2670 BufferManager::BufferInfo* info = NULL; |
2671 GLuint service_id = 0; | 2671 GLuint service_id = 0; |
2672 if (client_id != 0) { | 2672 if (client_id != 0) { |
2673 info = GetBufferInfo(client_id); | 2673 info = GetBufferInfo(client_id); |
2674 if (!info) { | 2674 if (!info) { |
2675 if (!group_->bind_generates_resource()) { | |
2676 SetGLError(GL_INVALID_VALUE, | |
2677 "glBindBuffer: id not generated by glGenBuffers"); | |
2678 return; | |
2679 } | |
2680 | |
2681 // It's a new id so make a buffer info for it. | 2675 // It's a new id so make a buffer info for it. |
2682 glGenBuffersARB(1, &service_id); | 2676 glGenBuffersARB(1, &service_id); |
2683 CreateBufferInfo(client_id, service_id); | 2677 CreateBufferInfo(client_id, service_id); |
2684 info = GetBufferInfo(client_id); | 2678 info = GetBufferInfo(client_id); |
2685 IdAllocatorInterface* id_allocator = | 2679 IdAllocatorInterface* id_allocator = |
2686 group_->GetIdAllocator(id_namespaces::kBuffers); | 2680 group_->GetIdAllocator(id_namespaces::kBuffers); |
2687 id_allocator->MarkAsUsed(client_id); | 2681 id_allocator->MarkAsUsed(client_id); |
2688 } | 2682 } |
2689 } | 2683 } |
2690 if (info) { | 2684 if (info) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 state_dirty_ = false; | 2744 state_dirty_ = false; |
2751 } | 2745 } |
2752 } | 2746 } |
2753 | 2747 |
2754 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 2748 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
2755 FramebufferManager::FramebufferInfo* info = NULL; | 2749 FramebufferManager::FramebufferInfo* info = NULL; |
2756 GLuint service_id = 0; | 2750 GLuint service_id = 0; |
2757 if (client_id != 0) { | 2751 if (client_id != 0) { |
2758 info = GetFramebufferInfo(client_id); | 2752 info = GetFramebufferInfo(client_id); |
2759 if (!info) { | 2753 if (!info) { |
2760 if (!group_->bind_generates_resource()) { | |
2761 SetGLError(GL_INVALID_VALUE, | |
2762 "glBindFramebuffer: id not generated by glGenFramebuffers"); | |
2763 return; | |
2764 } | |
2765 | |
2766 // It's a new id so make a framebuffer info for it. | 2754 // It's a new id so make a framebuffer info for it. |
2767 glGenFramebuffersEXT(1, &service_id); | 2755 glGenFramebuffersEXT(1, &service_id); |
2768 CreateFramebufferInfo(client_id, service_id); | 2756 CreateFramebufferInfo(client_id, service_id); |
2769 info = GetFramebufferInfo(client_id); | 2757 info = GetFramebufferInfo(client_id); |
2770 IdAllocatorInterface* id_allocator = | 2758 IdAllocatorInterface* id_allocator = |
2771 group_->GetIdAllocator(id_namespaces::kFramebuffers); | 2759 group_->GetIdAllocator(id_namespaces::kFramebuffers); |
2772 id_allocator->MarkAsUsed(client_id); | 2760 id_allocator->MarkAsUsed(client_id); |
2773 } else { | 2761 } else { |
2774 service_id = info->service_id(); | 2762 service_id = info->service_id(); |
2775 } | 2763 } |
(...skipping 19 matching lines...) Expand all Loading... |
2795 | 2783 |
2796 glBindFramebufferEXT(target, service_id); | 2784 glBindFramebufferEXT(target, service_id); |
2797 } | 2785 } |
2798 | 2786 |
2799 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 2787 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
2800 RenderbufferManager::RenderbufferInfo* info = NULL; | 2788 RenderbufferManager::RenderbufferInfo* info = NULL; |
2801 GLuint service_id = 0; | 2789 GLuint service_id = 0; |
2802 if (client_id != 0) { | 2790 if (client_id != 0) { |
2803 info = GetRenderbufferInfo(client_id); | 2791 info = GetRenderbufferInfo(client_id); |
2804 if (!info) { | 2792 if (!info) { |
2805 if (!group_->bind_generates_resource()) { | |
2806 SetGLError( | |
2807 GL_INVALID_VALUE, | |
2808 "glBindRenderbuffer: id not generated by glGenRenderbuffers"); | |
2809 return; | |
2810 } | |
2811 | |
2812 // It's a new id so make a renderbuffer info for it. | 2793 // It's a new id so make a renderbuffer info for it. |
2813 glGenRenderbuffersEXT(1, &service_id); | 2794 glGenRenderbuffersEXT(1, &service_id); |
2814 CreateRenderbufferInfo(client_id, service_id); | 2795 CreateRenderbufferInfo(client_id, service_id); |
2815 info = GetRenderbufferInfo(client_id); | 2796 info = GetRenderbufferInfo(client_id); |
2816 IdAllocatorInterface* id_allocator = | 2797 IdAllocatorInterface* id_allocator = |
2817 group_->GetIdAllocator(id_namespaces::kRenderbuffers); | 2798 group_->GetIdAllocator(id_namespaces::kRenderbuffers); |
2818 id_allocator->MarkAsUsed(client_id); | 2799 id_allocator->MarkAsUsed(client_id); |
2819 } else { | 2800 } else { |
2820 service_id = info->service_id(); | 2801 service_id = info->service_id(); |
2821 } | 2802 } |
2822 info->MarkAsValid(); | 2803 info->MarkAsValid(); |
2823 } | 2804 } |
2824 bound_renderbuffer_ = info; | 2805 bound_renderbuffer_ = info; |
2825 glBindRenderbufferEXT(target, service_id); | 2806 glBindRenderbufferEXT(target, service_id); |
2826 } | 2807 } |
2827 | 2808 |
2828 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { | 2809 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { |
2829 TextureManager::TextureInfo* info = NULL; | 2810 TextureManager::TextureInfo* info = NULL; |
2830 GLuint service_id = 0; | 2811 GLuint service_id = 0; |
2831 if (client_id != 0) { | 2812 if (client_id != 0) { |
2832 info = GetTextureInfo(client_id); | 2813 info = GetTextureInfo(client_id); |
2833 if (!info) { | 2814 if (!info) { |
2834 if (!group_->bind_generates_resource()) { | |
2835 SetGLError(GL_INVALID_VALUE, | |
2836 "glBindTexture: id not generated by glGenTextures"); | |
2837 return; | |
2838 } | |
2839 | |
2840 // It's a new id so make a texture info for it. | 2815 // It's a new id so make a texture info for it. |
2841 glGenTextures(1, &service_id); | 2816 glGenTextures(1, &service_id); |
2842 CreateTextureInfo(client_id, service_id); | 2817 CreateTextureInfo(client_id, service_id); |
2843 info = GetTextureInfo(client_id); | 2818 info = GetTextureInfo(client_id); |
2844 IdAllocatorInterface* id_allocator = | 2819 IdAllocatorInterface* id_allocator = |
2845 group_->GetIdAllocator(id_namespaces::kTextures); | 2820 group_->GetIdAllocator(id_namespaces::kTextures); |
2846 id_allocator->MarkAsUsed(client_id); | 2821 id_allocator->MarkAsUsed(client_id); |
2847 } | 2822 } |
2848 } else { | 2823 } else { |
2849 info = texture_manager()->GetDefaultTextureInfo(target); | 2824 info = texture_manager()->GetDefaultTextureInfo(target); |
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4677 } | 4652 } |
4678 | 4653 |
4679 error::Error GLES2DecoderImpl::HandleGetProgramInfoLog( | 4654 error::Error GLES2DecoderImpl::HandleGetProgramInfoLog( |
4680 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) { | 4655 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) { |
4681 GLuint program = c.program; | 4656 GLuint program = c.program; |
4682 uint32 bucket_id = static_cast<uint32>(c.bucket_id); | 4657 uint32 bucket_id = static_cast<uint32>(c.bucket_id); |
4683 Bucket* bucket = CreateBucket(bucket_id); | 4658 Bucket* bucket = CreateBucket(bucket_id); |
4684 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 4659 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
4685 program, "glGetProgramInfoLog"); | 4660 program, "glGetProgramInfoLog"); |
4686 if (!info || !info->log_info()) { | 4661 if (!info || !info->log_info()) { |
4687 bucket->SetFromString(""); | 4662 bucket->SetSize(0); |
4688 return error::kNoError; | 4663 return error::kNoError; |
4689 } | 4664 } |
4690 bucket->SetFromString(info->log_info()->c_str()); | 4665 bucket->SetFromString(info->log_info()->c_str()); |
4691 return error::kNoError; | 4666 return error::kNoError; |
4692 } | 4667 } |
4693 | 4668 |
4694 error::Error GLES2DecoderImpl::HandleGetShaderInfoLog( | 4669 error::Error GLES2DecoderImpl::HandleGetShaderInfoLog( |
4695 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) { | 4670 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) { |
4696 GLuint shader = c.shader; | 4671 GLuint shader = c.shader; |
4697 uint32 bucket_id = static_cast<uint32>(c.bucket_id); | 4672 uint32 bucket_id = static_cast<uint32>(c.bucket_id); |
4698 Bucket* bucket = CreateBucket(bucket_id); | 4673 Bucket* bucket = CreateBucket(bucket_id); |
4699 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 4674 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
4700 shader, "glGetShaderInfoLog"); | 4675 shader, "glGetShaderInfoLog"); |
4701 if (!info || !info->log_info()) { | 4676 if (!info || !info->log_info()) { |
4702 bucket->SetFromString(""); | 4677 bucket->SetSize(0); |
4703 return error::kNoError; | 4678 return error::kNoError; |
4704 } | 4679 } |
4705 bucket->SetFromString(info->log_info()->c_str()); | 4680 bucket->SetFromString(info->log_info()->c_str()); |
4706 return error::kNoError; | 4681 return error::kNoError; |
4707 } | 4682 } |
4708 | 4683 |
4709 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { | 4684 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { |
4710 const BufferManager::BufferInfo* info = GetBufferInfo(client_id); | 4685 const BufferManager::BufferInfo* info = GetBufferInfo(client_id); |
4711 return info && info->IsValid(); | 4686 return info && info->IsValid(); |
4712 } | 4687 } |
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6742 return error::kNoError; | 6717 return error::kNoError; |
6743 } | 6718 } |
6744 | 6719 |
6745 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM( | 6720 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM( |
6746 uint32 immediate_data_size, const gles2::GetProgramInfoCHROMIUM& c) { | 6721 uint32 immediate_data_size, const gles2::GetProgramInfoCHROMIUM& c) { |
6747 GLuint program = static_cast<GLuint>(c.program); | 6722 GLuint program = static_cast<GLuint>(c.program); |
6748 uint32 bucket_id = c.bucket_id; | 6723 uint32 bucket_id = c.bucket_id; |
6749 Bucket* bucket = CreateBucket(bucket_id); | 6724 Bucket* bucket = CreateBucket(bucket_id); |
6750 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. | 6725 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. |
6751 ProgramManager::ProgramInfo* info = NULL; | 6726 ProgramManager::ProgramInfo* info = NULL; |
6752 info = GetProgramInfo(program); | 6727 if (program) { |
6753 if (!info || !info->IsValid()) { | 6728 info = GetProgramInfoNotShader(program, "glGetProgramInfoCHROMIUM"); |
6754 return error::kNoError; | 6729 if (!info) { |
| 6730 return error::kNoError; |
| 6731 } |
| 6732 if (!info->IsValid()) { |
| 6733 // Program was not linked successfully. (ie, glLinkProgram) |
| 6734 SetGLError(GL_INVALID_OPERATION, |
| 6735 "glGetProgramInfoCHROMIUM: program not linked"); |
| 6736 return error::kNoError; |
| 6737 } |
6755 } | 6738 } |
6756 info->GetProgramInfo(bucket); | 6739 info->GetProgramInfo(bucket); |
6757 return error::kNoError; | 6740 return error::kNoError; |
6758 } | 6741 } |
6759 | 6742 |
6760 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { | 6743 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { |
6761 switch (reset_status_) { | 6744 switch (reset_status_) { |
6762 case GL_NO_ERROR: | 6745 case GL_NO_ERROR: |
6763 // TODO(kbr): improve the precision of the error code in this case. | 6746 // TODO(kbr): improve the precision of the error code in this case. |
6764 // Consider delegating to context for error code if MakeCurrent fails. | 6747 // Consider delegating to context for error code if MakeCurrent fails. |
(...skipping 25 matching lines...) Expand all Loading... |
6790 return false; | 6773 return false; |
6791 } | 6774 } |
6792 | 6775 |
6793 // Include the auto-generated part of this file. We split this because it means | 6776 // Include the auto-generated part of this file. We split this because it means |
6794 // we can easily edit the non-auto generated parts right here in this file | 6777 // we can easily edit the non-auto generated parts right here in this file |
6795 // instead of having to edit some template or the code generator. | 6778 // instead of having to edit some template or the code generator. |
6796 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6779 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6797 | 6780 |
6798 } // namespace gles2 | 6781 } // namespace gles2 |
6799 } // namespace gpu | 6782 } // namespace gpu |
OLD | NEW |