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 |
|
---|
7 | #include "server_dispatch.h"
|
---|
8 | #include "server.h"
|
---|
9 | #include "cr_error.h"
|
---|
10 | #include "cr_mem.h"
|
---|
11 | #include "cr_string.h"
|
---|
12 | #include "cr_pixeldata.h"
|
---|
13 |
|
---|
14 | void SERVER_DISPATCH_APIENTRY crServerDispatchSelectBuffer( GLsizei size, GLuint *buffer )
|
---|
15 | {
|
---|
16 | (void) size;
|
---|
17 | (void) buffer;
|
---|
18 | crError( "Unsupported network glSelectBuffer call." );
|
---|
19 | }
|
---|
20 |
|
---|
21 | void SERVER_DISPATCH_APIENTRY crServerDispatchGetChromiumParametervCR(GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values)
|
---|
22 | {
|
---|
23 | GLubyte local_storage[4096];
|
---|
24 | GLint bytes = 0;
|
---|
25 |
|
---|
26 | switch (type) {
|
---|
27 | case GL_BYTE:
|
---|
28 | case GL_UNSIGNED_BYTE:
|
---|
29 | bytes = count * sizeof(GLbyte);
|
---|
30 | break;
|
---|
31 | case GL_SHORT:
|
---|
32 | case GL_UNSIGNED_SHORT:
|
---|
33 | bytes = count * sizeof(GLshort);
|
---|
34 | break;
|
---|
35 | case GL_INT:
|
---|
36 | case GL_UNSIGNED_INT:
|
---|
37 | bytes = count * sizeof(GLint);
|
---|
38 | break;
|
---|
39 | case GL_FLOAT:
|
---|
40 | bytes = count * sizeof(GLfloat);
|
---|
41 | break;
|
---|
42 | case GL_DOUBLE:
|
---|
43 | bytes = count * sizeof(GLdouble);
|
---|
44 | break;
|
---|
45 | default:
|
---|
46 | crError("Bad type in crServerDispatchGetChromiumParametervCR");
|
---|
47 | }
|
---|
48 |
|
---|
49 | CRASSERT(bytes >= 0);
|
---|
50 | CRASSERT(bytes < 4096);
|
---|
51 |
|
---|
52 | switch (target)
|
---|
53 | {
|
---|
54 | case GL_DBG_CHECK_BREAK_CR:
|
---|
55 | {
|
---|
56 | if (bytes > 0)
|
---|
57 | {
|
---|
58 | GLubyte *pbRc = local_storage;
|
---|
59 | GLuint *puRc = (GLuint *)(bytes >=4 ? local_storage : NULL);
|
---|
60 | int rc;
|
---|
61 | memset(local_storage, 0, bytes);
|
---|
62 | if (cr_server.RcToGuestOnce)
|
---|
63 | {
|
---|
64 | rc = cr_server.RcToGuestOnce;
|
---|
65 | cr_server.RcToGuestOnce = 0;
|
---|
66 | }
|
---|
67 | else
|
---|
68 | {
|
---|
69 | rc = cr_server.RcToGuest;
|
---|
70 | }
|
---|
71 | if (puRc)
|
---|
72 | *puRc = rc;
|
---|
73 | else
|
---|
74 | *pbRc = !!rc;
|
---|
75 | }
|
---|
76 | else
|
---|
77 | {
|
---|
78 | crWarning("zero bytes for GL_DBG_CHECK_BREAK_CR");
|
---|
79 | }
|
---|
80 | break;
|
---|
81 | }
|
---|
82 | default:
|
---|
83 | cr_server.head_spu->dispatch_table.GetChromiumParametervCR( target, index, type, count, local_storage );
|
---|
84 | break;
|
---|
85 | }
|
---|
86 |
|
---|
87 | crServerReturnValue( local_storage, bytes );
|
---|
88 | }
|
---|
89 |
|
---|
90 | void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values)
|
---|
91 | {
|
---|
92 | CRMuralInfo *mural = cr_server.curClient->currentMural;
|
---|
93 | static int gather_connect_count = 0;
|
---|
94 |
|
---|
95 | switch (target) {
|
---|
96 | case GL_SET_MAX_VIEWPORT_CR:
|
---|
97 | {
|
---|
98 | GLint *maxDims = (GLint *)values;
|
---|
99 | cr_server.limits.maxViewportDims[0] = maxDims[0];
|
---|
100 | cr_server.limits.maxViewportDims[1] = maxDims[1];
|
---|
101 | }
|
---|
102 | break;
|
---|
103 |
|
---|
104 | case GL_TILE_INFO_CR:
|
---|
105 | /* message from tilesort SPU to set new tile bounds */
|
---|
106 | {
|
---|
107 | GLint numTiles, muralWidth, muralHeight, server, tiles;
|
---|
108 | GLint *tileBounds;
|
---|
109 | CRASSERT(count >= 4);
|
---|
110 | CRASSERT((count - 4) % 4 == 0); /* must be multiple of four */
|
---|
111 | CRASSERT(type == GL_INT);
|
---|
112 | numTiles = (count - 4) / 4;
|
---|
113 | tileBounds = (GLint *) values;
|
---|
114 | server = tileBounds[0];
|
---|
115 | muralWidth = tileBounds[1];
|
---|
116 | muralHeight = tileBounds[2];
|
---|
117 | tiles = tileBounds[3];
|
---|
118 | CRASSERT(tiles == numTiles);
|
---|
119 | tileBounds += 4; /* skip over header values */
|
---|
120 | /*crServerNewMuralTiling(mural, muralWidth, muralHeight, numTiles, tileBounds);
|
---|
121 | mural->viewportValidated = GL_FALSE;*/
|
---|
122 | }
|
---|
123 | break;
|
---|
124 |
|
---|
125 | case GL_GATHER_DRAWPIXELS_CR:
|
---|
126 | if (cr_server.only_swap_once && cr_server.curClient != cr_server.clients[0])
|
---|
127 | break;
|
---|
128 | cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
|
---|
129 | break;
|
---|
130 |
|
---|
131 | case GL_GATHER_CONNECT_CR:
|
---|
132 | /*
|
---|
133 | * We want the last connect to go through,
|
---|
134 | * otherwise we might deadlock in CheckWindowSize()
|
---|
135 | * in the readback spu
|
---|
136 | */
|
---|
137 | gather_connect_count++;
|
---|
138 | if (cr_server.only_swap_once && (gather_connect_count != cr_server.numClients))
|
---|
139 | {
|
---|
140 | break;
|
---|
141 | }
|
---|
142 | cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
|
---|
143 | gather_connect_count = 0;
|
---|
144 | break;
|
---|
145 |
|
---|
146 | case GL_SERVER_VIEW_MATRIX_CR:
|
---|
147 | /* Set this server's view matrix which will get premultiplied onto the
|
---|
148 | * modelview matrix. For non-planar tilesort and stereo.
|
---|
149 | */
|
---|
150 | CRASSERT(count == 18);
|
---|
151 | CRASSERT(type == GL_FLOAT);
|
---|
152 | /* values[0] is the server index. Ignored here but used in tilesort SPU */
|
---|
153 | /* values[1] is the left/right eye index (0 or 1) */
|
---|
154 | {
|
---|
155 | const GLfloat *v = (const GLfloat *) values;
|
---|
156 | const int eye = v[1] == 0.0 ? 0 : 1;
|
---|
157 | crMatrixInitFromFloats(&cr_server.viewMatrix[eye], v + 2);
|
---|
158 |
|
---|
159 | crDebug("Got GL_SERVER_VIEW_MATRIX_CR:\n"
|
---|
160 | " %f %f %f %f\n"
|
---|
161 | " %f %f %f %f\n"
|
---|
162 | " %f %f %f %f\n"
|
---|
163 | " %f %f %f %f",
|
---|
164 | cr_server.viewMatrix[eye].m00,
|
---|
165 | cr_server.viewMatrix[eye].m10,
|
---|
166 | cr_server.viewMatrix[eye].m20,
|
---|
167 | cr_server.viewMatrix[eye].m30,
|
---|
168 | cr_server.viewMatrix[eye].m01,
|
---|
169 | cr_server.viewMatrix[eye].m11,
|
---|
170 | cr_server.viewMatrix[eye].m21,
|
---|
171 | cr_server.viewMatrix[eye].m31,
|
---|
172 | cr_server.viewMatrix[eye].m02,
|
---|
173 | cr_server.viewMatrix[eye].m12,
|
---|
174 | cr_server.viewMatrix[eye].m22,
|
---|
175 | cr_server.viewMatrix[eye].m32,
|
---|
176 | cr_server.viewMatrix[eye].m03,
|
---|
177 | cr_server.viewMatrix[eye].m13,
|
---|
178 | cr_server.viewMatrix[eye].m23,
|
---|
179 | cr_server.viewMatrix[eye].m33);
|
---|
180 | }
|
---|
181 | cr_server.viewOverride = GL_TRUE;
|
---|
182 | break;
|
---|
183 |
|
---|
184 | case GL_SERVER_PROJECTION_MATRIX_CR:
|
---|
185 | /* Set this server's projection matrix which will get replace the user's
|
---|
186 | * projection matrix. For non-planar tilesort and stereo.
|
---|
187 | */
|
---|
188 | CRASSERT(count == 18);
|
---|
189 | CRASSERT(type == GL_FLOAT);
|
---|
190 | /* values[0] is the server index. Ignored here but used in tilesort SPU */
|
---|
191 | /* values[1] is the left/right eye index (0 or 1) */
|
---|
192 | {
|
---|
193 | const GLfloat *v = (const GLfloat *) values;
|
---|
194 | const int eye = v[1] == 0.0 ? 0 : 1;
|
---|
195 | crMatrixInitFromFloats(&cr_server.projectionMatrix[eye], v + 2);
|
---|
196 |
|
---|
197 | crDebug("Got GL_SERVER_PROJECTION_MATRIX_CR:\n"
|
---|
198 | " %f %f %f %f\n"
|
---|
199 | " %f %f %f %f\n"
|
---|
200 | " %f %f %f %f\n"
|
---|
201 | " %f %f %f %f",
|
---|
202 | cr_server.projectionMatrix[eye].m00,
|
---|
203 | cr_server.projectionMatrix[eye].m10,
|
---|
204 | cr_server.projectionMatrix[eye].m20,
|
---|
205 | cr_server.projectionMatrix[eye].m30,
|
---|
206 | cr_server.projectionMatrix[eye].m01,
|
---|
207 | cr_server.projectionMatrix[eye].m11,
|
---|
208 | cr_server.projectionMatrix[eye].m21,
|
---|
209 | cr_server.projectionMatrix[eye].m31,
|
---|
210 | cr_server.projectionMatrix[eye].m02,
|
---|
211 | cr_server.projectionMatrix[eye].m12,
|
---|
212 | cr_server.projectionMatrix[eye].m22,
|
---|
213 | cr_server.projectionMatrix[eye].m32,
|
---|
214 | cr_server.projectionMatrix[eye].m03,
|
---|
215 | cr_server.projectionMatrix[eye].m13,
|
---|
216 | cr_server.projectionMatrix[eye].m23,
|
---|
217 | cr_server.projectionMatrix[eye].m33);
|
---|
218 |
|
---|
219 | if (cr_server.projectionMatrix[eye].m33 == 0.0f) {
|
---|
220 | float x = cr_server.projectionMatrix[eye].m00;
|
---|
221 | float y = cr_server.projectionMatrix[eye].m11;
|
---|
222 | float a = cr_server.projectionMatrix[eye].m20;
|
---|
223 | float b = cr_server.projectionMatrix[eye].m21;
|
---|
224 | float c = cr_server.projectionMatrix[eye].m22;
|
---|
225 | float d = cr_server.projectionMatrix[eye].m32;
|
---|
226 | float znear = -d / (1.0f - c);
|
---|
227 | float zfar = (c - 1.0f) * znear / (c + 1.0f);
|
---|
228 | float left = znear * (a - 1.0f) / x;
|
---|
229 | float right = 2.0f * znear / x + left;
|
---|
230 | float bottom = znear * (b - 1.0f) / y;
|
---|
231 | float top = 2.0f * znear / y + bottom;
|
---|
232 | crDebug("Frustum: left, right, bottom, top, near, far: %f, %f, %f, %f, %f, %f", left, right, bottom, top, znear, zfar);
|
---|
233 | }
|
---|
234 | else {
|
---|
235 | /* Todo: Add debug output for orthographic projection*/
|
---|
236 | }
|
---|
237 |
|
---|
238 | }
|
---|
239 | cr_server.projectionOverride = GL_TRUE;
|
---|
240 | break;
|
---|
241 |
|
---|
242 | default:
|
---|
243 | /* Pass the parameter info to the head SPU */
|
---|
244 | cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
|
---|
245 | break;
|
---|
246 | }
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameteriCR(GLenum target, GLint value)
|
---|
251 | {
|
---|
252 | switch (target) {
|
---|
253 | case GL_SHARE_CONTEXT_RESOURCES_CR:
|
---|
254 | crStateShareContext(value);
|
---|
255 | break;
|
---|
256 | case GL_RCUSAGE_TEXTURE_SET_CR:
|
---|
257 | crStateSetTextureUsed(value, GL_TRUE);
|
---|
258 | break;
|
---|
259 | case GL_RCUSAGE_TEXTURE_CLEAR_CR:
|
---|
260 | crStateSetTextureUsed(value, GL_FALSE);
|
---|
261 | break;
|
---|
262 | case GL_SHARED_DISPLAY_LISTS_CR:
|
---|
263 | cr_server.sharedDisplayLists = value;
|
---|
264 | break;
|
---|
265 | case GL_SHARED_TEXTURE_OBJECTS_CR:
|
---|
266 | cr_server.sharedTextureObjects = value;
|
---|
267 | break;
|
---|
268 | case GL_SHARED_PROGRAMS_CR:
|
---|
269 | cr_server.sharedPrograms = value;
|
---|
270 | break;
|
---|
271 | case GL_SERVER_CURRENT_EYE_CR:
|
---|
272 | cr_server.currentEye = value ? 1 : 0;
|
---|
273 | break;
|
---|
274 | case GL_HOST_WND_CREATED_HIDDEN_CR:
|
---|
275 | cr_server.bWindowsInitiallyHidden = value ? 1 : 0;
|
---|
276 | break;
|
---|
277 | case GL_HH_SET_DEFAULT_SHARED_CTX:
|
---|
278 | crWarning("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring");
|
---|
279 | break;
|
---|
280 | default:
|
---|
281 | /* Pass the parameter info to the head SPU */
|
---|
282 | cr_server.head_spu->dispatch_table.ChromiumParameteriCR( target, value );
|
---|
283 | }
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameterfCR(GLenum target, GLfloat value)
|
---|
288 | {
|
---|
289 | switch (target) {
|
---|
290 | case GL_SHARED_DISPLAY_LISTS_CR:
|
---|
291 | cr_server.sharedDisplayLists = (int) value;
|
---|
292 | break;
|
---|
293 | case GL_SHARED_TEXTURE_OBJECTS_CR:
|
---|
294 | cr_server.sharedTextureObjects = (int) value;
|
---|
295 | break;
|
---|
296 | case GL_SHARED_PROGRAMS_CR:
|
---|
297 | cr_server.sharedPrograms = (int) value;
|
---|
298 | break;
|
---|
299 | default:
|
---|
300 | /* Pass the parameter info to the head SPU */
|
---|
301 | cr_server.head_spu->dispatch_table.ChromiumParameterfCR( target, value );
|
---|
302 | }
|
---|
303 | }
|
---|
304 |
|
---|
305 | GLint crServerGenerateID(GLint *pCounter)
|
---|
306 | {
|
---|
307 | return (*pCounter)++;
|
---|
308 | }
|
---|
309 |
|
---|
310 | /*#define CR_DUMP_BLITS*/
|
---|
311 |
|
---|
312 | #ifdef CR_DUMP_BLITS
|
---|
313 | static int blitnum=0;
|
---|
314 | static int copynum=0;
|
---|
315 | #endif
|
---|
316 |
|
---|
317 | # ifdef DEBUG_misha
|
---|
318 | //# define CR_CHECK_BLITS
|
---|
319 | # include <iprt/assert.h>
|
---|
320 | # undef CRASSERT /* iprt assert's int3 are inlined that is why are more convenient to use since they can be easily disabled individually */
|
---|
321 | # define CRASSERT Assert
|
---|
322 | # endif
|
---|
323 |
|
---|
324 |
|
---|
325 | void SERVER_DISPATCH_APIENTRY
|
---|
326 | crServerDispatchCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
|
---|
327 | {
|
---|
328 | /*@todo pbo/fbo disabled for now as it's slower, check on other gpus*/
|
---|
329 | static int siHavePBO = 0;
|
---|
330 | static int siHaveFBO = 0;
|
---|
331 |
|
---|
332 | if ((target!=GL_TEXTURE_2D) || (height>=0))
|
---|
333 | {
|
---|
334 | cr_server.head_spu->dispatch_table.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
---|
335 |
|
---|
336 | #ifdef CR_DUMP_BLITS
|
---|
337 | {
|
---|
338 | SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
|
---|
339 | void *img;
|
---|
340 | GLint w, h;
|
---|
341 | char fname[200];
|
---|
342 |
|
---|
343 | copynum++;
|
---|
344 |
|
---|
345 | gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
---|
346 | gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
---|
347 |
|
---|
348 | img = crAlloc(w*h*4);
|
---|
349 | CRASSERT(img);
|
---|
350 |
|
---|
351 | gl->GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, img);
|
---|
352 | sprintf(fname, "copy_blit%i_copy_%i.tga", blitnum, copynum);
|
---|
353 | crDumpNamedTGA(fname, w, h, img);
|
---|
354 | crFree(img);
|
---|
355 | }
|
---|
356 | #endif
|
---|
357 | }
|
---|
358 | else /* negative height, means we have to Yinvert the source pixels while copying */
|
---|
359 | {
|
---|
360 | SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
|
---|
361 |
|
---|
362 | if (siHavePBO<0)
|
---|
363 | {
|
---|
364 | const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
|
---|
365 | siHavePBO = crStrstr(ext, "GL_ARB_pixel_buffer_object") ? 1:0;
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (siHaveFBO<0)
|
---|
369 | {
|
---|
370 | const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
|
---|
371 | siHaveFBO = crStrstr(ext, "GL_EXT_framebuffer_object") ? 1:0;
|
---|
372 | }
|
---|
373 |
|
---|
374 | if (siHavePBO==0 && siHaveFBO==0)
|
---|
375 | {
|
---|
376 | #if 1
|
---|
377 | GLint dRow, sRow;
|
---|
378 | for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
|
---|
379 | {
|
---|
380 | gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
|
---|
381 | }
|
---|
382 | #else
|
---|
383 | {
|
---|
384 | GLint w, h, i;
|
---|
385 | char *img1, *img2, *sPtr, *dPtr;
|
---|
386 | CRContext *ctx = crStateGetCurrent();
|
---|
387 |
|
---|
388 | w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
|
---|
389 | h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
|
---|
390 |
|
---|
391 | img1 = crAlloc(4*w*h);
|
---|
392 | img2 = crAlloc(4*width*(-height));
|
---|
393 | CRASSERT(img1 && img2);
|
---|
394 |
|
---|
395 | gl->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, -height);
|
---|
396 | gl->GetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, img1);
|
---|
397 |
|
---|
398 | sPtr=img1+4*xoffset+4*w*yoffset;
|
---|
399 | dPtr=img2+4*width*(-height-1);
|
---|
400 |
|
---|
401 | for (i=0; i<-height; ++i)
|
---|
402 | {
|
---|
403 | crMemcpy(dPtr, sPtr, 4*width);
|
---|
404 | sPtr += 4*w;
|
---|
405 | dPtr -= 4*width;
|
---|
406 | }
|
---|
407 |
|
---|
408 | gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, img2);
|
---|
409 |
|
---|
410 | crFree(img1);
|
---|
411 | crFree(img2);
|
---|
412 | }
|
---|
413 | #endif
|
---|
414 | }
|
---|
415 | else if (siHaveFBO==1) /*@todo more states to set and restore here*/
|
---|
416 | {
|
---|
417 | GLuint tID, fboID;
|
---|
418 | GLenum status;
|
---|
419 | CRContext *ctx = crStateGetCurrent();
|
---|
420 |
|
---|
421 | gl->GenTextures(1, &tID);
|
---|
422 | gl->BindTexture(target, tID);
|
---|
423 | gl->CopyTexImage2D(target, level, GL_RGBA, x, y, width, -height, 0);
|
---|
424 | gl->GenFramebuffersEXT(1, &fboID);
|
---|
425 | gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
|
---|
426 | gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target,
|
---|
427 | ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid, level);
|
---|
428 | status = gl->CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
---|
429 | if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
---|
430 | {
|
---|
431 | crWarning("Framebuffer status 0x%x", status);
|
---|
432 | }
|
---|
433 |
|
---|
434 | gl->Enable(target);
|
---|
435 | gl->PushAttrib(GL_VIEWPORT_BIT);
|
---|
436 | gl->Viewport(xoffset, yoffset, width, -height);
|
---|
437 | gl->MatrixMode(GL_PROJECTION);
|
---|
438 | gl->PushMatrix();
|
---|
439 | gl->LoadIdentity();
|
---|
440 | gl->MatrixMode(GL_MODELVIEW);
|
---|
441 | gl->PushMatrix();
|
---|
442 | gl->LoadIdentity();
|
---|
443 |
|
---|
444 | gl->Disable(GL_DEPTH_TEST);
|
---|
445 | gl->Disable(GL_CULL_FACE);
|
---|
446 | gl->Disable(GL_STENCIL_TEST);
|
---|
447 | gl->Disable(GL_SCISSOR_TEST);
|
---|
448 |
|
---|
449 | gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
---|
450 | gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
---|
451 | gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
452 | gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
453 | gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
---|
454 |
|
---|
455 | gl->Begin(GL_QUADS);
|
---|
456 | gl->TexCoord2f(0.0f, 1.0f);
|
---|
457 | gl->Vertex2f(-1.0, -1.0);
|
---|
458 |
|
---|
459 | gl->TexCoord2f(0.0f, 0.0f);
|
---|
460 | gl->Vertex2f(-1.0f, 1.0f);
|
---|
461 |
|
---|
462 | gl->TexCoord2f(1.0f, 0.0f);
|
---|
463 | gl->Vertex2f(1.0f, 1.0f);
|
---|
464 |
|
---|
465 | gl->TexCoord2f(1.0f, 1.0f);
|
---|
466 | gl->Vertex2f(1.0f, -1.0f);
|
---|
467 | gl->End();
|
---|
468 |
|
---|
469 | gl->PopMatrix();
|
---|
470 | gl->MatrixMode(GL_PROJECTION);
|
---|
471 | gl->PopMatrix();
|
---|
472 | gl->PopAttrib();
|
---|
473 |
|
---|
474 | gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, 0, level);
|
---|
475 | gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->framebufferobject.drawFB ? ctx->framebufferobject.drawFB->hwid:0);
|
---|
476 | gl->BindTexture(target, ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid);
|
---|
477 | gl->DeleteFramebuffersEXT(1, &fboID);
|
---|
478 | gl->DeleteTextures(1, &tID);
|
---|
479 |
|
---|
480 | #if 0
|
---|
481 | {
|
---|
482 | GLint dRow, sRow, w, h;
|
---|
483 | void *img1, *img2;
|
---|
484 |
|
---|
485 | w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
|
---|
486 | h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
|
---|
487 |
|
---|
488 | img1 = crAlloc(4*w*h);
|
---|
489 | img2 = crAlloc(4*w*h);
|
---|
490 | CRASSERT(img1 && img2);
|
---|
491 |
|
---|
492 | gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img1);
|
---|
493 |
|
---|
494 |
|
---|
495 | for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
|
---|
496 | {
|
---|
497 | gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
|
---|
498 | }
|
---|
499 |
|
---|
500 | gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img2);
|
---|
501 |
|
---|
502 | if (crMemcmp(img1, img2, 4*w*h))
|
---|
503 | {
|
---|
504 | crDebug("MISMATCH! (%x, %i, ->%i,%i <-%i, %i [%ix%i])", target, level, xoffset, yoffset, x, y, width, height);
|
---|
505 | crDumpTGA(w, h, img1);
|
---|
506 | crDumpTGA(w, h, img2);
|
---|
507 | DebugBreak();
|
---|
508 | }
|
---|
509 | crFree(img1);
|
---|
510 | crFree(img2);
|
---|
511 | }
|
---|
512 | #endif
|
---|
513 | }
|
---|
514 | else
|
---|
515 | {
|
---|
516 | GLuint pboId, dRow, sRow;
|
---|
517 | CRContext *ctx = crStateGetCurrent();
|
---|
518 |
|
---|
519 | gl->GenBuffersARB(1, &pboId);
|
---|
520 | gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboId);
|
---|
521 | gl->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, -width*height*4, 0, GL_STATIC_COPY_ARB);
|
---|
522 |
|
---|
523 | #if 1
|
---|
524 | gl->ReadPixels(x, y, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
---|
525 | gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
|
---|
526 |
|
---|
527 | gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
|
---|
528 | for (dRow=yoffset, sRow=-height-1; dRow<yoffset-height; dRow++, sRow--)
|
---|
529 | {
|
---|
530 | gl->TexSubImage2D(target, level, xoffset, dRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)sRow*width*4));
|
---|
531 | }
|
---|
532 | #else /*few times slower again*/
|
---|
533 | for (dRow=0, sRow=y-height-1; dRow<-height; dRow++, sRow--)
|
---|
534 | {
|
---|
535 | gl->ReadPixels(x, sRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)dRow*width*4));
|
---|
536 | }
|
---|
537 | gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
|
---|
538 |
|
---|
539 | gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
|
---|
540 | gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
---|
541 | #endif
|
---|
542 |
|
---|
543 | gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, ctx->bufferobject.unpackBuffer->hwid);
|
---|
544 | gl->DeleteBuffersARB(1, &pboId);
|
---|
545 | }
|
---|
546 | }
|
---|
547 | }
|
---|
548 |
|
---|
549 | #ifdef CR_CHECK_BLITS
|
---|
550 | void crDbgFree(void *pvData)
|
---|
551 | {
|
---|
552 | crFree(pvData);
|
---|
553 | }
|
---|
554 |
|
---|
555 | void crDbgGetTexImage2D(GLint texTarget, GLint texName, GLvoid **ppvImage, GLint *pw, GLint *ph)
|
---|
556 | {
|
---|
557 | SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
|
---|
558 | GLint ppb, pub, dstw, dsth, otex;
|
---|
559 | GLint pa, pr, psp, psr, ua, ur, usp, usr;
|
---|
560 | GLvoid *pvImage;
|
---|
561 | GLint rfb, dfb, rb, db;
|
---|
562 |
|
---|
563 | gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
564 | gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
565 | gl->GetIntegerv(GL_READ_BUFFER, &rb);
|
---|
566 | gl->GetIntegerv(GL_DRAW_BUFFER, &db);
|
---|
567 |
|
---|
568 | gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, 0);
|
---|
569 | gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, 0);
|
---|
570 | gl->ReadBuffer(GL_BACK);
|
---|
571 | gl->DrawBuffer(GL_BACK);
|
---|
572 |
|
---|
573 | gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
|
---|
574 | gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
|
---|
575 | gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
|
---|
576 |
|
---|
577 | gl->GetIntegerv(GL_PACK_ROW_LENGTH, &pr);
|
---|
578 | gl->GetIntegerv(GL_PACK_ALIGNMENT, &pa);
|
---|
579 | gl->GetIntegerv(GL_PACK_SKIP_PIXELS, &psp);
|
---|
580 | gl->GetIntegerv(GL_PACK_SKIP_ROWS, &psr);
|
---|
581 |
|
---|
582 | gl->GetIntegerv(GL_UNPACK_ROW_LENGTH, &ur);
|
---|
583 | gl->GetIntegerv(GL_UNPACK_ALIGNMENT, &ua);
|
---|
584 | gl->GetIntegerv(GL_UNPACK_SKIP_PIXELS, &usp);
|
---|
585 | gl->GetIntegerv(GL_UNPACK_SKIP_ROWS, &usr);
|
---|
586 |
|
---|
587 | gl->BindTexture(texTarget, texName);
|
---|
588 | gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_WIDTH, &dstw);
|
---|
589 | gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_HEIGHT, &dsth);
|
---|
590 |
|
---|
591 | gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
|
---|
592 | gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
|
---|
593 | gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
---|
594 | gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
|
---|
595 |
|
---|
596 | gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
---|
597 | gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
---|
598 | gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
---|
599 | gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
---|
600 |
|
---|
601 | gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, 0);
|
---|
602 | gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
|
---|
603 |
|
---|
604 | pvImage = crAlloc(4*dstw*dsth);
|
---|
605 | gl->GetTexImage(texTarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvImage);
|
---|
606 |
|
---|
607 | gl->BindTexture(texTarget, otex);
|
---|
608 |
|
---|
609 | gl->PixelStorei(GL_PACK_ROW_LENGTH, pr);
|
---|
610 | gl->PixelStorei(GL_PACK_ALIGNMENT, pa);
|
---|
611 | gl->PixelStorei(GL_PACK_SKIP_PIXELS, psp);
|
---|
612 | gl->PixelStorei(GL_PACK_SKIP_ROWS, psr);
|
---|
613 |
|
---|
614 | gl->PixelStorei(GL_UNPACK_ROW_LENGTH, ur);
|
---|
615 | gl->PixelStorei(GL_UNPACK_ALIGNMENT, ua);
|
---|
616 | gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, usp);
|
---|
617 | gl->PixelStorei(GL_UNPACK_SKIP_ROWS, usr);
|
---|
618 |
|
---|
619 | gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, ppb);
|
---|
620 | gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, pub);
|
---|
621 |
|
---|
622 | gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, rfb);
|
---|
623 | gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, dfb);
|
---|
624 | gl->ReadBuffer(rb);
|
---|
625 | gl->DrawBuffer(db);
|
---|
626 |
|
---|
627 | *ppvImage = pvImage;
|
---|
628 | *pw = dstw;
|
---|
629 | *ph = dsth;
|
---|
630 | }
|
---|
631 |
|
---|
632 | DECLEXPORT(void) crDbgPrint(const char *format, ... )
|
---|
633 | {
|
---|
634 | va_list args;
|
---|
635 | static char txt[8092];
|
---|
636 |
|
---|
637 | va_start( args, format );
|
---|
638 | vsprintf( txt, format, args );
|
---|
639 |
|
---|
640 | OutputDebugString(txt);
|
---|
641 | }
|
---|
642 |
|
---|
643 | void crDbgDumpImage2D(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch)
|
---|
644 | {
|
---|
645 | crDbgPrint("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">%s</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n",
|
---|
646 | pvData, width, height, bpp, pitch,
|
---|
647 | pszDesc,
|
---|
648 | pvData, width, height, bpp, pitch);
|
---|
649 | }
|
---|
650 |
|
---|
651 | void crDbgDumpTexImage2D(const char* pszDesc, GLint texTarget, GLint texName, GLboolean fBreak)
|
---|
652 | {
|
---|
653 | GLvoid *pvImage;
|
---|
654 | GLint w, h;
|
---|
655 | crDbgGetTexImage2D(texTarget, texName, &pvImage, &w, &h);
|
---|
656 | crDbgPrint("%s target(%d), name(%d), width(%d), height(%d)", pszDesc, texTarget, texName, w, h);
|
---|
657 | crDbgDumpImage2D("texture data", pvImage, w, h, 32, (32 * w)/8);
|
---|
658 | if (fBreak)
|
---|
659 | {
|
---|
660 | CRASSERT(0);
|
---|
661 | }
|
---|
662 | crDbgFree(pvImage);
|
---|
663 | }
|
---|
664 | #endif
|
---|
665 |
|
---|
666 | PCR_BLITTER crServerVBoxBlitterGet()
|
---|
667 | {
|
---|
668 | if (!CrBltIsInitialized(&cr_server.Blitter))
|
---|
669 | {
|
---|
670 | CR_BLITTER_CONTEXT Ctx;
|
---|
671 | int rc;
|
---|
672 | CRASSERT(cr_server.MainContextInfo.SpuContext);
|
---|
673 | Ctx.Base.id = cr_server.MainContextInfo.SpuContext;
|
---|
674 | Ctx.Base.visualBits = cr_server.MainContextInfo.CreateInfo.visualBits;
|
---|
675 | rc = CrBltInit(&cr_server.Blitter, &Ctx, true, true, NULL, &cr_server.head_spu->dispatch_table);
|
---|
676 | if (RT_SUCCESS(rc))
|
---|
677 | {
|
---|
678 | CRASSERT(CrBltIsInitialized(&cr_server.Blitter));
|
---|
679 | }
|
---|
680 | else
|
---|
681 | {
|
---|
682 | crWarning("CrBltInit failed, rc %d", rc);
|
---|
683 | CRASSERT(!CrBltIsInitialized(&cr_server.Blitter));
|
---|
684 | return NULL;
|
---|
685 | }
|
---|
686 | }
|
---|
687 | return &cr_server.Blitter;
|
---|
688 | }
|
---|
689 |
|
---|
690 | int crServerVBoxBlitterTexInit(CRContext *ctx, CRMuralInfo *mural, PVBOXVR_TEXTURE pTex, GLboolean fDraw)
|
---|
691 | {
|
---|
692 | CRTextureObj *tobj;
|
---|
693 | CRFramebufferObjectState *pBuf = &ctx->framebufferobject;
|
---|
694 | GLenum enmBuf;
|
---|
695 | CRFBOAttachmentPoint *pAp;
|
---|
696 | GLuint idx;
|
---|
697 | CRTextureLevel *tl;
|
---|
698 | CRFramebufferObject *pFBO = fDraw ? pBuf->drawFB : pBuf->readFB;
|
---|
699 |
|
---|
700 | if (!pFBO)
|
---|
701 | {
|
---|
702 | GLuint hwid;
|
---|
703 |
|
---|
704 | if (!(mural->fPresentMode & CR_SERVER_REDIR_F_FBO))
|
---|
705 | return VERR_NOT_IMPLEMENTED;
|
---|
706 |
|
---|
707 | enmBuf = fDraw ? ctx->buffer.drawBuffer : ctx->buffer.readBuffer;
|
---|
708 | switch (enmBuf)
|
---|
709 | {
|
---|
710 | case GL_BACK:
|
---|
711 | case GL_BACK_RIGHT:
|
---|
712 | case GL_BACK_LEFT:
|
---|
713 | hwid = mural->aidColorTexs[CR_SERVER_FBO_BB_IDX(mural)];
|
---|
714 | break;
|
---|
715 | case GL_FRONT:
|
---|
716 | case GL_FRONT_RIGHT:
|
---|
717 | case GL_FRONT_LEFT:
|
---|
718 | hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];
|
---|
719 | break;
|
---|
720 | default:
|
---|
721 | crWarning("unsupported enum buf");
|
---|
722 | return VERR_NOT_IMPLEMENTED;
|
---|
723 | break;
|
---|
724 | }
|
---|
725 |
|
---|
726 | if (!hwid)
|
---|
727 | {
|
---|
728 | crWarning("offscreen render tex hwid is null");
|
---|
729 | return VERR_INVALID_STATE;
|
---|
730 | }
|
---|
731 |
|
---|
732 | pTex->width = mural->width;
|
---|
733 | pTex->height = mural->height;
|
---|
734 | pTex->target = GL_TEXTURE_2D;
|
---|
735 | pTex->hwid = hwid;
|
---|
736 | return VINF_SUCCESS;
|
---|
737 | }
|
---|
738 |
|
---|
739 | enmBuf = fDraw ? pFBO->drawbuffer[0] : pFBO->readbuffer;
|
---|
740 | idx = enmBuf - GL_COLOR_ATTACHMENT0_EXT;
|
---|
741 | if (idx >= CR_MAX_COLOR_ATTACHMENTS)
|
---|
742 | {
|
---|
743 | crWarning("idx is invalid %d, using 0", idx);
|
---|
744 | }
|
---|
745 |
|
---|
746 | pAp = &pFBO->color[idx];
|
---|
747 |
|
---|
748 | if (!pAp->name)
|
---|
749 | {
|
---|
750 | crWarning("no collor draw attachment");
|
---|
751 | return VERR_INVALID_STATE;
|
---|
752 | }
|
---|
753 |
|
---|
754 | if (pAp->level)
|
---|
755 | {
|
---|
756 | crWarning("non-zero level not implemented");
|
---|
757 | return VERR_NOT_IMPLEMENTED;
|
---|
758 | }
|
---|
759 |
|
---|
760 | tobj = (CRTextureObj*)crHashtableSearch(ctx->shared->textureTable, pAp->name);
|
---|
761 | if (!tobj)
|
---|
762 | {
|
---|
763 | crWarning("no texture object found for name %d", pAp->name);
|
---|
764 | return VERR_INVALID_STATE;
|
---|
765 | }
|
---|
766 |
|
---|
767 | if (tobj->target != GL_TEXTURE_2D && tobj->target != GL_TEXTURE_RECTANGLE_NV)
|
---|
768 | {
|
---|
769 | crWarning("non-texture[rect|2d] not implemented");
|
---|
770 | return VERR_NOT_IMPLEMENTED;
|
---|
771 | }
|
---|
772 |
|
---|
773 | CRASSERT(tobj->hwid);
|
---|
774 |
|
---|
775 | tl = tobj->level[0];
|
---|
776 | pTex->width = tl->width;
|
---|
777 | pTex->height = tl->height;
|
---|
778 | pTex->target = tobj->target;
|
---|
779 | pTex->hwid = tobj->hwid;
|
---|
780 |
|
---|
781 | return VINF_SUCCESS;
|
---|
782 | }
|
---|
783 |
|
---|
784 | int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
---|
785 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
---|
786 | GLbitfield mask, GLenum filter)
|
---|
787 | {
|
---|
788 | PCR_BLITTER pBlitter;
|
---|
789 | CR_BLITTER_CONTEXT Ctx;
|
---|
790 | CRMuralInfo *mural;
|
---|
791 | CRContext *ctx = crStateGetCurrent();
|
---|
792 | PVBOXVR_TEXTURE pDrawTex, pReadTex;
|
---|
793 | VBOXVR_TEXTURE DrawTex, ReadTex;
|
---|
794 | int rc;
|
---|
795 | GLuint idDrawFBO, idReadFBO;
|
---|
796 | CR_BLITTER_WINDOW BltInfo;
|
---|
797 |
|
---|
798 | if (mask != GL_COLOR_BUFFER_BIT)
|
---|
799 | {
|
---|
800 | crWarning("not supported blit mask %d", mask);
|
---|
801 | return VERR_NOT_IMPLEMENTED;
|
---|
802 | }
|
---|
803 |
|
---|
804 | if (!cr_server.curClient)
|
---|
805 | {
|
---|
806 | crWarning("no current client");
|
---|
807 | return VERR_INVALID_STATE;
|
---|
808 | }
|
---|
809 | mural = cr_server.curClient->currentMural;
|
---|
810 | if (!mural)
|
---|
811 | {
|
---|
812 | crWarning("no current mural");
|
---|
813 | return VERR_INVALID_STATE;
|
---|
814 | }
|
---|
815 |
|
---|
816 | rc = crServerVBoxBlitterTexInit(ctx, mural, &DrawTex, GL_TRUE);
|
---|
817 | if (RT_SUCCESS(rc))
|
---|
818 | {
|
---|
819 | pDrawTex = &DrawTex;
|
---|
820 | }
|
---|
821 | else
|
---|
822 | {
|
---|
823 | crWarning("crServerVBoxBlitterTexInit failed for draw");
|
---|
824 | return rc;
|
---|
825 | }
|
---|
826 |
|
---|
827 | rc = crServerVBoxBlitterTexInit(ctx, mural, &ReadTex, GL_FALSE);
|
---|
828 | if (RT_SUCCESS(rc))
|
---|
829 | {
|
---|
830 | pReadTex = &ReadTex;
|
---|
831 | }
|
---|
832 | else
|
---|
833 | {
|
---|
834 | // crWarning("crServerVBoxBlitterTexInit failed for read");
|
---|
835 | return rc;
|
---|
836 | }
|
---|
837 |
|
---|
838 | pBlitter = crServerVBoxBlitterGet();
|
---|
839 | if (!pBlitter)
|
---|
840 | {
|
---|
841 | crWarning("crServerVBoxBlitterGet failed");
|
---|
842 | return VERR_GENERAL_FAILURE;
|
---|
843 | }
|
---|
844 |
|
---|
845 | crServerVBoxBlitterWinInit(&BltInfo, mural);
|
---|
846 |
|
---|
847 | crServerVBoxBlitterCtxInit(&Ctx, cr_server.curClient->currentCtxInfo);
|
---|
848 |
|
---|
849 | CrBltMuralSetCurrent(pBlitter, &BltInfo);
|
---|
850 |
|
---|
851 | idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
|
---|
852 | idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
|
---|
853 |
|
---|
854 | crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO);
|
---|
855 |
|
---|
856 | rc = CrBltEnter(pBlitter, &Ctx, &BltInfo);
|
---|
857 | if (RT_SUCCESS(rc))
|
---|
858 | {
|
---|
859 | RTRECT ReadRect, DrawRect;
|
---|
860 | ReadRect.xLeft = srcX0;
|
---|
861 | ReadRect.yTop = srcY0;
|
---|
862 | ReadRect.xRight = srcX1;
|
---|
863 | ReadRect.yBottom = srcY1;
|
---|
864 | DrawRect.xLeft = dstX0;
|
---|
865 | DrawRect.yTop = dstY0;
|
---|
866 | DrawRect.xRight = dstX1;
|
---|
867 | DrawRect.yBottom = dstY1;
|
---|
868 | CrBltBlitTexTex(pBlitter, pReadTex, &ReadRect, pDrawTex, &DrawRect, 1, CRBLT_FLAGS_FROM_FILTER(filter));
|
---|
869 | CrBltLeave(pBlitter);
|
---|
870 | }
|
---|
871 | else
|
---|
872 | {
|
---|
873 | crWarning("CrBltEnter failed rc %d", rc);
|
---|
874 | }
|
---|
875 |
|
---|
876 | crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO);
|
---|
877 |
|
---|
878 | return rc;
|
---|
879 | }
|
---|
880 |
|
---|
881 | void SERVER_DISPATCH_APIENTRY
|
---|
882 | crServerDispatchBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
---|
883 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
---|
884 | GLbitfield mask, GLenum filter)
|
---|
885 | {
|
---|
886 | CRContext *ctx = crStateGetCurrent();
|
---|
887 | bool fTryBlitter = false;
|
---|
888 | #ifdef CR_CHECK_BLITS
|
---|
889 | // {
|
---|
890 | SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
|
---|
891 | GLint rfb=0, dfb=0, dtex=0, dlev=-1, rtex=0, rlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
|
---|
892 | GLint sdtex=0, srtex=0;
|
---|
893 | GLenum dStatus, rStatus;
|
---|
894 |
|
---|
895 | CRTextureObj *tobj = 0;
|
---|
896 | CRTextureLevel *tl = 0;
|
---|
897 | GLint id, tuId, pbufId, pbufIdHw, ubufId, ubufIdHw, width, height, depth;
|
---|
898 |
|
---|
899 | crDebug("===StateTracker===");
|
---|
900 | crDebug("Current TU: %i", ctx->texture.curTextureUnit);
|
---|
901 |
|
---|
902 | tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
|
---|
903 | CRASSERT(tobj);
|
---|
904 | tl = &tobj->level[0][0];
|
---|
905 | crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
|
---|
906 |
|
---|
907 | if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
|
---|
908 | {
|
---|
909 | pbufId = ctx->bufferobject.packBuffer->hwid;
|
---|
910 | }
|
---|
911 | else
|
---|
912 | {
|
---|
913 | pbufId = 0;
|
---|
914 | }
|
---|
915 | crDebug("Pack BufferId %i", pbufId);
|
---|
916 |
|
---|
917 | if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
|
---|
918 | {
|
---|
919 | ubufId = ctx->bufferobject.unpackBuffer->hwid;
|
---|
920 | }
|
---|
921 | else
|
---|
922 | {
|
---|
923 | ubufId = 0;
|
---|
924 | }
|
---|
925 | crDebug("Unpack BufferId %i", ubufId);
|
---|
926 |
|
---|
927 | crDebug("===GPU===");
|
---|
928 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &tuId);
|
---|
929 | crDebug("Current TU: %i", tuId - GL_TEXTURE0_ARB);
|
---|
930 | CRASSERT(tuId - GL_TEXTURE0_ARB == ctx->texture.curTextureUnit);
|
---|
931 |
|
---|
932 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
|
---|
933 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
|
---|
934 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
|
---|
935 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &depth);
|
---|
936 | crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
|
---|
937 | CRASSERT(id == tobj->hwid);
|
---|
938 | CRASSERT(width == tl->width);
|
---|
939 | CRASSERT(height == tl->height);
|
---|
940 | CRASSERT(depth == tl->depth);
|
---|
941 |
|
---|
942 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &pbufIdHw);
|
---|
943 | crDebug("Hw Pack BufferId %i", pbufIdHw);
|
---|
944 | CRASSERT(pbufIdHw == pbufId);
|
---|
945 |
|
---|
946 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &ubufIdHw);
|
---|
947 | crDebug("Hw Unpack BufferId %i", ubufIdHw);
|
---|
948 | CRASSERT(ubufIdHw == ubufId);
|
---|
949 |
|
---|
950 | gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
951 | gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
952 | gl->GetIntegerv(GL_READ_BUFFER, &rb);
|
---|
953 | gl->GetIntegerv(GL_DRAW_BUFFER, &db);
|
---|
954 |
|
---|
955 | gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
|
---|
956 | gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
|
---|
957 |
|
---|
958 | gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
|
---|
959 |
|
---|
960 | gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
|
---|
961 |
|
---|
962 | gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
|
---|
963 | gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
|
---|
964 | dStatus = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
|
---|
965 |
|
---|
966 | gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &rtex);
|
---|
967 | gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &rlev);
|
---|
968 | rStatus = gl->CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER_EXT);
|
---|
969 |
|
---|
970 | if (dtex)
|
---|
971 | {
|
---|
972 | CRASSERT(!dlev);
|
---|
973 | }
|
---|
974 |
|
---|
975 | if (rtex)
|
---|
976 | {
|
---|
977 | CRASSERT(!rlev);
|
---|
978 | }
|
---|
979 |
|
---|
980 | if (ctx->framebufferobject.drawFB)
|
---|
981 | {
|
---|
982 | CRASSERT(dfb);
|
---|
983 | CRASSERT(ctx->framebufferobject.drawFB->hwid == dfb);
|
---|
984 | CRASSERT(ctx->framebufferobject.drawFB->drawbuffer[0] == db);
|
---|
985 |
|
---|
986 | CRASSERT(dStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
|
---|
987 | CRASSERT(db==GL_COLOR_ATTACHMENT0_EXT);
|
---|
988 |
|
---|
989 | CRASSERT(ctx->framebufferobject.drawFB->color[0].type == GL_TEXTURE);
|
---|
990 | CRASSERT(ctx->framebufferobject.drawFB->color[0].level == 0);
|
---|
991 | sdtex = ctx->framebufferobject.drawFB->color[0].name;
|
---|
992 | sdtex = crStateGetTextureHWID(sdtex);
|
---|
993 |
|
---|
994 | CRASSERT(sdtex);
|
---|
995 | }
|
---|
996 | else
|
---|
997 | {
|
---|
998 | CRASSERT(!dfb);
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | if (ctx->framebufferobject.readFB)
|
---|
1002 | {
|
---|
1003 | CRASSERT(rfb);
|
---|
1004 | CRASSERT(ctx->framebufferobject.readFB->hwid == rfb);
|
---|
1005 |
|
---|
1006 | CRASSERT(rStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
|
---|
1007 |
|
---|
1008 | CRASSERT(ctx->framebufferobject.readFB->color[0].type == GL_TEXTURE);
|
---|
1009 | CRASSERT(ctx->framebufferobject.readFB->color[0].level == 0);
|
---|
1010 | srtex = ctx->framebufferobject.readFB->color[0].name;
|
---|
1011 | srtex = crStateGetTextureHWID(srtex);
|
---|
1012 |
|
---|
1013 | CRASSERT(srtex);
|
---|
1014 | }
|
---|
1015 | else
|
---|
1016 | {
|
---|
1017 | CRASSERT(!rfb);
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | CRASSERT(sdtex == dtex);
|
---|
1021 | CRASSERT(srtex == rtex);
|
---|
1022 |
|
---|
1023 | // crDbgDumpTexImage2D("==> src tex:", GL_TEXTURE_2D, rtex, true);
|
---|
1024 | // crDbgDumpTexImage2D("==> dst tex:", GL_TEXTURE_2D, dtex, true);
|
---|
1025 |
|
---|
1026 | // }
|
---|
1027 | #endif
|
---|
1028 | #ifdef CR_DUMP_BLITS
|
---|
1029 | SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
|
---|
1030 | GLint rfb=0, dfb=0, dtex=0, dlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
|
---|
1031 | GLenum status;
|
---|
1032 | char fname[200];
|
---|
1033 | void *img;
|
---|
1034 |
|
---|
1035 | blitnum++;
|
---|
1036 |
|
---|
1037 | crDebug("[%i]BlitFramebufferEXT(%i, %i, %i, %i, %i, %i, %i, %i, %x, %x)", blitnum, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
---|
1038 | crDebug("%i, %i <-> %i, %i", srcX1-srcX0, srcY1-srcY0, dstX1-dstX0, dstY1-dstY0);
|
---|
1039 |
|
---|
1040 | gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
1041 | gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
1042 | gl->GetIntegerv(GL_READ_BUFFER, &rb);
|
---|
1043 | gl->GetIntegerv(GL_DRAW_BUFFER, &db);
|
---|
1044 |
|
---|
1045 | gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
|
---|
1046 | gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
|
---|
1047 |
|
---|
1048 | gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
|
---|
1049 |
|
---|
1050 | gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
|
---|
1051 |
|
---|
1052 | CRASSERT(!rfb && dfb);
|
---|
1053 | gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
|
---|
1054 | gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
|
---|
1055 | status = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
|
---|
1056 |
|
---|
1057 | CRASSERT(status==GL_FRAMEBUFFER_COMPLETE_EXT
|
---|
1058 | && db==GL_COLOR_ATTACHMENT0_EXT
|
---|
1059 | && (rb==GL_FRONT || rb==GL_BACK)
|
---|
1060 | && !rfb && dfb && dtex && !dlev
|
---|
1061 | && !ppb && !pub);
|
---|
1062 |
|
---|
1063 | crDebug("Src[rb 0x%x, fbo %i] Dst[db 0x%x, fbo %i(0x%x), tex %i.%i]", rb, rfb, db, dfb, status, dtex, dlev);
|
---|
1064 | crDebug("Viewport [%i, %i, %i, %i]", vp[0], vp[1], vp[2], vp[3]);
|
---|
1065 |
|
---|
1066 | gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
|
---|
1067 | gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
|
---|
1068 | gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
---|
1069 | gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
|
---|
1070 |
|
---|
1071 | gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
---|
1072 | gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
---|
1073 | gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
---|
1074 | gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
---|
1075 |
|
---|
1076 | gl->BindTexture(GL_TEXTURE_2D, dtex);
|
---|
1077 | gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_WIDTH, &dstw);
|
---|
1078 | gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_HEIGHT, &dsth);
|
---|
1079 | gl->BindTexture(GL_TEXTURE_2D, otex);
|
---|
1080 | crDebug("Dst is %i, %i", dstw, dsth);
|
---|
1081 |
|
---|
1082 | CRASSERT(vp[2]>=dstw && vp[3]>=dsth);
|
---|
1083 | img = crAlloc(vp[2]*vp[3]*4);
|
---|
1084 | CRASSERT(img);
|
---|
1085 |
|
---|
1086 | gl->ReadPixels(0, 0, vp[2], vp[3], GL_BGRA, GL_UNSIGNED_BYTE, img);
|
---|
1087 | sprintf(fname, "blit%iA_src.tga", blitnum);
|
---|
1088 | crDumpNamedTGA(fname, vp[2], vp[3], img);
|
---|
1089 |
|
---|
1090 | gl->BindTexture(GL_TEXTURE_2D, dtex);
|
---|
1091 | gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
|
---|
1092 | sprintf(fname, "blit%iB_dst.tga", blitnum);
|
---|
1093 | crDumpNamedTGA(fname, dstw, dsth, img);
|
---|
1094 | gl->BindTexture(GL_TEXTURE_2D, otex);
|
---|
1095 | #endif
|
---|
1096 |
|
---|
1097 | if (srcY0 > srcY1)
|
---|
1098 | {
|
---|
1099 | /* work around Intel driver bug on Linux host */
|
---|
1100 | if (1 || dstY0 > dstY1)
|
---|
1101 | {
|
---|
1102 | /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */
|
---|
1103 | int32_t tmp = srcY0;
|
---|
1104 | srcY0 = srcY1;
|
---|
1105 | srcY1 = tmp;
|
---|
1106 | tmp = dstY0;
|
---|
1107 | dstY0 = dstY1;
|
---|
1108 | dstY1 = tmp;
|
---|
1109 | }
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | if (srcX0 > srcX1)
|
---|
1113 | {
|
---|
1114 | if (dstX0 > dstX1)
|
---|
1115 | {
|
---|
1116 | /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */
|
---|
1117 | int32_t tmp = srcX0;
|
---|
1118 | srcX0 = srcX1;
|
---|
1119 | srcX1 = tmp;
|
---|
1120 | tmp = dstX0;
|
---|
1121 | dstX0 = dstX1;
|
---|
1122 | dstX1 = tmp;
|
---|
1123 | }
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | if (cr_server.fBlitterMode)
|
---|
1127 | {
|
---|
1128 | fTryBlitter = true;
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 | if (fTryBlitter)
|
---|
1132 | {
|
---|
1133 | int rc = crServerVBoxBlitterBlitCurrentCtx(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
---|
1134 | if (RT_SUCCESS(rc))
|
---|
1135 | goto my_exit;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | if (ctx->viewport.scissorTest)
|
---|
1139 | cr_server.head_spu->dispatch_table.Disable(GL_SCISSOR_TEST);
|
---|
1140 |
|
---|
1141 | cr_server.head_spu->dispatch_table.BlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1,
|
---|
1142 | dstX0, dstY0, dstX1, dstY1,
|
---|
1143 | mask, filter);
|
---|
1144 |
|
---|
1145 | if (ctx->viewport.scissorTest)
|
---|
1146 | cr_server.head_spu->dispatch_table.Enable(GL_SCISSOR_TEST);
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | my_exit:
|
---|
1150 |
|
---|
1151 | //#ifdef CR_CHECK_BLITS
|
---|
1152 | // crDbgDumpTexImage2D("<== src tex:", GL_TEXTURE_2D, rtex, true);
|
---|
1153 | // crDbgDumpTexImage2D("<== dst tex:", GL_TEXTURE_2D, dtex, true);
|
---|
1154 | //#endif
|
---|
1155 | #ifdef CR_DUMP_BLITS
|
---|
1156 | gl->BindTexture(GL_TEXTURE_2D, dtex);
|
---|
1157 | gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
|
---|
1158 | sprintf(fname, "blit%iC_res.tga", blitnum);
|
---|
1159 | crDumpNamedTGA(fname, dstw, dsth, img);
|
---|
1160 | gl->BindTexture(GL_TEXTURE_2D, otex);
|
---|
1161 | crFree(img);
|
---|
1162 | #endif
|
---|
1163 | return;
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | void SERVER_DISPATCH_APIENTRY crServerDispatchDrawBuffer( GLenum mode )
|
---|
1167 | {
|
---|
1168 | crStateDrawBuffer( mode );
|
---|
1169 |
|
---|
1170 | if (!crStateGetCurrent()->framebufferobject.drawFB)
|
---|
1171 | {
|
---|
1172 | if (mode == GL_FRONT || mode == GL_FRONT_LEFT || mode == GL_FRONT_RIGHT)
|
---|
1173 | cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
|
---|
1174 |
|
---|
1175 | if (crServerIsRedirectedToFBO()
|
---|
1176 | && cr_server.curClient->currentMural->aidFBOs[0])
|
---|
1177 | {
|
---|
1178 | CRMuralInfo *mural = cr_server.curClient->currentMural;
|
---|
1179 | GLint iBufferNeeded = -1;
|
---|
1180 | switch (mode)
|
---|
1181 | {
|
---|
1182 | case GL_BACK:
|
---|
1183 | case GL_BACK_LEFT:
|
---|
1184 | case GL_BACK_RIGHT:
|
---|
1185 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1186 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1187 | break;
|
---|
1188 | case GL_FRONT:
|
---|
1189 | case GL_FRONT_LEFT:
|
---|
1190 | case GL_FRONT_RIGHT:
|
---|
1191 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1192 | iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
|
---|
1193 | break;
|
---|
1194 | case GL_NONE:
|
---|
1195 | crDebug("DrawBuffer: GL_NONE");
|
---|
1196 | break;
|
---|
1197 | case GL_AUX0:
|
---|
1198 | crDebug("DrawBuffer: GL_AUX0");
|
---|
1199 | break;
|
---|
1200 | case GL_AUX1:
|
---|
1201 | crDebug("DrawBuffer: GL_AUX1");
|
---|
1202 | break;
|
---|
1203 | case GL_AUX2:
|
---|
1204 | crDebug("DrawBuffer: GL_AUX2");
|
---|
1205 | break;
|
---|
1206 | case GL_AUX3:
|
---|
1207 | crDebug("DrawBuffer: GL_AUX3");
|
---|
1208 | break;
|
---|
1209 | case GL_LEFT:
|
---|
1210 | crWarning("DrawBuffer: GL_LEFT not supported properly");
|
---|
1211 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1212 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1213 | break;
|
---|
1214 | case GL_RIGHT:
|
---|
1215 | crWarning("DrawBuffer: GL_RIGHT not supported properly");
|
---|
1216 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1217 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1218 | break;
|
---|
1219 | case GL_FRONT_AND_BACK:
|
---|
1220 | crWarning("DrawBuffer: GL_FRONT_AND_BACK not supported properly");
|
---|
1221 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1222 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1223 | break;
|
---|
1224 | default:
|
---|
1225 | crWarning("DrawBuffer: unexpected mode! 0x%x", mode);
|
---|
1226 | iBufferNeeded = mural->iCurDrawBuffer;
|
---|
1227 | break;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | if (iBufferNeeded != mural->iCurDrawBuffer)
|
---|
1231 | {
|
---|
1232 | mural->iCurDrawBuffer = iBufferNeeded;
|
---|
1233 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
|
---|
1234 | }
|
---|
1235 | }
|
---|
1236 | }
|
---|
1237 |
|
---|
1238 | cr_server.head_spu->dispatch_table.DrawBuffer( mode );
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 | void SERVER_DISPATCH_APIENTRY crServerDispatchReadBuffer( GLenum mode )
|
---|
1242 | {
|
---|
1243 | crStateReadBuffer( mode );
|
---|
1244 |
|
---|
1245 | if (crServerIsRedirectedToFBO()
|
---|
1246 | && cr_server.curClient->currentMural->aidFBOs[0]
|
---|
1247 | && !crStateGetCurrent()->framebufferobject.readFB)
|
---|
1248 | {
|
---|
1249 | CRMuralInfo *mural = cr_server.curClient->currentMural;
|
---|
1250 | GLint iBufferNeeded = -1;
|
---|
1251 | switch (mode)
|
---|
1252 | {
|
---|
1253 | case GL_BACK:
|
---|
1254 | case GL_BACK_LEFT:
|
---|
1255 | case GL_BACK_RIGHT:
|
---|
1256 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1257 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1258 | break;
|
---|
1259 | case GL_FRONT:
|
---|
1260 | case GL_FRONT_LEFT:
|
---|
1261 | case GL_FRONT_RIGHT:
|
---|
1262 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1263 | iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
|
---|
1264 | break;
|
---|
1265 | case GL_NONE:
|
---|
1266 | crDebug("ReadBuffer: GL_NONE");
|
---|
1267 | break;
|
---|
1268 | case GL_AUX0:
|
---|
1269 | crDebug("ReadBuffer: GL_AUX0");
|
---|
1270 | break;
|
---|
1271 | case GL_AUX1:
|
---|
1272 | crDebug("ReadBuffer: GL_AUX1");
|
---|
1273 | break;
|
---|
1274 | case GL_AUX2:
|
---|
1275 | crDebug("ReadBuffer: GL_AUX2");
|
---|
1276 | break;
|
---|
1277 | case GL_AUX3:
|
---|
1278 | crDebug("ReadBuffer: GL_AUX3");
|
---|
1279 | break;
|
---|
1280 | case GL_LEFT:
|
---|
1281 | crWarning("ReadBuffer: GL_LEFT not supported properly");
|
---|
1282 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1283 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1284 | break;
|
---|
1285 | case GL_RIGHT:
|
---|
1286 | crWarning("ReadBuffer: GL_RIGHT not supported properly");
|
---|
1287 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1288 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1289 | break;
|
---|
1290 | case GL_FRONT_AND_BACK:
|
---|
1291 | crWarning("ReadBuffer: GL_FRONT_AND_BACK not supported properly");
|
---|
1292 | mode = GL_COLOR_ATTACHMENT0;
|
---|
1293 | iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
|
---|
1294 | break;
|
---|
1295 | default:
|
---|
1296 | crWarning("ReadBuffer: unexpected mode! 0x%x", mode);
|
---|
1297 | iBufferNeeded = mural->iCurDrawBuffer;
|
---|
1298 | break;
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | Assert(CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
|
---|
1302 | if (iBufferNeeded != mural->iCurReadBuffer)
|
---|
1303 | {
|
---|
1304 | mural->iCurReadBuffer = iBufferNeeded;
|
---|
1305 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
|
---|
1306 | }
|
---|
1307 | }
|
---|
1308 | cr_server.head_spu->dispatch_table.ReadBuffer( mode );
|
---|
1309 | }
|
---|
1310 |
|
---|
1311 | GLenum SERVER_DISPATCH_APIENTRY crServerDispatchGetError( void )
|
---|
1312 | {
|
---|
1313 | GLenum retval, err;
|
---|
1314 | CRContext *ctx = crStateGetCurrent();
|
---|
1315 | retval = ctx->error;
|
---|
1316 |
|
---|
1317 | err = cr_server.head_spu->dispatch_table.GetError();
|
---|
1318 | if (retval == GL_NO_ERROR)
|
---|
1319 | retval = err;
|
---|
1320 | else
|
---|
1321 | ctx->error = GL_NO_ERROR;
|
---|
1322 |
|
---|
1323 | /* our impl has a single error flag, so we just loop here to reset all error flags to no_error */
|
---|
1324 | while (err != GL_NO_ERROR)
|
---|
1325 | err = cr_server.head_spu->dispatch_table.GetError();
|
---|
1326 |
|
---|
1327 | crServerReturnValue( &retval, sizeof(retval) );
|
---|
1328 | return retval; /* WILL PROBABLY BE IGNORED */
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | void SERVER_DISPATCH_APIENTRY
|
---|
1332 | crServerMakeTmpCtxCurrent( GLint window, GLint nativeWindow, GLint context )
|
---|
1333 | {
|
---|
1334 | CRContext *pCtx = crStateGetCurrent();
|
---|
1335 | CRContext *pCurCtx = NULL;
|
---|
1336 | GLuint idDrawFBO = 0, idReadFBO = 0;
|
---|
1337 | int fDoPrePostProcess = 0;
|
---|
1338 |
|
---|
1339 | if (pCtx)
|
---|
1340 | {
|
---|
1341 | GLint curSrvSpuCtx = cr_server.currentCtxInfo && cr_server.currentCtxInfo->SpuContext > 0 ? cr_server.currentCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext;
|
---|
1342 | bool fSwitchToTmpCtx = (curSrvSpuCtx != context);
|
---|
1343 | CRMuralInfo *pCurrentMural = cr_server.currentMural;
|
---|
1344 | CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo;
|
---|
1345 | pCurCtx = pCurCtxInfo ? pCurCtxInfo->pContext : NULL;
|
---|
1346 |
|
---|
1347 | CRASSERT(pCurCtx == pCtx);
|
---|
1348 |
|
---|
1349 | if (pCurrentMural)
|
---|
1350 | {
|
---|
1351 | idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
|
---|
1352 | idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
|
---|
1353 | }
|
---|
1354 | else
|
---|
1355 | {
|
---|
1356 | idDrawFBO = 0;
|
---|
1357 | idReadFBO = 0;
|
---|
1358 | }
|
---|
1359 |
|
---|
1360 | fDoPrePostProcess = fSwitchToTmpCtx ? 1 : -1;
|
---|
1361 | }
|
---|
1362 | else
|
---|
1363 | {
|
---|
1364 | /* this is a GUI thread, so no need to do anything here */
|
---|
1365 | }
|
---|
1366 |
|
---|
1367 | if (fDoPrePostProcess > 0)
|
---|
1368 | crStateSwitchPrepare(NULL, pCurCtx, idDrawFBO, idReadFBO);
|
---|
1369 |
|
---|
1370 | cr_server.head_spu->dispatch_table.MakeCurrent( window, nativeWindow, context);
|
---|
1371 |
|
---|
1372 | if (fDoPrePostProcess < 0)
|
---|
1373 | crStateSwitchPostprocess(pCurCtx, NULL, idDrawFBO, idReadFBO);
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | void crServerInitTmpCtxDispatch()
|
---|
1377 | {
|
---|
1378 | crSPUInitDispatchTable(&cr_server.TmpCtxDispatch);
|
---|
1379 | crSPUCopyDispatchTable(&cr_server.TmpCtxDispatch, &cr_server.head_spu->dispatch_table);
|
---|
1380 | cr_server.TmpCtxDispatch.MakeCurrent = crServerMakeTmpCtxCurrent;
|
---|
1381 | }
|
---|
1382 |
|
---|
1383 | /* dump stuff */
|
---|
1384 | #ifdef VBOX_WITH_CRSERVER_DUMPER
|
---|
1385 |
|
---|
1386 | /* first four bits are buffer dump config
|
---|
1387 | * second four bits are texture dump config
|
---|
1388 | * config flags:
|
---|
1389 | * 1 - blit on enter
|
---|
1390 | * 2 - blit on exit
|
---|
1391 | *
|
---|
1392 | *
|
---|
1393 | * Example:
|
---|
1394 | *
|
---|
1395 | * 0x03 - dump buffer on enter and exit
|
---|
1396 | * 0x22 - dump texture and buffer on exit */
|
---|
1397 |
|
---|
1398 | unsigned long g_CrDbgDumpEnabled = 1;
|
---|
1399 | unsigned long g_CrDbgDumpDraw = CR_SERVER_DUMP_F_COMPILE_SHADER
|
---|
1400 | | CR_SERVER_DUMP_F_LINK_PROGRAM
|
---|
1401 | | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
|
---|
1402 | | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
|
---|
1403 | | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
|
---|
1404 | | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
|
---|
1405 | | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
|
---|
1406 | | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
|
---|
1407 | | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
|
---|
1408 | | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
|
---|
1409 | | CR_SERVER_DUMP_F_DRAWEL
|
---|
1410 | | CR_SERVER_DUMP_F_SHADER_SOURCE
|
---|
1411 | ; //CR_SERVER_DUMP_F_DRAW_BUFF_ENTER | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE;
|
---|
1412 | unsigned long g_CrDbgDumpDrawFramesSettings = CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
|
---|
1413 | | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
|
---|
1414 | | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
|
---|
1415 | | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
|
---|
1416 | | CR_SERVER_DUMP_F_COMPILE_SHADER
|
---|
1417 | | CR_SERVER_DUMP_F_LINK_PROGRAM
|
---|
1418 | | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER;
|
---|
1419 | unsigned long g_CrDbgDumpDrawFramesAppliedSettings = 0;
|
---|
1420 | unsigned long g_CrDbgDumpDrawFramesSavedInitSettings = 0;
|
---|
1421 | unsigned long g_CrDbgDumpDrawFramesCount = 0;
|
---|
1422 |
|
---|
1423 | void crServerDumpCheckTerm()
|
---|
1424 | {
|
---|
1425 | if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
|
---|
1426 | return;
|
---|
1427 |
|
---|
1428 | CrBltTerm(&cr_server.RecorderBlitter);
|
---|
1429 | }
|
---|
1430 |
|
---|
1431 | int crServerDumpCheckInit()
|
---|
1432 | {
|
---|
1433 | int rc;
|
---|
1434 | CR_BLITTER_WINDOW BltWin;
|
---|
1435 | CR_BLITTER_CONTEXT BltCtx;
|
---|
1436 | CRMuralInfo *pBlitterMural;
|
---|
1437 |
|
---|
1438 | if (CrBltIsInitialized(&cr_server.RecorderBlitter))
|
---|
1439 | return VINF_SUCCESS;
|
---|
1440 |
|
---|
1441 | pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
|
---|
1442 | if (!pBlitterMural)
|
---|
1443 | {
|
---|
1444 | crWarning("crServerGetDummyMural failed");
|
---|
1445 | return VERR_GENERAL_FAILURE;
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
|
---|
1449 | crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
|
---|
1450 |
|
---|
1451 | rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, NULL, &cr_server.TmpCtxDispatch);
|
---|
1452 | if (!RT_SUCCESS(rc))
|
---|
1453 | {
|
---|
1454 | crWarning("CrBltInit failed rc %d", rc);
|
---|
1455 | return rc;
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | rc = CrBltMuralSetCurrent(&cr_server.RecorderBlitter, &BltWin);
|
---|
1459 | if (!RT_SUCCESS(rc))
|
---|
1460 | {
|
---|
1461 | crWarning("CrBltMuralSetCurrent failed rc %d", rc);
|
---|
1462 | return rc;
|
---|
1463 | }
|
---|
1464 |
|
---|
1465 | #if 0
|
---|
1466 | crDmpDbgPrintInit(&cr_server.DbgPrintDumper);
|
---|
1467 | cr_server.pDumper = &cr_server.DbgPrintDumper.Base;
|
---|
1468 | #else
|
---|
1469 | crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
|
---|
1470 | cr_server.pDumper = &cr_server.HtmlDumper.Base;
|
---|
1471 | #endif
|
---|
1472 |
|
---|
1473 | crRecInit(&cr_server.Recorder, &cr_server.RecorderBlitter, &cr_server.TmpCtxDispatch, cr_server.pDumper);
|
---|
1474 | return VINF_SUCCESS;
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | void crServerDumpShader(GLint id)
|
---|
1478 | {
|
---|
1479 | CRContext *ctx = crStateGetCurrent();
|
---|
1480 | crRecDumpShader(&cr_server.Recorder, ctx, id, 0);
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 | void crServerDumpProgram(GLint id)
|
---|
1484 | {
|
---|
1485 | CRContext *ctx = crStateGetCurrent();
|
---|
1486 | crRecDumpProgram(&cr_server.Recorder, ctx, id, 0);
|
---|
1487 | }
|
---|
1488 |
|
---|
1489 | void crServerDumpCurrentProgram()
|
---|
1490 | {
|
---|
1491 | CRContext *ctx = crStateGetCurrent();
|
---|
1492 | crRecDumpCurrentProgram(&cr_server.Recorder, ctx);
|
---|
1493 | }
|
---|
1494 |
|
---|
1495 | void crServerDumpRecompileDumpCurrentProgram()
|
---|
1496 | {
|
---|
1497 | crDmpStrF(cr_server.Recorder.pDumper, "==Dump(1)==");
|
---|
1498 | crServerRecompileCurrentProgram();
|
---|
1499 | crServerDumpCurrentProgramUniforms();
|
---|
1500 | crServerDumpCurrentProgramAttribs();
|
---|
1501 | crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(1)");
|
---|
1502 | crServerRecompileCurrentProgram();
|
---|
1503 | crDmpStrF(cr_server.Recorder.pDumper, "Dump(2)");
|
---|
1504 | crServerRecompileCurrentProgram();
|
---|
1505 | crServerDumpCurrentProgramUniforms();
|
---|
1506 | crServerDumpCurrentProgramAttribs();
|
---|
1507 | crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(2)");
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | void crServerRecompileCurrentProgram()
|
---|
1511 | {
|
---|
1512 | CRContext *ctx = crStateGetCurrent();
|
---|
1513 | crRecRecompileCurrentProgram(&cr_server.Recorder, ctx);
|
---|
1514 | }
|
---|
1515 |
|
---|
1516 | void crServerDumpCurrentProgramUniforms()
|
---|
1517 | {
|
---|
1518 | CRContext *ctx = crStateGetCurrent();
|
---|
1519 | crDmpStrF(cr_server.Recorder.pDumper, "==Uniforms==");
|
---|
1520 | crRecDumpCurrentProgramUniforms(&cr_server.Recorder, ctx);
|
---|
1521 | crDmpStrF(cr_server.Recorder.pDumper, "==Done Uniforms==");
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | void crServerDumpCurrentProgramAttribs()
|
---|
1525 | {
|
---|
1526 | CRContext *ctx = crStateGetCurrent();
|
---|
1527 | crDmpStrF(cr_server.Recorder.pDumper, "==Attribs==");
|
---|
1528 | crRecDumpCurrentProgramAttribs(&cr_server.Recorder, ctx);
|
---|
1529 | crDmpStrF(cr_server.Recorder.pDumper, "==Done Attribs==");
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | void crServerDumpState()
|
---|
1533 | {
|
---|
1534 | CRContext *ctx = crStateGetCurrent();
|
---|
1535 | crRecDumpGlGetState(&cr_server.Recorder, ctx);
|
---|
1536 | crRecDumpGlEnableState(&cr_server.Recorder, ctx);
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | void crServerDumpDrawel(const char*pszFormat, ...)
|
---|
1540 | {
|
---|
1541 | CRContext *ctx = crStateGetCurrent();
|
---|
1542 | va_list pArgList;
|
---|
1543 | va_start(pArgList, pszFormat);
|
---|
1544 | crRecDumpVertAttrV(&cr_server.Recorder, ctx, pszFormat, pArgList);
|
---|
1545 | va_end(pArgList);
|
---|
1546 | }
|
---|
1547 |
|
---|
1548 | void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
|
---|
1549 | {
|
---|
1550 | CRContext *ctx = crStateGetCurrent();
|
---|
1551 | crRecDumpVertAttrv(&cr_server.Recorder, ctx, idx, pszElFormat, cbEl, pvVal, cVal);
|
---|
1552 | }
|
---|
1553 |
|
---|
1554 | void crServerDumpBuffer(int idx)
|
---|
1555 | {
|
---|
1556 | CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
|
---|
1557 | CR_BLITTER_WINDOW BltWin;
|
---|
1558 | CR_BLITTER_CONTEXT BltCtx;
|
---|
1559 | CRContext *ctx = crStateGetCurrent();
|
---|
1560 | GLint idFBO;
|
---|
1561 | GLint idTex;
|
---|
1562 | VBOXVR_TEXTURE RedirTex;
|
---|
1563 | int rc = crServerDumpCheckInit();
|
---|
1564 | idx = idx >= 0 ? idx : crServerMuralFBOIdxFromBufferName(cr_server.currentMural, pCtxInfo->pContext->buffer.drawBuffer);
|
---|
1565 | if (!RT_SUCCESS(rc))
|
---|
1566 | {
|
---|
1567 | crWarning("crServerDumpCheckInit failed, rc %d", rc);
|
---|
1568 | return;
|
---|
1569 | }
|
---|
1570 |
|
---|
1571 | if (idx < 0)
|
---|
1572 | {
|
---|
1573 | crWarning("neg idx, unsupported");
|
---|
1574 | return;
|
---|
1575 | }
|
---|
1576 |
|
---|
1577 | idFBO = CR_SERVER_FBO_FOR_IDX(cr_server.currentMural, idx);
|
---|
1578 | idTex = CR_SERVER_FBO_TEX_FOR_IDX(cr_server.currentMural, idx);
|
---|
1579 |
|
---|
1580 | crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
|
---|
1581 | crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
|
---|
1582 |
|
---|
1583 | RedirTex.width = cr_server.currentMural->fboWidth;
|
---|
1584 | RedirTex.height = cr_server.currentMural->fboHeight;
|
---|
1585 | RedirTex.target = GL_TEXTURE_2D;
|
---|
1586 | RedirTex.hwid = idTex;
|
---|
1587 |
|
---|
1588 | crRecDumpBuffer(&cr_server.Recorder, ctx, &BltCtx, &BltWin, idFBO, idTex ? &RedirTex : NULL);
|
---|
1589 | }
|
---|
1590 |
|
---|
1591 | void crServerDumpTextures()
|
---|
1592 | {
|
---|
1593 | CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
|
---|
1594 | CR_BLITTER_WINDOW BltWin;
|
---|
1595 | CR_BLITTER_CONTEXT BltCtx;
|
---|
1596 | CRContext *ctx = crStateGetCurrent();
|
---|
1597 | int rc = crServerDumpCheckInit();
|
---|
1598 | if (!RT_SUCCESS(rc))
|
---|
1599 | {
|
---|
1600 | crWarning("crServerDumpCheckInit failed, rc %d", rc);
|
---|
1601 | return;
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
|
---|
1605 | crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
|
---|
1606 |
|
---|
1607 | crRecDumpTextures(&cr_server.Recorder, ctx, &BltCtx, &BltWin);
|
---|
1608 | }
|
---|
1609 |
|
---|
1610 | bool crServerDumpFilterOp(unsigned long event, CR_DUMPER *pDumper)
|
---|
1611 | {
|
---|
1612 | return CR_SERVER_DUMP_DEFAULT_FILTER_OP(event);
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper)
|
---|
1616 | {
|
---|
1617 | return CR_SERVER_DUMP_DEFAULT_FILTER_DMP(event);
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | void crServerDumpFramesCheck()
|
---|
1621 | {
|
---|
1622 | if (!g_CrDbgDumpDrawFramesCount)
|
---|
1623 | return;
|
---|
1624 |
|
---|
1625 | if (!g_CrDbgDumpDrawFramesAppliedSettings)
|
---|
1626 | {
|
---|
1627 | if (!g_CrDbgDumpDrawFramesSettings)
|
---|
1628 | {
|
---|
1629 | crWarning("g_CrDbgDumpDrawFramesSettings is NULL, bump will not be started");
|
---|
1630 | g_CrDbgDumpDrawFramesCount = 0;
|
---|
1631 | return;
|
---|
1632 | }
|
---|
1633 |
|
---|
1634 | g_CrDbgDumpDrawFramesSavedInitSettings = g_CrDbgDumpDraw;
|
---|
1635 | g_CrDbgDumpDrawFramesAppliedSettings = g_CrDbgDumpDrawFramesSettings;
|
---|
1636 | g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSettings;
|
---|
1637 | crDmpStrF(cr_server.Recorder.pDumper, "***Starting draw dump for %d frames, settings(0x%x)", g_CrDbgDumpDrawFramesCount, g_CrDbgDumpDraw);
|
---|
1638 | return;
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | --g_CrDbgDumpDrawFramesCount;
|
---|
1642 |
|
---|
1643 | if (!g_CrDbgDumpDrawFramesCount)
|
---|
1644 | {
|
---|
1645 | crDmpStrF(cr_server.Recorder.pDumper, "***Stop draw dump");
|
---|
1646 | g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSavedInitSettings;
|
---|
1647 | g_CrDbgDumpDrawFramesAppliedSettings = 0;
|
---|
1648 | }
|
---|
1649 | }
|
---|
1650 | #endif
|
---|
1651 | /* */
|
---|