OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 7094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7105 GLenum type; | 7105 GLenum type; |
7106 bool is_gl; | 7106 bool is_gl; |
7107 }; | 7107 }; |
7108 | 7108 |
7109 const QueryType kQueryTypes[] = { | 7109 const QueryType kQueryTypes[] = { |
7110 { GL_COMMANDS_ISSUED_CHROMIUM, false }, | 7110 { GL_COMMANDS_ISSUED_CHROMIUM, false }, |
7111 { GL_LATENCY_QUERY_CHROMIUM, false }, | 7111 { GL_LATENCY_QUERY_CHROMIUM, false }, |
7112 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false }, | 7112 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false }, |
7113 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false }, | 7113 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false }, |
7114 { GL_GET_ERROR_QUERY_CHROMIUM, false }, | 7114 { GL_GET_ERROR_QUERY_CHROMIUM, false }, |
7115 { GL_COMMANDS_COMPLETED_CHROMIUM, false }, | |
7115 { GL_ANY_SAMPLES_PASSED_EXT, true }, | 7116 { GL_ANY_SAMPLES_PASSED_EXT, true }, |
7116 }; | 7117 }; |
7117 | 7118 |
7118 static void CheckBeginEndQueryBadMemoryFails( | 7119 static void CheckBeginEndQueryBadMemoryFails( |
7119 GLES2DecoderTestBase* test, | 7120 GLES2DecoderTestBase* test, |
7120 GLuint client_id, | 7121 GLuint client_id, |
7121 GLuint service_id, | 7122 GLuint service_id, |
7122 const QueryType& query_type, | 7123 const QueryType& query_type, |
7123 int32 shm_id, | 7124 int32 shm_id, |
7124 uint32 shm_offset) { | 7125 uint32 shm_offset) { |
(...skipping 28 matching lines...) Expand all Loading... | |
7153 if (query_type.is_gl) { | 7154 if (query_type.is_gl) { |
7154 EXPECT_CALL(*gl, EndQueryARB(query_type.type)) | 7155 EXPECT_CALL(*gl, EndQueryARB(query_type.type)) |
7155 .Times(1) | 7156 .Times(1) |
7156 .RetiresOnSaturation(); | 7157 .RetiresOnSaturation(); |
7157 } | 7158 } |
7158 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { | 7159 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { |
7159 EXPECT_CALL(*gl, GetError()) | 7160 EXPECT_CALL(*gl, GetError()) |
7160 .WillOnce(Return(GL_NO_ERROR)) | 7161 .WillOnce(Return(GL_NO_ERROR)) |
7161 .RetiresOnSaturation(); | 7162 .RetiresOnSaturation(); |
7162 } | 7163 } |
7164 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | |
7165 EXPECT_CALL(*gl, Finish()).Times(1).RetiresOnSaturation(); | |
7166 } | |
7163 | 7167 |
7164 EndQueryEXT end_cmd; | 7168 EndQueryEXT end_cmd; |
7165 end_cmd.Init(query_type.type, 1); | 7169 end_cmd.Init(query_type.type, 1); |
7166 error::Error error2 = test->ExecuteCmd(end_cmd); | 7170 error::Error error2 = test->ExecuteCmd(end_cmd); |
7167 | 7171 |
7168 if (query_type.is_gl) { | 7172 if (query_type.is_gl) { |
7169 EXPECT_CALL(*gl, | 7173 EXPECT_CALL(*gl, |
7170 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 7174 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
7171 .WillOnce(SetArgumentPointee<2>(1)) | 7175 .WillOnce(SetArgumentPointee<2>(1)) |
7172 .RetiresOnSaturation(); | 7176 .RetiresOnSaturation(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7269 | 7273 |
7270 EndQueryEXT end_cmd; | 7274 EndQueryEXT end_cmd; |
7271 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); | 7275 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); |
7272 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 7276 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
7273 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 7277 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
7274 EXPECT_FALSE(query->pending()); | 7278 EXPECT_FALSE(query->pending()); |
7275 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), | 7279 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), |
7276 static_cast<GLenum>(sync->result)); | 7280 static_cast<GLenum>(sync->result)); |
7277 } | 7281 } |
7278 | 7282 |
7283 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) { | |
7284 InitState init; | |
7285 init.extensions = "GL_ARB_sync"; | |
7286 init.gl_version = "opengl es 2.0"; | |
7287 init.has_alpha = true; | |
7288 init.request_alpha = true; | |
7289 init.bind_generates_resource = true; | |
7290 InitDecoder(init); | |
7291 | |
7292 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | |
7293 | |
7294 BeginQueryEXT begin_cmd; | |
7295 begin_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, | |
7296 kNewClientId, | |
7297 kSharedMemoryId, | |
7298 kSharedMemoryOffset); | |
7299 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | |
7300 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
7301 | |
7302 QueryManager* query_manager = decoder_->GetQueryManager(); | |
7303 ASSERT_TRUE(query_manager != NULL); | |
7304 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | |
7305 ASSERT_TRUE(query != NULL); | |
7306 EXPECT_FALSE(query->pending()); | |
7307 | |
7308 GLsync gl_sync = reinterpret_cast<GLsync>(0xdeadbeef); | |
no sievers
2014/04/15 18:41:15
nit: const GLsync kGLSync = ...
reveman
2014/04/15 22:29:28
Done.
| |
7309 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | |
7310 .WillOnce(Return(gl_sync)) | |
7311 .RetiresOnSaturation(); | |
no sievers
2014/04/15 18:41:15
no glFlush() expected?
reveman
2014/04/15 22:29:28
I was hoping we wouldn't need an implicit flush. T
| |
7312 | |
7313 EndQueryEXT end_cmd; | |
7314 end_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, 1); | |
7315 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | |
7316 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
7317 EXPECT_TRUE(query->pending()); | |
7318 | |
7319 EXPECT_CALL(*gl_, GetSynciv(gl_sync, GL_SYNC_STATUS, 1, _, _)) | |
7320 .WillOnce(SetArgumentPointee<4>(GL_UNSIGNALED)) | |
7321 .RetiresOnSaturation(); | |
7322 bool process_success = query_manager->ProcessPendingQueries(); | |
7323 | |
7324 EXPECT_TRUE(process_success); | |
7325 EXPECT_TRUE(query->pending()); | |
7326 | |
7327 EXPECT_CALL(*gl_, GetSynciv(gl_sync, GL_SYNC_STATUS, 1, _, _)) | |
7328 .WillOnce(SetArgumentPointee<4>(GL_SIGNALED)) | |
7329 .RetiresOnSaturation(); | |
7330 process_success = query_manager->ProcessPendingQueries(); | |
7331 | |
7332 EXPECT_TRUE(process_success); | |
7333 EXPECT_FALSE(query->pending()); | |
7334 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); | |
7335 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); | |
7336 | |
7337 EXPECT_CALL(*gl_, DeleteSync(gl_sync)).Times(1).RetiresOnSaturation(); | |
7338 ResetDecoder(); | |
7339 } | |
7340 | |
7279 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { | 7341 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { |
7280 Mailbox mailbox = Mailbox::Generate(); | 7342 Mailbox mailbox = Mailbox::Generate(); |
7281 | 7343 |
7282 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); | 7344 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); |
7283 | 7345 |
7284 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 7346 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
7285 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7347 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
7286 0, 0); | 7348 0, 0); |
7287 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7349 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
7288 0, 0); | 7350 0, 0); |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9445 // TODO(gman): TexImage2DImmediate | 9507 // TODO(gman): TexImage2DImmediate |
9446 | 9508 |
9447 // TODO(gman): TexSubImage2DImmediate | 9509 // TODO(gman): TexSubImage2DImmediate |
9448 | 9510 |
9449 // TODO(gman): UseProgram | 9511 // TODO(gman): UseProgram |
9450 | 9512 |
9451 // TODO(gman): SwapBuffers | 9513 // TODO(gman): SwapBuffers |
9452 | 9514 |
9453 } // namespace gles2 | 9515 } // namespace gles2 |
9454 } // namespace gpu | 9516 } // namespace gpu |
OLD | NEW |