Lines Matching defs:pState
181 #define VMSVGA3D_CLEAR_CURRENT_CONTEXT(pState) \
182 do { (pState)->idActiveContext = OPENGL_INVALID_ID; } while (0)
186 * @parm pState The VMSVGA3d state.
190 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
191 if ((pState)->idActiveContext != (pContext)->id) \
195 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
196 (pState)->idActiveContext = (pContext)->id; \
200 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
201 if ((pState)->idActiveContext != (pContext)->id) \
204 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
205 (pState)->idActiveContext = (pContext)->id; \
208 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
209 if ((pState)->idActiveContext != (pContext)->id) \
211 Bool fMakeCurrentRc = glXMakeCurrent((pState)->display, \
215 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
216 (pState)->idActiveContext = (pContext)->id; \
396 * @parm pState The VMSVGA3d state.
404 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { \
405 Assert((pState)->idActiveContext == (pContext)->id); \
412 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { } while (0)
420 * @parm pState The VMSVGA3d state.
424 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { \
425 Assert((pState)->idActiveContext == (pContext)->id); \
430 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { } while (0)
957 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface);
960 static void vmsvga3dSetPackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
962 static void vmsvga3dRestorePackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
976 * @param pState The VMSVGA3d state.
984 static bool vmsvga3dCheckGLExtension(PVMSVGA3DSTATE pState, float fMinGLVersion, const char *pszWantedExtension)
993 if (strstr(pState->pszExtensions, pszWantedExtension))
999 || fRet == (pState->fGLVersion >= fMinGLVersion)
1002 pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet));
1004 AssertMsg(fMinGLVersion == 0.0 || fRet == (pState->fGLVersion >= fMinGLVersion),
1006 pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet));
1321 PVMSVGA3DSTATE pState = RT_FROM_MEMBER(pThis, VMSVGA3DSTATE, ShaderIf);
1322 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pState->papContexts[fOtherProfile ? 2 : 1]);
1336 PVMSVGA3DSTATE pState = RT_FROM_MEMBER(pThis, VMSVGA3DSTATE, ShaderIf);
1338 : fOtherProfile ? pState->pszOtherExtensions : pState->pszExtensions;
1403 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
1404 rc = RTSemEventCreate(&pState->WndRequestSem);
1407 rc = RTThreadCreate(&pState->pWindowThread, vmsvga3dWindowThread, pState->WndRequestSem, 0, RTTHREADTYPE_GUI, 0,
1414 RTSemEventDestroy(pState->WndRequestSem);
1429 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
1437 if (pState->fGLVersion != 0.0)
1446 pContext = pState->papContexts[1];
1447 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
1456 rc = vmsvga3dGatherExtensions(&pState->pszExtensions, VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE);
1458 vmsvga3dLogRelExtensions("", pState->pszExtensions);
1460 pState->fGLVersion = atof((const char *)glGetString(GL_VERSION));
1470 pContext = pState->papContexts[1]; /* Array may have been reallocated. */
1472 pOtherCtx = pState->papContexts[2];
1473 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pOtherCtx);
1482 rc = vmsvga3dGatherExtensions(&pState->pszOtherExtensions, VBOX_VMSVGA3D_OTHER_OGL_PROFILE);
1484 vmsvga3dLogRelExtensions("Alternative ", pState->pszOtherExtensions);
1486 pState->fOtherGLVersion = atof((const char *)glGetString(GL_VERSION));
1488 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
1490 pState->pszOtherExtensions = (char *)"";
1491 pState->fOtherGLVersion = pState->fGLVersion;
1495 if (vmsvga3dCheckGLExtension(pState, 3.0f, " GL_ARB_framebuffer_object "))
1497 pState->ext.glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)OGLGETPROCADDRESS("glIsRenderbuffer");
1498 pState->ext.glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)OGLGETPROCADDRESS("glBindRenderbuffer");
1499 pState->ext.glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)OGLGETPROCADDRESS("glDeleteRenderbuffers");
1500 pState->ext.glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)OGLGETPROCADDRESS("glGenRenderbuffers");
1501 pState->ext.glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)OGLGETPROCADDRESS("glRenderbufferStorage");
1502 pState->ext.glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)OGLGETPROCADDRESS("glGetRenderbufferParameteriv");
1503 pState->ext.glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)OGLGETPROCADDRESS("glIsFramebuffer");
1504 pState->ext.glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)OGLGETPROCADDRESS("glBindFramebuffer");
1505 pState->ext.glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)OGLGETPROCADDRESS("glDeleteFramebuffers");
1506 pState->ext.glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)OGLGETPROCADDRESS("glGenFramebuffers");
1507 pState->ext.glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)OGLGETPROCADDRESS("glCheckFramebufferStatus");
1508 pState->ext.glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)OGLGETPROCADDRESS("glFramebufferTexture1D");
1509 pState->ext.glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)OGLGETPROCADDRESS("glFramebufferTexture2D");
1510 pState->ext.glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)OGLGETPROCADDRESS("glFramebufferTexture3D");
1511 pState->ext.glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)OGLGETPROCADDRESS("glFramebufferRenderbuffer");
1512 pState->ext.glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)OGLGETPROCADDRESS("glGetFramebufferAttachmentParameteriv");
1513 pState->ext.glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)OGLGETPROCADDRESS("glGenerateMipmap");
1514 pState->ext.glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)OGLGETPROCADDRESS("glBlitFramebuffer");
1515 pState->ext.glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)OGLGETPROCADDRESS("glRenderbufferStorageMultisample");
1516 pState->ext.glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)OGLGETPROCADDRESS("glFramebufferTextureLayer");
1518 pState->ext.glPointParameterf = (PFNGLPOINTPARAMETERFPROC)OGLGETPROCADDRESS("glPointParameterf");
1519 AssertMsgReturn(pState->ext.glPointParameterf, ("glPointParameterf missing"), VERR_NOT_IMPLEMENTED);
1521 pState->ext.glBlendColor = (PFNGLBLENDCOLORPROC)OGLGETPROCADDRESS("glBlendColor");
1522 AssertMsgReturn(pState->ext.glBlendColor, ("glBlendColor missing"), VERR_NOT_IMPLEMENTED);
1523 pState->ext.glBlendEquation = (PFNGLBLENDEQUATIONPROC)OGLGETPROCADDRESS("glBlendEquation");
1524 AssertMsgReturn(pState->ext.glBlendEquation, ("glBlendEquation missing"), VERR_NOT_IMPLEMENTED);
1526 pState->ext.glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)OGLGETPROCADDRESS("glBlendEquationSeparate");
1527 AssertMsgReturn(pState->ext.glBlendEquationSeparate, ("glBlendEquationSeparate missing"), VERR_NOT_IMPLEMENTED);
1528 pState->ext.glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)OGLGETPROCADDRESS("glBlendFuncSeparate");
1529 AssertMsgReturn(pState->ext.glBlendFuncSeparate, ("glBlendFuncSeparate missing"), VERR_NOT_IMPLEMENTED);
1530 pState->ext.glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)OGLGETPROCADDRESS("glStencilOpSeparate");
1531 AssertMsgReturn(pState->ext.glStencilOpSeparate, ("glStencilOpSeparate missing"), VERR_NOT_IMPLEMENTED);
1532 pState->ext.glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)OGLGETPROCADDRESS("glStencilFuncSeparate");
1533 AssertMsgReturn(pState->ext.glStencilFuncSeparate, ("glStencilFuncSeparate missing"), VERR_NOT_IMPLEMENTED);
1534 pState->ext.glBindBuffer = (PFNGLBINDBUFFERPROC)OGLGETPROCADDRESS("glBindBuffer");
1535 AssertMsgReturn(pState->ext.glBindBuffer, ("glBindBuffer missing"), VERR_NOT_IMPLEMENTED);
1536 pState->ext.glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)OGLGETPROCADDRESS("glDeleteBuffers");
1537 AssertMsgReturn(pState->ext.glDeleteBuffers, ("glDeleteBuffers missing"), VERR_NOT_IMPLEMENTED);
1538 pState->ext.glGenBuffers = (PFNGLGENBUFFERSPROC)OGLGETPROCADDRESS("glGenBuffers");
1539 AssertMsgReturn(pState->ext.glGenBuffers, ("glGenBuffers missing"), VERR_NOT_IMPLEMENTED);
1540 pState->ext.glBufferData = (PFNGLBUFFERDATAPROC)OGLGETPROCADDRESS("glBufferData");
1541 AssertMsgReturn(pState->ext.glBufferData, ("glBufferData missing"), VERR_NOT_IMPLEMENTED);
1542 pState->ext.glMapBuffer = (PFNGLMAPBUFFERPROC)OGLGETPROCADDRESS("glMapBuffer");
1543 AssertMsgReturn(pState->ext.glMapBuffer, ("glMapBuffer missing"), VERR_NOT_IMPLEMENTED);
1544 pState->ext.glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)OGLGETPROCADDRESS("glUnmapBuffer");
1545 AssertMsgReturn(pState->ext.glUnmapBuffer, ("glUnmapBuffer missing"), VERR_NOT_IMPLEMENTED);
1546 pState->ext.glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)OGLGETPROCADDRESS("glEnableVertexAttribArray");
1547 AssertMsgReturn(pState->ext.glEnableVertexAttribArray, ("glEnableVertexAttribArray missing"), VERR_NOT_IMPLEMENTED);
1548 pState->ext.glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)OGLGETPROCADDRESS("glDisableVertexAttribArray");
1549 AssertMsgReturn(pState->ext.glDisableVertexAttribArray, ("glDisableVertexAttribArray missing"), VERR_NOT_IMPLEMENTED);
1550 pState->ext.glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)OGLGETPROCADDRESS("glVertexAttribPointer");
1551 AssertMsgReturn(pState->ext.glVertexAttribPointer, ("glVertexAttribPointer missing"), VERR_NOT_IMPLEMENTED);
1552 pState->ext.glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)OGLGETPROCADDRESS("glFogCoordPointer");
1553 AssertMsgReturn(pState->ext.glFogCoordPointer, ("glFogCoordPointer missing"), VERR_NOT_IMPLEMENTED);
1554 pState->ext.glActiveTexture = (PFNGLACTIVETEXTUREPROC)OGLGETPROCADDRESS("glActiveTexture");
1555 AssertMsgReturn(pState->ext.glActiveTexture, ("glActiveTexture missing"), VERR_NOT_IMPLEMENTED);
1557 pState->ext.glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)OGLGETPROCADDRESS("glClientActiveTexture");
1558 AssertMsgReturn(pState->ext.glClientActiveTexture, ("glClientActiveTexture missing"), VERR_NOT_IMPLEMENTED);
1560 pState->ext.glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)OGLGETPROCADDRESS("glGetProgramivARB");
1561 AssertMsgReturn(pState->ext.glGetProgramivARB, ("glGetProgramivARB missing"), VERR_NOT_IMPLEMENTED);
1564 if (vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_draw_elements_base_vertex "))
1566 pState->ext.glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)OGLGETPROCADDRESS("glDrawElementsBaseVertex");
1567 pState->ext.glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)OGLGETPROCADDRESS("glDrawElementsInstancedBaseVertex");
1573 if (vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_provoking_vertex "))
1575 pState->ext.glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)OGLGETPROCADDRESS("glProvokingVertex");
1583 pState->ext.fEXT_stencil_two_side = vmsvga3dCheckGLExtension(pState, 2.0f, " GL_EXT_stencil_two_side ");
1585 pState->ext.fEXT_stencil_two_side = vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_stencil_two_side ");
1591 pState->caps.maxActiveLights = 1;
1592 pState->caps.maxTextureBufferSize = 65536;
1593 pState->caps.maxTextures = 1;
1594 pState->caps.maxClipDistances = 4;
1595 pState->caps.maxColorAttachments = 1;
1596 pState->caps.maxRectangleTextureSize = 2048;
1597 pState->caps.maxTextureAnisotropy = 2;
1598 pState->caps.maxVertexShaderInstructions = 1024;
1599 pState->caps.maxFragmentShaderInstructions = 1024;
1600 pState->caps.vertexShaderVersion = SVGA3DVSVERSION_NONE;
1601 pState->caps.fragmentShaderVersion = SVGA3DPSVERSION_NONE;
1602 pState->caps.flPointSize[0] = 1;
1603 pState->caps.flPointSize[1] = 1;
1608 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, glGetIntegerv(GL_MAX_LIGHTS, &pState->caps.maxActiveLights));
1609 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &pState->caps.maxTextureBufferSize));
1610 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &pState->caps.maxTextures));
1612 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pOtherCtx);
1613 VMSVGA3D_INIT_CHECKED_BOTH(pState, pOtherCtx, pContext, glGetIntegerv(GL_MAX_CLIP_DISTANCES, &pState->caps.maxClipDistances));
1614 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
1616 VMSVGA3D_INIT_CHECKED(glGetIntegerv(GL_MAX_CLIP_DISTANCES, &pState->caps.maxClipDistances));
1618 VMSVGA3D_INIT_CHECKED(glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &pState->caps.maxColorAttachments));
1619 VMSVGA3D_INIT_CHECKED(glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &pState->caps.maxRectangleTextureSize));
1620 VMSVGA3D_INIT_CHECKED(glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &pState->caps.maxTextureAnisotropy));
1621 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx, glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, pState->caps.flPointSize));
1623 if (pState->ext.glGetProgramivARB)
1625 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx,
1626 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB,
1627 &pState->caps.maxFragmentShaderTemps));
1628 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx,
1629 pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB,
1630 &pState->caps.maxFragmentShaderInstructions));
1631 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx,
1632 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB,
1633 &pState->caps.maxVertexShaderTemps));
1634 VMSVGA3D_INIT_CHECKED_BOTH(pState, pContext, pOtherCtx,
1635 pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB,
1636 &pState->caps.maxVertexShaderInstructions));
1638 pState->caps.fS3TCSupported = vmsvga3dCheckGLExtension(pState, 0.0f, " GL_EXT_texture_compression_s3tc ");
1650 if ( vmsvga3dCheckGLExtension(pState, 0.0f, " GL_NV_gpu_program4 ")
1651 || strstr(pState->pszOtherExtensions, " GL_NV_gpu_program4 "))
1653 pState->caps.vertexShaderVersion = SVGA3DVSVERSION_40;
1654 pState->caps.fragmentShaderVersion = SVGA3DPSVERSION_40;
1657 if ( vmsvga3dCheckGLExtension(pState, 0.0f, " GL_NV_vertex_program3 ")
1658 || strstr(pState->pszOtherExtensions, " GL_NV_vertex_program3 ")
1659 || vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_shader_texture_lod ") /* Wine claims this suggests SM 3.0 support */
1660 || strstr(pState->pszOtherExtensions, " GL_ARB_shader_texture_lod ")
1663 pState->caps.vertexShaderVersion = SVGA3DVSVERSION_30;
1664 pState->caps.fragmentShaderVersion = SVGA3DPSVERSION_30;
1667 if ( vmsvga3dCheckGLExtension(pState, 0.0f, " GL_ARB_fragment_program ")
1668 || strstr(pState->pszOtherExtensions, " GL_ARB_fragment_program "))
1670 pState->caps.vertexShaderVersion = SVGA3DVSVERSION_20;
1671 pState->caps.fragmentShaderVersion = SVGA3DPSVERSION_20;
1676 pState->caps.vertexShaderVersion = SVGA3DVSVERSION_11;
1677 pState->caps.fragmentShaderVersion = SVGA3DPSVERSION_11;
1680 if (!vmsvga3dCheckGLExtension(pState, 3.2f, " GL_ARB_vertex_array_bgra "))
1753 pState->caps.maxActiveLights, pState->caps.maxTextures, pState->caps.maxTextureBufferSize));
1755 pState->caps.maxClipDistances, pState->caps.maxColorAttachments, pState->caps.maxClipDistances));
1757 pState->caps.maxColorAttachments, pState->caps.maxTextureAnisotropy, pState->caps.maxRectangleTextureSize));
1759 pState->caps.maxVertexShaderTemps, pState->caps.maxVertexShaderInstructions, pState->caps.maxFragmentShaderInstructions));
1761 pState->caps.maxFragmentShaderTemps,
1762 (int)pState->caps.flPointSize[0], (int)(pState->caps.flPointSize[0] * 100) % 100,
1763 (int)pState->caps.flPointSize[1], (int)(pState->caps.flPointSize[1] * 100) % 100));
1765 pState->caps.fragmentShaderVersion, pState->caps.vertexShaderVersion, pState->caps.fS3TCSupported));
1769 pState->ShaderIf.pfnSwitchInitProfile = vmsvga3dShaderIfSwitchInitProfile;
1770 pState->ShaderIf.pfnGetNextExtension = vmsvga3dShaderIfGetNextExtension;
1771 rc = ShaderInitLib(&pState->ShaderIf);
1782 if ( pState->fGLVersion < 3.0
1783 && pState->fOtherGLVersion < 3.0 /* darwin: legacy profile hack */)
1788 if ( !pState->ext.glIsRenderbuffer
1789 || !pState->ext.glBindRenderbuffer
1790 || !pState->ext.glDeleteRenderbuffers
1791 || !pState->ext.glGenRenderbuffers
1792 || !pState->ext.glRenderbufferStorage
1793 || !pState->ext.glGetRenderbufferParameteriv
1794 || !pState->ext.glIsFramebuffer
1795 || !pState->ext.glBindFramebuffer
1796 || !pState->ext.glDeleteFramebuffers
1797 || !pState->ext.glGenFramebuffers
1798 || !pState->ext.glCheckFramebufferStatus
1799 || !pState->ext.glFramebufferTexture1D
1800 || !pState->ext.glFramebufferTexture2D
1801 || !pState->ext.glFramebufferTexture3D
1802 || !pState->ext.glFramebufferRenderbuffer
1803 || !pState->ext.glGetFramebufferAttachmentParameteriv
1804 || !pState->ext.glGenerateMipmap
1805 || !pState->ext.glBlitFramebuffer
1806 || !pState->ext.glRenderbufferStorageMultisample
1807 || !pState->ext.glFramebufferTextureLayer)
1814 pState->idTestContext = SVGA_ID_INVALID;
1821 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
1825 for (uint32_t i = 0; i < pState->cSurfaces; i++)
1827 if (pState->papSurfaces[i]->id != SVGA3D_INVALID_ID)
1828 vmsvga3dSurfaceDestroy(pThis, pState->papSurfaces[i]->id);
1832 for (uint32_t i = 0; i < pState->cContexts; i++)
1834 if (pState->papContexts[i]->id != SVGA3D_INVALID_ID)
1835 vmsvga3dContextDestroy(pThis, pState->papContexts[i]->id);
1842 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
1843 AssertReturn(pState, VERR_WRONG_ORDER);
1855 rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_EXIT, 0, 0);
1858 RTSemEventDestroy(pState->WndRequestSem);
1863 pState->bTerminate = true;
1865 rc = RTThreadWait(pState->pWindowThread, 10000, NULL);
1867 XCloseDisplay(pState->display);
1870 RTStrFree(pState->pszExtensions);
1871 pState->pszExtensions = NULL;
1873 RTStrFree(pState->pszOtherExtensions);
1875 pState->pszOtherExtensions = NULL;
2014 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
2015 AssertReturn(pState, VERR_NO_MEMORY);
2034 *pu32Val = pState->caps.maxActiveLights;
2038 *pu32Val = pState->caps.maxTextures;
2042 *pu32Val = pState->caps.maxClipDistances;
2047 *pu32Val = pState->caps.vertexShaderVersion;
2052 *pu32Val = (pState->caps.vertexShaderVersion != SVGA3DVSVERSION_NONE);
2057 *pu32Val = pState->caps.fragmentShaderVersion;
2062 *pu32Val = (pState->caps.fragmentShaderVersion != SVGA3DPSVERSION_NONE);
2095 *(float *)pu32Val = pState->caps.flPointSize[1];
2106 *pu32Val = pState->caps.maxRectangleTextureSize;
2124 *pu32Val = pState->caps.maxTextureAnisotropy;
2134 *pu32Val = pState->caps.maxVertexShaderInstructions;
2138 *pu32Val = pState->caps.maxFragmentShaderInstructions;
2143 *pu32Val = pState->caps.maxVertexShaderTemps;
2148 *pu32Val = pState->caps.maxFragmentShaderTemps;
2175 *pu32Val = pState->caps.maxColorAttachments;
2231 *pu32Val = vmsvga3dGetSurfaceFormatSupport(pState, idx3dCaps);
2259 *pu32Val = vmsvga3dGetSurfaceFormatSupport(pState, idx3dCaps);
2615 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
2616 AssertReturn(pState, VERR_NO_MEMORY);
2627 if (sid >= pState->cSurfaces)
2631 void *pvNew = RTMemRealloc(pState->papSurfaces, sizeof(pState->papSurfaces[0]) * cNew);
2633 pState->papSurfaces = (PVMSVGA3DSURFACE *)pvNew;
2634 while (pState->cSurfaces < cNew)
2639 pState->papSurfaces[pState->cSurfaces++] = pSurface;
2642 pSurface = pState->papSurfaces[sid];
2807 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
2808 AssertReturn(pState, VERR_NO_MEMORY);
2810 if ( sid < pState->cSurfaces
2811 && pState->papSurfaces[sid]->id == sid)
2813 PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
2820 for (uint32_t cid = 0; cid < pState->cContexts; cid++)
2822 pContext = pState->papContexts[cid];
2835 pContext = &pState->SharedCtx;
2836 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
2840 if ( cid <= pState->cContexts
2841 && pState->papContexts[cid]->id == cid)
2843 pContext = pState->papContexts[cid];
2844 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
2850 for (cid = 0; cid < pState->cContexts; cid++)
2852 if (pState->papContexts[cid]->id == cid)
2854 pContext = pState->papContexts[cid];
2855 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
2873 pState->ext.glDeleteBuffers(1, &pSurface->oglId.buffer);
2874 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
2883 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
2892 pState->ext.glDeleteRenderbuffers(1, &pSurface->oglId.renderbuffer);
2893 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
2926 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
2931 AssertReturn(pState, VERR_NO_MEMORY);
2933 AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
2935 AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
2966 * @param pState The VMSVGA3D state structure.
2971 static void vmsvga3dSetUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
2978 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &pSave->iAlignment), pState, pContext);
2980 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &pSave->cxRow), pState, pContext);
3018 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1), pState, pContext);
3020 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0), pState, pContext);
3023 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0), pState, pContext);
3025 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE), pState, pContext);
3027 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE), pState, pContext);
3029 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0), pState, pContext);
3031 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0), pState, pContext);
3033 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0), pState, pContext);
3041 * @param pState The VMSVGA3D state structure.
3046 static void vmsvga3dRestoreUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
3051 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, pSave->iAlignment), pState, pContext);
3053 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, pSave->cxRow), pState, pContext);
3056 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, pSave->cyImage), pState, pContext);
3058 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SWAP_BYTES, pSave->fSwapBytes), pState, pContext);
3060 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_LSB_FIRST, pSave->fLsbFirst), pState, pContext);
3062 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_ROWS, pSave->cSkipRows), pState, pContext);
3064 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS, pSave->cSkipPixels), pState, pContext);
3066 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_IMAGES, pSave->cSkipImages), pState, pContext);
3072 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext,
3077 uint32_t idPrevCtx = pState->idActiveContext;
3078 pContext = &pState->SharedCtx;
3079 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3083 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3087 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3091 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3095 vmsvga3dSetUnpackParams(pState, pContext, pSurface, &SavedParams);
3118 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3139 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3143 vmsvga3dRestoreUnpackParams(pState, pContext, pSurface, &SavedParams);
3147 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3157 if (idPrevCtx < pState->cContexts && pState->papContexts[idPrevCtx]->id == idPrevCtx)
3159 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pState->papContexts[idPrevCtx]);
3168 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
3177 AssertReturn(pState, VERR_NO_MEMORY);
3179 AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
3181 AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
3183 pSurfaceSrc = pState->papSurfaces[sidSrc];
3184 pSurfaceDest = pState->papSurfaces[sidDest];
3193 pContext = &pState->SharedCtx;
3194 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3205 if ( cid >= pState->cContexts
3206 || pState->papContexts[cid]->id != cid)
3211 pContext = pState->papContexts[cid];
3212 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3219 rc = vmsvga3dCreateTexture(pState, pContext, cid, pSurfaceSrc);
3227 rc = vmsvga3dCreateTexture(pState, pContext, cid, pSurfaceDest);
3232 pState->ext.glBindFramebuffer(GL_READ_FRAMEBUFFER, pContext->idReadFramebuffer);
3233 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3234 pState->ext.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pContext->idDrawFramebuffer);
3235 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3238 pState->ext.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
3240 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3241 pState->ext.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
3243 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3249 pState->ext.glBlitFramebuffer(srcBox.x,
3275 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3278 pState->ext.glBindFramebuffer(GL_FRAMEBUFFER, pContext->idFramebuffer);
3279 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3288 * @param pState The VMSVGA3D state structure.
3293 static void vmsvga3dSetPackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
3300 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &pSave->iAlignment), pState, pContext);
3302 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &pSave->cxRow), pState, pContext);
3340 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ALIGNMENT, 1), pState, pContext);
3342 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ROW_LENGTH, 0), pState, pContext);
3345 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0), pState, pContext);
3347 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE), pState, pContext);
3349 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE), pState, pContext);
3351 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_ROWS, 0), pState, pContext);
3353 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_PIXELS, 0), pState, pContext);
3355 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_IMAGES, 0), pState, pContext);
3363 * @param pState The VMSVGA3D state structure.
3368 static void vmsvga3dRestorePackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
3373 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ALIGNMENT, pSave->iAlignment), pState, pContext);
3375 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ROW_LENGTH, pSave->cxRow), pState, pContext);
3378 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_IMAGE_HEIGHT, pSave->cyImage), pState, pContext);
3380 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SWAP_BYTES, pSave->fSwapBytes), pState, pContext);
3382 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_LSB_FIRST, pSave->fLsbFirst), pState, pContext);
3384 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_ROWS, pSave->cSkipRows), pState, pContext);
3386 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_PIXELS, pSave->cSkipPixels), pState, pContext);
3388 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_IMAGES, pSave->cSkipImages), pState, pContext);
3396 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
3402 AssertReturn(pState, VERR_NO_MEMORY);
3404 AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
3406 pSurface = pState->papSurfaces[sid];
3481 PVMSVGA3DCONTEXT pContext = &pState->SharedCtx;
3485 if ( cid >= pState->cContexts
3486 || pState->papContexts[cid]->id != cid)
3488 Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id));
3491 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid];
3493 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3542 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3545 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3549 vmsvga3dSetPackParams(pState, pContext, pSurface, &SavedParams);
3556 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3558 vmsvga3dRestorePackParams(pState, pContext, pSurface, &SavedParams);
3562 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3612 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3616 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3622 vmsvga3dSetUnpackParams(pState, pContext, pSurface, &SavedParams); /** @todo do we need to set ROW_LENGTH to w here? */
3634 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3637 vmsvga3dRestoreUnpackParams(pState, pContext, pSurface, &SavedParams);
3641 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
3661 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pSurface->oglId.buffer);
3665 uint8_t *pbData = (uint8_t *)pState->ext.glMapBuffer(GL_ARRAY_BUFFER, enmGlTransfer);
3707 pState->ext.glUnmapBuffer(GL_ARRAY_BUFFER);
3708 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3711 VMSVGA3D_GL_GET_AND_COMPLAIN(pState, pContext, ("glMapBuffer(GL_ARRAY_BUFFER, %#x) -> NULL\n", enmGlTransfer));
3714 VMSVGA3D_GL_COMPLAIN(pState, pContext, ("glBindBuffer(GL_ARRAY_BUFFER, %#x)\n", pSurface->oglId.buffer));
3715 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, 0);
3716 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3808 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
3815 AssertReturn(pState, VERR_NO_MEMORY);
3817 AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
3819 pSurface = pState->papSurfaces[sid];
3832 pContext = &pState->SharedCtx;
3833 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3838 if ( cid >= pState->cContexts
3839 || pState->papContexts[cid]->id != cid)
3844 pContext = pState->papContexts[cid];
3845 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3852 rc = vmsvga3dCreateTexture(pState, pContext, cid, pSurface);
3862 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3866 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3869 pState->ext.glGenerateMipmap(GL_TEXTURE_2D);
3870 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3874 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3881 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
3894 AssertReturn(pState, VERR_NO_MEMORY);
3896 AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
3898 pSurface = pState->papSurfaces[sid];
3910 pContext = &pState->SharedCtx;
3911 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3921 if ( cid >= pState->cContexts
3922 || pState->papContexts[cid]->id != cid)
3927 pContext = pState->papContexts[cid];
3928 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
3995 pState->ext.glBindFramebuffer(GL_READ_FRAMEBUFFER, pContext->idReadFramebuffer);
3996 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
3997 pState->ext.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 /* back buffer */);
3998 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4000 pState->ext.glActiveTexture(GL_TEXTURE0);
4003 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4079 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4095 pState->ext.glBindFramebuffer(GL_FRAMEBUFFER, pContext->idFramebuffer);
4096 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4100 pState->ext.glBindFramebuffer(GL_READ_FRAMEBUFFER, pContext->idReadFramebuffer);
4101 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
4102 pState->ext.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 /* back buffer */);
4103 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
4106 pState->ext.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pSurface->oglId.texture, 0 /* level 0 */);
4107 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
4113 pState->ext.glBlitFramebuffer(srcViewPort.x,
4123 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
4138 pState->ext.glBlitFramebuffer(RT_MAX(pRect[i].srcx, srcViewPort.x),
4151 pState->ext.glBindFramebuffer(GL_FRAMEBUFFER, pContext->idFramebuffer);
4152 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
4165 XMapWindow(pState->display, pContext->window);
4169 glXSwapBuffers(pState->display, pContext->window);
4178 * @param pvUser pointer to pState structure
4183 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pvUser;
4184 while (!pState->bTerminate)
4186 while (XPending(pState->display) > 0)
4189 XNextEvent(pState->display, &event);
4217 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4219 AssertReturn(pState, VERR_NO_MEMORY);
4232 if (pState->idTestContext == SVGA_ID_INVALID)
4234 pState->idTestContext = 207;
4235 rc = vmsvga3dContextDefine(pThis, pState->idTestContext);
4242 pContext = &pState->SharedCtx;
4246 if (cid >= pState->cContexts)
4250 void *pvNew = RTMemRealloc(pState->papContexts, sizeof(pState->papContexts[0]) * cNew);
4252 pState->papContexts = (PVMSVGA3DCONTEXT *)pvNew;
4253 while (pState->cContexts < cNew)
4258 pState->papContexts[pState->cContexts++] = pContext;
4262 if (pState->papContexts[cid]->id != SVGA3D_INVALID_ID)
4265 pContext = pState->papContexts[cid];
4275 pSharedCtx = &pState->SharedCtx;
4286 for (uint32_t i = 0; i < pState->cContexts; i++)
4287 if ( pState->papContexts[i]->id != SVGA3D_INVALID_ID
4290 && pState->papContexts[i]->fOtherProfile == RT_BOOL(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE)
4295 pSharedCtx = pState->papContexts[i];
4346 cs.hInstance = pState->hInstance;
4348 rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_CREATEWINDOW, (WPARAM)&pContext->hwnd, (LPARAM)&cs);
4405 if (pState->display == NULL)
4408 pState->display = XOpenDisplay(0);
4409 Assert(pState->display);
4411 Bool ret = glXQueryVersion(pState->display, &glxMajor, &glxMinor);
4414 rc = RTThreadCreate(&pState->pWindowThread, vmsvga3dXEventThread, pState, 0, RTTHREADTYPE_GUI, RTTHREADFLAGS_WAITABLE, "VMSVGA3DXEVENT");
4431 XVisualInfo *vi = glXChooseVisual(pState->display, DefaultScreen(pState->display), attrib);
4433 swa.colormap = XCreateColormap(pState->display, XDefaultRootWindow(pState->display), vi->visual, AllocNone);
4438 pContext->window = XCreateWindow(pState->display, hostWindow,//XDefaultRootWindow(pState->display),//hostWindow,
4448 pContext->glxContext = glXCreateContext(pState->display, vi, shareContext, GL_TRUE);
4452 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4455 if (pState->ext.glGenFramebuffers)
4458 pState->ext.glGenFramebuffers(1, &pContext->idFramebuffer);
4459 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4462 pState->ext.glBindFramebuffer(GL_FRAMEBUFFER, pContext->idFramebuffer);
4463 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4466 pState->ext.glGenFramebuffers(1, &pContext->idReadFramebuffer);
4467 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4469 pState->ext.glGenFramebuffers(1, &pContext->idDrawFramebuffer);
4470 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4476 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4485 if (pState->ext.glProvokingVertex)
4486 pState->ext.glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
4515 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4516 AssertReturn(pState, VERR_NO_MEMORY);
4520 if ( cid < pState->cContexts
4521 && pState->papContexts[cid]->id == cid)
4523 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid];
4527 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4560 for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
4562 PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
4604 pState->ext.glBindFramebuffer(GL_FRAMEBUFFER, 0 /* back buffer */);
4605 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4606 pState->ext.glDeleteFramebuffers(1, &pContext->idFramebuffer);
4607 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4611 pState->ext.glDeleteFramebuffers(1, &pContext->idReadFramebuffer);
4612 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4616 pState->ext.glDeleteFramebuffers(1, &pContext->idDrawFramebuffer);
4617 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4626 int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_DESTROYWINDOW, (WPARAM)pContext->hwnd, 0);
4632 glXMakeCurrent(pState->display, None, NULL);
4633 glXDestroyContext(pState->display, pContext->glxContext);
4634 XDestroyWindow(pState->display, pContext->window);
4640 VMSVGA3D_CLEAR_CURRENT_CONTEXT(pState);
4651 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4652 AssertReturn(pState, VERR_NO_MEMORY);
4655 for (uint32_t i = 0; i < pState->cContexts; i++)
4657 PVMSVGA3DCONTEXT pContext = pState->papContexts[i];
4670 int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_RESIZEWINDOW, (WPARAM)pContext->hwnd, (LPARAM)&cs);
4678 XConfigureWindow(pState->display, pContext->window, CWWidth | CWHeight, &wc);
4689 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4690 AssertReturn(pState, VERR_NO_MEMORY);
4695 if ( cid >= pState->cContexts
4696 || pState->papContexts[cid]->id != cid)
4701 pContext = pState->papContexts[cid];
4702 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4722 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4735 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4737 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4758 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4797 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4798 AssertReturn(pState, VERR_NO_MEMORY);
4802 if ( cid >= pState->cContexts
4803 || pState->papContexts[cid]->id != cid)
4808 pContext = pState->papContexts[cid];
4809 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4820 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
4939 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
4940 AssertReturn(pState, VERR_NO_MEMORY);
4944 if ( cid >= pState->cContexts
4945 || pState->papContexts[cid]->id != cid)
4950 pContext = pState->papContexts[cid];
4951 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
4970 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5009 if (pRenderState[i].floatValue < pState->caps.flPointSize[0])
5010 pRenderState[i].floatValue = pState->caps.flPointSize[0];
5011 if (pRenderState[i].floatValue > pState->caps.flPointSize[1])
5012 pRenderState[i].floatValue = pState->caps.flPointSize[1];
5015 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5020 pState->ext.glPointParameterf(GL_POINT_SIZE_MIN, pRenderState[i].floatValue);
5021 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5026 pState->ext.glPointParameterf(GL_POINT_SIZE_MAX, pRenderState[i].floatValue);
5027 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5045 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5058 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5070 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5076 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5081 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5086 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5091 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5139 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5143 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5177 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5198 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5218 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5253 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5255 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5257 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5259 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5282 pState->ext.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
5285 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5292 pState->ext.glBlendEquationSeparate(vmsvga3dBlendEquation2GL(pContext->state.aRenderState[SVGA3D_RS_BLENDEQUATION].uintValue),
5299 pState->ext.glBlendEquation(vmsvga3dBlendEquation2GL(pRenderState[i].uintValue));
5302 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5314 pState->ext.glBlendColor(red, green, blue, alpha);
5316 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5345 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5355 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5363 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5365 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5374 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5376 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5393 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5395 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5397 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5420 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5426 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5437 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5439 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5441 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5460 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5466 if (pState->ext.fEXT_stencil_two_side)
5484 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5486 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5488 pState->ext.glStencilFuncSeparate(GL_BACK, vmsvgaCmpFunc2GL(pRenderState[i].uintValue), ref, mask);
5489 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5504 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5506 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5508 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5526 pState->ext.glStencilOpSeparate(GL_BACK, sfail, dpfail, dppass);
5527 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5547 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5550 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5562 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5565 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5582 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5666 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5769 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
5772 AssertReturn(pState, VERR_NO_MEMORY);
5779 if ( cid >= pState->cContexts
5780 || pState->papContexts[cid]->id != cid)
5785 pContext = pState->papContexts[cid];
5786 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
5798 pState->ext.glFramebufferRenderbuffer(GL_FRAMEBUFFER, (type == SVGA3D_RT_DEPTH) ? GL_DEPTH_ATTACHMENT : GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
5799 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5811 pState->ext.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + type - SVGA3D_RT_COLOR0, 0, 0, 0);
5812 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5822 AssertReturn(target.sid < pState->cSurfaces && pState->papSurfaces[target.sid]->id == target.sid, VERR_INVALID_PARAMETER);
5823 pRenderTarget = pState->papSurfaces[target.sid];
5833 pContext = &pState->SharedCtx;
5834 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
5836 pState->ext.glGenRenderbuffers(1, &pRenderTarget->oglId.renderbuffer);
5837 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5839 pState->ext.glBindRenderbuffer(GL_RENDERBUFFER, pRenderTarget->oglId.renderbuffer);
5840 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5842 pState->ext.glRenderbufferStorage(GL_RENDERBUFFER,
5846 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5849 pState->ext.glBindRenderbuffer(GL_RENDERBUFFER, OPENGL_INVALID_ID);
5850 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5852 pContext = pState->papContexts[cid];
5853 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
5863 pState->ext.glBindRenderbuffer(GL_RENDERBUFFER, pRenderTarget->oglId.renderbuffer);
5864 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5874 pState->ext.glFramebufferRenderbuffer(GL_FRAMEBUFFER,
5877 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5893 int rc = vmsvga3dCreateTexture(pState, pContext, cid, pRenderTarget);
5902 pState->ext.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + type - SVGA3D_RT_COLOR0, GL_TEXTURE_2D, pRenderTarget->oglId.texture, target.mipmap);
5903 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
5908 GLenum status = pState->ext.glCheckFramebufferStatus(GL_FRAMEBUFFER);
6097 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6098 AssertReturn(pState, VERR_NO_MEMORY);
6102 if ( cid >= pState->cContexts
6103 || pState->papContexts[cid]->id != cid)
6108 pContext = pState->papContexts[cid];
6109 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6131 pState->ext.glActiveTexture(GL_TEXTURE0 + pTextureState[i].stage);
6132 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6186 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6189 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6196 AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
6198 PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
6210 int rc = vmsvga3dCreateTexture(pState, pContext, cid, pSurface);
6215 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6219 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6299 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6305 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6341 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6351 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6352 AssertReturn(pState, VERR_NO_MEMORY);
6357 if ( cid >= pState->cContexts
6358 || pState->papContexts[cid]->id != cid)
6363 pContext = pState->papContexts[cid];
6364 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6395 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6404 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6405 AssertReturn(pState, VERR_NO_MEMORY);
6410 if ( cid >= pState->cContexts
6411 || pState->papContexts[cid]->id != cid)
6416 pContext = pState->papContexts[cid];
6417 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6462 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6465 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6469 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6472 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6475 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6493 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6501 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6530 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6533 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6537 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6540 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6543 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6559 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6562 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6565 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
6584 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6585 AssertReturn(pState, VERR_NO_MEMORY);
6589 if ( cid >= pState->cContexts
6590 || pState->papContexts[cid]->id != cid)
6595 pContext = pState->papContexts[cid];
6596 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6614 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6621 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6622 AssertReturn(pState, VERR_NO_MEMORY);
6626 if ( cid >= pState->cContexts
6627 || pState->papContexts[cid]->id != cid)
6632 pContext = pState->papContexts[cid];
6633 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6641 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6667 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6668 AssertReturn(pState, VERR_NO_MEMORY);
6674 if ( cid >= pState->cContexts
6675 || pState->papContexts[cid]->id != cid)
6680 pContext = pState->papContexts[cid];
6681 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6694 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6702 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6703 AssertReturn(pState, VERR_NO_MEMORY);
6707 if ( cid >= pState->cContexts
6708 || pState->papContexts[cid]->id != cid)
6713 pContext = pState->papContexts[cid];
6714 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6721 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6740 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
6741 AssertReturn(pState, VERR_NO_MEMORY);
6746 if ( cid >= pState->cContexts
6747 || pState->papContexts[cid]->id != cid)
6752 pContext = pState->papContexts[cid];
6753 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6792 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6794 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6802 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6943 int vmsvga3dDrawPrimitivesProcessVertexDecls(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl)
6949 AssertReturn(sidVertex < pState->cSurfaces && pState->papSurfaces[sidVertex]->id == sidVertex, VERR_INVALID_PARAMETER);
6951 pVertexSurface = pState->papSurfaces[sidVertex];
6960 pContext = &pState->SharedCtx;
6961 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6964 pState->ext.glGenBuffers(1, &pVertexSurface->oglId.buffer);
6965 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6967 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pVertexSurface->oglId.buffer);
6968 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6972 pState->ext.glBufferData(GL_ARRAY_BUFFER, pVertexSurface->pMipmapLevels[0].cbSurface, pVertexSurface->pMipmapLevels[0].pSurfaceData, GL_DYNAMIC_DRAW);
6973 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6981 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, OPENGL_INVALID_ID);
6982 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
6985 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
6993 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pVertexSurface->oglId.buffer);
6994 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7017 pState->ext.glEnableVertexAttribArray(index);
7018 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7019 pState->ext.glVertexAttribPointer(index, size, type, normalized, pVertexDecl[iVertex].array.stride,
7021 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7031 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7034 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7044 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7047 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7057 pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
7060 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7063 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7079 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7082 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7086 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7087 pState->ext.glFogCoordPointer(type, pVertexDecl[iVertex].array.stride,
7089 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7110 int vmsvga3dDrawPrimitivesCleanupVertexDecls(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl)
7118 pState->ext.glDisableVertexAttribArray(iVertexDeclBase + iVertex);
7119 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7128 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7136 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7145 pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
7148 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7160 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7164 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7175 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, 0);
7176 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7183 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
7184 AssertReturn(pState, VERR_INTERNAL_ERROR);
7196 if ( cid >= pState->cContexts
7197 || pState->papContexts[cid]->id != cid)
7202 pContext = pState->papContexts[cid];
7203 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7212 PVMSVGA3DSURFACE pRenderTarget = pState->papSurfaces[pContext->sidRenderTarget];
7235 rc = vmsvga3dDrawPrimitivesProcessVertexDecls(pState, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]);
7262 || sidIndex >= pState->cSurfaces
7263 || pState->papSurfaces[sidIndex]->id != sidIndex)
7266 Assert(sidIndex < pState->cSurfaces && pState->papSurfaces[sidIndex]->id == sidIndex);
7270 pIndexSurface = pState->papSurfaces[sidIndex];
7277 pContext = &pState->SharedCtx;
7278 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7281 pState->ext.glGenBuffers(1, &pIndexSurface->oglId.buffer);
7282 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7284 pState->ext.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pIndexSurface->oglId.buffer);
7285 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7290 pState->ext.glBufferData(GL_ELEMENT_ARRAY_BUFFER, pIndexSurface->pMipmapLevels[0].cbSurface, pIndexSurface->pMipmapLevels[0].pSurfaceData, GL_DYNAMIC_DRAW);
7291 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7299 pState->ext.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OPENGL_INVALID_ID);
7300 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7302 pContext = pState->papContexts[cid];
7303 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7312 pState->ext.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pIndexSurface->oglId.buffer);
7313 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7340 pState->ext.glDrawElementsBaseVertex(modeDraw,
7347 pState->ext.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
7348 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7350 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
7371 rc = vmsvga3dDrawPrimitivesCleanupVertexDecls(pState, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]);
7385 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
7386 pState->ext.glActiveTexture(GL_TEXTURE0 + i);
7387 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
7390 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
7391 pState->ext.glActiveTexture(activeTextureUnit);
7392 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
7398 pTexture = pState->papSurfaces[pContext->aSidActiveTexture[activeTextureUnit - GL_TEXTURE0]];
7403 PVMSVGA3DSURFACE pTexture = pState->papSurfaces[pContext->aSidActiveTexture[i]];
7432 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
7433 AssertReturn(pState, VERR_NO_MEMORY);
7439 if ( cid >= pState->cContexts
7440 || pState->papContexts[cid]->id != cid)
7445 pContext = pState->papContexts[cid];
7446 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7532 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
7533 AssertReturn(pState, VERR_NO_MEMORY);
7539 if ( cid >= pState->cContexts
7540 || pState->papContexts[cid]->id != cid)
7545 pContext = pState->papContexts[cid];
7546 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7586 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
7587 AssertReturn(pState, VERR_NO_MEMORY);
7592 if ( cid >= pState->cContexts
7593 || pState->papContexts[cid]->id != cid)
7598 pContext = pState->papContexts[cid];
7599 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
7659 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
7660 AssertReturn(pState, VERR_NO_MEMORY);
7665 if ( cid >= pState->cContexts
7666 || pState->papContexts[cid]->id != cid)
7671 pContext = pState->papContexts[cid];
7672 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);