OLD | NEW |
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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 EXPECT_TRUE( | 1682 EXPECT_TRUE( |
1683 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); | 1683 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); |
1684 } | 1684 } |
1685 } | 1685 } |
1686 } | 1686 } |
1687 | 1687 |
1688 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 1688 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
1689 TeardownStateForTestPattern(); | 1689 TeardownStateForTestPattern(); |
1690 } | 1690 } |
1691 | 1691 |
| 1692 TEST_P(CHROMIUMPathRenderingWithTexturingTest, UnusedFragmentInputUpdate) { |
| 1693 if (!IsApplicable()) |
| 1694 return; |
| 1695 |
| 1696 // clang-format off |
| 1697 static const char* kVertexShaderString = SHADER( |
| 1698 attribute vec4 a_position; |
| 1699 void main() { |
| 1700 gl_Position = a_position; |
| 1701 } |
| 1702 ); |
| 1703 static const char* kFragmentShaderString = SHADER( |
| 1704 precision mediump float; |
| 1705 uniform vec4 u_colorA; |
| 1706 uniform float u_colorU; |
| 1707 uniform vec4 u_colorC; |
| 1708 void main() { |
| 1709 gl_FragColor = u_colorA + u_colorC; |
| 1710 } |
| 1711 ); |
| 1712 // clang-format on |
| 1713 const GLint kColorULocation = 1; |
| 1714 const GLint kNonexistingLocation = 5; |
| 1715 const GLint kUnboundLocation = 6; |
| 1716 |
| 1717 GLuint vertex_shader = |
| 1718 GLTestHelper::LoadShader(GL_VERTEX_SHADER, kVertexShaderString); |
| 1719 GLuint fragment_shader = |
| 1720 GLTestHelper::LoadShader(GL_FRAGMENT_SHADER, kFragmentShaderString); |
| 1721 GLuint program = glCreateProgram(); |
| 1722 glBindFragmentInputLocationCHROMIUM(program, kColorULocation, "u_colorU"); |
| 1723 // The non-existing uniform should behave like existing, but optimized away |
| 1724 // uniform. |
| 1725 glBindFragmentInputLocationCHROMIUM(program, kNonexistingLocation, |
| 1726 "nonexisting"); |
| 1727 // Let A and C be assigned automatic locations. |
| 1728 glAttachShader(program, vertex_shader); |
| 1729 glAttachShader(program, fragment_shader); |
| 1730 glLinkProgram(program); |
| 1731 GLint linked = 0; |
| 1732 glGetProgramiv(program, GL_LINK_STATUS, &linked); |
| 1733 EXPECT_EQ(1, linked); |
| 1734 glUseProgram(program); |
| 1735 |
| 1736 GLfloat kColor[16] = { |
| 1737 0.0f, |
| 1738 }; |
| 1739 // No errors on bound locations, since caller does not know |
| 1740 // if the driver optimizes them away or not. |
| 1741 glProgramPathFragmentInputGenCHROMIUM(program, kColorULocation, |
| 1742 GL_CONSTANT_CHROMIUM, 1, kColor); |
| 1743 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1744 |
| 1745 // No errors on bound locations of names that do not exist |
| 1746 // in the shader. Otherwise it would be inconsistent wrt the |
| 1747 // optimization case. |
| 1748 glProgramPathFragmentInputGenCHROMIUM(program, kNonexistingLocation, |
| 1749 GL_CONSTANT_CHROMIUM, 1, kColor); |
| 1750 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1751 |
| 1752 // The above are equal to updating -1. |
| 1753 glProgramPathFragmentInputGenCHROMIUM(program, -1, GL_CONSTANT_CHROMIUM, 1, |
| 1754 kColor); |
| 1755 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1756 |
| 1757 // No errors when updating with other type either. |
| 1758 // The type can not be known with the non-existing case. |
| 1759 glProgramPathFragmentInputGenCHROMIUM(program, kColorULocation, |
| 1760 GL_CONSTANT_CHROMIUM, 4, kColor); |
| 1761 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1762 glProgramPathFragmentInputGenCHROMIUM(program, kNonexistingLocation, |
| 1763 GL_CONSTANT_CHROMIUM, 4, kColor); |
| 1764 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1765 glProgramPathFragmentInputGenCHROMIUM(program, -1, GL_CONSTANT_CHROMIUM, 4, |
| 1766 kColor); |
| 1767 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1768 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1769 |
| 1770 // Updating an unbound, non-existing location still causes |
| 1771 // an error. |
| 1772 glProgramPathFragmentInputGenCHROMIUM(program, kUnboundLocation, |
| 1773 GL_CONSTANT_CHROMIUM, 4, kColor); |
| 1774 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
| 1775 } |
| 1776 |
1692 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, | 1777 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, |
1693 CHROMIUMPathRenderingWithTexturingTest, | 1778 CHROMIUMPathRenderingWithTexturingTest, |
1694 ::testing::Bool()); | 1779 ::testing::Bool()); |
1695 | 1780 |
1696 } // namespace gpu | 1781 } // namespace gpu |
OLD | NEW |