| 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 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 CopyTexImage2D( | 1975 CopyTexImage2D( |
| 1976 target, level, internal_format, 0, 0, width, height, border)) | 1976 target, level, internal_format, 0, 0, width, height, border)) |
| 1977 .Times(0); | 1977 .Times(0); |
| 1978 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1978 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1979 CopyTexImage2D cmd; | 1979 CopyTexImage2D cmd; |
| 1980 cmd.Init(target, level, internal_format, 0, 0, width, height); | 1980 cmd.Init(target, level, internal_format, 0, 0, width, height); |
| 1981 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1981 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1982 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 1982 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1983 } | 1983 } |
| 1984 | 1984 |
| 1985 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_Float) { |
| 1986 const GLuint kFBOClientTextureId = 4100; |
| 1987 const GLuint kFBOServiceTextureId = 4101; |
| 1988 |
| 1989 GLenum target = GL_TEXTURE_2D; |
| 1990 GLint level = 0; |
| 1991 GLenum internal_format = GL_RG16F; |
| 1992 GLenum format = GL_RG; |
| 1993 GLenum type = GL_HALF_FLOAT; |
| 1994 GLsizei width = 16; |
| 1995 GLsizei height = 8; |
| 1996 GLint border = 0; |
| 1997 |
| 1998 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 1999 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) |
| 2000 .RetiresOnSaturation(); |
| 2001 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 2002 |
| 2003 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 2004 DoTexImage2D(GL_TEXTURE_2D, |
| 2005 level, |
| 2006 internal_format, |
| 2007 width, |
| 2008 height, |
| 2009 0, |
| 2010 format, |
| 2011 type, |
| 2012 kSharedMemoryId, |
| 2013 kSharedMemoryOffset); |
| 2014 DoBindFramebuffer( |
| 2015 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 2016 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, |
| 2017 GL_COLOR_ATTACHMENT0, |
| 2018 GL_TEXTURE_2D, |
| 2019 kFBOClientTextureId, |
| 2020 kFBOServiceTextureId, |
| 2021 0, |
| 2022 GL_NO_ERROR); |
| 2023 EXPECT_CALL(*gl_, |
| 2024 CopyTexImage2D( |
| 2025 target, level, internal_format, 0, 0, width, height, border)) |
| 2026 .Times(0); |
| 2027 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2028 CopyTexImage2D cmd; |
| 2029 cmd.Init(target, level, internal_format, 0, 0, width, height); |
| 2030 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2031 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2032 } |
| 2033 |
| 2034 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_Integer) { |
| 2035 const GLuint kFBOClientTextureId = 4100; |
| 2036 const GLuint kFBOServiceTextureId = 4101; |
| 2037 |
| 2038 GLenum target = GL_TEXTURE_2D; |
| 2039 GLint level = 0; |
| 2040 GLenum internal_format = GL_RG8I; |
| 2041 GLenum format = GL_RG_INTEGER; |
| 2042 GLenum type = GL_UNSIGNED_BYTE; |
| 2043 GLsizei width = 16; |
| 2044 GLsizei height = 8; |
| 2045 GLint border = 0; |
| 2046 |
| 2047 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 2048 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) |
| 2049 .RetiresOnSaturation(); |
| 2050 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 2051 |
| 2052 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 2053 DoTexImage2D(GL_TEXTURE_2D, |
| 2054 level, |
| 2055 GL_RG8UI, |
| 2056 width, |
| 2057 height, |
| 2058 0, |
| 2059 format, |
| 2060 type, |
| 2061 kSharedMemoryId, |
| 2062 kSharedMemoryOffset); |
| 2063 DoBindFramebuffer( |
| 2064 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 2065 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, |
| 2066 GL_COLOR_ATTACHMENT0, |
| 2067 GL_TEXTURE_2D, |
| 2068 kFBOClientTextureId, |
| 2069 kFBOServiceTextureId, |
| 2070 0, |
| 2071 GL_NO_ERROR); |
| 2072 EXPECT_CALL(*gl_, |
| 2073 CopyTexImage2D( |
| 2074 target, level, internal_format, 0, 0, width, height, border)) |
| 2075 .Times(0); |
| 2076 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2077 CopyTexImage2D cmd; |
| 2078 cmd.Init(target, level, internal_format, 0, 0, width, height); |
| 2079 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2080 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2081 } |
| 2082 |
| 2083 TEST_P(GLES3DecoderTest, CopyTexImage2DInvalidInternalFormat_sRGB) { |
| 2084 const GLuint kFBOClientTextureId = 4100; |
| 2085 const GLuint kFBOServiceTextureId = 4101; |
| 2086 |
| 2087 GLenum target = GL_TEXTURE_2D; |
| 2088 GLint level = 0; |
| 2089 GLenum internal_format = GL_SRGB8; |
| 2090 GLenum format = GL_RGB; |
| 2091 GLenum type = GL_UNSIGNED_BYTE; |
| 2092 GLsizei width = 16; |
| 2093 GLsizei height = 8; |
| 2094 GLint border = 0; |
| 2095 |
| 2096 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 2097 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) |
| 2098 .RetiresOnSaturation(); |
| 2099 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 2100 |
| 2101 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 2102 DoTexImage2D(GL_TEXTURE_2D, |
| 2103 level, |
| 2104 GL_RGB, |
| 2105 width, |
| 2106 height, |
| 2107 0, |
| 2108 format, |
| 2109 type, |
| 2110 kSharedMemoryId, |
| 2111 kSharedMemoryOffset); |
| 2112 DoBindFramebuffer( |
| 2113 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 2114 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, |
| 2115 GL_COLOR_ATTACHMENT0, |
| 2116 GL_TEXTURE_2D, |
| 2117 kFBOClientTextureId, |
| 2118 kFBOServiceTextureId, |
| 2119 0, |
| 2120 GL_NO_ERROR); |
| 2121 EXPECT_CALL(*gl_, |
| 2122 CopyTexImage2D( |
| 2123 target, level, internal_format, 0, 0, width, height, border)) |
| 2124 .Times(0); |
| 2125 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2126 CopyTexImage2D cmd; |
| 2127 cmd.Init(target, level, internal_format, 0, 0, width, height); |
| 2128 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2129 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2130 } |
| 2131 |
| 1985 TEST_P(GLES2DecoderManualInitTest, | 2132 TEST_P(GLES2DecoderManualInitTest, |
| 1986 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { | 2133 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { |
| 1987 InitState init; | 2134 InitState init; |
| 1988 init.extensions = "GL_EXT_framebuffer_multisample"; | 2135 init.extensions = "GL_EXT_framebuffer_multisample"; |
| 1989 init.bind_generates_resource = true; | 2136 init.bind_generates_resource = true; |
| 1990 InitDecoder(init); | 2137 InitDecoder(init); |
| 1991 const GLuint kFBOClientTextureId = 4100; | 2138 const GLuint kFBOClientTextureId = 4100; |
| 1992 const GLuint kFBOServiceTextureId = 4101; | 2139 const GLuint kFBOServiceTextureId = 4101; |
| 1993 | 2140 |
| 1994 // Register a texture id. | 2141 // Register a texture id. |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2589 EXPECT_EQ(1, result->GetNumResults()); | 2736 EXPECT_EQ(1, result->GetNumResults()); |
| 2590 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2737 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2591 } | 2738 } |
| 2592 | 2739 |
| 2593 // TODO(gman): PixelStorei | 2740 // TODO(gman): PixelStorei |
| 2594 | 2741 |
| 2595 // TODO(gman): SwapBuffers | 2742 // TODO(gman): SwapBuffers |
| 2596 | 2743 |
| 2597 } // namespace gles2 | 2744 } // namespace gles2 |
| 2598 } // namespace gpu | 2745 } // namespace gpu |
| OLD | NEW |