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 <list> | 10 #include <list> |
(...skipping 4710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4721 } | 4721 } |
4722 Program* program = GetProgramInfoNotShader( | 4722 Program* program = GetProgramInfoNotShader( |
4723 program_id, "glBindAttribLocation"); | 4723 program_id, "glBindAttribLocation"); |
4724 if (!program) { | 4724 if (!program) { |
4725 return; | 4725 return; |
4726 } | 4726 } |
4727 program->SetAttribLocationBinding(name, static_cast<GLint>(index)); | 4727 program->SetAttribLocationBinding(name, static_cast<GLint>(index)); |
4728 glBindAttribLocation(program->service_id(), index, name); | 4728 glBindAttribLocation(program->service_id(), index, name); |
4729 } | 4729 } |
4730 | 4730 |
4731 error::Error GLES2DecoderImpl::HandleBindAttribLocation( | |
4732 uint32 immediate_data_size, const cmds::BindAttribLocation& c) { | |
4733 GLuint program = static_cast<GLuint>(c.program); | |
4734 GLuint index = static_cast<GLuint>(c.index); | |
4735 uint32 name_size = c.data_size; | |
4736 const char* name = GetSharedMemoryAs<const char*>( | |
4737 c.name_shm_id, c.name_shm_offset, name_size); | |
4738 if (name == NULL) { | |
4739 return error::kOutOfBounds; | |
4740 } | |
4741 std::string name_str(name, name_size); | |
4742 DoBindAttribLocation(program, index, name_str.c_str()); | |
4743 return error::kNoError; | |
4744 } | |
4745 | |
4746 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( | 4731 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( |
4747 uint32 immediate_data_size, const cmds::BindAttribLocationBucket& c) { | 4732 uint32 immediate_data_size, const cmds::BindAttribLocationBucket& c) { |
4748 GLuint program = static_cast<GLuint>(c.program); | 4733 GLuint program = static_cast<GLuint>(c.program); |
4749 GLuint index = static_cast<GLuint>(c.index); | 4734 GLuint index = static_cast<GLuint>(c.index); |
4750 Bucket* bucket = GetBucket(c.name_bucket_id); | 4735 Bucket* bucket = GetBucket(c.name_bucket_id); |
4751 if (!bucket || bucket->size() == 0) { | 4736 if (!bucket || bucket->size() == 0) { |
4752 return error::kInvalidArguments; | 4737 return error::kInvalidArguments; |
4753 } | 4738 } |
4754 std::string name_str; | 4739 std::string name_str; |
4755 if (!bucket->GetAsString(&name_str)) { | 4740 if (!bucket->GetAsString(&name_str)) { |
(...skipping 30 matching lines...) Expand all Loading... |
4786 if (!program) { | 4771 if (!program) { |
4787 return; | 4772 return; |
4788 } | 4773 } |
4789 if (!program->SetUniformLocationBinding(name, location)) { | 4774 if (!program->SetUniformLocationBinding(name, location)) { |
4790 LOCAL_SET_GL_ERROR( | 4775 LOCAL_SET_GL_ERROR( |
4791 GL_INVALID_VALUE, | 4776 GL_INVALID_VALUE, |
4792 "glBindUniformLocationCHROMIUM", "location out of range"); | 4777 "glBindUniformLocationCHROMIUM", "location out of range"); |
4793 } | 4778 } |
4794 } | 4779 } |
4795 | 4780 |
4796 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUM( | |
4797 uint32 immediate_data_size, const cmds::BindUniformLocationCHROMIUM& c) { | |
4798 GLuint program = static_cast<GLuint>(c.program); | |
4799 GLint location = static_cast<GLint>(c.location); | |
4800 uint32 name_size = c.data_size; | |
4801 const char* name = GetSharedMemoryAs<const char*>( | |
4802 c.name_shm_id, c.name_shm_offset, name_size); | |
4803 if (name == NULL) { | |
4804 return error::kOutOfBounds; | |
4805 } | |
4806 std::string name_str(name, name_size); | |
4807 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); | |
4808 return error::kNoError; | |
4809 } | |
4810 | |
4811 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket( | 4781 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket( |
4812 uint32 immediate_data_size, | 4782 uint32 immediate_data_size, |
4813 const cmds::BindUniformLocationCHROMIUMBucket& c) { | 4783 const cmds::BindUniformLocationCHROMIUMBucket& c) { |
4814 GLuint program = static_cast<GLuint>(c.program); | 4784 GLuint program = static_cast<GLuint>(c.program); |
4815 GLint location = static_cast<GLint>(c.location); | 4785 GLint location = static_cast<GLint>(c.location); |
4816 Bucket* bucket = GetBucket(c.name_bucket_id); | 4786 Bucket* bucket = GetBucket(c.name_bucket_id); |
4817 if (!bucket || bucket->size() == 0) { | 4787 if (!bucket || bucket->size() == 0) { |
4818 return error::kInvalidArguments; | 4788 return error::kInvalidArguments; |
4819 } | 4789 } |
4820 std::string name_str; | 4790 std::string name_str; |
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6694 Shader* shader = GetShaderInfoNotProgram(client_id, "glShaderSource"); | 6664 Shader* shader = GetShaderInfoNotProgram(client_id, "glShaderSource"); |
6695 if (!shader) { | 6665 if (!shader) { |
6696 return error::kNoError; | 6666 return error::kNoError; |
6697 } | 6667 } |
6698 // Note: We don't actually call glShaderSource here. We wait until | 6668 // Note: We don't actually call glShaderSource here. We wait until |
6699 // the call to glCompileShader. | 6669 // the call to glCompileShader. |
6700 shader->UpdateSource(str.c_str()); | 6670 shader->UpdateSource(str.c_str()); |
6701 return error::kNoError; | 6671 return error::kNoError; |
6702 } | 6672 } |
6703 | 6673 |
6704 error::Error GLES2DecoderImpl::HandleShaderSource( | |
6705 uint32 immediate_data_size, const cmds::ShaderSource& c) { | |
6706 uint32 data_size = c.data_size; | |
6707 const char* data = GetSharedMemoryAs<const char*>( | |
6708 c.data_shm_id, c.data_shm_offset, data_size); | |
6709 if (!data) { | |
6710 return error::kOutOfBounds; | |
6711 } | |
6712 return ShaderSourceHelper(c.shader, data, data_size); | |
6713 } | |
6714 | |
6715 error::Error GLES2DecoderImpl::HandleShaderSourceBucket( | 6674 error::Error GLES2DecoderImpl::HandleShaderSourceBucket( |
6716 uint32 immediate_data_size, const cmds::ShaderSourceBucket& c) { | 6675 uint32 immediate_data_size, const cmds::ShaderSourceBucket& c) { |
6717 Bucket* bucket = GetBucket(c.data_bucket_id); | 6676 Bucket* bucket = GetBucket(c.data_bucket_id); |
6718 if (!bucket || bucket->size() == 0) { | 6677 if (!bucket || bucket->size() == 0) { |
6719 return error::kInvalidArguments; | 6678 return error::kInvalidArguments; |
6720 } | 6679 } |
6721 return ShaderSourceHelper( | 6680 return ShaderSourceHelper( |
6722 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1), | 6681 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1), |
6723 bucket->size() - 1); | 6682 bucket->size() - 1); |
6724 } | 6683 } |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7630 // longer executing commands. | 7589 // longer executing commands. |
7631 if (*location != -1) { | 7590 if (*location != -1) { |
7632 return error::kGenericError; | 7591 return error::kGenericError; |
7633 } | 7592 } |
7634 *location = program->GetAttribLocation(name_str); | 7593 *location = program->GetAttribLocation(name_str); |
7635 return error::kNoError; | 7594 return error::kNoError; |
7636 } | 7595 } |
7637 | 7596 |
7638 error::Error GLES2DecoderImpl::HandleGetAttribLocation( | 7597 error::Error GLES2DecoderImpl::HandleGetAttribLocation( |
7639 uint32 immediate_data_size, const cmds::GetAttribLocation& c) { | 7598 uint32 immediate_data_size, const cmds::GetAttribLocation& c) { |
7640 uint32 name_size = c.data_size; | |
7641 const char* name = GetSharedMemoryAs<const char*>( | |
7642 c.name_shm_id, c.name_shm_offset, name_size); | |
7643 if (!name) { | |
7644 return error::kOutOfBounds; | |
7645 } | |
7646 std::string name_str(name, name_size); | |
7647 return GetAttribLocationHelper( | |
7648 c.program, c.location_shm_id, c.location_shm_offset, name_str); | |
7649 } | |
7650 | |
7651 error::Error GLES2DecoderImpl::HandleGetAttribLocationBucket( | |
7652 uint32 immediate_data_size, const cmds::GetAttribLocationBucket& c) { | |
7653 Bucket* bucket = GetBucket(c.name_bucket_id); | 7599 Bucket* bucket = GetBucket(c.name_bucket_id); |
7654 if (!bucket) { | 7600 if (!bucket) { |
7655 return error::kInvalidArguments; | 7601 return error::kInvalidArguments; |
7656 } | 7602 } |
7657 std::string name_str; | 7603 std::string name_str; |
7658 if (!bucket->GetAsString(&name_str)) { | 7604 if (!bucket->GetAsString(&name_str)) { |
7659 return error::kInvalidArguments; | 7605 return error::kInvalidArguments; |
7660 } | 7606 } |
7661 return GetAttribLocationHelper( | 7607 return GetAttribLocationHelper( |
7662 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 7608 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
(...skipping 26 matching lines...) Expand all Loading... |
7689 // longer executing commands. | 7635 // longer executing commands. |
7690 if (*location != -1) { | 7636 if (*location != -1) { |
7691 return error::kGenericError; | 7637 return error::kGenericError; |
7692 } | 7638 } |
7693 *location = program->GetUniformFakeLocation(name_str); | 7639 *location = program->GetUniformFakeLocation(name_str); |
7694 return error::kNoError; | 7640 return error::kNoError; |
7695 } | 7641 } |
7696 | 7642 |
7697 error::Error GLES2DecoderImpl::HandleGetUniformLocation( | 7643 error::Error GLES2DecoderImpl::HandleGetUniformLocation( |
7698 uint32 immediate_data_size, const cmds::GetUniformLocation& c) { | 7644 uint32 immediate_data_size, const cmds::GetUniformLocation& c) { |
7699 uint32 name_size = c.data_size; | |
7700 const char* name = GetSharedMemoryAs<const char*>( | |
7701 c.name_shm_id, c.name_shm_offset, name_size); | |
7702 if (!name) { | |
7703 return error::kOutOfBounds; | |
7704 } | |
7705 std::string name_str(name, name_size); | |
7706 return GetUniformLocationHelper( | |
7707 c.program, c.location_shm_id, c.location_shm_offset, name_str); | |
7708 } | |
7709 | |
7710 error::Error GLES2DecoderImpl::HandleGetUniformLocationBucket( | |
7711 uint32 immediate_data_size, const cmds::GetUniformLocationBucket& c) { | |
7712 Bucket* bucket = GetBucket(c.name_bucket_id); | 7645 Bucket* bucket = GetBucket(c.name_bucket_id); |
7713 if (!bucket) { | 7646 if (!bucket) { |
7714 return error::kInvalidArguments; | 7647 return error::kInvalidArguments; |
7715 } | 7648 } |
7716 std::string name_str; | 7649 std::string name_str; |
7717 if (!bucket->GetAsString(&name_str)) { | 7650 if (!bucket->GetAsString(&name_str)) { |
7718 return error::kInvalidArguments; | 7651 return error::kInvalidArguments; |
7719 } | 7652 } |
7720 return GetUniformLocationHelper( | 7653 return GetUniformLocationHelper( |
7721 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 7654 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10876 } | 10809 } |
10877 } | 10810 } |
10878 | 10811 |
10879 // Include the auto-generated part of this file. We split this because it means | 10812 // Include the auto-generated part of this file. We split this because it means |
10880 // we can easily edit the non-auto generated parts right here in this file | 10813 // we can easily edit the non-auto generated parts right here in this file |
10881 // instead of having to edit some template or the code generator. | 10814 // instead of having to edit some template or the code generator. |
10882 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10815 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10883 | 10816 |
10884 } // namespace gles2 | 10817 } // namespace gles2 |
10885 } // namespace gpu | 10818 } // namespace gpu |
OLD | NEW |