Changeset 45201 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- Mar 27, 2013 10:23:49 AM (12 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r45179 r45201 355 355 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 356 356 357 crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter)); 358 357 359 crServerInitDispatch(); 358 360 crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); … … 443 445 VBoxVrListInit(&cr_server.RootVr); 444 446 crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint)); 447 448 crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter)); 445 449 446 450 crServerSetVBoxConfigurationHGCM(); -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
r44196 r45201 625 625 #endif 626 626 627 PCR_BLITTER crServerVBoxBlitterGet() 628 { 629 if (!CrBltIsInitialized(&cr_server.Blitter)) 630 { 631 CR_BLITTER_CONTEXT Ctx; 632 int rc; 633 CRASSERT(cr_server.MainContextInfo.SpuContext); 634 Ctx.Base.id = cr_server.MainContextInfo.SpuContext; 635 Ctx.Base.visualBits = cr_server.MainContextInfo.CreateInfo.visualBits; 636 rc = CrBltInit(&cr_server.Blitter, &Ctx, true, &cr_server.head_spu->dispatch_table); 637 if (RT_SUCCESS(rc)) 638 { 639 CRASSERT(CrBltIsInitialized(&cr_server.Blitter)); 640 } 641 else 642 { 643 crWarning("CrBltInit failed, rc %d", rc); 644 CRASSERT(!CrBltIsInitialized(&cr_server.Blitter)); 645 return NULL; 646 } 647 } 648 return &cr_server.Blitter; 649 } 650 651 int crServerVBoxBlitterTexInit(CRContext *ctx, CRMuralInfo *mural, PVBOXVR_TEXTURE pTex, GLboolean fDraw) 652 { 653 CRTextureObj *tobj; 654 CRFramebufferObjectState *pBuf = &ctx->framebufferobject; 655 GLenum enmBuf; 656 CRFBOAttachmentPoint *pAp; 657 GLuint idx; 658 CRTextureLevel *tl; 659 CRFramebufferObject *pFBO = fDraw ? pBuf->drawFB : pBuf->readFB; 660 661 if (!pFBO) 662 { 663 GLuint hwid; 664 665 if (mural->fUseFBO == CR_SERVER_REDIR_NONE) 666 return VERR_NOT_IMPLEMENTED; 667 668 enmBuf = fDraw ? ctx->buffer.drawBuffer : ctx->buffer.readBuffer; 669 switch (enmBuf) 670 { 671 case GL_BACK: 672 case GL_BACK_RIGHT: 673 case GL_BACK_LEFT: 674 hwid = mural->aidColorTexs[CR_SERVER_FBO_BB_IDX(mural)]; 675 break; 676 case GL_FRONT: 677 case GL_FRONT_RIGHT: 678 case GL_FRONT_LEFT: 679 hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]; 680 break; 681 default: 682 crWarning("unsupported enum buf"); 683 return VERR_NOT_IMPLEMENTED; 684 break; 685 } 686 687 if (!hwid) 688 { 689 crWarning("offscreen render tex hwid is null"); 690 return VERR_INVALID_STATE; 691 } 692 693 pTex->width = mural->width; 694 pTex->height = mural->height; 695 pTex->target = GL_TEXTURE_2D; 696 pTex->hwid = hwid; 697 return VINF_SUCCESS; 698 } 699 700 enmBuf = fDraw ? pFBO->drawbuffer[0] : pFBO->readbuffer; 701 idx = enmBuf - GL_COLOR_ATTACHMENT0_EXT; 702 if (idx >= CR_MAX_COLOR_ATTACHMENTS) 703 { 704 crWarning("idx is invalid %d, using 0", idx); 705 } 706 707 pAp = &pFBO->color[idx]; 708 709 if (!pAp->name) 710 { 711 crWarning("no collor draw attachment"); 712 return VERR_INVALID_STATE; 713 } 714 715 if (pAp->level) 716 { 717 crWarning("non-zero level not implemented"); 718 return VERR_NOT_IMPLEMENTED; 719 } 720 721 tobj = (CRTextureObj*)crHashtableSearch(ctx->shared->textureTable, pAp->name); 722 if (!tobj) 723 { 724 crWarning("no texture object found for name %d", pAp->name); 725 return VERR_INVALID_STATE; 726 } 727 728 if (tobj->target != GL_TEXTURE_2D && tobj->target != GL_TEXTURE_RECTANGLE_NV) 729 { 730 crWarning("non-texture[rect|2d] not implemented"); 731 return VERR_NOT_IMPLEMENTED; 732 } 733 734 CRASSERT(tobj->hwid); 735 736 tl = tobj->level[0]; 737 pTex->width = tl->width; 738 pTex->height = tl->height; 739 pTex->target = tobj->target; 740 pTex->hwid = tobj->hwid; 741 742 return VINF_SUCCESS; 743 } 744 745 void crServerVBoxBlitterWinInit(CRMuralInfo *mural, CR_BLITTER_WINDOW *win) 746 { 747 win->Base.id = mural->spuWindow; 748 win->Base.visualBits = mural->CreateInfo.visualBits; 749 win->width = mural->width; 750 win->height = mural->height; 751 } 752 753 int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 754 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 755 GLbitfield mask, GLenum filter) 756 { 757 PCR_BLITTER pBlitter; 758 CR_BLITTER_CONTEXT Ctx; 759 CRMuralInfo *mural; 760 CRContext *ctx = crStateGetCurrent(); 761 PVBOXVR_TEXTURE pDrawTex, pReadTex; 762 VBOXVR_TEXTURE DrawTex, ReadTex; 763 int rc; 764 GLuint idDrawFBO, idReadFBO; 765 CR_BLITTER_WINDOW BltInfo; 766 767 if (mask != GL_COLOR_BUFFER_BIT) 768 { 769 crWarning("not supported blit mask %d", mask); 770 return VERR_NOT_IMPLEMENTED; 771 } 772 773 if (!cr_server.curClient) 774 { 775 crWarning("no current client"); 776 return VERR_INVALID_STATE; 777 } 778 mural = cr_server.curClient->currentMural; 779 if (!mural) 780 { 781 crWarning("no current mural"); 782 return VERR_INVALID_STATE; 783 } 784 785 rc = crServerVBoxBlitterTexInit(ctx, mural, &DrawTex, GL_TRUE); 786 if (RT_SUCCESS(rc)) 787 { 788 pDrawTex = &DrawTex; 789 } 790 else 791 { 792 crWarning("crServerVBoxBlitterTexInit failed for draw"); 793 return rc; 794 } 795 796 rc = crServerVBoxBlitterTexInit(ctx, mural, &ReadTex, GL_FALSE); 797 if (RT_SUCCESS(rc)) 798 { 799 pReadTex = &ReadTex; 800 } 801 else 802 { 803 // crWarning("crServerVBoxBlitterTexInit failed for read"); 804 return rc; 805 } 806 807 pBlitter = crServerVBoxBlitterGet(); 808 if (!pBlitter) 809 { 810 crWarning("crServerVBoxBlitterGet failed"); 811 return VERR_GENERAL_FAILURE; 812 } 813 814 crServerVBoxBlitterWinInit(mural, &BltInfo); 815 816 CrBltMuralSetCurrent(pBlitter, &BltInfo); 817 818 Ctx.Base.id = cr_server.curClient->currentCtxInfo->SpuContext; 819 if (Ctx.Base.id < 0) 820 Ctx.Base.id = cr_server.MainContextInfo.SpuContext; 821 Ctx.Base.visualBits = cr_server.curClient->currentCtxInfo->CreateInfo.visualBits; 822 823 idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer]; 824 idReadFBO = mural->aidFBOs[mural->iCurReadBuffer]; 825 826 crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO); 827 828 rc = CrBltEnter(pBlitter, &Ctx, &BltInfo); 829 if (RT_SUCCESS(rc)) 830 { 831 RTRECT ReadRect, DrawRect; 832 ReadRect.xLeft = srcX0; 833 ReadRect.yTop = srcY0; 834 ReadRect.xRight = srcX1; 835 ReadRect.yBottom = srcY1; 836 DrawRect.xLeft = dstX0; 837 DrawRect.yTop = dstY0; 838 DrawRect.xRight = dstX1; 839 DrawRect.yBottom = dstY1; 840 CrBltBlitTexTex(pBlitter, pReadTex, &ReadRect, pDrawTex, &DrawRect, 1, CRBLT_FLAGS_FROM_FILTER(filter)); 841 CrBltLeave(pBlitter); 842 } 843 else 844 { 845 crWarning("CrBltEnter failed rc %d", rc); 846 } 847 848 crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO); 849 850 return rc; 851 } 852 627 853 void SERVER_DISPATCH_APIENTRY 628 854 crServerDispatchBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, … … 631 857 { 632 858 CRContext *ctx = crStateGetCurrent(); 859 bool fTryBlitter = false; 633 860 #ifdef CR_CHECK_BLITS 634 861 // { … … 840 1067 #endif 841 1068 1069 if (srcY0 > srcY1) 1070 { 1071 if (dstY0 > dstY1) 1072 { 1073 /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */ 1074 int32_t tmp = srcY0; 1075 srcY0 = srcY1; 1076 srcY1 = tmp; 1077 tmp = dstY0; 1078 dstY0 = dstY1; 1079 dstY1 = tmp; 1080 } 1081 else 1082 { 1083 fTryBlitter = true; 1084 } 1085 } 1086 1087 if (srcX0 > srcX1) 1088 { 1089 if (dstX0 > dstX1) 1090 { 1091 /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */ 1092 int32_t tmp = srcX0; 1093 srcX0 = srcX1; 1094 srcX1 = tmp; 1095 tmp = dstX0; 1096 dstX0 = dstX1; 1097 dstX1 = tmp; 1098 } 1099 else 1100 { 1101 fTryBlitter = true; 1102 } 1103 } 1104 1105 /* @todo: enable for problematic platforms */ 1106 #if 0 1107 if (fTryBlitter) 1108 { 1109 int rc = crServerVBoxBlitterBlitCurrentCtx(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 1110 if (RT_SUCCESS(rc)) 1111 goto my_exit; 1112 } 1113 #endif 1114 842 1115 if (ctx->viewport.scissorTest) 843 1116 cr_server.head_spu->dispatch_table.Disable(GL_SCISSOR_TEST); … … 849 1122 if (ctx->viewport.scissorTest) 850 1123 cr_server.head_spu->dispatch_table.Enable(GL_SCISSOR_TEST); 1124 1125 1126 my_exit: 1127 851 1128 //#ifdef CR_CHECK_BLITS 852 1129 // crDbgDumpTexImage2D("<== src tex:", GL_TEXTURE_2D, rtex, true); … … 861 1138 crFree(img); 862 1139 #endif 1140 return; 863 1141 } 864 1142 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c
r45159 r45201 104 104 CR_STATE_SHAREDOBJ_USAGE_INIT(mural); 105 105 106 crServerSetupOutputRedirect(mural);107 108 106 Rect.xLeft = 0; 109 107 Rect.xRight = mural->width; … … 116 114 return -1; 117 115 } 116 117 crServerSetupOutputRedirect(mural); 118 118 119 119 if (mural->fRootVrOn) -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r45148 r45201 683 683 DstRect.xRight = paDstRegions[i].xRight * scaleX; 684 684 DstRect.yBottom = paDstRegions[i].yBottom * scaleY; 685 CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR );685 CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS); 686 686 } 687 687 } … … 705 705 if (RT_SUCCESS(rc)) 706 706 { 707 CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR );707 CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS); 708 708 } 709 709 else … … 721 721 if (render_spu.blitterTable) 722 722 { 723 CR_BLITTER_WINDOW * pBltInfo = CrBltMuralGetCurrent(window->pBlitter);724 if (pBltInfo == &window->BltInfo)723 const CR_BLITTER_WINDOW * pBltInfo = CrBltMuralGetCurrentInfo(window->pBlitter); 724 if (pBltInfo->Base.id == window->BltInfo.Base.id) 725 725 { 726 726 CrBltMuralSetCurrent(window->pBlitter, NULL); … … 729 729 else 730 730 { 731 CRASSERT(CrBltMuralGetCurrent (window->pBlitter) == &window->BltInfo);731 CRASSERT(CrBltMuralGetCurrentInfo(window->pBlitter)->Base.id == window->BltInfo.Base.id); 732 732 CrBltMuralSetCurrent(window->pBlitter, NULL); 733 733 CrBltTerm(window->pBlitter);
Note:
See TracChangeset
for help on using the changeset viewer.