VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c@ 50213

最後變更 在這個檔案從50213是 46173,由 vboxsync 提交於 12 年 前

crOpenGL: proper support for GL_NONE,AUX,etc. for offscreen rendering

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 18.6 KB
 
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 "state.h"
8#include "cr_error.h"
9#include "cr_mem.h"
10#include "cr_pixeldata.h"
11#include <iprt/err.h>
12#include <stdio.h>
13
14void crStateDiffContext( CRContext *from, CRContext *to )
15{
16 CRbitvalue *bitID = from->bitid;
17 CRStateBits *sb = GetCurrentBits();
18
19 /*crDebug( "Diffing two contexts!" ); */
20
21 if (CHECKDIRTY(sb->transform.dirty, bitID))
22 {
23 crStateTransformDiff( &(sb->transform), bitID, from, to );
24 }
25 if (CHECKDIRTY(sb->pixel.dirty, bitID))
26 {
27 crStatePixelDiff( &(sb->pixel), bitID, from, to );
28 }
29 if (CHECKDIRTY(sb->viewport.dirty, bitID))
30 {
31 crStateViewportDiff( &(sb->viewport), bitID, from, to );
32 }
33 if (CHECKDIRTY(sb->fog.dirty, bitID))
34 {
35 crStateFogDiff( &(sb->fog), bitID, from, to );
36 }
37 if (CHECKDIRTY(sb->texture.dirty, bitID))
38 {
39 crStateTextureDiff( &(sb->texture), bitID, from, to );
40 }
41 if (CHECKDIRTY(sb->lists.dirty, bitID))
42 {
43 crStateListsDiff( &(sb->lists), bitID, from, to );
44 }
45 if (CHECKDIRTY(sb->buffer.dirty, bitID))
46 {
47 crStateBufferDiff( &(sb->buffer), bitID, from, to );
48 }
49#ifdef CR_ARB_vertex_buffer_object
50 if (CHECKDIRTY(sb->bufferobject.dirty, bitID))
51 {
52 crStateBufferObjectDiff( &(sb->bufferobject), bitID, from, to );
53 }
54#endif
55 if (CHECKDIRTY(sb->client.dirty, bitID))
56 {
57 crStateClientDiff(&(sb->client), bitID, from, to );
58 }
59 if (CHECKDIRTY(sb->hint.dirty, bitID))
60 {
61 crStateHintDiff( &(sb->hint), bitID, from, to );
62 }
63 if (CHECKDIRTY(sb->lighting.dirty, bitID))
64 {
65 crStateLightingDiff( &(sb->lighting), bitID, from, to );
66 }
67 if (CHECKDIRTY(sb->line.dirty, bitID))
68 {
69 crStateLineDiff( &(sb->line), bitID, from, to );
70 }
71 if (CHECKDIRTY(sb->occlusion.dirty, bitID))
72 {
73 crStateOcclusionDiff( &(sb->occlusion), bitID, from, to );
74 }
75 if (CHECKDIRTY(sb->point.dirty, bitID))
76 {
77 crStatePointDiff( &(sb->point), bitID, from, to );
78 }
79 if (CHECKDIRTY(sb->polygon.dirty, bitID))
80 {
81 crStatePolygonDiff( &(sb->polygon), bitID, from, to );
82 }
83 if (CHECKDIRTY(sb->program.dirty, bitID))
84 {
85 crStateProgramDiff( &(sb->program), bitID, from, to );
86 }
87 if (CHECKDIRTY(sb->stencil.dirty, bitID))
88 {
89 crStateStencilDiff( &(sb->stencil), bitID, from, to );
90 }
91 if (CHECKDIRTY(sb->eval.dirty, bitID))
92 {
93 crStateEvaluatorDiff( &(sb->eval), bitID, from, to );
94 }
95#ifdef CR_ARB_imaging
96 if (CHECKDIRTY(sb->imaging.dirty, bitID))
97 {
98 crStateImagingDiff( &(sb->imaging), bitID, from, to );
99 }
100#endif
101#if 0
102 if (CHECKDIRTY(sb->selection.dirty, bitID))
103 {
104 crStateSelectionDiff( &(sb->selection), bitID, from, to );
105 }
106#endif
107#ifdef CR_NV_register_combiners
108 if (CHECKDIRTY(sb->regcombiner.dirty, bitID) && to->extensions.NV_register_combiners)
109 {
110 crStateRegCombinerDiff( &(sb->regcombiner), bitID, from, to );
111 }
112#endif
113#ifdef CR_ARB_multisample
114 if (CHECKDIRTY(sb->multisample.dirty, bitID) &&
115 from->extensions.ARB_multisample)
116 {
117 crStateMultisampleDiff( &(sb->multisample), bitID, from, to );
118 }
119#endif
120 if (CHECKDIRTY(sb->current.dirty, bitID))
121 {
122 crStateCurrentDiff( &(sb->current), bitID, from, to );
123 }
124}
125
126void crStateFreeFBImageLegacy(CRContext *to)
127{
128 if (to->buffer.pFrontImg)
129 {
130 crFree(to->buffer.pFrontImg);
131 to->buffer.pFrontImg = NULL;
132 }
133 if (to->buffer.pBackImg)
134 {
135 crFree(to->buffer.pBackImg);
136 to->buffer.pBackImg = NULL;
137 }
138
139 to->buffer.storedWidth = 0;
140 to->buffer.storedHeight = 0;
141}
142
143int crStateAcquireFBImage(CRContext *to, CRFBData *data)
144{
145 CRBufferState *pBuf = &to->buffer;
146 CRPixelPackState packing = to->client.pack;
147 uint32_t i;
148
149 diff_api.PixelStorei(GL_PACK_SKIP_ROWS, 0);
150 diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, 0);
151 diff_api.PixelStorei(GL_PACK_ALIGNMENT, 1);
152 diff_api.PixelStorei(GL_PACK_ROW_LENGTH, 0);
153 diff_api.PixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
154 diff_api.PixelStorei(GL_PACK_SKIP_IMAGES, 0);
155 diff_api.PixelStorei(GL_PACK_SWAP_BYTES, 0);
156 diff_api.PixelStorei(GL_PACK_LSB_FIRST, 0);
157
158 if (to->bufferobject.packBuffer->hwid>0)
159 {
160 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
161 }
162
163 for (i = 0; i < data->cElements; ++i)
164 {
165 CRFBDataElement *el = &data->aElements[i];
166
167 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
168 {
169 if (!to->buffer.depthTest)
170 {
171 diff_api.Enable(GL_DEPTH_TEST);
172 }
173 if (to->pixel.depthScale != 1.0f)
174 {
175 diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
176 }
177 if (to->pixel.depthBias != 0.0f)
178 {
179 diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
180 }
181 }
182 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
183 {
184 if (!to->stencil.stencilTest)
185 {
186 diff_api.Enable(GL_STENCIL_TEST);
187 }
188 if (to->pixel.mapStencil)
189 {
190 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
191 }
192 if (to->pixel.indexOffset)
193 {
194 diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
195 }
196 if (to->pixel.indexShift)
197 {
198 diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
199 }
200 }
201
202 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, el->idFBO);
203
204 if (el->enmBuffer)
205 diff_api.ReadBuffer(el->enmBuffer);
206
207 diff_api.ReadPixels(el->posX, el->posY, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
208 crDebug("Acquired %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
209
210 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
211 {
212 if (to->pixel.depthScale != 1.0f)
213 {
214 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
215 }
216 if (to->pixel.depthBias != 0.0f)
217 {
218 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
219 }
220 if (!to->buffer.depthTest)
221 {
222 diff_api.Disable(GL_DEPTH_TEST);
223 }
224 }
225 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
226 {
227 if (to->pixel.indexOffset)
228 {
229 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
230 }
231 if (to->pixel.indexShift)
232 {
233 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
234 }
235 if (to->pixel.mapStencil)
236 {
237 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
238 }
239 if (!to->stencil.stencilTest)
240 {
241 diff_api.Disable(GL_STENCIL_TEST);
242 }
243 }
244 }
245
246 if (to->bufferobject.packBuffer->hwid>0)
247 {
248 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->bufferobject.packBuffer->hwid);
249 }
250 if (to->framebufferobject.readFB)
251 {
252 CRASSERT(to->framebufferobject.readFB->hwid);
253 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, to->framebufferobject.readFB->hwid);
254 diff_api.ReadBuffer(to->framebufferobject.readFB->readbuffer);
255
256 }
257 else if (data->idOverrrideFBO)
258 {
259 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, data->idOverrrideFBO);
260 diff_api.ReadBuffer(GL_COLOR_ATTACHMENT0);
261 }
262 else
263 {
264 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0);
265 diff_api.ReadBuffer(to->buffer.readBuffer);
266 }
267
268 diff_api.PixelStorei(GL_PACK_SKIP_ROWS, packing.skipRows);
269 diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, packing.skipPixels);
270 diff_api.PixelStorei(GL_PACK_ALIGNMENT, packing.alignment);
271 diff_api.PixelStorei(GL_PACK_ROW_LENGTH, packing.rowLength);
272 diff_api.PixelStorei(GL_PACK_IMAGE_HEIGHT, packing.imageHeight);
273 diff_api.PixelStorei(GL_PACK_SKIP_IMAGES, packing.skipImages);
274 diff_api.PixelStorei(GL_PACK_SWAP_BYTES, packing.swapBytes);
275 diff_api.PixelStorei(GL_PACK_LSB_FIRST, packing.psLSBFirst);
276 return VINF_SUCCESS;
277}
278
279void crStateApplyFBImage(CRContext *to, CRFBData *data)
280{
281 {
282 CRBufferState *pBuf = &to->buffer;
283 CRPixelPackState unpack = to->client.unpack;
284 uint32_t i;
285
286 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
287 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
288 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
289 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
290 diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
291 diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
292 diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, 0);
293 diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, 0);
294
295 if (to->bufferobject.unpackBuffer->hwid>0)
296 {
297 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
298 }
299
300 diff_api.Disable(GL_ALPHA_TEST);
301 diff_api.Disable(GL_SCISSOR_TEST);
302 diff_api.Disable(GL_BLEND);
303 diff_api.Disable(GL_COLOR_LOGIC_OP);
304 diff_api.Disable(GL_DEPTH_TEST);
305 diff_api.Disable(GL_STENCIL_TEST);
306
307 for (i = 0; i < data->cElements; ++i)
308 {
309 CRFBDataElement *el = &data->aElements[i];
310#if 0
311 char fname[200];
312 sprintf(fname, "./img_apply_%p_%d_%d.tga", to, i, el->enmFormat);
313 crDumpNamedTGA(fname, el->width, el->height, el->pvData);
314#endif
315
316 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
317 {
318 diff_api.Enable(GL_DEPTH_TEST);
319 if (to->pixel.depthScale != 1.0f)
320 {
321 diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
322 }
323 if (to->pixel.depthBias != 0.0f)
324 {
325 diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
326 }
327 }
328 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
329 {
330 diff_api.Enable(GL_STENCIL_TEST);
331 if (to->pixel.mapStencil)
332 {
333 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
334 }
335 if (to->pixel.indexOffset)
336 {
337 diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
338 }
339 if (to->pixel.indexShift)
340 {
341 diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
342 }
343 }
344
345 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, el->idFBO);
346
347 if (el->enmBuffer)
348 diff_api.DrawBuffer(el->enmBuffer);
349
350 diff_api.WindowPos2iARB(el->posX, el->posY);
351 diff_api.DrawPixels(el->width, el->height, el->enmFormat, el->enmType, el->pvData);
352 crDebug("Applied %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
353
354 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
355 {
356 if (to->pixel.depthScale != 1.0f)
357 {
358 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
359 }
360 if (to->pixel.depthBias != 0.0f)
361 {
362 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
363 }
364 diff_api.Disable(GL_DEPTH_TEST);
365 }
366 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
367 {
368 if (to->pixel.indexOffset)
369 {
370 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
371 }
372 if (to->pixel.indexShift)
373 {
374 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
375 }
376 if (to->pixel.mapStencil)
377 {
378 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
379 }
380 diff_api.Disable(GL_STENCIL_TEST);
381 }
382 }
383
384 diff_api.WindowPos3fvARB(to->current.rasterAttrib[VERT_ATTRIB_POS]);
385 if (to->bufferobject.unpackBuffer->hwid>0)
386 {
387 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->bufferobject.unpackBuffer->hwid);
388 }
389 if (to->framebufferobject.drawFB)
390 {
391 CRASSERT(to->framebufferobject.drawFB->hwid);
392 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB->hwid);
393 diff_api.DrawBuffer(to->framebufferobject.drawFB->drawbuffer[0]);
394 }
395 else if (data->idOverrrideFBO)
396 {
397 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, data->idOverrrideFBO);
398 diff_api.DrawBuffer(GL_COLOR_ATTACHMENT0);
399 }
400 else
401 {
402 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
403 diff_api.DrawBuffer(to->buffer.drawBuffer);
404 }
405 if (to->buffer.alphaTest)
406 {
407 diff_api.Enable(GL_ALPHA_TEST);
408 }
409 if (to->viewport.scissorTest)
410 {
411 diff_api.Enable(GL_SCISSOR_TEST);
412 }
413 if (to->buffer.blend)
414 {
415 diff_api.Enable(GL_BLEND);
416 }
417 if (to->buffer.logicOp)
418 {
419 diff_api.Enable(GL_COLOR_LOGIC_OP);
420 }
421 if (to->buffer.depthTest)
422 {
423 diff_api.Enable(GL_DEPTH_TEST);
424 }
425 if (to->stencil.stencilTest)
426 {
427 diff_api.Enable(GL_STENCIL_TEST);
428 }
429
430 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, unpack.skipRows);
431 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, unpack.skipPixels);
432 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, unpack.alignment);
433 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, unpack.rowLength);
434 diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack.imageHeight);
435 diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, unpack.skipImages);
436 diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, unpack.swapBytes);
437 diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, unpack.psLSBFirst);
438
439 diff_api.Finish();
440 }
441}
442
443void crStateSwitchContext( CRContext *from, CRContext *to )
444{
445 CRbitvalue *bitID = to->bitid;
446 CRStateBits *sb = GetCurrentBits();
447
448 if (CHECKDIRTY(sb->attrib.dirty, bitID))
449 {
450 crStateAttribSwitch(&(sb->attrib), bitID, from, to );
451 }
452 if (CHECKDIRTY(sb->transform.dirty, bitID))
453 {
454 crStateTransformSwitch( &(sb->transform), bitID, from, to );
455 }
456 if (CHECKDIRTY(sb->pixel.dirty, bitID))
457 {
458 crStatePixelSwitch(&(sb->pixel), bitID, from, to );
459 }
460 if (CHECKDIRTY(sb->viewport.dirty, bitID))
461 {
462 crStateViewportSwitch(&(sb->viewport), bitID, from, to );
463 }
464 if (CHECKDIRTY(sb->fog.dirty, bitID))
465 {
466 crStateFogSwitch(&(sb->fog), bitID, from, to );
467 }
468 if (CHECKDIRTY(sb->texture.dirty, bitID))
469 {
470 crStateTextureSwitch( &(sb->texture), bitID, from, to );
471 }
472 if (CHECKDIRTY(sb->lists.dirty, bitID))
473 {
474 crStateListsSwitch(&(sb->lists), bitID, from, to );
475 }
476 if (CHECKDIRTY(sb->buffer.dirty, bitID))
477 {
478 crStateBufferSwitch( &(sb->buffer), bitID, from, to );
479 }
480#ifdef CR_ARB_vertex_buffer_object
481 if (CHECKDIRTY(sb->bufferobject.dirty, bitID))
482 {
483 crStateBufferObjectSwitch( &(sb->bufferobject), bitID, from, to );
484 }
485#endif
486 if (CHECKDIRTY(sb->client.dirty, bitID))
487 {
488 crStateClientSwitch( &(sb->client), bitID, from, to );
489 }
490#if 0
491 if (CHECKDIRTY(sb->hint.dirty, bitID))
492 {
493 crStateHintSwitch( &(sb->hint), bitID, from, to );
494 }
495#endif
496 if (CHECKDIRTY(sb->lighting.dirty, bitID))
497 {
498 crStateLightingSwitch( &(sb->lighting), bitID, from, to );
499 }
500 if (CHECKDIRTY(sb->occlusion.dirty, bitID))
501 {
502 crStateOcclusionSwitch( &(sb->occlusion), bitID, from, to );
503 }
504 if (CHECKDIRTY(sb->line.dirty, bitID))
505 {
506 crStateLineSwitch( &(sb->line), bitID, from, to );
507 }
508 if (CHECKDIRTY(sb->point.dirty, bitID))
509 {
510 crStatePointSwitch( &(sb->point), bitID, from, to );
511 }
512 if (CHECKDIRTY(sb->polygon.dirty, bitID))
513 {
514 crStatePolygonSwitch( &(sb->polygon), bitID, from, to );
515 }
516 if (CHECKDIRTY(sb->program.dirty, bitID))
517 {
518 crStateProgramSwitch( &(sb->program), bitID, from, to );
519 }
520 if (CHECKDIRTY(sb->stencil.dirty, bitID))
521 {
522 crStateStencilSwitch( &(sb->stencil), bitID, from, to );
523 }
524 if (CHECKDIRTY(sb->eval.dirty, bitID))
525 {
526 crStateEvaluatorSwitch( &(sb->eval), bitID, from, to );
527 }
528#ifdef CR_ARB_imaging
529 if (CHECKDIRTY(sb->imaging.dirty, bitID))
530 {
531 crStateImagingSwitch( &(sb->imaging), bitID, from, to );
532 }
533#endif
534#if 0
535 if (CHECKDIRTY(sb->selection.dirty, bitID))
536 {
537 crStateSelectionSwitch( &(sb->selection), bitID, from, to );
538 }
539#endif
540#ifdef CR_NV_register_combiners
541 if (CHECKDIRTY(sb->regcombiner.dirty, bitID) && to->extensions.NV_register_combiners)
542 {
543 crStateRegCombinerSwitch( &(sb->regcombiner), bitID, from, to );
544 }
545#endif
546#ifdef CR_ARB_multisample
547 if (CHECKDIRTY(sb->multisample.dirty, bitID))
548 {
549 crStateMultisampleSwitch( &(sb->multisample), bitID, from, to );
550 }
551#endif
552#ifdef CR_ARB_multisample
553 if (CHECKDIRTY(sb->multisample.dirty, bitID))
554 {
555 crStateMultisampleSwitch(&(sb->multisample), bitID, from, to );
556 }
557#endif
558#ifdef CR_EXT_framebuffer_object
559 /*Note, this should go after crStateTextureSwitch*/
560 crStateFramebufferObjectSwitch(from, to);
561#endif
562#ifdef CR_OPENGL_VERSION_2_0
563 crStateGLSLSwitch(from, to);
564#endif
565 if (CHECKDIRTY(sb->current.dirty, bitID))
566 {
567 crStateCurrentSwitch( &(sb->current), bitID, from, to );
568 }
569
570#ifdef WINDOWS
571 if (to->buffer.pFrontImg)
572 {
573 CRFBData *pLazyData = (CRFBData *)to->buffer.pFrontImg;
574 crStateApplyFBImage(to, pLazyData);
575 crStateFreeFBImageLegacy(to);
576 }
577#endif
578}
579
580void crStateSyncHWErrorState(CRContext *ctx)
581{
582 GLenum err;
583 while ((err = diff_api.GetError()) != GL_NO_ERROR)
584 {
585 if (ctx->error != GL_NO_ERROR)
586 ctx->error = err;
587 }
588}
589
590void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
591{
592 if (!fromCtx)
593 return;
594
595 if (g_bVBoxEnableDiffOnMakeCurrent && toCtx && toCtx != fromCtx)
596 crStateSyncHWErrorState(fromCtx);
597
598#ifdef CR_EXT_framebuffer_object
599 crStateFramebufferObjectDisableHW(fromCtx, idDrawFBO, idReadFBO);
600#endif
601}
602
603void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
604{
605 if (!toCtx)
606 return;
607
608 if (g_bVBoxEnableDiffOnMakeCurrent && fromCtx && toCtx != fromCtx)
609 {
610 GLenum err;
611 while ((err = diff_api.GetError()) != GL_NO_ERROR)
612 {
613 static int cErrPrints = 0;
614#ifndef DEBUG_misha
615 if (cErrPrints < 5)
616#endif
617 {
618 ++cErrPrints;
619 crWarning("gl error (0x%x) after context switch, ignoring.. (%d out of 5) ..", err, cErrPrints);
620 }
621 }
622 }
623#ifdef CR_EXT_framebuffer_object
624 crStateFramebufferObjectReenableHW(fromCtx, toCtx, idDrawFBO, idReadFBO);
625#endif
626}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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