Changeset 94063 in vbox for trunk/src/VBox
- Timestamp:
- Mar 2, 2022 3:41:38 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp
r93115 r94063 205 205 RT_UNTRUSTED_VALIDATED_FENCE(); 206 206 207 uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN; 208 SVGA3dConstantBufferBinding *pCBB = &pDXContext->svgaDXContext.shaderState[idxShaderState].constantBuffers[pCmd->slot]; 209 pCBB->sid = pCmd->sid; 210 pCBB->offsetInBytes = pCmd->offsetInBytes; 211 pCBB->sizeInBytes = pCmd->sizeInBytes; 212 207 213 rc = pSvgaR3State->pFuncsDX->pfnDXSetSingleConstantBuffer(pThisCC, pDXContext, pCmd->slot, pCmd->type, pCmd->sid, pCmd->offsetInBytes, pCmd->sizeInBytes); 208 if (RT_SUCCESS(rc))209 {210 uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;211 SVGA3dConstantBufferBinding *pCBB = &pDXContext->svgaDXContext.shaderState[idxShaderState].constantBuffers[pCmd->slot];212 pCBB->sid = pCmd->sid;213 pCBB->offsetInBytes = pCmd->offsetInBytes;214 pCBB->sizeInBytes = pCmd->sizeInBytes;215 }216 214 return rc; 217 215 } … … 238 236 || paShaderResourceViewId[i] == SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER); 239 237 RT_UNTRUSTED_VALIDATED_FENCE(); 238 239 uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN; 240 for (uint32_t i = 0; i < cShaderResourceViewId; ++i) 241 { 242 SVGA3dShaderResourceViewId const shaderResourceViewId = paShaderResourceViewId[i]; 243 pDXContext->svgaDXContext.shaderState[idxShaderState].shaderResources[pCmd->startView + i] = shaderResourceViewId; 244 } 240 245 241 246 rc = pSvgaR3State->pFuncsDX->pfnDXSetShaderResources(pThisCC, pDXContext, pCmd->startView, pCmd->type, cShaderResourceViewId, paShaderResourceViewId); … … 517 522 AssertRCReturn(rc, rc); 518 523 524 pDXContext->svgaDXContext.inputAssembly.indexBufferSid = pCmd->sid; 525 pDXContext->svgaDXContext.inputAssembly.indexBufferOffset = pCmd->offset; 526 pDXContext->svgaDXContext.inputAssembly.indexBufferFormat = pCmd->format; 527 519 528 rc = pSvgaR3State->pFuncsDX->pfnDXSetIndexBuffer(pThisCC, pDXContext, pCmd->sid, pCmd->format, pCmd->offset); 520 if (RT_SUCCESS(rc))521 {522 pDXContext->svgaDXContext.inputAssembly.indexBufferSid = pCmd->sid;523 pDXContext->svgaDXContext.inputAssembly.indexBufferOffset = pCmd->offset;524 pDXContext->svgaDXContext.inputAssembly.indexBufferFormat = pCmd->format;525 }526 529 return rc; 527 530 } … … 542 545 ASSERT_GUEST_RETURN(topology >= SVGA3D_PRIMITIVE_MIN && topology < SVGA3D_PRIMITIVE_MAX, VERR_INVALID_PARAMETER); 543 546 547 pDXContext->svgaDXContext.inputAssembly.topology = topology; 548 544 549 rc = pSvgaR3State->pFuncsDX->pfnDXSetTopology(pThisCC, pDXContext, topology); 545 if (RT_SUCCESS(rc))546 pDXContext->svgaDXContext.inputAssembly.topology = topology;547 550 return rc; 548 551 } … … 569 572 RT_UNTRUSTED_VALIDATED_FENCE(); 570 573 574 pDXContext->svgaDXContext.renderState.depthStencilViewId = depthStencilViewId; 575 for (uint32_t i = 0; i < cRenderTargetViewId; ++i) 576 pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = paRenderTargetViewId[i]; 577 571 578 rc = pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets(pThisCC, pDXContext, depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId); 572 if (RT_SUCCESS(rc))573 {574 pDXContext->svgaDXContext.renderState.depthStencilViewId = depthStencilViewId;575 for (uint32_t i = 0; i < cRenderTargetViewId; ++i)576 pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = paRenderTargetViewId[i];577 }578 579 return rc; 579 580 } … … 1062 1063 RT_ZERO(*pEntry); 1063 1064 1065 for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i) 1066 { 1067 if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] == renderTargetViewId) 1068 pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = SVGA_ID_INVALID; 1069 } 1070 1064 1071 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyRenderTargetView(pThisCC, pDXContext, renderTargetViewId); 1065 /// @todo for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)1066 //{1067 // if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] == renderTargetViewId)1068 // pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = SVGA_ID_INVALID;1069 //}1070 1072 return rc; 1071 1073 } … … 1700 1702 RT_UNTRUSTED_VALIDATED_FENCE(); 1701 1703 1704 pDXContext->svgaDXContext.streamOut.soid = soid; 1705 1702 1706 rc = pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput(pThisCC, pDXContext, soid); 1703 if (RT_SUCCESS(rc))1704 pDXContext->svgaDXContext.streamOut.soid = soid;1705 1706 1707 return rc; 1707 1708 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r93115 r94063 2068 2068 break; 2069 2069 } 2070 } 2071 2072 2073 static DECLCALLBACK(void) vmsvga3dBackSurfaceInvalidateImage(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface, uint32_t uFace, uint32_t uMipmap) 2074 { 2075 RT_NOREF(pThisCC, pSurface, uFace, uMipmap); 2070 2076 } 2071 2077 … … 7891 7897 p->pfnCreateTexture = vmsvga3dBackCreateTexture; 7892 7898 p->pfnSurfaceDestroy = vmsvga3dBackSurfaceDestroy; 7899 p->pfnSurfaceInvalidateImage = vmsvga3dBackSurfaceInvalidateImage; 7893 7900 p->pfnSurfaceCopy = vmsvga3dBackSurfaceCopy; 7894 7901 p->pfnSurfaceDMACopyBox = vmsvga3dBackSurfaceDMACopyBox; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r93739 r94063 76 76 } DXDEVICE; 77 77 78 /* Kind of a texture view. */ 79 typedef enum VMSVGA3DBACKVIEWTYPE 80 { 81 VMSVGA3D_VIEWTYPE_NONE = 0, 82 VMSVGA3D_VIEWTYPE_RENDERTARGET = 1, 83 VMSVGA3D_VIEWTYPE_DEPTHSTENCIL = 2, 84 VMSVGA3D_VIEWTYPE_SHADERRESOURCE = 3 85 } VMSVGA3DBACKVIEWTYPE; 86 87 /* Information about a texture view to track all created views:. 88 * when a surface is invalidated, then all views must deleted; 89 * when a view is deleted, then the view must be unlinked from the surface. 90 */ 91 typedef struct DXVIEWINFO 92 { 93 uint32_t sid; /* Surface which the view was created for. */ 94 uint32_t cid; /* DX context which created the view. */ 95 uint32_t viewId; /* View id assigned by the guest. */ 96 VMSVGA3DBACKVIEWTYPE enmViewType; 97 } DXVIEWINFO; 98 99 /* Context Object Table element for a texture view. */ 100 typedef struct DXVIEW 101 { 102 uint32_t cid; /* DX context which created the view. */ 103 uint32_t sid; /* Surface which the view was created for. */ 104 uint32_t viewId; /* View id assigned by the guest. */ 105 VMSVGA3DBACKVIEWTYPE enmViewType; 106 107 union 108 { 109 ID3D11View *pView; /* The view object. */ 110 ID3D11RenderTargetView *pRenderTargetView; 111 ID3D11DepthStencilView *pDepthStencilView; 112 ID3D11ShaderResourceView *pShaderResourceView; 113 } u; 114 115 RTLISTNODE nodeSurfaceView; /* Views are linked to the surface. */ 116 } DXVIEW; 117 78 118 /* What kind of resource has been created for the VMSVGA3D surface. */ 79 119 typedef enum VMSVGA3DBACKRESTYPE … … 82 122 VMSVGA3D_RESTYPE_SCREEN_TARGET = 1, 83 123 VMSVGA3D_RESTYPE_TEXTURE_1D = 2, 84 VMSVGA3D_RESTYPE_TEXTURE 85 VMSVGA3D_RESTYPE_ CUBE_TEXTURE = 4,124 VMSVGA3D_RESTYPE_TEXTURE_2D = 3, 125 VMSVGA3D_RESTYPE_TEXTURE_CUBE = 4, 86 126 VMSVGA3D_RESTYPE_TEXTURE_3D = 5, 87 127 VMSVGA3D_RESTYPE_BUFFER = 6, … … 95 135 { 96 136 ID3D11Resource *pResource; 137 ID3D11Texture1D *pTexture1D; 97 138 ID3D11Texture2D *pTexture2D; 98 139 ID3D11Texture3D *pTexture3D; … … 116 157 /** AVL tree containing DXSHAREDTEXTURE structures. */ 117 158 AVLU32TREE SharedTextureTree; 159 160 union 161 { 162 struct 163 { 164 /* Render target views, depth stencil views and shader resource views created for this texture. */ 165 RTLISTANCHOR listView; /* DXVIEW */ 166 } Texture; 167 } u2; 118 168 119 169 } VMSVGA3DBACKENDSURFACE; … … 170 220 } DXSTREAMOUTPUT; 171 221 172 #define DX_DEFERRED_SET_RENDER_TARGETS173 222 typedef struct VMSVGA3DBACKENDDXCONTEXT 174 223 { 175 DXDEVICE d evice;/* DX device interfaces for this context operations. */224 DXDEVICE dxDevice; /* DX device interfaces for this context operations. */ 176 225 177 226 /* Arrays for Context-Object Tables. Number of entries depends on COTable size. */ … … 192 241 ID3D11RasterizerState **papRasterizerState; 193 242 DXELEMENTLAYOUT *paElementLayout; 194 ID3D11RenderTargetView **papRenderTargetView;195 ID3D11DepthStencilView **papDepthStencilView;196 ID3D11ShaderResourceView **papShaderResourceView;243 DXVIEW *paRenderTargetView; 244 DXVIEW *paDepthStencilView; 245 DXVIEW *paShaderResourceView; 197 246 ID3D11Query **papQuery; 198 247 DXSHADER *paShader; 199 248 DXSTREAMOUTPUT *paStreamOutput; 200 249 201 #ifdef DX_DEFERRED_SET_RENDER_TARGETS202 struct203 {204 ID3D11RenderTargetView *papRenderTargetViews[SVGA3D_MAX_RENDER_TARGETS];205 uint32_t cRenderTargetViews;206 ID3D11DepthStencilView *pDepthStencilView;207 } state;208 #endif209 210 250 uint32_t cSOTarget; /* How many SO targets are currently set (SetSOTargets) */ 211 251 } VMSVGA3DBACKENDDXCONTEXT; 212 252 253 /* Shader disassembler function. Optional. */ 213 254 typedef HRESULT FN_D3D_DISASSEMBLE(LPCVOID pSrcData, SIZE_T SrcDataSize, UINT Flags, LPCSTR szComments, ID3D10Blob **ppDisassembly); 214 255 typedef FN_D3D_DISASSEMBLE *PFN_D3D_DISASSEMBLE; … … 222 263 PFN_D3D_DISASSEMBLE pfnD3DDisassemble; 223 264 224 DXDEVICE device; /* Device for the VMSVGA3D context independent operation. */ 265 /** @todo This device will be used for all rendering for "single DX device" mode. */ 266 DXDEVICE dxDevice; /* Device for the VMSVGA3D context independent operation. */ 225 267 } VMSVGA3DBACKEND; 226 268 227 269 270 /* Static function prototypes. */ 228 271 static int dxDeviceFlush(DXDEVICE *pDevice); 272 static int dxDefineShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry); 273 static int dxDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry); 274 static int dxDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry); 275 static int dxSetRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext); 229 276 static DECLCALLBACK(void) vmsvga3dBackSurfaceDestroy(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface); 230 277 … … 259 306 } 260 307 308 /* This is to workaround issues with X8 formats, because they can't be used in some operations. */ 261 309 #define DX_REPLACE_X8_WITH_A8 262 310 static DXGI_FORMAT vmsvgaDXSurfaceFormat2Dxgi(SVGA3dSurfaceFormat format) … … 690 738 if (dxgiFormat != DXGI_FORMAT_UNKNOWN) 691 739 { 692 ID3D11Device *pDevice = pState->pBackend->d evice.pDevice;740 ID3D11Device *pDevice = pState->pBackend->dxDevice.pDevice; 693 741 UINT FormatSupport = 0; 694 742 HRESULT hr = pDevice->CheckFormatSupport(dxgiFormat, &FormatSupport); … … 776 824 { 777 825 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); 778 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true);779 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true);826 // pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true); 827 // pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true); 780 828 781 829 /* No breakpoints for the following messages. */ … … 847 895 if (SUCCEEDED(hr2)) 848 896 { 897 /// @todo Use this to see whether all resources have been properly released. 898 //DEBUG_BREAKPOINT_TEST(); 849 899 //pDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL | (D3D11_RLDO_FLAGS)0x4 /*D3D11_RLDO_IGNORE_INTERNAL*/); 850 900 D3D_RELEASE(pDebug); … … 854 904 D3D_RELEASE(pDevice->pDevice); 855 905 RT_ZERO(*pDevice); 906 } 907 908 909 static void dxViewAddToList(PVGASTATECC pThisCC, DXVIEW *pDXView) 910 { 911 LogFunc(("cid = %u, sid = %u, viewId = %u, type = %u\n", 912 pDXView->cid, pDXView->sid, pDXView->viewId, pDXView->enmViewType)); 913 914 Assert(pDXView->u.pView); /* Only already created views should be added. Guard against mis-use by callers. */ 915 916 PVMSVGA3DSURFACE pSurface; 917 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pDXView->sid, &pSurface); 918 AssertRCReturnVoid(rc); 919 920 RTListAppend(&pSurface->pBackendSurface->u2.Texture.listView, &pDXView->nodeSurfaceView); 921 } 922 923 924 static void dxViewRemoveFromList(DXVIEW *pDXView) 925 { 926 LogFunc(("cid = %u, sid = %u, viewId = %u, type = %u\n", 927 pDXView->cid, pDXView->sid, pDXView->viewId, pDXView->enmViewType)); 928 /* pView can be NULL, if COT entry is already empty. */ 929 if (pDXView->u.pView) 930 { 931 Assert(pDXView->nodeSurfaceView.pNext && pDXView->nodeSurfaceView.pPrev); 932 RTListNodeRemove(&pDXView->nodeSurfaceView); 933 } 934 } 935 936 937 static int dxViewDestroy(DXVIEW *pDXView) 938 { 939 LogFunc(("cid = %u, sid = %u, viewId = %u, type = %u\n", 940 pDXView->cid, pDXView->sid, pDXView->viewId, pDXView->enmViewType)); 941 if (pDXView->u.pView) 942 { 943 D3D_RELEASE(pDXView->u.pView); 944 RTListNodeRemove(&pDXView->nodeSurfaceView); 945 RT_ZERO(*pDXView); 946 } 947 948 return VINF_SUCCESS; 949 } 950 951 952 static int dxViewInit(DXVIEW *pDXView, PVMSVGA3DSURFACE pSurface, VMSVGA3DDXCONTEXT *pDXContext, uint32_t viewId, VMSVGA3DBACKVIEWTYPE enmViewType, ID3D11View *pView) 953 { 954 pDXView->cid = pDXContext->cid; 955 pDXView->sid = pSurface->id; 956 pDXView->viewId = viewId; 957 pDXView->enmViewType = enmViewType; 958 pDXView->u.pView = pView; 959 RTListAppend(&pSurface->pBackendSurface->u2.Texture.listView, &pDXView->nodeSurfaceView); 960 961 LogFunc(("cid = %u, sid = %u, viewId = %u, type = %u\n", 962 pDXView->cid, pDXView->sid, pDXView->viewId, pDXView->enmViewType)); 963 964 DXVIEW *pIter, *pNext; 965 RTListForEachSafe(&pSurface->pBackendSurface->u2.Texture.listView, pIter, pNext, DXVIEW, nodeSurfaceView) 966 { 967 AssertPtr(pNext); 968 LogFunc(("pIter=%p, pNext=%p\n", pIter, pNext)); 969 } 970 971 return VINF_SUCCESS; 856 972 } 857 973 … … 868 984 869 985 870 DXDEVICE *dxDeviceFromCid(uint32_t cid, PVMSVGA3DSTATE pState)986 static DXDEVICE *dxDeviceFromCid(uint32_t cid, PVMSVGA3DSTATE pState) 871 987 { 872 988 if (cid != DX_CID_BACKEND) … … 875 991 int rc = vmsvga3dDXContextFromCid(pState, cid, &pDXContext); 876 992 if (RT_SUCCESS(rc)) 877 return &pDXContext->pBackendDXContext->d evice;993 return &pDXContext->pBackendDXContext->dxDevice; 878 994 } 879 995 else 880 return &pState->pBackend->d evice;996 return &pState->pBackend->dxDevice; 881 997 882 998 AssertFailed(); 883 999 return NULL; 1000 } 1001 1002 1003 static DXDEVICE *dxDeviceFromContext(PVMSVGA3DSTATE p3dState, VMSVGA3DDXCONTEXT *pDXContext) 1004 { 1005 if (pDXContext) 1006 return &pDXContext->pBackendDXContext->dxDevice; 1007 1008 return &p3dState->pBackend->dxDevice; 884 1009 } 885 1010 … … 966 1091 if (!pSharedTexture) 967 1092 { 968 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1093 DXDEVICE *pDevice = dxDeviceFromContext(pState, pDXContext); 969 1094 AssertReturn(pDevice->pDevice, NULL); 970 1095 … … 1010 1135 1011 1136 1012 static uint32_t dxGetShaderResourceViewSid(PVMSVGA3DDXCONTEXT pDXContext, uint32_t shaderResourceViewId)1013 { 1014 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, SVGA_ID_INVALID);1137 static SVGACOTableDXSRViewEntry const *dxGetShaderResourceViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t shaderResourceViewId) 1138 { 1139 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, NULL); 1015 1140 1016 1141 SVGACOTableDXSRViewEntry const *pSRViewEntry = &pDXContext->cot.paSRView[shaderResourceViewId]; 1017 return pSRViewEntry->sid; 1142 return pSRViewEntry; 1143 } 1144 1145 1146 static SVGACOTableDXDSViewEntry const *dxGetDepthStencilViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t depthStencilViewId) 1147 { 1148 ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, NULL); 1149 1150 SVGACOTableDXDSViewEntry const *pDSViewEntry = &pDXContext->cot.paDSView[depthStencilViewId]; 1151 return pDSViewEntry; 1152 } 1153 1154 1155 static SVGACOTableDXRTViewEntry const *dxGetRenderTargetViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t renderTargetViewId) 1156 { 1157 ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, NULL); 1158 1159 SVGACOTableDXRTViewEntry const *pRTViewEntry = &pDXContext->cot.paRTView[renderTargetViewId]; 1160 return pRTViewEntry; 1018 1161 } 1019 1162 … … 1209 1352 static HRESULT dxRenderTargetViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXRTViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11RenderTargetView **pp) 1210 1353 { 1211 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1354 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 1212 1355 1213 1356 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); … … 1283 1426 static HRESULT dxShaderResourceViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXSRViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11ShaderResourceView **pp) 1284 1427 { 1285 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1428 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 1286 1429 1287 1430 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); … … 1360 1503 static HRESULT dxDepthStencilViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXDSViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11DepthStencilView **pp) 1361 1504 { 1362 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1505 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 1363 1506 1364 1507 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); … … 1409 1552 1410 1553 1411 static HRESULT dxShaderCreate(PV MSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader, DXSHADER *pDXShader)1412 { 1413 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1554 static HRESULT dxShaderCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader, DXSHADER *pDXShader) 1555 { 1556 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 1414 1557 1415 1558 HRESULT hr = S_OK; … … 1466 1609 1467 1610 1468 static void dxShaderSet(PV MSVGA3DDXCONTEXT pDXContext, SVGA3dShaderType type, DXSHADER *pDXShader)1469 { 1470 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;1611 static void dxShaderSet(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderType type, DXSHADER *pDXShader) 1612 { 1613 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 1471 1614 1472 1615 switch (type) … … 1563 1706 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 1564 1707 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 1708 RTListInit(&pBackendSurface->u2.Texture.listView); 1565 1709 *ppBackendSurface = pBackendSurface; 1566 1710 return VINF_SUCCESS; … … 1576 1720 AssertReturn(pBackend, VERR_INVALID_STATE); 1577 1721 1578 DXDEVICE *pDXDevice = &pBackend->d evice;1722 DXDEVICE *pDXDevice = &pBackend->dxDevice; 1579 1723 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 1580 1724 … … 1686 1830 1687 1831 1832 static DXDEVICE *dxSurfaceDevice(PVMSVGA3DSTATE p3dState, PVMSVGA3DSURFACE pSurface, PVMSVGA3DDXCONTEXT pDXContext, UINT *pMiscFlags) 1833 { 1834 if (dxIsSurfaceShareable(pSurface)) 1835 { 1836 *pMiscFlags = D3D11_RESOURCE_MISC_SHARED; 1837 return &p3dState->pBackend->dxDevice; 1838 } 1839 1840 *pMiscFlags = 0; 1841 return &pDXContext->pBackendDXContext->dxDevice; 1842 } 1843 1688 1844 static int vmsvga3dBackSurfaceCreateTexture(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 1689 1845 { … … 1695 1851 1696 1852 UINT MiscFlags; 1697 DXDEVICE *pDXDevice; 1698 if (dxIsSurfaceShareable(pSurface)) 1699 { 1700 pDXDevice = &pBackend->device; 1701 MiscFlags = D3D11_RESOURCE_MISC_SHARED; 1702 } 1703 else 1704 { 1705 pDXDevice = &pDXContext->pBackendDXContext->device; 1706 MiscFlags = 0; 1707 } 1853 DXDEVICE *pDXDevice = dxSurfaceDevice(p3dState, pSurface, pDXContext, &MiscFlags); 1708 1854 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 1709 1855 … … 1880 2026 if (SUCCEEDED(hr)) 1881 2027 { 1882 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_ CUBE_TEXTURE;2028 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_CUBE; 1883 2029 } 1884 2030 } … … 2055 2201 if (SUCCEEDED(hr)) 2056 2202 { 2057 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE ;2203 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_2D; 2058 2204 } 2059 2205 } … … 2093 2239 static int vmsvga3dBackSurfaceCreateDepthStencilTexture(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 2094 2240 { 2095 DXDEVICE *pDXDevice = &pDXContext->pBackendDXContext->device;2241 DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 2096 2242 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 2097 2243 … … 2120 2266 if (pSurface->surfaceFlags & SVGA3D_SURFACE_CUBEMAP) 2121 2267 { 2122 AssertFailed(); /** @todo implement */ 2123 hr = E_FAIL; 2268 /* 2269 * CubeMap texture. 2270 */ 2271 Assert(pSurface->cFaces == 6); 2272 Assert(cWidth == cHeight); 2273 Assert(cDepth == 1); 2274 Assert(numMipLevels == 1); 2275 //DEBUG_BREAKPOINT_TEST(); 2276 D3D11_SUBRESOURCE_DATA *paInitialData = NULL; 2277 D3D11_SUBRESOURCE_DATA aInitialData[6 * SVGA3D_MAX_MIP_LEVELS]; 2278 if (pSurface->paMipmapLevels[0].pSurfaceData) 2279 { 2280 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 2281 /** @todo for (i = 0; i < pSurface->cFaces * numMipLevels; ++i) */ 2282 for (uint32_t iFace = 0; iFace < 6; ++iFace) 2283 { 2284 for (uint32_t i = 0; i < numMipLevels; ++i) 2285 { 2286 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, iFace, numMipLevels); 2287 2288 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[iSubresource]; 2289 D3D11_SUBRESOURCE_DATA *p = &aInitialData[iSubresource]; 2290 p->pSysMem = pMipmapLevel->pSurfaceData; 2291 p->SysMemPitch = pMipmapLevel->cbSurfacePitch; 2292 p->SysMemSlicePitch = pMipmapLevel->cbSurfacePlane; 2293 } 2294 } 2295 paInitialData = &aInitialData[0]; 2296 } 2297 2298 D3D11_TEXTURE2D_DESC td; 2299 RT_ZERO(td); 2300 td.Width = cWidth; 2301 td.Height = cHeight; 2302 td.MipLevels = 1; 2303 td.ArraySize = 6; 2304 td.Format = dxgiFormat; 2305 td.SampleDesc.Count = 1; 2306 td.SampleDesc.Quality = 0; 2307 td.Usage = D3D11_USAGE_DEFAULT; 2308 td.BindFlags = dxBindFlags(pSurface->surfaceFlags); 2309 td.CPUAccessFlags = 0; 2310 td.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE; 2311 2312 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.pTexture2D); 2313 Assert(SUCCEEDED(hr)); 2314 if (SUCCEEDED(hr)) 2315 { 2316 /* Map-able texture. */ 2317 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2318 td.ArraySize = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2319 td.Usage = D3D11_USAGE_DYNAMIC; 2320 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ 2321 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 2322 td.MiscFlags = 0; 2323 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pDynamicTexture); 2324 Assert(SUCCEEDED(hr)); 2325 } 2326 2327 if (SUCCEEDED(hr)) 2328 { 2329 /* Staging texture. */ 2330 td.Usage = D3D11_USAGE_STAGING; 2331 td.BindFlags = 0; /* No flags allowed. */ 2332 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; 2333 td.MiscFlags = 0; 2334 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture); 2335 Assert(SUCCEEDED(hr)); 2336 } 2337 2338 if (SUCCEEDED(hr)) 2339 { 2340 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_CUBE; 2341 } 2124 2342 } 2125 2343 else if (pSurface->surfaceFlags & SVGA3D_SURFACE_1D) … … 2141 2359 */ 2142 2360 Assert(pSurface->cFaces == 1); 2361 Assert(numMipLevels == 1); 2143 2362 2144 2363 D3D11_SUBRESOURCE_DATA *paInitialData = NULL; … … 2162 2381 td.Width = cWidth; 2163 2382 td.Height = cHeight; 2164 Assert(pSurface->cLevels == 1);2165 2383 td.MipLevels = 1; 2166 2384 td.ArraySize = 1; … … 2200 2418 if (SUCCEEDED(hr)) 2201 2419 { 2202 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE ;2420 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_2D; 2203 2421 } 2204 2422 } … … 2227 2445 static int vmsvga3dBackSurfaceCreateBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 2228 2446 { 2229 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;2447 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 2230 2448 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2231 2449 … … 2295 2513 static int vmsvga3dBackSurfaceCreateSoBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 2296 2514 { 2297 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;2515 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 2298 2516 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2299 2517 … … 2344 2562 static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 2345 2563 { 2346 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;2564 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 2347 2565 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2348 2566 … … 2443 2661 static int vmsvga3dBackSurfaceCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 2444 2662 { 2445 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;2663 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 2446 2664 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2447 2665 … … 2603 2821 AssertReturn(pBackend, VERR_INVALID_STATE); 2604 2822 2605 int rc = dxDeviceCreate(pBackend, &pBackend->d evice);2823 int rc = dxDeviceCreate(pBackend, &pBackend->dxDevice); 2606 2824 return rc; 2607 2825 } 2608 2826 2609 2827 2610 static DECLCALLBACK(int) vmsvga3dBack Terminate(PVGASTATECC pThisCC)2828 static DECLCALLBACK(int) vmsvga3dBackReset(PVGASTATECC pThisCC) 2611 2829 { 2612 2830 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; 2613 2831 AssertReturn(pState, VERR_INVALID_STATE); 2614 2832 2833 /** @todo This is generic code. Must be moved to in DevVGA-SVGA3d.cpp */ 2834 /* Destroy all leftover surfaces. */ 2835 for (uint32_t i = 0; i < pState->cSurfaces; i++) 2836 { 2837 if (pState->papSurfaces[i]->id != SVGA3D_INVALID_ID) 2838 vmsvga3dSurfaceDestroy(pThisCC, pState->papSurfaces[i]->id); 2839 } 2840 2841 /* Destroy all leftover DX contexts. */ 2842 for (uint32_t i = 0; i < pState->cDXContexts; i++) 2843 { 2844 if (pState->papDXContexts[i]->cid != SVGA3D_INVALID_ID) 2845 vmsvga3dDXDestroyContext(pThisCC, pState->papDXContexts[i]->cid); 2846 } 2847 2848 return VINF_SUCCESS; 2849 } 2850 2851 2852 static DECLCALLBACK(int) vmsvga3dBackTerminate(PVGASTATECC pThisCC) 2853 { 2854 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; 2855 AssertReturn(pState, VERR_INVALID_STATE); 2856 2615 2857 if (pState->pBackend) 2616 2858 { 2617 /** @todo Clean up backends. */ 2618 2619 dxDeviceDestroy(pState->pBackend, &pState->pBackend->device); 2859 /* Clean up backends. For example release resources from surfaces. */ 2860 vmsvga3dBackReset(pThisCC); 2861 2862 dxDeviceDestroy(pState->pBackend, &pState->pBackend->dxDevice); 2620 2863 2621 2864 RTMemFree(pState->pBackend); 2622 2865 pState->pBackend = NULL; 2623 2866 } 2624 2625 return VINF_SUCCESS;2626 }2627 2628 2629 static DECLCALLBACK(int) vmsvga3dBackReset(PVGASTATECC pThisCC)2630 {2631 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;2632 AssertReturn(pState, VERR_INVALID_STATE);2633 2634 /** @todo Cleanup all resources and recreate Device, ImmediateContext etc to be at the same state as after poweron. */2635 2867 2636 2868 return VINF_SUCCESS; … … 2727 2959 PVMSVGA3DBACKEND pBackend = pState->pBackend; 2728 2960 2729 DXDEVICE *pDXDevice = &pBackend->d evice;2961 DXDEVICE *pDXDevice = &pBackend->dxDevice; 2730 2962 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 2731 2963 … … 2957 3189 rc = VERR_NOT_SUPPORTED; 2958 3190 } 2959 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 2960 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_ CUBE_TEXTURE3191 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_2D 3192 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_CUBE 2961 3193 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 2962 3194 { … … 3151 3383 } 3152 3384 } 3153 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 3154 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_ CUBE_TEXTURE3385 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_2D 3386 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_CUBE 3155 3387 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 3156 3388 { … … 3350 3582 if (result == S_OK) 3351 3583 { 3352 pBackend->d evice.pImmediateContext->CopyResource(pHwScreen->pTexture, pBackendSurface->u.pTexture2D);3353 3354 dxDeviceFlush(&pBackend->d evice);3584 pBackend->dxDevice.pImmediateContext->CopyResource(pHwScreen->pTexture, pBackendSurface->u.pTexture2D); 3585 3586 dxDeviceFlush(&pBackend->dxDevice); 3355 3587 3356 3588 result = pHwScreen->pDXGIKeyedMutex->ReleaseSync(1); … … 3385 3617 } 3386 3618 3387 D3D_FEATURE_LEVEL const FeatureLevel = pState->pBackend->d evice.FeatureLevel;3619 D3D_FEATURE_LEVEL const FeatureLevel = pState->pBackend->dxDevice.FeatureLevel; 3388 3620 3389 3621 /* Most values are taken from: … … 3963 4195 pDstSurface ? pDstSurface->idAssociatedContext : SVGA_ID_INVALID)); 3964 4196 3965 //DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;4197 //DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 3966 4198 //AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 3967 4199 … … 3987 4219 dxSurfaceWait(pState, pSrcSurface, DX_CID_BACKEND); 3988 4220 3989 DXDEVICE *pDXDevice = &pBackend->d evice;4221 DXDEVICE *pDXDevice = &pBackend->dxDevice; 3990 4222 3991 4223 /* Clip the box. */ … … 4345 4577 LogFunc(("sid=%u\n", pSurface->id)); 4346 4578 4579 /* If any views have been created for this resource, then also release them. */ 4580 DXVIEW *pIter, *pNext; 4581 RTListForEachSafe(&pBackendSurface->u2.Texture.listView, pIter, pNext, DXVIEW, nodeSurfaceView) 4582 { 4583 LogFunc(("pIter=%p, pNext=%p\n", pIter, pNext)); 4584 dxViewDestroy(pIter); 4585 } 4586 4347 4587 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_SCREEN_TARGET) 4348 4588 { … … 4351 4591 D3D_RELEASE(pBackendSurface->u.pTexture2D); 4352 4592 } 4353 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 4354 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_ CUBE_TEXTURE)4593 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_2D 4594 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_CUBE) 4355 4595 { 4356 4596 D3D_RELEASE(pBackendSurface->pStagingTexture); … … 4377 4617 /* No context has created the surface, because the surface does not exist anymore. */ 4378 4618 pSurface->idAssociatedContext = SVGA_ID_INVALID; 4619 } 4620 4621 4622 static DECLCALLBACK(void) vmsvga3dBackSurfaceInvalidateImage(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface, uint32_t uFace, uint32_t uMipmap) 4623 { 4624 RT_NOREF(pThisCC, uFace, uMipmap); 4625 4626 /* The caller should not use the function for system memory surfaces. */ 4627 PVMSVGA3DBACKENDSURFACE pBackendSurface = pSurface->pBackendSurface; 4628 if (!pBackendSurface) 4629 return; 4630 4631 LogFunc(("sid=%u\n", pSurface->id)); 4632 4633 /* The guest uses this to invalidate a buffer. */ 4634 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER) 4635 { 4636 Assert(uFace == 0 && uMipmap == 0); /* The caller ensures this. */ 4637 vmsvga3dBackSurfaceDestroy(pThisCC, pSurface); 4638 } 4639 else 4640 { 4641 /** @todo Delete views that have been created for this mipmap. 4642 * For now just delete all views, they will be recte=reated if necessary. 4643 */ 4644 ASSERT_GUEST_FAILED(); 4645 DXVIEW *pIter, *pNext; 4646 RTListForEachSafe(&pBackendSurface->u2.Texture.listView, pIter, pNext, DXVIEW, nodeSurfaceView) 4647 { 4648 dxViewDestroy(pIter); 4649 } 4650 } 4379 4651 } 4380 4652 … … 4519 4791 #endif 4520 4792 } 4521 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE) 4793 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_2D 4794 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 4522 4795 { 4523 4796 /** @todo This is generic code and should be in DevVGA-SVGA3d.cpp for backends which support Map/Unmap. */ … … 4530 4803 uint32_t const cBlocksX = (pBox->w + pSurface->cxBlock - 1) / pSurface->cxBlock; 4531 4804 uint32_t const cBlocksY = (pBox->h + pSurface->cyBlock - 1) / pSurface->cyBlock; 4532 AssertMsgReturn(cBlocksX && cBlocksY , ("Empty box %dx%d\n", pBox->w, pBox->h), VERR_INTERNAL_ERROR);4805 AssertMsgReturn(cBlocksX && cBlocksY && pBox->d, ("Empty box %dx%dx%d\n", pBox->w, pBox->h, pBox->d), VERR_INTERNAL_ERROR); 4533 4806 4534 4807 /* vmsvgaR3GmrTransfer verifies uGuestOffset. … … 4536 4809 * to not cause 32 bit overflow when multiplied by cbBlock and cbGuestPitch. 4537 4810 */ 4538 uint64_t constuGuestOffset = u32GuestBlockX * pSurface->cbBlock + u32GuestBlockY * cbGuestPitch;4811 uint64_t uGuestOffset = u32GuestBlockX * pSurface->cbBlock + u32GuestBlockY * cbGuestPitch; 4539 4812 AssertReturn(uGuestOffset < UINT32_MAX, VERR_INVALID_PARAMETER); 4813 4814 /* 3D texture needs additional processing. */ 4815 ASSERT_GUEST_RETURN( pBox->z < D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 4816 && pBox->d <= D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 4817 && pBox->d <= D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION - pBox->z, 4818 VERR_INVALID_PARAMETER); 4819 ASSERT_GUEST_RETURN( pBox->srcz < D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 4820 && pBox->d <= D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 4821 && pBox->d <= D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION - pBox->srcz, 4822 VERR_INVALID_PARAMETER); 4823 4824 uGuestOffset += pBox->srcz * pMipLevel->cbSurfacePlane; 4540 4825 4541 4826 SVGA3dSurfaceImageId image; … … 4547 4832 box.x = pBox->x; 4548 4833 box.y = pBox->y; 4549 box.z = 0;4834 box.z = pBox->z; 4550 4835 box.w = pBox->w; 4551 4836 box.h = pBox->h; 4552 box.d = 1;4837 box.d = pBox->d; 4553 4838 4554 4839 VMSVGA3D_SURFACE_MAP const enmMap = transfer == SVGA3D_WRITE_HOST_VRAM … … 4570 4855 * and offset of the first scanline. 4571 4856 */ 4572 uint32_t const cbLockedBuf = map.cbRowPitch * cBlocksY; 4857 uint32_t cbLockedBuf = map.cbRowPitch * cBlocksY; 4858 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 4859 cbLockedBuf += map.cbDepthPitch * (pBox->d - 1); /// @todo why map does not compute this for 2D textures 4573 4860 uint8_t *pu8LockedBuf = (uint8_t *)map.pvData; 4574 uint32_t const offLockedBuf = 0; 4575 4576 rc = vmsvgaR3GmrTransfer(pThis, 4577 pThisCC, 4578 transfer, 4579 pu8LockedBuf, 4580 cbLockedBuf, 4581 offLockedBuf, 4582 map.cbRowPitch, 4583 GuestPtr, 4584 (uint32_t)uGuestOffset, 4585 cbGuestPitch, 4586 cBlocksX * pSurface->cbBlock, 4587 cBlocksY); 4588 AssertRC(rc); 4861 uint32_t offLockedBuf = 0; 4862 4863 for (uint32_t iPlane = 0; iPlane < pBox->d; ++iPlane) 4864 { 4865 AssertBreak(uGuestOffset < UINT32_MAX); 4866 4867 rc = vmsvgaR3GmrTransfer(pThis, 4868 pThisCC, 4869 transfer, 4870 pu8LockedBuf, 4871 cbLockedBuf, 4872 offLockedBuf, 4873 map.cbRowPitch, 4874 GuestPtr, 4875 (uint32_t)uGuestOffset, 4876 cbGuestPitch, 4877 cBlocksX * pSurface->cbBlock, 4878 cBlocksY); 4879 AssertRC(rc); 4880 4881 uGuestOffset += pMipLevel->cbSurfacePlane; 4882 offLockedBuf += map.cbDepthPitch; 4883 } 4589 4884 4590 4885 bool const fWritten = (transfer == SVGA3D_WRITE_HOST_VRAM); … … 4681 4976 LogFunc(("cid %d\n", pDXContext->cid)); 4682 4977 4683 int rc = dxDeviceCreate(pBackend, &pBackendDXContext->d evice);4978 int rc = dxDeviceCreate(pBackend, &pBackendDXContext->dxDevice); 4684 4979 return rc; 4685 4980 } … … 4697 4992 VMSVGA3DBACKENDDXCONTEXT *pBackendDXContext = pDXContext->pBackendDXContext; 4698 4993 4699 if (pBackendDXContext->papRenderTargetView) 4700 DX_RELEASE_ARRAY(pBackendDXContext->cRenderTargetView, pBackendDXContext->papRenderTargetView); 4701 if (pBackendDXContext->papDepthStencilView) 4702 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilView, pBackendDXContext->papDepthStencilView); 4703 if (pBackendDXContext->papShaderResourceView) 4704 DX_RELEASE_ARRAY(pBackendDXContext->cShaderResourceView, pBackendDXContext->papShaderResourceView); 4994 if (pBackendDXContext->paRenderTargetView) 4995 { 4996 for (uint32_t i = 0; i < pBackendDXContext->cRenderTargetView; ++i) 4997 D3D_RELEASE(pBackendDXContext->paRenderTargetView[i].u.pRenderTargetView); 4998 } 4999 if (pBackendDXContext->paDepthStencilView) 5000 { 5001 for (uint32_t i = 0; i < pBackendDXContext->cDepthStencilView; ++i) 5002 D3D_RELEASE(pBackendDXContext->paDepthStencilView[i].u.pDepthStencilView); 5003 } 5004 if (pBackendDXContext->paShaderResourceView) 5005 { 5006 for (uint32_t i = 0; i < pBackendDXContext->cShaderResourceView; ++i) 5007 D3D_RELEASE(pBackendDXContext->paShaderResourceView[i].u.pShaderResourceView); 5008 } 4705 5009 if (pBackendDXContext->paElementLayout) 4706 5010 { … … 4734 5038 RTMemFreeZ(pBackendDXContext->papRasterizerState, sizeof(pBackendDXContext->papRasterizerState[0]) * pBackendDXContext->cRasterizerState); 4735 5039 RTMemFreeZ(pBackendDXContext->paElementLayout, sizeof(pBackendDXContext->paElementLayout[0]) * pBackendDXContext->cElementLayout); 4736 RTMemFreeZ(pBackendDXContext->pa pRenderTargetView, sizeof(pBackendDXContext->papRenderTargetView[0]) * pBackendDXContext->cRenderTargetView);4737 RTMemFreeZ(pBackendDXContext->pa pDepthStencilView, sizeof(pBackendDXContext->papDepthStencilView[0]) * pBackendDXContext->cDepthStencilView);4738 RTMemFreeZ(pBackendDXContext->pa pShaderResourceView, sizeof(pBackendDXContext->papShaderResourceView[0]) * pBackendDXContext->cShaderResourceView);5040 RTMemFreeZ(pBackendDXContext->paRenderTargetView, sizeof(pBackendDXContext->paRenderTargetView[0]) * pBackendDXContext->cRenderTargetView); 5041 RTMemFreeZ(pBackendDXContext->paDepthStencilView, sizeof(pBackendDXContext->paDepthStencilView[0]) * pBackendDXContext->cDepthStencilView); 5042 RTMemFreeZ(pBackendDXContext->paShaderResourceView, sizeof(pBackendDXContext->paShaderResourceView[0]) * pBackendDXContext->cShaderResourceView); 4739 5043 RTMemFreeZ(pBackendDXContext->papQuery, sizeof(pBackendDXContext->papQuery[0]) * pBackendDXContext->cQuery); 4740 5044 RTMemFreeZ(pBackendDXContext->paShader, sizeof(pBackendDXContext->paShader[0]) * pBackendDXContext->cShader); … … 4770 5074 } 4771 5075 4772 dxDeviceDestroy(pBackend, &pBackendDXContext->d evice);5076 dxDeviceDestroy(pBackend, &pBackendDXContext->dxDevice); 4773 5077 4774 5078 RTMemFreeZ(pBackendDXContext, sizeof(*pBackendDXContext)); … … 4810 5114 RT_NOREF(pBackend); 4811 5115 4812 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5116 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4813 5117 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4814 5118 … … 4866 5170 } 4867 5171 4868 4869 static DECLCALLBACK(int) vmsvga3dBackDXSetShaderResources(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t startView, SVGA3dShaderType type, uint32_t cShaderResourceViewId, SVGA3dShaderResourceViewId const *paShaderResourceViewId) 4870 { 4871 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4872 RT_NOREF(pBackend); 4873 4874 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5172 static int dxSetShaderResources(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderType type) 5173 { 5174 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4875 5175 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4876 5176 5177 //DEBUG_BREAKPOINT_TEST(); 5178 AssertReturn(type >= SVGA3D_SHADERTYPE_MIN && type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER); 4877 5179 uint32_t const idxShaderState = type - SVGA3D_SHADERTYPE_MIN; 5180 uint32_t const *pSRIds = &pDXContext->svgaDXContext.shaderState[idxShaderState].shaderResources[0]; 4878 5181 ID3D11ShaderResourceView *papShaderResourceView[SVGA3D_DX_MAX_SRVIEWS]; 4879 for (uint32_t i = 0; i < cShaderResourceViewId; ++i)4880 { 4881 SVGA3dShaderResourceViewId shaderResourceViewId = p aShaderResourceViewId[i];5182 for (uint32_t i = 0; i < SVGA3D_DX_MAX_SRVIEWS; ++i) 5183 { 5184 SVGA3dShaderResourceViewId shaderResourceViewId = pSRIds[i]; 4882 5185 if (shaderResourceViewId != SVGA3D_INVALID_ID) 4883 5186 { 4884 5187 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->pBackendDXContext->cShaderResourceView, VERR_INVALID_PARAMETER); 4885 papShaderResourceView[i] = pDXContext->pBackendDXContext->papShaderResourceView[shaderResourceViewId]; 5188 5189 DXVIEW *pDXView = &pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId]; 5190 Assert(pDXView->u.pShaderResourceView); 5191 papShaderResourceView[i] = pDXView->u.pShaderResourceView; 4886 5192 } 4887 5193 else 4888 5194 papShaderResourceView[i] = NULL; 4889 4890 pDXContext->svgaDXContext.shaderState[idxShaderState].shaderResources[startView + i] = shaderResourceViewId; 4891 } 4892 4893 dxShaderResourceViewSet(pDevice, type, startView, cShaderResourceViewId, papShaderResourceView); 5195 } 5196 5197 dxShaderResourceViewSet(pDevice, type, 0, SVGA3D_DX_MAX_SRVIEWS, papShaderResourceView); 4894 5198 return VINF_SUCCESS; 4895 5199 } 4896 5200 4897 5201 5202 static DECLCALLBACK(int) vmsvga3dBackDXSetShaderResources(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t startView, SVGA3dShaderType type, uint32_t cShaderResourceViewId, SVGA3dShaderResourceViewId const *paShaderResourceViewId) 5203 { 5204 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5205 RT_NOREF(pBackend); 5206 5207 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5208 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5209 5210 RT_NOREF(startView, type, cShaderResourceViewId, paShaderResourceViewId); 5211 5212 return VINF_SUCCESS; 5213 } 5214 5215 4898 5216 static DECLCALLBACK(int) vmsvga3dBackDXSetShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderType type, PVMSVGA3DSHADER pShader) 4899 5217 { … … 4901 5219 RT_NOREF(pBackend); 4902 5220 4903 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5221 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4904 5222 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4905 5223 … … 4916 5234 pDXShader = NULL; 4917 5235 4918 dxShaderSet(p DXContext, type, pDXShader);5236 dxShaderSet(pThisCC, pDXContext, type, pDXShader); 4919 5237 return VINF_SUCCESS; 4920 5238 } … … 4926 5244 RT_NOREF(pBackend); 4927 5245 4928 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5246 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4929 5247 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4930 5248 … … 4956 5274 AssertCompile(RT_ELEMENTS(pDXContext->svgaDXContext.shaderState[0].shaderResources) == SVGA3D_DX_MAX_SRVIEWS); 4957 5275 4958 for (uint32_t idxShaderState = 0; idxShaderState < SVGA3D_NUM_SHADERTYPE; ++idxShaderState) 4959 { 4960 for (uint32_t idxSR = 0; idxSR < SVGA3D_NUM_SHADERTYPE; ++idxSR) 5276 int rc; 5277 5278 /* Unbind render target views because they mught be (re-)used as shader resource views. */ 5279 DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5280 pDXDevice->pImmediateContext->OMSetRenderTargets(0, NULL, NULL); 5281 5282 /* Make sure that the shader resource views exist. */ 5283 for (uint32_t idxShaderState = 0; idxShaderState < SVGA3D_NUM_SHADERTYPE_DX10 /** @todo SVGA3D_NUM_SHADERTYPE*/; ++idxShaderState) 5284 { 5285 for (uint32_t idxSR = 0; idxSR < SVGA3D_DX_MAX_SRVIEWS; ++idxSR) 4961 5286 { 4962 5287 SVGA3dShaderResourceViewId const shaderResourceViewId = pDXContext->svgaDXContext.shaderState[idxShaderState].shaderResources[idxSR]; … … 4965 5290 ASSERT_GUEST_RETURN_VOID(shaderResourceViewId < pDXContext->pBackendDXContext->cShaderResourceView); 4966 5291 4967 uint32_t const sid = dxGetShaderResourceViewSid(pDXContext, shaderResourceViewId); 5292 SVGACOTableDXSRViewEntry const *pSRViewEntry = dxGetShaderResourceViewEntry(pDXContext, shaderResourceViewId); 5293 AssertContinue(pSRViewEntry != NULL); 5294 5295 uint32_t const sid = pSRViewEntry->sid; 4968 5296 4969 5297 PVMSVGA3DSURFACE pSurface; 4970 intrc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface);5298 rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface); 4971 5299 AssertRCReturnVoid(rc); 4972 5300 4973 /** @todo The guest might have invalidated the surface. */ 4974 AssertContinue(pSurface->pBackendSurface); 4975 4976 /* Wait for the surface to finish drawing. */ 4977 dxSurfaceWait(pThisCC->svga.p3dState, pSurface, pDXContext->cid); 5301 /* The guest might have invalidated the surface in which case pSurface->pBackendSurface is NULL. */ 5302 /** @todo This is not needed for "single DX device" mode. */ 5303 if (pSurface->pBackendSurface) 5304 { 5305 /* Wait for the surface to finish drawing. */ 5306 dxSurfaceWait(pThisCC->svga.p3dState, pSurface, pDXContext->cid); 5307 } 5308 5309 /* If a view has not been created yet, do it now. */ 5310 if (!pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId].u.pView) 5311 { 5312 //DEBUG_BREAKPOINT_TEST(); 5313 LogFunc(("Re-creating SRV: sid=%u srvid = %u\n", sid, shaderResourceViewId)); 5314 rc = dxDefineShaderResourceView(pThisCC, pDXContext, shaderResourceViewId, pSRViewEntry); 5315 AssertContinue(RT_SUCCESS(rc)); 5316 } 4978 5317 } 4979 5318 } 4980 } 4981 4982 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4983 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5319 5320 /* Set shader resources. */ 5321 rc = dxSetShaderResources(pThisCC, pDXContext, (SVGA3dShaderType)(idxShaderState + SVGA3D_SHADERTYPE_MIN)); 5322 AssertRC(rc); 5323 } 5324 5325 5326 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4984 5327 AssertReturnVoid(pDevice->pDevice); 4985 5328 4986 pDevice->pImmediateContext->OMSetRenderTargets(pDXContext->pBackendDXContext->state.cRenderTargetViews, 4987 pDXContext->pBackendDXContext->state.papRenderTargetViews, 4988 pDXContext->pBackendDXContext->state.pDepthStencilView); 4989 #endif 5329 /** @todo Make sure that the render target views exist. Similar to SRVs. */ 5330 if (pDXContext->svgaDXContext.renderState.depthStencilViewId != SVGA3D_INVALID_ID) 5331 { 5332 uint32_t const viewId = pDXContext->svgaDXContext.renderState.depthStencilViewId; 5333 5334 ASSERT_GUEST_RETURN_VOID(viewId < pDXContext->pBackendDXContext->cDepthStencilView); 5335 5336 SVGACOTableDXDSViewEntry const *pDSViewEntry = dxGetDepthStencilViewEntry(pDXContext, viewId); 5337 AssertReturnVoid(pDSViewEntry != NULL); 5338 5339 PVMSVGA3DSURFACE pSurface; 5340 rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pDSViewEntry->sid, &pSurface); 5341 AssertRCReturnVoid(rc); 5342 5343 /* If a view has not been created yet, do it now. */ 5344 if (!pDXContext->pBackendDXContext->paDepthStencilView[viewId].u.pView) 5345 { 5346 //DEBUG_BREAKPOINT_TEST(); 5347 LogFunc(("Re-creating DSV: sid=%u dsvid = %u\n", pDSViewEntry->sid, viewId)); 5348 rc = dxDefineDepthStencilView(pThisCC, pDXContext, viewId, pDSViewEntry); 5349 AssertReturnVoid(RT_SUCCESS(rc)); 5350 } 5351 } 5352 5353 for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i) 5354 { 5355 if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] != SVGA3D_INVALID_ID) 5356 { 5357 uint32_t const viewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i]; 5358 5359 ASSERT_GUEST_RETURN_VOID(viewId < pDXContext->pBackendDXContext->cRenderTargetView); 5360 5361 SVGACOTableDXRTViewEntry const *pRTViewEntry = dxGetRenderTargetViewEntry(pDXContext, viewId); 5362 AssertReturnVoid(pRTViewEntry != NULL); 5363 5364 PVMSVGA3DSURFACE pSurface; 5365 rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pRTViewEntry->sid, &pSurface); 5366 AssertRCReturnVoid(rc); 5367 5368 /* If a view has not been created yet, do it now. */ 5369 if (!pDXContext->pBackendDXContext->paRenderTargetView[viewId].u.pView) 5370 { 5371 //DEBUG_BREAKPOINT_TEST(); 5372 LogFunc(("Re-creating RTV: sid=%u rtvid = %u\n", pRTViewEntry->sid, viewId)); 5373 rc = dxDefineRenderTargetView(pThisCC, pDXContext, viewId, pRTViewEntry); 5374 AssertReturnVoid(RT_SUCCESS(rc)); 5375 } 5376 } 5377 } 5378 5379 /* Set render targets. */ 5380 rc = dxSetRenderTargets(pThisCC, pDXContext); 5381 AssertRC(rc); 4990 5382 } 4991 5383 … … 4996 5388 RT_NOREF(pBackend); 4997 5389 4998 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5390 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 4999 5391 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5000 5392 … … 5246 5638 RT_NOREF(pBackend); 5247 5639 5248 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5640 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5249 5641 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5250 5642 … … 5271 5663 RT_NOREF(pBackend); 5272 5664 5273 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5665 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5274 5666 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5275 5667 … … 5293 5685 RT_NOREF(pBackend); 5294 5686 5295 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5687 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5296 5688 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5297 5689 … … 5327 5719 RT_NOREF(pBackend); 5328 5720 5329 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5721 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5330 5722 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5331 5723 … … 5362 5754 RT_NOREF(pBackend); 5363 5755 5364 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5756 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5365 5757 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5366 5758 … … 5443 5835 RT_NOREF(pBackend); 5444 5836 5445 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5837 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5446 5838 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5447 5839 … … 5553 5945 RT_NOREF(pBackend); 5554 5946 5555 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;5947 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5556 5948 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5557 5949 … … 5562 5954 5563 5955 5564 static DECLCALLBACK(int) vmsvga3dBackDXSetRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, uint32_t cRenderTargetViewId, SVGA3dRenderTargetViewId const *paRenderTargetViewId) 5565 { 5566 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5567 RT_NOREF(pBackend); 5568 5569 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5956 static int dxSetRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5957 { 5958 //pDXContext->svgaDXContext.renderState.depthStencilViewId = depthStencilViewId; 5959 //for (uint32_t i = 0; i < cRenderTargetViewId; ++i) 5960 // pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = paRenderTargetViewId[i]; 5961 5962 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5570 5963 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5571 5964 5572 ID3D11RenderTargetView * papRenderTargetViews[SVGA3D_MAX_RENDER_TARGETS];5573 RT_ZERO( papRenderTargetViews);5574 for (uint32_t i = 0; i < cRenderTargetViewId; ++i)5575 { 5576 SVGA3dRenderTargetViewId const renderTargetViewId = p aRenderTargetViewId[i];5965 ID3D11RenderTargetView *apRenderTargetViews[SVGA3D_MAX_RENDER_TARGETS]; 5966 RT_ZERO(apRenderTargetViews); 5967 for (uint32_t i = 0; i < SVGA3D_MAX_RENDER_TARGETS; ++i) 5968 { 5969 SVGA3dRenderTargetViewId const renderTargetViewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i]; 5577 5970 if (renderTargetViewId != SVGA3D_INVALID_ID) 5578 5971 { 5579 5972 ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->pBackendDXContext->cRenderTargetView, VERR_INVALID_PARAMETER); 5580 papRenderTargetViews[i] = pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId];5973 apRenderTargetViews[i] = pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId].u.pRenderTargetView; 5581 5974 } 5582 5975 } 5583 5976 5584 ID3D11DepthStencilView *pDepthStencilView; 5977 ID3D11DepthStencilView *pDepthStencilView = NULL; 5978 SVGA3dDepthStencilViewId const depthStencilViewId = pDXContext->svgaDXContext.renderState.depthStencilViewId; 5585 5979 if (depthStencilViewId != SVGA_ID_INVALID) 5586 pDepthStencilView = pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]; 5587 else 5588 pDepthStencilView = NULL; 5589 5590 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 5591 memcpy(pDXContext->pBackendDXContext->state.papRenderTargetViews, papRenderTargetViews, sizeof(papRenderTargetViews)); 5592 pDXContext->pBackendDXContext->state.cRenderTargetViews = cRenderTargetViewId; 5593 pDXContext->pBackendDXContext->state.pDepthStencilView = pDepthStencilView; 5594 pDevice->pImmediateContext->OMSetRenderTargets(0, NULL, NULL); 5595 #else 5596 pDevice->pImmediateContext->OMSetRenderTargets(cRenderTargetViewId, papRenderTargetViews, pDepthStencilView); 5597 #endif 5980 pDepthStencilView = pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId].u.pDepthStencilView; 5981 5982 pDevice->pImmediateContext->OMSetRenderTargets(SVGA3D_MAX_RENDER_TARGETS, 5983 apRenderTargetViews, 5984 pDepthStencilView); 5598 5985 return VINF_SUCCESS; 5599 5986 } 5600 5987 5601 5988 5989 static DECLCALLBACK(int) vmsvga3dBackDXSetRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, uint32_t cRenderTargetViewId, SVGA3dRenderTargetViewId const *paRenderTargetViewId) 5990 { 5991 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5992 RT_NOREF(pBackend); 5993 5994 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5995 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5996 5997 RT_NOREF(depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId); 5998 5999 return VINF_SUCCESS; 6000 } 6001 6002 5602 6003 static DECLCALLBACK(int) vmsvga3dBackDXSetBlendState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dBlendStateId blendId, float const blendFactor[4], uint32_t sampleMask) 5603 6004 { … … 5605 6006 RT_NOREF(pBackend); 5606 6007 5607 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6008 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5608 6009 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5609 6010 … … 5627 6028 RT_NOREF(pBackend); 5628 6029 5629 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6030 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5630 6031 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5631 6032 … … 5643 6044 { 5644 6045 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5645 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6046 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5646 6047 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5647 6048 … … 5738 6139 RT_NOREF(pBackend); 5739 6140 5740 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6141 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5741 6142 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5742 6143 … … 5795 6196 { 5796 6197 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5797 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6198 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5798 6199 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5799 6200 … … 5813 6214 RT_NOREF(pBackend); 5814 6215 5815 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6216 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5816 6217 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5817 6218 … … 5829 6230 RT_NOREF(pBackend); 5830 6231 5831 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6232 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5832 6233 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5833 6234 5834 ID3D11RenderTargetView *pRenderTargetView = pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]; 5835 AssertReturn(pRenderTargetView, VERR_INVALID_STATE); 5836 pDevice->pImmediateContext->ClearRenderTargetView(pRenderTargetView, pRGBA->value); 6235 DXVIEW *pDXView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId]; 6236 if (!pDXView->u.pRenderTargetView) 6237 { 6238 //DEBUG_BREAKPOINT_TEST(); 6239 /* (Re-)create the render target view, because a creation of a view is deferred until a draw or a clear call. */ 6240 SVGACOTableDXRTViewEntry const *pEntry = &pDXContext->cot.paRTView[renderTargetViewId]; 6241 int rc = dxDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry); 6242 AssertRCReturn(rc, rc); 6243 } 6244 pDevice->pImmediateContext->ClearRenderTargetView(pDXView->u.pRenderTargetView, pRGBA->value); 5837 6245 return VINF_SUCCESS; 5838 6246 } … … 5844 6252 RT_NOREF(pBackend); 5845 6253 5846 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6254 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5847 6255 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5848 6256 5849 ID3D11DepthStencilView *pDepthStencilView = pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]; 5850 AssertReturn(pDepthStencilView, VERR_INVALID_STATE); 5851 pDevice->pImmediateContext->ClearDepthStencilView(pDepthStencilView, flags, depth, stencil); 6257 DXVIEW *pDXView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId]; 6258 if (!pDXView->u.pDepthStencilView) 6259 { 6260 //DEBUG_BREAKPOINT_TEST(); 6261 /* (Re-)create the depth stencil view, because a creation of a view is deferred until a draw or a clear call. */ 6262 SVGACOTableDXDSViewEntry const *pEntry = &pDXContext->cot.paDSView[depthStencilViewId]; 6263 int rc = dxDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry); 6264 AssertRCReturn(rc, rc); 6265 } 6266 pDevice->pImmediateContext->ClearDepthStencilView(pDXView->u.pDepthStencilView, flags, depth, stencil); 5852 6267 return VINF_SUCCESS; 5853 6268 } … … 5859 6274 RT_NOREF(pBackend); 5860 6275 5861 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6276 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5862 6277 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5863 6278 … … 5964 6379 RT_NOREF(pBackend); 5965 6380 5966 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6381 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 5967 6382 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5968 6383 5969 ID3D11ShaderResourceView *pShaderResourceView = pDXContext->pBackendDXContext->pa pShaderResourceView[shaderResourceViewId];6384 ID3D11ShaderResourceView *pShaderResourceView = pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId].u.pShaderResourceView; 5970 6385 AssertReturn(pShaderResourceView, VERR_INVALID_STATE); 5971 6386 5972 uint32_t const sid = dxGetShaderResourceViewSid(pDXContext, shaderResourceViewId); 6387 SVGACOTableDXSRViewEntry const *pSRViewEntry = dxGetShaderResourceViewEntry(pDXContext, shaderResourceViewId); 6388 AssertReturn(pSRViewEntry, VERR_INVALID_STATE); 6389 6390 uint32_t const sid = pSRViewEntry->sid; 5973 6391 5974 6392 PVMSVGA3DSURFACE pSurface; … … 5991 6409 AssertRCReturn(rc, rc); 5992 6410 6411 ID3D11ShaderResourceView *pShaderResourceView; 6412 DXVIEW *pView = &pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId]; 6413 Assert(pView->u.pView == NULL); 6414 5993 6415 if (pSurface->pBackendSurface == NULL) 5994 6416 { … … 5998 6420 } 5999 6421 6000 HRESULT hr = dxShaderResourceViewCreate(pThisCC, pDXContext, pEntry, pSurface, &p DXContext->pBackendDXContext->papShaderResourceView[shaderResourceViewId]);6001 if (SUCCEEDED(hr))6002 return VINF_SUCCESS; 6003 return VERR_INVALID_STATE;6422 HRESULT hr = dxShaderResourceViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pShaderResourceView); 6423 AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE); 6424 6425 return dxViewInit(pView, pSurface, pDXContext, shaderResourceViewId, VMSVGA3D_VIEWTYPE_SHADERRESOURCE, pShaderResourceView); 6004 6426 } 6005 6427 … … 6010 6432 RT_NOREF(pBackend); 6011 6433 6012 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6434 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6013 6435 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6014 6436 … … 6022 6444 RT_NOREF(pBackend); 6023 6445 6024 D3D_RELEASE(pDXContext->pBackendDXContext->papShaderResourceView[shaderResourceViewId]); 6025 return VINF_SUCCESS; 6446 return dxViewDestroy(&pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId]); 6026 6447 } 6027 6448 … … 6034 6455 AssertRCReturn(rc, rc); 6035 6456 6457 DXVIEW *pView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId]; 6458 Assert(pView->u.pView == NULL); 6459 6036 6460 if (pSurface->pBackendSurface == NULL) 6037 6461 { … … 6041 6465 } 6042 6466 6043 HRESULT hr = dxRenderTargetViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]);6044 if (SUCCEEDED(hr))6045 return VINF_SUCCESS;6046 6047 return VERR_INVALID_STATE;6467 ID3D11RenderTargetView *pRenderTargetView; 6468 HRESULT hr = dxRenderTargetViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pRenderTargetView); 6469 AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE); 6470 6471 return dxViewInit(pView, pSurface, pDXContext, renderTargetViewId, VMSVGA3D_VIEWTYPE_RENDERTARGET, pRenderTargetView); 6048 6472 } 6049 6473 … … 6054 6478 RT_NOREF(pBackend); 6055 6479 6056 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6480 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6057 6481 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6058 6482 … … 6066 6490 RT_NOREF(pBackend); 6067 6491 6068 D3D_RELEASE(pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]); 6069 return VINF_SUCCESS; 6492 return dxViewDestroy(&pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId]); 6070 6493 } 6071 6494 … … 6078 6501 AssertRCReturn(rc, rc); 6079 6502 6503 DXVIEW *pView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId]; 6504 Assert(pView->u.pView == NULL); 6505 6080 6506 if ( pSurface->pBackendSurface != NULL 6081 6507 && pDXContext->cid != pSurface->idAssociatedContext) … … 6092 6518 } 6093 6519 6094 HRESULT hr = dxDepthStencilViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]); 6095 if (SUCCEEDED(hr)) 6096 return VINF_SUCCESS; 6097 return VERR_INVALID_STATE; 6520 ID3D11DepthStencilView *pDepthStencilView; 6521 HRESULT hr = dxDepthStencilViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDepthStencilView); 6522 AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE); 6523 6524 return dxViewInit(pView, pSurface, pDXContext, depthStencilViewId, VMSVGA3D_VIEWTYPE_DEPTHSTENCIL, pDepthStencilView); 6098 6525 } 6099 6526 … … 6103 6530 RT_NOREF(pBackend); 6104 6531 6105 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6532 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6106 6533 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6107 6534 … … 6115 6542 RT_NOREF(pBackend); 6116 6543 6117 D3D_RELEASE(pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]); 6118 return VINF_SUCCESS; 6544 return dxViewDestroy(&pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId]); 6119 6545 } 6120 6546 … … 6157 6583 { 6158 6584 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 6159 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6585 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6160 6586 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6161 6587 … … 6183 6609 6184 6610 6185 static int dxDefineBlendState(PV MSVGA3DDXCONTEXT pDXContext,6611 static int dxDefineBlendState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, 6186 6612 SVGA3dBlendStateId blendId, SVGACOTableDXBlendStateEntry const *pEntry) 6187 6613 { 6188 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6614 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6189 6615 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6190 6616 … … 6201 6627 RT_NOREF(pBackend); 6202 6628 6203 return dxDefineBlendState(p DXContext, blendId, pEntry);6629 return dxDefineBlendState(pThisCC, pDXContext, blendId, pEntry); 6204 6630 } 6205 6631 … … 6215 6641 6216 6642 6217 static int dxDefineDepthStencilState(PV MSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry const *pEntry)6218 { 6219 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6643 static int dxDefineDepthStencilState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry const *pEntry) 6644 { 6645 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6220 6646 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6221 6647 … … 6232 6658 RT_NOREF(pBackend); 6233 6659 6234 return dxDefineDepthStencilState(p DXContext, depthStencilId, pEntry);6660 return dxDefineDepthStencilState(pThisCC, pDXContext, depthStencilId, pEntry); 6235 6661 } 6236 6662 … … 6246 6672 6247 6673 6248 static int dxDefineRasterizerState(PV MSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry)6249 { 6250 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6674 static int dxDefineRasterizerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry) 6675 { 6676 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6251 6677 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6252 6678 … … 6263 6689 RT_NOREF(pBackend); 6264 6690 6265 return dxDefineRasterizerState(p DXContext, rasterizerId, pEntry);6691 return dxDefineRasterizerState(pThisCC, pDXContext, rasterizerId, pEntry); 6266 6692 } 6267 6693 … … 6277 6703 6278 6704 6279 static int dxDefineSamplerState(PV MSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry)6280 { 6281 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6705 static int dxDefineSamplerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry) 6706 { 6707 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6282 6708 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6283 6709 … … 6294 6720 RT_NOREF(pBackend); 6295 6721 6296 return dxDefineSamplerState(p DXContext, samplerId, pEntry);6722 return dxDefineSamplerState(pThisCC, pDXContext, samplerId, pEntry); 6297 6723 } 6298 6724 … … 6366 6792 { 6367 6793 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 6368 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;6794 DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); 6369 6795 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 6370 6796 … … 6403 6829 #endif 6404 6830 6405 HRESULT hr = dxShaderCreate(p DXContext, pShader, pDXShader);6831 HRESULT hr = dxShaderCreate(pThisCC, pDXContext, pShader, pDXShader); 6406 6832 if (SUCCEEDED(hr)) 6407 6833 { … … 6500 6926 case SVGA_COTABLE_RTVIEW: 6501 6927 /* Clear current entries. */ 6502 if (pBackendDXContext->pa pRenderTargetView)6928 if (pBackendDXContext->paRenderTargetView) 6503 6929 { 6504 for (uint32_t i = cValidEntries; i < pBackendDXContext->cRenderTargetView; ++i) 6505 D3D_RELEASE(pBackendDXContext->papRenderTargetView[i]); 6930 for (uint32_t i = 0; i < pBackendDXContext->cRenderTargetView; ++i) 6931 { 6932 DXVIEW *pDXView = &pBackendDXContext->paRenderTargetView[i]; 6933 if (i < cValidEntries) 6934 dxViewRemoveFromList(pDXView); /* Remove from list because DXVIEW array will be reallocated. */ 6935 else 6936 dxViewDestroy(pDXView); 6937 } 6506 6938 } 6507 6939 6508 rc = dxCOTableRealloc((void **)&pBackendDXContext->pa pRenderTargetView, &pBackendDXContext->cRenderTargetView,6509 sizeof(pBackendDXContext->pa pRenderTargetView[0]), pDXContext->cot.cRTView, cValidEntries);6940 rc = dxCOTableRealloc((void **)&pBackendDXContext->paRenderTargetView, &pBackendDXContext->cRenderTargetView, 6941 sizeof(pBackendDXContext->paRenderTargetView[0]), pDXContext->cot.cRTView, cValidEntries); 6510 6942 AssertRCBreak(rc); 6511 6943 … … 6516 6948 continue; /* Skip uninitialized entry. */ 6517 6949 6518 dxDefineRenderTargetView(pThisCC, pDXContext, i, pEntry); 6950 DXVIEW *pDXView = &pBackendDXContext->paRenderTargetView[i]; 6951 /** @todo Verify that the pEntry content still corresponds to the view. */ 6952 if (pDXView->u.pView) 6953 dxViewAddToList(pThisCC, pDXView); 6519 6954 } 6520 6955 break; 6521 6956 case SVGA_COTABLE_DSVIEW: 6522 if (pBackendDXContext->pa pDepthStencilView)6957 if (pBackendDXContext->paDepthStencilView) 6523 6958 { 6524 for (uint32_t i = cValidEntries; i < pBackendDXContext->cDepthStencilView; ++i) 6525 D3D_RELEASE(pBackendDXContext->papDepthStencilView[i]); 6959 for (uint32_t i = 0; i < pBackendDXContext->cDepthStencilView; ++i) 6960 { 6961 DXVIEW *pDXView = &pBackendDXContext->paDepthStencilView[i]; 6962 if (i < cValidEntries) 6963 dxViewRemoveFromList(pDXView); /* Remove from list because DXVIEW array will be reallocated. */ 6964 else 6965 dxViewDestroy(pDXView); 6966 } 6526 6967 } 6527 6968 6528 rc = dxCOTableRealloc((void **)&pBackendDXContext->pa pDepthStencilView, &pBackendDXContext->cDepthStencilView,6529 sizeof(pBackendDXContext->pa pDepthStencilView[0]), pDXContext->cot.cDSView, cValidEntries);6969 rc = dxCOTableRealloc((void **)&pBackendDXContext->paDepthStencilView, &pBackendDXContext->cDepthStencilView, 6970 sizeof(pBackendDXContext->paDepthStencilView[0]), pDXContext->cot.cDSView, cValidEntries); 6530 6971 AssertRCBreak(rc); 6531 6972 … … 6536 6977 continue; /* Skip uninitialized entry. */ 6537 6978 6538 dxDefineDepthStencilView(pThisCC, pDXContext, i, pEntry); 6979 DXVIEW *pDXView = &pBackendDXContext->paDepthStencilView[i]; 6980 /** @todo Verify that the pEntry content still corresponds to the view. */ 6981 if (pDXView->u.pView) 6982 dxViewAddToList(pThisCC, pDXView); 6539 6983 } 6540 6984 break; 6541 6985 case SVGA_COTABLE_SRVIEW: 6542 if (pBackendDXContext->pa pShaderResourceView)6986 if (pBackendDXContext->paShaderResourceView) 6543 6987 { 6544 for (uint32_t i = cValidEntries; i < pBackendDXContext->cShaderResourceView; ++i) 6545 D3D_RELEASE(pBackendDXContext->papShaderResourceView[i]); 6988 for (uint32_t i = 0; i < pBackendDXContext->cShaderResourceView; ++i) 6989 { 6990 DXVIEW *pDXView = &pBackendDXContext->paShaderResourceView[i]; 6991 if (i < cValidEntries) 6992 dxViewRemoveFromList(pDXView); /* Remove from list because DXVIEW array will be reallocated. */ 6993 else 6994 dxViewDestroy(pDXView); 6995 } 6546 6996 } 6547 6997 6548 rc = dxCOTableRealloc((void **)&pBackendDXContext->pa pShaderResourceView, &pBackendDXContext->cShaderResourceView,6549 sizeof(pBackendDXContext->pa pShaderResourceView[0]), pDXContext->cot.cSRView, cValidEntries);6998 rc = dxCOTableRealloc((void **)&pBackendDXContext->paShaderResourceView, &pBackendDXContext->cShaderResourceView, 6999 sizeof(pBackendDXContext->paShaderResourceView[0]), pDXContext->cot.cSRView, cValidEntries); 6550 7000 AssertRCBreak(rc); 6551 7001 … … 6556 7006 continue; /* Skip uninitialized entry. */ 6557 7007 6558 dxDefineShaderResourceView(pThisCC, pDXContext, i, pEntry); 7008 DXVIEW *pDXView = &pBackendDXContext->paShaderResourceView[i]; 7009 /** @todo Verify that the pEntry content still corresponds to the view. */ 7010 if (pDXView->u.pView) 7011 dxViewAddToList(pThisCC, pDXView); 6559 7012 } 6560 7013 break; … … 6596 7049 continue; /* Skip uninitialized entry. */ 6597 7050 6598 dxDefineBlendState(p DXContext, i, pEntry);7051 dxDefineBlendState(pThisCC, pDXContext, i, pEntry); 6599 7052 } 6600 7053 break; … … 6616 7069 continue; /* Skip uninitialized entry. */ 6617 7070 6618 dxDefineDepthStencilState(p DXContext, i, pEntry);7071 dxDefineDepthStencilState(pThisCC, pDXContext, i, pEntry); 6619 7072 } 6620 7073 break; … … 6636 7089 continue; /* Skip uninitialized entry. */ 6637 7090 6638 dxDefineRasterizerState(p DXContext, i, pEntry);7091 dxDefineRasterizerState(pThisCC, pDXContext, i, pEntry); 6639 7092 } 6640 7093 break; … … 6656 7109 continue; /* Skip uninitialized entry. */ 6657 7110 6658 dxDefineSamplerState(p DXContext, i, pEntry);7111 dxDefineSamplerState(pThisCC, pDXContext, i, pEntry); 6659 7112 } 6660 7113 break; … … 7465 7918 p->pfnCreateTexture = vmsvga3dBackCreateTexture; 7466 7919 p->pfnSurfaceDestroy = vmsvga3dBackSurfaceDestroy; 7920 p->pfnSurfaceInvalidateImage = vmsvga3dBackSurfaceInvalidateImage; 7467 7921 p->pfnSurfaceCopy = vmsvga3dBackSurfaceCopy; 7468 7922 p->pfnSurfaceDMACopyBox = vmsvga3dBackSurfaceDMACopyBox; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r93115 r94063 1171 1171 1172 1172 1173 static DECLCALLBACK(void) vmsvga3dBackSurfaceInvalidateImage(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface, uint32_t uFace, uint32_t uMipmap) 1174 { 1175 RT_NOREF(pThisCC, pSurface, uFace, uMipmap); 1176 } 1177 1178 1173 1179 /* 1174 1180 * Release all shared surface objects. … … 6385 6391 p->pfnCreateTexture = vmsvga3dBackCreateTexture; 6386 6392 p->pfnSurfaceDestroy = vmsvga3dBackSurfaceDestroy; 6393 p->pfnSurfaceInvalidateImage = vmsvga3dBackSurfaceInvalidateImage; 6387 6394 p->pfnSurfaceCopy = vmsvga3dBackSurfaceCopy; 6388 6395 p->pfnSurfaceDMACopyBox = vmsvga3dBackSurfaceDMACopyBox; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r93115 r94063 1148 1148 AssertRCReturn(rc, rc); 1149 1149 1150 /* Invalidate views, etc. */ 1151 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1152 if (pSvgaR3State->pFuncs3D) 1153 pSvgaR3State->pFuncs3D->pfnSurfaceInvalidateImage(pThisCC, pSurface, face, mipmap); 1154 1150 1155 pMipmapLevel->fDirty = true; 1151 1156 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r93115 r94063 321 321 DECLCALLBACKMEMBER(int, pfnCreateTexture, (PVGASTATECC pThisCC, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface)); 322 322 DECLCALLBACKMEMBER(void, pfnSurfaceDestroy, (PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface)); 323 DECLCALLBACKMEMBER(void, pfnSurfaceInvalidateImage, (PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface, uint32_t uFace, uint32_t uMipmap)); 323 324 DECLCALLBACKMEMBER(int, pfnSurfaceCopy, (PVGASTATECC pThisCC, SVGA3dSurfaceImageId dest, SVGA3dSurfaceImageId src, uint32_t cCopyBoxes, SVGA3dCopyBox *pBox)); 324 325 DECLCALLBACKMEMBER(int, pfnSurfaceDMACopyBox, (PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
Note:
See TracChangeset
for help on using the changeset viewer.