Changeset 73363 in vbox
- Timestamp:
- Jul 26, 2018 8:33:24 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r73330 r73363 639 639 } 640 640 641 static int vmsvga3dLoadGLFunctions(PVMSVGA3DSTATE pState) 642 { 643 /* A strict approach to get a proc address as recommended by Khronos: 644 * - "If the function is a core OpenGL function, then we need to check the OpenGL version". 645 * - "If the function is an extension, we need to check to see if the extension is supported." 646 */ 647 648 /* Get a function address, return VERR_NOT_IMPLEMENTED on failure. */ 649 #define GLGETPROC_(ProcType, ProcName, NameSuffix) do { \ 650 pState->ext.ProcName = (ProcType)OGLGETPROCADDRESS(#ProcName NameSuffix); \ 651 AssertLogRelMsgReturn(pState->ext.ProcName, (#ProcName NameSuffix " missing"), VERR_NOT_IMPLEMENTED); \ 652 } while(0) 653 654 /* Get an optional function address. LogRel on failure. */ 655 #define GLGETPROCOPT_(ProcType, ProcName, NameSuffix) do { \ 656 pState->ext.ProcName = (ProcType)OGLGETPROCADDRESS(#ProcName NameSuffix); \ 657 if (!pState->ext.ProcName) \ 658 { \ 659 LogRel(("VMSVGA3d: missing optional %s\n", #ProcName NameSuffix)); \ 660 AssertFailed(); \ 661 } \ 662 } while(0) 663 664 /* OpenGL 2.0 or earlier core. Do not bother with extensions. */ 665 GLGETPROC_(PFNGLGENQUERIESPROC , glGenQueries, ""); 666 GLGETPROC_(PFNGLDELETEQUERIESPROC , glDeleteQueries, ""); 667 GLGETPROC_(PFNGLBEGINQUERYPROC , glBeginQuery, ""); 668 GLGETPROC_(PFNGLENDQUERYPROC , glEndQuery, ""); 669 GLGETPROC_(PFNGLGETQUERYOBJECTUIVPROC , glGetQueryObjectuiv, ""); 670 GLGETPROC_(PFNGLTEXIMAGE3DPROC , glTexImage3D, ""); 671 GLGETPROC_(PFNGLCOMPRESSEDTEXIMAGE2DPROC , glCompressedTexImage2D, ""); 672 GLGETPROC_(PFNGLCOMPRESSEDTEXIMAGE3DPROC , glCompressedTexImage3D, ""); 673 GLGETPROC_(PFNGLPOINTPARAMETERFPROC , glPointParameterf, ""); 674 GLGETPROC_(PFNGLBLENDEQUATIONSEPARATEPROC , glBlendEquationSeparate, ""); 675 GLGETPROC_(PFNGLBLENDFUNCSEPARATEPROC , glBlendFuncSeparate, ""); 676 GLGETPROC_(PFNGLSTENCILOPSEPARATEPROC , glStencilOpSeparate, ""); 677 GLGETPROC_(PFNGLSTENCILFUNCSEPARATEPROC , glStencilFuncSeparate, ""); 678 GLGETPROC_(PFNGLBINDBUFFERPROC , glBindBuffer, ""); 679 GLGETPROC_(PFNGLDELETEBUFFERSPROC , glDeleteBuffers, ""); 680 GLGETPROC_(PFNGLGENBUFFERSPROC , glGenBuffers, ""); 681 GLGETPROC_(PFNGLBUFFERDATAPROC , glBufferData, ""); 682 GLGETPROC_(PFNGLMAPBUFFERPROC , glMapBuffer, ""); 683 GLGETPROC_(PFNGLUNMAPBUFFERPROC , glUnmapBuffer, ""); 684 GLGETPROC_(PFNGLENABLEVERTEXATTRIBARRAYPROC , glEnableVertexAttribArray, ""); 685 GLGETPROC_(PFNGLDISABLEVERTEXATTRIBARRAYPROC , glDisableVertexAttribArray, ""); 686 GLGETPROC_(PFNGLVERTEXATTRIBPOINTERPROC , glVertexAttribPointer, ""); 687 GLGETPROC_(PFNGLACTIVETEXTUREPROC , glActiveTexture, ""); 688 /** @todo Why ARB? Seems to be RT_OS_DARWIN related, see DevVGA-SVGA3d-internal.h */ 689 GLGETPROC_(PFNGLGETPROGRAMIVARBPROC , glGetProgramivARB, ""); 690 GLGETPROC_(PFNGLFOGCOORDPOINTERPROC , glFogCoordPointer, ""); 691 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102 692 GLGETPROC_(PFNGLBLENDCOLORPROC , glBlendColor, ""); 693 GLGETPROC_(PFNGLBLENDEQUATIONPROC , glBlendEquation, ""); 694 #endif 695 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103 696 GLGETPROC_(PFNGLCLIENTACTIVETEXTUREPROC , glClientActiveTexture, ""); 697 #endif 698 699 /* OpenGL 3.0 core, GL_ARB_instanced_arrays. Same functions names in the ARB and core specs. */ 700 if ( pState->rsGLVersion >= 3.0f 701 || vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_framebuffer_object ")) 702 { 703 GLGETPROC_(PFNGLISRENDERBUFFERPROC , glIsRenderbuffer, ""); 704 GLGETPROC_(PFNGLBINDRENDERBUFFERPROC , glBindRenderbuffer, ""); 705 GLGETPROC_(PFNGLDELETERENDERBUFFERSPROC , glDeleteRenderbuffers, ""); 706 GLGETPROC_(PFNGLGENRENDERBUFFERSPROC , glGenRenderbuffers, ""); 707 GLGETPROC_(PFNGLRENDERBUFFERSTORAGEPROC , glRenderbufferStorage, ""); 708 GLGETPROC_(PFNGLGETRENDERBUFFERPARAMETERIVPROC , glGetRenderbufferParameteriv, ""); 709 GLGETPROC_(PFNGLISFRAMEBUFFERPROC , glIsFramebuffer, ""); 710 GLGETPROC_(PFNGLBINDFRAMEBUFFERPROC , glBindFramebuffer, ""); 711 GLGETPROC_(PFNGLDELETEFRAMEBUFFERSPROC , glDeleteFramebuffers, ""); 712 GLGETPROC_(PFNGLGENFRAMEBUFFERSPROC , glGenFramebuffers, ""); 713 GLGETPROC_(PFNGLCHECKFRAMEBUFFERSTATUSPROC , glCheckFramebufferStatus, ""); 714 GLGETPROC_(PFNGLFRAMEBUFFERTEXTURE1DPROC , glFramebufferTexture1D, ""); 715 GLGETPROC_(PFNGLFRAMEBUFFERTEXTURE2DPROC , glFramebufferTexture2D, ""); 716 GLGETPROC_(PFNGLFRAMEBUFFERTEXTURE3DPROC , glFramebufferTexture3D, ""); 717 GLGETPROC_(PFNGLFRAMEBUFFERRENDERBUFFERPROC , glFramebufferRenderbuffer, ""); 718 GLGETPROC_(PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC , glGetFramebufferAttachmentParameteriv, ""); 719 GLGETPROC_(PFNGLGENERATEMIPMAPPROC , glGenerateMipmap, ""); 720 GLGETPROC_(PFNGLBLITFRAMEBUFFERPROC , glBlitFramebuffer, ""); 721 GLGETPROC_(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC , glRenderbufferStorageMultisample, ""); 722 GLGETPROC_(PFNGLFRAMEBUFFERTEXTURELAYERPROC , glFramebufferTextureLayer, ""); 723 } 724 725 /* OpenGL 3.1 core, GL_ARB_draw_instanced, GL_EXT_draw_instanced. */ 726 if (pState->rsGLVersion >= 3.1f) 727 { 728 GLGETPROC_(PFNGLDRAWARRAYSINSTANCEDPROC , glDrawArraysInstanced, ""); 729 GLGETPROC_(PFNGLDRAWELEMENTSINSTANCEDPROC , glDrawElementsInstanced, ""); 730 } 731 else if (vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_draw_instanced ")) 732 { 733 GLGETPROC_(PFNGLDRAWARRAYSINSTANCEDARBPROC , glDrawArraysInstanced, "ARB"); 734 GLGETPROC_(PFNGLDRAWELEMENTSINSTANCEDARBPROC , glDrawElementsInstanced, "ARB"); 735 } 736 else if (vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_draw_instanced ")) 737 { 738 GLGETPROC_(PFNGLDRAWARRAYSINSTANCEDEXTPROC , glDrawArraysInstanced, "EXT"); 739 GLGETPROC_(PFNGLDRAWELEMENTSINSTANCEDEXTPROC , glDrawElementsInstanced, "EXT"); 740 } 741 742 /* OpenGL 3.2 core, GL_ARB_draw_elements_base_vertex. Same functions names in the ARB and core specs. */ 743 if ( pState->rsGLVersion >= 3.2f 744 || vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_draw_elements_base_vertex ")) 745 { 746 GLGETPROC_(PFNGLDRAWELEMENTSBASEVERTEXPROC , glDrawElementsBaseVertex, ""); 747 GLGETPROC_(PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC , glDrawElementsInstancedBaseVertex, ""); 748 } 749 750 /* Optional. OpenGL 3.2 core, GL_ARB_provoking_vertex. Same functions names in the ARB and core specs. */ 751 if ( pState->rsGLVersion >= 3.2f 752 || vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_provoking_vertex ")) 753 { 754 GLGETPROCOPT_(PFNGLPROVOKINGVERTEXPROC , glProvokingVertex, ""); 755 } 756 757 /* OpenGL 3.3 core, GL_ARB_instanced_arrays. */ 758 if (pState->rsGLVersion >= 3.3f) 759 { 760 GLGETPROC_(PFNGLVERTEXATTRIBDIVISORPROC , glVertexAttribDivisor, ""); 761 } 762 else if (vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_instanced_arrays ")) 763 { 764 GLGETPROC_(PFNGLVERTEXATTRIBDIVISORARBPROC , glVertexAttribDivisor, "ARB"); 765 } 766 767 /* Extension support */ 768 /** @todo See SVGA3D_RS_STENCILENABLE2SIDED. */ 769 pState->ext.fEXT_stencil_two_side = vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_stencil_two_side "); 770 771 #undef GLGETPROCOPT_ 772 #undef GLGETPROC_ 773 774 return VINF_SUCCESS; 775 } 776 777 641 778 /* We must delay window creation until the PowerOn phase. Init is too early and will cause failures. */ 642 779 int vmsvga3dPowerOn(PVGASTATE pThis) … … 707 844 #endif 708 845 709 710 if (vmsvga3dCheckGLExtension(pState, 3.0f, " GL_ARB_framebuffer_object ")) 711 { 712 pState->ext.glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)OGLGETPROCADDRESS("glIsRenderbuffer"); 713 pState->ext.glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)OGLGETPROCADDRESS("glBindRenderbuffer"); 714 pState->ext.glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)OGLGETPROCADDRESS("glDeleteRenderbuffers"); 715 pState->ext.glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)OGLGETPROCADDRESS("glGenRenderbuffers"); 716 pState->ext.glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)OGLGETPROCADDRESS("glRenderbufferStorage"); 717 pState->ext.glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)OGLGETPROCADDRESS("glGetRenderbufferParameteriv"); 718 pState->ext.glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)OGLGETPROCADDRESS("glIsFramebuffer"); 719 pState->ext.glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)OGLGETPROCADDRESS("glBindFramebuffer"); 720 pState->ext.glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)OGLGETPROCADDRESS("glDeleteFramebuffers"); 721 pState->ext.glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)OGLGETPROCADDRESS("glGenFramebuffers"); 722 pState->ext.glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)OGLGETPROCADDRESS("glCheckFramebufferStatus"); 723 pState->ext.glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)OGLGETPROCADDRESS("glFramebufferTexture1D"); 724 pState->ext.glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)OGLGETPROCADDRESS("glFramebufferTexture2D"); 725 pState->ext.glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)OGLGETPROCADDRESS("glFramebufferTexture3D"); 726 pState->ext.glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)OGLGETPROCADDRESS("glFramebufferRenderbuffer"); 727 pState->ext.glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)OGLGETPROCADDRESS("glGetFramebufferAttachmentParameteriv"); 728 pState->ext.glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)OGLGETPROCADDRESS("glGenerateMipmap"); 729 pState->ext.glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)OGLGETPROCADDRESS("glBlitFramebuffer"); 730 pState->ext.glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)OGLGETPROCADDRESS("glRenderbufferStorageMultisample"); 731 pState->ext.glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)OGLGETPROCADDRESS("glFramebufferTextureLayer"); 732 } 733 pState->ext.glPointParameterf = (PFNGLPOINTPARAMETERFPROC)OGLGETPROCADDRESS("glPointParameterf"); 734 AssertMsgReturn(pState->ext.glPointParameterf, ("glPointParameterf missing"), VERR_NOT_IMPLEMENTED); 735 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102 736 pState->ext.glBlendColor = (PFNGLBLENDCOLORPROC)OGLGETPROCADDRESS("glBlendColor"); 737 AssertMsgReturn(pState->ext.glBlendColor, ("glBlendColor missing"), VERR_NOT_IMPLEMENTED); 738 pState->ext.glBlendEquation = (PFNGLBLENDEQUATIONPROC)OGLGETPROCADDRESS("glBlendEquation"); 739 AssertMsgReturn(pState->ext.glBlendEquation, ("glBlendEquation missing"), VERR_NOT_IMPLEMENTED); 740 #endif 741 pState->ext.glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)OGLGETPROCADDRESS("glBlendEquationSeparate"); 742 AssertMsgReturn(pState->ext.glBlendEquationSeparate, ("glBlendEquationSeparate missing"), VERR_NOT_IMPLEMENTED); 743 pState->ext.glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)OGLGETPROCADDRESS("glBlendFuncSeparate"); 744 AssertMsgReturn(pState->ext.glBlendFuncSeparate, ("glBlendFuncSeparate missing"), VERR_NOT_IMPLEMENTED); 745 pState->ext.glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)OGLGETPROCADDRESS("glStencilOpSeparate"); 746 AssertMsgReturn(pState->ext.glStencilOpSeparate, ("glStencilOpSeparate missing"), VERR_NOT_IMPLEMENTED); 747 pState->ext.glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)OGLGETPROCADDRESS("glStencilFuncSeparate"); 748 AssertMsgReturn(pState->ext.glStencilFuncSeparate, ("glStencilFuncSeparate missing"), VERR_NOT_IMPLEMENTED); 749 pState->ext.glBindBuffer = (PFNGLBINDBUFFERPROC)OGLGETPROCADDRESS("glBindBuffer"); 750 AssertMsgReturn(pState->ext.glBindBuffer, ("glBindBuffer missing"), VERR_NOT_IMPLEMENTED); 751 pState->ext.glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)OGLGETPROCADDRESS("glDeleteBuffers"); 752 AssertMsgReturn(pState->ext.glDeleteBuffers, ("glDeleteBuffers missing"), VERR_NOT_IMPLEMENTED); 753 pState->ext.glGenBuffers = (PFNGLGENBUFFERSPROC)OGLGETPROCADDRESS("glGenBuffers"); 754 AssertMsgReturn(pState->ext.glGenBuffers, ("glGenBuffers missing"), VERR_NOT_IMPLEMENTED); 755 pState->ext.glBufferData = (PFNGLBUFFERDATAPROC)OGLGETPROCADDRESS("glBufferData"); 756 AssertMsgReturn(pState->ext.glBufferData, ("glBufferData missing"), VERR_NOT_IMPLEMENTED); 757 pState->ext.glMapBuffer = (PFNGLMAPBUFFERPROC)OGLGETPROCADDRESS("glMapBuffer"); 758 AssertMsgReturn(pState->ext.glMapBuffer, ("glMapBuffer missing"), VERR_NOT_IMPLEMENTED); 759 pState->ext.glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)OGLGETPROCADDRESS("glUnmapBuffer"); 760 AssertMsgReturn(pState->ext.glUnmapBuffer, ("glUnmapBuffer missing"), VERR_NOT_IMPLEMENTED); 761 pState->ext.glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)OGLGETPROCADDRESS("glEnableVertexAttribArray"); 762 AssertMsgReturn(pState->ext.glEnableVertexAttribArray, ("glEnableVertexAttribArray missing"), VERR_NOT_IMPLEMENTED); 763 pState->ext.glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)OGLGETPROCADDRESS("glDisableVertexAttribArray"); 764 AssertMsgReturn(pState->ext.glDisableVertexAttribArray, ("glDisableVertexAttribArray missing"), VERR_NOT_IMPLEMENTED); 765 pState->ext.glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)OGLGETPROCADDRESS("glVertexAttribPointer"); 766 AssertMsgReturn(pState->ext.glVertexAttribPointer, ("glVertexAttribPointer missing"), VERR_NOT_IMPLEMENTED); 767 pState->ext.glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)OGLGETPROCADDRESS("glFogCoordPointer"); 768 AssertMsgReturn(pState->ext.glFogCoordPointer, ("glFogCoordPointer missing"), VERR_NOT_IMPLEMENTED); 769 pState->ext.glActiveTexture = (PFNGLACTIVETEXTUREPROC)OGLGETPROCADDRESS("glActiveTexture"); 770 AssertMsgReturn(pState->ext.glActiveTexture, ("glActiveTexture missing"), VERR_NOT_IMPLEMENTED); 771 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103 772 pState->ext.glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)OGLGETPROCADDRESS("glClientActiveTexture"); 773 AssertMsgReturn(pState->ext.glClientActiveTexture, ("glClientActiveTexture missing"), VERR_NOT_IMPLEMENTED); 774 #endif 775 pState->ext.glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)OGLGETPROCADDRESS("glGetProgramivARB"); 776 AssertMsgReturn(pState->ext.glGetProgramivARB, ("glGetProgramivARB missing"), VERR_NOT_IMPLEMENTED); 777 778 /* OpenGL 3.2 core */ 779 if (vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_draw_elements_base_vertex ")) 780 { 781 pState->ext.glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)OGLGETPROCADDRESS("glDrawElementsBaseVertex"); 782 pState->ext.glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)OGLGETPROCADDRESS("glDrawElementsInstancedBaseVertex"); 783 } 784 else 785 LogRel(("VMSVGA3d: missing extension GL_ARB_draw_elements_base_vertex\n")); 786 787 /* OpenGL 3.2 core */ 788 if (vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_provoking_vertex ")) 789 { 790 pState->ext.glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)OGLGETPROCADDRESS("glProvokingVertex"); 791 } 792 else 793 LogRel(("VMSVGA3d: missing extension GL_ARB_provoking_vertex\n")); 794 795 /* Extension support */ 796 #if defined(RT_OS_DARWIN) 797 /** @todo OpenGL version history suggest this, verify... */ 798 pState->ext.fEXT_stencil_two_side = vmsvga3dCheckGLExtension(pState, 2.0f, " GL_EXT_stencil_two_side "); 799 #else 800 pState->ext.fEXT_stencil_two_side = vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_stencil_two_side "); 801 #endif 802 803 #define GLGETPROC(ProcType, ProcName, NameSuffix) do { \ 804 pState->ext.ProcName = (ProcType)OGLGETPROCADDRESS(#ProcName NameSuffix); \ 805 AssertLogRelMsgReturn(pState->ext.ProcName, (#ProcName NameSuffix " missing"), VERR_NOT_IMPLEMENTED); \ 806 } while(0) 807 #define GLGETPROCOPT(ProcType, ProcName, NameSuffix) do { \ 808 pState->ext.ProcName = (ProcType)OGLGETPROCADDRESS(#ProcName NameSuffix); \ 809 AssertMsg(pState->ext.ProcName, (#ProcName NameSuffix " missing (optional)")); \ 810 } while(0) 811 812 /* OpenGL 2.0 core */ 813 GLGETPROCOPT(PFNGLGENQUERIESPROC , glGenQueries, ""); 814 GLGETPROCOPT(PFNGLDELETEQUERIESPROC , glDeleteQueries, ""); 815 GLGETPROCOPT(PFNGLBEGINQUERYPROC , glBeginQuery, ""); 816 GLGETPROCOPT(PFNGLENDQUERYPROC , glEndQuery, ""); 817 GLGETPROCOPT(PFNGLGETQUERYOBJECTUIVPROC , glGetQueryObjectuiv, ""); 818 GLGETPROC (PFNGLTEXIMAGE3DPROC , glTexImage3D, ""); 819 GLGETPROC (PFNGLCOMPRESSEDTEXIMAGE2DPROC , glCompressedTexImage2D, ""); 820 GLGETPROC (PFNGLCOMPRESSEDTEXIMAGE3DPROC , glCompressedTexImage3D, ""); 821 822 /** @todo A structured approach for loading OpenGL functions. */ 823 /* OpenGL 3.3 core, GL_ARB_instanced_arrays. Required. */ 824 if (pState->rsGLVersion >= 3.3f) 825 GLGETPROC(PFNGLVERTEXATTRIBDIVISORPROC , glVertexAttribDivisor, ""); 826 else if (vmsvga3dCheckGLExtension(pState, 3.3f, " GL_ARB_instanced_arrays ")) 827 GLGETPROC(PFNGLVERTEXATTRIBDIVISORPROC , glVertexAttribDivisor, "ARB"); 828 829 /* OpenGL 3.1 core, GL_ARB_draw_instanced. Required. */ 830 if (pState->rsGLVersion >= 3.1f) 831 { 832 GLGETPROC(PFNGLDRAWARRAYSINSTANCEDPROC , glDrawArraysInstanced, ""); 833 GLGETPROC(PFNGLDRAWELEMENTSINSTANCEDPROC , glDrawElementsInstanced, ""); 834 } 835 else if (vmsvga3dCheckGLExtension(pState, 3.1f, " GL_ARB_draw_instanced ")) 836 { 837 GLGETPROC(PFNGLDRAWARRAYSINSTANCEDPROC , glDrawArraysInstanced, "ARB"); 838 GLGETPROC(PFNGLDRAWELEMENTSINSTANCEDPROC , glDrawElementsInstanced, "ARB"); 839 } 840 #undef GLGETPROCOPT 841 #undef GLGETPROC 846 /* 847 * Resolve GL function pointers and store them in pState->ext. 848 */ 849 rc = vmsvga3dLoadGLFunctions(pState); 850 if (RT_FAILURE(rc)) 851 { 852 LogRel(("VMSVGA3d: missing required OpenGL function or extension; aborting\n")); 853 return rc; 854 } 855 842 856 /* 843 857 * Initialize the capabilities with sensible defaults. … … 875 889 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, pState->caps.flPointSize)); 876 890 877 if (pState->ext.glGetProgramivARB) 878 { 879 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 880 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, 881 &pState->caps.maxFragmentShaderTemps)); 882 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 883 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, 884 &pState->caps.maxFragmentShaderInstructions)); 885 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 886 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, 887 &pState->caps.maxVertexShaderTemps)); 888 889 /* Intel Windows drivers return 31, while the guest expects 32 at least. */ 890 if ( pState->caps.maxVertexShaderTemps < 32 891 && vmsvga3dIsVendorIntel()) 892 pState->caps.maxVertexShaderTemps = 32; 893 894 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 895 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, 896 &pState->caps.maxVertexShaderInstructions)); 897 } 891 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 892 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, 893 &pState->caps.maxFragmentShaderTemps)); 894 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 895 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, 896 &pState->caps.maxFragmentShaderInstructions)); 897 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 898 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, 899 &pState->caps.maxVertexShaderTemps)); 900 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, 901 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, 902 &pState->caps.maxVertexShaderInstructions)); 903 898 904 pState->caps.fS3TCSupported = vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_texture_compression_s3tc "); 899 905 … … 952 958 } 953 959 954 if (!vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_vertex_array_bgra ")) 955 { 956 /** @todo Intel drivers don't support this extension! */ 960 if ( !vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_vertex_array_bgra ") 961 && !vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_vertex_array_bgra ")) 962 { 963 /** @todo Intel drivers don't support this extension! (TEST IT, may be it was about GL_ARB only?) */ 957 964 LogRel(("VMSVGA3D: WARNING: Missing required extension GL_ARB_vertex_array_bgra (d3dcolor)!!!\n")); 958 965 } 966 967 /* 968 * Tweak capabilities. 969 */ 970 /* Intel Windows drivers return 31, while the guest expects 32 at least. */ 971 if ( pState->caps.maxVertexShaderTemps < 32 972 && vmsvga3dIsVendorIntel()) 973 pState->caps.maxVertexShaderTemps = 32; 974 959 975 #if 0 960 976 SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND = 11, … … 1058 1074 { 1059 1075 LogRel(("VMSVGA3d: unsupported OpenGL version; minimum is 3.0\n")); 1060 return VERR_NOT_IMPLEMENTED;1061 }1062 if ( !pState->ext.glIsRenderbuffer1063 || !pState->ext.glBindRenderbuffer1064 || !pState->ext.glDeleteRenderbuffers1065 || !pState->ext.glGenRenderbuffers1066 || !pState->ext.glRenderbufferStorage1067 || !pState->ext.glGetRenderbufferParameteriv1068 || !pState->ext.glIsFramebuffer1069 || !pState->ext.glBindFramebuffer1070 || !pState->ext.glDeleteFramebuffers1071 || !pState->ext.glGenFramebuffers1072 || !pState->ext.glCheckFramebufferStatus1073 || !pState->ext.glFramebufferTexture1D1074 || !pState->ext.glFramebufferTexture2D1075 || !pState->ext.glFramebufferTexture3D1076 || !pState->ext.glFramebufferRenderbuffer1077 || !pState->ext.glGetFramebufferAttachmentParameteriv1078 || !pState->ext.glGenerateMipmap1079 || !pState->ext.glBlitFramebuffer1080 || !pState->ext.glRenderbufferStorageMultisample1081 || !pState->ext.glFramebufferTextureLayer)1082 {1083 LogRel(("VMSVGA3d: missing required OpenGL extension; aborting\n"));1084 1076 return VERR_NOT_IMPLEMENTED; 1085 1077 } … … 4567 4559 4568 4560 case SVGA3D_RS_STENCILENABLE2SIDED: /* SVGA3dBool */ 4561 /** @todo This should be implemented similar to SVGA3D_RS_SEPARATEALPHABLENDENABLE, 4562 * i.e. use OpenGL 2.0 glStencil[Func|Op]Separate when SVGA3D_RS_STENCILENABLE2SIDED 4563 * is enabled. 4564 * It looks like VMSVGA (D3D) does not support separate masks, i.e. does not need 4565 * glStencilMaskSeparate. 4566 * 4567 * GL_EXT_stencil_two_side is an NVidia extension which implements similar functionality 4568 * as glStencil[*]Separate functions, but it not needed with OpenGL 2.0. 4569 */ 4569 4570 /* @note GL_EXT_stencil_two_side required! */ 4570 4571 if (pState->ext.fEXT_stencil_two_side) … … 6203 6204 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6204 6205 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6205 if (pState->ext.glVertexAttribDivisor) 6206 { 6207 GLuint const divisor = paVertexDivisors && paVertexDivisors[index].s.instanceData ? 1 : 0; 6208 pState->ext.glVertexAttribDivisor(index, divisor); 6209 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6210 } 6206 6207 GLuint const divisor = paVertexDivisors && paVertexDivisors[index].s.instanceData ? 1 : 0; 6208 pState->ext.glVertexAttribDivisor(index, divisor); 6209 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6210 6211 6211 /** @todo case SVGA3D_DECLUSAGE_COLOR: color component order not identical!! test GL_BGRA!! */ 6212 6212 }
Note:
See TracChangeset
for help on using the changeset viewer.