Changeset 69905 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Dec 2, 2017 9:27:46 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119382
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r69859 r69905 831 831 /* Occlusion query. */ 832 832 VMSVGA3DQUERY occlusion; 833 834 #ifdef VMSVGA3D_DIRECT3D 835 /* State which is currently applied to the D3D device. It is recreated as needed and not saved. 836 * The purpose is to remember the currently applied state and do not re-apply it if it has not changed. 837 * Unnecessary state changes are very bad for performance. 838 */ 839 struct 840 { 841 /* Vertex declaration. */ 842 IDirect3DVertexDeclaration9 *pVertexDecl; 843 uint32_t cVertexElements; 844 D3DVERTEXELEMENT9 aVertexElements[SVGA3D_MAX_VERTEX_ARRAYS + 1]; 845 } d3dState; 846 #endif 833 847 } VMSVGA3DCONTEXT; 834 848 /** Pointer to a VMSVGA3d context. */ -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r69904 r69905 2893 2893 Log(("vmsvga3dContextDestroy id %x\n", cid)); 2894 2894 2895 /* Cleanup the device runtime state. */ 2896 D3D_RELEASE(pContext->d3dState.pVertexDecl); 2897 2895 2898 /* Check for all surfaces that are associated with this context to remove all dependencies */ 2896 2899 for (uint32_t sid = 0; sid < pState->cSurfaces; sid++) … … 3165 3168 } 3166 3169 #endif /* #ifdef VMSVGA3D_DIRECT3D9_RESET */ 3170 3171 /* Cleanup the device runtime state. */ 3172 D3D_RELEASE(pContext->d3dState.pVertexDecl); 3173 3167 3174 memset(&cs, 0, sizeof(cs)); 3168 3175 cs.cx = pThis->svga.uWidth; … … 5810 5817 memcpy(&aVertexElements[numVertexDecls], &sVertexEnd, sizeof(sVertexEnd)); 5811 5818 5812 /* Create and set the vertex declaration. */ 5813 IDirect3DVertexDeclaration9 *pVertexDeclD3D = NULL; 5814 hr = pContext->pDevice->CreateVertexDeclaration(&aVertexElements[0], &pVertexDeclD3D); 5815 AssertMsgReturn(hr == D3D_OK, ("CreateVertexDeclaration failed with %x\n", hr), VERR_INTERNAL_ERROR); 5816 5817 hr = pContext->pDevice->SetVertexDeclaration(pVertexDeclD3D); 5818 AssertMsgReturnStmt(hr == D3D_OK, ("SetVertexDeclaration failed with %x\n", hr), 5819 D3D_RELEASE(pVertexDeclD3D), VERR_INTERNAL_ERROR); 5819 /* Check if this context already has the same vertex declaration. */ 5820 if ( pContext->d3dState.pVertexDecl 5821 && pContext->d3dState.cVertexElements == numVertexDecls + 1 5822 && memcmp(pContext->d3dState.aVertexElements, 5823 aVertexElements, 5824 pContext->d3dState.cVertexElements * sizeof(aVertexElements[0])) == 0) 5825 { 5826 /* Same. */ 5827 } 5828 else 5829 { 5830 D3D_RELEASE(pContext->d3dState.pVertexDecl); 5831 5832 pContext->d3dState.cVertexElements = numVertexDecls + 1; 5833 memcpy(pContext->d3dState.aVertexElements, 5834 aVertexElements, 5835 pContext->d3dState.cVertexElements * sizeof(aVertexElements[0])); 5836 5837 /* Create and set the vertex declaration. */ 5838 hr = pContext->pDevice->CreateVertexDeclaration(&aVertexElements[0], &pContext->d3dState.pVertexDecl); 5839 AssertMsgReturn(hr == D3D_OK, ("CreateVertexDeclaration failed with %x\n", hr), VERR_INTERNAL_ERROR); 5840 5841 hr = pContext->pDevice->SetVertexDeclaration(pContext->d3dState.pVertexDecl); 5842 AssertMsgReturnStmt(hr == D3D_OK, ("SetVertexDeclaration failed with %x\n", hr), 5843 D3D_RELEASE(pContext->d3dState.pVertexDecl), 5844 VERR_INTERNAL_ERROR); 5845 } 5820 5846 5821 5847 /* Begin a scene before rendering anything. */ 5822 5848 hr = pContext->pDevice->BeginScene(); 5823 AssertMsgReturnStmt(hr == D3D_OK, ("BeginScene failed with %x\n", hr), 5824 D3D_RELEASE(pVertexDeclD3D), VERR_INTERNAL_ERROR); 5849 AssertMsgReturn(hr == D3D_OK, ("BeginScene failed with %x\n", hr), VERR_INTERNAL_ERROR); 5825 5850 5826 5851 /* Now draw the primitives. */ … … 5919 5944 } 5920 5945 5921 /* Release vertex declaration, end the scene and do some cleanup regardless of the rc. */ 5922 D3D_RELEASE(pVertexDeclD3D); 5923 5946 /* End the scene and do some cleanup regardless of the rc. */ 5924 5947 hr = pContext->pDevice->EndScene(); 5925 5948 AssertMsgReturn(hr == D3D_OK, ("EndScene failed with %x\n", hr), VERR_INTERNAL_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.