Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <cmath> | 10 #include <cmath> |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 // Creates a vertex attrib manager for the given vertex array. | 1263 // Creates a vertex attrib manager for the given vertex array. |
| 1264 scoped_refptr<VertexAttribManager> CreateVertexAttribManager( | 1264 scoped_refptr<VertexAttribManager> CreateVertexAttribManager( |
| 1265 GLuint client_id, | 1265 GLuint client_id, |
| 1266 GLuint service_id, | 1266 GLuint service_id, |
| 1267 bool client_visible) { | 1267 bool client_visible) { |
| 1268 return vertex_array_manager()->CreateVertexAttribManager( | 1268 return vertex_array_manager()->CreateVertexAttribManager( |
| 1269 client_id, service_id, group_->max_vertex_attribs(), client_visible); | 1269 client_id, service_id, group_->max_vertex_attribs(), client_visible); |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); | 1272 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); |
| 1273 | |
| 1274 error::Error DoBindFragDataLocation(GLuint program_id, | |
| 1275 GLuint colorName, | |
| 1276 const char* name); | |
| 1277 | |
| 1278 error::Error DoBindFragDataLocationIndexed(GLuint program_id, | |
| 1279 GLuint colorName, | |
| 1280 GLuint index, | |
| 1281 const char* name); | |
| 1282 | |
| 1273 void DoBindUniformLocationCHROMIUM( | 1283 void DoBindUniformLocationCHROMIUM( |
| 1274 GLuint client_id, GLint location, const char* name); | 1284 GLuint client_id, GLint location, const char* name); |
| 1275 | 1285 |
| 1276 error::Error GetAttribLocationHelper( | 1286 error::Error GetAttribLocationHelper( |
| 1277 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1287 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 1278 const std::string& name_str); | 1288 const std::string& name_str); |
| 1279 | 1289 |
| 1280 error::Error GetUniformLocationHelper( | 1290 error::Error GetUniformLocationHelper( |
| 1281 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1291 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 1282 const std::string& name_str); | 1292 const std::string& name_str); |
| 1283 | 1293 |
| 1284 error::Error GetFragDataLocationHelper( | 1294 error::Error GetFragDataLocationHelper( |
| 1285 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1295 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 1286 const std::string& name_str); | 1296 const std::string& name_str); |
| 1287 | 1297 |
| 1298 error::Error GetFragDataIndexHelper(GLuint program_id, | |
| 1299 uint32 index_shm_id, | |
| 1300 uint32 index_shm_offset, | |
| 1301 const std::string& name_str); | |
| 1302 | |
| 1288 // Wrapper for glShaderSource. | 1303 // Wrapper for glShaderSource. |
| 1289 void DoShaderSource( | 1304 void DoShaderSource( |
| 1290 GLuint client_id, GLsizei count, const char** data, const GLint* length); | 1305 GLuint client_id, GLsizei count, const char** data, const GLint* length); |
| 1291 | 1306 |
| 1292 // Wrapper for glTransformFeedbackVaryings. | 1307 // Wrapper for glTransformFeedbackVaryings. |
| 1293 void DoTransformFeedbackVaryings( | 1308 void DoTransformFeedbackVaryings( |
| 1294 GLuint client_program_id, GLsizei count, const char* const* varyings, | 1309 GLuint client_program_id, GLsizei count, const char* const* varyings, |
| 1295 GLenum buffer_mode); | 1310 GLenum buffer_mode); |
| 1296 | 1311 |
| 1297 // Clear any textures used by the current program. | 1312 // Clear any textures used by the current program. |
| (...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3253 resources.MaxVaryingVectors = group_->max_varying_vectors(); | 3268 resources.MaxVaryingVectors = group_->max_varying_vectors(); |
| 3254 resources.MaxVertexTextureImageUnits = | 3269 resources.MaxVertexTextureImageUnits = |
| 3255 group_->max_vertex_texture_image_units(); | 3270 group_->max_vertex_texture_image_units(); |
| 3256 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); | 3271 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); |
| 3257 resources.MaxTextureImageUnits = group_->max_texture_image_units(); | 3272 resources.MaxTextureImageUnits = group_->max_texture_image_units(); |
| 3258 resources.MaxFragmentUniformVectors = | 3273 resources.MaxFragmentUniformVectors = |
| 3259 group_->max_fragment_uniform_vectors(); | 3274 group_->max_fragment_uniform_vectors(); |
| 3260 resources.MaxDrawBuffers = group_->max_draw_buffers(); | 3275 resources.MaxDrawBuffers = group_->max_draw_buffers(); |
| 3261 resources.MaxExpressionComplexity = 256; | 3276 resources.MaxExpressionComplexity = 256; |
| 3262 resources.MaxCallStackDepth = 256; | 3277 resources.MaxCallStackDepth = 256; |
| 3278 resources.MaxDualSourceDrawBuffers = group_->max_dual_source_draw_buffers(); | |
| 3263 | 3279 |
| 3264 GLint range[2] = { 0, 0 }; | 3280 GLint range[2] = { 0, 0 }; |
| 3265 GLint precision = 0; | 3281 GLint precision = 0; |
| 3266 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 3282 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
| 3267 range, &precision); | 3283 range, &precision); |
| 3268 resources.FragmentPrecisionHigh = | 3284 resources.FragmentPrecisionHigh = |
| 3269 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); | 3285 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
| 3270 | 3286 |
| 3271 if (IsWebGLContext()) { | 3287 if (IsWebGLContext()) { |
| 3272 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 3288 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3285 resources.OES_EGL_image_external = | 3301 resources.OES_EGL_image_external = |
| 3286 features().oes_egl_image_external ? 1 : 0; | 3302 features().oes_egl_image_external ? 1 : 0; |
| 3287 resources.EXT_draw_buffers = | 3303 resources.EXT_draw_buffers = |
| 3288 features().ext_draw_buffers ? 1 : 0; | 3304 features().ext_draw_buffers ? 1 : 0; |
| 3289 resources.EXT_frag_depth = | 3305 resources.EXT_frag_depth = |
| 3290 features().ext_frag_depth ? 1 : 0; | 3306 features().ext_frag_depth ? 1 : 0; |
| 3291 resources.EXT_shader_texture_lod = | 3307 resources.EXT_shader_texture_lod = |
| 3292 features().ext_shader_texture_lod ? 1 : 0; | 3308 features().ext_shader_texture_lod ? 1 : 0; |
| 3293 resources.NV_draw_buffers = | 3309 resources.NV_draw_buffers = |
| 3294 features().nv_draw_buffers ? 1 : 0; | 3310 features().nv_draw_buffers ? 1 : 0; |
| 3311 resources.EXT_blend_func_extended = | |
| 3312 features().ext_blend_func_extended ? 1 : 0; | |
| 3295 } | 3313 } |
| 3296 | 3314 |
| 3297 ShShaderSpec shader_spec; | 3315 ShShaderSpec shader_spec; |
| 3298 switch (context_type_) { | 3316 switch (context_type_) { |
| 3299 case ContextGroup::CONTEXT_TYPE_WEBGL1: | 3317 case ContextGroup::CONTEXT_TYPE_WEBGL1: |
| 3300 shader_spec = SH_WEBGL_SPEC; | 3318 shader_spec = SH_WEBGL_SPEC; |
| 3301 break; | 3319 break; |
| 3302 case ContextGroup::CONTEXT_TYPE_WEBGL2: | 3320 case ContextGroup::CONTEXT_TYPE_WEBGL2: |
| 3303 shader_spec = SH_WEBGL2_SPEC; | 3321 shader_spec = SH_WEBGL2_SPEC; |
| 3304 break; | 3322 break; |
| (...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5453 *params = 0; | 5471 *params = 0; |
| 5454 } | 5472 } |
| 5455 } | 5473 } |
| 5456 return true; | 5474 return true; |
| 5457 case GL_BIND_GENERATES_RESOURCE_CHROMIUM: | 5475 case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 5458 *num_written = 1; | 5476 *num_written = 1; |
| 5459 if (params) { | 5477 if (params) { |
| 5460 params[0] = group_->bind_generates_resource() ? 1 : 0; | 5478 params[0] = group_->bind_generates_resource() ? 1 : 0; |
| 5461 } | 5479 } |
| 5462 return true; | 5480 return true; |
| 5481 case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS: | |
| 5482 *num_written = 1; | |
| 5483 if (params) { | |
| 5484 params[0] = group_->max_dual_source_draw_buffers(); | |
| 5485 } | |
| 5486 return true; | |
| 5463 default: | 5487 default: |
| 5464 if (pname >= GL_DRAW_BUFFER0_ARB && | 5488 if (pname >= GL_DRAW_BUFFER0_ARB && |
| 5465 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { | 5489 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { |
| 5466 *num_written = 1; | 5490 *num_written = 1; |
| 5467 if (params) { | 5491 if (params) { |
| 5468 Framebuffer* framebuffer = | 5492 Framebuffer* framebuffer = |
| 5469 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 5493 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
| 5470 if (framebuffer) { | 5494 if (framebuffer) { |
| 5471 params[0] = framebuffer->GetDrawBuffer(pname); | 5495 params[0] = framebuffer->GetDrawBuffer(pname); |
| 5472 } else { // backbuffer | 5496 } else { // backbuffer |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5633 return error::kInvalidArguments; | 5657 return error::kInvalidArguments; |
| 5634 } | 5658 } |
| 5635 std::string name_str; | 5659 std::string name_str; |
| 5636 if (!bucket->GetAsString(&name_str)) { | 5660 if (!bucket->GetAsString(&name_str)) { |
| 5637 return error::kInvalidArguments; | 5661 return error::kInvalidArguments; |
| 5638 } | 5662 } |
| 5639 DoBindAttribLocation(program, index, name_str.c_str()); | 5663 DoBindAttribLocation(program, index, name_str.c_str()); |
| 5640 return error::kNoError; | 5664 return error::kNoError; |
| 5641 } | 5665 } |
| 5642 | 5666 |
| 5667 error::Error GLES2DecoderImpl::DoBindFragDataLocation(GLuint program_id, | |
| 5668 GLuint colorName, | |
| 5669 const char* name) { | |
| 5670 if (!unsafe_es3_apis_enabled()) | |
| 5671 return error::kUnknownCommand; | |
| 5672 | |
| 5673 const char kFunctionName[] = "glBindFragDataLocationEXT"; | |
| 5674 if (!StringIsValidForGLES(name)) { | |
| 5675 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Invalid character"); | |
| 5676 return error::kNoError; | |
| 5677 } | |
| 5678 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { | |
| 5679 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix"); | |
| 5680 return error::kNoError; | |
| 5681 } | |
| 5682 if (colorName >= group_->max_draw_buffers()) { | |
| 5683 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | |
| 5684 "colorName out of range"); | |
| 5685 return error::kNoError; | |
| 5686 } | |
| 5687 Program* program = GetProgramInfoNotShader(program_id, kFunctionName); | |
| 5688 if (!program) { | |
| 5689 return error::kNoError; | |
| 5690 } | |
| 5691 DCHECK(!IsWebGLContext()); | |
| 5692 // Note: the name is passed directly, since names are never hashed for | |
| 5693 // non-WebGL context. Also the | |
| 5694 // potential built-in names can not be controlled by the client, since they | |
| 5695 // will be overridden if | |
| 5696 // used. | |
| 5697 glBindFragDataLocation(program->service_id(), colorName, name); | |
| 5698 return error::kNoError; | |
| 5699 } | |
| 5700 error::Error GLES2DecoderImpl::HandleBindFragDataLocationEXTBucket( | |
| 5701 uint32 immediate_data_size, | |
| 5702 const void* cmd_data) { | |
| 5703 const gles2::cmds::BindFragDataLocationEXTBucket& c = | |
| 5704 *static_cast<const gles2::cmds::BindFragDataLocationEXTBucket*>(cmd_data); | |
| 5705 GLuint program = static_cast<GLuint>(c.program); | |
| 5706 GLuint colorNumber = static_cast<GLint>(c.colorNumber); | |
| 5707 Bucket* bucket = GetBucket(c.name_bucket_id); | |
| 5708 if (!bucket || bucket->size() == 0) { | |
| 5709 return error::kInvalidArguments; | |
| 5710 } | |
| 5711 std::string name_str; | |
| 5712 if (!bucket->GetAsString(&name_str)) { | |
| 5713 return error::kInvalidArguments; | |
| 5714 } | |
| 5715 return DoBindFragDataLocation(program, colorNumber, name_str.c_str()); | |
| 5716 } | |
| 5717 | |
| 5718 error::Error GLES2DecoderImpl::DoBindFragDataLocationIndexed(GLuint program_id, | |
| 5719 GLuint colorName, | |
| 5720 GLuint index, | |
| 5721 const char* name) { | |
| 5722 if (!unsafe_es3_apis_enabled()) | |
| 5723 return error::kUnknownCommand; | |
| 5724 | |
| 5725 const char kFunctionName[] = "glBindFragDataLocationIndexEXT"; | |
| 5726 if (!StringIsValidForGLES(name)) { | |
| 5727 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Invalid character"); | |
| 5728 return error::kNoError; | |
| 5729 } | |
| 5730 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { | |
| 5731 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix"); | |
| 5732 return error::kNoError; | |
| 5733 } | |
| 5734 if ((index == 0 && colorName >= group_->max_draw_buffers()) || | |
| 5735 (index == 1 && colorName >= group_->max_dual_source_draw_buffers())) { | |
| 5736 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | |
| 5737 "colorName out of range for the color index"); | |
| 5738 return error::kNoError; | |
| 5739 } | |
| 5740 Program* program = GetProgramInfoNotShader(program_id, kFunctionName); | |
| 5741 if (!program) { | |
| 5742 return error::kNoError; | |
| 5743 } | |
| 5744 DCHECK(!IsWebGLContext()); | |
| 5745 // Note: the name is passed directly, since names are never hashed for | |
| 5746 // non-WebGL context. Also the | |
| 5747 // potential built-in names can not be controlled by the client, since they | |
| 5748 // will be overridden if | |
| 5749 // used. | |
| 5750 glBindFragDataLocationIndexed(program->service_id(), colorName, index, name); | |
| 5751 return error::kNoError; | |
| 5752 } | |
| 5753 | |
| 5754 error::Error GLES2DecoderImpl::HandleBindFragDataLocationIndexedEXTBucket( | |
| 5755 uint32 immediate_data_size, | |
| 5756 const void* cmd_data) { | |
| 5757 const gles2::cmds::BindFragDataLocationIndexedEXTBucket& c = | |
| 5758 *static_cast<const gles2::cmds::BindFragDataLocationIndexedEXTBucket*>( | |
| 5759 cmd_data); | |
| 5760 GLuint program = static_cast<GLuint>(c.program); | |
| 5761 GLuint colorNumber = static_cast<GLint>(c.colorNumber); | |
| 5762 GLuint index = static_cast<GLint>(c.index); | |
| 5763 Bucket* bucket = GetBucket(c.name_bucket_id); | |
| 5764 if (!bucket || bucket->size() == 0) { | |
| 5765 return error::kInvalidArguments; | |
| 5766 } | |
| 5767 std::string name_str; | |
| 5768 if (!bucket->GetAsString(&name_str)) { | |
| 5769 return error::kInvalidArguments; | |
| 5770 } | |
| 5771 return DoBindFragDataLocationIndexed(program, colorNumber, index, | |
| 5772 name_str.c_str()); | |
| 5773 } | |
| 5774 | |
| 5643 void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM( | 5775 void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM( |
| 5644 GLuint program_id, GLint location, const char* name) { | 5776 GLuint program_id, GLint location, const char* name) { |
| 5645 if (!StringIsValidForGLES(name)) { | 5777 if (!StringIsValidForGLES(name)) { |
| 5646 LOCAL_SET_GL_ERROR( | 5778 LOCAL_SET_GL_ERROR( |
| 5647 GL_INVALID_VALUE, | 5779 GL_INVALID_VALUE, |
| 5648 "glBindUniformLocationCHROMIUM", "Invalid character"); | 5780 "glBindUniformLocationCHROMIUM", "Invalid character"); |
| 5649 return; | 5781 return; |
| 5650 } | 5782 } |
| 5651 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { | 5783 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { |
| 5652 LOCAL_SET_GL_ERROR( | 5784 LOCAL_SET_GL_ERROR( |
| (...skipping 3534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9187 result->SetNumResults(count); | 9319 result->SetNumResults(count); |
| 9188 } else { | 9320 } else { |
| 9189 LOCAL_SET_GL_ERROR(error, "GetUniformIndices", ""); | 9321 LOCAL_SET_GL_ERROR(error, "GetUniformIndices", ""); |
| 9190 } | 9322 } |
| 9191 return error::kNoError; | 9323 return error::kNoError; |
| 9192 } | 9324 } |
| 9193 | 9325 |
| 9194 error::Error GLES2DecoderImpl::GetFragDataLocationHelper( | 9326 error::Error GLES2DecoderImpl::GetFragDataLocationHelper( |
| 9195 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 9327 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 9196 const std::string& name_str) { | 9328 const std::string& name_str) { |
| 9329 const char kFunctionName[] = "glGetFragDataLocation"; | |
| 9197 GLint* location = GetSharedMemoryAs<GLint*>( | 9330 GLint* location = GetSharedMemoryAs<GLint*>( |
| 9198 location_shm_id, location_shm_offset, sizeof(GLint)); | 9331 location_shm_id, location_shm_offset, sizeof(GLint)); |
| 9199 if (!location) { | 9332 if (!location) { |
| 9200 return error::kOutOfBounds; | 9333 return error::kOutOfBounds; |
| 9201 } | 9334 } |
| 9202 // Require the client to init this incase the context is lost and we are no | 9335 // Require the client to init this incase the context is lost and we are no |
| 9203 // longer executing commands. | 9336 // longer executing commands. |
| 9204 if (*location != -1) { | 9337 if (*location != -1) { |
| 9205 return error::kGenericError; | 9338 return error::kGenericError; |
| 9206 } | 9339 } |
| 9207 Program* program = GetProgramInfoNotShader( | 9340 Program* program = GetProgramInfoNotShader(client_id, kFunctionName); |
| 9208 client_id, "glGetFragDataLocation"); | |
| 9209 if (!program) { | 9341 if (!program) { |
| 9210 return error::kNoError; | 9342 return error::kNoError; |
| 9211 } | 9343 } |
| 9212 *location = glGetFragDataLocation(program->service_id(), name_str.c_str()); | 9344 if (!program->IsValid()) { |
| 9345 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 9346 "program not linked"); | |
| 9347 return error::kNoError; | |
| 9348 } | |
|
Mark Kilgard
2015/08/28 19:53:24
yes, good to add this link check here
| |
| 9349 | |
| 9350 *location = program->GetFragDataLocation(name_str); | |
| 9213 return error::kNoError; | 9351 return error::kNoError; |
| 9214 } | 9352 } |
| 9215 | 9353 |
| 9216 error::Error GLES2DecoderImpl::HandleGetFragDataLocation( | 9354 error::Error GLES2DecoderImpl::HandleGetFragDataLocation( |
| 9217 uint32 immediate_data_size, | 9355 uint32 immediate_data_size, |
| 9218 const void* cmd_data) { | 9356 const void* cmd_data) { |
| 9219 if (!unsafe_es3_apis_enabled()) | 9357 if (!unsafe_es3_apis_enabled()) |
| 9220 return error::kUnknownCommand; | 9358 return error::kUnknownCommand; |
| 9221 const gles2::cmds::GetFragDataLocation& c = | 9359 const gles2::cmds::GetFragDataLocation& c = |
| 9222 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data); | 9360 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data); |
| 9223 Bucket* bucket = GetBucket(c.name_bucket_id); | 9361 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 9224 if (!bucket) { | 9362 if (!bucket) { |
| 9225 return error::kInvalidArguments; | 9363 return error::kInvalidArguments; |
| 9226 } | 9364 } |
| 9227 std::string name_str; | 9365 std::string name_str; |
| 9228 if (!bucket->GetAsString(&name_str)) { | 9366 if (!bucket->GetAsString(&name_str)) { |
| 9229 return error::kInvalidArguments; | 9367 return error::kInvalidArguments; |
| 9230 } | 9368 } |
| 9231 return GetFragDataLocationHelper( | 9369 return GetFragDataLocationHelper( |
| 9232 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 9370 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
| 9233 } | 9371 } |
| 9234 | 9372 |
| 9373 error::Error GLES2DecoderImpl::GetFragDataIndexHelper( | |
| 9374 GLuint program_id, | |
| 9375 uint32 index_shm_id, | |
| 9376 uint32 index_shm_offset, | |
| 9377 const std::string& name_str) { | |
| 9378 const char kFunctionName[] = "glGetFragDataIndexEXT"; | |
| 9379 GLint* index = | |
| 9380 GetSharedMemoryAs<GLint*>(index_shm_id, index_shm_offset, sizeof(GLint)); | |
| 9381 if (!index) { | |
| 9382 return error::kOutOfBounds; | |
| 9383 } | |
| 9384 // Require the client to init this incase the context is lost and we are no | |
| 9385 // longer executing commands. | |
| 9386 if (*index != -1) { | |
| 9387 return error::kGenericError; | |
| 9388 } | |
| 9389 Program* program = GetProgramInfoNotShader(program_id, kFunctionName); | |
| 9390 if (!program) { | |
| 9391 return error::kNoError; | |
| 9392 } | |
| 9393 if (!program->IsValid()) { | |
| 9394 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 9395 "program not linked"); | |
| 9396 return error::kNoError; | |
| 9397 } | |
| 9398 | |
| 9399 *index = program->GetFragDataIndex(name_str); | |
| 9400 return error::kNoError; | |
| 9401 } | |
| 9402 | |
| 9403 error::Error GLES2DecoderImpl::HandleGetFragDataIndexEXT( | |
| 9404 uint32 immediate_data_size, | |
| 9405 const void* cmd_data) { | |
| 9406 if (!unsafe_es3_apis_enabled()) | |
| 9407 return error::kUnknownCommand; | |
| 9408 const gles2::cmds::GetFragDataIndexEXT& c = | |
| 9409 *static_cast<const gles2::cmds::GetFragDataIndexEXT*>(cmd_data); | |
| 9410 Bucket* bucket = GetBucket(c.name_bucket_id); | |
| 9411 if (!bucket) { | |
| 9412 return error::kInvalidArguments; | |
| 9413 } | |
| 9414 std::string name_str; | |
| 9415 if (!bucket->GetAsString(&name_str)) { | |
| 9416 return error::kInvalidArguments; | |
| 9417 } | |
| 9418 return GetFragDataIndexHelper(c.program, c.index_shm_id, c.index_shm_offset, | |
| 9419 | |
| 9420 name_str); | |
| 9421 } | |
| 9422 | |
| 9235 error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex( | 9423 error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex( |
| 9236 uint32 immediate_data_size, const void* cmd_data) { | 9424 uint32 immediate_data_size, const void* cmd_data) { |
| 9237 if (!unsafe_es3_apis_enabled()) | 9425 if (!unsafe_es3_apis_enabled()) |
| 9238 return error::kUnknownCommand; | 9426 return error::kUnknownCommand; |
| 9239 const gles2::cmds::GetUniformBlockIndex& c = | 9427 const gles2::cmds::GetUniformBlockIndex& c = |
| 9240 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data); | 9428 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data); |
| 9241 Bucket* bucket = GetBucket(c.name_bucket_id); | 9429 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 9242 if (!bucket) { | 9430 if (!bucket) { |
| 9243 return error::kInvalidArguments; | 9431 return error::kInvalidArguments; |
| 9244 } | 9432 } |
| (...skipping 6219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15464 return error::kNoError; | 15652 return error::kNoError; |
| 15465 } | 15653 } |
| 15466 | 15654 |
| 15467 // Include the auto-generated part of this file. We split this because it means | 15655 // Include the auto-generated part of this file. We split this because it means |
| 15468 // we can easily edit the non-auto generated parts right here in this file | 15656 // we can easily edit the non-auto generated parts right here in this file |
| 15469 // instead of having to edit some template or the code generator. | 15657 // instead of having to edit some template or the code generator. |
| 15470 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15658 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15471 | 15659 |
| 15472 } // namespace gles2 | 15660 } // namespace gles2 |
| 15473 } // namespace gpu | 15661 } // namespace gpu |
| OLD | NEW |