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

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

Issue 2012533004: Add generated and hand-written passthrough command handlers with stub Doers. (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
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 4935 matching lines...) Expand 10 before | Expand all | Expand 10 after
4946 """ % {'name': func.name}) 4946 """ % {'name': func.name})
4947 if func.IsUnsafe(): 4947 if func.IsUnsafe():
4948 f.write("""if (!unsafe_es3_apis_enabled()) 4948 f.write("""if (!unsafe_es3_apis_enabled())
4949 return error::kUnknownCommand; 4949 return error::kUnknownCommand;
4950 """) 4950 """)
4951 f.write("""const gles2::cmds::%(name)s& c = 4951 f.write("""const gles2::cmds::%(name)s& c =
4952 *static_cast<const gles2::cmds::%(name)s*>(cmd_data); 4952 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
4953 (void)c; 4953 (void)c;
4954 """ % {'name': func.name}) 4954 """ % {'name': func.name})
4955 4955
4956 def WriteServiceImplementation(self, func, f): 4956 def WriteServiceHandlerArgGetCode(self, func, f):
4957 """Writes the service implementation for a command.""" 4957 """Writes the argument unpack code for service handlers."""
4958 self.WriteServiceHandlerFunctionHeader(func, f)
4959 self.WriteHandlerExtensionCheck(func, f)
4960 self.WriteHandlerDeferReadWrite(func, f);
4961 if len(func.GetOriginalArgs()) > 0: 4958 if len(func.GetOriginalArgs()) > 0:
4962 last_arg = func.GetLastOriginalArg() 4959 last_arg = func.GetLastOriginalArg()
4963 all_but_last_arg = func.GetOriginalArgs()[:-1] 4960 all_but_last_arg = func.GetOriginalArgs()[:-1]
4964 for arg in all_but_last_arg: 4961 for arg in all_but_last_arg:
4965 arg.WriteGetCode(f) 4962 arg.WriteGetCode(f)
4966 self.WriteGetDataSizeCode(func, f) 4963 self.WriteGetDataSizeCode(func, f)
4967 last_arg.WriteGetCode(f) 4964 last_arg.WriteGetCode(f)
4965
4966 def WriteImmediateServiceHandlerArgGetCode(self, func, f):
4967 """Writes the argument unpack code for immediate service handlers."""
4968 for arg in func.GetOriginalArgs():
4969 if arg.IsPointer():
4970 self.WriteGetDataSizeCode(func, f)
4971 arg.WriteGetCode(f)
4972
4973 def WriteBucketServiceHandlerArgGetCode(self, func, f):
4974 """Writes the argument unpack code for bucket service handlers."""
4975 for arg in func.GetCmdArgs():
4976 arg.WriteGetCode(f)
4977
4978 def WriteServiceImplementation(self, func, f):
4979 """Writes the service implementation for a command."""
4980 self.WriteServiceHandlerFunctionHeader(func, f)
4981 self.WriteHandlerExtensionCheck(func, f)
4982 self.WriteHandlerDeferReadWrite(func, f);
4983 self.WriteServiceHandlerArgGetCode(func, f)
4968 func.WriteHandlerValidation(f) 4984 func.WriteHandlerValidation(f)
4969 func.WriteHandlerImplementation(f) 4985 func.WriteHandlerImplementation(f)
4970 f.write(" return error::kNoError;\n") 4986 f.write(" return error::kNoError;\n")
4971 f.write("}\n") 4987 f.write("}\n")
4972 f.write("\n") 4988 f.write("\n")
4973 4989
4974 def WriteImmediateServiceImplementation(self, func, f): 4990 def WriteImmediateServiceImplementation(self, func, f):
4975 """Writes the service implementation for an immediate version of command.""" 4991 """Writes the service implementation for an immediate version of command."""
4976 self.WriteServiceHandlerFunctionHeader(func, f) 4992 self.WriteServiceHandlerFunctionHeader(func, f)
4977 self.WriteHandlerExtensionCheck(func, f) 4993 self.WriteHandlerExtensionCheck(func, f)
4978 self.WriteHandlerDeferReadWrite(func, f); 4994 self.WriteHandlerDeferReadWrite(func, f);
4979 for arg in func.GetOriginalArgs(): 4995 self.WriteImmediateServiceHandlerArgGetCode(func, f)
4980 if arg.IsPointer():
4981 self.WriteGetDataSizeCode(func, f)
4982 arg.WriteGetCode(f)
4983 func.WriteHandlerValidation(f) 4996 func.WriteHandlerValidation(f)
4984 func.WriteHandlerImplementation(f) 4997 func.WriteHandlerImplementation(f)
4985 f.write(" return error::kNoError;\n") 4998 f.write(" return error::kNoError;\n")
4986 f.write("}\n") 4999 f.write("}\n")
4987 f.write("\n") 5000 f.write("\n")
4988 5001
4989 def WriteBucketServiceImplementation(self, func, f): 5002 def WriteBucketServiceImplementation(self, func, f):
4990 """Writes the service implementation for a bucket version of command.""" 5003 """Writes the service implementation for a bucket version of command."""
4991 self.WriteServiceHandlerFunctionHeader(func, f) 5004 self.WriteServiceHandlerFunctionHeader(func, f)
4992 self.WriteHandlerExtensionCheck(func, f) 5005 self.WriteHandlerExtensionCheck(func, f)
4993 self.WriteHandlerDeferReadWrite(func, f); 5006 self.WriteHandlerDeferReadWrite(func, f);
4994 for arg in func.GetCmdArgs(): 5007 self.WriteBucketServiceHandlerArgGetCode(func, f)
4995 arg.WriteGetCode(f)
4996 func.WriteHandlerValidation(f) 5008 func.WriteHandlerValidation(f)
4997 func.WriteHandlerImplementation(f) 5009 func.WriteHandlerImplementation(f)
4998 f.write(" return error::kNoError;\n") 5010 f.write(" return error::kNoError;\n")
4999 f.write("}\n") 5011 f.write("}\n")
5000 f.write("\n") 5012 f.write("\n")
5001 5013
5014 def WritePassthroughServiceFunctionHeader(self, func, f):
5015 """Writes function header for service passthrough handlers."""
5016 f.write("""error::Error GLES2DecoderPassthroughImpl::Handle%(name)s(
5017 uint32_t immediate_data_size, const void* cmd_data) {
5018 """ % {'name': func.name})
5019 f.write("""const gles2::cmds::%(name)s& c =
5020 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
5021 (void)c;
5022 """ % {'name': func.name})
5023
5024 def WritePassthroughServiceFunctionDoerCall(self, func, f):
5025 """Writes the function call to the passthrough service doer."""
5026 f.write(""" error::Error error = Do%(name)s(%(args)s);
5027 if (error != error::kNoError) {
5028 return error;
5029 }""" % {'name': func.original_name,
5030 'args': func.MakePassthroughServiceDoerArgString("")})
5031
5032 def WritePassthroughServiceImplementation(self, func, f):
5033 """Writes the service implementation for a command."""
5034 self.WritePassthroughServiceFunctionHeader(func, f)
5035 self.WriteServiceHandlerArgGetCode(func, f)
5036 self.WritePassthroughServiceFunctionDoerCall(func, f)
5037 f.write(" return error::kNoError;\n")
5038 f.write("}\n")
5039 f.write("\n")
5040
5041 def WritePassthroughImmediateServiceImplementation(self, func, f):
5042 """Writes the service implementation for a command."""
5043 self.WritePassthroughServiceFunctionHeader(func, f)
5044 self.WriteImmediateServiceHandlerArgGetCode(func, f)
5045 self.WritePassthroughServiceFunctionDoerCall(func, f)
5046 f.write(" return error::kNoError;\n")
5047 f.write("}\n")
5048 f.write("\n")
5049
5050 def WritePassthroughBucketServiceImplementation(self, func, f):
5051 """Writes the service implementation for a command."""
5052 self.WritePassthroughServiceFunctionHeader(func, f)
5053 self.WriteBucketServiceHandlerArgGetCode(func, f)
5054 self.WritePassthroughServiceFunctionDoerCall(func, f)
5055 f.write(" return error::kNoError;\n")
5056 f.write("}\n")
5057 f.write("\n")
5058
5002 def WriteHandlerExtensionCheck(self, func, f): 5059 def WriteHandlerExtensionCheck(self, func, f):
5003 if func.GetInfo('extension_flag'): 5060 if func.GetInfo('extension_flag'):
5004 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag')) 5061 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag'))
5005 f.write(" return error::kUnknownCommand;") 5062 f.write(" return error::kUnknownCommand;")
5006 f.write(" }\n\n") 5063 f.write(" }\n\n")
5007 5064
5008 def WriteHandlerDeferReadWrite(self, func, f): 5065 def WriteHandlerDeferReadWrite(self, func, f):
5009 """Writes the code to handle deferring reads or writes.""" 5066 """Writes the code to handle deferring reads or writes."""
5010 defer_draws = func.GetInfo('defer_draws') 5067 defer_draws = func.GetInfo('defer_draws')
5011 defer_reads = func.GetInfo('defer_reads') 5068 defer_reads = func.GetInfo('defer_reads')
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
5628 pass 5685 pass
5629 5686
5630 def WriteImmediateServiceImplementation(self, func, f): 5687 def WriteImmediateServiceImplementation(self, func, f):
5631 """Overrriden from TypeHandler.""" 5688 """Overrriden from TypeHandler."""
5632 pass 5689 pass
5633 5690
5634 def WriteBucketServiceImplementation(self, func, f): 5691 def WriteBucketServiceImplementation(self, func, f):
5635 """Overrriden from TypeHandler.""" 5692 """Overrriden from TypeHandler."""
5636 pass 5693 pass
5637 5694
5695 def WritePassthroughServiceImplementation(self, func, f):
5696 """Overrriden from TypeHandler."""
5697 pass
5698
5699 def WritePassthroughImmediateServiceImplementation(self, func, f):
5700 """Overrriden from TypeHandler."""
5701 pass
5702
5703 def WritePassthroughBucketServiceImplementation(self, func, f):
5704 """Overrriden from TypeHandler."""
5705 pass
5706
5638 def WriteServiceUnitTest(self, func, f, *extras): 5707 def WriteServiceUnitTest(self, func, f, *extras):
5639 """Overrriden from TypeHandler.""" 5708 """Overrriden from TypeHandler."""
5640 pass 5709 pass
5641 5710
5642 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5711 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5643 """Overrriden from TypeHandler.""" 5712 """Overrriden from TypeHandler."""
5644 pass 5713 pass
5645 5714
5646 def WriteImmediateCmdGetTotalSize(self, func, f): 5715 def WriteImmediateCmdGetTotalSize(self, func, f):
5647 """Overrriden from TypeHandler.""" 5716 """Overrriden from TypeHandler."""
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5870 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5939 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5871 """Overrriden from TypeHandler.""" 5940 """Overrriden from TypeHandler."""
5872 pass 5941 pass
5873 5942
5874 def WriteBucketServiceImplementation(self, func, f): 5943 def WriteBucketServiceImplementation(self, func, f):
5875 """Overrriden from TypeHandler.""" 5944 """Overrriden from TypeHandler."""
5876 if ((not func.name == 'CompressedTexSubImage2DBucket') and 5945 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5877 (not func.name == 'CompressedTexSubImage3DBucket')): 5946 (not func.name == 'CompressedTexSubImage3DBucket')):
5878 TypeHandler.WriteBucketServiceImplemenation(self, func, f) 5947 TypeHandler.WriteBucketServiceImplemenation(self, func, f)
5879 5948
5949 def WritePassthroughBucketServiceImplementation(self, func, f):
5950 """Overrriden from TypeHandler."""
5951 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5952 (not func.name == 'CompressedTexSubImage3DBucket')):
5953 TypeHandler.WritePassthroughBucketServiceImplementation(self, func, f)
5880 5954
5881 class BindHandler(TypeHandler): 5955 class BindHandler(TypeHandler):
5882 """Handler for glBind___ type functions.""" 5956 """Handler for glBind___ type functions."""
5883 5957
5884 def WriteServiceUnitTest(self, func, f, *extras): 5958 def WriteServiceUnitTest(self, func, f, *extras):
5885 """Overrriden from TypeHandler.""" 5959 """Overrriden from TypeHandler."""
5886 5960
5887 if len(func.GetOriginalArgs()) == 1: 5961 if len(func.GetOriginalArgs()) == 1:
5888 valid_test = """ 5962 valid_test = """
5889 TEST_P(%(test_name)s, %(name)sValidArgs) { 5963 TEST_P(%(test_name)s, %(name)sValidArgs) {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 (func.name, func.MakeCmdArgString(""))) 6541 (func.name, func.MakeCmdArgString("")))
6468 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') 6542 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n')
6469 f.write(" CheckGLError();\n") 6543 f.write(" CheckGLError();\n")
6470 if func.return_type == "GLsync": 6544 if func.return_type == "GLsync":
6471 f.write(" return reinterpret_cast<GLsync>(client_id);\n") 6545 f.write(" return reinterpret_cast<GLsync>(client_id);\n")
6472 else: 6546 else:
6473 f.write(" return client_id;\n") 6547 f.write(" return client_id;\n")
6474 f.write("}\n") 6548 f.write("}\n")
6475 f.write("\n") 6549 f.write("\n")
6476 6550
6551 def WritePassthroughServiceImplementation(self, func, f):
6552 """Overrriden from TypeHandler."""
6553 pass
6477 6554
6478 class DeleteHandler(TypeHandler): 6555 class DeleteHandler(TypeHandler):
6479 """Handler for glDelete___ single resource type functions.""" 6556 """Handler for glDelete___ single resource type functions."""
6480 6557
6481 def WriteServiceImplementation(self, func, f): 6558 def WriteServiceImplementation(self, func, f):
6482 """Overrriden from TypeHandler.""" 6559 """Overrriden from TypeHandler."""
6483 if func.IsUnsafe(): 6560 if func.IsUnsafe():
6484 TypeHandler.WriteServiceImplementation(self, func, f) 6561 TypeHandler.WriteServiceImplementation(self, func, f)
6485 # HandleDeleteShader and HandleDeleteProgram are manually written. 6562 # HandleDeleteShader and HandleDeleteProgram are manually written.
6486 pass 6563 pass
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6763 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n") 6840 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n")
6764 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n") 6841 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n")
6765 f.write(" sizeof(ids)));\n") 6842 f.write(" sizeof(ids)));\n")
6766 f.write("}\n") 6843 f.write("}\n")
6767 f.write("\n") 6844 f.write("\n")
6768 6845
6769 6846
6770 class GETnHandler(TypeHandler): 6847 class GETnHandler(TypeHandler):
6771 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions.""" 6848 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions."""
6772 6849
6850 def InitFunction(self, func):
6851 """Overrriden from TypeHandler."""
6852 TypeHandler.InitFunction(self, func)
6853
6854 if func.name == 'GetSynciv':
6855 return
6856
6857 arg_insert_point = len(func.passthrough_service_doer_args) - 1;
6858 func.passthrough_service_doer_args.insert(
6859 arg_insert_point, Argument('length', 'GLsizei*'))
6860 func.passthrough_service_doer_args.insert(
6861 arg_insert_point, Argument('bufsize', 'GLsizei'))
6862
6773 def NeedsDataTransferFunction(self, func): 6863 def NeedsDataTransferFunction(self, func):
6774 """Overriden from TypeHandler.""" 6864 """Overriden from TypeHandler."""
6775 return False 6865 return False
6776 6866
6777 def WriteServiceImplementation(self, func, f): 6867 def WriteServiceImplementation(self, func, f):
6778 """Overrriden from TypeHandler.""" 6868 """Overrriden from TypeHandler."""
6779 self.WriteServiceHandlerFunctionHeader(func, f) 6869 self.WriteServiceHandlerFunctionHeader(func, f)
6780 last_arg = func.GetLastOriginalArg() 6870 last_arg = func.GetLastOriginalArg()
6781 # All except shm_id and shm_offset. 6871 # All except shm_id and shm_offset.
6782 all_but_last_args = func.GetCmdArgs()[:-2] 6872 all_but_last_args = func.GetCmdArgs()[:-2]
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6816 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); 6906 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s");
6817 if (error == GL_NO_ERROR) { 6907 if (error == GL_NO_ERROR) {
6818 result->SetNumResults(num_values); 6908 result->SetNumResults(num_values);
6819 } 6909 }
6820 return error::kNoError; 6910 return error::kNoError;
6821 } 6911 }
6822 6912
6823 """ 6913 """
6824 f.write(code % {'func_name': func.name}) 6914 f.write(code % {'func_name': func.name})
6825 6915
6916 def WritePassthroughServiceImplementation(self, func, f):
6917 """Overrriden from TypeHandler."""
6918 self.WritePassthroughServiceFunctionHeader(func, f)
6919 last_arg = func.GetLastOriginalArg()
6920 # All except shm_id and shm_offset.
6921 all_but_last_args = func.GetCmdArgs()[:-2]
6922 for arg in all_but_last_args:
6923 arg.WriteGetCode(f)
6924
6925 code = """ unsigned int buffer_size = 0;
6926 typedef cmds::%(func_name)s::Result Result;
6927 Result* result = GetSharedMemoryAndSizeAs<Result*>(
6928 c.%(last_arg_name)s_shm_id, c.%(last_arg_name)s_shm_offset,
6929 &buffer_size);
6930 %(last_arg_type)s %(last_arg_name)s = result ? result->GetData() : NULL;
6931 if (%(last_arg_name)s == NULL) {
6932 return error::kOutOfBounds;
6933 }
6934 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
6935 GLsizei written_values = 0;
6936 GLsizei* length = &written_values;
6937 """
6938 f.write(code % {
6939 'last_arg_type': last_arg.type,
6940 'last_arg_name': last_arg.name,
6941 'func_name': func.name,
6942 })
6943
6944 self.WritePassthroughServiceFunctionDoerCall(func, f)
6945
6946 code = """ if (written_values > bufsize) {
6947 return error::kOutOfBounds;
6948 }
6949 result->SetNumResults(written_values);
6950 return error::kNoError;
6951 }
6952
6953 """
6954 f.write(code % {'func_name': func.name})
6955
6826 def WriteGLES2Implementation(self, func, f): 6956 def WriteGLES2Implementation(self, func, f):
6827 """Overrriden from TypeHandler.""" 6957 """Overrriden from TypeHandler."""
6828 impl_decl = func.GetInfo('impl_decl') 6958 impl_decl = func.GetInfo('impl_decl')
6829 if impl_decl == None or impl_decl == True: 6959 if impl_decl == None or impl_decl == True:
6830 f.write("%s GLES2Implementation::%s(%s) {\n" % 6960 f.write("%s GLES2Implementation::%s(%s) {\n" %
6831 (func.return_type, func.original_name, 6961 (func.return_type, func.original_name,
6832 func.MakeTypedOriginalArgString(""))) 6962 func.MakeTypedOriginalArgString("")))
6833 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 6963 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6834 func.WriteDestinationInitalizationValidation(f) 6964 func.WriteDestinationInitalizationValidation(f)
6835 self.WriteClientGLCallLog(func, f) 6965 self.WriteClientGLCallLog(func, f)
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
8252 8382
8253 class IsHandler(TypeHandler): 8383 class IsHandler(TypeHandler):
8254 """Handler for glIs____ type and glGetError functions.""" 8384 """Handler for glIs____ type and glGetError functions."""
8255 8385
8256 def InitFunction(self, func): 8386 def InitFunction(self, func):
8257 """Overrriden from TypeHandler.""" 8387 """Overrriden from TypeHandler."""
8258 func.AddCmdArg(Argument("result_shm_id", 'uint32_t')) 8388 func.AddCmdArg(Argument("result_shm_id", 'uint32_t'))
8259 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t')) 8389 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t'))
8260 if func.GetInfo('result') == None: 8390 if func.GetInfo('result') == None:
8261 func.AddInfo('result', ['uint32_t']) 8391 func.AddInfo('result', ['uint32_t'])
8392 func.passthrough_service_doer_args.append(Argument('result', 'uint32_t*'))
8262 8393
8263 def WriteServiceUnitTest(self, func, f, *extras): 8394 def WriteServiceUnitTest(self, func, f, *extras):
8264 """Overrriden from TypeHandler.""" 8395 """Overrriden from TypeHandler."""
8265 valid_test = """ 8396 valid_test = """
8266 TEST_P(%(test_name)s, %(name)sValidArgs) { 8397 TEST_P(%(test_name)s, %(name)sValidArgs) {
8267 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); 8398 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
8268 SpecializedSetup<cmds::%(name)s, 0>(true); 8399 SpecializedSetup<cmds::%(name)s, 0>(true);
8269 cmds::%(name)s cmd; 8400 cmds::%(name)s cmd;
8270 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);""" 8401 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);"""
8271 if func.IsUnsafe(): 8402 if func.IsUnsafe():
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
8340 } 8471 }
8341 """ 8472 """
8342 f.write(code % {'func_name': func.name}) 8473 f.write(code % {'func_name': func.name})
8343 func.WriteHandlerValidation(f) 8474 func.WriteHandlerValidation(f)
8344 f.write(" *result_dst = %s(%s);\n" % 8475 f.write(" *result_dst = %s(%s);\n" %
8345 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) 8476 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
8346 f.write(" return error::kNoError;\n") 8477 f.write(" return error::kNoError;\n")
8347 f.write("}\n") 8478 f.write("}\n")
8348 f.write("\n") 8479 f.write("\n")
8349 8480
8481 def WritePassthroughServiceImplementation(self, func, f):
8482 """Overrriden from TypeHandler."""
8483 self.WritePassthroughServiceFunctionHeader(func, f)
8484 self.WriteServiceHandlerArgGetCode(func, f)
8485
8486 code = """ typedef cmds::%(func_name)s::Result Result;
8487 Result* result = GetSharedMemoryAs<Result*>(
8488 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8489 if (!result) {
8490 return error::kOutOfBounds;
8491 }
8492 """
8493 f.write(code % {'func_name': func.name})
8494 self.WritePassthroughServiceFunctionDoerCall(func, f)
8495 f.write(" return error::kNoError;\n")
8496 f.write("}\n")
8497 f.write("\n")
8498
8350 def WriteGLES2Implementation(self, func, f): 8499 def WriteGLES2Implementation(self, func, f):
8351 """Overrriden from TypeHandler.""" 8500 """Overrriden from TypeHandler."""
8352 impl_func = func.GetInfo('impl_func') 8501 impl_func = func.GetInfo('impl_func')
8353 if impl_func == None or impl_func == True: 8502 if impl_func == None or impl_func == True:
8354 error_value = func.GetInfo("error_value") or "GL_FALSE" 8503 error_value = func.GetInfo("error_value") or "GL_FALSE"
8355 f.write("%s GLES2Implementation::%s(%s) {\n" % 8504 f.write("%s GLES2Implementation::%s(%s) {\n" %
8356 (func.return_type, func.original_name, 8505 (func.return_type, func.original_name,
8357 func.MakeTypedOriginalArgString(""))) 8506 func.MakeTypedOriginalArgString("")))
8358 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 8507 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
8359 self.WriteTraceEvent(func, f) 8508 self.WriteTraceEvent(func, f)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
8529 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8678 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8530 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 8679 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
8531 } 8680 }
8532 """ 8681 """
8533 self.WriteValidUnitTest(func, f, invalid_test, *extras) 8682 self.WriteValidUnitTest(func, f, invalid_test, *extras)
8534 8683
8535 def WriteServiceImplementation(self, func, f): 8684 def WriteServiceImplementation(self, func, f):
8536 """Overrriden from TypeHandler.""" 8685 """Overrriden from TypeHandler."""
8537 pass 8686 pass
8538 8687
8688 def WritePassthroughServiceImplementation(self, func, f):
8689 """Overrriden from TypeHandler."""
8690 pass
8691
8539 class NamedType(object): 8692 class NamedType(object):
8540 """A class that represents a type of an argument in a client function. 8693 """A class that represents a type of an argument in a client function.
8541 8694
8542 A type of an argument that is to be passed through in the command buffer 8695 A type of an argument that is to be passed through in the command buffer
8543 command. Currently used only for the arguments that are specificly named in 8696 command. Currently used only for the arguments that are specificly named in
8544 the 'cmd_buffer_functions.txt' f, mostly enums. 8697 the 'cmd_buffer_functions.txt' f, mostly enums.
8545 """ 8698 """
8546 8699
8547 def __init__(self, info): 8700 def __init__(self, info):
8548 assert not 'is_complete' in info or info['is_complete'] == True 8701 assert not 'is_complete' in info or info['is_complete'] == True
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
9364 self.name = name 9517 self.name = name
9365 self.original_name = info['original_name'] 9518 self.original_name = info['original_name']
9366 9519
9367 self.original_args = self.ParseArgs(info['original_args']) 9520 self.original_args = self.ParseArgs(info['original_args'])
9368 9521
9369 if 'cmd_args' in info: 9522 if 'cmd_args' in info:
9370 self.args_for_cmds = self.ParseArgs(info['cmd_args']) 9523 self.args_for_cmds = self.ParseArgs(info['cmd_args'])
9371 else: 9524 else:
9372 self.args_for_cmds = self.original_args[:] 9525 self.args_for_cmds = self.original_args[:]
9373 9526
9527 self.passthrough_service_doer_args = self.original_args[:]
9528
9374 self.return_type = info['return_type'] 9529 self.return_type = info['return_type']
9375 if self.return_type != 'void': 9530 if self.return_type != 'void':
9376 self.return_arg = CreateArg(info['return_type'] + " result") 9531 self.return_arg = CreateArg(info['return_type'] + " result")
9377 else: 9532 else:
9378 self.return_arg = None 9533 self.return_arg = None
9379 9534
9380 self.num_pointer_args = sum( 9535 self.num_pointer_args = sum(
9381 [1 for arg in self.args_for_cmds if arg.IsPointer()]) 9536 [1 for arg in self.args_for_cmds if arg.IsPointer()])
9382 if self.num_pointer_args > 0: 9537 if self.num_pointer_args > 0:
9383 for arg in reversed(self.original_args): 9538 for arg in reversed(self.original_args):
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
9521 return [arg for arg in self.args_for_cmds if arg.IsConstant()] 9676 return [arg for arg in self.args_for_cmds if arg.IsConstant()]
9522 9677
9523 def GetInitArgs(self): 9678 def GetInitArgs(self):
9524 """Gets the init args for this function.""" 9679 """Gets the init args for this function."""
9525 return self.init_args 9680 return self.init_args
9526 9681
9527 def GetOriginalArgs(self): 9682 def GetOriginalArgs(self):
9528 """Gets the original arguments to this function.""" 9683 """Gets the original arguments to this function."""
9529 return self.original_args 9684 return self.original_args
9530 9685
9686 def GetPassthroughServiceDoerArgs(self):
9687 """Gets the original arguments to this function."""
9688 return self.passthrough_service_doer_args
9689
9531 def GetLastOriginalArg(self): 9690 def GetLastOriginalArg(self):
9532 """Gets the last original argument to this function.""" 9691 """Gets the last original argument to this function."""
9533 return self.original_args[len(self.original_args) - 1] 9692 return self.original_args[len(self.original_args) - 1]
9534 9693
9535 def GetLastOriginalPointerArg(self): 9694 def GetLastOriginalPointerArg(self):
9536 return self.last_original_pointer_arg 9695 return self.last_original_pointer_arg
9537 9696
9538 def GetResourceIdArg(self): 9697 def GetResourceIdArg(self):
9539 for arg in self.original_args: 9698 for arg in self.original_args:
9540 if hasattr(arg, 'resource_type'): 9699 if hasattr(arg, 'resource_type'):
(...skipping 14 matching lines...) Expand all
9555 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) 9714 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args])
9556 return self._MaybePrependComma(arg_string, add_comma) 9715 return self._MaybePrependComma(arg_string, add_comma)
9557 9716
9558 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 9717 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9559 """Gets the list of arguments as they are in GL.""" 9718 """Gets the list of arguments as they are in GL."""
9560 args = self.GetOriginalArgs() 9719 args = self.GetOriginalArgs()
9561 arg_string = separator.join( 9720 arg_string = separator.join(
9562 ["%s%s" % (prefix, arg.name) for arg in args]) 9721 ["%s%s" % (prefix, arg.name) for arg in args])
9563 return self._MaybePrependComma(arg_string, add_comma) 9722 return self._MaybePrependComma(arg_string, add_comma)
9564 9723
9724 def MakePassthroughServiceDoerArgString(self, prefix, add_comma = False,
9725 separator = ", "):
9726 """Gets the list of arguments as they are in used by the passthrough
9727 service doer function."""
9728 args = self.GetPassthroughServiceDoerArgs()
9729 arg_string = separator.join(
9730 ["%s%s" % (prefix, arg.name) for arg in args])
9731 return self._MaybePrependComma(arg_string, add_comma)
9732
9565 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "): 9733 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "):
9566 """Gets a list of GL arguments after removing unneeded arguments.""" 9734 """Gets a list of GL arguments after removing unneeded arguments."""
9567 args = self.GetOriginalArgs() 9735 args = self.GetOriginalArgs()
9568 arg_string = separator.join( 9736 arg_string = separator.join(
9569 ["%s%s" % (prefix, arg.name) 9737 ["%s%s" % (prefix, arg.name)
9570 for arg in args if not arg.IsConstant()]) 9738 for arg in args if not arg.IsConstant()])
9571 return self._MaybePrependComma(arg_string, add_comma) 9739 return self._MaybePrependComma(arg_string, add_comma)
9572 9740
9573 def MakeTypedPepperArgString(self, prefix): 9741 def MakeTypedPepperArgString(self, prefix):
9574 """Gets a list of arguments as they need to be for Pepper.""" 9742 """Gets a list of arguments as they need to be for Pepper."""
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
9728 self.type_handler.WriteDocs(self, f) 9896 self.type_handler.WriteDocs(self, f)
9729 9897
9730 def WriteCmdHelper(self, f): 9898 def WriteCmdHelper(self, f):
9731 """Writes the cmd's helper.""" 9899 """Writes the cmd's helper."""
9732 self.type_handler.WriteCmdHelper(self, f) 9900 self.type_handler.WriteCmdHelper(self, f)
9733 9901
9734 def WriteServiceImplementation(self, f): 9902 def WriteServiceImplementation(self, f):
9735 """Writes the service implementation for a command.""" 9903 """Writes the service implementation for a command."""
9736 self.type_handler.WriteServiceImplementation(self, f) 9904 self.type_handler.WriteServiceImplementation(self, f)
9737 9905
9906 def WritePassthroughServiceImplementation(self, f):
9907 """Writes the service implementation for a command."""
9908 self.type_handler.WritePassthroughServiceImplementation(self, f)
9909
9738 def WriteServiceUnitTest(self, f, *extras): 9910 def WriteServiceUnitTest(self, f, *extras):
9739 """Writes the service implementation for a command.""" 9911 """Writes the service implementation for a command."""
9740 self.type_handler.WriteServiceUnitTest(self, f, *extras) 9912 self.type_handler.WriteServiceUnitTest(self, f, *extras)
9741 9913
9742 def WriteGLES2CLibImplementation(self, f): 9914 def WriteGLES2CLibImplementation(self, f):
9743 """Writes the GLES2 C Lib Implemention.""" 9915 """Writes the GLES2 C Lib Implemention."""
9744 self.type_handler.WriteGLES2CLibImplementation(self, f) 9916 self.type_handler.WriteGLES2CLibImplementation(self, f)
9745 9917
9746 def WriteGLES2InterfaceHeader(self, f): 9918 def WriteGLES2InterfaceHeader(self, f):
9747 """Writes the GLES2 Interface declaration.""" 9919 """Writes the GLES2 Interface declaration."""
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9844 10016
9845 Function.InitFunction(self) 10017 Function.InitFunction(self)
9846 10018
9847 def IsImmediate(self): 10019 def IsImmediate(self):
9848 return True 10020 return True
9849 10021
9850 def WriteServiceImplementation(self, f): 10022 def WriteServiceImplementation(self, f):
9851 """Overridden from Function""" 10023 """Overridden from Function"""
9852 self.type_handler.WriteImmediateServiceImplementation(self, f) 10024 self.type_handler.WriteImmediateServiceImplementation(self, f)
9853 10025
10026 def WritePassthroughServiceImplementation(self, f):
10027 """Overridden from Function"""
10028 self.type_handler.WritePassthroughImmediateServiceImplementation(self, f)
10029
9854 def WriteHandlerImplementation(self, f): 10030 def WriteHandlerImplementation(self, f):
9855 """Overridden from Function""" 10031 """Overridden from Function"""
9856 self.type_handler.WriteImmediateHandlerImplementation(self, f) 10032 self.type_handler.WriteImmediateHandlerImplementation(self, f)
9857 10033
9858 def WriteServiceUnitTest(self, f, *extras): 10034 def WriteServiceUnitTest(self, f, *extras):
9859 """Writes the service implementation for a command.""" 10035 """Writes the service implementation for a command."""
9860 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras) 10036 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras)
9861 10037
9862 def WriteValidationCode(self, f): 10038 def WriteValidationCode(self, f):
9863 """Overridden from Function""" 10039 """Overridden from Function"""
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
9919 new_args_for_cmds.append(new_arg) 10095 new_args_for_cmds.append(new_arg)
9920 10096
9921 self.args_for_cmds = new_args_for_cmds 10097 self.args_for_cmds = new_args_for_cmds
9922 10098
9923 Function.InitFunction(self) 10099 Function.InitFunction(self)
9924 10100
9925 def WriteServiceImplementation(self, f): 10101 def WriteServiceImplementation(self, f):
9926 """Overridden from Function""" 10102 """Overridden from Function"""
9927 self.type_handler.WriteBucketServiceImplementation(self, f) 10103 self.type_handler.WriteBucketServiceImplementation(self, f)
9928 10104
10105 def WritePassthroughServiceImplementation(self, f):
10106 """Overridden from Function"""
10107 self.type_handler.WritePassthroughBucketServiceImplementation(self, f)
10108
9929 def WriteHandlerImplementation(self, f): 10109 def WriteHandlerImplementation(self, f):
9930 """Overridden from Function""" 10110 """Overridden from Function"""
9931 self.type_handler.WriteBucketHandlerImplementation(self, f) 10111 self.type_handler.WriteBucketHandlerImplementation(self, f)
9932 10112
9933 def WriteServiceUnitTest(self, f, *extras): 10113 def WriteServiceUnitTest(self, f, *extras):
9934 """Overridden from Function""" 10114 """Overridden from Function"""
9935 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras) 10115 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras)
9936 10116
9937 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 10117 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9938 """Overridden from Function""" 10118 """Overridden from Function"""
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
10550 return false; 10730 return false;
10551 """ % capability) 10731 """ % capability)
10552 f.write(""" default: 10732 f.write(""" default:
10553 NOTREACHED(); 10733 NOTREACHED();
10554 return false; 10734 return false;
10555 } 10735 }
10556 } 10736 }
10557 """) 10737 """)
10558 self.generated_cpp_filenames.append(filename) 10738 self.generated_cpp_filenames.append(filename)
10559 10739
10740 def WritePassthroughServiceImplementation(self, filename):
10741 """Writes the passthrough service decorder implementation."""
10742 comment = "// It is included by gles2_cmd_decoder_passthrough.cc\n"
10743 with CHeaderWriter(filename, comment) as f:
10744 for func in self.functions:
10745 func.WritePassthroughServiceImplementation(f)
10746 self.generated_cpp_filenames.append(filename)
10747
10560 def WriteServiceUnitTests(self, filename_pattern): 10748 def WriteServiceUnitTests(self, filename_pattern):
10561 """Writes the service decorder unit tests.""" 10749 """Writes the service decorder unit tests."""
10562 num_tests = len(self.functions) 10750 num_tests = len(self.functions)
10563 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change. 10751 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change.
10564 count = 0 10752 count = 0
10565 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE): 10753 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE):
10566 count += 1 10754 count += 1
10567 filename = filename_pattern % count 10755 filename = filename_pattern % count
10568 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \ 10756 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \
10569 % count 10757 % count
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
11265 gen.WriteGLES2TraceImplementationHeader( 11453 gen.WriteGLES2TraceImplementationHeader(
11266 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h") 11454 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h")
11267 gen.WriteGLES2TraceImplementation( 11455 gen.WriteGLES2TraceImplementation(
11268 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h") 11456 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h")
11269 gen.WriteGLES2CLibImplementation( 11457 gen.WriteGLES2CLibImplementation(
11270 "gpu/command_buffer/client/gles2_c_lib_autogen.h") 11458 "gpu/command_buffer/client/gles2_c_lib_autogen.h")
11271 gen.WriteCmdHelperHeader( 11459 gen.WriteCmdHelperHeader(
11272 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h") 11460 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h")
11273 gen.WriteServiceImplementation( 11461 gen.WriteServiceImplementation(
11274 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h") 11462 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h")
11463 gen.WritePassthroughServiceImplementation(
11464 "gpu/command_buffer/service/" +
11465 "gles2_cmd_decoder_passthrough_handlers_autogen.h")
11275 gen.WriteServiceContextStateHeader( 11466 gen.WriteServiceContextStateHeader(
11276 "gpu/command_buffer/service/context_state_autogen.h") 11467 "gpu/command_buffer/service/context_state_autogen.h")
11277 gen.WriteServiceContextStateImpl( 11468 gen.WriteServiceContextStateImpl(
11278 "gpu/command_buffer/service/context_state_impl_autogen.h") 11469 "gpu/command_buffer/service/context_state_impl_autogen.h")
11279 gen.WriteClientContextStateHeader( 11470 gen.WriteClientContextStateHeader(
11280 "gpu/command_buffer/client/client_context_state_autogen.h") 11471 "gpu/command_buffer/client/client_context_state_autogen.h")
11281 gen.WriteClientContextStateImpl( 11472 gen.WriteClientContextStateImpl(
11282 "gpu/command_buffer/client/client_context_state_impl_autogen.h") 11473 "gpu/command_buffer/client/client_context_state_impl_autogen.h")
11283 gen.WriteServiceUnitTests( 11474 gen.WriteServiceUnitTests(
11284 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h") 11475 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h")
(...skipping 15 matching lines...) Expand all
11300 Format(gen.generated_cpp_filenames) 11491 Format(gen.generated_cpp_filenames)
11301 11492
11302 if gen.errors > 0: 11493 if gen.errors > 0:
11303 print "%d errors" % gen.errors 11494 print "%d errors" % gen.errors
11304 return 1 11495 return 1
11305 return 0 11496 return 0
11306 11497
11307 11498
11308 if __name__ == '__main__': 11499 if __name__ == '__main__':
11309 sys.exit(main(sys.argv[1:])) 11500 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698