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

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

Issue 1505343003: Updating texture validation to account for sampler objects in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed DCHECK that was causing bots to fail Created 5 years 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
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 <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
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 5726 matching lines...) Expand 10 before | Expand all | Expand 10 after
7649 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); 7651 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState());
7650 glBindTexture(textarget, texture->service_id()); 7652 glBindTexture(textarget, texture->service_id());
7651 DoCopyTexImage(texture, textarget, image); 7653 DoCopyTexImage(texture, textarget, image);
7652 RestoreCurrentTextureBindings(&state_, textarget); 7654 RestoreCurrentTextureBindings(&state_, textarget);
7653 } 7655 }
7654 } 7656 }
7655 } 7657 }
7656 7658
7657 bool GLES2DecoderImpl::PrepareTexturesForRender() { 7659 bool GLES2DecoderImpl::PrepareTexturesForRender() {
7658 DCHECK(state_.current_program.get()); 7660 DCHECK(state_.current_program.get());
7659 if (!texture_manager()->HaveUnrenderableTextures() && 7661 if (!texture_manager()->NeedsTextureRenderChecks() &&
7660 !texture_manager()->HaveImages()) { 7662 !texture_manager()->HaveImages()) {
7661 return true; 7663 return true;
7662 } 7664 }
7663 bool textures_set = false; 7665 bool textures_set = false;
7664 const Program::SamplerIndices& sampler_indices = 7666 const Program::SamplerIndices& sampler_indices =
7665 state_.current_program->sampler_indices(); 7667 state_.current_program->sampler_indices();
7666 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7668 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7667 const Program::UniformInfo* uniform_info = 7669 const Program::UniformInfo* uniform_info =
7668 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7670 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7669 DCHECK(uniform_info); 7671 DCHECK(uniform_info);
7670 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7672 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7671 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7673 GLuint texture_unit_index = uniform_info->texture_units[jj];
7672 if (texture_unit_index < state_.texture_units.size()) { 7674 if (texture_unit_index < state_.texture_units.size()) {
7673 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7675 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7674 TextureRef* texture_ref = 7676 TextureRef* texture_ref =
7675 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7677 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7676 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); 7678 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type);
7677 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { 7679 const SamplerState* sampler_state = GetSamplerStateForTextureUnit(
7680 uniform_info->type, texture_unit_index);
7681 if (!texture_ref ||
7682 !texture_manager()->CanRenderWithSampler(
7683 texture_ref, sampler_state)) {
7678 textures_set = true; 7684 textures_set = true;
7679 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7685 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7680 glBindTexture( 7686 glBindTexture(
7681 textarget, 7687 textarget,
7682 texture_manager()->black_texture_id(uniform_info->type)); 7688 texture_manager()->black_texture_id(uniform_info->type));
7683 if (!texture_ref) { 7689 if (!texture_ref) {
7684 LOCAL_RENDER_WARNING( 7690 LOCAL_RENDER_WARNING(
7685 std::string("there is no texture bound to the unit ") + 7691 std::string("there is no texture bound to the unit ") +
7686 base::UintToString(texture_unit_index)); 7692 base::UintToString(texture_unit_index));
7687 } else { 7693 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7723 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7729 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7724 const Program::UniformInfo* uniform_info = 7730 const Program::UniformInfo* uniform_info =
7725 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7731 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7726 DCHECK(uniform_info); 7732 DCHECK(uniform_info);
7727 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7733 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7728 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7734 GLuint texture_unit_index = uniform_info->texture_units[jj];
7729 if (texture_unit_index < state_.texture_units.size()) { 7735 if (texture_unit_index < state_.texture_units.size()) {
7730 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7736 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7731 TextureRef* texture_ref = 7737 TextureRef* texture_ref =
7732 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7738 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7733 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { 7739 const SamplerState* sampler_state = GetSamplerStateForTextureUnit(
7740 uniform_info->type, texture_unit_index);
7741 if (!texture_ref ||
7742 !texture_manager()->CanRenderWithSampler(
7743 texture_ref, sampler_state)) {
7734 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7744 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7735 // Get the texture_ref info that was previously bound here. 7745 // Get the texture_ref info that was previously bound here.
7736 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D 7746 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D
7737 ? texture_unit.bound_texture_2d.get() 7747 ? texture_unit.bound_texture_2d.get()
7738 : texture_unit.bound_texture_cube_map.get(); 7748 : texture_unit.bound_texture_cube_map.get();
7739 glBindTexture(texture_unit.bind_target, 7749 glBindTexture(texture_unit.bind_target,
7740 texture_ref ? texture_ref->service_id() : 0); 7750 texture_ref ? texture_ref->service_id() : 0);
7741 continue; 7751 continue;
7742 } 7752 }
7743 } 7753 }
(...skipping 7905 matching lines...) Expand 10 before | Expand all | Expand 10 after
15649 if (location < 0 || 15659 if (location < 0 ||
15650 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) { 15660 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) {
15651 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 15661 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
15652 "location out of range"); 15662 "location out of range");
15653 return; 15663 return;
15654 } 15664 }
15655 15665
15656 program->SetFragmentInputLocationBinding(name, location); 15666 program->SetFragmentInputLocationBinding(name, location);
15657 } 15667 }
15658 15668
15669 const SamplerState* GLES2DecoderImpl::GetSamplerStateForTextureUnit(
15670 GLenum target, GLuint unit) {
15671 if (features().enable_samplers) {
15672 Sampler* sampler = state_.sampler_units[unit].get();
15673 if (sampler)
15674 return sampler->sampler_state();
15675 }
15676 TextureUnit& texture_unit = state_.texture_units[unit];
15677 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get();
15678 if (texture_ref)
15679 return texture_ref->texture()->sampler_state();
15680
15681 return nullptr;
15682 }
15683
15659 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( 15684 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket(
15660 uint32 immediate_data_size, 15685 uint32 immediate_data_size,
15661 const void* cmd_data) { 15686 const void* cmd_data) {
15662 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = 15687 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c =
15663 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( 15688 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>(
15664 cmd_data); 15689 cmd_data);
15665 if (!features().chromium_path_rendering) { 15690 if (!features().chromium_path_rendering) {
15666 return error::kUnknownCommand; 15691 return error::kUnknownCommand;
15667 } 15692 }
15668 15693
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
15785 return error::kNoError; 15810 return error::kNoError;
15786 } 15811 }
15787 15812
15788 // Include the auto-generated part of this file. We split this because it means 15813 // 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 15814 // 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. 15815 // instead of having to edit some template or the code generator.
15791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15816 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15792 15817
15793 } // namespace gles2 15818 } // namespace gles2
15794 } // namespace gpu 15819 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/mailbox_manager_unittest.cc » ('j') | gpu/command_buffer/service/texture_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698