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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1874 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1875 | 1875 |
1876 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, | 1876 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, |
1877 GLint location, | 1877 GLint location, |
1878 const std::string& name); | 1878 const std::string& name); |
1879 | 1879 |
1880 // If |texture_manager_version_| doesn't match the current version, then this | 1880 // If |texture_manager_version_| doesn't match the current version, then this |
1881 // will rebind all external textures to match their current service_id. | 1881 // will rebind all external textures to match their current service_id. |
1882 void RestoreAllExternalTextureBindingsIfNeeded() override; | 1882 void RestoreAllExternalTextureBindingsIfNeeded() override; |
1883 | 1883 |
| 1884 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); |
| 1885 |
1884 // Generate a member function prototype for each command in an automated and | 1886 // Generate a member function prototype for each command in an automated and |
1885 // typesafe way. | 1887 // typesafe way. |
1886 #define GLES2_CMD_OP(name) \ | 1888 #define GLES2_CMD_OP(name) \ |
1887 Error Handle##name(uint32_t immediate_data_size, const void* data); | 1889 Error Handle##name(uint32_t immediate_data_size, const void* data); |
1888 | 1890 |
1889 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1891 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1890 | 1892 |
1891 #undef GLES2_CMD_OP | 1893 #undef GLES2_CMD_OP |
1892 | 1894 |
1893 // The GL context this decoder renders to on behalf of the client. | 1895 // The GL context this decoder renders to on behalf of the client. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 | 2082 |
2081 // Most recent generation of the TextureManager. If this no longer matches | 2083 // Most recent generation of the TextureManager. If this no longer matches |
2082 // the current generation when our context becomes current, then we'll rebind | 2084 // the current generation when our context becomes current, then we'll rebind |
2083 // all the textures to stay up-to-date with Texture::service_id() changes. | 2085 // all the textures to stay up-to-date with Texture::service_id() changes. |
2084 uint32_t texture_manager_service_id_generation_; | 2086 uint32_t texture_manager_service_id_generation_; |
2085 | 2087 |
2086 bool force_shader_name_hashing_for_test; | 2088 bool force_shader_name_hashing_for_test; |
2087 | 2089 |
2088 GLfloat line_width_range_[2]; | 2090 GLfloat line_width_range_[2]; |
2089 | 2091 |
| 2092 SamplerState default_sampler_state_; |
| 2093 |
2090 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2094 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
2091 }; | 2095 }; |
2092 | 2096 |
2093 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2097 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
2094 #define GLES2_CMD_OP(name) \ | 2098 #define GLES2_CMD_OP(name) \ |
2095 { \ | 2099 { \ |
2096 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2100 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
2097 cmds::name::cmd_flags, \ | 2101 cmds::name::cmd_flags, \ |
2098 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2102 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
2099 } \ | 2103 } \ |
(...skipping 5498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7598 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 7602 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
7599 glBindTexture(textarget, texture->service_id()); | 7603 glBindTexture(textarget, texture->service_id()); |
7600 DoCopyTexImage(texture, textarget, image); | 7604 DoCopyTexImage(texture, textarget, image); |
7601 RestoreCurrentTextureBindings(&state_, textarget); | 7605 RestoreCurrentTextureBindings(&state_, textarget); |
7602 } | 7606 } |
7603 } | 7607 } |
7604 } | 7608 } |
7605 | 7609 |
7606 bool GLES2DecoderImpl::PrepareTexturesForRender() { | 7610 bool GLES2DecoderImpl::PrepareTexturesForRender() { |
7607 DCHECK(state_.current_program.get()); | 7611 DCHECK(state_.current_program.get()); |
7608 if (!texture_manager()->HaveUnrenderableTextures() && | |
7609 !texture_manager()->HaveImages()) { | |
7610 return true; | |
7611 } | |
7612 bool textures_set = false; | 7612 bool textures_set = false; |
7613 const Program::SamplerIndices& sampler_indices = | 7613 const Program::SamplerIndices& sampler_indices = |
7614 state_.current_program->sampler_indices(); | 7614 state_.current_program->sampler_indices(); |
7615 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7615 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7616 const Program::UniformInfo* uniform_info = | 7616 const Program::UniformInfo* uniform_info = |
7617 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7617 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7618 DCHECK(uniform_info); | 7618 DCHECK(uniform_info); |
7619 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7619 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7620 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7620 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7621 if (texture_unit_index < state_.texture_units.size()) { | 7621 if (texture_unit_index < state_.texture_units.size()) { |
7622 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7622 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7623 TextureRef* texture_ref = | 7623 TextureRef* texture_ref = |
7624 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7624 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7625 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); | 7625 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); |
7626 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7626 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
| 7627 uniform_info->type, texture_unit_index); |
| 7628 if (!texture_ref || |
| 7629 !texture_manager()->CanRenderWithSampler( |
| 7630 texture_ref, sampler_state)) { |
7627 textures_set = true; | 7631 textures_set = true; |
7628 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7632 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7629 glBindTexture( | 7633 glBindTexture( |
7630 textarget, | 7634 textarget, |
7631 texture_manager()->black_texture_id(uniform_info->type)); | 7635 texture_manager()->black_texture_id(uniform_info->type)); |
7632 if (!texture_ref) { | 7636 if (!texture_ref) { |
7633 LOCAL_RENDER_WARNING( | 7637 LOCAL_RENDER_WARNING( |
7634 std::string("there is no texture bound to the unit ") + | 7638 std::string("there is no texture bound to the unit ") + |
7635 base::UintToString(texture_unit_index)); | 7639 base::UintToString(texture_unit_index)); |
7636 } else { | 7640 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7672 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7676 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7673 const Program::UniformInfo* uniform_info = | 7677 const Program::UniformInfo* uniform_info = |
7674 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7678 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7675 DCHECK(uniform_info); | 7679 DCHECK(uniform_info); |
7676 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7680 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7677 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7681 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7678 if (texture_unit_index < state_.texture_units.size()) { | 7682 if (texture_unit_index < state_.texture_units.size()) { |
7679 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7683 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7680 TextureRef* texture_ref = | 7684 TextureRef* texture_ref = |
7681 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7685 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7682 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7686 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
| 7687 uniform_info->type, texture_unit_index); |
| 7688 if (!texture_ref || |
| 7689 !texture_manager()->CanRenderWithSampler( |
| 7690 texture_ref, sampler_state)) { |
7683 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7691 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7684 // Get the texture_ref info that was previously bound here. | 7692 // Get the texture_ref info that was previously bound here. |
7685 texture_ref = | 7693 texture_ref = |
7686 texture_unit.GetInfoForTarget(texture_unit.bind_target).get(); | 7694 texture_unit.GetInfoForTarget(texture_unit.bind_target).get(); |
7687 glBindTexture(texture_unit.bind_target, | 7695 glBindTexture(texture_unit.bind_target, |
7688 texture_ref ? texture_ref->service_id() : 0); | 7696 texture_ref ? texture_ref->service_id() : 0); |
7689 continue; | 7697 continue; |
7690 } | 7698 } |
7691 } | 7699 } |
7692 } | 7700 } |
(...skipping 7720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15413 if (location < 0 || | 15421 if (location < 0 || |
15414 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) { | 15422 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) { |
15415 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 15423 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
15416 "location out of range"); | 15424 "location out of range"); |
15417 return; | 15425 return; |
15418 } | 15426 } |
15419 | 15427 |
15420 program->SetFragmentInputLocationBinding(name, location); | 15428 program->SetFragmentInputLocationBinding(name, location); |
15421 } | 15429 } |
15422 | 15430 |
| 15431 const SamplerState& GLES2DecoderImpl::GetSamplerStateForTextureUnit( |
| 15432 GLenum target, GLuint unit) { |
| 15433 if (features().enable_samplers) { |
| 15434 Sampler* sampler = state_.sampler_units[unit].get(); |
| 15435 if (sampler) |
| 15436 return sampler->sampler_state(); |
| 15437 } |
| 15438 TextureUnit& texture_unit = state_.texture_units[unit]; |
| 15439 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get(); |
| 15440 if (texture_ref) |
| 15441 return texture_ref->texture()->sampler_state(); |
| 15442 |
| 15443 return default_sampler_state_; |
| 15444 } |
| 15445 |
15423 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( | 15446 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( |
15424 uint32_t immediate_data_size, | 15447 uint32_t immediate_data_size, |
15425 const void* cmd_data) { | 15448 const void* cmd_data) { |
15426 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = | 15449 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = |
15427 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( | 15450 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( |
15428 cmd_data); | 15451 cmd_data); |
15429 if (!features().chromium_path_rendering) { | 15452 if (!features().chromium_path_rendering) { |
15430 return error::kUnknownCommand; | 15453 return error::kUnknownCommand; |
15431 } | 15454 } |
15432 | 15455 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15576 } | 15599 } |
15577 | 15600 |
15578 // Include the auto-generated part of this file. We split this because it means | 15601 // Include the auto-generated part of this file. We split this because it means |
15579 // we can easily edit the non-auto generated parts right here in this file | 15602 // we can easily edit the non-auto generated parts right here in this file |
15580 // instead of having to edit some template or the code generator. | 15603 // instead of having to edit some template or the code generator. |
15581 #include "base/macros.h" | 15604 #include "base/macros.h" |
15582 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15605 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15583 | 15606 |
15584 } // namespace gles2 | 15607 } // namespace gles2 |
15585 } // namespace gpu | 15608 } // namespace gpu |
OLD | NEW |