VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/packer.py@ 78190

最後變更 在這個檔案從78190是 78190,由 vboxsync 提交於 6 年 前

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 8.2 KB
 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6# This script generates the packer.c file from the gl_header.parsed file.
7
8from __future__ import print_function
9import sys, string, re
10
11import apiutil
12
13
14
15def WriteData( offset, arg_type, arg_name ):
16 """Return a string to write a variable to the packing buffer."""
17 retval = 9
18 if apiutil.IsPointer(arg_type):
19 retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
20 else:
21 if arg_type == "GLdouble" or arg_type == "GLclampd":
22 retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
23 else:
24 retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
25 if retval == 9:
26 print >>sys.stderr, "no retval for %s %s" % (arg_name, arg_type)
27 assert 0
28 return retval
29
30
31def UpdateCurrentPointer( func_name ):
32 m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
33 if m :
34 k = m.group(1)
35 name = '%s%s' % (k[:1].lower(),k[1:])
36 type = m.group(3) + m.group(2)
37 print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
38 return
39
40 m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)EXT$", func_name )
41 if m :
42 k = m.group(1)
43 name = 'secondaryColor'
44 type = m.group(3) + m.group(2)
45 print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
46 return
47
48 m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
49 if m :
50 k = m.group(1)
51 name = 'texCoord'
52 type = m.group(3) + m.group(2)
53 print("\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type))
54 return
55
56 m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
57 if m :
58 k = m.group(1)
59 name = 'texCoord'
60 type = m.group(3) + m.group(2)
61 print("\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type))
62 return
63
64 m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
65 if m :
66 k = m.group(1)
67 name = 'index'
68 type = m.group(2) + "1"
69 print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
70 return
71
72 m = re.match( r"^(EdgeFlag)$", func_name )
73 if m :
74 k = m.group(1)
75 name = 'edgeFlag'
76 type = "l1"
77 print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
78 return
79
80 m = re.match( r"^(FogCoord)(f|d)EXT$", func_name )
81 if m :
82 k = m.group(1)
83 name = 'fogCoord'
84 type = m.group(2) + "1"
85 print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
86 return
87
88
89 m = re.search( r"^(VertexAttrib)([1234])N?(ub|b|s|f|d)(NV|ARB)$", func_name )
90 if m :
91 k = m.group(1)
92 name = 'vertexAttrib'
93 type = m.group(3) + m.group(2)
94 # Add 12 to skip the packet length, opcode and index fields
95 print("\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type))
96 if m.group(4) == "ARB" or m.group(4) == "NV":
97 print("\tpc->current.attribsUsedMask |= (1 << index);")
98 print("\tpc->current.changedVertexAttrib |= (1 << index);")
99 return
100
101
102
103def PrintFunc( func_name, params, can_have_pointers ):
104 """Emit a packer function."""
105 print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
106 print('{')
107 print('\tCR_GET_PACKER_CONTEXT(pc);')
108
109 # Save original function name
110 orig_func_name = func_name
111
112 # Convert to a non-vector version of the function if possible
113 func_name = apiutil.NonVectorFunction( func_name )
114 if not func_name:
115 func_name = orig_func_name
116
117 # Check if there are any pointer parameters.
118 # That's usually a problem so we'll emit an error function.
119 nonVecParams = apiutil.Parameters(func_name)
120 bail_out = 0
121 for (name, type, vecSize) in nonVecParams:
122 if apiutil.IsPointer(type) and vecSize == 0 and not can_have_pointers:
123 bail_out = 1
124 if bail_out:
125 for (name, type, vecSize) in nonVecParams:
126 print('\t(void)%s;' % (name))
127 print('\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers))
128 print('\t(void) pc;')
129 print('}')
130 # XXX we should really abort here
131 return
132
133 if "extpack" in apiutil.ChromiumProps(func_name):
134 is_extended = 1
135 else:
136 is_extended = 0
137
138
139 print("\tunsigned char *data_ptr = NULL;")
140 print('\t(void) pc;')
141 #if func_name == "Enable" or func_name == "Disable":
142 # print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */"
143
144 for index in range(0,len(params)):
145 (name, type, vecSize) = params[index]
146 if vecSize>0 and func_name!=orig_func_name:
147 print(" if (!%s) {" % name)
148 # Know the reason for this one, so avoid the spam.
149 if orig_func_name != "SecondaryColor3fvEXT":
150 print(" crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name))
151 print(" return;")
152 print(" }")
153
154 packet_length = apiutil.PacketLength(nonVecParams)
155
156 if packet_length == 0 and not is_extended:
157 print("\tCR_GET_BUFFERED_POINTER_NO_ARGS(pc);")
158 elif func_name[:9] == "Translate" or func_name[:5] == "Color":
159 # XXX WTF is the purpose of this?
160 if is_extended:
161 packet_length += 8
162 print("\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, %d, GL_TRUE);" % packet_length)
163 else:
164 if is_extended:
165 packet_length += 8
166 print("\tCR_GET_BUFFERED_POINTER(pc, %d);" % packet_length)
167 UpdateCurrentPointer( func_name )
168
169 if is_extended:
170 counter = 8
171 print(WriteData( 0, 'GLint', packet_length ))
172 print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name )))
173 else:
174 counter = 0
175
176 # Now emit the WRITE_() macros for all parameters
177 for index in range(0,len(params)):
178 (name, type, vecSize) = params[index]
179 # if we're converting a vector-valued function to a non-vector func:
180 if vecSize > 0 and func_name != orig_func_name:
181 ptrType = apiutil.PointerType(type)
182 for i in range(0, vecSize):
183 print(WriteData( counter + i * apiutil.sizeof(ptrType),
184 ptrType, "%s[%d]" % (name, i)))
185 # XXX increment counter here?
186 else:
187 print(WriteData( counter, type, name))
188 if apiutil.IsPointer(type):
189 counter += apiutil.PointerSize()
190 else:
191 counter += apiutil.sizeof(type)
192
193 # finish up
194 if is_extended:
195 print("\tWRITE_OPCODE(pc, CR_EXTEND_OPCODE);")
196 else:
197 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name ))
198
199 if "get" in apiutil.Properties(func_name):
200 print('\tCR_CMDBLOCK_CHECK_FLUSH(pc);')
201
202 print('\tCR_UNLOCK_PACKER_CONTEXT(pc);')
203 print('}\n')
204
205
206r0_funcs = [ 'ChromiumParameteriCR', 'WindowSize', 'WindowShow', 'WindowPosition' ]
207
208
209apiutil.CopyrightC()
210
211print("""
212/* DO NOT EDIT - THIS FILE GENERATED BY THE packer.py SCRIPT */
213
214/* For each of the OpenGL functions we have a packer function which
215 * packs the function's opcode and arguments into a buffer.
216 */
217
218#include "packer.h"
219#include "cr_opcodes.h"
220
221""")
222
223
224keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
225
226for func_name in keys:
227 if apiutil.FindSpecial( "packer", func_name ):
228 continue
229
230 if not apiutil.HasPackOpcode(func_name):
231 continue
232
233 pointers_ok = 0
234
235 return_type = apiutil.ReturnType(func_name)
236 params = apiutil.Parameters(func_name)
237
238 if return_type != 'void':
239 # Yet another gross hack for glGetString
240 if return_type.find('*') == -1:
241 return_type = return_type + " *"
242 params.append(("return_value", return_type, 0))
243
244 if "get" in apiutil.Properties(func_name):
245 pointers_ok = 1
246 params.append(("writeback", "int *", 0))
247
248 if func_name == 'Writeback':
249 pointers_ok = 1
250
251 if not func_name in r0_funcs:
252 print('#ifndef IN_RING0')
253
254 PrintFunc( func_name, params, pointers_ok )
255
256 if not func_name in r0_funcs:
257 print('#endif')
258
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette