| 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) { |
| 7125 // We need to reset the decoder on each iteration, because we lose the | 7126 // We need to reset the decoder on each iteration, because we lose the |
| 7126 // context every time. | 7127 // context every time. |
| 7127 GLES2DecoderTestBase::InitState init; | 7128 GLES2DecoderTestBase::InitState init; |
| 7128 init.extensions = "GL_EXT_occlusion_query_boolean"; | 7129 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; |
| 7129 init.gl_version = "opengl es 2.0"; | 7130 init.gl_version = "opengl es 2.0"; |
| 7130 init.has_alpha = true; | 7131 init.has_alpha = true; |
| 7131 init.request_alpha = true; | 7132 init.request_alpha = true; |
| 7132 init.bind_generates_resource = true; | 7133 init.bind_generates_resource = true; |
| 7133 test->InitDecoder(init); | 7134 test->InitDecoder(init); |
| 7134 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 7135 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 7135 | 7136 |
| 7136 BeginQueryEXT begin_cmd; | 7137 BeginQueryEXT begin_cmd; |
| 7137 | 7138 |
| 7138 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 7139 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| (...skipping 14 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 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); |
| 7165 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 7166 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation(); |
| 7167 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 7168 .WillOnce(Return(kGlSync)) |
| 7169 .RetiresOnSaturation(); |
| 7170 } |
| 7163 | 7171 |
| 7164 EndQueryEXT end_cmd; | 7172 EndQueryEXT end_cmd; |
| 7165 end_cmd.Init(query_type.type, 1); | 7173 end_cmd.Init(query_type.type, 1); |
| 7166 error::Error error2 = test->ExecuteCmd(end_cmd); | 7174 error::Error error2 = test->ExecuteCmd(end_cmd); |
| 7167 | 7175 |
| 7168 if (query_type.is_gl) { | 7176 if (query_type.is_gl) { |
| 7169 EXPECT_CALL(*gl, | 7177 EXPECT_CALL(*gl, |
| 7170 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 7178 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 7171 .WillOnce(SetArgumentPointee<2>(1)) | 7179 .WillOnce(SetArgumentPointee<2>(1)) |
| 7172 .RetiresOnSaturation(); | 7180 .RetiresOnSaturation(); |
| 7173 EXPECT_CALL(*gl, | 7181 EXPECT_CALL(*gl, |
| 7174 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) | 7182 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) |
| 7175 .WillOnce(SetArgumentPointee<2>(1)) | 7183 .WillOnce(SetArgumentPointee<2>(1)) |
| 7176 .RetiresOnSaturation(); | 7184 .RetiresOnSaturation(); |
| 7177 } | 7185 } |
| 7186 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 7187 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 7188 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 7189 .RetiresOnSaturation(); |
| 7190 } |
| 7178 | 7191 |
| 7179 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | 7192 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 7180 ASSERT_TRUE(query_manager != NULL); | 7193 ASSERT_TRUE(query_manager != NULL); |
| 7181 bool process_success = query_manager->ProcessPendingQueries(); | 7194 bool process_success = query_manager->ProcessPendingQueries(); |
| 7182 | 7195 |
| 7183 EXPECT_TRUE(error1 != error::kNoError || | 7196 EXPECT_TRUE(error1 != error::kNoError || |
| 7184 error2 != error::kNoError || | 7197 error2 != error::kNoError || |
| 7185 !process_success); | 7198 !process_success); |
| 7186 | 7199 |
| 7187 if (query_type.is_gl) { | 7200 if (query_type.is_gl) { |
| 7188 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) | 7201 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) |
| 7189 .Times(1) | 7202 .Times(1) |
| 7190 .RetiresOnSaturation(); | 7203 .RetiresOnSaturation(); |
| 7191 } | 7204 } |
| 7205 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) |
| 7206 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 7192 test->ResetDecoder(); | 7207 test->ResetDecoder(); |
| 7193 } | 7208 } |
| 7194 | 7209 |
| 7195 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { | 7210 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { |
| 7196 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 7211 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 7197 CheckBeginEndQueryBadMemoryFails( | 7212 CheckBeginEndQueryBadMemoryFails( |
| 7198 this, kNewClientId, kNewServiceId, | 7213 this, kNewClientId, kNewServiceId, |
| 7199 kQueryTypes[i], | 7214 kQueryTypes[i], |
| 7200 kInvalidSharedMemoryId, kSharedMemoryOffset); | 7215 kInvalidSharedMemoryId, kSharedMemoryOffset); |
| 7201 } | 7216 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7269 | 7284 |
| 7270 EndQueryEXT end_cmd; | 7285 EndQueryEXT end_cmd; |
| 7271 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); | 7286 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); |
| 7272 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 7287 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 7273 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 7288 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7274 EXPECT_FALSE(query->pending()); | 7289 EXPECT_FALSE(query->pending()); |
| 7275 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), | 7290 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), |
| 7276 static_cast<GLenum>(sync->result)); | 7291 static_cast<GLenum>(sync->result)); |
| 7277 } | 7292 } |
| 7278 | 7293 |
| 7294 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) { |
| 7295 InitState init; |
| 7296 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; |
| 7297 init.gl_version = "opengl es 2.0"; |
| 7298 init.has_alpha = true; |
| 7299 init.request_alpha = true; |
| 7300 init.bind_generates_resource = true; |
| 7301 InitDecoder(init); |
| 7302 |
| 7303 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 7304 |
| 7305 BeginQueryEXT begin_cmd; |
| 7306 begin_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, |
| 7307 kNewClientId, |
| 7308 kSharedMemoryId, |
| 7309 kSharedMemoryOffset); |
| 7310 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7311 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7312 |
| 7313 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 7314 ASSERT_TRUE(query_manager != NULL); |
| 7315 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 7316 ASSERT_TRUE(query != NULL); |
| 7317 EXPECT_FALSE(query->pending()); |
| 7318 |
| 7319 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef); |
| 7320 EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation(); |
| 7321 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 7322 .WillOnce(Return(kGlSync)) |
| 7323 .RetiresOnSaturation(); |
| 7324 |
| 7325 EndQueryEXT end_cmd; |
| 7326 end_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, 1); |
| 7327 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 7328 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7329 EXPECT_TRUE(query->pending()); |
| 7330 |
| 7331 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) |
| 7332 .WillOnce(Return(GL_TIMEOUT_EXPIRED)) |
| 7333 .RetiresOnSaturation(); |
| 7334 bool process_success = query_manager->ProcessPendingQueries(); |
| 7335 |
| 7336 EXPECT_TRUE(process_success); |
| 7337 EXPECT_TRUE(query->pending()); |
| 7338 |
| 7339 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _)) |
| 7340 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 7341 .RetiresOnSaturation(); |
| 7342 process_success = query_manager->ProcessPendingQueries(); |
| 7343 |
| 7344 EXPECT_TRUE(process_success); |
| 7345 EXPECT_FALSE(query->pending()); |
| 7346 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); |
| 7347 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); |
| 7348 |
| 7349 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 7350 ResetDecoder(); |
| 7351 } |
| 7352 |
| 7279 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { | 7353 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { |
| 7280 Mailbox mailbox = Mailbox::Generate(); | 7354 Mailbox mailbox = Mailbox::Generate(); |
| 7281 | 7355 |
| 7282 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); | 7356 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); |
| 7283 | 7357 |
| 7284 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 7358 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 7285 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7359 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7286 0, 0); | 7360 0, 0); |
| 7287 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7361 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7288 0, 0); | 7362 0, 0); |
| (...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9468 // TODO(gman): TexImage2DImmediate | 9542 // TODO(gman): TexImage2DImmediate |
| 9469 | 9543 |
| 9470 // TODO(gman): TexSubImage2DImmediate | 9544 // TODO(gman): TexSubImage2DImmediate |
| 9471 | 9545 |
| 9472 // TODO(gman): UseProgram | 9546 // TODO(gman): UseProgram |
| 9473 | 9547 |
| 9474 // TODO(gman): SwapBuffers | 9548 // TODO(gman): SwapBuffers |
| 9475 | 9549 |
| 9476 } // namespace gles2 | 9550 } // namespace gles2 |
| 9477 } // namespace gpu | 9551 } // namespace gpu |
| OLD | NEW |