VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.cpp@ 78191

Last change on this file since 78191 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.9 KB
Line 
1/* Copyright (c) 2001-2003, Stanford University
2 All rights reserved.
3
4 See the file LICENSE.txt for information on redistributing this software. */
5
6#include "server_dispatch.h"
7#include "server.h"
8#include "cr_mem.h"
9
10
11/*
12 * Notes on ID translation:
13 *
14 * If a server has multiple clients (in the case of parallel applications)
15 * and N of the clients all create a display list with ID K, does K name
16 * one display list or N different display lists?
17 *
18 * By default, there is one display list named K. If the clients put
19 * identical commands into list K, then this is fine. But if the clients
20 * each put something different into list K when they created it, then this
21 * is a serious problem.
22 *
23 * By zeroing the 'shared_display_lists' configuration option, we can tell
24 * the server to make list K be unique for all N clients. We do this by
25 * translating K into a new, unique ID dependent on which client we're
26 * talking to (curClient->number).
27 *
28 * Same story for texture objects, vertex programs, etc.
29 *
30 * The application can also dynamically switch between shared and private
31 * display lists with:
32 * glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_TRUE)
33 * and
34 * glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_FALSE)
35 *
36 */
37
38
39
40static GLuint TranslateListID( GLuint id )
41{
42 if (!cr_server.sharedDisplayLists) {
43 int client = cr_server.curClient->number;
44 return id + client * 100000;
45 }
46 return id;
47}
48
49
50GLuint SERVER_DISPATCH_APIENTRY crServerDispatchGenLists( GLsizei range )
51{
52 GLuint retval;
53 retval = cr_server.head_spu->dispatch_table.GenLists( range );
54 crServerReturnValue( &retval, sizeof(retval) );
55 return retval; /* WILL PROBABLY BE IGNORED */
56}
57
58
59void SERVER_DISPATCH_APIENTRY
60crServerDispatchNewList( GLuint list, GLenum mode )
61{
62 if (mode == GL_COMPILE_AND_EXECUTE)
63 crWarning("using glNewList(GL_COMPILE_AND_EXECUTE) can confuse the crserver");
64
65 list = TranslateListID( list );
66 crStateNewList( list, mode );
67 cr_server.head_spu->dispatch_table.NewList( list, mode );
68}
69
70static void crServerQueryHWState()
71{
72 if (!cr_server.bUseMultipleContexts)
73 {
74 GLuint fbFbo, bbFbo;
75 CRClient *client = cr_server.curClient;
76 CRMuralInfo *mural = client ? client->currentMural : NULL;
77 if (mural && mural->fRedirected)
78 {
79 fbFbo = mural->aidFBOs[CR_SERVER_FBO_FB_IDX(mural)];
80 bbFbo = mural->aidFBOs[CR_SERVER_FBO_BB_IDX(mural)];
81 }
82 else
83 {
84 fbFbo = bbFbo = 0;
85 }
86 crStateQueryHWState(fbFbo, bbFbo);
87 }
88}
89
90void SERVER_DISPATCH_APIENTRY crServerDispatchEndList(void)
91{
92 CRContext *g = crStateGetCurrent();
93 CRListsState *l = &(g->lists);
94
95 cr_server.head_spu->dispatch_table.EndList();
96 crStateEndList();
97
98#ifndef IN_GUEST
99 if (l->mode==GL_COMPILE)
100 {
101 crServerQueryHWState();
102 }
103#endif
104}
105
106void SERVER_DISPATCH_APIENTRY
107crServerDispatchCallList( GLuint list )
108{
109 list = TranslateListID( list );
110
111 if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
112 /* we're not compiling, so execute the list now */
113 /* Issue the list as-is */
114 cr_server.head_spu->dispatch_table.CallList( list );
115 crServerQueryHWState();
116 }
117 else {
118 /* we're compiling glCallList into another list - just pass it through */
119 cr_server.head_spu->dispatch_table.CallList( list );
120 }
121}
122
123
124/**
125 * Translate an array of display list IDs from various datatypes to GLuint
126 * IDs while adding the per-client offset.
127 */
128static void
129TranslateListIDs(GLsizei n, GLenum type, const GLvoid *lists, GLuint *newLists)
130{
131 int offset = cr_server.curClient->number * 100000;
132 GLsizei i;
133 switch (type) {
134 case GL_UNSIGNED_BYTE:
135 {
136 const GLubyte *src = (const GLubyte *) lists;
137 for (i = 0; i < n; i++) {
138 newLists[i] = src[i] + offset;
139 }
140 }
141 break;
142 case GL_BYTE:
143 {
144 const GLbyte *src = (const GLbyte *) lists;
145 for (i = 0; i < n; i++) {
146 newLists[i] = src[i] + offset;
147 }
148 }
149 break;
150 case GL_UNSIGNED_SHORT:
151 {
152 const GLushort *src = (const GLushort *) lists;
153 for (i = 0; i < n; i++) {
154 newLists[i] = src[i] + offset;
155 }
156 }
157 break;
158 case GL_SHORT:
159 {
160 const GLshort *src = (const GLshort *) lists;
161 for (i = 0; i < n; i++) {
162 newLists[i] = src[i] + offset;
163 }
164 }
165 break;
166 case GL_UNSIGNED_INT:
167 {
168 const GLuint *src = (const GLuint *) lists;
169 for (i = 0; i < n; i++) {
170 newLists[i] = src[i] + offset;
171 }
172 }
173 break;
174 case GL_INT:
175 {
176 const GLint *src = (const GLint *) lists;
177 for (i = 0; i < n; i++) {
178 newLists[i] = src[i] + offset;
179 }
180 }
181 break;
182 case GL_FLOAT:
183 {
184 const GLfloat *src = (const GLfloat *) lists;
185 for (i = 0; i < n; i++) {
186 newLists[i] = (GLuint) src[i] + offset;
187 }
188 }
189 break;
190 case GL_2_BYTES:
191 {
192 const GLubyte *src = (const GLubyte *) lists;
193 for (i = 0; i < n; i++) {
194 newLists[i] = (src[i*2+0] * 256 +
195 src[i*2+1]) + offset;
196 }
197 }
198 break;
199 case GL_3_BYTES:
200 {
201 const GLubyte *src = (const GLubyte *) lists;
202 for (i = 0; i < n; i++) {
203 newLists[i] = (src[i*3+0] * 256 * 256 +
204 src[i*3+1] * 256 +
205 src[i*3+2]) + offset;
206 }
207 }
208 break;
209 case GL_4_BYTES:
210 {
211 const GLubyte *src = (const GLubyte *) lists;
212 for (i = 0; i < n; i++) {
213 newLists[i] = (src[i*4+0] * 256 * 256 * 256 +
214 src[i*4+1] * 256 * 256 +
215 src[i*4+2] * 256 +
216 src[i*4+3]) + offset;
217 }
218 }
219 break;
220 default:
221 crWarning("CRServer: invalid display list datatype 0x%x", type);
222 }
223}
224
225void SERVER_DISPATCH_APIENTRY
226crServerDispatchCallLists( GLsizei n, GLenum type, const GLvoid *lists )
227{
228 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
229 {
230 crError("crServerDispatchCallLists: parameter 'n' is out of range");
231 return;
232 }
233
234 if (!cr_server.sharedDisplayLists) {
235 /* need to translate IDs */
236 GLuint *newLists = (GLuint *) crAlloc(n * sizeof(GLuint));
237 if (newLists) {
238 TranslateListIDs(n, type, lists, newLists);
239 }
240 lists = newLists;
241 type = GL_UNSIGNED_INT;
242 }
243
244 if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
245 /* we're not compiling, so execute the list now */
246 /* Issue the list as-is */
247 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
248 crServerQueryHWState();
249 }
250 else {
251 /* we're compiling glCallList into another list - just pass it through */
252 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
253 }
254
255 if (!cr_server.sharedDisplayLists) {
256 crFree((void *) lists); /* malloc'd above */
257 }
258}
259
260
261GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsList( GLuint list )
262{
263 GLboolean retval;
264 list = TranslateListID( list );
265 retval = cr_server.head_spu->dispatch_table.IsList( list );
266 crServerReturnValue( &retval, sizeof(retval) );
267 return retval;
268}
269
270
271void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteLists( GLuint list, GLsizei range )
272{
273 list = TranslateListID( list );
274 crStateDeleteLists( list, range );
275 cr_server.head_spu->dispatch_table.DeleteLists( list, range );
276}
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