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

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

Issue 1126243002: Check for shader version mismatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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/test_helper.h" 5 #include "gpu/command_buffer/service/test_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 767 }
768 manager->SetParameteri("", error_state, texture_ref, pname, value); 768 manager->SetParameteri("", error_state, texture_ref, pname, value);
769 } 769 }
770 770
771 // static 771 // static
772 void TestHelper::SetShaderStates( 772 void TestHelper::SetShaderStates(
773 ::gfx::MockGLInterface* gl, Shader* shader, 773 ::gfx::MockGLInterface* gl, Shader* shader,
774 bool expected_valid, 774 bool expected_valid,
775 const std::string* const expected_log_info, 775 const std::string* const expected_log_info,
776 const std::string* const expected_translated_source, 776 const std::string* const expected_translated_source,
777 const int* const expected_shader_version,
777 const AttributeMap* const expected_attrib_map, 778 const AttributeMap* const expected_attrib_map,
778 const UniformMap* const expected_uniform_map, 779 const UniformMap* const expected_uniform_map,
779 const VaryingMap* const expected_varying_map, 780 const VaryingMap* const expected_varying_map,
780 const NameMap* const expected_name_map) { 781 const NameMap* const expected_name_map) {
781 const std::string empty_log_info; 782 const std::string empty_log_info;
782 const std::string* log_info = (expected_log_info && !expected_valid) ? 783 const std::string* log_info = (expected_log_info && !expected_valid) ?
783 expected_log_info : &empty_log_info; 784 expected_log_info : &empty_log_info;
784 const std::string empty_translated_source; 785 const std::string empty_translated_source;
785 const std::string* translated_source = 786 const std::string* translated_source =
786 (expected_translated_source && expected_valid) ? 787 (expected_translated_source && expected_valid) ?
787 expected_translated_source : &empty_translated_source; 788 expected_translated_source : &empty_translated_source;
789 int default_shader_version = 100;
790 const int* shader_version = (expected_shader_version && expected_valid) ?
791 expected_shader_version : &default_shader_version;
788 const AttributeMap empty_attrib_map; 792 const AttributeMap empty_attrib_map;
789 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ? 793 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ?
790 expected_attrib_map : &empty_attrib_map; 794 expected_attrib_map : &empty_attrib_map;
791 const UniformMap empty_uniform_map; 795 const UniformMap empty_uniform_map;
792 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ? 796 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ?
793 expected_uniform_map : &empty_uniform_map; 797 expected_uniform_map : &empty_uniform_map;
794 const VaryingMap empty_varying_map; 798 const VaryingMap empty_varying_map;
795 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ? 799 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ?
796 expected_varying_map : &empty_varying_map; 800 expected_varying_map : &empty_varying_map;
797 const NameMap empty_name_map; 801 const NameMap empty_name_map;
798 const NameMap* name_map = (expected_name_map && expected_valid) ? 802 const NameMap* name_map = (expected_name_map && expected_valid) ?
799 expected_name_map : &empty_name_map; 803 expected_name_map : &empty_name_map;
800 804
801 MockShaderTranslator* mock_translator = new MockShaderTranslator; 805 MockShaderTranslator* mock_translator = new MockShaderTranslator;
802 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator); 806 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator);
803 EXPECT_CALL(*mock_translator, Translate(_, 807 EXPECT_CALL(*mock_translator, Translate(_,
804 NotNull(), // log_info 808 NotNull(), // log_info
805 NotNull(), // translated_source 809 NotNull(), // translated_source
810 NotNull(), // shader_version
806 NotNull(), // attrib_map 811 NotNull(), // attrib_map
807 NotNull(), // uniform_map 812 NotNull(), // uniform_map
808 NotNull(), // varying_map 813 NotNull(), // varying_map
809 NotNull())) // name_map 814 NotNull())) // name_map
810 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), 815 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info),
811 SetArgumentPointee<2>(*translated_source), 816 SetArgumentPointee<2>(*translated_source),
812 SetArgumentPointee<3>(*attrib_map), 817 SetArgumentPointee<3>(*shader_version),
813 SetArgumentPointee<4>(*uniform_map), 818 SetArgumentPointee<4>(*attrib_map),
814 SetArgumentPointee<5>(*varying_map), 819 SetArgumentPointee<5>(*uniform_map),
815 SetArgumentPointee<6>(*name_map), 820 SetArgumentPointee<6>(*varying_map),
821 SetArgumentPointee<7>(*name_map),
816 Return(expected_valid))) 822 Return(expected_valid)))
817 .RetiresOnSaturation(); 823 .RetiresOnSaturation();
818 if (expected_valid) { 824 if (expected_valid) {
819 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL)) 825 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL))
820 .Times(1) 826 .Times(1)
821 .RetiresOnSaturation(); 827 .RetiresOnSaturation();
822 EXPECT_CALL(*gl, CompileShader(shader->service_id())) 828 EXPECT_CALL(*gl, CompileShader(shader->service_id()))
823 .Times(1) 829 .Times(1)
824 .RetiresOnSaturation(); 830 .RetiresOnSaturation();
825 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), 831 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(),
826 GL_COMPILE_STATUS, 832 GL_COMPILE_STATUS,
827 NotNull())) // status 833 NotNull())) // status
828 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) 834 .WillOnce(SetArgumentPointee<2>(GL_TRUE))
829 .RetiresOnSaturation(); 835 .RetiresOnSaturation();
830 } 836 }
831 shader->RequestCompile(translator, Shader::kGL); 837 shader->RequestCompile(translator, Shader::kGL);
832 shader->DoCompile(); 838 shader->DoCompile();
833 } 839 }
834 840
835 // static 841 // static
836 void TestHelper::SetShaderStates( 842 void TestHelper::SetShaderStates(
837 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) { 843 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) {
838 SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL); 844 SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
839 } 845 }
840 846
841 // static 847 // static
842 sh::Attribute TestHelper::ConstructAttribute( 848 sh::Attribute TestHelper::ConstructAttribute(
843 GLenum type, GLint array_size, GLenum precision, 849 GLenum type, GLint array_size, GLenum precision,
844 bool static_use, const std::string& name) { 850 bool static_use, const std::string& name) {
845 return ConstructShaderVariable<sh::Attribute>( 851 return ConstructShaderVariable<sh::Attribute>(
846 type, array_size, precision, static_use, name); 852 type, array_size, precision, static_use, name);
847 } 853 }
848 854
(...skipping 19 matching lines...) Expand all
868 gfx::SetGLImplementation(implementation); 874 gfx::SetGLImplementation(implementation);
869 } 875 }
870 876
871 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { 877 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() {
872 gfx::SetGLImplementation(old_implementation_); 878 gfx::SetGLImplementation(old_implementation_);
873 } 879 }
874 880
875 } // namespace gles2 881 } // namespace gles2
876 } // namespace gpu 882 } // namespace gpu
877 883
OLDNEW
« gpu/command_buffer/service/program_manager.cc ('K') | « gpu/command_buffer/service/test_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698