Changeset 44053 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Dec 6, 2012 3:21:37 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82526
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c
r43980 r44053 23 23 #include "cr_mem.h" 24 24 25 #define CRSTATE_FBO_CHECKERR (expr, result, message) \25 #define CRSTATE_FBO_CHECKERR_RET(expr, result, message, ret) \ 26 26 if (expr) { \ 27 27 crStateError(__LINE__, __FILE__, result, message); \ 28 return; \ 29 } 30 28 return ret; \ 29 } 30 31 #define CRSTATE_NO_RETURN 32 33 #define CRSTATE_FBO_CHECKERR(expr, result, message) CRSTATE_FBO_CHECKERR_RET(expr, result, message, CRSTATE_NO_RETURN) 34 31 35 DECLEXPORT(void) STATE_APIENTRY 32 36 crStateFramebufferObjectInit(CRContext *ctx) … … 381 385 } 382 386 383 static void crStateFramebufferTextureCheck(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, 384 GLboolean *failed, CRFBOAttachmentPoint **ap, CRTextureObj **tobj) 385 { 386 CRContext *g = GetCurrentContext(); 387 CRFramebufferObjectState *fbo = &g->framebufferobject; 388 CRFramebufferObject *pFBO; 387 static GLuint crStateFramebufferTextureCheck(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, 388 CRFBOAttachmentPoint **aap, CRTextureObj **tobj) 389 { 390 CRContext *g = GetCurrentContext(); 391 CRFramebufferObjectState *fbo = &g->framebufferobject; 392 CRFramebufferObject *apFBOs[2]; 393 GLuint cPBOs = 0, i; 389 394 GLuint maxtexsizelog2; 390 395 391 *failed = GL_TRUE; 392 393 CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); 394 CRSTATE_FBO_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), 395 GL_INVALID_ENUM, "invalid target"); 396 pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB; 397 CRSTATE_FBO_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound"); 398 CRSTATE_FBO_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, ap), GL_INVALID_ENUM, "invalid attachment"); 396 397 CRSTATE_FBO_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0); 398 CRSTATE_FBO_CHECKERR_RET(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), 399 GL_INVALID_ENUM, "invalid target", 0); 400 switch (target) 401 { 402 case GL_READ_FRAMEBUFFER: 403 cPBOs = 1; 404 apFBOs[0] = fbo->readFB; 405 break; 406 case GL_DRAW_FRAMEBUFFER: 407 cPBOs = 1; 408 apFBOs[0] = fbo->drawFB; 409 break; 410 case GL_FRAMEBUFFER: 411 if (fbo->readFB == fbo->drawFB) 412 { 413 cPBOs = 1; 414 apFBOs[0] = fbo->readFB; 415 } 416 else 417 { 418 cPBOs = 2; 419 apFBOs[0] = fbo->readFB; 420 apFBOs[1] = fbo->drawFB; 421 } 422 break; 423 default: 424 crWarning("unexpected dtarget value: 0x%x", target); 425 CRSTATE_FBO_CHECKERR_RET(1, GL_INVALID_ENUM, "unexpected target", 0); 426 break; 427 } 428 429 Assert(cPBOs); 430 Assert(cPBOs <= 2); 431 432 for (i = 0; i < cPBOs; ++i) 433 { 434 CRSTATE_FBO_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "no fbo bound", 0); 435 CRSTATE_FBO_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0); 436 } 399 437 400 438 if (!texture) 401 439 { 402 *failed = GL_FALSE; 403 return; 440 return cPBOs; 404 441 } 405 442 … … 429 466 break; 430 467 default: 431 CRSTATE_FBO_CHECKERR (GL_TRUE, GL_INVALID_OPERATION, "invalid textarget");432 } 433 434 CRSTATE_FBO_CHECKERR (!*tobj, GL_INVALID_OPERATION, "invalid textarget/texture combo");468 CRSTATE_FBO_CHECKERR_RET(GL_TRUE, GL_INVALID_OPERATION, "invalid textarget", 0); 469 } 470 471 CRSTATE_FBO_CHECKERR_RET(!*tobj, GL_INVALID_OPERATION, "invalid textarget/texture combo", 0); 435 472 436 473 if (GL_TEXTURE_RECTANGLE_ARB==textarget) 437 474 { 438 CRSTATE_FBO_CHECKERR(level!=0, GL_INVALID_VALUE, "non zero mipmap level"); 439 } 440 441 CRSTATE_FBO_CHECKERR(level<0, GL_INVALID_VALUE, "level<0"); 442 CRSTATE_FBO_CHECKERR(level>maxtexsizelog2, GL_INVALID_VALUE, "level too big"); 443 444 *failed = GL_FALSE; 475 CRSTATE_FBO_CHECKERR_RET(level!=0, GL_INVALID_VALUE, "non zero mipmap level", 0); 476 } 477 478 CRSTATE_FBO_CHECKERR_RET(level<0, GL_INVALID_VALUE, "level<0", 0); 479 CRSTATE_FBO_CHECKERR_RET(level>maxtexsizelog2, GL_INVALID_VALUE, "level too big", 0); 445 480 446 481 #ifdef IN_GUEST 447 if ((*ap)->type!=GL_TEXTURE || (*ap)->name!=texture || (*ap)->level!=level) 448 { 449 pFBO->status = GL_FRAMEBUFFER_UNDEFINED; 450 } 451 #endif 482 for (i = 0; i < cPBOs; ++i) 483 { 484 if ((aap[i])->type!=GL_TEXTURE || (aap[i])->name!=texture || (aap[i])->level!=level) 485 { 486 apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; 487 } 488 } 489 #endif 490 491 Assert(cPBOs); 492 Assert(cPBOs <= 2); 493 494 return cPBOs; 452 495 } 453 496 … … 457 500 CRContext *g = GetCurrentContext(); 458 501 CRFramebufferObjectState *fbo = &g->framebufferobject; 459 CRFBOAttachmentPoint *ap; 502 CRFBOAttachmentPoint *aap[2]; 503 GLuint cap, i; 460 504 CRTextureObj *tobj; 461 GLboolean failed; 462 463 crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, &failed, &ap, &tobj); 464 if (failed) return; 505 506 cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); 507 if (!cap) return; 465 508 466 509 if (!texture) 467 510 { 468 crStateInitFBOAttachmentPoint(ap); 511 for (i = 0; i < cap; ++i) 512 { 513 crStateInitFBOAttachmentPoint(aap[i]); 514 } 469 515 return; 470 516 } … … 476 522 #endif 477 523 478 crStateInitFBOAttachmentPoint(ap); 479 ap->type = GL_TEXTURE; 480 ap->name = texture; 481 ap->level = level; 524 for (i = 0; i < cap; ++i) 525 { 526 crStateInitFBOAttachmentPoint(aap[i]); 527 aap[i]->type = GL_TEXTURE; 528 aap[i]->name = texture; 529 aap[i]->level = level; 530 } 482 531 } 483 532 … … 487 536 CRContext *g = GetCurrentContext(); 488 537 CRFramebufferObjectState *fbo = &g->framebufferobject; 489 CRFBOAttachmentPoint *ap; 538 CRFBOAttachmentPoint *aap[2]; 539 GLuint cap, i; 490 540 CRTextureObj *tobj; 491 GLboolean failed; 492 493 crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, &failed, &ap, &tobj); 494 if (failed) return; 541 542 cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); 543 if (!cap) return; 495 544 496 545 if (!texture) 497 546 { 498 crStateInitFBOAttachmentPoint(ap); 547 for (i = 0; i < cap; ++i) 548 { 549 crStateInitFBOAttachmentPoint(aap[i]); 550 } 499 551 return; 500 552 } … … 506 558 #endif 507 559 508 crStateInitFBOAttachmentPoint(ap); 509 ap->type = GL_TEXTURE; 510 ap->name = texture; 511 ap->level = level; 512 if (textarget!=GL_TEXTURE_2D && textarget!=GL_TEXTURE_RECTANGLE_ARB) 513 { 514 ap->face = textarget; 560 for (i = 0; i < cap; ++i) 561 { 562 crStateInitFBOAttachmentPoint(aap[i]); 563 aap[i]->type = GL_TEXTURE; 564 aap[i]->name = texture; 565 aap[i]->level = level; 566 if (textarget!=GL_TEXTURE_2D && textarget!=GL_TEXTURE_RECTANGLE_ARB) 567 { 568 aap[i]->face = textarget; 569 } 515 570 } 516 571 } … … 521 576 CRContext *g = GetCurrentContext(); 522 577 CRFramebufferObjectState *fbo = &g->framebufferobject; 523 CRFBOAttachmentPoint *ap; 578 CRFBOAttachmentPoint *aap[2]; 579 GLuint cap, i; 524 580 CRTextureObj *tobj; 525 GLboolean failed; 526 527 crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, &failed, &ap, &tobj); 528 if (failed) return; 581 582 cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); 583 if (!cap) return; 529 584 530 585 if (!texture) 531 586 { 532 crStateInitFBOAttachmentPoint(ap); 587 for (i = 0; i < cap; ++i) 588 { 589 crStateInitFBOAttachmentPoint(aap[i]); 590 } 533 591 return; 534 592 } … … 541 599 #endif 542 600 543 crStateInitFBOAttachmentPoint(ap); 544 ap->type = GL_TEXTURE; 545 ap->name = texture; 546 ap->level = level; 547 ap->zoffset = zoffset; 601 for (i = 0; i < cap; ++i) 602 { 603 crStateInitFBOAttachmentPoint(aap[i]); 604 aap[i]->type = GL_TEXTURE; 605 aap[i]->name = texture; 606 aap[i]->level = level; 607 aap[i]->zoffset = zoffset; 608 } 548 609 } 549 610
Note:
See TracChangeset
for help on using the changeset viewer.