Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

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

Powered by Google App Engine
This is Rietveld 408576698