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

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

Issue 10635011: Add glBindUniformLocationCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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) 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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 renderbuffer_manager()->GetRenderbufferInfo(client_id); 868 renderbuffer_manager()->GetRenderbufferInfo(client_id);
869 return info; 869 return info;
870 } 870 }
871 871
872 // Removes the renderbuffer info for the given renderbuffer. 872 // Removes the renderbuffer info for the given renderbuffer.
873 void RemoveRenderbufferInfo(GLuint client_id) { 873 void RemoveRenderbufferInfo(GLuint client_id) {
874 renderbuffer_manager()->RemoveRenderbufferInfo(client_id); 874 renderbuffer_manager()->RemoveRenderbufferInfo(client_id);
875 } 875 }
876 876
877 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); 877 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name);
878 void DoBindUniformLocationCHROMIUM(
879 GLuint client_id, GLint location, const char* name);
878 880
879 error::Error GetAttribLocationHelper( 881 error::Error GetAttribLocationHelper(
880 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 882 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
881 const std::string& name_str); 883 const std::string& name_str);
882 884
883 error::Error GetUniformLocationHelper( 885 error::Error GetUniformLocationHelper(
884 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 886 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
885 const std::string& name_str); 887 const std::string& name_str);
886 888
887 // Helper for glShaderSource. 889 // Helper for glShaderSource.
(...skipping 3128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4016 return error::kInvalidArguments; 4018 return error::kInvalidArguments;
4017 } 4019 }
4018 std::string name_str; 4020 std::string name_str;
4019 if (!bucket->GetAsString(&name_str)) { 4021 if (!bucket->GetAsString(&name_str)) {
4020 return error::kInvalidArguments; 4022 return error::kInvalidArguments;
4021 } 4023 }
4022 DoBindAttribLocation(program, index, name_str.c_str()); 4024 DoBindAttribLocation(program, index, name_str.c_str());
4023 return error::kNoError; 4025 return error::kNoError;
4024 } 4026 }
4025 4027
4028 void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM(
4029 GLuint program, GLint location, const char* name) {
4030 if (!StringIsValidForGLES(name)) {
4031 SetGLError(GL_INVALID_VALUE,
4032 "glBindUniformLocationCHROMIUM", "Invalid character");
4033 return;
4034 }
4035 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
4036 SetGLError(GL_INVALID_OPERATION,
4037 "glBindUniformLocationCHROMIUM", "reserved prefix");
4038 return;
4039 }
4040 if (location < 0 || static_cast<uint32>(location) >=
4041 (group_->max_fragment_uniform_vectors() +
4042 group_->max_vertex_uniform_vectors()) * 4) {
4043 SetGLError(GL_INVALID_VALUE,
4044 "glBindUniformLocationCHROMIUM", "location out of range");
4045 return;
4046 }
4047 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
4048 program, "glBindUniformLocationCHROMIUM");
4049 if (!info) {
4050 return;
4051 }
4052 if (!info->SetUniformLocationBinding(name, location)) {
4053 SetGLError(GL_INVALID_VALUE,
4054 "glBindUniformLocationCHROMIUM", "location out of range");
4055 }
4056 }
4057
4058 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUM(
4059 uint32 immediate_data_size, const gles2::BindUniformLocationCHROMIUM& c) {
4060 GLuint program = static_cast<GLuint>(c.program);
4061 GLint location = static_cast<GLint>(c.location);
4062 uint32 name_size = c.data_size;
4063 const char* name = GetSharedMemoryAs<const char*>(
4064 c.name_shm_id, c.name_shm_offset, name_size);
4065 if (name == NULL) {
4066 return error::kOutOfBounds;
4067 }
4068 String name_str(name, name_size);
4069 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4070 return error::kNoError;
4071 }
4072
4073 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMImmediate(
4074 uint32 immediate_data_size,
4075 const gles2::BindUniformLocationCHROMIUMImmediate& c) {
4076 GLuint program = static_cast<GLuint>(c.program);
4077 GLint location = static_cast<GLint>(c.location);
4078 uint32 name_size = c.data_size;
4079 const char* name = GetImmediateDataAs<const char*>(
4080 c, name_size, immediate_data_size);
4081 if (name == NULL) {
4082 return error::kOutOfBounds;
4083 }
4084 String name_str(name, name_size);
4085 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4086 return error::kNoError;
4087 }
4088
4089 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket(
4090 uint32 immediate_data_size,
4091 const gles2::BindUniformLocationCHROMIUMBucket& c) {
4092 GLuint program = static_cast<GLuint>(c.program);
4093 GLint location = static_cast<GLint>(c.location);
4094 Bucket* bucket = GetBucket(c.name_bucket_id);
4095 if (!bucket || bucket->size() == 0) {
4096 return error::kInvalidArguments;
4097 }
4098 std::string name_str;
4099 if (!bucket->GetAsString(&name_str)) {
4100 return error::kInvalidArguments;
4101 }
4102 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4103 return error::kNoError;
4104 }
4105
4026 error::Error GLES2DecoderImpl::HandleDeleteShader( 4106 error::Error GLES2DecoderImpl::HandleDeleteShader(
4027 uint32 immediate_data_size, const gles2::DeleteShader& c) { 4107 uint32 immediate_data_size, const gles2::DeleteShader& c) {
4028 GLuint client_id = c.shader; 4108 GLuint client_id = c.shader;
4029 if (client_id) { 4109 if (client_id) {
4030 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id); 4110 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
4031 if (info) { 4111 if (info) {
4032 if (!info->IsDeleted()) { 4112 if (!info->IsDeleted()) {
4033 glDeleteShader(info->service_id()); 4113 glDeleteShader(info->service_id());
4034 shader_manager()->MarkAsDeleted(info); 4114 shader_manager()->MarkAsDeleted(info);
4035 } 4115 }
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
6559 GLint* location = GetSharedMemoryAs<GLint*>( 6639 GLint* location = GetSharedMemoryAs<GLint*>(
6560 location_shm_id, location_shm_offset, sizeof(GLint)); 6640 location_shm_id, location_shm_offset, sizeof(GLint));
6561 if (!location) { 6641 if (!location) {
6562 return error::kOutOfBounds; 6642 return error::kOutOfBounds;
6563 } 6643 }
6564 // Require the client to init this incase the context is lost an we are no 6644 // Require the client to init this incase the context is lost an we are no
6565 // longer executing commands. 6645 // longer executing commands.
6566 if (*location != -1) { 6646 if (*location != -1) {
6567 return error::kGenericError; 6647 return error::kGenericError;
6568 } 6648 }
6569 *location = GLES2Util::SwizzleLocation( 6649 *location = info->GetUniformFakeLocation(name_str);
6570 info->GetUniformFakeLocation(name_str));
6571 return error::kNoError; 6650 return error::kNoError;
6572 } 6651 }
6573 6652
6574 error::Error GLES2DecoderImpl::HandleGetUniformLocation( 6653 error::Error GLES2DecoderImpl::HandleGetUniformLocation(
6575 uint32 immediate_data_size, const gles2::GetUniformLocation& c) { 6654 uint32 immediate_data_size, const gles2::GetUniformLocation& c) {
6576 uint32 name_size = c.data_size; 6655 uint32 name_size = c.data_size;
6577 const char* name = GetSharedMemoryAs<const char*>( 6656 const char* name = GetSharedMemoryAs<const char*>(
6578 c.name_shm_id, c.name_shm_offset, name_size); 6657 c.name_shm_id, c.name_shm_offset, name_size);
6579 if (!name) { 6658 if (!name) {
6580 return error::kOutOfBounds; 6659 return error::kOutOfBounds;
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
7868 return false; 7947 return false;
7869 } 7948 }
7870 result->size = size; 7949 result->size = size;
7871 *result_type = type; 7950 *result_type = type;
7872 return true; 7951 return true;
7873 } 7952 }
7874 7953
7875 error::Error GLES2DecoderImpl::HandleGetUniformiv( 7954 error::Error GLES2DecoderImpl::HandleGetUniformiv(
7876 uint32 immediate_data_size, const gles2::GetUniformiv& c) { 7955 uint32 immediate_data_size, const gles2::GetUniformiv& c) {
7877 GLuint program = c.program; 7956 GLuint program = c.program;
7878 GLint fake_location = GLES2Util::UnswizzleLocation(c.location); 7957 GLint fake_location = c.location;
7879 GLuint service_id; 7958 GLuint service_id;
7880 GLenum result_type; 7959 GLenum result_type;
7881 GLint real_location = -1; 7960 GLint real_location = -1;
7882 Error error; 7961 Error error;
7883 void* result; 7962 void* result;
7884 if (GetUniformSetup( 7963 if (GetUniformSetup(
7885 program, fake_location, c.params_shm_id, c.params_shm_offset, 7964 program, fake_location, c.params_shm_id, c.params_shm_offset,
7886 &error, &real_location, &service_id, &result, &result_type)) { 7965 &error, &real_location, &service_id, &result, &result_type)) {
7887 glGetUniformiv( 7966 glGetUniformiv(
7888 service_id, real_location, 7967 service_id, real_location,
7889 static_cast<gles2::GetUniformiv::Result*>(result)->GetData()); 7968 static_cast<gles2::GetUniformiv::Result*>(result)->GetData());
7890 } 7969 }
7891 return error; 7970 return error;
7892 } 7971 }
7893 7972
7894 error::Error GLES2DecoderImpl::HandleGetUniformfv( 7973 error::Error GLES2DecoderImpl::HandleGetUniformfv(
7895 uint32 immediate_data_size, const gles2::GetUniformfv& c) { 7974 uint32 immediate_data_size, const gles2::GetUniformfv& c) {
7896 GLuint program = c.program; 7975 GLuint program = c.program;
7897 GLint fake_location = GLES2Util::UnswizzleLocation(c.location); 7976 GLint fake_location = c.location;
7898 GLuint service_id; 7977 GLuint service_id;
7899 GLint real_location = -1; 7978 GLint real_location = -1;
7900 Error error; 7979 Error error;
7901 typedef gles2::GetUniformfv::Result Result; 7980 typedef gles2::GetUniformfv::Result Result;
7902 Result* result; 7981 Result* result;
7903 GLenum result_type; 7982 GLenum result_type;
7904 if (GetUniformSetup( 7983 if (GetUniformSetup(
7905 program, fake_location, c.params_shm_id, c.params_shm_offset, 7984 program, fake_location, c.params_shm_id, c.params_shm_offset,
7906 &error, &real_location, &service_id, 7985 &error, &real_location, &service_id,
7907 reinterpret_cast<void**>(&result), &result_type)) { 7986 reinterpret_cast<void**>(&result), &result_type)) {
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
9075 BindAndApplyTextureParameters(info); 9154 BindAndApplyTextureParameters(info);
9076 } 9155 }
9077 9156
9078 // Include the auto-generated part of this file. We split this because it means 9157 // Include the auto-generated part of this file. We split this because it means
9079 // we can easily edit the non-auto generated parts right here in this file 9158 // we can easily edit the non-auto generated parts right here in this file
9080 // instead of having to edit some template or the code generator. 9159 // instead of having to edit some template or the code generator.
9081 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9160 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9082 9161
9083 } // namespace gles2 9162 } // namespace gles2
9084 } // namespace gpu 9163 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('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