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 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2200 | 2200 |
2201 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | 2201 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
2202 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); | 2202 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); |
2203 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | 2203 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
2204 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 2204 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
2205 } | 2205 } |
2206 | 2206 |
2207 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { | 2207 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { |
2208 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | 2208 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
2209 GetImageManager()->AddImage(image.get(), 1); | 2209 GetImageManager()->AddImage(image.get(), 1); |
2210 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); | 2210 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2211 | 2211 |
2212 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | 2212 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
2213 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); | 2213 EXPECT_CALL(*gl_, GetError()) |
2214 .WillOnce(Return(GL_NO_ERROR)) | |
2215 .RetiresOnSaturation(); | |
2216 EXPECT_CALL(*gl_, GetError()) | |
2217 .WillOnce(Return(GL_NO_ERROR)) | |
2218 .RetiresOnSaturation(); | |
2219 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
2214 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | 2220 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
2215 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 2221 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2216 | 2222 |
2217 DoTexImage2D( | |
2218 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
2219 TextureRef* texture_ref = | 2223 TextureRef* texture_ref = |
2220 group().texture_manager()->GetTexture(client_texture_id_); | 2224 group().texture_manager()->GetTexture(client_texture_id_); |
2221 ASSERT_TRUE(texture_ref != NULL); | 2225 ASSERT_TRUE(texture_ref != NULL); |
2222 Texture* texture = texture_ref->texture(); | 2226 Texture* texture = texture_ref->texture(); |
2227 | |
2228 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | |
2229 DoTexImage2D( | |
2230 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
2223 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 2231 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
2224 } | 2232 } |
2225 | 2233 |
2234 TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) { | |
2235 ASSERT_FALSE( | |
no sievers
2015/02/25 21:52:48
nit: put comment "this specifically tests that we
| |
2236 feature_info()->workarounds().texsubimage2d_faster_than_teximage2d); | |
2237 | |
2238 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | |
2239 GetImageManager()->AddImage(image.get(), 1); | |
2240 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
2241 | |
2242 GLenum target = GL_TEXTURE_2D; | |
2243 GLint level = 0; | |
2244 GLint xoffset = 0; | |
2245 GLint yoffset = 0; | |
2246 GLsizei width = 1; | |
2247 GLsizei height = 1; | |
2248 GLint border = 0; | |
2249 GLenum format = GL_RGBA; | |
2250 GLenum type = GL_UNSIGNED_BYTE; | |
2251 uint32_t pixels_shm_id = kSharedMemoryId; | |
2252 uint32_t pixels_shm_offset = 0; | |
no sievers
2015/02/25 21:52:49
kSharedMemoryOffset
| |
2253 GLboolean internal = 0; | |
2254 | |
2255 // Define texture first. | |
2256 DoTexImage2D(target, level, format, width, height, border, format, type, | |
2257 pixels_shm_id, pixels_shm_offset); | |
2258 | |
2259 // Bind texture to GLImage. | |
2260 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
no sievers
2015/02/25 21:52:48
nit: line 2260-2276 seems to be duplicated a few t
| |
2261 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
2262 EXPECT_CALL(*gl_, GetError()) | |
2263 .WillOnce(Return(GL_NO_ERROR)) | |
2264 .RetiresOnSaturation(); | |
2265 EXPECT_CALL(*gl_, GetError()) | |
2266 .WillOnce(Return(GL_NO_ERROR)) | |
2267 .RetiresOnSaturation(); | |
2268 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
2269 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
2270 | |
2271 // Check binding. | |
2272 TextureRef* texture_ref = | |
2273 group().texture_manager()->GetTexture(client_texture_id_); | |
2274 ASSERT_TRUE(texture_ref != NULL); | |
2275 Texture* texture = texture_ref->texture(); | |
2276 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | |
2277 | |
2278 // TexSubImage2D should not unbind GLImage. | |
2279 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, | |
2280 height, format, type, _)) | |
2281 .Times(1) | |
2282 .RetiresOnSaturation(); | |
2283 cmds::TexSubImage2D tex_sub_image_2d_cmd; | |
2284 tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height, | |
2285 format, type, pixels_shm_id, pixels_shm_offset, | |
2286 internal); | |
2287 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd)); | |
2288 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | |
2289 } | |
2290 | |
2291 TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) { | |
2292 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | |
2293 GetImageManager()->AddImage(image.get(), 1); | |
2294 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
2295 | |
2296 GLenum target = GL_TEXTURE_2D; | |
2297 GLint level = 0; | |
2298 GLint xoffset = 0; | |
2299 GLint yoffset = 0; | |
2300 GLsizei width = 1; | |
2301 GLsizei height = 1; | |
2302 GLint border = 0; | |
2303 GLenum format = GL_RGBA; | |
2304 GLenum type = GL_UNSIGNED_BYTE; | |
2305 uint32_t pixels_shm_id = kSharedMemoryId; | |
2306 uint32_t pixels_shm_offset = 0; | |
no sievers
2015/02/25 21:52:48
kSharedMemoryOffset
| |
2307 | |
2308 // Define texture first. | |
2309 DoTexImage2D(target, level, format, width, height, border, format, type, | |
2310 pixels_shm_id, pixels_shm_offset); | |
2311 | |
2312 // Bind texture to GLImage. | |
2313 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
2314 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
2315 EXPECT_CALL(*gl_, GetError()) | |
2316 .WillOnce(Return(GL_NO_ERROR)) | |
2317 .RetiresOnSaturation(); | |
2318 EXPECT_CALL(*gl_, GetError()) | |
2319 .WillOnce(Return(GL_NO_ERROR)) | |
2320 .RetiresOnSaturation(); | |
2321 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
2322 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
2323 | |
2324 // Check binding. | |
2325 TextureRef* texture_ref = | |
2326 group().texture_manager()->GetTexture(client_texture_id_); | |
2327 ASSERT_TRUE(texture_ref != NULL); | |
2328 Texture* texture = texture_ref->texture(); | |
2329 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | |
2330 | |
2331 // ClearLevel use glTexSubImage2D to avoid unbinding GLImage. | |
no sievers
2015/02/25 21:52:48
nit: 'should use'
| |
2332 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
2333 .Times(2) | |
2334 .RetiresOnSaturation(); | |
2335 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, | |
2336 height, format, type, _)) | |
2337 .Times(1) | |
2338 .RetiresOnSaturation(); | |
2339 GetDecoder()->ClearLevel(texture, target, level, format, format, type, width, | |
2340 height, false); | |
2341 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | |
2342 } | |
2343 | |
2226 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { | 2344 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |
2227 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2345 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2228 DoTexImage2D( | 2346 DoTexImage2D( |
2229 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 2347 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2230 TextureRef* texture_ref = | 2348 TextureRef* texture_ref = |
2231 group().texture_manager()->GetTexture(client_texture_id_); | 2349 group().texture_manager()->GetTexture(client_texture_id_); |
2232 ASSERT_TRUE(texture_ref != NULL); | 2350 ASSERT_TRUE(texture_ref != NULL); |
2233 Texture* texture = texture_ref->texture(); | 2351 Texture* texture = texture_ref->texture(); |
2234 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 2352 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
2235 | 2353 |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2837 // TODO(gman): CompressedTexSubImage2DImmediate | 2955 // TODO(gman): CompressedTexSubImage2DImmediate |
2838 | 2956 |
2839 // TODO(gman): TexImage2D | 2957 // TODO(gman): TexImage2D |
2840 | 2958 |
2841 // TODO(gman): TexImage2DImmediate | 2959 // TODO(gman): TexImage2DImmediate |
2842 | 2960 |
2843 // TODO(gman): TexSubImage2DImmediate | 2961 // TODO(gman): TexSubImage2DImmediate |
2844 | 2962 |
2845 } // namespace gles2 | 2963 } // namespace gles2 |
2846 } // namespace gpu | 2964 } // namespace gpu |
OLD | NEW |