Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 932963003: Add glClientWaitSync to GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 905a390b4f922c324a0f74eb89dbc4b9b5545554..e99ee62ee848206f907c356dcdd13649776c8468 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -265,6 +265,89 @@ TEST_P(GLES2DecoderTest, IsTexture) {
EXPECT_FALSE(DoIsTexture(client_texture_id_));
}
+TEST_P(GLES2DecoderTest, ClientWaitSyncValid) {
+ typedef cmds::ClientWaitSync::Result Result;
+ Result* result = static_cast<Result*>(shared_memory_address_);
+ cmds::ClientWaitSync cmd;
+ GLuint64Union mapping;
+ mapping.param64 = 0;
+ cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1],
+ shared_memory_id_, shared_memory_offset_);
+ EXPECT_CALL(*gl_,
+ ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId),
+ GL_SYNC_FLUSH_COMMANDS_BIT, 0))
+ .WillOnce(Return(GL_CONDITION_SATISFIED))
+ .RetiresOnSaturation();
+ *result = GL_WAIT_FAILED;
+ decoder_->set_unsafe_es3_apis_enabled(true);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(static_cast<GLenum>(GL_CONDITION_SATISFIED), *result);
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ decoder_->set_unsafe_es3_apis_enabled(false);
+ EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
+}
+
+TEST_P(GLES2DecoderTest, ClientWaitSyncNonZeroTimeoutFails) {
+ typedef cmds::ClientWaitSync::Result Result;
+ Result* result = static_cast<Result*>(shared_memory_address_);
+ cmds::ClientWaitSync cmd;
+ GLuint64Union mapping;
+ decoder_->set_unsafe_es3_apis_enabled(true);
+ mapping.param64 = 0xABCDEF0123456789;
+ cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1],
+ shared_memory_id_, shared_memory_offset_);
+ *result = GL_WAIT_FAILED;
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(static_cast<GLenum>(GL_WAIT_FAILED), *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
+TEST_P(GLES2DecoderTest, ClientWaitSyncInvalidSyncFails) {
+ typedef cmds::ClientWaitSync::Result Result;
+ Result* result = static_cast<Result*>(shared_memory_address_);
+ cmds::ClientWaitSync cmd;
+ GLuint64Union mapping;
+ decoder_->set_unsafe_es3_apis_enabled(true);
+ mapping.param64 = 0;
+ cmd.Init(kInvalidClientId, mapping.param32[0], mapping.param32[1],
+ shared_memory_id_, shared_memory_offset_);
+ *result = GL_WAIT_FAILED;
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(static_cast<GLenum>(GL_WAIT_FAILED), *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
+TEST_P(GLES2DecoderTest, ClientWaitSyncResultNotInitFails) {
+ typedef cmds::ClientWaitSync::Result Result;
+ Result* result = static_cast<Result*>(shared_memory_address_);
+ cmds::ClientWaitSync cmd;
+ GLuint64Union mapping;
+ decoder_->set_unsafe_es3_apis_enabled(true);
+ mapping.param64 = 0;
+ cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1],
+ shared_memory_id_, shared_memory_offset_);
+ *result = 1; // Any value other than GL_WAIT_FAILED
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_P(GLES2DecoderTest, ClientWaitSyncBadSharedMemoryFails) {
+ typedef cmds::ClientWaitSync::Result Result;
+ Result* result = static_cast<Result*>(shared_memory_address_);
+ cmds::ClientWaitSync cmd;
+ GLuint64Union mapping;
+ decoder_->set_unsafe_es3_apis_enabled(true);
+ mapping.param64 = 0;
+ *result = GL_WAIT_FAILED;
+ cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1],
+ kInvalidSharedMemoryId, shared_memory_offset_);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+
+ *result = GL_WAIT_FAILED;
+ cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1],
+ shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
+
TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) {
InitState init;
InitDecoder(init);

Powered by Google App Engine
This is Rietveld 408576698