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 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1871 // and allow context preemption and GPU watchdog checks in GpuScheduler(). | 1871 // and allow context preemption and GPU watchdog checks in GpuScheduler(). |
1872 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } | 1872 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } |
1873 | 1873 |
1874 void ProcessPendingReadPixels(bool did_finish); | 1874 void ProcessPendingReadPixels(bool did_finish); |
1875 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1875 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1876 | 1876 |
1877 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, | 1877 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, |
1878 GLint location, | 1878 GLint location, |
1879 const std::string& name); | 1879 const std::string& name); |
1880 | 1880 |
1881 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); | |
1882 | |
1881 // Generate a member function prototype for each command in an automated and | 1883 // Generate a member function prototype for each command in an automated and |
1882 // typesafe way. | 1884 // typesafe way. |
1883 #define GLES2_CMD_OP(name) \ | 1885 #define GLES2_CMD_OP(name) \ |
1884 Error Handle##name(uint32_t immediate_data_size, const void* data); | 1886 Error Handle##name(uint32_t immediate_data_size, const void* data); |
1885 | 1887 |
1886 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1888 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1887 | 1889 |
1888 #undef GLES2_CMD_OP | 1890 #undef GLES2_CMD_OP |
1889 | 1891 |
1890 // The GL context this decoder renders to on behalf of the client. | 1892 // 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... | |
2071 uint16_t arg_count; // How many arguments are expected for this command. | 2073 uint16_t arg_count; // How many arguments are expected for this command. |
2072 }; | 2074 }; |
2073 | 2075 |
2074 // A table of CommandInfo for all the commands. | 2076 // A table of CommandInfo for all the commands. |
2075 static const CommandInfo command_info[kNumCommands - kStartPoint]; | 2077 static const CommandInfo command_info[kNumCommands - kStartPoint]; |
2076 | 2078 |
2077 bool force_shader_name_hashing_for_test; | 2079 bool force_shader_name_hashing_for_test; |
2078 | 2080 |
2079 GLfloat line_width_range_[2]; | 2081 GLfloat line_width_range_[2]; |
2080 | 2082 |
2083 SamplerState default_sampler_state_; | |
2084 | |
2081 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 2085 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
2082 }; | 2086 }; |
2083 | 2087 |
2084 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { | 2088 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { |
2085 #define GLES2_CMD_OP(name) \ | 2089 #define GLES2_CMD_OP(name) \ |
2086 { \ | 2090 { \ |
2087 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ | 2091 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ |
2088 cmds::name::cmd_flags, \ | 2092 cmds::name::cmd_flags, \ |
2089 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 2093 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
2090 } \ | 2094 } \ |
(...skipping 5492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7583 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 7587 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
7584 glBindTexture(textarget, texture->service_id()); | 7588 glBindTexture(textarget, texture->service_id()); |
7585 DoCopyTexImage(texture, textarget, image); | 7589 DoCopyTexImage(texture, textarget, image); |
7586 RestoreCurrentTextureBindings(&state_, textarget); | 7590 RestoreCurrentTextureBindings(&state_, textarget); |
7587 } | 7591 } |
7588 } | 7592 } |
7589 } | 7593 } |
7590 | 7594 |
7591 bool GLES2DecoderImpl::PrepareTexturesForRender() { | 7595 bool GLES2DecoderImpl::PrepareTexturesForRender() { |
7592 DCHECK(state_.current_program.get()); | 7596 DCHECK(state_.current_program.get()); |
7593 if (!texture_manager()->HaveUnrenderableTextures() && | 7597 if (!texture_manager()->HaveImages()) { |
piman
2016/01/20 01:14:02
Hmm, actually, don't you need to go through the co
bajones
2016/01/20 23:57:55
Good catch, I had read the original code as an ||
| |
7594 !texture_manager()->HaveImages()) { | |
7595 return true; | 7598 return true; |
7596 } | 7599 } |
7597 bool textures_set = false; | 7600 bool textures_set = false; |
7598 const Program::SamplerIndices& sampler_indices = | 7601 const Program::SamplerIndices& sampler_indices = |
7599 state_.current_program->sampler_indices(); | 7602 state_.current_program->sampler_indices(); |
7600 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7603 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7601 const Program::UniformInfo* uniform_info = | 7604 const Program::UniformInfo* uniform_info = |
7602 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7605 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7603 DCHECK(uniform_info); | 7606 DCHECK(uniform_info); |
7604 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7607 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7605 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7608 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7606 if (texture_unit_index < state_.texture_units.size()) { | 7609 if (texture_unit_index < state_.texture_units.size()) { |
7607 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7610 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7608 TextureRef* texture_ref = | 7611 TextureRef* texture_ref = |
7609 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7612 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7610 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); | 7613 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); |
7611 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7614 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
7615 uniform_info->type, texture_unit_index); | |
7616 if (!texture_ref || | |
7617 !texture_manager()->CanRenderWithSampler( | |
7618 texture_ref, sampler_state)) { | |
7612 textures_set = true; | 7619 textures_set = true; |
7613 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7620 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7614 glBindTexture( | 7621 glBindTexture( |
7615 textarget, | 7622 textarget, |
7616 texture_manager()->black_texture_id(uniform_info->type)); | 7623 texture_manager()->black_texture_id(uniform_info->type)); |
7617 if (!texture_ref) { | 7624 if (!texture_ref) { |
7618 LOCAL_RENDER_WARNING( | 7625 LOCAL_RENDER_WARNING( |
7619 std::string("there is no texture bound to the unit ") + | 7626 std::string("there is no texture bound to the unit ") + |
7620 base::UintToString(texture_unit_index)); | 7627 base::UintToString(texture_unit_index)); |
7621 } else { | 7628 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7657 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 7664 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
7658 const Program::UniformInfo* uniform_info = | 7665 const Program::UniformInfo* uniform_info = |
7659 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 7666 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
7660 DCHECK(uniform_info); | 7667 DCHECK(uniform_info); |
7661 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 7668 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
7662 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 7669 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
7663 if (texture_unit_index < state_.texture_units.size()) { | 7670 if (texture_unit_index < state_.texture_units.size()) { |
7664 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 7671 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
7665 TextureRef* texture_ref = | 7672 TextureRef* texture_ref = |
7666 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 7673 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
7667 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 7674 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( |
7675 uniform_info->type, texture_unit_index); | |
7676 if (!texture_ref || | |
7677 !texture_manager()->CanRenderWithSampler( | |
7678 texture_ref, sampler_state)) { | |
7668 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 7679 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
7669 // Get the texture_ref info that was previously bound here. | 7680 // Get the texture_ref info that was previously bound here. |
7670 texture_ref = | 7681 texture_ref = |
7671 texture_unit.GetInfoForTarget(texture_unit.bind_target).get(); | 7682 texture_unit.GetInfoForTarget(texture_unit.bind_target).get(); |
7672 glBindTexture(texture_unit.bind_target, | 7683 glBindTexture(texture_unit.bind_target, |
7673 texture_ref ? texture_ref->service_id() : 0); | 7684 texture_ref ? texture_ref->service_id() : 0); |
7674 continue; | 7685 continue; |
7675 } | 7686 } |
7676 } | 7687 } |
7677 } | 7688 } |
(...skipping 7765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15443 if (location < 0 || | 15454 if (location < 0 || |
15444 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) { | 15455 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) { |
15445 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 15456 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
15446 "location out of range"); | 15457 "location out of range"); |
15447 return; | 15458 return; |
15448 } | 15459 } |
15449 | 15460 |
15450 program->SetFragmentInputLocationBinding(name, location); | 15461 program->SetFragmentInputLocationBinding(name, location); |
15451 } | 15462 } |
15452 | 15463 |
15464 const SamplerState& GLES2DecoderImpl::GetSamplerStateForTextureUnit( | |
15465 GLenum target, GLuint unit) { | |
15466 if (features().enable_samplers) { | |
15467 Sampler* sampler = state_.sampler_units[unit].get(); | |
15468 if (sampler) | |
15469 return sampler->sampler_state(); | |
15470 } | |
15471 TextureUnit& texture_unit = state_.texture_units[unit]; | |
15472 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get(); | |
15473 if (texture_ref) | |
15474 return texture_ref->texture()->sampler_state(); | |
15475 | |
15476 return default_sampler_state_; | |
15477 } | |
15478 | |
15453 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( | 15479 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( |
15454 uint32_t immediate_data_size, | 15480 uint32_t immediate_data_size, |
15455 const void* cmd_data) { | 15481 const void* cmd_data) { |
15456 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = | 15482 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = |
15457 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( | 15483 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( |
15458 cmd_data); | 15484 cmd_data); |
15459 if (!features().chromium_path_rendering) { | 15485 if (!features().chromium_path_rendering) { |
15460 return error::kUnknownCommand; | 15486 return error::kUnknownCommand; |
15461 } | 15487 } |
15462 | 15488 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15580 } | 15606 } |
15581 | 15607 |
15582 // Include the auto-generated part of this file. We split this because it means | 15608 // Include the auto-generated part of this file. We split this because it means |
15583 // we can easily edit the non-auto generated parts right here in this file | 15609 // we can easily edit the non-auto generated parts right here in this file |
15584 // instead of having to edit some template or the code generator. | 15610 // instead of having to edit some template or the code generator. |
15585 #include "base/macros.h" | 15611 #include "base/macros.h" |
15586 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15612 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15587 | 15613 |
15588 } // namespace gles2 | 15614 } // namespace gles2 |
15589 } // namespace gpu | 15615 } // namespace gpu |
OLD | NEW |