Chromium Code Reviews

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

Issue 2190543005: Command buffer: feedback loop detection for CopyTexSubImage3D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bot failure: split tests, previous calls to CopyTexSubImage3D may make framebuffer incomplete Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1195 matching lines...)
1206 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, 1206 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1207 kX, kY, kWidth + 1, kHeight); 1207 kX, kY, kWidth + 1, kHeight);
1208 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1208 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1209 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1209 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1210 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, 1210 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1211 kX, kY, kWidth, kHeight + 1); 1211 kX, kY, kWidth, kHeight + 1);
1212 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1212 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1213 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1213 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1214 } 1214 }
1215 1215
1216 TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopSucceeds0) {
1217 const GLenum kTarget = GL_TEXTURE_3D;
1218 const GLint kInternalFormat = GL_RGB8;
1219 const GLint kXoffset = 0;
1220 const GLint kYoffset = 0;
1221 const GLint kZoffset = 0;
1222 const GLint kX = 0;
1223 const GLint kY = 0;
1224 const GLsizei kWidth = 2;
1225 const GLsizei kHeight = 2;
1226 const GLsizei kDepth = 2;
1227 const GLsizei kBorder = 0;
1228 const GLenum kFormat = GL_RGB;
1229 const GLenum kType = GL_UNSIGNED_BYTE;
1230
1231 DoBindTexture(kTarget, client_texture_id_, kServiceTextureId);
1232 DoBindFramebuffer(
1233 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
1234
1235 FramebufferTextureLayer tex_layer;
1236 CopyTexSubImage3D cmd;
1237
1238 // The source and the target for CopyTexSubImage3D are the same 3d texture.
1239 // But level of 3D texture != level of read attachment in fbo.
1240 GLint kLevel = 0;
1241 GLint kLayer = 0; // kZoffset is 0
1242 EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER,
1243 GL_COLOR_ATTACHMENT0,
1244 kServiceTextureId, kLevel, kLayer))
1245 .Times(1)
1246 .RetiresOnSaturation();
1247 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth,
1248 kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset);
1249 tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_,
1250 kLevel, kLayer);
1251 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer));
1252 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1253
1254 kLevel = 1;
1255 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
1256 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
1257 .RetiresOnSaturation();
1258 EXPECT_CALL(*gl_,
1259 CopyTexSubImage3D(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1260 kX, kY, kWidth, kHeight))
1261 .Times(1)
1262 .RetiresOnSaturation();
1263 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth,
1264 kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset);
1265 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1266 kX, kY, kWidth, kHeight);
1267 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1268 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1269 }
1270
1271 TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopSucceeds1) {
1272 const GLenum kTarget = GL_TEXTURE_3D;
1273 const GLint kInternalFormat = GL_RGB8;
1274 const GLint kXoffset = 0;
1275 const GLint kYoffset = 0;
1276 const GLint kZoffset = 0;
1277 const GLint kX = 0;
1278 const GLint kY = 0;
1279 const GLsizei kWidth = 2;
1280 const GLsizei kHeight = 2;
1281 const GLsizei kDepth = 2;
1282 const GLsizei kBorder = 0;
1283 const GLenum kFormat = GL_RGB;
1284 const GLenum kType = GL_UNSIGNED_BYTE;
1285
1286 DoBindTexture(kTarget, client_texture_id_, kServiceTextureId);
1287 DoBindFramebuffer(
1288 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
1289
1290 FramebufferTextureLayer tex_layer;
1291 CopyTexSubImage3D cmd;
1292
1293 // The source and the target for CopyTexSubImage3D are the same 3d texture.
1294 // But zoffset of 3D texture != layer of read attachment in fbo.
1295 GLint kLevel = 0;
1296 GLint kLayer = 1; // kZoffset is 0
1297 EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER,
1298 GL_COLOR_ATTACHMENT0,
1299 kServiceTextureId, kLevel, kLayer))
1300 .Times(1)
1301 .RetiresOnSaturation();
1302 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth,
1303 kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset);
1304 tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_,
1305 kLevel, kLayer);
1306 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer));
1307 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1308
1309 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
1310 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
1311 .RetiresOnSaturation();
1312 EXPECT_CALL(*gl_,
1313 CopyTexSubImage3D(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1314 kX, kY, kWidth, kHeight))
1315 .Times(1)
1316 .RetiresOnSaturation();
1317 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1318 kX, kY, kWidth, kHeight);
1319 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1320 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1321 }
1322
1323 TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopFails) {
1324 const GLenum kTarget = GL_TEXTURE_3D;
1325 const GLint kInternalFormat = GL_RGB8;
1326 const GLint kXoffset = 0;
1327 const GLint kYoffset = 0;
1328 const GLint kZoffset = 0;
1329 const GLint kX = 0;
1330 const GLint kY = 0;
1331 const GLsizei kWidth = 2;
1332 const GLsizei kHeight = 2;
1333 const GLsizei kDepth = 2;
1334 const GLsizei kBorder = 0;
1335 const GLenum kFormat = GL_RGB;
1336 const GLenum kType = GL_UNSIGNED_BYTE;
1337
1338 DoBindTexture(kTarget, client_texture_id_, kServiceTextureId);
1339 DoBindFramebuffer(
1340 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
1341
1342 FramebufferTextureLayer tex_layer;
1343 CopyTexSubImage3D cmd;
1344
1345 // The source and the target for CopyTexSubImage3D are the same 3d texture.
1346 // And level / zoffset of 3D texture equal to level / layer of read attachment
1347 // in fbo.
1348 GLint kLevel = 1;
1349 GLint kLayer = 0; // kZoffset is 0
1350 EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER,
1351 GL_COLOR_ATTACHMENT0,
1352 kServiceTextureId, kLevel, kLayer))
1353 .Times(1)
1354 .RetiresOnSaturation();
1355 DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth,
1356 kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset);
1357 tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_,
1358 kLevel, kLayer);
1359 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer));
1360 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1361
1362 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
1363 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
1364 .RetiresOnSaturation();
1365 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1366 kX, kY, kWidth, kHeight);
1367 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1368 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1369 }
1370
1216 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) { 1371 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) {
1217 const uint32_t kBucketId = 123; 1372 const uint32_t kBucketId = 123;
1218 const GLenum kTarget = GL_TEXTURE_2D_ARRAY; 1373 const GLenum kTarget = GL_TEXTURE_2D_ARRAY;
1219 const GLint kLevel = 0; 1374 const GLint kLevel = 0;
1220 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; 1375 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
1221 const GLsizei kWidth = 4; 1376 const GLsizei kWidth = 4;
1222 const GLsizei kHeight = 8; 1377 const GLsizei kHeight = 8;
1223 const GLsizei kDepth = 4; 1378 const GLsizei kDepth = 4;
1224 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); 1379 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId);
1225 ASSERT_TRUE(bucket != NULL); 1380 ASSERT_TRUE(bucket != NULL);
(...skipping 2993 matching lines...)
4219 // TODO(gman): CompressedTexSubImage2DImmediate 4374 // TODO(gman): CompressedTexSubImage2DImmediate
4220 4375
4221 // TODO(gman): TexImage2D 4376 // TODO(gman): TexImage2D
4222 4377
4223 // TODO(gman): TexImage2DImmediate 4378 // TODO(gman): TexImage2DImmediate
4224 4379
4225 // TODO(gman): TexSubImage2DImmediate 4380 // TODO(gman): TexSubImage2DImmediate
4226 4381
4227 } // namespace gles2 4382 } // namespace gles2
4228 } // namespace gpu 4383 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine