Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| (...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1905 kSharedMemoryOffset); | 1905 kSharedMemoryOffset); |
| 1906 DoBindFramebuffer( | 1906 DoBindFramebuffer( |
| 1907 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1907 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 1908 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, | 1908 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, |
| 1909 GL_COLOR_ATTACHMENT0, | 1909 GL_COLOR_ATTACHMENT0, |
| 1910 GL_TEXTURE_2D, | 1910 GL_TEXTURE_2D, |
| 1911 kFBOClientTextureId, | 1911 kFBOClientTextureId, |
| 1912 kFBOServiceTextureId, | 1912 kFBOServiceTextureId, |
| 1913 0, | 1913 0, |
| 1914 GL_NO_ERROR); | 1914 GL_NO_ERROR); |
| 1915 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | |
|
Zhenyao Mo
2015/10/13 01:19:32
We can probably be more specific and put GL_FRAMEB
qiankun
2015/10/13 14:28:01
Done.
| |
| 1916 .WillOnce(SetArgPointee<3>(GL_LINEAR)) | |
| 1917 .RetiresOnSaturation(); | |
| 1915 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) | 1918 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) |
| 1916 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 1919 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 1917 .RetiresOnSaturation(); | 1920 .RetiresOnSaturation(); |
| 1918 | 1921 |
| 1919 EXPECT_CALL(*gl_, | 1922 EXPECT_CALL(*gl_, |
| 1920 CopyTexImage2D( | 1923 CopyTexImage2D( |
| 1921 target, level, internal_format, 0, 0, width, height, border)) | 1924 target, level, internal_format, 0, 0, width, height, border)) |
| 1922 .Times(1) | 1925 .Times(1) |
| 1923 .RetiresOnSaturation(); | 1926 .RetiresOnSaturation(); |
| 1924 EXPECT_CALL(*gl_, GetError()) | 1927 EXPECT_CALL(*gl_, GetError()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1975 CopyTexImage2D( | 1978 CopyTexImage2D( |
| 1976 target, level, internal_format, 0, 0, width, height, border)) | 1979 target, level, internal_format, 0, 0, width, height, border)) |
| 1977 .Times(0); | 1980 .Times(0); |
| 1978 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1981 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1979 CopyTexImage2D cmd; | 1982 CopyTexImage2D cmd; |
| 1980 cmd.Init(target, level, internal_format, 0, 0, width, height); | 1983 cmd.Init(target, level, internal_format, 0, 0, width, height); |
| 1981 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1984 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1982 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 1985 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1983 } | 1986 } |
| 1984 | 1987 |
| 1988 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_Float) { | |
| 1989 const GLuint kFBOClientTextureId = 4100; | |
| 1990 const GLuint kFBOServiceTextureId = 4101; | |
| 1991 | |
| 1992 GLenum target = GL_TEXTURE_2D; | |
| 1993 GLint level = 0; | |
| 1994 GLenum internal_format = GL_RG16F; | |
| 1995 GLenum format = GL_RG; | |
| 1996 GLenum type = GL_HALF_FLOAT; | |
| 1997 GLsizei width = 16; | |
| 1998 GLsizei height = 8; | |
| 1999 GLint border = 0; | |
| 2000 | |
| 2001 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 2002 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) | |
| 2003 .RetiresOnSaturation(); | |
| 2004 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 2005 | |
| 2006 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 2007 DoTexImage2D(GL_TEXTURE_2D, | |
| 2008 level, | |
| 2009 internal_format, | |
| 2010 width, | |
| 2011 height, | |
| 2012 0, | |
| 2013 format, | |
| 2014 type, | |
| 2015 kSharedMemoryId, | |
| 2016 kSharedMemoryOffset); | |
| 2017 DoBindFramebuffer( | |
| 2018 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 2019 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, | |
| 2020 GL_COLOR_ATTACHMENT0, | |
| 2021 GL_TEXTURE_2D, | |
| 2022 kFBOClientTextureId, | |
| 2023 kFBOServiceTextureId, | |
| 2024 0, | |
| 2025 GL_NO_ERROR); | |
| 2026 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | |
| 2027 .WillOnce(SetArgPointee<3>(GL_LINEAR)) | |
| 2028 .RetiresOnSaturation(); | |
| 2029 EXPECT_CALL(*gl_, | |
| 2030 CopyTexImage2D( | |
| 2031 target, level, internal_format, 0, 0, width, height, border)) | |
| 2032 .Times(0); | |
| 2033 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 2034 CopyTexImage2D cmd; | |
| 2035 cmd.Init(target, level, internal_format, 0, 0, width, height); | |
| 2036 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2037 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2038 } | |
| 2039 | |
| 2040 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_Integer) { | |
| 2041 const GLuint kFBOClientTextureId = 4100; | |
| 2042 const GLuint kFBOServiceTextureId = 4101; | |
| 2043 | |
| 2044 GLenum target = GL_TEXTURE_2D; | |
| 2045 GLint level = 0; | |
| 2046 GLenum internal_format = GL_RG8I; | |
| 2047 GLenum format = GL_RG_INTEGER; | |
| 2048 GLenum type = GL_UNSIGNED_BYTE; | |
| 2049 GLsizei width = 16; | |
| 2050 GLsizei height = 8; | |
| 2051 GLint border = 0; | |
| 2052 | |
| 2053 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 2054 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) | |
| 2055 .RetiresOnSaturation(); | |
| 2056 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 2057 | |
| 2058 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 2059 DoTexImage2D(GL_TEXTURE_2D, | |
| 2060 level, | |
| 2061 GL_RG8UI, | |
| 2062 width, | |
| 2063 height, | |
| 2064 0, | |
| 2065 format, | |
| 2066 type, | |
| 2067 kSharedMemoryId, | |
| 2068 kSharedMemoryOffset); | |
| 2069 DoBindFramebuffer( | |
| 2070 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 2071 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, | |
| 2072 GL_COLOR_ATTACHMENT0, | |
| 2073 GL_TEXTURE_2D, | |
| 2074 kFBOClientTextureId, | |
| 2075 kFBOServiceTextureId, | |
| 2076 0, | |
| 2077 GL_NO_ERROR); | |
| 2078 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | |
| 2079 .WillOnce(SetArgPointee<3>(GL_LINEAR)) | |
| 2080 .RetiresOnSaturation(); | |
| 2081 EXPECT_CALL(*gl_, | |
| 2082 CopyTexImage2D( | |
| 2083 target, level, internal_format, 0, 0, width, height, border)) | |
| 2084 .Times(0); | |
| 2085 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 2086 CopyTexImage2D cmd; | |
| 2087 cmd.Init(target, level, internal_format, 0, 0, width, height); | |
| 2088 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2089 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2090 } | |
| 2091 | |
| 2092 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_sRGB) { | |
| 2093 const GLuint kFBOClientTextureId = 4100; | |
| 2094 const GLuint kFBOServiceTextureId = 4101; | |
| 2095 | |
| 2096 GLenum target = GL_TEXTURE_2D; | |
| 2097 GLint level = 0; | |
| 2098 GLenum internal_format = GL_SRGB8; | |
| 2099 GLenum format = GL_RGB; | |
| 2100 GLenum type = GL_UNSIGNED_BYTE; | |
| 2101 GLsizei width = 16; | |
| 2102 GLsizei height = 8; | |
| 2103 GLint border = 0; | |
| 2104 | |
| 2105 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 2106 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) | |
| 2107 .RetiresOnSaturation(); | |
| 2108 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 2109 | |
| 2110 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 2111 DoTexImage2D(GL_TEXTURE_2D, | |
| 2112 level, | |
| 2113 internal_format, | |
| 2114 width, | |
| 2115 height, | |
| 2116 0, | |
| 2117 format, | |
| 2118 type, | |
| 2119 kSharedMemoryId, | |
| 2120 kSharedMemoryOffset); | |
| 2121 DoBindFramebuffer( | |
| 2122 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 2123 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, | |
| 2124 GL_COLOR_ATTACHMENT0, | |
| 2125 GL_TEXTURE_2D, | |
| 2126 kFBOClientTextureId, | |
| 2127 kFBOServiceTextureId, | |
| 2128 0, | |
| 2129 GL_NO_ERROR); | |
| 2130 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | |
| 2131 .WillOnce(SetArgPointee<3>(GL_LINEAR)) | |
| 2132 .RetiresOnSaturation(); | |
| 2133 EXPECT_CALL(*gl_, | |
| 2134 CopyTexImage2D( | |
| 2135 target, level, internal_format, 0, 0, width, height, border)) | |
| 2136 .Times(0); | |
| 2137 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 2138 CopyTexImage2D cmd; | |
| 2139 cmd.Init(target, level, internal_format, 0, 0, width, height); | |
| 2140 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2141 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2142 } | |
| 2143 | |
| 1985 TEST_P(GLES2DecoderManualInitTest, | 2144 TEST_P(GLES2DecoderManualInitTest, |
| 1986 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { | 2145 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { |
| 1987 InitState init; | 2146 InitState init; |
| 1988 init.extensions = "GL_EXT_framebuffer_multisample"; | 2147 init.extensions = "GL_EXT_framebuffer_multisample"; |
| 1989 init.bind_generates_resource = true; | 2148 init.bind_generates_resource = true; |
| 1990 InitDecoder(init); | 2149 InitDecoder(init); |
| 1991 const GLuint kFBOClientTextureId = 4100; | 2150 const GLuint kFBOClientTextureId = 4100; |
| 1992 const GLuint kFBOServiceTextureId = 4101; | 2151 const GLuint kFBOServiceTextureId = 4101; |
| 1993 | 2152 |
| 1994 // Register a texture id. | 2153 // Register a texture id. |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2589 EXPECT_EQ(1, result->GetNumResults()); | 2748 EXPECT_EQ(1, result->GetNumResults()); |
| 2590 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2749 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2591 } | 2750 } |
| 2592 | 2751 |
| 2593 // TODO(gman): PixelStorei | 2752 // TODO(gman): PixelStorei |
| 2594 | 2753 |
| 2595 // TODO(gman): SwapBuffers | 2754 // TODO(gman): SwapBuffers |
| 2596 | 2755 |
| 2597 } // namespace gles2 | 2756 } // namespace gles2 |
| 2598 } // namespace gpu | 2757 } // namespace gpu |
| OLD | NEW |