VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c@ 56566

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

Host 3D: Expando SPU, DLM module.

  • DLM module reworked. Now it uses hardware way in order to execute Display List (software approach dropped);
  • Chromium/utils slightly extended with more helper functions needed for Expando/DLM;
  • More testing needed especially for glCallLists() and glListBase();
  • Expando/DLM code now enabed for Mac hosts.
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 7.8 KB
 
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#ifndef VBOX_WITH_CR_DISPLAY_LISTS
43 if (!cr_server.sharedDisplayLists) {
44 int client = cr_server.curClient->number;
45 return id + client * 100000;
46 }
47#endif
48 return id;
49}
50
51
52GLuint SERVER_DISPATCH_APIENTRY crServerDispatchGenLists( GLsizei range )
53{
54 GLuint retval;
55 retval = cr_server.head_spu->dispatch_table.GenLists( range );
56 crServerReturnValue( &retval, sizeof(retval) );
57 return retval; /* WILL PROBABLY BE IGNORED */
58}
59
60
61void SERVER_DISPATCH_APIENTRY
62crServerDispatchNewList( GLuint list, GLenum mode )
63{
64 if (mode == GL_COMPILE_AND_EXECUTE)
65 crWarning("using glNewList(GL_COMPILE_AND_EXECUTE) can confuse the crserver");
66
67 list = TranslateListID( list );
68 crStateNewList( list, mode );
69 cr_server.head_spu->dispatch_table.NewList( list, mode );
70}
71
72static void crServerQueryHWState()
73{
74 if (!cr_server.bUseMultipleContexts)
75 {
76 GLuint fbFbo, bbFbo;
77 CRClient *client = cr_server.curClient;
78 CRMuralInfo *mural = client ? client->currentMural : NULL;
79 if (mural && mural->fRedirected)
80 {
81 fbFbo = mural->aidFBOs[CR_SERVER_FBO_FB_IDX(mural)];
82 bbFbo = mural->aidFBOs[CR_SERVER_FBO_BB_IDX(mural)];
83 }
84 else
85 {
86 fbFbo = bbFbo = 0;
87 }
88 crStateQueryHWState(fbFbo, bbFbo);
89 }
90}
91
92void SERVER_DISPATCH_APIENTRY crServerDispatchEndList(void)
93{
94 CRContext *g = crStateGetCurrent();
95 CRListsState *l = &(g->lists);
96
97 cr_server.head_spu->dispatch_table.EndList();
98 crStateEndList();
99
100#ifndef IN_GUEST
101 if (l->mode==GL_COMPILE)
102 {
103 crServerQueryHWState();
104 }
105#endif
106}
107
108void SERVER_DISPATCH_APIENTRY
109crServerDispatchCallList( GLuint list )
110{
111 list = TranslateListID( list );
112
113 if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
114 /* we're not compiling, so execute the list now */
115 /* Issue the list as-is */
116 cr_server.head_spu->dispatch_table.CallList( list );
117 crServerQueryHWState();
118 }
119 else {
120 /* we're compiling glCallList into another list - just pass it through */
121 cr_server.head_spu->dispatch_table.CallList( list );
122 }
123}
124
125
126/**
127 * Translate an array of display list IDs from various datatypes to GLuint
128 * IDs while adding the per-client offset.
129 */
130static void
131TranslateListIDs(GLsizei n, GLenum type, const GLvoid *lists, GLuint *newLists)
132{
133 int offset = cr_server.curClient->number * 100000;
134 GLsizei i;
135 switch (type) {
136 case GL_UNSIGNED_BYTE:
137 {
138 const GLubyte *src = (const GLubyte *) lists;
139 for (i = 0; i < n; i++) {
140 newLists[i] = src[i] + offset;
141 }
142 }
143 break;
144 case GL_BYTE:
145 {
146 const GLbyte *src = (const GLbyte *) lists;
147 for (i = 0; i < n; i++) {
148 newLists[i] = src[i] + offset;
149 }
150 }
151 break;
152 case GL_UNSIGNED_SHORT:
153 {
154 const GLushort *src = (const GLushort *) lists;
155 for (i = 0; i < n; i++) {
156 newLists[i] = src[i] + offset;
157 }
158 }
159 break;
160 case GL_SHORT:
161 {
162 const GLshort *src = (const GLshort *) lists;
163 for (i = 0; i < n; i++) {
164 newLists[i] = src[i] + offset;
165 }
166 }
167 break;
168 case GL_UNSIGNED_INT:
169 {
170 const GLuint *src = (const GLuint *) lists;
171 for (i = 0; i < n; i++) {
172 newLists[i] = src[i] + offset;
173 }
174 }
175 break;
176 case GL_INT:
177 {
178 const GLint *src = (const GLint *) lists;
179 for (i = 0; i < n; i++) {
180 newLists[i] = src[i] + offset;
181 }
182 }
183 break;
184 case GL_FLOAT:
185 {
186 const GLfloat *src = (const GLfloat *) lists;
187 for (i = 0; i < n; i++) {
188 newLists[i] = (GLuint) src[i] + offset;
189 }
190 }
191 break;
192 case GL_2_BYTES:
193 {
194 const GLubyte *src = (const GLubyte *) lists;
195 for (i = 0; i < n; i++) {
196 newLists[i] = (src[i*2+0] * 256 +
197 src[i*2+1]) + offset;
198 }
199 }
200 break;
201 case GL_3_BYTES:
202 {
203 const GLubyte *src = (const GLubyte *) lists;
204 for (i = 0; i < n; i++) {
205 newLists[i] = (src[i*3+0] * 256 * 256 +
206 src[i*3+1] * 256 +
207 src[i*3+2]) + offset;
208 }
209 }
210 break;
211 case GL_4_BYTES:
212 {
213 const GLubyte *src = (const GLubyte *) lists;
214 for (i = 0; i < n; i++) {
215 newLists[i] = (src[i*4+0] * 256 * 256 * 256 +
216 src[i*4+1] * 256 * 256 +
217 src[i*4+2] * 256 +
218 src[i*4+3]) + offset;
219 }
220 }
221 break;
222 default:
223 crWarning("CRServer: invalid display list datatype 0x%x", type);
224 }
225}
226
227
228void SERVER_DISPATCH_APIENTRY
229crServerDispatchCallLists( GLsizei n, GLenum type, const GLvoid *lists )
230{
231 if (!cr_server.sharedDisplayLists) {
232 /* need to translate IDs */
233 GLuint *newLists = (GLuint *) crAlloc(n * sizeof(GLuint));
234 if (newLists) {
235 TranslateListIDs(n, type, lists, newLists);
236 }
237 lists = newLists;
238 type = GL_UNSIGNED_INT;
239 }
240
241 if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
242 /* we're not compiling, so execute the list now */
243 /* Issue the list as-is */
244 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
245 crServerQueryHWState();
246 }
247 else {
248 /* we're compiling glCallList into another list - just pass it through */
249 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
250 }
251
252 if (!cr_server.sharedDisplayLists) {
253 crFree((void *) lists); /* malloc'd above */
254 }
255}
256
257
258GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsList( GLuint list )
259{
260 GLboolean retval;
261 list = TranslateListID( list );
262 retval = cr_server.head_spu->dispatch_table.IsList( list );
263 crServerReturnValue( &retval, sizeof(retval) );
264 return retval;
265}
266
267
268void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteLists( GLuint list, GLsizei range )
269{
270 list = TranslateListID( list );
271 crStateDeleteLists( list, range );
272 cr_server.head_spu->dispatch_table.DeleteLists( list, range );
273}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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