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

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

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: address review comments Created 5 years, 2 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 <cmath> 10 #include <cmath>
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 // Horizontal tab, line feed, vertical tab, form feed, carriage return 319 // Horizontal tab, line feed, vertical tab, form feed, carriage return
320 // are also valid. 320 // are also valid.
321 if (c >= 9 && c <= 13) { 321 if (c >= 9 && c <= 13) {
322 return true; 322 return true;
323 } 323 }
324 324
325 return false; 325 return false;
326 } 326 }
327 327
328 static bool StringIsValidForGLES(const char* str) { 328 static bool StringIsValidForGLES(const std::string& str) {
329 for (; *str; ++str) { 329 return str.length() == 0 ||
330 if (!CharacterIsValidForGLES(*str)) { 330 std::find_if_not(str.begin(), str.end(), CharacterIsValidForGLES) ==
331 return false; 331 str.end();
332 }
333 }
334 return true;
335 } 332 }
336 333
337 // This class prevents any GL errors that occur when it is in scope from 334 // This class prevents any GL errors that occur when it is in scope from
338 // being reported to the client. 335 // being reported to the client.
339 class ScopedGLErrorSuppressor { 336 class ScopedGLErrorSuppressor {
340 public: 337 public:
341 explicit ScopedGLErrorSuppressor( 338 explicit ScopedGLErrorSuppressor(
342 const char* function_name, ErrorState* error_state); 339 const char* function_name, ErrorState* error_state);
343 ~ScopedGLErrorSuppressor(); 340 ~ScopedGLErrorSuppressor();
344 private: 341 private:
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 1262
1266 // Creates a vertex attrib manager for the given vertex array. 1263 // Creates a vertex attrib manager for the given vertex array.
1267 scoped_refptr<VertexAttribManager> CreateVertexAttribManager( 1264 scoped_refptr<VertexAttribManager> CreateVertexAttribManager(
1268 GLuint client_id, 1265 GLuint client_id,
1269 GLuint service_id, 1266 GLuint service_id,
1270 bool client_visible) { 1267 bool client_visible) {
1271 return vertex_array_manager()->CreateVertexAttribManager( 1268 return vertex_array_manager()->CreateVertexAttribManager(
1272 client_id, service_id, group_->max_vertex_attribs(), client_visible); 1269 client_id, service_id, group_->max_vertex_attribs(), client_visible);
1273 } 1270 }
1274 1271
1275 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); 1272 void DoBindAttribLocation(GLuint client_id,
1276 void DoBindUniformLocationCHROMIUM( 1273 GLuint index,
1277 GLuint client_id, GLint location, const char* name); 1274 const std::string& name);
1275
1276 error::Error DoBindFragDataLocation(GLuint program_id,
1277 GLuint colorName,
1278 const std::string& name);
1279
1280 error::Error DoBindFragDataLocationIndexed(GLuint program_id,
1281 GLuint colorName,
1282 GLuint index,
1283 const std::string& name);
1284
1285 void DoBindUniformLocationCHROMIUM(GLuint client_id,
1286 GLint location,
1287 const std::string& name);
1278 1288
1279 error::Error GetAttribLocationHelper( 1289 error::Error GetAttribLocationHelper(
1280 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1290 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1281 const std::string& name_str); 1291 const std::string& name_str);
1282 1292
1283 error::Error GetUniformLocationHelper( 1293 error::Error GetUniformLocationHelper(
1284 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1294 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1285 const std::string& name_str); 1295 const std::string& name_str);
1286 1296
1287 error::Error GetFragDataLocationHelper( 1297 error::Error GetFragDataLocationHelper(
1288 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 1298 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
1289 const std::string& name_str); 1299 const std::string& name_str);
1290 1300
1301 error::Error GetFragDataIndexHelper(GLuint program_id,
1302 uint32 index_shm_id,
1303 uint32 index_shm_offset,
1304 const std::string& name_str);
1305
1291 // Wrapper for glShaderSource. 1306 // Wrapper for glShaderSource.
1292 void DoShaderSource( 1307 void DoShaderSource(
1293 GLuint client_id, GLsizei count, const char** data, const GLint* length); 1308 GLuint client_id, GLsizei count, const char** data, const GLint* length);
1294 1309
1295 // Wrapper for glTransformFeedbackVaryings. 1310 // Wrapper for glTransformFeedbackVaryings.
1296 void DoTransformFeedbackVaryings( 1311 void DoTransformFeedbackVaryings(
1297 GLuint client_program_id, GLsizei count, const char* const* varyings, 1312 GLuint client_program_id, GLsizei count, const char* const* varyings,
1298 GLenum buffer_mode); 1313 GLenum buffer_mode);
1299 1314
1300 // Clear any textures used by the current program. 1315 // Clear any textures used by the current program.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 GLenum transform_type, 1956 GLenum transform_type,
1942 uint32 transforms_shm_id, 1957 uint32 transforms_shm_id,
1943 uint32 transforms_shm_offset, 1958 uint32 transforms_shm_offset,
1944 error::Error* out_error, 1959 error::Error* out_error,
1945 GLuint** out_paths, 1960 GLuint** out_paths,
1946 const GLfloat** out_transforms, 1961 const GLfloat** out_transforms,
1947 scoped_ptr<GLuint[]>* out_temp_path_buffer); 1962 scoped_ptr<GLuint[]>* out_temp_path_buffer);
1948 1963
1949 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, 1964 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id,
1950 GLint location, 1965 GLint location,
1951 const char* name); 1966 const std::string& name);
1952 1967
1953 // Generate a member function prototype for each command in an automated and 1968 // Generate a member function prototype for each command in an automated and
1954 // typesafe way. 1969 // typesafe way.
1955 #define GLES2_CMD_OP(name) \ 1970 #define GLES2_CMD_OP(name) \
1956 Error Handle##name(uint32 immediate_data_size, const void* data); 1971 Error Handle##name(uint32 immediate_data_size, const void* data);
1957 1972
1958 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1973 GLES2_COMMAND_LIST(GLES2_CMD_OP)
1959 1974
1960 #undef GLES2_CMD_OP 1975 #undef GLES2_CMD_OP
1961 1976
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 resources.MaxVaryingVectors = group_->max_varying_vectors(); 3273 resources.MaxVaryingVectors = group_->max_varying_vectors();
3259 resources.MaxVertexTextureImageUnits = 3274 resources.MaxVertexTextureImageUnits =
3260 group_->max_vertex_texture_image_units(); 3275 group_->max_vertex_texture_image_units();
3261 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); 3276 resources.MaxCombinedTextureImageUnits = group_->max_texture_units();
3262 resources.MaxTextureImageUnits = group_->max_texture_image_units(); 3277 resources.MaxTextureImageUnits = group_->max_texture_image_units();
3263 resources.MaxFragmentUniformVectors = 3278 resources.MaxFragmentUniformVectors =
3264 group_->max_fragment_uniform_vectors(); 3279 group_->max_fragment_uniform_vectors();
3265 resources.MaxDrawBuffers = group_->max_draw_buffers(); 3280 resources.MaxDrawBuffers = group_->max_draw_buffers();
3266 resources.MaxExpressionComplexity = 256; 3281 resources.MaxExpressionComplexity = 256;
3267 resources.MaxCallStackDepth = 256; 3282 resources.MaxCallStackDepth = 256;
3283 resources.MaxDualSourceDrawBuffers = group_->max_dual_source_draw_buffers();
3268 3284
3269 GLint range[2] = { 0, 0 }; 3285 GLint range[2] = { 0, 0 };
3270 GLint precision = 0; 3286 GLint precision = 0;
3271 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, 3287 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
3272 range, &precision); 3288 range, &precision);
3273 resources.FragmentPrecisionHigh = 3289 resources.FragmentPrecisionHigh =
3274 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); 3290 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision);
3275 3291
3276 if (IsWebGLContext()) { 3292 if (IsWebGLContext()) {
3277 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; 3293 resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
(...skipping 12 matching lines...) Expand all
3290 resources.OES_EGL_image_external = 3306 resources.OES_EGL_image_external =
3291 features().oes_egl_image_external ? 1 : 0; 3307 features().oes_egl_image_external ? 1 : 0;
3292 resources.EXT_draw_buffers = 3308 resources.EXT_draw_buffers =
3293 features().ext_draw_buffers ? 1 : 0; 3309 features().ext_draw_buffers ? 1 : 0;
3294 resources.EXT_frag_depth = 3310 resources.EXT_frag_depth =
3295 features().ext_frag_depth ? 1 : 0; 3311 features().ext_frag_depth ? 1 : 0;
3296 resources.EXT_shader_texture_lod = 3312 resources.EXT_shader_texture_lod =
3297 features().ext_shader_texture_lod ? 1 : 0; 3313 features().ext_shader_texture_lod ? 1 : 0;
3298 resources.NV_draw_buffers = 3314 resources.NV_draw_buffers =
3299 features().nv_draw_buffers ? 1 : 0; 3315 features().nv_draw_buffers ? 1 : 0;
3316 resources.EXT_blend_func_extended =
3317 features().ext_blend_func_extended ? 1 : 0;
3300 } 3318 }
3301 3319
3302 ShShaderSpec shader_spec; 3320 ShShaderSpec shader_spec;
3303 switch (context_type_) { 3321 switch (context_type_) {
3304 case CONTEXT_TYPE_WEBGL1: 3322 case CONTEXT_TYPE_WEBGL1:
3305 shader_spec = SH_WEBGL_SPEC; 3323 shader_spec = SH_WEBGL_SPEC;
3306 break; 3324 break;
3307 case CONTEXT_TYPE_WEBGL2: 3325 case CONTEXT_TYPE_WEBGL2:
3308 shader_spec = SH_WEBGL2_SPEC; 3326 shader_spec = SH_WEBGL2_SPEC;
3309 break; 3327 break;
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 *params = 0; 5529 *params = 0;
5512 } 5530 }
5513 } 5531 }
5514 return true; 5532 return true;
5515 case GL_BIND_GENERATES_RESOURCE_CHROMIUM: 5533 case GL_BIND_GENERATES_RESOURCE_CHROMIUM:
5516 *num_written = 1; 5534 *num_written = 1;
5517 if (params) { 5535 if (params) {
5518 params[0] = group_->bind_generates_resource() ? 1 : 0; 5536 params[0] = group_->bind_generates_resource() ? 1 : 0;
5519 } 5537 }
5520 return true; 5538 return true;
5539 case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS:
Zhenyao Mo 2015/09/30 00:23:47 Use _EXT instead.
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
5540 *num_written = 1;
5541 if (params) {
5542 params[0] = group_->max_dual_source_draw_buffers();
5543 }
5544 return true;
5521 default: 5545 default:
5522 if (pname >= GL_DRAW_BUFFER0_ARB && 5546 if (pname >= GL_DRAW_BUFFER0_ARB &&
5523 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { 5547 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) {
5524 *num_written = 1; 5548 *num_written = 1;
5525 if (params) { 5549 if (params) {
5526 Framebuffer* framebuffer = 5550 Framebuffer* framebuffer =
5527 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); 5551 GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
5528 if (framebuffer) { 5552 if (framebuffer) {
5529 params[0] = framebuffer->GetDrawBuffer(pname); 5553 params[0] = framebuffer->GetDrawBuffer(pname);
5530 } else { // backbuffer 5554 } else { // backbuffer
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5640 &state_, target, pname, params); 5664 &state_, target, pname, params);
5641 } 5665 }
5642 5666
5643 void GLES2DecoderImpl::DoGetBufferParameteriv( 5667 void GLES2DecoderImpl::DoGetBufferParameteriv(
5644 GLenum target, GLenum pname, GLint* params) { 5668 GLenum target, GLenum pname, GLint* params) {
5645 // Just delegate it. Some validation is actually done before this. 5669 // Just delegate it. Some validation is actually done before this.
5646 buffer_manager()->ValidateAndDoGetBufferParameteriv( 5670 buffer_manager()->ValidateAndDoGetBufferParameteriv(
5647 &state_, target, pname, params); 5671 &state_, target, pname, params);
5648 } 5672 }
5649 5673
5650 void GLES2DecoderImpl::DoBindAttribLocation( 5674 void GLES2DecoderImpl::DoBindAttribLocation(GLuint program_id,
5651 GLuint program_id, GLuint index, const char* name) { 5675 GLuint index,
5676 const std::string& name) {
5652 if (!StringIsValidForGLES(name)) { 5677 if (!StringIsValidForGLES(name)) {
5653 LOCAL_SET_GL_ERROR( 5678 LOCAL_SET_GL_ERROR(
5654 GL_INVALID_VALUE, "glBindAttribLocation", "Invalid character"); 5679 GL_INVALID_VALUE, "glBindAttribLocation", "Invalid character");
5655 return; 5680 return;
5656 } 5681 }
5657 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { 5682 if (ProgramManager::HasBuiltInPrefix(name)) {
5658 LOCAL_SET_GL_ERROR( 5683 LOCAL_SET_GL_ERROR(
5659 GL_INVALID_OPERATION, "glBindAttribLocation", "reserved prefix"); 5684 GL_INVALID_OPERATION, "glBindAttribLocation", "reserved prefix");
5660 return; 5685 return;
5661 } 5686 }
5662 if (index >= group_->max_vertex_attribs()) { 5687 if (index >= group_->max_vertex_attribs()) {
5663 LOCAL_SET_GL_ERROR( 5688 LOCAL_SET_GL_ERROR(
5664 GL_INVALID_VALUE, "glBindAttribLocation", "index out of range"); 5689 GL_INVALID_VALUE, "glBindAttribLocation", "index out of range");
5665 return; 5690 return;
5666 } 5691 }
5667 Program* program = GetProgramInfoNotShader( 5692 Program* program = GetProgramInfoNotShader(
5668 program_id, "glBindAttribLocation"); 5693 program_id, "glBindAttribLocation");
5669 if (!program) { 5694 if (!program) {
5670 return; 5695 return;
5671 } 5696 }
5672 // At this point, the program's shaders may not be translated yet, 5697 // At this point, the program's shaders may not be translated yet,
5673 // therefore, we may not find the hashed attribute name. 5698 // therefore, we may not find the hashed attribute name.
5674 // glBindAttribLocation call with original name is useless. 5699 // glBindAttribLocation call with original name is useless.
5675 // So instead, we should simply cache the binding, and then call 5700 // So instead, we should simply cache the binding, and then call
5676 // Program::ExecuteBindAttribLocationCalls() right before link. 5701 // Program::ExecuteBindAttribLocationCalls() right before link.
5677 program->SetAttribLocationBinding(name, static_cast<GLint>(index)); 5702 program->SetAttribLocationBinding(name, static_cast<GLint>(index));
5678 // TODO(zmo): Get rid of the following glBindAttribLocation call. 5703 // TODO(zmo): Get rid of the following glBindAttribLocation call.
5679 glBindAttribLocation(program->service_id(), index, name); 5704 glBindAttribLocation(program->service_id(), index, name.c_str());
5680 } 5705 }
5681 5706
5682 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( 5707 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket(
5683 uint32 immediate_data_size, 5708 uint32 immediate_data_size,
5684 const void* cmd_data) { 5709 const void* cmd_data) {
5685 const gles2::cmds::BindAttribLocationBucket& c = 5710 const gles2::cmds::BindAttribLocationBucket& c =
5686 *static_cast<const gles2::cmds::BindAttribLocationBucket*>(cmd_data); 5711 *static_cast<const gles2::cmds::BindAttribLocationBucket*>(cmd_data);
5687 GLuint program = static_cast<GLuint>(c.program); 5712 GLuint program = static_cast<GLuint>(c.program);
5688 GLuint index = static_cast<GLuint>(c.index); 5713 GLuint index = static_cast<GLuint>(c.index);
5689 Bucket* bucket = GetBucket(c.name_bucket_id); 5714 Bucket* bucket = GetBucket(c.name_bucket_id);
5690 if (!bucket || bucket->size() == 0) { 5715 if (!bucket || bucket->size() == 0) {
5691 return error::kInvalidArguments; 5716 return error::kInvalidArguments;
5692 } 5717 }
5693 std::string name_str; 5718 std::string name_str;
5694 if (!bucket->GetAsString(&name_str)) { 5719 if (!bucket->GetAsString(&name_str)) {
5695 return error::kInvalidArguments; 5720 return error::kInvalidArguments;
5696 } 5721 }
5697 DoBindAttribLocation(program, index, name_str.c_str()); 5722 DoBindAttribLocation(program, index, name_str);
5698 return error::kNoError; 5723 return error::kNoError;
5699 } 5724 }
5700 5725
5701 void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM( 5726 error::Error GLES2DecoderImpl::DoBindFragDataLocation(GLuint program_id,
5702 GLuint program_id, GLint location, const char* name) { 5727 GLuint colorName,
5728 const std::string& name) {
5729 const char kFunctionName[] = "glBindFragDataLocationEXT";
5730 if (!StringIsValidForGLES(name)) {
5731 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid character");
5732 return error::kNoError;
5733 }
5734 if (ProgramManager::HasBuiltInPrefix(name)) {
5735 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
5736 return error::kNoError;
5737 }
5738 if (colorName >= group_->max_draw_buffers()) {
5739 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
5740 "colorName out of range");
5741 return error::kNoError;
5742 }
5743 Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
5744 if (!program) {
5745 return error::kNoError;
5746 }
5747 if (!program->SetProgramOutputLocationBinding(name, colorName)) {
5748 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "invalid name");
5749 return error::kNoError;
5750 }
5751 return error::kNoError;
5752 }
5753
5754 error::Error GLES2DecoderImpl::HandleBindFragDataLocationEXTBucket(
5755 uint32 immediate_data_size,
5756 const void* cmd_data) {
5757 if (!features().ext_blend_func_extended) {
5758 return error::kUnknownCommand;
5759 }
5760 const gles2::cmds::BindFragDataLocationEXTBucket& c =
5761 *static_cast<const gles2::cmds::BindFragDataLocationEXTBucket*>(cmd_data);
5762 GLuint program = static_cast<GLuint>(c.program);
5763 GLuint colorNumber = static_cast<GLint>(c.colorNumber);
Zhenyao Mo 2015/09/30 00:23:47 static_cast<GLuint>
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
5764 Bucket* bucket = GetBucket(c.name_bucket_id);
5765 if (!bucket || bucket->size() == 0) {
5766 return error::kInvalidArguments;
5767 }
5768 std::string name_str;
5769 if (!bucket->GetAsString(&name_str)) {
5770 return error::kInvalidArguments;
5771 }
5772 return DoBindFragDataLocation(program, colorNumber, name_str);
5773 }
5774
5775 error::Error GLES2DecoderImpl::DoBindFragDataLocationIndexed(
5776 GLuint program_id,
5777 GLuint colorName,
5778 GLuint index,
5779 const std::string& name) {
5780 const char kFunctionName[] = "glBindFragDataLocationIndexEXT";
5781 if (!StringIsValidForGLES(name)) {
5782 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid character");
5783 return error::kNoError;
5784 }
5785 if (ProgramManager::HasBuiltInPrefix(name)) {
5786 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
5787 return error::kNoError;
5788 }
5789 if ((index == 0 && colorName >= group_->max_draw_buffers()) ||
Zhenyao Mo 2015/09/30 00:23:47 You should validate index == 0 || index == 1) firs
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
5790 (index == 1 && colorName >= group_->max_dual_source_draw_buffers())) {
5791 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
5792 "colorName out of range for the color index");
5793 return error::kNoError;
5794 }
5795 Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
5796 if (!program) {
5797 return error::kNoError;
5798 }
5799 if (!program->SetProgramOutputLocationBinding(name, colorName, index)) {
5800 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "invalid name");
5801 return error::kNoError;
5802 }
5803 return error::kNoError;
5804 }
5805
5806 error::Error GLES2DecoderImpl::HandleBindFragDataLocationIndexedEXTBucket(
5807 uint32 immediate_data_size,
5808 const void* cmd_data) {
5809 if (!features().ext_blend_func_extended) {
5810 return error::kUnknownCommand;
5811 }
5812 const gles2::cmds::BindFragDataLocationIndexedEXTBucket& c =
5813 *static_cast<const gles2::cmds::BindFragDataLocationIndexedEXTBucket*>(
5814 cmd_data);
5815 GLuint program = static_cast<GLuint>(c.program);
5816 GLuint colorNumber = static_cast<GLint>(c.colorNumber);
Zhenyao Mo 2015/09/30 00:23:47 GLuint
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
5817 GLuint index = static_cast<GLint>(c.index);
Zhenyao Mo 2015/09/30 00:23:47 GLuint
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
5818 Bucket* bucket = GetBucket(c.name_bucket_id);
5819 if (!bucket || bucket->size() == 0) {
5820 return error::kInvalidArguments;
5821 }
5822 std::string name_str;
5823 if (!bucket->GetAsString(&name_str)) {
5824 return error::kInvalidArguments;
5825 }
5826 return DoBindFragDataLocationIndexed(program, colorNumber, index, name_str);
5827 }
5828
5829 void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM(GLuint program_id,
5830 GLint location,
5831 const std::string& name) {
5703 if (!StringIsValidForGLES(name)) { 5832 if (!StringIsValidForGLES(name)) {
5704 LOCAL_SET_GL_ERROR( 5833 LOCAL_SET_GL_ERROR(
5705 GL_INVALID_VALUE, 5834 GL_INVALID_VALUE,
5706 "glBindUniformLocationCHROMIUM", "Invalid character"); 5835 "glBindUniformLocationCHROMIUM", "Invalid character");
5707 return; 5836 return;
5708 } 5837 }
5709 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { 5838 if (ProgramManager::HasBuiltInPrefix(name)) {
5710 LOCAL_SET_GL_ERROR( 5839 LOCAL_SET_GL_ERROR(
5711 GL_INVALID_OPERATION, 5840 GL_INVALID_OPERATION,
5712 "glBindUniformLocationCHROMIUM", "reserved prefix"); 5841 "glBindUniformLocationCHROMIUM", "reserved prefix");
5713 return; 5842 return;
5714 } 5843 }
5715 if (location < 0 || static_cast<uint32>(location) >= 5844 if (location < 0 || static_cast<uint32>(location) >=
5716 (group_->max_fragment_uniform_vectors() + 5845 (group_->max_fragment_uniform_vectors() +
5717 group_->max_vertex_uniform_vectors()) * 4) { 5846 group_->max_vertex_uniform_vectors()) * 4) {
5718 LOCAL_SET_GL_ERROR( 5847 LOCAL_SET_GL_ERROR(
5719 GL_INVALID_VALUE, 5848 GL_INVALID_VALUE,
(...skipping 21 matching lines...) Expand all
5741 GLuint program = static_cast<GLuint>(c.program); 5870 GLuint program = static_cast<GLuint>(c.program);
5742 GLint location = static_cast<GLint>(c.location); 5871 GLint location = static_cast<GLint>(c.location);
5743 Bucket* bucket = GetBucket(c.name_bucket_id); 5872 Bucket* bucket = GetBucket(c.name_bucket_id);
5744 if (!bucket || bucket->size() == 0) { 5873 if (!bucket || bucket->size() == 0) {
5745 return error::kInvalidArguments; 5874 return error::kInvalidArguments;
5746 } 5875 }
5747 std::string name_str; 5876 std::string name_str;
5748 if (!bucket->GetAsString(&name_str)) { 5877 if (!bucket->GetAsString(&name_str)) {
5749 return error::kInvalidArguments; 5878 return error::kInvalidArguments;
5750 } 5879 }
5751 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); 5880 DoBindUniformLocationCHROMIUM(program, location, name_str);
5752 return error::kNoError; 5881 return error::kNoError;
5753 } 5882 }
5754 5883
5755 error::Error GLES2DecoderImpl::HandleDeleteShader(uint32 immediate_data_size, 5884 error::Error GLES2DecoderImpl::HandleDeleteShader(uint32 immediate_data_size,
5756 const void* cmd_data) { 5885 const void* cmd_data) {
5757 const gles2::cmds::DeleteShader& c = 5886 const gles2::cmds::DeleteShader& c =
5758 *static_cast<const gles2::cmds::DeleteShader*>(cmd_data); 5887 *static_cast<const gles2::cmds::DeleteShader*>(cmd_data);
5759 GLuint client_id = c.shader; 5888 GLuint client_id = c.shader;
5760 if (client_id) { 5889 if (client_id) {
5761 Shader* shader = GetShader(client_id); 5890 Shader* shader = GetShader(client_id);
(...skipping 3534 matching lines...) Expand 10 before | Expand all | Expand 10 after
9296 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 9425 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
9297 "glScheduleOverlayPlaneCHROMIUM", 9426 "glScheduleOverlayPlaneCHROMIUM",
9298 "failed to schedule overlay"); 9427 "failed to schedule overlay");
9299 } 9428 }
9300 return error::kNoError; 9429 return error::kNoError;
9301 } 9430 }
9302 9431
9303 error::Error GLES2DecoderImpl::GetAttribLocationHelper( 9432 error::Error GLES2DecoderImpl::GetAttribLocationHelper(
9304 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 9433 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
9305 const std::string& name_str) { 9434 const std::string& name_str) {
9306 if (!StringIsValidForGLES(name_str.c_str())) { 9435 if (!StringIsValidForGLES(name_str)) {
9307 LOCAL_SET_GL_ERROR( 9436 LOCAL_SET_GL_ERROR(
9308 GL_INVALID_VALUE, "glGetAttribLocation", "Invalid character"); 9437 GL_INVALID_VALUE, "glGetAttribLocation", "Invalid character");
9309 return error::kNoError; 9438 return error::kNoError;
9310 } 9439 }
9311 Program* program = GetProgramInfoNotShader( 9440 Program* program = GetProgramInfoNotShader(
9312 client_id, "glGetAttribLocation"); 9441 client_id, "glGetAttribLocation");
9313 if (!program) { 9442 if (!program) {
9314 return error::kNoError; 9443 return error::kNoError;
9315 } 9444 }
9316 if (!program->IsValid()) { 9445 if (!program->IsValid()) {
(...skipping 28 matching lines...) Expand all
9345 if (!bucket->GetAsString(&name_str)) { 9474 if (!bucket->GetAsString(&name_str)) {
9346 return error::kInvalidArguments; 9475 return error::kInvalidArguments;
9347 } 9476 }
9348 return GetAttribLocationHelper( 9477 return GetAttribLocationHelper(
9349 c.program, c.location_shm_id, c.location_shm_offset, name_str); 9478 c.program, c.location_shm_id, c.location_shm_offset, name_str);
9350 } 9479 }
9351 9480
9352 error::Error GLES2DecoderImpl::GetUniformLocationHelper( 9481 error::Error GLES2DecoderImpl::GetUniformLocationHelper(
9353 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 9482 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
9354 const std::string& name_str) { 9483 const std::string& name_str) {
9355 if (!StringIsValidForGLES(name_str.c_str())) { 9484 if (!StringIsValidForGLES(name_str)) {
9356 LOCAL_SET_GL_ERROR( 9485 LOCAL_SET_GL_ERROR(
9357 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character"); 9486 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character");
9358 return error::kNoError; 9487 return error::kNoError;
9359 } 9488 }
9360 Program* program = GetProgramInfoNotShader( 9489 Program* program = GetProgramInfoNotShader(
9361 client_id, "glGetUniformLocation"); 9490 client_id, "glGetUniformLocation");
9362 if (!program) { 9491 if (!program) {
9363 return error::kNoError; 9492 return error::kNoError;
9364 } 9493 }
9365 if (!program->IsValid()) { 9494 if (!program->IsValid()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
9446 result->SetNumResults(count); 9575 result->SetNumResults(count);
9447 } else { 9576 } else {
9448 LOCAL_SET_GL_ERROR(error, "GetUniformIndices", ""); 9577 LOCAL_SET_GL_ERROR(error, "GetUniformIndices", "");
9449 } 9578 }
9450 return error::kNoError; 9579 return error::kNoError;
9451 } 9580 }
9452 9581
9453 error::Error GLES2DecoderImpl::GetFragDataLocationHelper( 9582 error::Error GLES2DecoderImpl::GetFragDataLocationHelper(
9454 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 9583 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
9455 const std::string& name_str) { 9584 const std::string& name_str) {
9585 const char kFunctionName[] = "glGetFragDataLocation";
9456 GLint* location = GetSharedMemoryAs<GLint*>( 9586 GLint* location = GetSharedMemoryAs<GLint*>(
9457 location_shm_id, location_shm_offset, sizeof(GLint)); 9587 location_shm_id, location_shm_offset, sizeof(GLint));
9458 if (!location) { 9588 if (!location) {
9459 return error::kOutOfBounds; 9589 return error::kOutOfBounds;
9460 } 9590 }
9461 // Require the client to init this incase the context is lost and we are no 9591 // Require the client to init this incase the context is lost and we are no
9462 // longer executing commands. 9592 // longer executing commands.
9463 if (*location != -1) { 9593 if (*location != -1) {
9464 return error::kGenericError; 9594 return error::kGenericError;
9465 } 9595 }
9466 Program* program = GetProgramInfoNotShader( 9596 Program* program = GetProgramInfoNotShader(client_id, kFunctionName);
9467 client_id, "glGetFragDataLocation");
9468 if (!program) { 9597 if (!program) {
9469 return error::kNoError; 9598 return error::kNoError;
9470 } 9599 }
9471 *location = glGetFragDataLocation(program->service_id(), name_str.c_str()); 9600 if (!program->IsValid()) {
9601 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
9602 "program not linked");
9603 return error::kNoError;
9604 }
9605
9606 *location = program->GetFragDataLocation(name_str);
9472 return error::kNoError; 9607 return error::kNoError;
9473 } 9608 }
9474 9609
9475 error::Error GLES2DecoderImpl::HandleGetFragDataLocation( 9610 error::Error GLES2DecoderImpl::HandleGetFragDataLocation(
9476 uint32 immediate_data_size, 9611 uint32 immediate_data_size,
9477 const void* cmd_data) { 9612 const void* cmd_data) {
9478 if (!unsafe_es3_apis_enabled()) 9613 if (!unsafe_es3_apis_enabled())
9479 return error::kUnknownCommand; 9614 return error::kUnknownCommand;
9480 const gles2::cmds::GetFragDataLocation& c = 9615 const gles2::cmds::GetFragDataLocation& c =
9481 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data); 9616 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data);
9482 Bucket* bucket = GetBucket(c.name_bucket_id); 9617 Bucket* bucket = GetBucket(c.name_bucket_id);
9483 if (!bucket) { 9618 if (!bucket) {
9484 return error::kInvalidArguments; 9619 return error::kInvalidArguments;
9485 } 9620 }
9486 std::string name_str; 9621 std::string name_str;
9487 if (!bucket->GetAsString(&name_str)) { 9622 if (!bucket->GetAsString(&name_str)) {
9488 return error::kInvalidArguments; 9623 return error::kInvalidArguments;
9489 } 9624 }
9490 return GetFragDataLocationHelper( 9625 return GetFragDataLocationHelper(
9491 c.program, c.location_shm_id, c.location_shm_offset, name_str); 9626 c.program, c.location_shm_id, c.location_shm_offset, name_str);
9492 } 9627 }
9493 9628
9629 error::Error GLES2DecoderImpl::GetFragDataIndexHelper(
9630 GLuint program_id,
9631 uint32 index_shm_id,
9632 uint32 index_shm_offset,
9633 const std::string& name_str) {
9634 const char kFunctionName[] = "glGetFragDataIndexEXT";
9635 GLint* index =
9636 GetSharedMemoryAs<GLint*>(index_shm_id, index_shm_offset, sizeof(GLint));
9637 if (!index) {
9638 return error::kOutOfBounds;
9639 }
9640 // Require the client to init this incase the context is lost and we are no
9641 // longer executing commands.
9642 if (*index != -1) {
9643 return error::kGenericError;
Zhenyao Mo 2015/09/30 00:23:47 We return kInvalidArguments in such cases.
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
9644 }
9645 Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
9646 if (!program) {
9647 return error::kNoError;
9648 }
9649 if (!program->IsValid()) {
9650 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
9651 "program not linked");
9652 return error::kNoError;
9653 }
9654
9655 *index = program->GetFragDataIndex(name_str);
9656 return error::kNoError;
9657 }
9658
9659 error::Error GLES2DecoderImpl::HandleGetFragDataIndexEXT(
9660 uint32 immediate_data_size,
9661 const void* cmd_data) {
9662 if (!features().ext_blend_func_extended) {
9663 return error::kUnknownCommand;
9664 }
9665 const gles2::cmds::GetFragDataIndexEXT& c =
9666 *static_cast<const gles2::cmds::GetFragDataIndexEXT*>(cmd_data);
9667 Bucket* bucket = GetBucket(c.name_bucket_id);
9668 if (!bucket) {
9669 return error::kInvalidArguments;
9670 }
9671 std::string name_str;
9672 if (!bucket->GetAsString(&name_str)) {
9673 return error::kInvalidArguments;
9674 }
9675 return GetFragDataIndexHelper(c.program, c.index_shm_id, c.index_shm_offset,
9676 name_str);
9677 }
9678
9494 error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex( 9679 error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex(
9495 uint32 immediate_data_size, const void* cmd_data) { 9680 uint32 immediate_data_size, const void* cmd_data) {
9496 if (!unsafe_es3_apis_enabled()) 9681 if (!unsafe_es3_apis_enabled())
9497 return error::kUnknownCommand; 9682 return error::kUnknownCommand;
9498 const gles2::cmds::GetUniformBlockIndex& c = 9683 const gles2::cmds::GetUniformBlockIndex& c =
9499 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data); 9684 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data);
9500 Bucket* bucket = GetBucket(c.name_bucket_id); 9685 Bucket* bucket = GetBucket(c.name_bucket_id);
9501 if (!bucket) { 9686 if (!bucket) {
9502 return error::kInvalidArguments; 9687 return error::kInvalidArguments;
9503 } 9688 }
(...skipping 6131 matching lines...) Expand 10 before | Expand all | Expand 10 after
15635 } 15820 }
15636 15821
15637 ApplyDirtyState(); 15822 ApplyDirtyState();
15638 glStencilThenCoverStrokePathInstancedNV(num_paths, path_name_type, paths, 0, 15823 glStencilThenCoverStrokePathInstancedNV(num_paths, path_name_type, paths, 0,
15639 reference, mask, cover_mode, 15824 reference, mask, cover_mode,
15640 transform_type, transforms); 15825 transform_type, transforms);
15641 15826
15642 return error::kNoError; 15827 return error::kNoError;
15643 } 15828 }
15644 15829
15645 void GLES2DecoderImpl::DoBindFragmentInputLocationCHROMIUM(GLuint program_id, 15830 void GLES2DecoderImpl::DoBindFragmentInputLocationCHROMIUM(
15646 GLint location, 15831 GLuint program_id,
15647 const char* name) { 15832 GLint location,
15833 const std::string& name) {
15648 static const char kFunctionName[] = "glBindFragmentInputLocationCHROMIUM"; 15834 static const char kFunctionName[] = "glBindFragmentInputLocationCHROMIUM";
15835 if (!StringIsValidForGLES(name)) {
15836 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid character");
15837 return;
15838 }
15839 if (ProgramManager::HasBuiltInPrefix(name)) {
15840 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
15841 return;
15842 }
15649 Program* program = GetProgram(program_id); 15843 Program* program = GetProgram(program_id);
15650 if (!program || program->IsDeleted()) { 15844 if (!program || program->IsDeleted()) {
15651 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "invalid program"); 15845 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "invalid program");
15652 return; 15846 return;
15653 } 15847 }
15654 if (!StringIsValidForGLES(name)) {
15655 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid character");
15656 return;
15657 }
15658 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
15659 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
15660 return;
15661 }
15662 if (location < 0 || 15848 if (location < 0 ||
15663 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) { 15849 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) {
15664 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 15850 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
15665 "location out of range"); 15851 "location out of range");
15666 return; 15852 return;
15667 } 15853 }
15668 15854
15669 if (!program->SetFragmentInputLocationBinding(name, location)) { 15855 if (!program->SetFragmentInputLocationBinding(name, location)) {
15670 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid name"); 15856 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid name");
15671 return; 15857 return;
(...skipping 13 matching lines...) Expand all
15685 GLuint program = static_cast<GLuint>(c.program); 15871 GLuint program = static_cast<GLuint>(c.program);
15686 GLint location = static_cast<GLint>(c.location); 15872 GLint location = static_cast<GLint>(c.location);
15687 Bucket* bucket = GetBucket(c.name_bucket_id); 15873 Bucket* bucket = GetBucket(c.name_bucket_id);
15688 if (!bucket || bucket->size() == 0) { 15874 if (!bucket || bucket->size() == 0) {
15689 return error::kInvalidArguments; 15875 return error::kInvalidArguments;
15690 } 15876 }
15691 std::string name_str; 15877 std::string name_str;
15692 if (!bucket->GetAsString(&name_str)) { 15878 if (!bucket->GetAsString(&name_str)) {
15693 return error::kInvalidArguments; 15879 return error::kInvalidArguments;
15694 } 15880 }
15695 DoBindFragmentInputLocationCHROMIUM(program, location, name_str.c_str()); 15881 DoBindFragmentInputLocationCHROMIUM(program, location, name_str);
15696 return error::kNoError; 15882 return error::kNoError;
15697 } 15883 }
15698 15884
15699 error::Error GLES2DecoderImpl::HandleProgramPathFragmentInputGenCHROMIUM( 15885 error::Error GLES2DecoderImpl::HandleProgramPathFragmentInputGenCHROMIUM(
15700 uint32 immediate_data_size, 15886 uint32 immediate_data_size,
15701 const void* cmd_data) { 15887 const void* cmd_data) {
15702 static const char kFunctionName[] = "glProgramPathFragmentInputGenCHROMIUM"; 15888 static const char kFunctionName[] = "glProgramPathFragmentInputGenCHROMIUM";
15703 const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM& c = 15889 const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM& c =
15704 *static_cast<const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM*>( 15890 *static_cast<const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM*>(
15705 cmd_data); 15891 cmd_data);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
15805 return error::kNoError; 15991 return error::kNoError;
15806 } 15992 }
15807 15993
15808 // Include the auto-generated part of this file. We split this because it means 15994 // Include the auto-generated part of this file. We split this because it means
15809 // we can easily edit the non-auto generated parts right here in this file 15995 // we can easily edit the non-auto generated parts right here in this file
15810 // instead of having to edit some template or the code generator. 15996 // instead of having to edit some template or the code generator.
15811 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15997 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15812 15998
15813 } // namespace gles2 15999 } // namespace gles2
15814 } // namespace gpu 16000 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698