VirtualBox

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

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

Host 3D: crServer: move things in place: shader-related stuff from server_lists.c -> server_glsl.c.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 7.7 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 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
225
226void SERVER_DISPATCH_APIENTRY
227crServerDispatchCallLists( GLsizei n, GLenum type, const GLvoid *lists )
228{
229 if (!cr_server.sharedDisplayLists) {
230 /* need to translate IDs */
231 GLuint *newLists = (GLuint *) crAlloc(n * sizeof(GLuint));
232 if (newLists) {
233 TranslateListIDs(n, type, lists, newLists);
234 }
235 lists = newLists;
236 type = GL_UNSIGNED_INT;
237 }
238
239 if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
240 /* we're not compiling, so execute the list now */
241 /* Issue the list as-is */
242 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
243 crServerQueryHWState();
244 }
245 else {
246 /* we're compiling glCallList into another list - just pass it through */
247 cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
248 }
249
250 if (!cr_server.sharedDisplayLists) {
251 crFree((void *) lists); /* malloc'd above */
252 }
253}
254
255
256GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsList( GLuint list )
257{
258 GLboolean retval;
259 list = TranslateListID( list );
260 retval = cr_server.head_spu->dispatch_table.IsList( list );
261 crServerReturnValue( &retval, sizeof(retval) );
262 return retval;
263}
264
265
266void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteLists( GLuint list, GLsizei range )
267{
268 list = TranslateListID( list );
269 crStateDeleteLists( list, range );
270 cr_server.head_spu->dispatch_table.DeleteLists( list, range );
271}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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