VirtualBox

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

Last change on this file since 78190 was 78190, checked in by vboxsync, 6 years ago

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))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.4 KB
Line 
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_bbox.c file from gl_header.parsed
7
8from __future__ import print_function
9import sys
10import string
11
12import apiutil
13
14
15apiutil.CopyrightC()
16
17print("""
18/* DO NOT EDIT - THIS FILE GENERATED BY THE packer_bbox.py SCRIPT */
19
20/* These functions pack glVertex functions and also update the bounding box
21 * if the cr_packer_globals.updateBBOX variable is non-zero.
22 */
23
24#include "packer.h"
25#include "cr_opcodes.h"
26#include "pack_bbox.h"
27
28#include <float.h>
29
30/**
31 * Reset packer bounding box to empty state.
32 */
33void crPackResetBoundingBox(CRPackContext *pc)
34{
35 pc->bounds_min.x = FLT_MAX;
36 pc->bounds_min.y = FLT_MAX;
37 pc->bounds_min.z = FLT_MAX;
38 pc->bounds_max.x = -FLT_MAX;
39 pc->bounds_max.y = -FLT_MAX;
40 pc->bounds_max.z = -FLT_MAX;
41 pc->updateBBOX = 1;
42}
43
44/**
45 * Query current bounding box.
46 * \return GL_TRUE if non-empty box, GL_FALSE if empty box.
47 */
48GLboolean crPackGetBoundingBox(CRPackContext *pc,
49 GLfloat *xmin, GLfloat *ymin, GLfloat *zmin,
50 GLfloat *xmax, GLfloat *ymax, GLfloat *zmax)
51{
52 if (pc->bounds_min.x != FLT_MAX) {
53 *xmin = pc->bounds_min.x;
54 *ymin = pc->bounds_min.y;
55 *zmin = pc->bounds_min.z;
56 *xmax = pc->bounds_max.x;
57 *ymax = pc->bounds_max.y;
58 *zmax = pc->bounds_max.z;
59 return GL_TRUE;
60 }
61 else {
62 return GL_FALSE;
63 }
64}
65
66""")
67
68def WriteData( offset, arg_type, arg_name ):
69 if arg_type.find('*') != -1:
70 retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
71 else:
72 if arg_type == "GLdouble" or arg_type == "GLclampd":
73 retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
74 else:
75 retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
76 return retval
77
78
79def PrintFunction( func_name, extSuffix, num_coords, argtype,
80 do_count, do_vector ):
81 """
82 Generate all the functions named crPackVertex[234][dfis][v]BBOX() and
83 crPackVertex[234][dfis][v]BBOX_COUNT().
84 We also handle glVertexAttrib*ARB.
85 Note: func_name should not have an ARB suffix.
86 """
87
88 if do_count:
89 countSuffix = "_COUNT"
90 else:
91 countSuffix = ""
92
93 if func_name[0:12] == "VertexAttrib":
94 isVertexAttrib = 1
95 else:
96 isVertexAttrib = 0
97
98 if argtype[0] == "N":
99 normalized = 1
100 else:
101 normalized = 0;
102
103 if argtype == "b" or argtype == "Nb":
104 vector_type = "GLbyte"
105 elif argtype == "ub" or argtype == "Nub":
106 vector_type = "GLubyte"
107 elif argtype == "s" or argtype == "Ns":
108 vector_type = "GLshort"
109 elif argtype == "us" or argtype == "Nus":
110 vector_type = "GLushort"
111 elif argtype == "i" or argtype == "Ni":
112 vector_type = "GLint"
113 elif argtype == "ui" or argtype == "Nui":
114 vector_type = "GLuint"
115 elif argtype == "f":
116 vector_type = "GLfloat"
117 elif argtype == "d":
118 vector_type = "GLdouble"
119 else:
120 print("type is %s" % argtype)
121 abort()
122
123 if do_vector:
124 if isVertexAttrib:
125 func_name = 'VertexAttrib%d%sv' % (num_coords, argtype)
126 else:
127 func_name = 'Vertex%d%sv' % (num_coords,argtype)
128
129 params = apiutil.Parameters(func_name + extSuffix)
130
131 print('void PACK_APIENTRY crPack%sBBOX%s(%s)' % (func_name + extSuffix, countSuffix,
132 apiutil.MakeDeclarationString(params)))
133 print('{')
134
135 if do_vector:
136 # vector version
137 packet_length = num_coords * apiutil.sizeof(vector_type)
138 if isVertexAttrib:
139 packet_length += 4 # for index
140 if packet_length % 4 != 0:
141 packet_length += 2
142
143 else:
144 # non-vector
145 packet_length = apiutil.PacketLength( params )
146 if isVertexAttrib:
147 packet_length += 0 # for index
148 if packet_length % 4 != 0:
149 packet_length += 2
150
151
152 print("\tCR_GET_PACKER_CONTEXT(pc);")
153 print("\tunsigned char *data_ptr = NULL;")
154
155 if normalized:
156 if argtype == "Nb":
157 t = "B"
158 elif argtype == "Ni":
159 t = "I"
160 elif argtype == "Nui":
161 t = "UI"
162 elif argtype == "Nub":
163 t = "UB"
164 elif argtype == "Ns":
165 t = "S"
166 elif argtype == "Nus":
167 t = "US"
168 else:
169 abort()
170 if do_vector:
171 print("\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t))
172 else:
173 print("\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t))
174 else:
175 if do_vector:
176 print("\tCREATE_%dD_VFLOATS();" % num_coords)
177 else:
178 print("\tCREATE_%dD_FLOATS();" % num_coords)
179
180 print("\tCR_GET_BUFFERED%s_POINTER(pc, %d);" % (countSuffix, packet_length))
181
182 # Bounding box code
183 if isVertexAttrib:
184 print("\tif (pc->updateBBOX && index == 0)")
185 else:
186 print("\tif (pc->updateBBOX)")
187 print("\t{")
188 if num_coords < 4:
189 print("\t\tUPDATE_%dD_BBOX();" % num_coords)
190 else:
191 print("\t\tUPDATE_3D_BBOX();")
192 print("\t}")
193
194 if isVertexAttrib:
195 print("\tif (index > 0) {")
196 t = argtype
197 print("\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords))
198 print("\t\tpc->current.attribsUsedMask |= (1 << index);")
199 if do_count:
200 print("\t\tpc->current.vtx_count--;")
201
202 print("\t}")
203
204 fname = func_name + extSuffix
205 if do_vector:
206 # use non-vector opcode
207 opcode = apiutil.OpcodeName( func_name[:-1] + extSuffix )
208 else:
209 opcode = apiutil.OpcodeName( func_name + extSuffix )
210 counter = 0
211
212 if do_vector:
213 if isVertexAttrib:
214 print("\tWRITE_DATA(0, GLuint, index);")
215 counter += 4
216 argname = params[1][0] # skip 'index' parameter
217 else:
218 argname = params[0][0]
219
220 for index in range(num_coords):
221 print(WriteData( counter, vector_type, "%s[%d]" % (argname, index)))
222 counter += apiutil.sizeof(vector_type)
223
224 if isVertexAttrib:
225 if do_vector == 2:
226 # this is a bit of a hack
227 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" ))
228 else:
229 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] + "ARB" ))
230 else:
231 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] ))
232 else:
233 for index in range(0,len(params)):
234 (name, type, vecSize) = params[index]
235 print(WriteData( counter, type, name))
236 counter += apiutil.sizeof(type)
237
238 if isVertexAttrib:
239 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" ))
240 else:
241 print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name ))
242
243 print("\tCR_UNLOCK_PACKER_CONTEXT(pc);")
244
245
246 print('}\n')
247
248#end PrintFunction()
249
250
251for num_coords in [2,3,4]:
252 for argtype in ['d', 'f', 'i', 's']:
253 func_name = 'Vertex%d%s' % (num_coords, argtype)
254 for count in range(0, 2):
255 for vec in range(0, 2):
256 PrintFunction( func_name, "", num_coords, argtype,
257 count, vec )
258
259for num_coords in [1,2,3,4]:
260 for argtype in ['d', 'f', 's']:
261 func_name = 'VertexAttrib%d%s' % (num_coords, argtype)
262 for count in range(0, 2):
263 for vec in range(0, 2):
264 PrintFunction( func_name, "ARB", num_coords, argtype,
265 count, vec )
266
267# Special vector functions
268moreFuncs = [ [ "VertexAttrib4ubv", "ub" ],
269 [ "VertexAttrib4usv", "us" ],
270 [ "VertexAttrib4uiv", "ui" ],
271 [ "VertexAttrib4bv", "b" ],
272 [ "VertexAttrib4iv", "i" ],
273 [ "VertexAttrib4Nbv", "Nb" ],
274 [ "VertexAttrib4Nsv", "Ns" ],
275 [ "VertexAttrib4Niv", "Ni" ],
276 [ "VertexAttrib4Nubv", "Nub" ],
277 [ "VertexAttrib4Nusv", "Nus" ],
278 [ "VertexAttrib4Nuiv", "Nui" ]
279 ]
280for (func_name, argtype) in moreFuncs:
281 vec = 2 # special, hacked value
282 num_coords = 4
283 for count in range(0, 2):
284 PrintFunction( func_name, "ARB", num_coords, argtype, count, vec )
285
286# Special non-vector functions
287moreFuncs = [ [ "VertexAttrib4Nub", "Nub" ] ]
288for (func_name, argtype) in moreFuncs:
289 vec = 0
290 num_coords = 4
291 for count in range(0, 2):
292 PrintFunction( func_name, "ARB", num_coords, argtype, count, vec )
293
Note: See TracBrowser for help on using the repository browser.

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