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

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

Issue 1630263002: Revert of Updating texture validation to account for sampler objects in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/sampler_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // If |texture_manager_version_| doesn't match the current version, then this 1881 // If |texture_manager_version_| doesn't match the current version, then this
1882 // will rebind all external textures to match their current service_id. 1882 // will rebind all external textures to match their current service_id.
1883 void RestoreAllExternalTextureBindingsIfNeeded() override; 1883 void RestoreAllExternalTextureBindingsIfNeeded() override;
1884 1884
1885 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit);
1886
1887 // Generate a member function prototype for each command in an automated and 1885 // Generate a member function prototype for each command in an automated and
1888 // typesafe way. 1886 // typesafe way.
1889 #define GLES2_CMD_OP(name) \ 1887 #define GLES2_CMD_OP(name) \
1890 Error Handle##name(uint32_t immediate_data_size, const void* data); 1888 Error Handle##name(uint32_t immediate_data_size, const void* data);
1891 1889
1892 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1890 GLES2_COMMAND_LIST(GLES2_CMD_OP)
1893 1891
1894 #undef GLES2_CMD_OP 1892 #undef GLES2_CMD_OP
1895 1893
1896 // The GL context this decoder renders to on behalf of the client. 1894 // The GL context this decoder renders to on behalf of the client.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 2082
2085 // Most recent generation of the TextureManager. If this no longer matches 2083 // Most recent generation of the TextureManager. If this no longer matches
2086 // 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
2087 // 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.
2088 uint32_t texture_manager_service_id_generation_; 2086 uint32_t texture_manager_service_id_generation_;
2089 2087
2090 bool force_shader_name_hashing_for_test; 2088 bool force_shader_name_hashing_for_test;
2091 2089
2092 GLfloat line_width_range_[2]; 2090 GLfloat line_width_range_[2];
2093 2091
2094 SamplerState default_sampler_state_;
2095
2096 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); 2092 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
2097 }; 2093 };
2098 2094
2099 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = { 2095 const GLES2DecoderImpl::CommandInfo GLES2DecoderImpl::command_info[] = {
2100 #define GLES2_CMD_OP(name) \ 2096 #define GLES2_CMD_OP(name) \
2101 { \ 2097 { \
2102 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \ 2098 &GLES2DecoderImpl::Handle##name, cmds::name::kArgFlags, \
2103 cmds::name::cmd_flags, \ 2099 cmds::name::cmd_flags, \
2104 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ 2100 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \
2105 } \ 2101 } \
(...skipping 5501 matching lines...) Expand 10 before | Expand all | Expand 10 after
7607 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); 7603 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState());
7608 glBindTexture(textarget, texture->service_id()); 7604 glBindTexture(textarget, texture->service_id());
7609 DoCopyTexImage(texture, textarget, image); 7605 DoCopyTexImage(texture, textarget, image);
7610 RestoreCurrentTextureBindings(&state_, textarget); 7606 RestoreCurrentTextureBindings(&state_, textarget);
7611 } 7607 }
7612 } 7608 }
7613 } 7609 }
7614 7610
7615 bool GLES2DecoderImpl::PrepareTexturesForRender() { 7611 bool GLES2DecoderImpl::PrepareTexturesForRender() {
7616 DCHECK(state_.current_program.get()); 7612 DCHECK(state_.current_program.get());
7613 if (!texture_manager()->HaveUnrenderableTextures() &&
7614 !texture_manager()->HaveImages()) {
7615 return true;
7616 }
7617 bool textures_set = false; 7617 bool textures_set = false;
7618 const Program::SamplerIndices& sampler_indices = 7618 const Program::SamplerIndices& sampler_indices =
7619 state_.current_program->sampler_indices(); 7619 state_.current_program->sampler_indices();
7620 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7620 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7621 const Program::UniformInfo* uniform_info = 7621 const Program::UniformInfo* uniform_info =
7622 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7622 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7623 DCHECK(uniform_info); 7623 DCHECK(uniform_info);
7624 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7624 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7625 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7625 GLuint texture_unit_index = uniform_info->texture_units[jj];
7626 if (texture_unit_index < state_.texture_units.size()) { 7626 if (texture_unit_index < state_.texture_units.size()) {
7627 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7627 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7628 TextureRef* texture_ref = 7628 TextureRef* texture_ref =
7629 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7629 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7630 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); 7630 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type);
7631 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( 7631 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) {
7632 uniform_info->type, texture_unit_index);
7633 if (!texture_ref ||
7634 !texture_manager()->CanRenderWithSampler(
7635 texture_ref, sampler_state)) {
7636 textures_set = true; 7632 textures_set = true;
7637 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7633 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7638 glBindTexture( 7634 glBindTexture(
7639 textarget, 7635 textarget,
7640 texture_manager()->black_texture_id(uniform_info->type)); 7636 texture_manager()->black_texture_id(uniform_info->type));
7641 if (!texture_ref) { 7637 if (!texture_ref) {
7642 LOCAL_RENDER_WARNING( 7638 LOCAL_RENDER_WARNING(
7643 std::string("there is no texture bound to the unit ") + 7639 std::string("there is no texture bound to the unit ") +
7644 base::UintToString(texture_unit_index)); 7640 base::UintToString(texture_unit_index));
7645 } else { 7641 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7681 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7677 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7682 const Program::UniformInfo* uniform_info = 7678 const Program::UniformInfo* uniform_info =
7683 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7679 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7684 DCHECK(uniform_info); 7680 DCHECK(uniform_info);
7685 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7681 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7686 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7682 GLuint texture_unit_index = uniform_info->texture_units[jj];
7687 if (texture_unit_index < state_.texture_units.size()) { 7683 if (texture_unit_index < state_.texture_units.size()) {
7688 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7684 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7689 TextureRef* texture_ref = 7685 TextureRef* texture_ref =
7690 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7686 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7691 const SamplerState& sampler_state = GetSamplerStateForTextureUnit( 7687 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) {
7692 uniform_info->type, texture_unit_index);
7693 if (!texture_ref ||
7694 !texture_manager()->CanRenderWithSampler(
7695 texture_ref, sampler_state)) {
7696 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7688 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7697 // Get the texture_ref info that was previously bound here. 7689 // Get the texture_ref info that was previously bound here.
7698 texture_ref = 7690 texture_ref =
7699 texture_unit.GetInfoForTarget(texture_unit.bind_target).get(); 7691 texture_unit.GetInfoForTarget(texture_unit.bind_target).get();
7700 glBindTexture(texture_unit.bind_target, 7692 glBindTexture(texture_unit.bind_target,
7701 texture_ref ? texture_ref->service_id() : 0); 7693 texture_ref ? texture_ref->service_id() : 0);
7702 continue; 7694 continue;
7703 } 7695 }
7704 } 7696 }
7705 } 7697 }
(...skipping 7752 matching lines...) Expand 10 before | Expand all | Expand 10 after
15458 if (location < 0 || 15450 if (location < 0 ||
15459 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) { 15451 static_cast<uint32_t>(location) >= group_->max_varying_vectors() * 4) {
15460 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 15452 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
15461 "location out of range"); 15453 "location out of range");
15462 return; 15454 return;
15463 } 15455 }
15464 15456
15465 program->SetFragmentInputLocationBinding(name, location); 15457 program->SetFragmentInputLocationBinding(name, location);
15466 } 15458 }
15467 15459
15468 const SamplerState& GLES2DecoderImpl::GetSamplerStateForTextureUnit(
15469 GLenum target, GLuint unit) {
15470 if (features().enable_samplers) {
15471 Sampler* sampler = state_.sampler_units[unit].get();
15472 if (sampler)
15473 return sampler->sampler_state();
15474 }
15475 TextureUnit& texture_unit = state_.texture_units[unit];
15476 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get();
15477 if (texture_ref)
15478 return texture_ref->texture()->sampler_state();
15479
15480 return default_sampler_state_;
15481 }
15482
15483 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( 15460 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket(
15484 uint32_t immediate_data_size, 15461 uint32_t immediate_data_size,
15485 const void* cmd_data) { 15462 const void* cmd_data) {
15486 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = 15463 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c =
15487 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( 15464 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>(
15488 cmd_data); 15465 cmd_data);
15489 if (!features().chromium_path_rendering) { 15466 if (!features().chromium_path_rendering) {
15490 return error::kUnknownCommand; 15467 return error::kUnknownCommand;
15491 } 15468 }
15492 15469
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
15636 } 15613 }
15637 15614
15638 // Include the auto-generated part of this file. We split this because it means 15615 // Include the auto-generated part of this file. We split this because it means
15639 // we can easily edit the non-auto generated parts right here in this file 15616 // we can easily edit the non-auto generated parts right here in this file
15640 // instead of having to edit some template or the code generator. 15617 // instead of having to edit some template or the code generator.
15641 #include "base/macros.h" 15618 #include "base/macros.h"
15642 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15619 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15643 15620
15644 } // namespace gles2 15621 } // namespace gles2
15645 } // namespace gpu 15622 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/sampler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698