VirtualBox

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

Last change on this file since 45490 was 44816, checked in by vboxsync, 12 years ago

crOpenGl: more stencil/depth saved state fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.4 KB
Line 
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->idFBO)
258 {
259 diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, data->idFBO);
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 char fname[200];
311 sprintf(fname, "./img_apply_%p_%d_%d.tga", to, i, el->enmFormat);
312 crDumpNamedTGA(fname, el->width, el->height, el->pvData);
313
314 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
315 {
316 diff_api.Enable(GL_DEPTH_TEST);
317 if (to->pixel.depthScale != 1.0f)
318 {
319 diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f);
320 }
321 if (to->pixel.depthBias != 0.0f)
322 {
323 diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f);
324 }
325 }
326 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
327 {
328 diff_api.Enable(GL_STENCIL_TEST);
329 if (to->pixel.mapStencil)
330 {
331 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE);
332 }
333 if (to->pixel.indexOffset)
334 {
335 diff_api.PixelTransferi (GL_INDEX_OFFSET, 0);
336 }
337 if (to->pixel.indexShift)
338 {
339 diff_api.PixelTransferi (GL_INDEX_SHIFT, 0);
340 }
341 }
342
343 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, el->idFBO);
344
345 if (el->enmBuffer)
346 diff_api.DrawBuffer(el->enmBuffer);
347
348 diff_api.WindowPos2iARB(el->posX, el->posY);
349 diff_api.DrawPixels(el->width, el->height, el->enmFormat, el->enmType, el->pvData);
350 crDebug("Applied %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData);
351
352 if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL)
353 {
354 if (to->pixel.depthScale != 1.0f)
355 {
356 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale);
357 }
358 if (to->pixel.depthBias != 0.0f)
359 {
360 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias);
361 }
362 diff_api.Disable(GL_DEPTH_TEST);
363 }
364 if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL)
365 {
366 if (to->pixel.indexOffset)
367 {
368 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset);
369 }
370 if (to->pixel.indexShift)
371 {
372 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift);
373 }
374 if (to->pixel.mapStencil)
375 {
376 diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE);
377 }
378 diff_api.Disable(GL_STENCIL_TEST);
379 }
380 }
381
382 diff_api.WindowPos3fvARB(to->current.rasterAttrib[VERT_ATTRIB_POS]);
383 if (to->bufferobject.unpackBuffer->hwid>0)
384 {
385 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->bufferobject.unpackBuffer->hwid);
386 }
387 if (to->framebufferobject.drawFB)
388 {
389 CRASSERT(to->framebufferobject.drawFB->hwid);
390 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB->hwid);
391 diff_api.DrawBuffer(to->framebufferobject.drawFB->drawbuffer[0]);
392 }
393 else if (data->idFBO)
394 {
395 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, data->idFBO);
396 diff_api.DrawBuffer(GL_COLOR_ATTACHMENT0);
397 }
398 else
399 {
400 diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
401 diff_api.DrawBuffer(to->buffer.drawBuffer);
402 }
403 if (to->buffer.alphaTest)
404 {
405 diff_api.Enable(GL_ALPHA_TEST);
406 }
407 if (to->viewport.scissorTest)
408 {
409 diff_api.Enable(GL_SCISSOR_TEST);
410 }
411 if (to->buffer.blend)
412 {
413 diff_api.Enable(GL_BLEND);
414 }
415 if (to->buffer.logicOp)
416 {
417 diff_api.Enable(GL_COLOR_LOGIC_OP);
418 }
419 if (to->buffer.depthTest)
420 {
421 diff_api.Enable(GL_DEPTH_TEST);
422 }
423 if (to->stencil.stencilTest)
424 {
425 diff_api.Enable(GL_STENCIL_TEST);
426 }
427
428 diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, unpack.skipRows);
429 diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, unpack.skipPixels);
430 diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, unpack.alignment);
431 diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, unpack.rowLength);
432 diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack.imageHeight);
433 diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, unpack.skipImages);
434 diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, unpack.swapBytes);
435 diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, unpack.psLSBFirst);
436
437 diff_api.Finish();
438 }
439}
440
441void crStateSwitchContext( CRContext *from, CRContext *to )
442{
443 CRbitvalue *bitID = to->bitid;
444 CRStateBits *sb = GetCurrentBits();
445
446 if (CHECKDIRTY(sb->attrib.dirty, bitID))
447 {
448 crStateAttribSwitch(&(sb->attrib), bitID, from, to );
449 }
450 if (CHECKDIRTY(sb->transform.dirty, bitID))
451 {
452 crStateTransformSwitch( &(sb->transform), bitID, from, to );
453 }
454 if (CHECKDIRTY(sb->pixel.dirty, bitID))
455 {
456 crStatePixelSwitch(&(sb->pixel), bitID, from, to );
457 }
458 if (CHECKDIRTY(sb->viewport.dirty, bitID))
459 {
460 crStateViewportSwitch(&(sb->viewport), bitID, from, to );
461 }
462 if (CHECKDIRTY(sb->fog.dirty, bitID))
463 {
464 crStateFogSwitch(&(sb->fog), bitID, from, to );
465 }
466 if (CHECKDIRTY(sb->texture.dirty, bitID))
467 {
468 crStateTextureSwitch( &(sb->texture), bitID, from, to );
469 }
470 if (CHECKDIRTY(sb->lists.dirty, bitID))
471 {
472 crStateListsSwitch(&(sb->lists), bitID, from, to );
473 }
474 if (CHECKDIRTY(sb->buffer.dirty, bitID))
475 {
476 crStateBufferSwitch( &(sb->buffer), bitID, from, to );
477 }
478#ifdef CR_ARB_vertex_buffer_object
479 if (CHECKDIRTY(sb->bufferobject.dirty, bitID))
480 {
481 crStateBufferObjectSwitch( &(sb->bufferobject), bitID, from, to );
482 }
483#endif
484 if (CHECKDIRTY(sb->client.dirty, bitID))
485 {
486 crStateClientSwitch( &(sb->client), bitID, from, to );
487 }
488#if 0
489 if (CHECKDIRTY(sb->hint.dirty, bitID))
490 {
491 crStateHintSwitch( &(sb->hint), bitID, from, to );
492 }
493#endif
494 if (CHECKDIRTY(sb->lighting.dirty, bitID))
495 {
496 crStateLightingSwitch( &(sb->lighting), bitID, from, to );
497 }
498 if (CHECKDIRTY(sb->occlusion.dirty, bitID))
499 {
500 crStateOcclusionSwitch( &(sb->occlusion), bitID, from, to );
501 }
502 if (CHECKDIRTY(sb->line.dirty, bitID))
503 {
504 crStateLineSwitch( &(sb->line), bitID, from, to );
505 }
506 if (CHECKDIRTY(sb->point.dirty, bitID))
507 {
508 crStatePointSwitch( &(sb->point), bitID, from, to );
509 }
510 if (CHECKDIRTY(sb->polygon.dirty, bitID))
511 {
512 crStatePolygonSwitch( &(sb->polygon), bitID, from, to );
513 }
514 if (CHECKDIRTY(sb->program.dirty, bitID))
515 {
516 crStateProgramSwitch( &(sb->program), bitID, from, to );
517 }
518 if (CHECKDIRTY(sb->stencil.dirty, bitID))
519 {
520 crStateStencilSwitch( &(sb->stencil), bitID, from, to );
521 }
522 if (CHECKDIRTY(sb->eval.dirty, bitID))
523 {
524 crStateEvaluatorSwitch( &(sb->eval), bitID, from, to );
525 }
526#ifdef CR_ARB_imaging
527 if (CHECKDIRTY(sb->imaging.dirty, bitID))
528 {
529 crStateImagingSwitch( &(sb->imaging), bitID, from, to );
530 }
531#endif
532#if 0
533 if (CHECKDIRTY(sb->selection.dirty, bitID))
534 {
535 crStateSelectionSwitch( &(sb->selection), bitID, from, to );
536 }
537#endif
538#ifdef CR_NV_register_combiners
539 if (CHECKDIRTY(sb->regcombiner.dirty, bitID) && to->extensions.NV_register_combiners)
540 {
541 crStateRegCombinerSwitch( &(sb->regcombiner), bitID, from, to );
542 }
543#endif
544#ifdef CR_ARB_multisample
545 if (CHECKDIRTY(sb->multisample.dirty, bitID))
546 {
547 crStateMultisampleSwitch( &(sb->multisample), bitID, from, to );
548 }
549#endif
550#ifdef CR_ARB_multisample
551 if (CHECKDIRTY(sb->multisample.dirty, bitID))
552 {
553 crStateMultisampleSwitch(&(sb->multisample), bitID, from, to );
554 }
555#endif
556#ifdef CR_EXT_framebuffer_object
557 /*Note, this should go after crStateTextureSwitch*/
558 crStateFramebufferObjectSwitch(from, to);
559#endif
560#ifdef CR_OPENGL_VERSION_2_0
561 crStateGLSLSwitch(from, to);
562#endif
563 if (CHECKDIRTY(sb->current.dirty, bitID))
564 {
565 crStateCurrentSwitch( &(sb->current), bitID, from, to );
566 }
567
568#ifdef WINDOWS
569 if (to->buffer.pFrontImg)
570 {
571 CRFBData *pLazyData = (CRFBData *)to->buffer.pFrontImg;
572 crStateApplyFBImage(to, pLazyData);
573 crStateFreeFBImageLegacy(to);
574 }
575#endif
576}
577
578void crStateSyncHWErrorState(CRContext *ctx)
579{
580 GLenum err;
581 while ((err = diff_api.GetError()) != GL_NO_ERROR)
582 {
583 if (ctx->error != GL_NO_ERROR)
584 ctx->error = err;
585 }
586}
587
588void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
589{
590 if (!fromCtx)
591 return;
592
593 if (g_bVBoxEnableDiffOnMakeCurrent && toCtx && toCtx != fromCtx)
594 crStateSyncHWErrorState(fromCtx);
595
596#ifdef CR_EXT_framebuffer_object
597 crStateFramebufferObjectDisableHW(fromCtx, idDrawFBO, idReadFBO);
598#endif
599}
600
601void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO)
602{
603 if (!toCtx)
604 return;
605
606 if (g_bVBoxEnableDiffOnMakeCurrent && fromCtx && toCtx != fromCtx)
607 {
608 GLenum err;
609 while ((err = diff_api.GetError()) != GL_NO_ERROR)
610 {
611 crWarning("gl error (0x%x) after context switch, ignoring..", err);
612 }
613 }
614#ifdef CR_EXT_framebuffer_object
615 crStateFramebufferObjectReenableHW(fromCtx, toCtx, idDrawFBO, idReadFBO);
616#endif
617}
Note: See TracBrowser for help on using the repository browser.

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