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

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 a couple of unnecessary changes 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()->HaveImages()) {
piman 2015/12/14 14:04:14 This early exit is pretty important for performanc
bajones 2015/12/14 17:40:38 For ES3 we can't evaluate this ahead of time becau
7660 !texture_manager()->HaveImages()) {
7661 return true; 7662 return true;
7662 } 7663 }
7663 bool textures_set = false; 7664 bool textures_set = false;
7664 const Program::SamplerIndices& sampler_indices = 7665 const Program::SamplerIndices& sampler_indices =
7665 state_.current_program->sampler_indices(); 7666 state_.current_program->sampler_indices();
7666 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7667 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7667 const Program::UniformInfo* uniform_info = 7668 const Program::UniformInfo* uniform_info =
7668 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7669 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7669 DCHECK(uniform_info); 7670 DCHECK(uniform_info);
7670 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7671 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7671 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7672 GLuint texture_unit_index = uniform_info->texture_units[jj];
7672 if (texture_unit_index < state_.texture_units.size()) { 7673 if (texture_unit_index < state_.texture_units.size()) {
7673 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7674 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7674 TextureRef* texture_ref = 7675 TextureRef* texture_ref =
7675 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7676 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7676 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type); 7677 GLenum textarget = GetBindTargetForSamplerType(uniform_info->type);
7677 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { 7678 const SamplerState* sampler_state = GetSamplerStateForTextureUnit(
7679 uniform_info->type, texture_unit_index);
7680 if (!texture_ref ||
7681 !texture_manager()->CanRenderWithSampler(
7682 texture_ref, sampler_state)) {
7678 textures_set = true; 7683 textures_set = true;
7679 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7684 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7680 glBindTexture( 7685 glBindTexture(
7681 textarget, 7686 textarget,
7682 texture_manager()->black_texture_id(uniform_info->type)); 7687 texture_manager()->black_texture_id(uniform_info->type));
7683 if (!texture_ref) { 7688 if (!texture_ref) {
7684 LOCAL_RENDER_WARNING( 7689 LOCAL_RENDER_WARNING(
7685 std::string("there is no texture bound to the unit ") + 7690 std::string("there is no texture bound to the unit ") +
7686 base::UintToString(texture_unit_index)); 7691 base::UintToString(texture_unit_index));
7687 } else { 7692 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7723 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 7728 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
7724 const Program::UniformInfo* uniform_info = 7729 const Program::UniformInfo* uniform_info =
7725 state_.current_program->GetUniformInfo(sampler_indices[ii]); 7730 state_.current_program->GetUniformInfo(sampler_indices[ii]);
7726 DCHECK(uniform_info); 7731 DCHECK(uniform_info);
7727 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 7732 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
7728 GLuint texture_unit_index = uniform_info->texture_units[jj]; 7733 GLuint texture_unit_index = uniform_info->texture_units[jj];
7729 if (texture_unit_index < state_.texture_units.size()) { 7734 if (texture_unit_index < state_.texture_units.size()) {
7730 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 7735 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
7731 TextureRef* texture_ref = 7736 TextureRef* texture_ref =
7732 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 7737 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
7733 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { 7738 const SamplerState* sampler_state = GetSamplerStateForTextureUnit(
7739 uniform_info->type, texture_unit_index);
7740 if (!texture_ref ||
7741 !texture_manager()->CanRenderWithSampler(
7742 texture_ref, sampler_state)) {
7734 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 7743 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
7735 // Get the texture_ref info that was previously bound here. 7744 // Get the texture_ref info that was previously bound here.
7736 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D 7745 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D
7737 ? texture_unit.bound_texture_2d.get() 7746 ? texture_unit.bound_texture_2d.get()
7738 : texture_unit.bound_texture_cube_map.get(); 7747 : texture_unit.bound_texture_cube_map.get();
7739 glBindTexture(texture_unit.bind_target, 7748 glBindTexture(texture_unit.bind_target,
7740 texture_ref ? texture_ref->service_id() : 0); 7749 texture_ref ? texture_ref->service_id() : 0);
7741 continue; 7750 continue;
7742 } 7751 }
7743 } 7752 }
(...skipping 7905 matching lines...) Expand 10 before | Expand all | Expand 10 after
15649 if (location < 0 || 15658 if (location < 0 ||
15650 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) { 15659 static_cast<uint32>(location) >= group_->max_varying_vectors() * 4) {
15651 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 15660 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
15652 "location out of range"); 15661 "location out of range");
15653 return; 15662 return;
15654 } 15663 }
15655 15664
15656 program->SetFragmentInputLocationBinding(name, location); 15665 program->SetFragmentInputLocationBinding(name, location);
15657 } 15666 }
15658 15667
15668 const SamplerState* GLES2DecoderImpl::GetSamplerStateForTextureUnit(
15669 GLenum target, GLuint unit) {
15670 if (features().enable_samplers) {
15671 Sampler* sampler = state_.sampler_units[unit].get();
15672 if (sampler)
15673 return sampler->sampler_state();
15674 }
15675 TextureUnit& texture_unit = state_.texture_units[unit];
15676 TextureRef* texture_ref = texture_unit.GetInfoForSamplerType(target).get();
15677 if (texture_ref)
15678 return texture_ref->texture()->sampler_state();
15679
15680 return nullptr;
15681 }
15682
15659 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( 15683 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket(
15660 uint32 immediate_data_size, 15684 uint32 immediate_data_size,
15661 const void* cmd_data) { 15685 const void* cmd_data) {
15662 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = 15686 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c =
15663 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( 15687 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>(
15664 cmd_data); 15688 cmd_data);
15665 if (!features().chromium_path_rendering) { 15689 if (!features().chromium_path_rendering) {
15666 return error::kUnknownCommand; 15690 return error::kUnknownCommand;
15667 } 15691 }
15668 15692
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
15785 return error::kNoError; 15809 return error::kNoError;
15786 } 15810 }
15787 15811
15788 // Include the auto-generated part of this file. We split this because it means 15812 // 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 15813 // 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. 15814 // instead of having to edit some template or the code generator.
15791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15815 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15792 15816
15793 } // namespace gles2 15817 } // namespace gles2
15794 } // namespace gpu 15818 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/sampler_manager.h » ('j') | gpu/command_buffer/service/sampler_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698