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

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

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [WIP] Review comments follow-up Created 6 years, 11 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 unified diff | Download patch
OLDNEW
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 7131 matching lines...) Expand 10 before | Expand all | Expand 10 after
7142 true, // has alpha 7142 true, // has alpha
7143 false, // has depth 7143 false, // has depth
7144 false, // has stencil 7144 false, // has stencil
7145 true, // request alpha 7145 true, // request alpha
7146 false, // request depth 7146 false, // request depth
7147 false, // request stencil 7147 false, // request stencil
7148 true); // bind generates resource 7148 true); // bind generates resource
7149 7149
7150 // Test end fails if no begin. 7150 // Test end fails if no begin.
7151 EndQueryEXT end_cmd; 7151 EndQueryEXT end_cmd;
7152 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); 7152 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, false, 1);
7153 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7153 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7154 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7154 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7155 7155
7156 BeginQueryEXT begin_cmd; 7156 BeginQueryEXT begin_cmd;
7157 7157
7158 // Test id = 0 fails. 7158 // Test id = 0 fails.
7159 begin_cmd.Init( 7159 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT,
7160 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); 7160 0,
7161 false,
7162 kSharedMemoryId,
7163 kSharedMemoryOffset);
7161 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7164 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7162 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7165 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7163 7166
7164 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7167 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7165 7168
7166 // Test valid parameters work. 7169 // Test valid parameters work.
7167 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) 7170 EXPECT_CALL(*gl_, GenQueriesARB(1, _))
7168 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) 7171 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
7169 .RetiresOnSaturation(); 7172 .RetiresOnSaturation();
7170 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) 7173 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId))
7171 .Times(1) 7174 .Times(1)
7172 .RetiresOnSaturation(); 7175 .RetiresOnSaturation();
7173 begin_cmd.Init( 7176 begin_cmd.Init(
7174 GL_ANY_SAMPLES_PASSED_EXT, kNewClientId, 7177 GL_ANY_SAMPLES_PASSED_EXT, kNewClientId,
7178 false,
7175 kSharedMemoryId, kSharedMemoryOffset); 7179 kSharedMemoryId, kSharedMemoryOffset);
7176 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7180 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7177 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7181 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7178 7182
7179 QueryManager* query_manager = decoder_->GetQueryManager(); 7183 QueryManager* query_manager = decoder_->GetQueryManager();
7180 ASSERT_TRUE(query_manager != NULL); 7184 ASSERT_TRUE(query_manager != NULL);
7181 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); 7185 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
7182 ASSERT_TRUE(query != NULL); 7186 ASSERT_TRUE(query != NULL);
7183 EXPECT_FALSE(query->pending()); 7187 EXPECT_FALSE(query->pending());
7184 7188
7185 // Test trying begin again fails 7189 // Test trying begin again fails
7186 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7190 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7187 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7191 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7188 7192
7189 // Test end fails with different target 7193 // Test end fails with different target
7190 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, 1); 7194 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, false, 1);
7191 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7195 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7192 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7196 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7193 7197
7194 // Test end succeeds 7198 // Test end succeeds
7195 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) 7199 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT))
7196 .Times(1) 7200 .Times(1)
7197 .RetiresOnSaturation(); 7201 .RetiresOnSaturation();
7198 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); 7202 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, false, 1);
7199 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7203 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7200 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7204 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7201 EXPECT_TRUE(query->pending()); 7205 EXPECT_TRUE(query->pending());
7202 7206
7203 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _)) 7207 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _))
7204 .Times(1) 7208 .Times(1)
7205 .RetiresOnSaturation(); 7209 .RetiresOnSaturation();
7206 } 7210 }
7207 7211
7208 static void CheckBeginEndQueryBadMemoryFails( 7212 static void CheckBeginEndQueryBadMemoryFails(
7209 GLES2DecoderTestBase* test, 7213 GLES2DecoderTestBase* test,
7210 GLuint client_id, 7214 GLuint client_id,
7211 GLuint service_id, 7215 GLuint service_id,
7212 int32 shm_id, 7216 int32 shm_id,
7213 uint32 shm_offset) { 7217 uint32 shm_offset) {
7214 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); 7218 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock();
7215 7219
7216 BeginQueryEXT begin_cmd; 7220 BeginQueryEXT begin_cmd;
7217 7221
7218 test->GenHelper<GenQueriesEXTImmediate>(client_id); 7222 test->GenHelper<GenQueriesEXTImmediate>(client_id);
7219 7223
7220 EXPECT_CALL(*gl, GenQueriesARB(1, _)) 7224 EXPECT_CALL(*gl, GenQueriesARB(1, _))
7221 .WillOnce(SetArgumentPointee<1>(service_id)) 7225 .WillOnce(SetArgumentPointee<1>(service_id))
7222 .RetiresOnSaturation(); 7226 .RetiresOnSaturation();
7223 EXPECT_CALL(*gl, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, service_id)) 7227 EXPECT_CALL(*gl, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, service_id))
7224 .Times(1) 7228 .Times(1)
7225 .RetiresOnSaturation(); 7229 .RetiresOnSaturation();
7226 7230
7227 // Test bad shared memory fails 7231 // Test bad shared memory fails
7228 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, client_id, shm_id, shm_offset); 7232 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, client_id,
7233 false, shm_id, shm_offset);
7229 error::Error error1 = test->ExecuteCmd(begin_cmd); 7234 error::Error error1 = test->ExecuteCmd(begin_cmd);
7230 7235
7231 EXPECT_CALL(*gl, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) 7236 EXPECT_CALL(*gl, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT))
7232 .Times(1) 7237 .Times(1)
7233 .RetiresOnSaturation(); 7238 .RetiresOnSaturation();
7234 7239
7235 EndQueryEXT end_cmd; 7240 EndQueryEXT end_cmd;
7236 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); 7241 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, false, 1);
7237 error::Error error2 = test->ExecuteCmd(end_cmd); 7242 error::Error error2 = test->ExecuteCmd(end_cmd);
7238 7243
7239 EXPECT_CALL(*gl, 7244 EXPECT_CALL(*gl,
7240 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) 7245 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _))
7241 .WillOnce(SetArgumentPointee<2>(1)) 7246 .WillOnce(SetArgumentPointee<2>(1))
7242 .RetiresOnSaturation(); 7247 .RetiresOnSaturation();
7243 EXPECT_CALL(*gl, 7248 EXPECT_CALL(*gl,
7244 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) 7249 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _))
7245 .WillOnce(SetArgumentPointee<2>(1)) 7250 .WillOnce(SetArgumentPointee<2>(1))
7246 .RetiresOnSaturation(); 7251 .RetiresOnSaturation();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
7291 } 7296 }
7292 7297
7293 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { 7298 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) {
7294 BeginQueryEXT begin_cmd; 7299 BeginQueryEXT begin_cmd;
7295 7300
7296 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7301 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7297 7302
7298 // Test valid parameters work. 7303 // Test valid parameters work.
7299 begin_cmd.Init( 7304 begin_cmd.Init(
7300 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId, 7305 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId,
7306 false,
7301 kSharedMemoryId, kSharedMemoryOffset); 7307 kSharedMemoryId, kSharedMemoryOffset);
7302 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7308 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7303 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7309 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7304 7310
7305 QueryManager* query_manager = decoder_->GetQueryManager(); 7311 QueryManager* query_manager = decoder_->GetQueryManager();
7306 ASSERT_TRUE(query_manager != NULL); 7312 ASSERT_TRUE(query_manager != NULL);
7307 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); 7313 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
7308 ASSERT_TRUE(query != NULL); 7314 ASSERT_TRUE(query != NULL);
7309 EXPECT_FALSE(query->pending()); 7315 EXPECT_FALSE(query->pending());
7310 7316
7311 // Test end succeeds 7317 // Test end succeeds
7312 EndQueryEXT end_cmd; 7318 EndQueryEXT end_cmd;
7313 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); 7319 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, false, 1);
7314 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7320 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7315 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7321 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7316 EXPECT_FALSE(query->pending()); 7322 EXPECT_FALSE(query->pending());
7317 } 7323 }
7318 7324
7319 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { 7325 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) {
7320 BeginQueryEXT begin_cmd; 7326 BeginQueryEXT begin_cmd;
7321 7327
7322 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7328 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7323 7329
7324 // Test valid parameters work. 7330 // Test valid parameters work.
7325 begin_cmd.Init( 7331 begin_cmd.Init(
7326 GL_GET_ERROR_QUERY_CHROMIUM, kNewClientId, 7332 GL_GET_ERROR_QUERY_CHROMIUM, kNewClientId,
7333 false,
7327 kSharedMemoryId, kSharedMemoryOffset); 7334 kSharedMemoryId, kSharedMemoryOffset);
7328 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7335 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7329 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7336 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7330 7337
7331 QueryManager* query_manager = decoder_->GetQueryManager(); 7338 QueryManager* query_manager = decoder_->GetQueryManager();
7332 ASSERT_TRUE(query_manager != NULL); 7339 ASSERT_TRUE(query_manager != NULL);
7333 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); 7340 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
7334 ASSERT_TRUE(query != NULL); 7341 ASSERT_TRUE(query != NULL);
7335 EXPECT_FALSE(query->pending()); 7342 EXPECT_FALSE(query->pending());
7336 7343
7337 // Test end succeeds 7344 // Test end succeeds
7338 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); 7345 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_);
7339 7346
7340 EXPECT_CALL(*gl_, GetError()) 7347 EXPECT_CALL(*gl_, GetError())
7341 .WillOnce(Return(GL_INVALID_VALUE)) 7348 .WillOnce(Return(GL_INVALID_VALUE))
7342 .RetiresOnSaturation(); 7349 .RetiresOnSaturation();
7343 7350
7344 EndQueryEXT end_cmd; 7351 EndQueryEXT end_cmd;
7345 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); 7352 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, false, 1);
7346 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7353 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7347 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7354 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7348 EXPECT_FALSE(query->pending()); 7355 EXPECT_FALSE(query->pending());
7349 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), 7356 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE),
7350 static_cast<GLenum>(sync->result)); 7357 static_cast<GLenum>(sync->result));
7351 } 7358 }
7352 7359
7353 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { 7360 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
7354 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; 7361 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
7355 group().mailbox_manager()->GenerateMailboxName( 7362 group().mailbox_manager()->GenerateMailboxName(
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
8849 // TODO(gman): TexImage2DImmediate 8856 // TODO(gman): TexImage2DImmediate
8850 8857
8851 // TODO(gman): TexSubImage2DImmediate 8858 // TODO(gman): TexSubImage2DImmediate
8852 8859
8853 // TODO(gman): UseProgram 8860 // TODO(gman): UseProgram
8854 8861
8855 // TODO(gman): SwapBuffers 8862 // TODO(gman): SwapBuffers
8856 8863
8857 } // namespace gles2 8864 } // namespace gles2
8858 } // namespace gpu 8865 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698