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

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
« no previous file with comments | « no previous file | gpu/command_buffer/common/buffer.h » ('j') | gpu/command_buffer/common/buffer.cc » ('J')
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 4908 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 """ % {'name': func.name}) 4919 """ % {'name': func.name})
4920 if func.IsUnsafe(): 4920 if func.IsUnsafe():
4921 f.write("""if (!unsafe_es3_apis_enabled()) 4921 f.write("""if (!unsafe_es3_apis_enabled())
4922 return error::kUnknownCommand; 4922 return error::kUnknownCommand;
4923 """) 4923 """)
4924 f.write("""const gles2::cmds::%(name)s& c = 4924 f.write("""const gles2::cmds::%(name)s& c =
4925 *static_cast<const gles2::cmds::%(name)s*>(cmd_data); 4925 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
4926 (void)c; 4926 (void)c;
4927 """ % {'name': func.name}) 4927 """ % {'name': func.name})
4928 4928
4929 def WriteServiceImplementation(self, func, f): 4929 def WriteServiceHandlerArgGetCode(self, func, f):
4930 """Writes the service implementation for a command.""" 4930 """Writes the argument unpack code for service handlers."""
4931 self.WriteServiceHandlerFunctionHeader(func, f)
4932 self.WriteHandlerExtensionCheck(func, f)
4933 self.WriteHandlerDeferReadWrite(func, f);
4934 if len(func.GetOriginalArgs()) > 0: 4931 if len(func.GetOriginalArgs()) > 0:
4935 last_arg = func.GetLastOriginalArg() 4932 last_arg = func.GetLastOriginalArg()
4936 all_but_last_arg = func.GetOriginalArgs()[:-1] 4933 all_but_last_arg = func.GetOriginalArgs()[:-1]
4937 for arg in all_but_last_arg: 4934 for arg in all_but_last_arg:
4938 arg.WriteGetCode(f) 4935 arg.WriteGetCode(f)
4939 self.WriteGetDataSizeCode(func, f) 4936 self.WriteGetDataSizeCode(func, f)
4940 last_arg.WriteGetCode(f) 4937 last_arg.WriteGetCode(f)
4938
4939 def WriteImmediateServiceHandlerArgGetCode(self, func, f):
4940 """Writes the argument unpack code for immediate service handlers."""
4941 for arg in func.GetOriginalArgs():
4942 if arg.IsPointer():
4943 self.WriteGetDataSizeCode(func, f)
4944 arg.WriteGetCode(f)
4945
4946 def WriteBucketServiceHandlerArgGetCode(self, func, f):
4947 """Writes the argument unpack code for bucket service handlers."""
4948 for arg in func.GetCmdArgs():
4949 arg.WriteGetCode(f)
4950
4951 def WriteServiceImplementation(self, func, f):
4952 """Writes the service implementation for a command."""
4953 self.WriteServiceHandlerFunctionHeader(func, f)
4954 self.WriteHandlerExtensionCheck(func, f)
4955 self.WriteHandlerDeferReadWrite(func, f);
4956 self.WriteServiceHandlerArgGetCode(func, f)
4941 func.WriteHandlerValidation(f) 4957 func.WriteHandlerValidation(f)
4942 func.WriteHandlerImplementation(f) 4958 func.WriteHandlerImplementation(f)
4943 f.write(" return error::kNoError;\n") 4959 f.write(" return error::kNoError;\n")
4944 f.write("}\n") 4960 f.write("}\n")
4945 f.write("\n") 4961 f.write("\n")
4946 4962
4947 def WriteImmediateServiceImplementation(self, func, f): 4963 def WriteImmediateServiceImplementation(self, func, f):
4948 """Writes the service implementation for an immediate version of command.""" 4964 """Writes the service implementation for an immediate version of command."""
4949 self.WriteServiceHandlerFunctionHeader(func, f) 4965 self.WriteServiceHandlerFunctionHeader(func, f)
4950 self.WriteHandlerExtensionCheck(func, f) 4966 self.WriteHandlerExtensionCheck(func, f)
4951 self.WriteHandlerDeferReadWrite(func, f); 4967 self.WriteHandlerDeferReadWrite(func, f);
4952 for arg in func.GetOriginalArgs(): 4968 self.WriteImmediateServiceHandlerArgGetCode(func, f)
4953 if arg.IsPointer():
4954 self.WriteGetDataSizeCode(func, f)
4955 arg.WriteGetCode(f)
4956 func.WriteHandlerValidation(f) 4969 func.WriteHandlerValidation(f)
4957 func.WriteHandlerImplementation(f) 4970 func.WriteHandlerImplementation(f)
4958 f.write(" return error::kNoError;\n") 4971 f.write(" return error::kNoError;\n")
4959 f.write("}\n") 4972 f.write("}\n")
4960 f.write("\n") 4973 f.write("\n")
4961 4974
4962 def WriteBucketServiceImplementation(self, func, f): 4975 def WriteBucketServiceImplementation(self, func, f):
4963 """Writes the service implementation for a bucket version of command.""" 4976 """Writes the service implementation for a bucket version of command."""
4964 self.WriteServiceHandlerFunctionHeader(func, f) 4977 self.WriteServiceHandlerFunctionHeader(func, f)
4965 self.WriteHandlerExtensionCheck(func, f) 4978 self.WriteHandlerExtensionCheck(func, f)
4966 self.WriteHandlerDeferReadWrite(func, f); 4979 self.WriteHandlerDeferReadWrite(func, f);
4967 for arg in func.GetCmdArgs(): 4980 self.WriteBucketServiceHandlerArgGetCode(func, f)
4968 arg.WriteGetCode(f)
4969 func.WriteHandlerValidation(f) 4981 func.WriteHandlerValidation(f)
4970 func.WriteHandlerImplementation(f) 4982 func.WriteHandlerImplementation(f)
4971 f.write(" return error::kNoError;\n") 4983 f.write(" return error::kNoError;\n")
4972 f.write("}\n") 4984 f.write("}\n")
4973 f.write("\n") 4985 f.write("\n")
4974 4986
4987 def WritePassthroughServiceFunctionHeader(self, func, f):
4988 """Writes function header for service passthrough handlers."""
4989 f.write("""error::Error GLES2DecoderPassthroughImpl::Handle%(name)s(
4990 uint32_t immediate_data_size, const void* cmd_data) {
4991 """ % {'name': func.name})
4992 f.write("""const gles2::cmds::%(name)s& c =
4993 *static_cast<const gles2::cmds::%(name)s*>(cmd_data);
4994 (void)c;
4995 """ % {'name': func.name})
4996
4997 def WritePassthroughServiceFunctionDoerCall(self, func, f):
4998 """Writes the function call to the passthrough service doer."""
4999 f.write(""" error::Error error = Do%(name)s(%(args)s);
5000 if (error != error::kNoError) {
5001 return error;
5002 }""" % {'name': func.original_name,
5003 'args': func.MakePassthroughServiceDoerArgString("")})
5004
5005 def WritePassthroughServiceImplementation(self, func, f):
5006 """Writes the service implementation for a command."""
5007 self.WritePassthroughServiceFunctionHeader(func, f)
piman 2016/05/25 23:34:42 I see that you don't have an extension check here.
Geoff Lang 2016/05/27 14:31:28 I think we can continue to report command errors i
5008 self.WriteServiceHandlerArgGetCode(func, f)
5009 self.WritePassthroughServiceFunctionDoerCall(func, f)
5010 f.write(" return error::kNoError;\n")
5011 f.write("}\n")
5012 f.write("\n")
5013
5014 def WritePassthroughImmediateServiceImplementation(self, func, f):
5015 """Writes the service implementation for a command."""
5016 self.WritePassthroughServiceFunctionHeader(func, f)
5017 self.WriteImmediateServiceHandlerArgGetCode(func, f)
5018 self.WritePassthroughServiceFunctionDoerCall(func, f)
5019 f.write(" return error::kNoError;\n")
5020 f.write("}\n")
5021 f.write("\n")
5022
5023 def WritePassthroughBucketServiceImplementation(self, func, f):
5024 """Writes the service implementation for a command."""
5025 self.WritePassthroughServiceFunctionHeader(func, f)
5026 self.WriteBucketServiceHandlerArgGetCode(func, f)
5027 self.WritePassthroughServiceFunctionDoerCall(func, f)
5028 f.write(" return error::kNoError;\n")
5029 f.write("}\n")
5030 f.write("\n")
5031
4975 def WriteHandlerExtensionCheck(self, func, f): 5032 def WriteHandlerExtensionCheck(self, func, f):
4976 if func.GetInfo('extension_flag'): 5033 if func.GetInfo('extension_flag'):
4977 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag')) 5034 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag'))
4978 f.write(" return error::kUnknownCommand;") 5035 f.write(" return error::kUnknownCommand;")
4979 f.write(" }\n\n") 5036 f.write(" }\n\n")
4980 5037
4981 def WriteHandlerDeferReadWrite(self, func, f): 5038 def WriteHandlerDeferReadWrite(self, func, f):
4982 """Writes the code to handle deferring reads or writes.""" 5039 """Writes the code to handle deferring reads or writes."""
4983 defer_draws = func.GetInfo('defer_draws') 5040 defer_draws = func.GetInfo('defer_draws')
4984 defer_reads = func.GetInfo('defer_reads') 5041 defer_reads = func.GetInfo('defer_reads')
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
5629 pass 5686 pass
5630 5687
5631 def WriteImmediateServiceImplementation(self, func, f): 5688 def WriteImmediateServiceImplementation(self, func, f):
5632 """Overrriden from TypeHandler.""" 5689 """Overrriden from TypeHandler."""
5633 pass 5690 pass
5634 5691
5635 def WriteBucketServiceImplementation(self, func, f): 5692 def WriteBucketServiceImplementation(self, func, f):
5636 """Overrriden from TypeHandler.""" 5693 """Overrriden from TypeHandler."""
5637 pass 5694 pass
5638 5695
5696 def WritePassthroughServiceImplementation(self, func, f):
5697 """Overrriden from TypeHandler."""
5698 pass
5699
5700 def WritePassthroughImmediateServiceImplementation(self, func, f):
5701 """Overrriden from TypeHandler."""
5702 pass
5703
5704 def WritePassthroughBucketServiceImplementation(self, func, f):
5705 """Overrriden from TypeHandler."""
5706 pass
5707
5639 def WriteServiceUnitTest(self, func, f, *extras): 5708 def WriteServiceUnitTest(self, func, f, *extras):
5640 """Overrriden from TypeHandler.""" 5709 """Overrriden from TypeHandler."""
5641 pass 5710 pass
5642 5711
5643 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5712 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5644 """Overrriden from TypeHandler.""" 5713 """Overrriden from TypeHandler."""
5645 pass 5714 pass
5646 5715
5647 def WriteImmediateCmdGetTotalSize(self, func, f): 5716 def WriteImmediateCmdGetTotalSize(self, func, f):
5648 """Overrriden from TypeHandler.""" 5717 """Overrriden from TypeHandler."""
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5871 def WriteImmediateServiceUnitTest(self, func, f, *extras): 5940 def WriteImmediateServiceUnitTest(self, func, f, *extras):
5872 """Overrriden from TypeHandler.""" 5941 """Overrriden from TypeHandler."""
5873 pass 5942 pass
5874 5943
5875 def WriteBucketServiceImplementation(self, func, f): 5944 def WriteBucketServiceImplementation(self, func, f):
5876 """Overrriden from TypeHandler.""" 5945 """Overrriden from TypeHandler."""
5877 if ((not func.name == 'CompressedTexSubImage2DBucket') and 5946 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5878 (not func.name == 'CompressedTexSubImage3DBucket')): 5947 (not func.name == 'CompressedTexSubImage3DBucket')):
5879 TypeHandler.WriteBucketServiceImplemenation(self, func, f) 5948 TypeHandler.WriteBucketServiceImplemenation(self, func, f)
5880 5949
5950 def WritePassthroughBucketServiceImplementation(self, func, f):
5951 """Overrriden from TypeHandler."""
5952 if ((not func.name == 'CompressedTexSubImage2DBucket') and
5953 (not func.name == 'CompressedTexSubImage3DBucket')):
5954 TypeHandler.WritePassthroughBucketServiceImplementation(self, func, f)
5881 5955
5882 class BindHandler(TypeHandler): 5956 class BindHandler(TypeHandler):
5883 """Handler for glBind___ type functions.""" 5957 """Handler for glBind___ type functions."""
5884 5958
5885 def WriteServiceUnitTest(self, func, f, *extras): 5959 def WriteServiceUnitTest(self, func, f, *extras):
5886 """Overrriden from TypeHandler.""" 5960 """Overrriden from TypeHandler."""
5887 5961
5888 if len(func.GetOriginalArgs()) == 1: 5962 if len(func.GetOriginalArgs()) == 1:
5889 valid_test = """ 5963 valid_test = """
5890 TEST_P(%(test_name)s, %(name)sValidArgs) { 5964 TEST_P(%(test_name)s, %(name)sValidArgs) {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
6478 (func.name, func.MakeCmdArgString(""))) 6552 (func.name, func.MakeCmdArgString("")))
6479 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') 6553 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n')
6480 f.write(" CheckGLError();\n") 6554 f.write(" CheckGLError();\n")
6481 if func.return_type == "GLsync": 6555 if func.return_type == "GLsync":
6482 f.write(" return reinterpret_cast<GLsync>(client_id);\n") 6556 f.write(" return reinterpret_cast<GLsync>(client_id);\n")
6483 else: 6557 else:
6484 f.write(" return client_id;\n") 6558 f.write(" return client_id;\n")
6485 f.write("}\n") 6559 f.write("}\n")
6486 f.write("\n") 6560 f.write("\n")
6487 6561
6562 def WritePassthroughServiceImplementation(self, func, f):
6563 """Overrriden from TypeHandler."""
6564 pass
6488 6565
6489 class DeleteHandler(TypeHandler): 6566 class DeleteHandler(TypeHandler):
6490 """Handler for glDelete___ single resource type functions.""" 6567 """Handler for glDelete___ single resource type functions."""
6491 6568
6492 def WriteServiceImplementation(self, func, f): 6569 def WriteServiceImplementation(self, func, f):
6493 """Overrriden from TypeHandler.""" 6570 """Overrriden from TypeHandler."""
6494 if func.IsUnsafe(): 6571 if func.IsUnsafe():
6495 TypeHandler.WriteServiceImplementation(self, func, f) 6572 TypeHandler.WriteServiceImplementation(self, func, f)
6496 # HandleDeleteShader and HandleDeleteProgram are manually written. 6573 # HandleDeleteShader and HandleDeleteProgram are manually written.
6497 pass 6574 pass
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6774 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n") 6851 f.write(" RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));\n")
6775 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n") 6852 f.write(" EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd),\n")
6776 f.write(" sizeof(ids)));\n") 6853 f.write(" sizeof(ids)));\n")
6777 f.write("}\n") 6854 f.write("}\n")
6778 f.write("\n") 6855 f.write("\n")
6779 6856
6780 6857
6781 class GETnHandler(TypeHandler): 6858 class GETnHandler(TypeHandler):
6782 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions.""" 6859 """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions."""
6783 6860
6861 def InitFunction(self, func):
6862 """Overrriden from TypeHandler."""
6863 TypeHandler.InitFunction(self, func)
6864
6865 if func.name == 'GetSynciv':
6866 return
6867
6868 arg_insert_point = len(func.passthrough_service_doer_args) - 1;
6869 func.passthrough_service_doer_args.insert(
6870 arg_insert_point, Argument('length', 'GLsizei*'))
6871 func.passthrough_service_doer_args.insert(
6872 arg_insert_point, Argument('bufsize', 'GLsizei'))
6873
6784 def NeedsDataTransferFunction(self, func): 6874 def NeedsDataTransferFunction(self, func):
6785 """Overriden from TypeHandler.""" 6875 """Overriden from TypeHandler."""
6786 return False 6876 return False
6787 6877
6788 def WriteServiceImplementation(self, func, f): 6878 def WriteServiceImplementation(self, func, f):
6789 """Overrriden from TypeHandler.""" 6879 """Overrriden from TypeHandler."""
6790 self.WriteServiceHandlerFunctionHeader(func, f) 6880 self.WriteServiceHandlerFunctionHeader(func, f)
6791 last_arg = func.GetLastOriginalArg() 6881 last_arg = func.GetLastOriginalArg()
6792 # All except shm_id and shm_offset. 6882 # All except shm_id and shm_offset.
6793 all_but_last_args = func.GetCmdArgs()[:-2] 6883 all_but_last_args = func.GetCmdArgs()[:-2]
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6827 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); 6917 code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s");
6828 if (error == GL_NO_ERROR) { 6918 if (error == GL_NO_ERROR) {
6829 result->SetNumResults(num_values); 6919 result->SetNumResults(num_values);
6830 } 6920 }
6831 return error::kNoError; 6921 return error::kNoError;
6832 } 6922 }
6833 6923
6834 """ 6924 """
6835 f.write(code % {'func_name': func.name}) 6925 f.write(code % {'func_name': func.name})
6836 6926
6927 def WritePassthroughServiceImplementation(self, func, f):
6928 """Overrriden from TypeHandler."""
6929 self.WritePassthroughServiceFunctionHeader(func, f)
6930 last_arg = func.GetLastOriginalArg()
6931 # All except shm_id and shm_offset.
6932 all_but_last_args = func.GetCmdArgs()[:-2]
6933 for arg in all_but_last_args:
6934 arg.WriteGetCode(f)
6935
6936 code = """ unsigned int buffer_size = 0;
6937 typedef cmds::%(func_name)s::Result Result;
6938 Result* result = GetSharedMemoryAndSizeAs<Result*>(
6939 c.%(last_arg_name)s_shm_id, c.%(last_arg_name)s_shm_offset,
6940 &buffer_size);
6941 %(last_arg_type)s %(last_arg_name)s = result ? result->GetData() : NULL;
piman 2016/05/25 23:34:42 Is it the responsibility of the Do* function to ch
Geoff Lang 2016/05/27 14:31:28 Good point, added the null check here.
6942 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
6943 GLsizei written_values = 0;
6944 GLsizei* length = &written_values;
6945 """
6946 f.write(code % {
6947 'last_arg_type': last_arg.type,
6948 'last_arg_name': last_arg.name,
6949 'func_name': func.name,
6950 })
6951
6952 self.WritePassthroughServiceFunctionDoerCall(func, f)
6953
6954 code = """ if (written_values > bufsize) {
piman 2016/05/25 23:34:42 Is the intent that the function will only write up
Geoff Lang 2016/05/27 14:31:28 Yes, exactly.
6955 return error::kOutOfBounds;
6956 }
6957 result->SetNumResults(written_values);
6958 return error::kNoError;
6959 }
6960
6961 """
6962 f.write(code % {'func_name': func.name})
6963
6837 def WriteGLES2Implementation(self, func, f): 6964 def WriteGLES2Implementation(self, func, f):
6838 """Overrriden from TypeHandler.""" 6965 """Overrriden from TypeHandler."""
6839 impl_decl = func.GetInfo('impl_decl') 6966 impl_decl = func.GetInfo('impl_decl')
6840 if impl_decl == None or impl_decl == True: 6967 if impl_decl == None or impl_decl == True:
6841 f.write("%s GLES2Implementation::%s(%s) {\n" % 6968 f.write("%s GLES2Implementation::%s(%s) {\n" %
6842 (func.return_type, func.original_name, 6969 (func.return_type, func.original_name,
6843 func.MakeTypedOriginalArgString(""))) 6970 func.MakeTypedOriginalArgString("")))
6844 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 6971 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
6845 func.WriteDestinationInitalizationValidation(f) 6972 func.WriteDestinationInitalizationValidation(f)
6846 self.WriteClientGLCallLog(func, f) 6973 self.WriteClientGLCallLog(func, f)
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
8263 8390
8264 class IsHandler(TypeHandler): 8391 class IsHandler(TypeHandler):
8265 """Handler for glIs____ type and glGetError functions.""" 8392 """Handler for glIs____ type and glGetError functions."""
8266 8393
8267 def InitFunction(self, func): 8394 def InitFunction(self, func):
8268 """Overrriden from TypeHandler.""" 8395 """Overrriden from TypeHandler."""
8269 func.AddCmdArg(Argument("result_shm_id", 'uint32_t')) 8396 func.AddCmdArg(Argument("result_shm_id", 'uint32_t'))
8270 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t')) 8397 func.AddCmdArg(Argument("result_shm_offset", 'uint32_t'))
8271 if func.GetInfo('result') == None: 8398 if func.GetInfo('result') == None:
8272 func.AddInfo('result', ['uint32_t']) 8399 func.AddInfo('result', ['uint32_t'])
8400 func.passthrough_service_doer_args.append(Argument('result', 'uint32_t*'))
8273 8401
8274 def WriteServiceUnitTest(self, func, f, *extras): 8402 def WriteServiceUnitTest(self, func, f, *extras):
8275 """Overrriden from TypeHandler.""" 8403 """Overrriden from TypeHandler."""
8276 valid_test = """ 8404 valid_test = """
8277 TEST_P(%(test_name)s, %(name)sValidArgs) { 8405 TEST_P(%(test_name)s, %(name)sValidArgs) {
8278 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); 8406 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
8279 SpecializedSetup<cmds::%(name)s, 0>(true); 8407 SpecializedSetup<cmds::%(name)s, 0>(true);
8280 cmds::%(name)s cmd; 8408 cmds::%(name)s cmd;
8281 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);""" 8409 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);"""
8282 if func.IsUnsafe(): 8410 if func.IsUnsafe():
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
8351 } 8479 }
8352 """ 8480 """
8353 f.write(code % {'func_name': func.name}) 8481 f.write(code % {'func_name': func.name})
8354 func.WriteHandlerValidation(f) 8482 func.WriteHandlerValidation(f)
8355 f.write(" *result_dst = %s(%s);\n" % 8483 f.write(" *result_dst = %s(%s);\n" %
8356 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) 8484 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
8357 f.write(" return error::kNoError;\n") 8485 f.write(" return error::kNoError;\n")
8358 f.write("}\n") 8486 f.write("}\n")
8359 f.write("\n") 8487 f.write("\n")
8360 8488
8489 def WritePassthroughServiceImplementation(self, func, f):
8490 """Overrriden from TypeHandler."""
8491 self.WritePassthroughServiceFunctionHeader(func, f)
8492 self.WriteServiceHandlerArgGetCode(func, f)
8493
8494 code = """ typedef cmds::%(func_name)s::Result Result;
8495 Result* result = GetSharedMemoryAs<Result*>(
8496 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8497 if (!result) {
8498 return error::kOutOfBounds;
8499 }
8500 """
8501 f.write(code % {'func_name': func.name})
8502 self.WritePassthroughServiceFunctionDoerCall(func, f)
8503 f.write(" return error::kNoError;\n")
8504 f.write("}\n")
8505 f.write("\n")
8506
8361 def WriteGLES2Implementation(self, func, f): 8507 def WriteGLES2Implementation(self, func, f):
8362 """Overrriden from TypeHandler.""" 8508 """Overrriden from TypeHandler."""
8363 impl_func = func.GetInfo('impl_func') 8509 impl_func = func.GetInfo('impl_func')
8364 if impl_func == None or impl_func == True: 8510 if impl_func == None or impl_func == True:
8365 error_value = func.GetInfo("error_value") or "GL_FALSE" 8511 error_value = func.GetInfo("error_value") or "GL_FALSE"
8366 f.write("%s GLES2Implementation::%s(%s) {\n" % 8512 f.write("%s GLES2Implementation::%s(%s) {\n" %
8367 (func.return_type, func.original_name, 8513 (func.return_type, func.original_name,
8368 func.MakeTypedOriginalArgString(""))) 8514 func.MakeTypedOriginalArgString("")))
8369 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 8515 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
8370 self.WriteTraceEvent(func, f) 8516 self.WriteTraceEvent(func, f)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
8540 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8686 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8541 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 8687 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
8542 } 8688 }
8543 """ 8689 """
8544 self.WriteValidUnitTest(func, f, invalid_test, *extras) 8690 self.WriteValidUnitTest(func, f, invalid_test, *extras)
8545 8691
8546 def WriteServiceImplementation(self, func, f): 8692 def WriteServiceImplementation(self, func, f):
8547 """Overrriden from TypeHandler.""" 8693 """Overrriden from TypeHandler."""
8548 pass 8694 pass
8549 8695
8696 def WritePassthroughServiceImplementation(self, func, f):
8697 """Overrriden from TypeHandler."""
8698 pass
8699
8550 class NamedType(object): 8700 class NamedType(object):
8551 """A class that represents a type of an argument in a client function. 8701 """A class that represents a type of an argument in a client function.
8552 8702
8553 A type of an argument that is to be passed through in the command buffer 8703 A type of an argument that is to be passed through in the command buffer
8554 command. Currently used only for the arguments that are specificly named in 8704 command. Currently used only for the arguments that are specificly named in
8555 the 'cmd_buffer_functions.txt' f, mostly enums. 8705 the 'cmd_buffer_functions.txt' f, mostly enums.
8556 """ 8706 """
8557 8707
8558 def __init__(self, info): 8708 def __init__(self, info):
8559 assert not 'is_complete' in info or info['is_complete'] == True 8709 assert not 'is_complete' in info or info['is_complete'] == True
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
9375 self.name = name 9525 self.name = name
9376 self.original_name = info['original_name'] 9526 self.original_name = info['original_name']
9377 9527
9378 self.original_args = self.ParseArgs(info['original_args']) 9528 self.original_args = self.ParseArgs(info['original_args'])
9379 9529
9380 if 'cmd_args' in info: 9530 if 'cmd_args' in info:
9381 self.args_for_cmds = self.ParseArgs(info['cmd_args']) 9531 self.args_for_cmds = self.ParseArgs(info['cmd_args'])
9382 else: 9532 else:
9383 self.args_for_cmds = self.original_args[:] 9533 self.args_for_cmds = self.original_args[:]
9384 9534
9535 self.passthrough_service_doer_args = self.original_args[:]
9536
9385 self.return_type = info['return_type'] 9537 self.return_type = info['return_type']
9386 if self.return_type != 'void': 9538 if self.return_type != 'void':
9387 self.return_arg = CreateArg(info['return_type'] + " result") 9539 self.return_arg = CreateArg(info['return_type'] + " result")
9388 else: 9540 else:
9389 self.return_arg = None 9541 self.return_arg = None
9390 9542
9391 self.num_pointer_args = sum( 9543 self.num_pointer_args = sum(
9392 [1 for arg in self.args_for_cmds if arg.IsPointer()]) 9544 [1 for arg in self.args_for_cmds if arg.IsPointer()])
9393 if self.num_pointer_args > 0: 9545 if self.num_pointer_args > 0:
9394 for arg in reversed(self.original_args): 9546 for arg in reversed(self.original_args):
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
9532 return [arg for arg in self.args_for_cmds if arg.IsConstant()] 9684 return [arg for arg in self.args_for_cmds if arg.IsConstant()]
9533 9685
9534 def GetInitArgs(self): 9686 def GetInitArgs(self):
9535 """Gets the init args for this function.""" 9687 """Gets the init args for this function."""
9536 return self.init_args 9688 return self.init_args
9537 9689
9538 def GetOriginalArgs(self): 9690 def GetOriginalArgs(self):
9539 """Gets the original arguments to this function.""" 9691 """Gets the original arguments to this function."""
9540 return self.original_args 9692 return self.original_args
9541 9693
9694 def GetPassthroughServiceDoerArgs(self):
9695 """Gets the original arguments to this function."""
9696 return self.passthrough_service_doer_args
9697
9542 def GetLastOriginalArg(self): 9698 def GetLastOriginalArg(self):
9543 """Gets the last original argument to this function.""" 9699 """Gets the last original argument to this function."""
9544 return self.original_args[len(self.original_args) - 1] 9700 return self.original_args[len(self.original_args) - 1]
9545 9701
9546 def GetLastOriginalPointerArg(self): 9702 def GetLastOriginalPointerArg(self):
9547 return self.last_original_pointer_arg 9703 return self.last_original_pointer_arg
9548 9704
9549 def GetResourceIdArg(self): 9705 def GetResourceIdArg(self):
9550 for arg in self.original_args: 9706 for arg in self.original_args:
9551 if hasattr(arg, 'resource_type'): 9707 if hasattr(arg, 'resource_type'):
(...skipping 14 matching lines...) Expand all
9566 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) 9722 ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args])
9567 return self._MaybePrependComma(arg_string, add_comma) 9723 return self._MaybePrependComma(arg_string, add_comma)
9568 9724
9569 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 9725 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9570 """Gets the list of arguments as they are in GL.""" 9726 """Gets the list of arguments as they are in GL."""
9571 args = self.GetOriginalArgs() 9727 args = self.GetOriginalArgs()
9572 arg_string = separator.join( 9728 arg_string = separator.join(
9573 ["%s%s" % (prefix, arg.name) for arg in args]) 9729 ["%s%s" % (prefix, arg.name) for arg in args])
9574 return self._MaybePrependComma(arg_string, add_comma) 9730 return self._MaybePrependComma(arg_string, add_comma)
9575 9731
9732 def MakePassthroughServiceDoerArgString(self, prefix, add_comma = False,
9733 separator = ", "):
9734 """Gets the list of arguments as they are in used by the passthrough
9735 service doer function."""
9736 args = self.GetPassthroughServiceDoerArgs()
9737 arg_string = separator.join(
9738 ["%s%s" % (prefix, arg.name) for arg in args])
9739 return self._MaybePrependComma(arg_string, add_comma)
9740
9576 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "): 9741 def MakeHelperArgString(self, prefix, add_comma = False, separator = ", "):
9577 """Gets a list of GL arguments after removing unneeded arguments.""" 9742 """Gets a list of GL arguments after removing unneeded arguments."""
9578 args = self.GetOriginalArgs() 9743 args = self.GetOriginalArgs()
9579 arg_string = separator.join( 9744 arg_string = separator.join(
9580 ["%s%s" % (prefix, arg.name) 9745 ["%s%s" % (prefix, arg.name)
9581 for arg in args if not arg.IsConstant()]) 9746 for arg in args if not arg.IsConstant()])
9582 return self._MaybePrependComma(arg_string, add_comma) 9747 return self._MaybePrependComma(arg_string, add_comma)
9583 9748
9584 def MakeTypedPepperArgString(self, prefix): 9749 def MakeTypedPepperArgString(self, prefix):
9585 """Gets a list of arguments as they need to be for Pepper.""" 9750 """Gets a list of arguments as they need to be for Pepper."""
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
9739 self.type_handler.WriteDocs(self, f) 9904 self.type_handler.WriteDocs(self, f)
9740 9905
9741 def WriteCmdHelper(self, f): 9906 def WriteCmdHelper(self, f):
9742 """Writes the cmd's helper.""" 9907 """Writes the cmd's helper."""
9743 self.type_handler.WriteCmdHelper(self, f) 9908 self.type_handler.WriteCmdHelper(self, f)
9744 9909
9745 def WriteServiceImplementation(self, f): 9910 def WriteServiceImplementation(self, f):
9746 """Writes the service implementation for a command.""" 9911 """Writes the service implementation for a command."""
9747 self.type_handler.WriteServiceImplementation(self, f) 9912 self.type_handler.WriteServiceImplementation(self, f)
9748 9913
9914 def WritePassthroughServiceImplementation(self, f):
9915 """Writes the service implementation for a command."""
9916 self.type_handler.WritePassthroughServiceImplementation(self, f)
9917
9749 def WriteServiceUnitTest(self, f, *extras): 9918 def WriteServiceUnitTest(self, f, *extras):
9750 """Writes the service implementation for a command.""" 9919 """Writes the service implementation for a command."""
9751 self.type_handler.WriteServiceUnitTest(self, f, *extras) 9920 self.type_handler.WriteServiceUnitTest(self, f, *extras)
9752 9921
9753 def WriteGLES2CLibImplementation(self, f): 9922 def WriteGLES2CLibImplementation(self, f):
9754 """Writes the GLES2 C Lib Implemention.""" 9923 """Writes the GLES2 C Lib Implemention."""
9755 self.type_handler.WriteGLES2CLibImplementation(self, f) 9924 self.type_handler.WriteGLES2CLibImplementation(self, f)
9756 9925
9757 def WriteGLES2InterfaceHeader(self, f): 9926 def WriteGLES2InterfaceHeader(self, f):
9758 """Writes the GLES2 Interface declaration.""" 9927 """Writes the GLES2 Interface declaration."""
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
9863 10032
9864 Function.InitFunction(self) 10033 Function.InitFunction(self)
9865 10034
9866 def IsImmediate(self): 10035 def IsImmediate(self):
9867 return True 10036 return True
9868 10037
9869 def WriteServiceImplementation(self, f): 10038 def WriteServiceImplementation(self, f):
9870 """Overridden from Function""" 10039 """Overridden from Function"""
9871 self.type_handler.WriteImmediateServiceImplementation(self, f) 10040 self.type_handler.WriteImmediateServiceImplementation(self, f)
9872 10041
10042 def WritePassthroughServiceImplementation(self, f):
10043 """Overridden from Function"""
10044 self.type_handler.WritePassthroughImmediateServiceImplementation(self, f)
10045
9873 def WriteHandlerImplementation(self, f): 10046 def WriteHandlerImplementation(self, f):
9874 """Overridden from Function""" 10047 """Overridden from Function"""
9875 self.type_handler.WriteImmediateHandlerImplementation(self, f) 10048 self.type_handler.WriteImmediateHandlerImplementation(self, f)
9876 10049
9877 def WriteServiceUnitTest(self, f, *extras): 10050 def WriteServiceUnitTest(self, f, *extras):
9878 """Writes the service implementation for a command.""" 10051 """Writes the service implementation for a command."""
9879 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras) 10052 self.type_handler.WriteImmediateServiceUnitTest(self, f, *extras)
9880 10053
9881 def WriteValidationCode(self, f): 10054 def WriteValidationCode(self, f):
9882 """Overridden from Function""" 10055 """Overridden from Function"""
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
9938 new_args_for_cmds.append(new_arg) 10111 new_args_for_cmds.append(new_arg)
9939 10112
9940 self.args_for_cmds = new_args_for_cmds 10113 self.args_for_cmds = new_args_for_cmds
9941 10114
9942 Function.InitFunction(self) 10115 Function.InitFunction(self)
9943 10116
9944 def WriteServiceImplementation(self, f): 10117 def WriteServiceImplementation(self, f):
9945 """Overridden from Function""" 10118 """Overridden from Function"""
9946 self.type_handler.WriteBucketServiceImplementation(self, f) 10119 self.type_handler.WriteBucketServiceImplementation(self, f)
9947 10120
10121 def WritePassthroughServiceImplementation(self, f):
10122 """Overridden from Function"""
10123 self.type_handler.WritePassthroughBucketServiceImplementation(self, f)
10124
9948 def WriteHandlerImplementation(self, f): 10125 def WriteHandlerImplementation(self, f):
9949 """Overridden from Function""" 10126 """Overridden from Function"""
9950 self.type_handler.WriteBucketHandlerImplementation(self, f) 10127 self.type_handler.WriteBucketHandlerImplementation(self, f)
9951 10128
9952 def WriteServiceUnitTest(self, f, *extras): 10129 def WriteServiceUnitTest(self, f, *extras):
9953 """Overridden from Function""" 10130 """Overridden from Function"""
9954 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras) 10131 self.type_handler.WriteBucketServiceUnitTest(self, f, *extras)
9955 10132
9956 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): 10133 def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "):
9957 """Overridden from Function""" 10134 """Overridden from Function"""
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
10586 return false; 10763 return false;
10587 """ % capability) 10764 """ % capability)
10588 f.write(""" default: 10765 f.write(""" default:
10589 NOTREACHED(); 10766 NOTREACHED();
10590 return false; 10767 return false;
10591 } 10768 }
10592 } 10769 }
10593 """) 10770 """)
10594 self.generated_cpp_filenames.append(filename) 10771 self.generated_cpp_filenames.append(filename)
10595 10772
10773 def WritePassthroughServiceImplementation(self, filename):
10774 """Writes the passthrough service decorder implementation."""
10775 comment = "// It is included by gles2_cmd_decoder_passthrough.cc\n"
10776 with CHeaderWriter(filename, comment) as f:
10777 for func in self.functions:
10778 func.WritePassthroughServiceImplementation(f)
10779 self.generated_cpp_filenames.append(filename)
10780
10596 def WriteServiceUnitTests(self, filename_pattern): 10781 def WriteServiceUnitTests(self, filename_pattern):
10597 """Writes the service decorder unit tests.""" 10782 """Writes the service decorder unit tests."""
10598 num_tests = len(self.functions) 10783 num_tests = len(self.functions)
10599 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change. 10784 FUNCTIONS_PER_FILE = 98 # hard code this so it doesn't change.
10600 count = 0 10785 count = 0
10601 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE): 10786 for test_num in range(0, num_tests, FUNCTIONS_PER_FILE):
10602 count += 1 10787 count += 1
10603 filename = filename_pattern % count 10788 filename = filename_pattern % count
10604 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \ 10789 comment = "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" \
10605 % count 10790 % count
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
11394 gen.WriteGLES2TraceImplementationHeader( 11579 gen.WriteGLES2TraceImplementationHeader(
11395 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h") 11580 "gpu/command_buffer/client/gles2_trace_implementation_autogen.h")
11396 gen.WriteGLES2TraceImplementation( 11581 gen.WriteGLES2TraceImplementation(
11397 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h") 11582 "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h")
11398 gen.WriteGLES2CLibImplementation( 11583 gen.WriteGLES2CLibImplementation(
11399 "gpu/command_buffer/client/gles2_c_lib_autogen.h") 11584 "gpu/command_buffer/client/gles2_c_lib_autogen.h")
11400 gen.WriteCmdHelperHeader( 11585 gen.WriteCmdHelperHeader(
11401 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h") 11586 "gpu/command_buffer/client/gles2_cmd_helper_autogen.h")
11402 gen.WriteServiceImplementation( 11587 gen.WriteServiceImplementation(
11403 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h") 11588 "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h")
11589 gen.WritePassthroughServiceImplementation(
11590 "gpu/command_buffer/service/" +
11591 "gles2_cmd_decoder_passthrough_handlers_autogen.h")
11404 gen.WriteServiceContextStateHeader( 11592 gen.WriteServiceContextStateHeader(
11405 "gpu/command_buffer/service/context_state_autogen.h") 11593 "gpu/command_buffer/service/context_state_autogen.h")
11406 gen.WriteServiceContextStateImpl( 11594 gen.WriteServiceContextStateImpl(
11407 "gpu/command_buffer/service/context_state_impl_autogen.h") 11595 "gpu/command_buffer/service/context_state_impl_autogen.h")
11408 gen.WriteClientContextStateHeader( 11596 gen.WriteClientContextStateHeader(
11409 "gpu/command_buffer/client/client_context_state_autogen.h") 11597 "gpu/command_buffer/client/client_context_state_autogen.h")
11410 gen.WriteClientContextStateImpl( 11598 gen.WriteClientContextStateImpl(
11411 "gpu/command_buffer/client/client_context_state_impl_autogen.h") 11599 "gpu/command_buffer/client/client_context_state_impl_autogen.h")
11412 gen.WriteServiceUnitTests( 11600 gen.WriteServiceUnitTests(
11413 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h") 11601 "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h")
(...skipping 18 matching lines...) Expand all
11432 Format(gen.generated_cpp_filenames) 11620 Format(gen.generated_cpp_filenames)
11433 11621
11434 if gen.errors > 0: 11622 if gen.errors > 0:
11435 print "%d errors" % gen.errors 11623 print "%d errors" % gen.errors
11436 return 1 11624 return 1
11437 return 0 11625 return 0
11438 11626
11439 11627
11440 if __name__ == '__main__': 11628 if __name__ == '__main__':
11441 sys.exit(main(sys.argv[1:])) 11629 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/buffer.h » ('j') | gpu/command_buffer/common/buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698