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 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1903 // and allow context preemption and GPU watchdog checks in GpuScheduler(). | 1903 // and allow context preemption and GPU watchdog checks in GpuScheduler(). |
1904 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } | 1904 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } |
1905 | 1905 |
1906 void ProcessPendingReadPixels(bool did_finish); | 1906 void ProcessPendingReadPixels(bool did_finish); |
1907 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1907 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1908 | 1908 |
1909 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, | 1909 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, |
1910 GLint location, | 1910 GLint location, |
1911 const std::string& name); | 1911 const std::string& name); |
1912 | 1912 |
1913 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); | |
1914 | |
1913 // Generate a member function prototype for each command in an automated and | 1915 // Generate a member function prototype for each command in an automated and |
1914 // typesafe way. | 1916 // typesafe way. |
1915 #define GLES2_CMD_OP(name) \ | 1917 #define GLES2_CMD_OP(name) \ |
1916 Error Handle##name(uint32 immediate_data_size, const void* data); | 1918 Error Handle##name(uint32 immediate_data_size, const void* data); |
1917 | 1919 |
1918 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1920 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1919 | 1921 |
1920 #undef GLES2_CMD_OP | 1922 #undef GLES2_CMD_OP |
1921 | 1923 |
1922 // The GL context this decoder renders to on behalf of the client. | 1924 // The GL context this decoder renders to on behalf of the client. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2103 uint16 arg_count; // How many arguments are expected for this command. | 2105 uint16 arg_count; // How many arguments are expected for this command. |
2104 }; | 2106 }; |
2105 | 2107 |
2106 // A table of CommandInfo for all the commands. | 2108 // A table of CommandInfo for all the commands. |
2107 static const CommandInfo command_info[kNumCommands - kStartPoint]; | 2109 static const CommandInfo command_info[kNumCommands - kStartPoint]; |
2108 | 2110 |
2109 bool force_shader_name_hashing_for_test; | 2111 bool force_shader_name_hashing_for_test; |
2110 | 2112 |
2111 GLfloat line_width_range_[2]; | 2113 GLfloat line_width_range_[2]; |
2112 | 2114 |
2115 SamplerState default_sampler_state_; | |
2116 | |
2113 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2117 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
2114 }; | 2118 }; |
2115 | 2119 |
2116 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2120 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
2117 #define GLES2_CMD_OP(name) \ | 2121 #define GLES2_CMD_OP(name) \ |
2118 { \ | 2122 { \ |
2119 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2123 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
2120 cmds::name::cmd_flags, \ | 2124 cmds::name::cmd_flags, \ |
2121 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2125 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
2122 } \ | 2126 } \ |
(...skipping 5526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7649 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 7653 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
7650 glBindTexture(textarget, texture->service_id()); | 7654 glBindTexture(textarget, texture->service_id()); |
7651 DoCopyTexImage(texture, textarget, image); | 7655 DoCopyTexImage(texture, textarget, image); |
7652 RestoreCurrentTextureBindings(&state_, textarget); | 7656 RestoreCurrentTextureBindings(&state_, textarget); |
7653 } | 7657 } |
7654 } | 7658 } |
7655 } | 7659 } |
7656 | 7660 |
7657 bool GLES2DecoderImpl::PrepareTexturesForRender() { | 7661 bool GLES2DecoderImpl::PrepareTexturesForRender() { |
7658 DCHECK(state_.current_program.get()); | 7662 DCHECK(state_.current_program.get()); |
7659 if (!texture_manager()->HaveUnrenderableTextures() && | 7663 if (!texture_manager()->HaveImages()) { |
Zhenyao Mo
2015/12/14 22:48:33
This is wrong. Now we can't short cut here as we
Ken Russell (switch to Gerrit)
2015/12/14 23:22:44
Could this be updated so that at least ES 2.0 cont
Zhenyao Mo
2015/12/14 23:58:17
Now that we could possibly share textures among ES
Ken Russell (switch to Gerrit)
2015/12/15 00:27:20
It's a good point. As long as these checks are onl
| |
7660 !texture_manager()->HaveImages()) { | |
7661 return true; | 7664 return true; |
7662 } | 7665 } |
7663 bool textures_set = false; | 7666 bool textures_set = false; |
7664 const Program::SamplerIndices& sampler_indices = | 7667 const Program::SamplerIndices& sampler_indices = |
7665 state_.current_program->sampler_indices(); | 7668 state_.current_program->sampler_indices(); |
7666 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7669 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7667 const Program::UniformInfo* uniform_info = | 7670 const Program::UniformInfo* uniform_info = |
7668 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7671 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7669 DCHECK(uniform_info); | 7672 DCHECK(uniform_info); |
7670 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7673 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7671 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7674 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7672 if (texture_unit_index < state_.texture_units.size()) { | 7675 if (texture_unit_index < state_.texture_units.size()) { |
7673 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7676 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7674 TextureRef* texture_ref = | 7677 TextureRef* texture_ref = |
7675 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7678 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7676 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); | 7679 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); |
7677 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7680 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
7681 uniform_info->type, texture_unit_index); | |
7682 if (!texture_ref || | |
7683 !texture_manager()->CanRenderWithSampler( | |
7684 texture_ref, sampler_state)) { | |
7678 textures_set = true; | 7685 textures_set = true; |
7679 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7686 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7680 glBindTexture( | 7687 glBindTexture( |
7681 textarget, | 7688 textarget, |
7682 texture_manager()->black_texture_id(uniform_info->type)); | 7689 texture_manager()->black_texture_id(uniform_info->type)); |
7683 if (!texture_ref) { | 7690 if (!texture_ref) { |
7684 LOCAL_RENDER_WARNING( | 7691 LOCAL_RENDER_WARNING( |
7685 std::string("there is no texture bound to the unit ") + | 7692 std::string("there is no texture bound to the unit ") + |
7686 base::UintToString(texture_unit_index)); | 7693 base::UintToString(texture_unit_index)); |
7687 } else { | 7694 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7723 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7730 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7724 const Program::UniformInfo* uniform_info = | 7731 const Program::UniformInfo* uniform_info = |
7725 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7732 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7726 DCHECK(uniform_info); | 7733 DCHECK(uniform_info); |
7727 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7734 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7728 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7735 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7729 if (texture_unit_index < state_.texture_units.size()) { | 7736 if (texture_unit_index < state_.texture_units.size()) { |
7730 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7737 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7731 TextureRef* texture_ref = | 7738 TextureRef* texture_ref = |
7732 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7739 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7733 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7740 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
7741 uniform_info->type, texture_unit_index); | |
7742 if (!texture_ref || | |
7743 !texture_manager()->CanRenderWithSampler( | |
7744 texture_ref, sampler_state)) { | |
7734 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7745 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7735 // Get the texture_ref info that was previously bound here. | 7746 // Get the texture_ref info that was previously bound here. |
7736 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D | 7747 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D |
7737 ? texture_unit.bound_texture_2d.get() | 7748 ? texture_unit.bound_texture_2d.get() |
7738 : texture_unit.bound_texture_cube_map.get(); | 7749 : texture_unit.bound_texture_cube_map.get(); |
7739 glBindTexture(texture_unit.bind_target, | 7750 glBindTexture(texture_unit.bind_target, |
7740 texture_ref ? texture_ref->service_id() : 0); | 7751 texture_ref ? texture_ref->service_id() : 0); |
7741 continue; | 7752 continue; |
7742 } | 7753 } |
7743 } | 7754 } |
(...skipping 7905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15649 if (location < 0 || | 15660 if (location < 0 || |
15650 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) { | 15661 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) { |
15651 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 15662 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
15652 "location out of range"); | 15663 "location out of range"); |
15653 return; | 15664 return; |
15654 } | 15665 } |
15655 | 15666 |
15656 program->SetFragmentInputLocationBinding(name, location); | 15667 program->SetFragmentInputLocationBinding(name, location); |
15657 } | 15668 } |
15658 | 15669 |
15670 const SamplerState& GLES2DecoderImpl::GetSamplerStateForTextureUnit( | |
15671 GLenum target, GLuint unit) { | |
15672 if (features().enable_samplers) { | |
15673 Sampler* sampler = state_.sampler_units[unit].get(); | |
15674 if (sampler) | |
15675 return sampler->sampler_state(); | |
15676 } | |
15677 TextureUnit& texture_unit = state_.texture_units[unit]; | |
15678 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get(); | |
15679 if (texture_ref) | |
15680 return texture_ref->texture()->sampler_state(); | |
15681 | |
15682 return default_sampler_state_; | |
15683 } | |
15684 | |
15659 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( | 15685 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( |
15660 uint32 immediate_data_size, | 15686 uint32 immediate_data_size, |
15661 const void* cmd_data) { | 15687 const void* cmd_data) { |
15662 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = | 15688 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = |
15663 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( | 15689 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( |
15664 cmd_data); | 15690 cmd_data); |
15665 if (!features().chromium_path_rendering) { | 15691 if (!features().chromium_path_rendering) { |
15666 return error::kUnknownCommand; | 15692 return error::kUnknownCommand; |
15667 } | 15693 } |
15668 | 15694 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15785 return error::kNoError; | 15811 return error::kNoError; |
15786 } | 15812 } |
15787 | 15813 |
15788 // Include the auto-generated part of this file. We split this because it means | 15814 // Include the auto-generated part of this file. We split this because it means |
15789 // we can easily edit the non-auto generated parts right here in this file | 15815 // we can easily edit the non-auto generated parts right here in this file |
15790 // instead of having to edit some template or the code generator. | 15816 // instead of having to edit some template or the code generator. |
15791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15817 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15792 | 15818 |
15793 } // namespace gles2 | 15819 } // namespace gles2 |
15794 } // namespace gpu | 15820 } // namespace gpu |
OLD | NEW |