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

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: rebase 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/common/buffer.h » ('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 4949 matching lines...) Expand 10 before | Expand all | Expand 10 after
4960 """ % {'name': func.name}) 4960 """ % {'name': func.name})
4961 if func.IsUnsafe(): 4961 if func.IsUnsafe():
4962 f.write("""if (!unsafe_es3_apis_enabled()) 4962 f.write("""if (!unsafe_es3_apis_enabled())
4963 return error::kUnknownCommand; 4963 return error::kUnknownCommand;
4964 """) 4964 """)
4965 f.write("""const gles2::cmds::%(name)s& c = 4965 f.write("""const gles2::cmds::%(name)s& c =
4966 *static_cast<const gles2::cmds::%(name)s*>(cmd_data); 4966 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
4967 (void)c; 4967 (void)c;
4968 """ % {'name': func.name}) 4968 """ % {'name': func.name})
4969 4969
4970 def WriteServiceImplementation(self, func, f): 4970 def WriteServiceHandlerArgGetCode(self, func, f):
4971 """Writes the service implementation for a command.""" 4971 """Writes the argument unpack code for service handlers."""
4972 self.WriteServiceHandlerFunctionHeader(func, f)
4973 self.WriteHandlerExtensionCheck(func, f)
4974 self.WriteHandlerDeferReadWrite(func, f);
4975 if len(func.GetOriginalArgs()) > 0: 4972 if len(func.GetOriginalArgs()) > 0:
4976 last_arg = func.GetLastOriginalArg() 4973 last_arg = func.GetLastOriginalArg()
4977 all_but_last_arg = func.GetOriginalArgs()[:-1] 4974 all_but_last_arg = func.GetOriginalArgs()[:-1]
4978 for arg in all_but_last_arg: 4975 for arg in all_but_last_arg:
4979 arg.WriteGetCode(f) 4976 arg.WriteGetCode(f)
4980 self.WriteGetDataSizeCode(func, f) 4977 self.WriteGetDataSizeCode(func, f)
4981 last_arg.WriteGetCode(f) 4978 last_arg.WriteGetCode(f)
4979
4980 def WriteImmediateServiceHandlerArgGetCode(self, func, f):
4981 """Writes the argument unpack code for immediate service handlers."""
4982 for arg in func.GetOriginalArgs():
4983 if arg.IsPointer():
4984 self.WriteGetDataSizeCode(func, f)
4985 arg.WriteGetCode(f)
4986
4987 def WriteBucketServiceHandlerArgGetCode(self, func, f):
4988 """Writes the argument unpack code for bucket service handlers."""
4989 for arg in func.GetCmdArgs():
4990 arg.WriteGetCode(f)
4991
4992 def WriteServiceImplementation(self, func, f):
4993 """Writes the service implementation for a command."""
4994 self.WriteServiceHandlerFunctionHeader(func, f)
4995 self.WriteHandlerExtensionCheck(func, f)
4996 self.WriteHandlerDeferReadWrite(func, f);
4997 self.WriteServiceHandlerArgGetCode(func, f)
4982 func.WriteHandlerValidation(f) 4998 func.WriteHandlerValidation(f)
4983 func.WriteHandlerImplementation(f) 4999 func.WriteHandlerImplementation(f)
4984 f.write(" return error::kNoError;\n") 5000 f.write(" return error::kNoError;\n")
4985 f.write("}\n") 5001 f.write("}\n")
4986 f.write("\n") 5002 f.write("\n")
4987 5003
4988 def WriteImmediateServiceImplementation(self, func, f): 5004 def WriteImmediateServiceImplementation(self, func, f):
4989 """Writes the service implementation for an immediate version of command.""" 5005 """Writes the service implementation for an immediate version of command."""
4990 self.WriteServiceHandlerFunctionHeader(func, f) 5006 self.WriteServiceHandlerFunctionHeader(func, f)
4991 self.WriteHandlerExtensionCheck(func, f) 5007 self.WriteHandlerExtensionCheck(func, f)
4992 self.WriteHandlerDeferReadWrite(func, f); 5008 self.WriteHandlerDeferReadWrite(func, f);
4993 for arg in func.GetOriginalArgs(): 5009 self.WriteImmediateServiceHandlerArgGetCode(func, f)
4994 if arg.IsPointer():
4995 self.WriteGetDataSizeCode(func, f)
4996 arg.WriteGetCode(f)
4997 func.WriteHandlerValidation(f) 5010 func.WriteHandlerValidation(f)
4998 func.WriteHandlerImplementation(f) 5011 func.WriteHandlerImplementation(f)
4999 f.write(" return error::kNoError;\n") 5012 f.write(" return error::kNoError;\n")
5000 f.write("}\n") 5013 f.write("}\n")
5001 f.write("\n") 5014 f.write("\n")
5002 5015
5003 def WriteBucketServiceImplementation(self, func, f): 5016 def WriteBucketServiceImplementation(self, func, f):
5004 """Writes the service implementation for a bucket version of command.""" 5017 """Writes the service implementation for a bucket version of command."""
5005 self.WriteServiceHandlerFunctionHeader(func, f) 5018 self.WriteServiceHandlerFunctionHeader(func, f)
5006 self.WriteHandlerExtensionCheck(func, f) 5019 self.WriteHandlerExtensionCheck(func, f)
5007 self.WriteHandlerDeferReadWrite(func, f); 5020 self.WriteHandlerDeferReadWrite(func, f);
5008 for arg in func.GetCmdArgs(): 5021 self.WriteBucketServiceHandlerArgGetCode(func, f)
5009 arg.WriteGetCode(f)
5010 func.WriteHandlerValidation(f) 5022 func.WriteHandlerValidation(f)
5011 func.WriteHandlerImplementation(f) 5023 func.WriteHandlerImplementation(f)
5012 f.write(" return error::kNoError;\n") 5024 f.write(" return error::kNoError;\n")
5013 f.write("}\n") 5025 f.write("}\n")
5014 f.write("\n") 5026 f.write("\n")
5015 5027
5028 def WritePassthroughServiceFunctionHeader(self, func, f):
5029 """Writes function header for service passthrough handlers."""
5030 f.write("""error::Error GLES2DecoderPassthroughImpl::Handle%(name)s(
5031 uint32_t immediate_data_size, const void* cmd_data) {
5032 """ % {'name': func.name})
5033 f.write("""const gles2::cmds::%(name)s& c =
5034 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
5035 (void)c;
5036 """ % {'name': func.name})
5037
5038 def WritePassthroughServiceFunctionDoerCall(self, func, f):
5039 """Writes the function call to the passthrough service doer."""
5040 f.write(""" error::Error error = Do%(name)s(%(args)s);
5041 if (error != error::kNoError) {
5042 return error;
5043 }""" % {'name': func.original_name,
5044 'args': func.MakePassthroughServiceDoerArgString("")})
5045
5046 def WritePassthroughServiceImplementation(self, func, f):
5047 """Writes the service implementation for a command."""
5048 self.WritePassthroughServiceFunctionHeader(func, f)
5049 self.WriteServiceHandlerArgGetCode(func, f)
5050 self.WritePassthroughServiceFunctionDoerCall(func, f)
5051 f.write(" return error::kNoError;\n")
5052 f.write("}\n")
5053 f.write("\n")
5054
5055 def WritePassthroughImmediateServiceImplementation(self, func, f):
5056 """Writes the service implementation for a command."""
5057 self.WritePassthroughServiceFunctionHeader(func, f)
5058 self.WriteImmediateServiceHandlerArgGetCode(func, f)
5059 self.WritePassthroughServiceFunctionDoerCall(func, f)
5060 f.write(" return error::kNoError;\n")
5061 f.write("}\n")
5062 f.write("\n")
5063
5064 def WritePassthroughBucketServiceImplementation(self, func, f):
5065 """Writes the service implementation for a command."""
5066 self.WritePassthroughServiceFunctionHeader(func, f)
5067 self.WriteBucketServiceHandlerArgGetCode(func, f)
5068 self.WritePassthroughServiceFunctionDoerCall(func, f)
5069 f.write(" return error::kNoError;\n")
5070 f.write("}\n")
5071 f.write("\n")
5072
5016 def WriteHandlerExtensionCheck(self, func, f): 5073 def WriteHandlerExtensionCheck(self, func, f):
5017 if func.GetInfo('extension_flag'): 5074 if func.GetInfo('extension_flag'):
5018 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag')) 5075 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag'))
5019 f.write(" return error::kUnknownCommand;") 5076 f.write(" return error::kUnknownCommand;")
5020 f.write(" }\n\n") 5077 f.write(" }\n\n")
5021 5078
5022 def WriteHandlerDeferReadWrite(self, func, f): 5079 def WriteHandlerDeferReadWrite(self, func, f):
5023 """Writes the code to handle deferring reads or writes.""" 5080 """Writes the code to handle deferring reads or writes."""
5024 defer_draws = func.GetInfo('defer_draws') 5081 defer_draws = func.GetInfo('defer_draws')
5025 defer_reads = func.GetInfo('defer_reads') 5082 defer_reads = func.GetInfo('defer_reads')
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
5642 pass 5699 pass
5643 5700
5644 def WriteImmediateServiceImplementation(self, func, f): 5701 def WriteImmediateServiceImplementation(self, func, f):
5645 """Overrriden from TypeHandler.""" 5702 """Overrriden from TypeHandler."""
5646 pass 5703 pass
5647 5704
5648 def WriteBucketServiceImplementation(self, func, f): 5705 def WriteBucketServiceImplementation(self, func, f):
5649 """Overrriden from TypeHandler.""" 5706 """Overrriden from TypeHandler."""
5650 pass 5707 pass
5651 5708
5709 def WritePassthroughServiceImplementation(self, func, f):
5710 """Overrriden from TypeHandler."""
5711 pass
5712
5713 def WritePassthroughImmediateServiceImplementation(self, func, f):
5714 """Overrriden from TypeHandler."""
5715 pass
5716
5717 def WritePassthroughBucketServiceImplementation(self, func, f):
5718 """Overrriden from TypeHandler."""
5719 pass
5720
5652 def WriteServiceUnitTest(self, func, f, *extras): 5721 def WriteServiceUnitTest(self, func, f, *extras):
5653 """Overrriden from TypeHandler.""" 5722 """Overrriden from TypeHandler."""
5654 pass 5723 pass
5655 5724
5656 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5725 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5657 """Overrriden from TypeHandler.""" 5726 """Overrriden from TypeHandler."""
5658 pass 5727 pass
5659 5728
5660 def WriteImmediateCmdGetTotalSize(self, func, f): 5729 def WriteImmediateCmdGetTotalSize(self, func, f):
5661 """Overrriden from TypeHandler.""" 5730 """Overrriden from TypeHandler."""
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5884 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5953 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5885 """Overrriden from TypeHandler.""" 5954 """Overrriden from TypeHandler."""
5886 pass 5955 pass
5887 5956
5888 def WriteBucketServiceImplementation(self, func, f): 5957 def WriteBucketServiceImplementation(self, func, f):
5889 """Overrriden from TypeHandler.""" 5958 """Overrriden from TypeHandler."""
5890 if ((not func.name == 'CompressedTexSubImage2DBucket') and 5959 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5891 (not func.name == 'CompressedTexSubImage3DBucket')): 5960 (not func.name == 'CompressedTexSubImage3DBucket')):
5892 TypeHandler.WriteBucketServiceImplemenation(self, func, f) 5961 TypeHandler.WriteBucketServiceImplemenation(self, func, f)
5893 5962
5963 def WritePassthroughBucketServiceImplementation(self, func, f):
5964 """Overrriden from TypeHandler."""
5965 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5966 (not func.name == 'CompressedTexSubImage3DBucket')):
5967 TypeHandler.WritePassthroughBucketServiceImplementation(self, func, f)
5894 5968
5895 class BindHandler(TypeHandler): 5969 class BindHandler(TypeHandler):
5896 """Handler for glBind___ type functions.""" 5970 """Handler for glBind___ type functions."""
5897 5971
5898 def WriteServiceUnitTest(self, func, f, *extras): 5972 def WriteServiceUnitTest(self, func, f, *extras):
5899 """Overrriden from TypeHandler.""" 5973 """Overrriden from TypeHandler."""
5900 5974
5901 if len(func.GetOriginalArgs()) == 1: 5975 if len(func.GetOriginalArgs()) == 1:
5902 valid_test = """ 5976 valid_test = """
5903 TEST_P(%(test_name)s, %(name)sValidArgs) { 5977 TEST_P(%(test_name)s, %(name)sValidArgs) {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
6481 (func.name, func.MakeCmdArgString(""))) 6555 (func.name, func.MakeCmdArgString("")))
6482 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') 6556 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n')
6483 f.write(" CheckGLError();\n") 6557 f.write(" CheckGLError();\n")
6484 if func.return_type == "GLsync": 6558 if func.return_type == "GLsync":
6485 f.write(" return reinterpret_cast<GLsync>(client_id);\n") 6559 f.write(" return reinterpret_cast<GLsync>(client_id);\n")
6486 else: 6560 else:
6487 f.write(" return client_id;\n") 6561 f.write(" return client_id;\n")
6488 f.write("}\n") 6562 f.write("}\n")
6489 f.write("\n") 6563 f.write("\n")
6490 6564
6565 def WritePassthroughServiceImplementation(self, func, f):
6566 """Overrriden from TypeHandler."""
6567 pass
6491 6568
6492 class DeleteHandler(TypeHandler): 6569 class DeleteHandler(TypeHandler):
6493 """Handler for glDelete___ single resource type functions.""" 6570 """Handler for glDelete___ single resource type functions."""
6494 6571
6495 def WriteServiceImplementation(self, func, f): 6572 def WriteServiceImplementation(self, func, f):
6496 """Overrriden from TypeHandler.""" 6573 """Overrriden from TypeHandler."""
6497 if func.IsUnsafe(): 6574 if func.IsUnsafe():
6498 TypeHandler.WriteServiceImplementation(self, func, f) 6575 TypeHandler.WriteServiceImplementation(self, func, f)
6499 # HandleDeleteShader and HandleDeleteProgram are manually written. 6576 # HandleDeleteShader and HandleDeleteProgram are manually written.
6500 pass 6577 pass
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6777 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n") 6854 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n")
6778 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n") 6855 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n")
6779 f.write(" sizeof(ids)));\n") 6856 f.write(" sizeof(ids)));\n")
6780 f.write("}\n") 6857 f.write("}\n")
6781 f.write("\n") 6858 f.write("\n")
6782 6859
6783 6860
6784 class GETnHandler(TypeHandler): 6861 class GETnHandler(TypeHandler):
6785 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions.""" 6862 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions."""
6786 6863
6864 def InitFunction(self, func):
6865 """Overrriden from TypeHandler."""
6866 TypeHandler.InitFunction(self, func)
6867
6868 if func.name == 'GetSynciv':
6869 return
6870
6871 arg_insert_point = len(func.passthrough_service_doer_args) - 1;
6872 func.passthrough_service_doer_args.insert(
6873 arg_insert_point, Argument('length', 'GLsizei*'))
6874 func.passthrough_service_doer_args.insert(
6875 arg_insert_point, Argument('bufsize', 'GLsizei'))
6876
6787 def NeedsDataTransferFunction(self, func): 6877 def NeedsDataTransferFunction(self, func):
6788 """Overriden from TypeHandler.""" 6878 """Overriden from TypeHandler."""
6789 return False 6879 return False
6790 6880
6791 def WriteServiceImplementation(self, func, f): 6881 def WriteServiceImplementation(self, func, f):
6792 """Overrriden from TypeHandler.""" 6882 """Overrriden from TypeHandler."""
6793 self.WriteServiceHandlerFunctionHeader(func, f) 6883 self.WriteServiceHandlerFunctionHeader(func, f)
6794 last_arg = func.GetLastOriginalArg() 6884 last_arg = func.GetLastOriginalArg()
6795 # All except shm_id and shm_offset. 6885 # All except shm_id and shm_offset.
6796 all_but_last_args = func.GetCmdArgs()[:-2] 6886 all_but_last_args = func.GetCmdArgs()[:-2]
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6830 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); 6920 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s");
6831 if (error == GL_NO_ERROR) { 6921 if (error == GL_NO_ERROR) {
6832 result->SetNumResults(num_values); 6922 result->SetNumResults(num_values);
6833 } 6923 }
6834 return error::kNoError; 6924 return error::kNoError;
6835 } 6925 }
6836 6926
6837 """ 6927 """
6838 f.write(code % {'func_name': func.name}) 6928 f.write(code % {'func_name': func.name})
6839 6929
6930 def WritePassthroughServiceImplementation(self, func, f):
6931 """Overrriden from TypeHandler."""
6932 self.WritePassthroughServiceFunctionHeader(func, f)
6933 last_arg = func.GetLastOriginalArg()
6934 # All except shm_id and shm_offset.
6935 all_but_last_args = func.GetCmdArgs()[:-2]
6936 for arg in all_but_last_args:
6937 arg.WriteGetCode(f)
6938
6939 code = """ unsigned int buffer_size = 0;
6940 typedef cmds::%(func_name)s::Result Result;
6941 Result* result = GetSharedMemoryAndSizeAs<Result*>(
6942 c.%(last_arg_name)s_shm_id, c.%(last_arg_name)s_shm_offset,
6943 &buffer_size);
6944 %(last_arg_type)s %(last_arg_name)s = result ? result->GetData() : NULL;
6945 if (%(last_arg_name)s == NULL) {
6946 return error::kOutOfBounds;
6947 }
6948 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
6949 GLsizei written_values = 0;
6950 GLsizei* length = &written_values;
6951 """
6952 f.write(code % {
6953 'last_arg_type': last_arg.type,
6954 'last_arg_name': last_arg.name,
6955 'func_name': func.name,
6956 })
6957
6958 self.WritePassthroughServiceFunctionDoerCall(func, f)
6959
6960 code = """ if (written_values > bufsize) {
6961 return error::kOutOfBounds;
6962 }
6963 result->SetNumResults(written_values);
6964 return error::kNoError;
6965 }
6966
6967 """
6968 f.write(code % {'func_name': func.name})
6969
6840 def WriteGLES2Implementation(self, func, f): 6970 def WriteGLES2Implementation(self, func, f):
6841 """Overrriden from TypeHandler.""" 6971 """Overrriden from TypeHandler."""
6842 impl_decl = func.GetInfo('impl_decl') 6972 impl_decl = func.GetInfo('impl_decl')
6843 if impl_decl == None or impl_decl == True: 6973 if impl_decl == None or impl_decl == True:
6844 f.write("%s GLES2Implementation::%s(%s) {\n" % 6974 f.write("%s GLES2Implementation::%s(%s) {\n" %
6845 (func.return_type, func.original_name, 6975 (func.return_type, func.original_name,
6846 func.MakeTypedOriginalArgString(""))) 6976 func.MakeTypedOriginalArgString("")))
6847 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 6977 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6848 func.WriteDestinationInitalizationValidation(f) 6978 func.WriteDestinationInitalizationValidation(f)
6849 self.WriteClientGLCallLog(func, f) 6979 self.WriteClientGLCallLog(func, f)
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
8266 8396
8267 class IsHandler(TypeHandler): 8397 class IsHandler(TypeHandler):
8268 """Handler for glIs____ type and glGetError functions.""" 8398 """Handler for glIs____ type and glGetError functions."""
8269 8399
8270 def InitFunction(self, func): 8400 def InitFunction(self, func):
8271 """Overrriden from TypeHandler.""" 8401 """Overrriden from TypeHandler."""
8272 func.AddCmdArg(Argument("result_shm_id", 'uint32_t')) 8402 func.AddCmdArg(Argument("result_shm_id", 'uint32_t'))
8273 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t')) 8403 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t'))
8274 if func.GetInfo('result') == None: 8404 if func.GetInfo('result') == None:
8275 func.AddInfo('result', ['uint32_t']) 8405 func.AddInfo('result', ['uint32_t'])
8406 func.passthrough_service_doer_args.append(Argument('result', 'uint32_t*'))
8276 8407
8277 def WriteServiceUnitTest(self, func, f, *extras): 8408 def WriteServiceUnitTest(self, func, f, *extras):
8278 """Overrriden from TypeHandler.""" 8409 """Overrriden from TypeHandler."""
8279 valid_test = """ 8410 valid_test = """
8280 TEST_P(%(test_name)s, %(name)sValidArgs) { 8411 TEST_P(%(test_name)s, %(name)sValidArgs) {
8281 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); 8412 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
8282 SpecializedSetup<cmds::%(name)s, 0>(true); 8413 SpecializedSetup<cmds::%(name)s, 0>(true);
8283 cmds::%(name)s cmd; 8414 cmds::%(name)s cmd;
8284 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);""" 8415 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);"""
8285 if func.IsUnsafe(): 8416 if func.IsUnsafe():
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
8354 } 8485 }
8355 """ 8486 """
8356 f.write(code % {'func_name': func.name}) 8487 f.write(code % {'func_name': func.name})
8357 func.WriteHandlerValidation(f) 8488 func.WriteHandlerValidation(f)
8358 f.write(" *result_dst = %s(%s);\n" % 8489 f.write(" *result_dst = %s(%s);\n" %
8359 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) 8490 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
8360 f.write(" return error::kNoError;\n") 8491 f.write(" return error::kNoError;\n")
8361 f.write("}\n") 8492 f.write("}\n")
8362 f.write("\n") 8493 f.write("\n")
8363 8494
8495 def WritePassthroughServiceImplementation(self, func, f):
8496 """Overrriden from TypeHandler."""
8497 self.WritePassthroughServiceFunctionHeader(func, f)
8498 self.WriteServiceHandlerArgGetCode(func, f)
8499
8500 code = """ typedef cmds::%(func_name)s::Result Result;
8501 Result* result = GetSharedMemoryAs<Result*>(
8502 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8503 if (!result) {
8504 return error::kOutOfBounds;
8505 }
8506 """
8507 f.write(code % {'func_name': func.name})
8508 self.WritePassthroughServiceFunctionDoerCall(func, f)
8509 f.write(" return error::kNoError;\n")
8510 f.write("}\n")
8511 f.write("\n")
8512
8364 def WriteGLES2Implementation(self, func, f): 8513 def WriteGLES2Implementation(self, func, f):
8365 """Overrriden from TypeHandler.""" 8514 """Overrriden from TypeHandler."""
8366 impl_func = func.GetInfo('impl_func') 8515 impl_func = func.GetInfo('impl_func')
8367 if impl_func == None or impl_func == True: 8516 if impl_func == None or impl_func == True:
8368 error_value = func.GetInfo("error_value") or "GL_FALSE" 8517 error_value = func.GetInfo("error_value") or "GL_FALSE"
8369 f.write("%s GLES2Implementation::%s(%s) {\n" % 8518 f.write("%s GLES2Implementation::%s(%s) {\n" %
8370 (func.return_type, func.original_name, 8519 (func.return_type, func.original_name,
8371 func.MakeTypedOriginalArgString(""))) 8520 func.MakeTypedOriginalArgString("")))
8372 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 8521 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
8373 self.WriteTraceEvent(func, f) 8522 self.WriteTraceEvent(func, f)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
8543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8692 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8544 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 8693 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
8545 } 8694 }
8546 """ 8695 """
8547 self.WriteValidUnitTest(func, f, invalid_test, *extras) 8696 self.WriteValidUnitTest(func, f, invalid_test, *extras)
8548 8697
8549 def WriteServiceImplementation(self, func, f): 8698 def WriteServiceImplementation(self, func, f):
8550 """Overrriden from TypeHandler.""" 8699 """Overrriden from TypeHandler."""
8551 pass 8700 pass
8552 8701
8702 def WritePassthroughServiceImplementation(self, func, f):
8703 """Overrriden from TypeHandler."""
8704 pass
8705
8553 class NamedType(object): 8706 class NamedType(object):
8554 """A class that represents a type of an argument in a client function. 8707 """A class that represents a type of an argument in a client function.
8555 8708
8556 A type of an argument that is to be passed through in the command buffer 8709 A type of an argument that is to be passed through in the command buffer
8557 command. Currently used only for the arguments that are specificly named in 8710 command. Currently used only for the arguments that are specificly named in
8558 the 'cmd_buffer_functions.txt' f, mostly enums. 8711 the 'cmd_buffer_functions.txt' f, mostly enums.
8559 """ 8712 """
8560 8713
8561 def __init__(self, info): 8714 def __init__(self, info):
8562 assert not 'is_complete' in info or info['is_complete'] == True 8715 assert not 'is_complete' in info or info['is_complete'] == True
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
9378 self.name = name 9531 self.name = name
9379 self.original_name = info['original_name'] 9532 self.original_name = info['original_name']
9380 9533
9381 self.original_args = self.ParseArgs(info['original_args']) 9534 self.original_args = self.ParseArgs(info['original_args'])
9382 9535
9383 if 'cmd_args' in info: 9536 if 'cmd_args' in info:
9384 self.args_for_cmds = self.ParseArgs(info['cmd_args']) 9537 self.args_for_cmds = self.ParseArgs(info['cmd_args'])
9385 else: 9538 else:
9386 self.args_for_cmds = self.original_args[:] 9539 self.args_for_cmds = self.original_args[:]
9387 9540
9541 self.passthrough_service_doer_args = self.original_args[:]
9542
9388 self.return_type = info['return_type'] 9543 self.return_type = info['return_type']
9389 if self.return_type != 'void': 9544 if self.return_type != 'void':
9390 self.return_arg = CreateArg(info['return_type'] + " result") 9545 self.return_arg = CreateArg(info['return_type'] + " result")
9391 else: 9546 else:
9392 self.return_arg = None 9547 self.return_arg = None
9393 9548
9394 self.num_pointer_args = sum( 9549 self.num_pointer_args = sum(
9395 [1 for arg in self.args_for_cmds if arg.IsPointer()]) 9550 [1 for arg in self.args_for_cmds if arg.IsPointer()])
9396 if self.num_pointer_args > 0: 9551 if self.num_pointer_args > 0:
9397 for arg in reversed(self.original_args): 9552 for arg in reversed(self.original_args):
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
9535 return [arg for arg in self.args_for_cmds if arg.IsConstant()] 9690 return [arg for arg in self.args_for_cmds if arg.IsConstant()]
9536 9691
9537 def GetInitArgs(self): 9692 def GetInitArgs(self):
9538 """Gets the init args for this function.""" 9693 """Gets the init args for this function."""
9539 return self.init_args 9694 return self.init_args
9540 9695
9541 def GetOriginalArgs(self): 9696 def GetOriginalArgs(self):
9542 """Gets the original arguments to this function.""" 9697 """Gets the original arguments to this function."""
9543 return self.original_args 9698 return self.original_args
9544 9699
9700 def GetPassthroughServiceDoerArgs(self):
9701 """Gets the original arguments to this function."""
9702 return self.passthrough_service_doer_args
9703
9545 def GetLastOriginalArg(self): 9704 def GetLastOriginalArg(self):
9546 """Gets the last original argument to this function.""" 9705 """Gets the last original argument to this function."""
9547 return self.original_args[len(self.original_args) - 1] 9706 return self.original_args[len(self.original_args) - 1]
9548 9707
9549 def GetLastOriginalPointerArg(self): 9708 def GetLastOriginalPointerArg(self):
9550 return self.last_original_pointer_arg 9709 return self.last_original_pointer_arg
9551 9710
9552 def GetResourceIdArg(self): 9711 def GetResourceIdArg(self):
9553 for arg in self.original_args: 9712 for arg in self.original_args:
9554 if hasattr(arg, 'resource_type'): 9713 if hasattr(arg, 'resource_type'):
(...skipping 14 matching lines...) Expand all
9569 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) 9728 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args])
9570 return self._MaybePrependComma(arg_string, add_comma) 9729 return self._MaybePrependComma(arg_string, add_comma)
9571 9730
9572 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 9731 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9573 """Gets the list of arguments as they are in GL.""" 9732 """Gets the list of arguments as they are in GL."""
9574 args = self.GetOriginalArgs() 9733 args = self.GetOriginalArgs()
9575 arg_string = separator.join( 9734 arg_string = separator.join(
9576 ["%s%s" % (prefix, arg.name) for arg in args]) 9735 ["%s%s" % (prefix, arg.name) for arg in args])
9577 return self._MaybePrependComma(arg_string, add_comma) 9736 return self._MaybePrependComma(arg_string, add_comma)
9578 9737
9738 def MakePassthroughServiceDoerArgString(self, prefix, add_comma = False,
9739 separator = ", "):
9740 """Gets the list of arguments as they are in used by the passthrough
9741 service doer function."""
9742 args = self.GetPassthroughServiceDoerArgs()
9743 arg_string = separator.join(
9744 ["%s%s" % (prefix, arg.name) for arg in args])
9745 return self._MaybePrependComma(arg_string, add_comma)
9746
9579 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "): 9747 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "):
9580 """Gets a list of GL arguments after removing unneeded arguments.""" 9748 """Gets a list of GL arguments after removing unneeded arguments."""
9581 args = self.GetOriginalArgs() 9749 args = self.GetOriginalArgs()
9582 arg_string = separator.join( 9750 arg_string = separator.join(
9583 ["%s%s" % (prefix, arg.name) 9751 ["%s%s" % (prefix, arg.name)
9584 for arg in args if not arg.IsConstant()]) 9752 for arg in args if not arg.IsConstant()])
9585 return self._MaybePrependComma(arg_string, add_comma) 9753 return self._MaybePrependComma(arg_string, add_comma)
9586 9754
9587 def MakeTypedPepperArgString(self, prefix): 9755 def MakeTypedPepperArgString(self, prefix):
9588 """Gets a list of arguments as they need to be for Pepper.""" 9756 """Gets a list of arguments as they need to be for Pepper."""
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
9742 self.type_handler.WriteDocs(self, f) 9910 self.type_handler.WriteDocs(self, f)
9743 9911
9744 def WriteCmdHelper(self, f): 9912 def WriteCmdHelper(self, f):
9745 """Writes the cmd's helper.""" 9913 """Writes the cmd's helper."""
9746 self.type_handler.WriteCmdHelper(self, f) 9914 self.type_handler.WriteCmdHelper(self, f)
9747 9915
9748 def WriteServiceImplementation(self, f): 9916 def WriteServiceImplementation(self, f):
9749 """Writes the service implementation for a command.""" 9917 """Writes the service implementation for a command."""
9750 self.type_handler.WriteServiceImplementation(self, f) 9918 self.type_handler.WriteServiceImplementation(self, f)
9751 9919
9920 def WritePassthroughServiceImplementation(self, f):
9921 """Writes the service implementation for a command."""
9922 self.type_handler.WritePassthroughServiceImplementation(self, f)
9923
9752 def WriteServiceUnitTest(self, f, *extras): 9924 def WriteServiceUnitTest(self, f, *extras):
9753 """Writes the service implementation for a command.""" 9925 """Writes the service implementation for a command."""
9754 self.type_handler.WriteServiceUnitTest(self, f, *extras) 9926 self.type_handler.WriteServiceUnitTest(self, f, *extras)
9755 9927
9756 def WriteGLES2CLibImplementation(self, f): 9928 def WriteGLES2CLibImplementation(self, f):
9757 """Writes the GLES2 C Lib Implemention.""" 9929 """Writes the GLES2 C Lib Implemention."""
9758 self.type_handler.WriteGLES2CLibImplementation(self, f) 9930 self.type_handler.WriteGLES2CLibImplementation(self, f)
9759 9931
9760 def WriteGLES2InterfaceHeader(self, f): 9932 def WriteGLES2InterfaceHeader(self, f):
9761 """Writes the GLES2 Interface declaration.""" 9933 """Writes the GLES2 Interface declaration."""
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9858 10030
9859 Function.InitFunction(self) 10031 Function.InitFunction(self)
9860 10032
9861 def IsImmediate(self): 10033 def IsImmediate(self):
9862 return True 10034 return True
9863 10035
9864 def WriteServiceImplementation(self, f): 10036 def WriteServiceImplementation(self, f):
9865 """Overridden from Function""" 10037 """Overridden from Function"""
9866 self.type_handler.WriteImmediateServiceImplementation(self, f) 10038 self.type_handler.WriteImmediateServiceImplementation(self, f)
9867 10039
10040 def WritePassthroughServiceImplementation(self, f):
10041 """Overridden from Function"""
10042 self.type_handler.WritePassthroughImmediateServiceImplementation(self, f)
10043
9868 def WriteHandlerImplementation(self, f): 10044 def WriteHandlerImplementation(self, f):
9869 """Overridden from Function""" 10045 """Overridden from Function"""
9870 self.type_handler.WriteImmediateHandlerImplementation(self, f) 10046 self.type_handler.WriteImmediateHandlerImplementation(self, f)
9871 10047
9872 def WriteServiceUnitTest(self, f, *extras): 10048 def WriteServiceUnitTest(self, f, *extras):
9873 """Writes the service implementation for a command.""" 10049 """Writes the service implementation for a command."""
9874 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras) 10050 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras)
9875 10051
9876 def WriteValidationCode(self, f): 10052 def WriteValidationCode(self, f):
9877 """Overridden from Function""" 10053 """Overridden from Function"""
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
9933 new_args_for_cmds.append(new_arg) 10109 new_args_for_cmds.append(new_arg)
9934 10110
9935 self.args_for_cmds = new_args_for_cmds 10111 self.args_for_cmds = new_args_for_cmds
9936 10112
9937 Function.InitFunction(self) 10113 Function.InitFunction(self)
9938 10114
9939 def WriteServiceImplementation(self, f): 10115 def WriteServiceImplementation(self, f):
9940 """Overridden from Function""" 10116 """Overridden from Function"""
9941 self.type_handler.WriteBucketServiceImplementation(self, f) 10117 self.type_handler.WriteBucketServiceImplementation(self, f)
9942 10118
10119 def WritePassthroughServiceImplementation(self, f):
10120 """Overridden from Function"""
10121 self.type_handler.WritePassthroughBucketServiceImplementation(self, f)
10122
9943 def WriteHandlerImplementation(self, f): 10123 def WriteHandlerImplementation(self, f):
9944 """Overridden from Function""" 10124 """Overridden from Function"""
9945 self.type_handler.WriteBucketHandlerImplementation(self, f) 10125 self.type_handler.WriteBucketHandlerImplementation(self, f)
9946 10126
9947 def WriteServiceUnitTest(self, f, *extras): 10127 def WriteServiceUnitTest(self, f, *extras):
9948 """Overridden from Function""" 10128 """Overridden from Function"""
9949 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras) 10129 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras)
9950 10130
9951 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 10131 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9952 """Overridden from Function""" 10132 """Overridden from Function"""
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
10564 return false; 10744 return false;
10565 """ % capability) 10745 """ % capability)
10566 f.write(""" default: 10746 f.write(""" default:
10567 NOTREACHED(); 10747 NOTREACHED();
10568 return false; 10748 return false;
10569 } 10749 }
10570 } 10750 }
10571 """) 10751 """)
10572 self.generated_cpp_filenames.append(filename) 10752 self.generated_cpp_filenames.append(filename)
10573 10753
10754 def WritePassthroughServiceImplementation(self, filename):
10755 """Writes the passthrough service decorder implementation."""
10756 with CWriter(filename) as f:
10757 header = """
10758 #include \"gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h\"
10759
10760 namespace gpu {
10761 namespace gles2 {
10762
10763 """;
10764 f.write(header);
10765
10766 for func in self.functions:
10767 func.WritePassthroughServiceImplementation(f)
10768
10769 footer = """
10770 } // namespace gles2
10771 } // namespace gpu
10772
10773 """;
10774 f.write(footer);
10775 self.generated_cpp_filenames.append(filename)
10776
10574 def WriteServiceUnitTests(self, filename_pattern): 10777 def WriteServiceUnitTests(self, filename_pattern):
10575 """Writes the service decorder unit tests.""" 10778 """Writes the service decorder unit tests."""
10576 num_tests = len(self.functions) 10779 num_tests = len(self.functions)
10577 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change. 10780 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change.
10578 count = 0 10781 count = 0
10579 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE): 10782 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE):
10580 count += 1 10783 count += 1
10581 filename = filename_pattern % count 10784 filename = filename_pattern % count
10582 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \ 10785 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \
10583 % count 10786 % count
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
11279 gen.WriteGLES2TraceImplementationHeader( 11482 gen.WriteGLES2TraceImplementationHeader(
11280 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h") 11483 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h")
11281 gen.WriteGLES2TraceImplementation( 11484 gen.WriteGLES2TraceImplementation(
11282 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h") 11485 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h")
11283 gen.WriteGLES2CLibImplementation( 11486 gen.WriteGLES2CLibImplementation(
11284 "gpu/command_buffer/client/gles2_c_lib_autogen.h") 11487 "gpu/command_buffer/client/gles2_c_lib_autogen.h")
11285 gen.WriteCmdHelperHeader( 11488 gen.WriteCmdHelperHeader(
11286 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h") 11489 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h")
11287 gen.WriteServiceImplementation( 11490 gen.WriteServiceImplementation(
11288 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h") 11491 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h")
11492 gen.WritePassthroughServiceImplementation(
11493 "gpu/command_buffer/service/" +
11494 "gles2_cmd_decoder_passthrough_handlers_autogen.cc")
11289 gen.WriteServiceContextStateHeader( 11495 gen.WriteServiceContextStateHeader(
11290 "gpu/command_buffer/service/context_state_autogen.h") 11496 "gpu/command_buffer/service/context_state_autogen.h")
11291 gen.WriteServiceContextStateImpl( 11497 gen.WriteServiceContextStateImpl(
11292 "gpu/command_buffer/service/context_state_impl_autogen.h") 11498 "gpu/command_buffer/service/context_state_impl_autogen.h")
11293 gen.WriteClientContextStateHeader( 11499 gen.WriteClientContextStateHeader(
11294 "gpu/command_buffer/client/client_context_state_autogen.h") 11500 "gpu/command_buffer/client/client_context_state_autogen.h")
11295 gen.WriteClientContextStateImpl( 11501 gen.WriteClientContextStateImpl(
11296 "gpu/command_buffer/client/client_context_state_impl_autogen.h") 11502 "gpu/command_buffer/client/client_context_state_impl_autogen.h")
11297 gen.WriteServiceUnitTests( 11503 gen.WriteServiceUnitTests(
11298 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h") 11504 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h")
(...skipping 15 matching lines...) Expand all
11314 Format(gen.generated_cpp_filenames) 11520 Format(gen.generated_cpp_filenames)
11315 11521
11316 if gen.errors > 0: 11522 if gen.errors > 0:
11317 print "%d errors" % gen.errors 11523 print "%d errors" % gen.errors
11318 return 1 11524 return 1
11319 return 0 11525 return 0
11320 11526
11321 11527
11322 if __name__ == '__main__': 11528 if __name__ == '__main__':
11323 sys.exit(main(sys.argv[1:])) 11529 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698