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

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

Issue 154263011: Reduce cost of glBind* on contexts without bind_generates_resource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated gpu_unittest to match new error semantics. Created 6 years, 10 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
OLDNEW
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 #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 3619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 glActiveTexture(texture_unit); 3630 glActiveTexture(texture_unit);
3631 } 3631 }
3632 3632
3633 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { 3633 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
3634 Buffer* buffer = NULL; 3634 Buffer* buffer = NULL;
3635 GLuint service_id = 0; 3635 GLuint service_id = 0;
3636 if (client_id != 0) { 3636 if (client_id != 0) {
3637 buffer = GetBuffer(client_id); 3637 buffer = GetBuffer(client_id);
3638 if (!buffer) { 3638 if (!buffer) {
3639 if (!group_->bind_generates_resource()) { 3639 if (!group_->bind_generates_resource()) {
3640 LOG(ERROR) << "glBindBuffer: id not generated by glGenBuffers"; 3640 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3641 current_decoder_error_ = error::kGenericError; 3641 "glBindBuffer",
3642 "id not generated by glGenBuffers");
3642 return; 3643 return;
3643 } 3644 }
3644 3645
3645 // It's a new id so make a buffer buffer for it. 3646 // It's a new id so make a buffer buffer for it.
3646 glGenBuffersARB(1, &service_id); 3647 glGenBuffersARB(1, &service_id);
3647 CreateBuffer(client_id, service_id); 3648 CreateBuffer(client_id, service_id);
3648 buffer = GetBuffer(client_id); 3649 buffer = GetBuffer(client_id);
3649 IdAllocatorInterface* id_allocator = 3650 IdAllocatorInterface* id_allocator =
3650 group_->GetIdAllocator(id_namespaces::kBuffers); 3651 group_->GetIdAllocator(id_namespaces::kBuffers);
3651 id_allocator->MarkAsUsed(client_id); 3652 id_allocator->MarkAsUsed(client_id);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 } 3806 }
3806 } 3807 }
3807 3808
3808 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { 3809 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
3809 Framebuffer* framebuffer = NULL; 3810 Framebuffer* framebuffer = NULL;
3810 GLuint service_id = 0; 3811 GLuint service_id = 0;
3811 if (client_id != 0) { 3812 if (client_id != 0) {
3812 framebuffer = GetFramebuffer(client_id); 3813 framebuffer = GetFramebuffer(client_id);
3813 if (!framebuffer) { 3814 if (!framebuffer) {
3814 if (!group_->bind_generates_resource()) { 3815 if (!group_->bind_generates_resource()) {
3815 LOG(ERROR) 3816 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3816 << "glBindFramebuffer: id not generated by glGenFramebuffers"; 3817 "glBindFramebuffer",
3817 current_decoder_error_ = error::kGenericError; 3818 "id not generated by glGenFramebuffers");
3818 return; 3819 return;
3819 } 3820 }
3820 3821
3821 // It's a new id so make a framebuffer framebuffer for it. 3822 // It's a new id so make a framebuffer framebuffer for it.
3822 glGenFramebuffersEXT(1, &service_id); 3823 glGenFramebuffersEXT(1, &service_id);
3823 CreateFramebuffer(client_id, service_id); 3824 CreateFramebuffer(client_id, service_id);
3824 framebuffer = GetFramebuffer(client_id); 3825 framebuffer = GetFramebuffer(client_id);
3825 IdAllocatorInterface* id_allocator = 3826 IdAllocatorInterface* id_allocator =
3826 group_->GetIdAllocator(id_namespaces::kFramebuffers); 3827 group_->GetIdAllocator(id_namespaces::kFramebuffers);
3827 id_allocator->MarkAsUsed(client_id); 3828 id_allocator->MarkAsUsed(client_id);
3828 } else { 3829 } else {
(...skipping 24 matching lines...) Expand all
3853 OnFboChanged(); 3854 OnFboChanged();
3854 } 3855 }
3855 3856
3856 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { 3857 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) {
3857 Renderbuffer* renderbuffer = NULL; 3858 Renderbuffer* renderbuffer = NULL;
3858 GLuint service_id = 0; 3859 GLuint service_id = 0;
3859 if (client_id != 0) { 3860 if (client_id != 0) {
3860 renderbuffer = GetRenderbuffer(client_id); 3861 renderbuffer = GetRenderbuffer(client_id);
3861 if (!renderbuffer) { 3862 if (!renderbuffer) {
3862 if (!group_->bind_generates_resource()) { 3863 if (!group_->bind_generates_resource()) {
3863 LOG(ERROR) 3864 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3864 << "glBindRenderbuffer: id not generated by glGenRenderbuffers"; 3865 "glBindRenderbuffer",
3865 current_decoder_error_ = error::kGenericError; 3866 "id not generated by glGenRenderbuffers");
3866 return; 3867 return;
3867 } 3868 }
3868 3869
3869 // It's a new id so make a renderbuffer renderbuffer for it. 3870 // It's a new id so make a renderbuffer renderbuffer for it.
3870 glGenRenderbuffersEXT(1, &service_id); 3871 glGenRenderbuffersEXT(1, &service_id);
3871 CreateRenderbuffer(client_id, service_id); 3872 CreateRenderbuffer(client_id, service_id);
3872 renderbuffer = GetRenderbuffer(client_id); 3873 renderbuffer = GetRenderbuffer(client_id);
3873 IdAllocatorInterface* id_allocator = 3874 IdAllocatorInterface* id_allocator =
3874 group_->GetIdAllocator(id_namespaces::kRenderbuffers); 3875 group_->GetIdAllocator(id_namespaces::kRenderbuffers);
3875 id_allocator->MarkAsUsed(client_id); 3876 id_allocator->MarkAsUsed(client_id);
3876 } else { 3877 } else {
3877 service_id = renderbuffer->service_id(); 3878 service_id = renderbuffer->service_id();
3878 } 3879 }
3879 renderbuffer->MarkAsValid(); 3880 renderbuffer->MarkAsValid();
3880 } 3881 }
3881 LogClientServiceForInfo(renderbuffer, client_id, "glBindRenerbuffer"); 3882 LogClientServiceForInfo(renderbuffer, client_id, "glBindRenerbuffer");
3882 state_.bound_renderbuffer = renderbuffer; 3883 state_.bound_renderbuffer = renderbuffer;
3883 glBindRenderbufferEXT(target, service_id); 3884 glBindRenderbufferEXT(target, service_id);
3884 } 3885 }
3885 3886
3886 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { 3887 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
3887 TextureRef* texture_ref = NULL; 3888 TextureRef* texture_ref = NULL;
3888 GLuint service_id = 0; 3889 GLuint service_id = 0;
3889 if (client_id != 0) { 3890 if (client_id != 0) {
3890 texture_ref = GetTexture(client_id); 3891 texture_ref = GetTexture(client_id);
3891 if (!texture_ref) { 3892 if (!texture_ref) {
3892 if (!group_->bind_generates_resource()) { 3893 if (!group_->bind_generates_resource()) {
3893 LOG(ERROR) << "glBindTexture: id not generated by glGenTextures"; 3894 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3894 current_decoder_error_ = error::kGenericError; 3895 "glBindTexture",
3895 return; 3896 "id not generated by glGenTextures");
3897 return;
3896 } 3898 }
3897 3899
3898 // It's a new id so make a texture texture for it. 3900 // It's a new id so make a texture texture for it.
3899 glGenTextures(1, &service_id); 3901 glGenTextures(1, &service_id);
3900 DCHECK_NE(0u, service_id); 3902 DCHECK_NE(0u, service_id);
3901 CreateTexture(client_id, service_id); 3903 CreateTexture(client_id, service_id);
3902 texture_ref = GetTexture(client_id); 3904 texture_ref = GetTexture(client_id);
3903 IdAllocatorInterface* id_allocator = 3905 IdAllocatorInterface* id_allocator =
3904 group_->GetIdAllocator(id_namespaces::kTextures); 3906 group_->GetIdAllocator(id_namespaces::kTextures);
3905 id_allocator->MarkAsUsed(client_id); 3907 id_allocator->MarkAsUsed(client_id);
(...skipping 6625 matching lines...) Expand 10 before | Expand all | Expand 10 after
10531 DoDidUseTexImageIfNeeded(texture, texture->target()); 10533 DoDidUseTexImageIfNeeded(texture, texture->target());
10532 } 10534 }
10533 10535
10534 // Include the auto-generated part of this file. We split this because it means 10536 // Include the auto-generated part of this file. We split this because it means
10535 // we can easily edit the non-auto generated parts right here in this file 10537 // we can easily edit the non-auto generated parts right here in this file
10536 // instead of having to edit some template or the code generator. 10538 // instead of having to edit some template or the code generator.
10537 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10539 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10538 10540
10539 } // namespace gles2 10541 } // namespace gles2
10540 } // namespace gpu 10542 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/share_group.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