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

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

Issue 2852923004: Remove NameMap from shader translator and shader/program managers (Closed)
Patch Set: remove some TODO(zmo)s Created 3 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/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 Shader* vshader = shader_manager_.CreateShader( 420 Shader* vshader = shader_manager_.CreateShader(
421 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); 421 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER);
422 Shader* fshader = shader_manager_.CreateShader( 422 Shader* fshader = shader_manager_.CreateShader(
423 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); 423 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER);
424 // Check shader got created. 424 // Check shader got created.
425 EXPECT_TRUE(vshader != NULL && fshader != NULL); 425 EXPECT_TRUE(vshader != NULL && fshader != NULL);
426 // Set Status 426 // Set Status
427 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 427 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
428 shader_version, &vertex_attrib_map, 428 shader_version, &vertex_attrib_map,
429 &vertex_uniform_map, &vertex_varying_map, 429 &vertex_uniform_map, &vertex_varying_map,
430 nullptr, &vertex_output_variable_list, nullptr); 430 nullptr, &vertex_output_variable_list);
431 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 431 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
432 shader_version, &frag_attrib_map, 432 shader_version, &frag_attrib_map,
433 &frag_uniform_map, &frag_varying_map, nullptr, 433 &frag_uniform_map, &frag_varying_map, nullptr,
434 &frag_output_variable_list, nullptr); 434 &frag_output_variable_list);
435 435
436 // Set up program 436 // Set up program
437 Program* program = 437 Program* program =
438 manager_->CreateProgram(kClientProgramId, kServiceProgramId); 438 manager_->CreateProgram(kClientProgramId, kServiceProgramId);
439 EXPECT_TRUE(program != NULL); 439 EXPECT_TRUE(program != NULL);
440 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 440 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
441 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 441 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
442 return program; 442 return program;
443 } 443 }
444 444
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 kUniform3StaticUse, kUniform3Name); 868 kUniform3StaticUse, kUniform3Name);
869 output_variable_list.push_back(TestHelper::ConstructOutputVariable( 869 output_variable_list.push_back(TestHelper::ConstructOutputVariable(
870 kOutputVariable1Type, kOutputVariable1Size, kOutputVariable1Precision, 870 kOutputVariable1Type, kOutputVariable1Size, kOutputVariable1Precision,
871 kOutputVariable1StaticUse, kOutputVariable1Name)); 871 kOutputVariable1StaticUse, kOutputVariable1Name));
872 872
873 Shader* vshader = shader_manager_.CreateShader( 873 Shader* vshader = shader_manager_.CreateShader(
874 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); 874 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER);
875 ASSERT_TRUE(vshader != NULL); 875 ASSERT_TRUE(vshader != NULL);
876 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 876 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
877 nullptr, &attrib_map, &uniform_map, &varying_map, 877 nullptr, &attrib_map, &uniform_map, &varying_map,
878 nullptr, &output_variable_list, nullptr); 878 nullptr, &output_variable_list);
879 Shader* fshader = shader_manager_.CreateShader( 879 Shader* fshader = shader_manager_.CreateShader(
880 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); 880 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER);
881 ASSERT_TRUE(fshader != NULL); 881 ASSERT_TRUE(fshader != NULL);
882 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 882 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
883 nullptr, &attrib_map, &uniform_map, &varying_map, 883 nullptr, &attrib_map, &uniform_map, &varying_map,
884 nullptr, &output_variable_list, nullptr); 884 nullptr, &output_variable_list);
885 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { 885 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = {
886 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, 886 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
887 { kAttrib2Name, kAttrib2Size, kAttrib2BadType, kAttrib2Location, }, 887 { kAttrib2Name, kAttrib2Size, kAttrib2BadType, kAttrib2Location, },
888 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, 888 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
889 }; 889 };
890 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 890 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
891 { kUniform1Name, 891 { kUniform1Name,
892 kUniform1Size, 892 kUniform1Size,
893 kUniform1Type, 893 kUniform1Type,
894 kUniform1FakeLocation, 894 kUniform1FakeLocation,
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 // Check we can create shader. 1539 // Check we can create shader.
1540 Shader* vshader = shader_manager_.CreateShader( 1540 Shader* vshader = shader_manager_.CreateShader(
1541 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); 1541 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER);
1542 Shader* fshader = shader_manager_.CreateShader( 1542 Shader* fshader = shader_manager_.CreateShader(
1543 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); 1543 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER);
1544 // Check shader got created. 1544 // Check shader got created.
1545 ASSERT_TRUE(vshader != NULL && fshader != NULL); 1545 ASSERT_TRUE(vshader != NULL && fshader != NULL);
1546 // Set Status 1546 // Set Status
1547 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 1547 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
1548 nullptr, &attrib_map, nullptr, nullptr, nullptr, 1548 nullptr, &attrib_map, nullptr, nullptr, nullptr,
1549 nullptr, nullptr); 1549 nullptr);
1550 // Check attrib infos got copied. 1550 // Check attrib infos got copied.
1551 for (AttributeMap::const_iterator it = attrib_map.begin(); 1551 for (AttributeMap::const_iterator it = attrib_map.begin();
1552 it != attrib_map.end(); ++it) { 1552 it != attrib_map.end(); ++it) {
1553 const sh::Attribute* variable_info = 1553 const sh::Attribute* variable_info =
1554 vshader->GetAttribInfo(it->first); 1554 vshader->GetAttribInfo(it->first);
1555 ASSERT_TRUE(variable_info != NULL); 1555 ASSERT_TRUE(variable_info != NULL);
1556 EXPECT_EQ(it->second.type, variable_info->type); 1556 EXPECT_EQ(it->second.type, variable_info->type);
1557 EXPECT_EQ(it->second.arraySize, variable_info->arraySize); 1557 EXPECT_EQ(it->second.arraySize, variable_info->arraySize);
1558 EXPECT_EQ(it->second.precision, variable_info->precision); 1558 EXPECT_EQ(it->second.precision, variable_info->precision);
1559 EXPECT_EQ(it->second.staticUse, variable_info->staticUse); 1559 EXPECT_EQ(it->second.staticUse, variable_info->staticUse);
1560 EXPECT_EQ(it->second.name, variable_info->name); 1560 EXPECT_EQ(it->second.name, variable_info->name);
1561 } 1561 }
1562 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1562 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1563 nullptr, &attrib_map, nullptr, nullptr, nullptr, 1563 nullptr, &attrib_map, nullptr, nullptr, nullptr,
1564 nullptr, nullptr); 1564 nullptr);
1565 // Set up program 1565 // Set up program
1566 Program* program = 1566 Program* program =
1567 manager_->CreateProgram(kClientProgramId, kServiceProgramId); 1567 manager_->CreateProgram(kClientProgramId, kServiceProgramId);
1568 ASSERT_TRUE(program != NULL); 1568 ASSERT_TRUE(program != NULL);
1569 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 1569 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
1570 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 1570 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
1571 1571
1572 EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); 1572 EXPECT_FALSE(program->DetectAttribLocationBindingConflicts());
1573 EXPECT_TRUE(LinkAsExpected(program, true)); 1573 EXPECT_TRUE(LinkAsExpected(program, true));
1574 1574
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 // Check we can create shader. 1622 // Check we can create shader.
1623 Shader* vshader = shader_manager_.CreateShader( 1623 Shader* vshader = shader_manager_.CreateShader(
1624 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); 1624 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER);
1625 Shader* fshader = shader_manager_.CreateShader( 1625 Shader* fshader = shader_manager_.CreateShader(
1626 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); 1626 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER);
1627 // Check shader got created. 1627 // Check shader got created.
1628 ASSERT_TRUE(vshader != NULL && fshader != NULL); 1628 ASSERT_TRUE(vshader != NULL && fshader != NULL);
1629 // Set Status 1629 // Set Status
1630 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 1630 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
1631 nullptr, nullptr, &vertex_uniform_map, nullptr, 1631 nullptr, nullptr, &vertex_uniform_map, nullptr,
1632 nullptr, nullptr, nullptr); 1632 nullptr, nullptr);
1633 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1633 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1634 nullptr, nullptr, &frag_uniform_map, nullptr, 1634 nullptr, nullptr, &frag_uniform_map, nullptr,
1635 nullptr, nullptr, nullptr); 1635 nullptr, nullptr);
1636 // Set up program 1636 // Set up program
1637 Program* program = 1637 Program* program =
1638 manager_->CreateProgram(kClientProgramId, kServiceProgramId); 1638 manager_->CreateProgram(kClientProgramId, kServiceProgramId);
1639 ASSERT_TRUE(program != NULL); 1639 ASSERT_TRUE(program != NULL);
1640 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 1640 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
1641 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 1641 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
1642 1642
1643 std::string conflicting_name; 1643 std::string conflicting_name;
1644 1644
1645 EXPECT_TRUE(program->DetectUniformsMismatch(&conflicting_name)); 1645 EXPECT_TRUE(program->DetectUniformsMismatch(&conflicting_name));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 EXPECT_EQ("a", conflicting_name); 1744 EXPECT_EQ("a", conflicting_name);
1745 EXPECT_TRUE(LinkAsExpected(program, false)); 1745 EXPECT_TRUE(LinkAsExpected(program, false));
1746 } 1746 }
1747 1747
1748 TEST_F(ProgramManagerWithShaderTest, FragmentOutputTypes) { 1748 TEST_F(ProgramManagerWithShaderTest, FragmentOutputTypes) {
1749 // Set up program 1749 // Set up program
1750 Shader* vshader = shader_manager_.CreateShader( 1750 Shader* vshader = shader_manager_.CreateShader(
1751 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); 1751 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER);
1752 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 1752 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
1753 nullptr, nullptr, nullptr, nullptr, nullptr, 1753 nullptr, nullptr, nullptr, nullptr, nullptr,
1754 nullptr, nullptr); 1754 nullptr);
1755 Shader* fshader = shader_manager_.CreateShader( 1755 Shader* fshader = shader_manager_.CreateShader(
1756 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); 1756 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER);
1757 ASSERT_TRUE(vshader && fshader); 1757 ASSERT_TRUE(vshader && fshader);
1758 Program* program = 1758 Program* program =
1759 manager_->CreateProgram(kClientProgramId, kServiceProgramId); 1759 manager_->CreateProgram(kClientProgramId, kServiceProgramId);
1760 ASSERT_TRUE(program); 1760 ASSERT_TRUE(program);
1761 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 1761 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
1762 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 1762 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
1763 1763
1764 { // No outputs. 1764 { // No outputs.
1765 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1765 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1766 nullptr, nullptr, nullptr, nullptr, nullptr, 1766 nullptr, nullptr, nullptr, nullptr, nullptr,
1767 nullptr, nullptr); 1767 nullptr);
1768 EXPECT_TRUE(LinkAsExpected(program, true)); 1768 EXPECT_TRUE(LinkAsExpected(program, true));
1769 EXPECT_EQ(0u, program->fragment_output_type_mask()); 1769 EXPECT_EQ(0u, program->fragment_output_type_mask());
1770 EXPECT_EQ(0u, program->fragment_output_written_mask()); 1770 EXPECT_EQ(0u, program->fragment_output_written_mask());
1771 } 1771 }
1772 1772
1773 { // gl_FragColor 1773 { // gl_FragColor
1774 OutputVariableList fragment_outputs; 1774 OutputVariableList fragment_outputs;
1775 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1775 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1776 GL_FLOAT_VEC4, 0, GL_MEDIUM_FLOAT, true, "gl_FragColor"); 1776 GL_FLOAT_VEC4, 0, GL_MEDIUM_FLOAT, true, "gl_FragColor");
1777 var.location = -1; 1777 var.location = -1;
1778 fragment_outputs.push_back(var); 1778 fragment_outputs.push_back(var);
1779 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1779 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1780 nullptr, nullptr, nullptr, nullptr, nullptr, 1780 nullptr, nullptr, nullptr, nullptr, nullptr,
1781 &fragment_outputs, nullptr); 1781 &fragment_outputs);
1782 EXPECT_TRUE(LinkAsExpected(program, true)); 1782 EXPECT_TRUE(LinkAsExpected(program, true));
1783 EXPECT_EQ(0x3u, program->fragment_output_type_mask()); 1783 EXPECT_EQ(0x3u, program->fragment_output_type_mask());
1784 EXPECT_EQ(0x3u, program->fragment_output_written_mask()); 1784 EXPECT_EQ(0x3u, program->fragment_output_written_mask());
1785 } 1785 }
1786 1786
1787 { // gl_FragData 1787 { // gl_FragData
1788 OutputVariableList fragment_outputs; 1788 OutputVariableList fragment_outputs;
1789 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1789 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1790 GL_FLOAT_VEC4, 8, GL_MEDIUM_FLOAT, true, "gl_FragData"); 1790 GL_FLOAT_VEC4, 8, GL_MEDIUM_FLOAT, true, "gl_FragData");
1791 var.location = -1; 1791 var.location = -1;
1792 fragment_outputs.push_back(var); 1792 fragment_outputs.push_back(var);
1793 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1793 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1794 nullptr, nullptr, nullptr, nullptr, nullptr, 1794 nullptr, nullptr, nullptr, nullptr, nullptr,
1795 &fragment_outputs, nullptr); 1795 &fragment_outputs);
1796 EXPECT_TRUE(LinkAsExpected(program, true)); 1796 EXPECT_TRUE(LinkAsExpected(program, true));
1797 EXPECT_EQ(0xFFFFu, program->fragment_output_type_mask()); 1797 EXPECT_EQ(0xFFFFu, program->fragment_output_type_mask());
1798 EXPECT_EQ(0xFFFFu, program->fragment_output_written_mask()); 1798 EXPECT_EQ(0xFFFFu, program->fragment_output_written_mask());
1799 } 1799 }
1800 1800
1801 { // gl_FragColor, gl_FragDepth 1801 { // gl_FragColor, gl_FragDepth
1802 OutputVariableList fragment_outputs; 1802 OutputVariableList fragment_outputs;
1803 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1803 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1804 GL_FLOAT_VEC4, 0, GL_MEDIUM_FLOAT, true, "gl_FragColor"); 1804 GL_FLOAT_VEC4, 0, GL_MEDIUM_FLOAT, true, "gl_FragColor");
1805 var.location = -1; 1805 var.location = -1;
1806 fragment_outputs.push_back(var); 1806 fragment_outputs.push_back(var);
1807 var = TestHelper::ConstructOutputVariable( 1807 var = TestHelper::ConstructOutputVariable(
1808 GL_FLOAT, 0, GL_MEDIUM_FLOAT, true, "gl_FragDepth"); 1808 GL_FLOAT, 0, GL_MEDIUM_FLOAT, true, "gl_FragDepth");
1809 var.location = -1; 1809 var.location = -1;
1810 fragment_outputs.push_back(var); 1810 fragment_outputs.push_back(var);
1811 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1811 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1812 nullptr, nullptr, nullptr, nullptr, nullptr, 1812 nullptr, nullptr, nullptr, nullptr, nullptr,
1813 &fragment_outputs, nullptr); 1813 &fragment_outputs);
1814 EXPECT_TRUE(LinkAsExpected(program, true)); 1814 EXPECT_TRUE(LinkAsExpected(program, true));
1815 EXPECT_EQ(0x3u, program->fragment_output_type_mask()); 1815 EXPECT_EQ(0x3u, program->fragment_output_type_mask());
1816 EXPECT_EQ(0x3u, program->fragment_output_written_mask()); 1816 EXPECT_EQ(0x3u, program->fragment_output_written_mask());
1817 } 1817 }
1818 1818
1819 { // Single user defined output. 1819 { // Single user defined output.
1820 OutputVariableList fragment_outputs; 1820 OutputVariableList fragment_outputs;
1821 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1821 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1822 GL_UNSIGNED_INT_VEC4, 0, GL_MEDIUM_INT, true, "myOutput"); 1822 GL_UNSIGNED_INT_VEC4, 0, GL_MEDIUM_INT, true, "myOutput");
1823 var.location = -1; 1823 var.location = -1;
1824 fragment_outputs.push_back(var); 1824 fragment_outputs.push_back(var);
1825 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1825 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1826 nullptr, nullptr, nullptr, nullptr, nullptr, 1826 nullptr, nullptr, nullptr, nullptr, nullptr,
1827 &fragment_outputs, nullptr); 1827 &fragment_outputs);
1828 EXPECT_TRUE(LinkAsExpected(program, true)); 1828 EXPECT_TRUE(LinkAsExpected(program, true));
1829 EXPECT_EQ(0x2u, program->fragment_output_type_mask()); 1829 EXPECT_EQ(0x2u, program->fragment_output_type_mask());
1830 EXPECT_EQ(0x3u, program->fragment_output_written_mask()); 1830 EXPECT_EQ(0x3u, program->fragment_output_written_mask());
1831 } 1831 }
1832 1832
1833 { // Single user defined output - no static use. 1833 { // Single user defined output - no static use.
1834 OutputVariableList fragment_outputs; 1834 OutputVariableList fragment_outputs;
1835 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1835 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1836 GL_UNSIGNED_INT_VEC4, 0, GL_MEDIUM_INT, false, "myOutput"); 1836 GL_UNSIGNED_INT_VEC4, 0, GL_MEDIUM_INT, false, "myOutput");
1837 var.location = -1; 1837 var.location = -1;
1838 fragment_outputs.push_back(var); 1838 fragment_outputs.push_back(var);
1839 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1839 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1840 nullptr, nullptr, nullptr, nullptr, nullptr, 1840 nullptr, nullptr, nullptr, nullptr, nullptr,
1841 &fragment_outputs, nullptr); 1841 &fragment_outputs);
1842 EXPECT_TRUE(LinkAsExpected(program, true)); 1842 EXPECT_TRUE(LinkAsExpected(program, true));
1843 EXPECT_EQ(0x2u, program->fragment_output_type_mask()); 1843 EXPECT_EQ(0x2u, program->fragment_output_type_mask());
1844 EXPECT_EQ(0x3u, program->fragment_output_written_mask()); 1844 EXPECT_EQ(0x3u, program->fragment_output_written_mask());
1845 } 1845 }
1846 1846
1847 { // Multiple user defined outputs. 1847 { // Multiple user defined outputs.
1848 OutputVariableList fragment_outputs; 1848 OutputVariableList fragment_outputs;
1849 sh::OutputVariable var = TestHelper::ConstructOutputVariable( 1849 sh::OutputVariable var = TestHelper::ConstructOutputVariable(
1850 GL_INT_VEC4, 0, GL_MEDIUM_INT, true, "myOutput"); 1850 GL_INT_VEC4, 0, GL_MEDIUM_INT, true, "myOutput");
1851 var.location = 0; 1851 var.location = 0;
1852 fragment_outputs.push_back(var); 1852 fragment_outputs.push_back(var);
1853 var = TestHelper::ConstructOutputVariable( 1853 var = TestHelper::ConstructOutputVariable(
1854 GL_FLOAT_VEC4, 2, GL_MEDIUM_FLOAT, true, "myOutputArray"); 1854 GL_FLOAT_VEC4, 2, GL_MEDIUM_FLOAT, true, "myOutputArray");
1855 var.location = 2; 1855 var.location = 2;
1856 fragment_outputs.push_back(var); 1856 fragment_outputs.push_back(var);
1857 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 1857 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
1858 nullptr, nullptr, nullptr, nullptr, nullptr, 1858 nullptr, nullptr, nullptr, nullptr, nullptr,
1859 &fragment_outputs, nullptr); 1859 &fragment_outputs);
1860 EXPECT_TRUE(LinkAsExpected(program, true)); 1860 EXPECT_TRUE(LinkAsExpected(program, true));
1861 EXPECT_EQ(0xF1u, program->fragment_output_type_mask()); 1861 EXPECT_EQ(0xF1u, program->fragment_output_type_mask());
1862 EXPECT_EQ(0xF3u, program->fragment_output_written_mask()); 1862 EXPECT_EQ(0xF3u, program->fragment_output_written_mask());
1863 } 1863 }
1864 } 1864 }
1865 1865
1866 // Varyings go over 8 rows. 1866 // Varyings go over 8 rows.
1867 TEST_F(ProgramManagerWithShaderTest, TooManyVaryings) { 1867 TEST_F(ProgramManagerWithShaderTest, TooManyVaryings) {
1868 const VarInfo kVertexVaryings[] = { 1868 const VarInfo kVertexVaryings[] = {
1869 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying }, 1869 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying },
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 kFragmentInput1Type, kFragmentInput1Size, kFragmentInput1Precision, 2353 kFragmentInput1Type, kFragmentInput1Size, kFragmentInput1Precision,
2354 kFragmentInput1StaticUse, kFragmentInput1Name); 2354 kFragmentInput1StaticUse, kFragmentInput1Name);
2355 varying_map[kFragmentInput2Name] = TestHelper::ConstructVarying( 2355 varying_map[kFragmentInput2Name] = TestHelper::ConstructVarying(
2356 kFragmentInput2Type, kFragmentInput2Size, kFragmentInput2Precision, 2356 kFragmentInput2Type, kFragmentInput2Size, kFragmentInput2Precision,
2357 kFragmentInput2StaticUse, kFragmentInput2Name); 2357 kFragmentInput2StaticUse, kFragmentInput2Name);
2358 varying_map[kFragmentInput3Name] = TestHelper::ConstructVarying( 2358 varying_map[kFragmentInput3Name] = TestHelper::ConstructVarying(
2359 kFragmentInput3Type, kFragmentInput3Size, kFragmentInput3Precision, 2359 kFragmentInput3Type, kFragmentInput3Size, kFragmentInput3Precision,
2360 kFragmentInput3StaticUse, kFragmentInput3Name); 2360 kFragmentInput3StaticUse, kFragmentInput3Name);
2361 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr, 2361 TestHelper::SetShaderStates(gl_.get(), vshader, true, nullptr, nullptr,
2362 nullptr, nullptr, nullptr, &varying_map, nullptr, 2362 nullptr, nullptr, nullptr, &varying_map, nullptr,
2363 nullptr, nullptr); 2363 nullptr);
2364 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr, 2364 TestHelper::SetShaderStates(gl_.get(), fshader, true, nullptr, nullptr,
2365 nullptr, nullptr, nullptr, &varying_map, nullptr, 2365 nullptr, nullptr, nullptr, &varying_map, nullptr,
2366 nullptr, nullptr); 2366 nullptr);
2367 Program* program = 2367 Program* program =
2368 manager_->CreateProgram(kClientProgramId, kServiceProgramId); 2368 manager_->CreateProgram(kClientProgramId, kServiceProgramId);
2369 ASSERT_TRUE(program != NULL); 2369 ASSERT_TRUE(program != NULL);
2370 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 2370 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
2371 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 2371 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
2372 program->SetFragmentInputLocationBinding(kFragmentInput1Name, 2372 program->SetFragmentInputLocationBinding(kFragmentInput1Name,
2373 kFragmentInput1DesiredLocation); 2373 kFragmentInput1DesiredLocation);
2374 program->SetFragmentInputLocationBinding(kFragmentInput3Name, 2374 program->SetFragmentInputLocationBinding(kFragmentInput3Name,
2375 kFragmentInput3DesiredLocation); 2375 kFragmentInput3DesiredLocation);
2376 TestHelper::VaryingInfo kFragmentInputExpectationInfos[] = { 2376 TestHelper::VaryingInfo kFragmentInputExpectationInfos[] = {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 ProgramManagerDualSourceBlendingES2Test, 2513 ProgramManagerDualSourceBlendingES2Test,
2514 testing::Values( 2514 testing::Values(
2515 make_gl_ext_tuple("3.2", 2515 make_gl_ext_tuple("3.2",
2516 "GL_ARB_draw_buffers GL_ARB_blend_func_extended " 2516 "GL_ARB_draw_buffers GL_ARB_blend_func_extended "
2517 "GL_ARB_program_interface_query"), 2517 "GL_ARB_program_interface_query"),
2518 make_gl_ext_tuple("opengl es 3.1", 2518 make_gl_ext_tuple("opengl es 3.1",
2519 "GL_EXT_draw_buffers GL_EXT_blend_func_extended"))); 2519 "GL_EXT_draw_buffers GL_EXT_blend_func_extended")));
2520 2520
2521 } // namespace gles2 2521 } // namespace gles2
2522 } // namespace gpu 2522 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | gpu/command_buffer/service/shader_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698