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

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 2043983002: gpu: Disallow null client ids in Gen* functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """code generator for GLES2 command buffers.""" 6 """code generator for GLES2 command buffers."""
7 7
8 import itertools 8 import itertools
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 6168 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 """ 6179 """
6180 f.write(code) 6180 f.write(code)
6181 6181
6182 def WriteHandlerImplementation (self, func, f): 6182 def WriteHandlerImplementation (self, func, f):
6183 """Overrriden from TypeHandler.""" 6183 """Overrriden from TypeHandler."""
6184 raise NotImplementedError("GENn functions are immediate") 6184 raise NotImplementedError("GENn functions are immediate")
6185 6185
6186 def WriteImmediateHandlerImplementation(self, func, f): 6186 def WriteImmediateHandlerImplementation(self, func, f):
6187 """Overrriden from TypeHandler.""" 6187 """Overrriden from TypeHandler."""
6188 param_name = func.GetLastOriginalArg().name 6188 param_name = func.GetLastOriginalArg().name
6189 f.write(" if (!CheckUniqueIds(n, %s) || !%sHelper(n, %s)) {\n" 6189 f.write(" if (!CheckUniqueAndNonNullIds(n, %s) || !%sHelper(n, %s)) {\n"
6190 " return error::kInvalidArguments;\n" 6190 " return error::kInvalidArguments;\n"
6191 " }\n" % 6191 " }\n" %
6192 (param_name, func.original_name, param_name)) 6192 (param_name, func.original_name, param_name))
6193 6193
6194 def WriteGLES2Implementation(self, func, f): 6194 def WriteGLES2Implementation(self, func, f):
6195 """Overrriden from TypeHandler.""" 6195 """Overrriden from TypeHandler."""
6196 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({ 6196 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({
6197 for (GLsizei i = 0; i < n; ++i) { 6197 for (GLsizei i = 0; i < n; ++i) {
6198 GPU_CLIENT_LOG(" " << i << ": " << %s[i]); 6198 GPU_CLIENT_LOG(" " << i << ": " << %s[i]);
6199 } 6199 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 EXPECT_EQ(error::kNoError, 6285 EXPECT_EQ(error::kNoError,
6286 ExecuteImmediateCmd(*cmd, sizeof(temp))); 6286 ExecuteImmediateCmd(*cmd, sizeof(temp)));
6287 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6287 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6288 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); 6288 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL);
6289 } 6289 }
6290 """ 6290 """
6291 self.WriteValidUnitTest(func, f, valid_test, { 6291 self.WriteValidUnitTest(func, f, valid_test, {
6292 'resource_name': func.GetInfo('resource_type'), 6292 'resource_name': func.GetInfo('resource_type'),
6293 }, *extras) 6293 }, *extras)
6294 duplicate_id_test = """ 6294 duplicate_id_test = """
6295 TEST_P(%(test_name)s, %(name)sDuplicateIds) { 6295 TEST_P(%(test_name)s, %(name)sDuplicateOrNullIds) {
6296 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); 6296 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
6297 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); 6297 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>();
6298 GLuint temp[3] = {kNewClientId, kNewClientId + 1, kNewClientId}; 6298 GLuint temp[3] = {kNewClientId, kNewClientId + 1, kNewClientId};
6299 SpecializedSetup<cmds::%(name)s, 1>(true);""" 6299 SpecializedSetup<cmds::%(name)s, 1>(true);"""
6300 if func.IsUnsafe(): 6300 if func.IsUnsafe():
6301 duplicate_id_test += """ 6301 duplicate_id_test += """
6302 decoder_->set_unsafe_es3_apis_enabled(true);""" 6302 decoder_->set_unsafe_es3_apis_enabled(true);"""
6303 duplicate_id_test += """ 6303 duplicate_id_test += """
6304 cmd->Init(3, temp); 6304 cmd->Init(3, temp);
6305 EXPECT_EQ(error::kInvalidArguments, 6305 EXPECT_EQ(error::kInvalidArguments,
6306 ExecuteImmediateCmd(*cmd, sizeof(temp))); 6306 ExecuteImmediateCmd(*cmd, sizeof(temp)));
6307 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) == NULL); 6307 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) == NULL);
6308 EXPECT_TRUE(Get%(resource_name)s(kNewClientId + 1) == NULL); 6308 EXPECT_TRUE(Get%(resource_name)s(kNewClientId + 1) == NULL);
6309 GLuint null_id[2] = {kNewClientId, 0};
6310 cmd->Init(2, null_id);
6311 EXPECT_EQ(error::kInvalidArguments,
6312 ExecuteImmediateCmd(*cmd, sizeof(temp)));
6313 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) == NULL);
6309 } 6314 }
6310 """ 6315 """
6311 self.WriteValidUnitTest(func, f, duplicate_id_test, { 6316 self.WriteValidUnitTest(func, f, duplicate_id_test, {
6312 'resource_name': func.GetInfo('resource_type'), 6317 'resource_name': func.GetInfo('resource_type'),
6313 }, *extras) 6318 }, *extras)
6314 invalid_test = """ 6319 invalid_test = """
6315 TEST_P(%(test_name)s, %(name)sInvalidArgs) { 6320 TEST_P(%(test_name)s, %(name)sInvalidArgs) {
6316 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); 6321 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
6317 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); 6322 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>();
6318 SpecializedSetup<cmds::%(name)s, 0>(false); 6323 SpecializedSetup<cmds::%(name)s, 0>(false);
(...skipping 5201 matching lines...) Expand 10 before | Expand all | Expand 10 after
11520 Format(gen.generated_cpp_filenames) 11525 Format(gen.generated_cpp_filenames)
11521 11526
11522 if gen.errors > 0: 11527 if gen.errors > 0:
11523 print "%d errors" % gen.errors 11528 print "%d errors" % gen.errors
11524 return 1 11529 return 1
11525 return 0 11530 return 0
11526 11531
11527 11532
11528 if __name__ == '__main__': 11533 if __name__ == '__main__':
11529 sys.exit(main(sys.argv[1:])) 11534 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698