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

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

Issue 895933004: Add UniformBlocks related commands to command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uniform
Patch Set: Working Created 5 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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 bool client_visible) { 1156 bool client_visible) {
1157 return vertex_array_manager()->CreateVertexAttribManager( 1157 return vertex_array_manager()->CreateVertexAttribManager(
1158 client_id, service_id, group_->max_vertex_attribs(), client_visible); 1158 client_id, service_id, group_->max_vertex_attribs(), client_visible);
1159 } 1159 }
1160 1160
1161 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); 1161 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name);
1162 void DoBindUniformLocationCHROMIUM( 1162 void DoBindUniformLocationCHROMIUM(
1163 GLuint client_id, GLint location, const char* name); 1163 GLuint client_id, GLint location, const char* name);
1164 1164
1165 error::Error GetAttribLocationHelper( 1165 error::Error GetAttribLocationHelper(
1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1167 const std::string& name_str); 1167 const std::string& name_str);
1168 1168
1169 error::Error GetUniformLocationHelper( 1169 error::Error GetUniformLocationHelper(
1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1171 const std::string& name_str); 1171 const std::string& name_str);
1172 1172
1173 error::Error GetFragDataLocationHelper( 1173 error::Error GetFragDataLocationHelper(
1174 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1174 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1175 const std::string& name_str); 1175 const std::string& name_str);
1176 1176
1177 // Wrapper for glShaderSource. 1177 // Wrapper for glShaderSource.
1178 void DoShaderSource( 1178 void DoShaderSource(
1179 GLuint client_id, GLsizei count, const char** data, const GLint* length); 1179 GLuint client_id, GLsizei count, const char** data, const GLint* length);
1180 1180
1181 // Wrapper for glTransformFeedbackVaryings. 1181 // Wrapper for glTransformFeedbackVaryings.
1182 void DoTransformFeedbackVaryings( 1182 void DoTransformFeedbackVaryings(
1183 GLuint client_program_id, GLsizei count, const char* const* varyings, 1183 GLuint client_program_id, GLsizei count, const char* const* varyings,
1184 GLenum buffer_mode); 1184 GLenum buffer_mode);
1185 1185
(...skipping 7008 matching lines...) Expand 10 before | Expand all | Expand 10 after
8194 return error::kInvalidArguments; 8194 return error::kInvalidArguments;
8195 } 8195 }
8196 std::string name_str; 8196 std::string name_str;
8197 if (!bucket->GetAsString(&name_str)) { 8197 if (!bucket->GetAsString(&name_str)) {
8198 return error::kInvalidArguments; 8198 return error::kInvalidArguments;
8199 } 8199 }
8200 return GetFragDataLocationHelper( 8200 return GetFragDataLocationHelper(
8201 c.program, c.location_shm_id, c.location_shm_offset, name_str); 8201 c.program, c.location_shm_id, c.location_shm_offset, name_str);
8202 } 8202 }
8203 8203
8204 error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex(
8205 uint32 immediate_data_size, const void* cmd_data) {
8206 if (!unsafe_es3_apis_enabled())
8207 return error::kUnknownCommand;
8208 const gles2::cmds::GetUniformBlockIndex& c =
8209 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data);
8210 Bucket* bucket = GetBucket(c.name_bucket_id);
8211 if (!bucket) {
8212 return error::kInvalidArguments;
8213 }
8214 std::string name_str;
8215 if (!bucket->GetAsString(&name_str)) {
8216 return error::kInvalidArguments;
8217 }
8218 GLuint* index = GetSharedMemoryAs<GLuint*>(
8219 c.index_shm_id, c.index_shm_offset, sizeof(GLuint));
8220 if (!index) {
8221 return error::kOutOfBounds;
8222 }
8223 // Require the client to init this in case the context is lost and we are no
8224 // longer executing commands.
8225 if (*index != GL_INVALID_INDEX) {
8226 return error::kGenericError;
8227 }
8228 Program* program = GetProgramInfoNotShader(
8229 c.program, "glGetUniformBlockIndex");
8230 if (!program) {
8231 return error::kNoError;
8232 }
8233 *index = glGetUniformBlockIndex(program->service_id(), name_str.c_str());
8234 return error::kNoError;
8235 }
8236
8204 error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size, 8237 error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size,
8205 const void* cmd_data) { 8238 const void* cmd_data) {
8206 const gles2::cmds::GetString& c = 8239 const gles2::cmds::GetString& c =
8207 *static_cast<const gles2::cmds::GetString*>(cmd_data); 8240 *static_cast<const gles2::cmds::GetString*>(cmd_data);
8208 GLenum name = static_cast<GLenum>(c.name); 8241 GLenum name = static_cast<GLenum>(c.name);
8209 if (!validators_->string_type.IsValid(name)) { 8242 if (!validators_->string_type.IsValid(name)) {
8210 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name"); 8243 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name");
8211 return error::kNoError; 8244 return error::kNoError;
8212 } 8245 }
8213 const char* str = reinterpret_cast<const char*>(glGetString(name)); 8246 const char* str = reinterpret_cast<const char*>(glGetString(name));
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
9690 return error::kNoError; 9723 return error::kNoError;
9691 } 9724 }
9692 result->success = 1; // true. 9725 result->success = 1; // true.
9693 result->size = uniform_info->size; 9726 result->size = uniform_info->size;
9694 result->type = uniform_info->type; 9727 result->type = uniform_info->type;
9695 Bucket* bucket = CreateBucket(name_bucket_id); 9728 Bucket* bucket = CreateBucket(name_bucket_id);
9696 bucket->SetFromString(uniform_info->name.c_str()); 9729 bucket->SetFromString(uniform_info->name.c_str());
9697 return error::kNoError; 9730 return error::kNoError;
9698 } 9731 }
9699 9732
9733 error::Error GLES2DecoderImpl::HandleGetActiveUniformBlockName(
9734 uint32 immediate_data_size, const void* cmd_data) {
9735 if (!unsafe_es3_apis_enabled())
9736 return error::kUnknownCommand;
9737 const gles2::cmds::GetActiveUniformBlockName& c =
9738 *static_cast<const gles2::cmds::GetActiveUniformBlockName*>(cmd_data);
9739 GLuint program_id = c.program;
9740 GLuint index = c.index;
9741 uint32 name_bucket_id = c.name_bucket_id;
9742 typedef cmds::GetActiveUniformBlockName::Result Result;
9743 Result* result = GetSharedMemoryAs<Result*>(
9744 c.result_shm_id, c.result_shm_offset, sizeof(*result));
9745 if (!result) {
9746 return error::kOutOfBounds;
9747 }
9748 // Check that the client initialized the result.
9749 if (*result != 0) {
9750 return error::kInvalidArguments;
9751 }
9752 Program* program = GetProgramInfoNotShader(
9753 program_id, "glGetActiveUniformBlockName");
9754 if (!program) {
9755 return error::kNoError;
9756 }
9757 GLuint service_id = program->service_id();
9758 GLint link_status = GL_FALSE;
9759 glGetProgramiv(service_id, GL_LINK_STATUS, &link_status);
9760 if (link_status != GL_TRUE) {
9761 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
9762 "glGetActiveActiveUniformBlockName", "program not linked");
9763 return error::kNoError;
9764 }
9765 GLint max_length = 0;
9766 glGetProgramiv(
9767 service_id, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_length);
9768 // Increase one so &buffer[0] is always valid.
9769 GLsizei buf_size = static_cast<GLsizei>(max_length) + 1;
9770 std::vector<char> buffer(buf_size);
9771 GLsizei length = 0;
9772 glGetActiveUniformBlockName(
9773 service_id, index, buf_size, &length, &buffer[0]);
9774 if (length == 0) {
9775 *result = 0;
9776 return error::kNoError;
9777 }
9778 *result = 1;
9779 Bucket* bucket = CreateBucket(name_bucket_id);
9780 DCHECK_GT(buf_size, length);
9781 DCHECK_EQ(0, buffer[length]);
9782 bucket->SetFromString(&buffer[0]);
9783 return error::kNoError;
9784 }
9785
9700 error::Error GLES2DecoderImpl::HandleGetActiveAttrib(uint32 immediate_data_size, 9786 error::Error GLES2DecoderImpl::HandleGetActiveAttrib(uint32 immediate_data_size,
9701 const void* cmd_data) { 9787 const void* cmd_data) {
9702 const gles2::cmds::GetActiveAttrib& c = 9788 const gles2::cmds::GetActiveAttrib& c =
9703 *static_cast<const gles2::cmds::GetActiveAttrib*>(cmd_data); 9789 *static_cast<const gles2::cmds::GetActiveAttrib*>(cmd_data);
9704 GLuint program_id = c.program; 9790 GLuint program_id = c.program;
9705 GLuint index = c.index; 9791 GLuint index = c.index;
9706 uint32 name_bucket_id = c.name_bucket_id; 9792 uint32 name_bucket_id = c.name_bucket_id;
9707 typedef cmds::GetActiveAttrib::Result Result; 9793 typedef cmds::GetActiveAttrib::Result Result;
9708 Result* result = GetSharedMemoryAs<Result*>( 9794 Result* result = GetSharedMemoryAs<Result*>(
9709 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 9795 c.result_shm_id, c.result_shm_offset, sizeof(*result));
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
10024 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. 10110 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail.
10025 Program* program = NULL; 10111 Program* program = NULL;
10026 program = GetProgram(program_id); 10112 program = GetProgram(program_id);
10027 if (!program || !program->IsValid()) { 10113 if (!program || !program->IsValid()) {
10028 return error::kNoError; 10114 return error::kNoError;
10029 } 10115 }
10030 program->GetProgramInfo(program_manager(), bucket); 10116 program->GetProgramInfo(program_manager(), bucket);
10031 return error::kNoError; 10117 return error::kNoError;
10032 } 10118 }
10033 10119
10120 error::Error GLES2DecoderImpl::HandleGetUniformBlocksCHROMIUM(
10121 uint32 immediate_data_size, const void* cmd_data) {
10122 if (!unsafe_es3_apis_enabled())
10123 return error::kUnknownCommand;
10124 const gles2::cmds::GetUniformBlocksCHROMIUM& c =
10125 *static_cast<const gles2::cmds::GetUniformBlocksCHROMIUM*>(cmd_data);
10126 GLuint program_id = static_cast<GLuint>(c.program);
10127 uint32 bucket_id = c.bucket_id;
10128 Bucket* bucket = CreateBucket(bucket_id);
10129 bucket->SetSize(sizeof(UniformBlocksHeader)); // in case we fail.
10130 Program* program = NULL;
10131 program = GetProgram(program_id);
10132 if (!program || !program->IsValid()) {
10133 return error::kNoError;
10134 }
10135 program->GetUniformBlocks(bucket);
10136 return error::kNoError;
10137 }
10138
10034 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { 10139 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() {
10035 switch (reset_status_) { 10140 switch (reset_status_) {
10036 case GL_NO_ERROR: 10141 case GL_NO_ERROR:
10037 // TODO(kbr): improve the precision of the error code in this case. 10142 // TODO(kbr): improve the precision of the error code in this case.
10038 // Consider delegating to context for error code if MakeCurrent fails. 10143 // Consider delegating to context for error code if MakeCurrent fails.
10039 return error::kUnknown; 10144 return error::kUnknown;
10040 case GL_GUILTY_CONTEXT_RESET_ARB: 10145 case GL_GUILTY_CONTEXT_RESET_ARB:
10041 return error::kGuilty; 10146 return error::kGuilty;
10042 case GL_INNOCENT_CONTEXT_RESET_ARB: 10147 case GL_INNOCENT_CONTEXT_RESET_ARB:
10043 return error::kInnocent; 10148 return error::kInnocent;
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
11683 } 11788 }
11684 } 11789 }
11685 11790
11686 // Include the auto-generated part of this file. We split this because it means 11791 // Include the auto-generated part of this file. We split this because it means
11687 // we can easily edit the non-auto generated parts right here in this file 11792 // we can easily edit the non-auto generated parts right here in this file
11688 // instead of having to edit some template or the code generator. 11793 // instead of having to edit some template or the code generator.
11689 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11794 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11690 11795
11691 } // namespace gles2 11796 } // namespace gles2
11692 } // namespace gpu 11797 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_ids_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698