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

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

Issue 11363191: Cache more GL state both service and client side. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 // does not overflow the uniform. 975 // does not overflow the uniform.
976 bool PrepForSetUniformByLocation( 976 bool PrepForSetUniformByLocation(
977 GLint fake_location, const char* function_name, 977 GLint fake_location, const char* function_name,
978 GLint* real_location, GLenum* type, GLsizei* count); 978 GLint* real_location, GLenum* type, GLsizei* count);
979 979
980 // Gets the service id for any simulated backbuffer fbo. 980 // Gets the service id for any simulated backbuffer fbo.
981 GLuint GetBackbufferServiceId() const; 981 GLuint GetBackbufferServiceId() const;
982 982
983 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv 983 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv
984 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); 984 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written);
985 // Same as GetHelper except for auto-generated state.
986 bool GetStateAsGLint(GLenum pname, GLint* params, GLsizei* num_written);
987 bool GetStateAsGLfloat(GLenum pname, GLfloat* params, GLsizei* num_written);
988 985
989 // Wrapper for glCreateProgram 986 // Wrapper for glCreateProgram
990 bool CreateProgramHelper(GLuint client_id); 987 bool CreateProgramHelper(GLuint client_id);
991 988
992 // Wrapper for glCreateShader 989 // Wrapper for glCreateShader
993 bool CreateShaderHelper(GLenum type, GLuint client_id); 990 bool CreateShaderHelper(GLenum type, GLuint client_id);
994 991
995 // Wrapper for glActiveTexture 992 // Wrapper for glActiveTexture
996 void DoActiveTexture(GLenum texture_unit); 993 void DoActiveTexture(GLenum texture_unit);
997 994
(...skipping 2875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 } 3870 }
3874 return true; 3871 return true;
3875 default: 3872 default:
3876 *num_written = util_.GLGetNumValuesReturned(pname); 3873 *num_written = util_.GLGetNumValuesReturned(pname);
3877 return false; 3874 return false;
3878 } 3875 }
3879 } 3876 }
3880 3877
3881 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( 3878 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet(
3882 GLenum pname, GLsizei* num_values) { 3879 GLenum pname, GLsizei* num_values) {
3883 if (GetStateAsGLint(pname, NULL, num_values)) { 3880 if (state_.GetStateAsGLint(pname, NULL, num_values)) {
3884 return true; 3881 return true;
3885 } 3882 }
3886 return GetHelper(pname, NULL, num_values); 3883 return GetHelper(pname, NULL, num_values);
3887 } 3884 }
3888 3885
3889 void GLES2DecoderImpl::DoGetBooleanv(GLenum pname, GLboolean* params) { 3886 void GLES2DecoderImpl::DoGetBooleanv(GLenum pname, GLboolean* params) {
3890 DCHECK(params); 3887 DCHECK(params);
3891 GLsizei num_written = 0; 3888 GLsizei num_written = 0;
3892 if (GetNumValuesReturnedForGLGet(pname, &num_written)) { 3889 if (GetNumValuesReturnedForGLGet(pname, &num_written)) {
3893 scoped_array<GLint> values(new GLint[num_written]); 3890 scoped_array<GLint> values(new GLint[num_written]);
3894 if (!GetStateAsGLint(pname, values.get(), &num_written)) { 3891 if (!state_.GetStateAsGLint(pname, values.get(), &num_written)) {
3895 GetHelper(pname, values.get(), &num_written); 3892 GetHelper(pname, values.get(), &num_written);
3896 } 3893 }
3897 for (GLsizei ii = 0; ii < num_written; ++ii) { 3894 for (GLsizei ii = 0; ii < num_written; ++ii) {
3898 params[ii] = static_cast<GLboolean>(values[ii]); 3895 params[ii] = static_cast<GLboolean>(values[ii]);
3899 } 3896 }
3900 } else { 3897 } else {
3901 glGetBooleanv(pname, params); 3898 glGetBooleanv(pname, params);
3902 } 3899 }
3903 } 3900 }
3904 3901
3905 void GLES2DecoderImpl::DoGetFloatv(GLenum pname, GLfloat* params) { 3902 void GLES2DecoderImpl::DoGetFloatv(GLenum pname, GLfloat* params) {
3906 DCHECK(params); 3903 DCHECK(params);
3907 GLsizei num_written = 0; 3904 GLsizei num_written = 0;
3908 if (!GetStateAsGLfloat(pname, params, &num_written)) { 3905 if (!state_.GetStateAsGLfloat(pname, params, &num_written)) {
3909 if (GetHelper(pname, NULL, &num_written)) { 3906 if (GetHelper(pname, NULL, &num_written)) {
3910 scoped_array<GLint> values(new GLint[num_written]); 3907 scoped_array<GLint> values(new GLint[num_written]);
3911 GetHelper(pname, values.get(), &num_written); 3908 GetHelper(pname, values.get(), &num_written);
3912 for (GLsizei ii = 0; ii < num_written; ++ii) { 3909 for (GLsizei ii = 0; ii < num_written; ++ii) {
3913 params[ii] = static_cast<GLfloat>(values[ii]); 3910 params[ii] = static_cast<GLfloat>(values[ii]);
3914 } 3911 }
3915 } else { 3912 } else {
3916 glGetFloatv(pname, params); 3913 glGetFloatv(pname, params);
3917 } 3914 }
3918 } 3915 }
3919 } 3916 }
3920 3917
3921 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { 3918 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) {
3922 DCHECK(params); 3919 DCHECK(params);
3923 GLsizei num_written; 3920 GLsizei num_written;
3924 if (!GetStateAsGLint(pname, params, &num_written) && 3921 if (!state_.GetStateAsGLint(pname, params, &num_written) &&
3925 !GetHelper(pname, params, &num_written)) { 3922 !GetHelper(pname, params, &num_written)) {
3926 glGetIntegerv(pname, params); 3923 glGetIntegerv(pname, params);
3927 } 3924 }
3928 } 3925 }
3929 3926
3930 void GLES2DecoderImpl::DoGetProgramiv( 3927 void GLES2DecoderImpl::DoGetProgramiv(
3931 GLuint program_id, GLenum pname, GLint* params) { 3928 GLuint program_id, GLenum pname, GLint* params) {
3932 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 3929 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
3933 program_id, "glGetProgramiv"); 3930 program_id, "glGetProgramiv");
3934 if (!info) { 3931 if (!info) {
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
5850 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 5847 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram(
5851 shader, "glGetShaderInfoLog"); 5848 shader, "glGetShaderInfoLog");
5852 if (!info || !info->log_info()) { 5849 if (!info || !info->log_info()) {
5853 bucket->SetFromString(""); 5850 bucket->SetFromString("");
5854 return error::kNoError; 5851 return error::kNoError;
5855 } 5852 }
5856 bucket->SetFromString(info->log_info()->c_str()); 5853 bucket->SetFromString(info->log_info()->c_str());
5857 return error::kNoError; 5854 return error::kNoError;
5858 } 5855 }
5859 5856
5857 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) {
5858 return state_.GetEnabled(cap);
5859 }
5860
5860 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { 5861 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) {
5861 const BufferManager::BufferInfo* buffer = GetBufferInfo(client_id); 5862 const BufferManager::BufferInfo* buffer = GetBufferInfo(client_id);
5862 return buffer && buffer->IsValid() && !buffer->IsDeleted(); 5863 return buffer && buffer->IsValid() && !buffer->IsDeleted();
5863 } 5864 }
5864 5865
5865 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { 5866 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) {
5866 const FramebufferManager::FramebufferInfo* framebuffer = 5867 const FramebufferManager::FramebufferInfo* framebuffer =
5867 GetFramebufferInfo(client_id); 5868 GetFramebufferInfo(client_id);
5868 return framebuffer && framebuffer->IsValid() && !framebuffer->IsDeleted(); 5869 return framebuffer && framebuffer->IsValid() && !framebuffer->IsDeleted();
5869 } 5870 }
(...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after
8415 for (uint32 ii = 0; ii < num_results; ++ii) { 8416 for (uint32 ii = 0; ii < num_results; ++ii) {
8416 if (results[ii]) { 8417 if (results[ii]) {
8417 return error::kInvalidArguments; 8418 return error::kInvalidArguments;
8418 } 8419 }
8419 } 8420 }
8420 8421
8421 // Get each result. 8422 // Get each result.
8422 GLint* start = results; 8423 GLint* start = results;
8423 for (GLuint ii = 0; ii < count; ++ii) { 8424 for (GLuint ii = 0; ii < count; ++ii) {
8424 GLsizei num_written = 0; 8425 GLsizei num_written = 0;
8425 if (!GetStateAsGLint(enums[ii], results, &num_written) && 8426 if (!state_.GetStateAsGLint(enums[ii], results, &num_written) &&
8426 !GetHelper(enums[ii], results, &num_written)) { 8427 !GetHelper(enums[ii], results, &num_written)) {
8427 glGetIntegerv(enums[ii], results); 8428 glGetIntegerv(enums[ii], results);
8428 } 8429 }
8429 results += num_written; 8430 results += num_written;
8430 } 8431 }
8431 8432
8432 // Just to verify. Should this be a DCHECK? 8433 // Just to verify. Should this be a DCHECK?
8433 if (static_cast<uint32>(results - start) != num_results) { 8434 if (static_cast<uint32>(results - start) != num_results) {
8434 return error::kOutOfBounds; 8435 return error::kOutOfBounds;
8435 } 8436 }
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
9321 GL_RGBA, GL_UNSIGNED_BYTE, false); 9322 GL_RGBA, GL_UNSIGNED_BYTE, false);
9322 } 9323 }
9323 9324
9324 // Include the auto-generated part of this file. We split this because it means 9325 // Include the auto-generated part of this file. We split this because it means
9325 // we can easily edit the non-auto generated parts right here in this file 9326 // we can easily edit the non-auto generated parts right here in this file
9326 // instead of having to edit some template or the code generator. 9327 // instead of having to edit some template or the code generator.
9327 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9328 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9328 9329
9329 } // namespace gles2 9330 } // namespace gles2
9330 } // namespace gpu 9331 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state_impl_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698