Changeset 91441 in vbox
- Timestamp:
- Sep 28, 2021 5:37:53 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r91375 r91441 3075 3075 { 3076 3076 #ifdef VMSVGA3D_DX 3077 DEBUG_BREAKPOINT_TEST();3077 //DEBUG_BREAKPOINT_TEST(); 3078 3078 RT_NOREF(cbCmd); 3079 3079 return vmsvga3dDXDefineStreamOutput(pThisCC, idDXContext, pCmd); … … 3103 3103 { 3104 3104 #ifdef VMSVGA3D_DX 3105 DEBUG_BREAKPOINT_TEST(); 3106 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 3107 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 3108 return vmsvga3dDXSetStreamOutput(pThisCC, idDXContext); 3105 //DEBUG_BREAKPOINT_TEST(); 3106 RT_NOREF(cbCmd); 3107 return vmsvga3dDXSetStreamOutput(pThisCC, idDXContext, pCmd); 3109 3108 #else 3110 3109 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.cpp
r91375 r91441 1617 1617 case VGPU10_OPCODE_DCL_OUTPUT: 1618 1618 case VGPU10_OPCODE_DCL_OUTPUT_SIV: 1619 case VGPU10_OPCODE_DCL_OUTPUT_SGV: 1619 1620 ASSERT_GUEST_RETURN(pInfo->cOutputSignature < RT_ELEMENTS(pInfo->aOutputSignature), VERR_INVALID_PARAMETER); 1620 1621 pSignatureEntry = &pInfo->aOutputSignature[pInfo->cOutputSignature++]; … … 1943 1944 1944 1945 1946 static char const *dxbcGetOutputSemanticName(DXShaderInfo const *pInfo, uint32_t idxRegister, uint32_t u32BlobType, 1947 uint32_t cSignature, SVGA3dDXSignatureEntry const *paSignature) 1948 { 1949 for (uint32_t i = 0; i < cSignature; ++i) 1950 { 1951 SVGA3dDXSignatureEntry const *p = &paSignature[i]; 1952 if (p->registerIndex == idxRegister) 1953 { 1954 AssertReturn(p->semanticName < SVGADX_SIGNATURE_SEMANTIC_NAME_MAX, NULL); 1955 VGPUSemanticInfo const *pSemanticInfo = dxbcSemanticInfo(pInfo, p->semanticName, u32BlobType); 1956 return pSemanticInfo->pszName; 1957 } 1958 } 1959 return NULL; 1960 } 1961 1962 char const *DXShaderGetOutputSemanticName(DXShaderInfo const *pInfo, uint32_t idxRegister) 1963 { 1964 return dxbcGetOutputSemanticName(pInfo, idxRegister, DXBC_BLOB_TYPE_OSGN, pInfo->cOutputSignature, &pInfo->aOutputSignature[0]); 1965 } 1966 1967 1945 1968 #ifdef DXBC_STANDALONE_TEST 1946 1969 static int dxbcCreateFromBytecode(void const *pvShaderCode, uint32_t cbShaderCode, void **ppvDXBC, uint32_t *pcbDXBC) -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.h
r88838 r91441 48 48 int DXShaderParse(void const *pvCode, uint32_t cbCode, DXShaderInfo *pInfo); 49 49 int DXShaderCreateDXBC(DXShaderInfo const *pInfo, void const *pvShader, uint32_t cbShader, void **ppvDXBC, uint32_t *pcbDXBC); 50 char const *DXShaderGetOutputSemanticName(DXShaderInfo const *pInfo, uint32_t idxRegister); 50 51 51 52 #endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_dx_shader_h */ -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp
r91375 r91441 1581 1581 memcpy(pEntry->decl, pCmd->decl, sizeof(pEntry->decl)); 1582 1582 memcpy(pEntry->streamOutputStrideInBytes, pCmd->streamOutputStrideInBytes, sizeof(pEntry->streamOutputStrideInBytes)); 1583 pEntry->rasterizedStream = pCmd->rasterizedStream;1584 pEntry->numOutputStreamStrides ;1583 pEntry->rasterizedStream = 0; // Apparently invalid in this command: pCmd->rasterizedStream; 1584 pEntry->numOutputStreamStrides = 0; 1585 1585 pEntry->mobid = SVGA_ID_INVALID; 1586 1586 pEntry->offsetInBytes = 0; … … 1623 1623 1624 1624 1625 int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext )1625 int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd) 1626 1626 { 1627 1627 int rc; … … 1635 1635 AssertRCReturn(rc, rc); 1636 1636 1637 rc = pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput(pThisCC, pDXContext); 1637 SVGA3dStreamOutputId const soid = pCmd->soid; 1638 1639 ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE); 1640 ASSERT_GUEST_RETURN( soid == SVGA_ID_INVALID 1641 || soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER); 1642 RT_UNTRUSTED_VALIDATED_FENCE(); 1643 1644 rc = pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput(pThisCC, pDXContext, soid); 1645 if (RT_SUCCESS(rc)) 1646 pDXContext->svgaDXContext.streamOut.soid = soid; 1647 1638 1648 return rc; 1639 1649 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r91375 r91441 59 59 IDXGIFactory *pDxgiFactory; /* DXGI Factory. */ 60 60 D3D_FEATURE_LEVEL FeatureLevel; 61 62 /* Staging buffer for transfer to surface buffers. */ 63 ID3D11Buffer *pStagingBuffer; /* The staging buffer resource. */ 64 uint32_t cbStagingBuffer; /* Current size of the staging buffer resource. */ 61 65 } DXDEVICE; 62 66 … … 145 149 void *pvDXBC; 146 150 uint32_t cbDXBC; 151 152 uint32_t soid; /* Stream output declarations for geometry shaders. */ 147 153 } DXSHADER; 148 154 149 155 typedef struct DXSTREAMOUTPUT 150 156 { 151 ID3D11Buffer *pSOBuffer; 157 UINT cDeclarationEntry; 158 D3D11_SO_DECLARATION_ENTRY aDeclarationEntry[SVGA3D_MAX_STREAMOUT_DECLS]; 152 159 } DXSTREAMOUTPUT; 153 160 161 #define DX_DEFERRED_SET_RENDER_TARGETS 154 162 typedef struct VMSVGA3DBACKENDDXCONTEXT 155 163 { … … 179 187 DXSHADER *paShader; 180 188 DXSTREAMOUTPUT *paStreamOutput; 189 190 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 191 struct 192 { 193 ID3D11RenderTargetView *papRenderTargetViews[SVGA3D_MAX_RENDER_TARGETS]; 194 uint32_t cRenderTargetViews; 195 ID3D11DepthStencilView *pDepthStencilView; 196 } state; 197 #endif 198 199 uint32_t cSOTarget; /* How many SO targets are currently set (SetSOTargets) */ 181 200 } VMSVGA3DBACKENDDXCONTEXT; 182 201 … … 744 763 D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET, /* U. */ 745 764 D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH, /* U. */ 765 D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT, /* P. */ 746 766 }; 747 767 … … 784 804 { 785 805 RT_NOREF(pBackend); 806 807 D3D_RELEASE(pDevice->pStagingBuffer); 808 786 809 if (pDevice->pImmediateContext) 787 810 pDevice->pImmediateContext->ClearState(); … … 952 975 } 953 976 977 954 978 static int dxDefineStreamOutput(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid, SVGACOTableDXStreamOutputEntry const *pEntry) 955 979 { 956 RT_NOREF(pDXContext, soid, pEntry); 980 DXSTREAMOUTPUT *pDXStreamOutput = &pDXContext->pBackendDXContext->paStreamOutput[soid]; 981 982 /* Make D3D11_SO_DECLARATION_ENTRY array from SVGA3dStreamOutputDeclarationEntry. */ 983 pDXStreamOutput->cDeclarationEntry = pEntry->numOutputStreamEntries; 984 for (uint32_t i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i) 985 { 986 D3D11_SO_DECLARATION_ENTRY *pDst = &pDXStreamOutput->aDeclarationEntry[i]; 987 SVGA3dStreamOutputDeclarationEntry const *pSrc = &pEntry->decl[i]; 988 989 uint32_t const registerMask = pSrc->registerMask & 0xF; 990 unsigned const iFirstBit = ASMBitFirstSetU32(registerMask); 991 unsigned const iLastBit = ASMBitLastSetU32(registerMask); 992 993 pDst->Stream = pSrc->stream; 994 pDst->SemanticName = NULL; /* Will be taken from the shader output declaration. */ 995 pDst->SemanticIndex = 0; 996 pDst->StartComponent = iFirstBit > 0 ? iFirstBit - 1 : 0; 997 pDst->ComponentCount = iFirstBit > 0 ? iLastBit - (iFirstBit - 1) : 0; 998 pDst->OutputSlot = pSrc->outputSlot; 999 } 1000 957 1001 return VINF_SUCCESS; 958 1002 } … … 960 1004 static void dxDestroyStreamOutput(DXSTREAMOUTPUT *pDXStreamOutput) 961 1005 { 962 D3D_RELEASE(pDXStreamOutput->pSOBuffer);1006 RT_NOREF(pDXStreamOutput); 963 1007 } 964 1008 … … 1296 1340 1297 1341 1298 static HRESULT dxShaderCreate(DXDEVICE *pDevice, PVMSVGA3DSHADER pShader, DXSHADER *pDXShader) 1299 { 1342 static HRESULT dxShaderCreate(PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader, DXSHADER *pDXShader) 1343 { 1344 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 1345 1300 1346 HRESULT hr = S_OK; 1301 1347 … … 1311 1357 break; 1312 1358 case SVGA3D_SHADERTYPE_GS: 1313 hr = pDevice->pDevice->CreateGeometryShader(pDXShader->pvDXBC, pDXShader->cbDXBC, NULL, &pDXShader->pGeometryShader); 1359 { 1360 SVGA3dStreamOutputId const soid = pDXContext->svgaDXContext.streamOut.soid; 1361 if (soid == SVGA_ID_INVALID) 1362 hr = pDevice->pDevice->CreateGeometryShader(pDXShader->pvDXBC, pDXShader->cbDXBC, NULL, &pDXShader->pGeometryShader); 1363 else 1364 { 1365 ASSERT_GUEST_RETURN(soid < pDXContext->pBackendDXContext->cStreamOutput, E_INVALIDARG); 1366 1367 SVGACOTableDXStreamOutputEntry const *pEntry = &pDXContext->cot.paStreamOutput[soid]; 1368 DXSTREAMOUTPUT *pDXStreamOutput = &pDXContext->pBackendDXContext->paStreamOutput[soid]; 1369 uint32_t const cSOTarget = pDXContext->pBackendDXContext->cSOTarget; 1370 1371 for (uint32_t i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i) 1372 { 1373 D3D11_SO_DECLARATION_ENTRY *p = &pDXStreamOutput->aDeclarationEntry[i]; 1374 SVGA3dStreamOutputDeclarationEntry const *decl = &pEntry->decl[i]; 1375 p->SemanticName = DXShaderGetOutputSemanticName(&pShader->shaderInfo, decl->registerIndex); 1376 } 1377 1378 hr = pDevice->pDevice->CreateGeometryShaderWithStreamOutput(pDXShader->pvDXBC, pDXShader->cbDXBC, 1379 pDXStreamOutput->aDeclarationEntry, pDXStreamOutput->cDeclarationEntry, 1380 pEntry->streamOutputStrideInBytes, cSOTarget, pEntry->rasterizedStream, 1381 /*pClassLinkage=*/ NULL, &pDXShader->pGeometryShader); 1382 if (SUCCEEDED(hr)) 1383 pDXShader->soid = soid; 1384 } 1314 1385 Assert(SUCCEEDED(hr)); 1315 1386 break; 1387 } 1316 1388 case SVGA3D_SHADERTYPE_HS: 1317 1389 case SVGA3D_SHADERTYPE_DS: … … 1325 1397 1326 1398 1327 static void dxShaderSet(DXDEVICE *pDevice, SVGA3dShaderType type, DXSHADER *pDXShader) 1328 { 1399 static void dxShaderSet(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderType type, DXSHADER *pDXShader) 1400 { 1401 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 1402 1329 1403 switch (type) 1330 1404 { … … 1336 1410 break; 1337 1411 case SVGA3D_SHADERTYPE_GS: 1412 { 1413 Assert(!pDXShader || (pDXShader->soid == pDXContext->svgaDXContext.streamOut.soid)); 1338 1414 pDevice->pImmediateContext->GSSetShader(pDXShader ? pDXShader->pGeometryShader : NULL, NULL, 0); 1339 1415 } break; 1340 1416 case SVGA3D_SHADERTYPE_HS: 1341 1417 case SVGA3D_SHADERTYPE_DS: … … 2052 2128 | SVGA3D_SURFACE_BIND_VERTEX_BUFFER 2053 2129 | SVGA3D_SURFACE_BIND_INDEX_BUFFER 2054 /// @todo only for constant buffers| SVGA3D_SURFACE_BIND_CONSTANT_BUFFER2055 //| SVGA3D_SURFACE_BIND_STREAM_OUTPUT2056 2130 )), VERR_INVALID_PARAMETER); 2057 2131 … … 2062 2136 } 2063 2137 2138 PVMSVGA3DMIPMAPLEVEL pMipLevel; 2139 int rc = vmsvga3dMipmapLevel(pSurface, 0, 0, &pMipLevel); 2140 AssertRCReturn(rc, rc); 2141 2064 2142 PVMSVGA3DBACKENDSURFACE pBackendSurface; 2065 intrc = dxBackendSurfaceAlloc(&pBackendSurface);2143 rc = dxBackendSurfaceAlloc(&pBackendSurface); 2066 2144 AssertRCReturn(rc, rc); 2145 2146 /* Upload the current data, if any. */ 2147 D3D11_SUBRESOURCE_DATA *pInitialData = NULL; 2148 D3D11_SUBRESOURCE_DATA initialData; 2149 if (pMipLevel->pSurfaceData) 2150 { 2151 initialData.pSysMem = pMipLevel->pSurfaceData; 2152 initialData.SysMemPitch = pMipLevel->cbSurface; 2153 initialData.SysMemSlicePitch = pMipLevel->cbSurface; 2154 2155 pInitialData = &initialData; 2156 2157 pMipLevel->fDirty = false; 2158 pSurface->fDirty = false; 2159 } 2067 2160 2068 2161 D3D11_BUFFER_DESC bd; 2069 2162 RT_ZERO(bd); 2070 bd.ByteWidth = pSurface->paMipmapLevels[0].cbSurface; 2071 bd.Usage = D3D11_USAGE_DYNAMIC; 2072 bd.BindFlags = D3D11_BIND_VERTEX_BUFFER 2073 | D3D11_BIND_INDEX_BUFFER 2074 //| D3D11_BIND_CONSTANT_BUFFER 2075 //| D3D11_BIND_STREAM_OUTPUT 2076 ; 2077 bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 2078 bd.MiscFlags = 0; 2079 bd.StructureByteStride = 0; 2080 2081 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, 0, &pBackendSurface->u.pBuffer); 2163 bd.ByteWidth = pMipLevel->cbSurface; 2164 bd.Usage = D3D11_USAGE_DEFAULT; 2165 bd.BindFlags = D3D11_BIND_VERTEX_BUFFER 2166 | D3D11_BIND_INDEX_BUFFER; 2167 2168 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u.pBuffer); 2082 2169 if (SUCCEEDED(hr)) 2083 2170 { … … 2089 2176 pSurface->pBackendSurface = pBackendSurface; 2090 2177 pSurface->idAssociatedContext = pDXContext->cid; 2091 pSurface->fDirty = true;2092 2178 return VINF_SUCCESS; 2093 2179 } … … 2311 2397 RTMemFree(pBackendSurface); 2312 2398 return VERR_NO_MEMORY; 2399 } 2400 2401 2402 static int dxStagingBufferRealloc(DXDEVICE *pDXDevice, uint32_t cbRequiredSize) 2403 { 2404 AssertReturn(cbRequiredSize < SVGA3D_MAX_SURFACE_MEM_SIZE, VERR_INVALID_PARAMETER); 2405 2406 if (RT_LIKELY(cbRequiredSize <= pDXDevice->cbStagingBuffer)) 2407 return VINF_SUCCESS; 2408 2409 D3D_RELEASE(pDXDevice->pStagingBuffer); 2410 2411 uint32_t const cbAlloc = RT_ALIGN_32(cbRequiredSize, _64K); 2412 2413 D3D11_SUBRESOURCE_DATA *pInitialData = NULL; 2414 D3D11_BUFFER_DESC bd; 2415 RT_ZERO(bd); 2416 bd.ByteWidth = cbAlloc; 2417 bd.Usage = D3D11_USAGE_STAGING; 2418 //bd.BindFlags = 0; /* No bind flags are allowed for staging resources. */ 2419 bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ; 2420 2421 int rc = VINF_SUCCESS; 2422 ID3D11Buffer *pBuffer; 2423 HRESULT hr = pDXDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBuffer); 2424 if (SUCCEEDED(hr)) 2425 { 2426 pDXDevice->pStagingBuffer = pBuffer; 2427 pDXDevice->cbStagingBuffer = cbAlloc; 2428 } 2429 else 2430 { 2431 pDXDevice->cbStagingBuffer = 0; 2432 rc = VERR_NO_MEMORY; 2433 } 2434 2435 return rc; 2313 2436 } 2314 2437 … … 2659 2782 clipBox.d = pMipLevel->mipmapSize.depth; 2660 2783 } 2661 2662 /// @todo Hack. Need Staging buffer ro CopyResource data to the actual buffer2663 if (enmMapType == VMSVGA3D_SURFACE_MAP_WRITE && pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER)2664 enmMapType = VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;2665 2784 2666 2785 D3D11_MAP d3d11MapType; … … 2801 2920 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER) 2802 2921 { 2803 UINT const Subresource = 0; /* Buffers have only one subresource. */ 2804 HRESULT hr = pDevice->pImmediateContext->Map(pSurface->pBackendSurface->u.pBuffer, Subresource, 2805 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 2806 if (SUCCEEDED(hr)) 2922 /* Map the staging buffer. */ 2923 rc = dxStagingBufferRealloc(pDevice, pMipLevel->cbSurface); 2924 if (RT_SUCCESS(rc)) 2807 2925 { 2808 pMap->enmMapType = enmMapType; 2809 pMap->box = clipBox; 2810 pMap->cbPixel = pSurface->cbBlock; 2811 pMap->cbRowPitch = mappedResource.RowPitch; 2812 pMap->cbDepthPitch = mappedResource.DepthPitch; 2813 pMap->pvData = (uint8_t *)mappedResource.pData 2814 + pMap->box.x * pMap->cbPixel 2815 + pMap->box.y * pMap->cbRowPitch 2816 + pMap->box.z * pMap->cbDepthPitch; 2926 if (enmMapType == VMSVGA3D_SURFACE_MAP_READ) 2927 { 2928 /* Copy from the buffer to the staging buffer. */ 2929 ID3D11Resource *pDstResource = pDevice->pStagingBuffer; 2930 UINT DstSubresource = 0; 2931 UINT DstX = clipBox.x; 2932 UINT DstY = clipBox.y; 2933 UINT DstZ = clipBox.z; 2934 ID3D11Resource *pSrcResource = pBackendSurface->u.pResource; 2935 UINT SrcSubresource = 0; 2936 D3D11_BOX SrcBox; 2937 SrcBox.left = clipBox.x; 2938 SrcBox.top = clipBox.y; 2939 SrcBox.front = clipBox.z; 2940 SrcBox.right = clipBox.w; 2941 SrcBox.bottom = clipBox.h; 2942 SrcBox.back = clipBox.d; 2943 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 2944 pSrcResource, SrcSubresource, &SrcBox); 2945 } 2946 2947 UINT const Subresource = 0; /* Buffers have only one subresource. */ 2948 HRESULT hr = pDevice->pImmediateContext->Map(pDevice->pStagingBuffer, Subresource, 2949 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 2950 if (SUCCEEDED(hr)) 2951 { 2952 pMap->enmMapType = enmMapType; 2953 pMap->box = clipBox; 2954 pMap->cbPixel = pSurface->cbBlock; 2955 pMap->cbRowPitch = mappedResource.RowPitch; 2956 pMap->cbDepthPitch = mappedResource.DepthPitch; 2957 pMap->pvData = (uint8_t *)mappedResource.pData 2958 + pMap->box.x * pMap->cbPixel 2959 + pMap->box.y * pMap->cbRowPitch 2960 + pMap->box.z * pMap->cbDepthPitch; 2961 } 2962 else 2963 rc = VERR_NOT_SUPPORTED; 2817 2964 } 2818 else2819 rc = VERR_NOT_SUPPORTED;2820 2965 } 2821 2966 else … … 2878 3023 UINT DstY = pMap->box.y; 2879 3024 UINT DstZ = pMap->box.z; 2880 ID3D11Resource *pSrcResource = p BackendSurface->pDynamicTexture;3025 ID3D11Resource *pSrcResource = pMappedTexture; 2881 3026 UINT SrcSubresource = Subresource; 2882 3027 D3D11_BOX SrcBox; … … 2962 3107 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER) 2963 3108 { 3109 /* Unmap the staging buffer. */ 2964 3110 UINT const Subresource = 0; /* Buffers have only one subresource. */ 2965 pDevice->pImmediateContext->Unmap(pBackendSurface->u.pBuffer, Subresource); 3111 pDevice->pImmediateContext->Unmap(pDevice->pStagingBuffer, Subresource); 3112 3113 /* Copy from the staging buffer to the actual buffer */ 3114 if ( fWritten 3115 && ( pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE 3116 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ_WRITE 3117 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD)) 3118 { 3119 ID3D11Resource *pDstResource = pBackendSurface->u.pResource; 3120 UINT DstSubresource = 0; 3121 UINT DstX = (pMap->box.x / pSurface->cxBlock) * pSurface->cxBlock; 3122 UINT DstY = (pMap->box.y / pSurface->cyBlock) * pSurface->cyBlock; 3123 UINT DstZ = pMap->box.z; 3124 ID3D11Resource *pSrcResource = pDevice->pStagingBuffer; 3125 UINT SrcSubresource = 0; 3126 D3D11_BOX SrcBox; 3127 3128 uint32_t const cxBlocks = (pMap->box.w + pSurface->cxBlock - 1) / pSurface->cxBlock; 3129 uint32_t const cyBlocks = (pMap->box.h + pSurface->cyBlock - 1) / pSurface->cyBlock; 3130 3131 SrcBox.left = DstX; 3132 SrcBox.top = DstY; 3133 SrcBox.front = DstZ; 3134 SrcBox.right = DstX + cxBlocks * pSurface->cxBlock; 3135 SrcBox.bottom = DstY + cyBlocks * pSurface->cyBlock; 3136 SrcBox.back = DstZ + pMap->box.d; 3137 3138 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 3139 pSrcResource, SrcSubresource, &SrcBox); 3140 } 2966 3141 } 2967 3142 else … … 4630 4805 pDXShader = NULL; 4631 4806 4632 dxShaderSet(pD evice, type, pDXShader);4807 dxShaderSet(pDXContext, type, pDXShader); 4633 4808 return VINF_SUCCESS; 4634 4809 } … … 4664 4839 4665 4840 4841 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4842 static void dxSetupPipeline(PVMSVGA3DDXCONTEXT pDXContext) 4843 { 4844 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4845 AssertReturnVoid(pDevice->pDevice); 4846 4847 pDevice->pImmediateContext->OMSetRenderTargets(pDXContext->pBackendDXContext->state.cRenderTargetViews, 4848 pDXContext->pBackendDXContext->state.papRenderTargetViews, 4849 pDXContext->pBackendDXContext->state.pDepthStencilView); 4850 } 4851 #endif 4852 4853 4666 4854 static DECLCALLBACK(int) vmsvga3dBackDXDraw(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t vertexCount, uint32_t startVertexLocation) 4667 4855 { … … 4671 4859 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4672 4860 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4861 4862 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4863 dxSetupPipeline(pDXContext); 4864 #endif 4673 4865 4674 4866 if (pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN) … … 4754 4946 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4755 4947 4948 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4949 dxSetupPipeline(pDXContext); 4950 #endif 4951 4756 4952 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4757 4953 … … 4774 4970 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4775 4971 4972 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4973 dxSetupPipeline(pDXContext); 4974 #endif 4975 4776 4976 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4777 4977 … … 4794 4994 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4795 4995 4996 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 4997 dxSetupPipeline(pDXContext); 4998 #endif 4999 4796 5000 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4797 5001 … … 4809 5013 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4810 5014 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5015 5016 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 5017 dxSetupPipeline(pDXContext); 5018 #endif 4811 5019 4812 5020 RT_NOREF(pBackend, pDXContext); … … 4882 5090 if (pSurface->pBackendSurface == NULL) 4883 5091 { 4884 /* Create the resource . */5092 /* Create the resource and initialize it with the current surface data. */ 4885 5093 rc = vmsvga3dBackSurfaceCreateBuffer(pThisCC, pDXContext, pSurface); 4886 5094 AssertRCReturn(rc, rc); 4887 5095 } 4888 5096 #if 0 4889 5097 if (pSurface->fDirty) 4890 5098 { … … 4906 5114 AssertRCReturn(rc, rc); 4907 5115 } 5116 #endif 4908 5117 4909 5118 Assert(pSurface->pBackendSurface->u.pBuffer); … … 4951 5160 if (pSurface->pBackendSurface == NULL) 4952 5161 { 4953 /* Create the resource . */5162 /* Create the resource and initialize it with the current surface data. */ 4954 5163 rc = vmsvga3dBackSurfaceCreateBuffer(pThisCC, pDXContext, pSurface); 4955 5164 AssertRCReturn(rc, rc); 4956 5165 } 4957 5166 #if 0 4958 5167 if (pSurface->fDirty) 4959 5168 { … … 4975 5184 AssertRCReturn(rc, rc); 4976 5185 } 4977 5186 #endif 4978 5187 pResource = pSurface->pBackendSurface->u.pBuffer; 4979 5188 enmDxgiFormat = vmsvgaDXSurfaceFormat2Dxgi(format); … … 5064 5273 5065 5274 ID3D11RenderTargetView *papRenderTargetViews[SVGA3D_MAX_RENDER_TARGETS]; 5275 RT_ZERO(papRenderTargetViews); 5066 5276 for (uint32_t i = 0; i < cRenderTargetViewId; ++i) 5067 5277 { … … 5072 5282 papRenderTargetViews[i] = pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]; 5073 5283 } 5074 else5075 papRenderTargetViews[i] = NULL;5076 5284 } 5077 5285 … … 5082 5290 pDepthStencilView = NULL; 5083 5291 5292 #ifdef DX_DEFERRED_SET_RENDER_TARGETS 5293 memcpy(pDXContext->pBackendDXContext->state.papRenderTargetViews, papRenderTargetViews, sizeof(papRenderTargetViews)); 5294 pDXContext->pBackendDXContext->state.cRenderTargetViews = cRenderTargetViewId; 5295 pDXContext->pBackendDXContext->state.pDepthStencilView = pDepthStencilView; 5296 pDevice->pImmediateContext->OMSetRenderTargets(0, NULL, NULL); 5297 #else 5084 5298 pDevice->pImmediateContext->OMSetRenderTargets(cRenderTargetViewId, papRenderTargetViews, pDepthStencilView); 5299 #endif 5085 5300 return VINF_SUCCESS; 5086 5301 } … … 5217 5432 5218 5433 5219 static DECLCALLBACK(int) vmsvga3dBackDXSetSOTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cS oTarget, SVGA3dSoTarget const *paSoTarget)5434 static DECLCALLBACK(int) vmsvga3dBackDXSetSOTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cSOTarget, SVGA3dSoTarget const *paSoTarget) 5220 5435 { 5221 5436 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; … … 5238 5453 { 5239 5454 /* Get corresponding resource. Create the buffer if does not yet exist. */ 5240 if (i < cS oTarget && paSoTarget[i].sid != SVGA_ID_INVALID)5455 if (i < cSOTarget && paSoTarget[i].sid != SVGA_ID_INVALID) 5241 5456 { 5242 5457 PVMSVGA3DSURFACE pSurface; … … 5266 5481 pDXContext->svgaDXContext.streamOut.targets[i] = SVGA_ID_INVALID; 5267 5482 } 5268 5269 /// @todo pDXContext->svgaDXContext.streamOut.soid?5270 5483 } 5271 5484 5272 5485 pDevice->pImmediateContext->SOSetTargets(SVGA3D_DX_MAX_SOTARGETS, paResource, paOffset); 5486 5487 pDXContext->pBackendDXContext->cSOTarget = cSOTarget; 5273 5488 5274 5489 return VINF_SUCCESS; … … 5785 6000 static int dxDefineShader(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry) 5786 6001 { 6002 /** @todo A common approach for creation of COTable backend objects: runtime, empty DX COTable, live DX COTable. */ 5787 6003 DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shaderId]; 5788 pDXShader->enmShaderType = pEntry->type; 6004 if (pDXShader->enmShaderType == SVGA3D_SHADERTYPE_INVALID) 6005 { 6006 /* Init the shader structure. */ 6007 pDXShader->enmShaderType = pEntry->type; 6008 pDXShader->soid = SVGA_ID_INVALID; 6009 } 5789 6010 5790 6011 PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId]; … … 5802 6023 pDXShader->pvDXBC = NULL; 5803 6024 pDXShader->cbDXBC = 0; 6025 pDXShader->soid = SVGA_ID_INVALID; 5804 6026 return VINF_SUCCESS; 5805 6027 } … … 5891 6113 #endif 5892 6114 5893 HRESULT hr = dxShaderCreate(pD evice, pShader, pDXShader);6115 HRESULT hr = dxShaderCreate(pDXContext, pShader, pDXShader); 5894 6116 if (SUCCEEDED(hr)) 5895 6117 { … … 5930 6152 5931 6153 5932 static DECLCALLBACK(int) vmsvga3dBackDXSetStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5933 { 5934 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5935 5936 RT_NOREF(pBackend, pDXContext); 5937 AssertFailed(); /** @todo Implement */ 5938 return VERR_NOT_IMPLEMENTED; 6154 static DECLCALLBACK(int) vmsvga3dBackDXSetStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid) 6155 { 6156 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 6157 RT_NOREF(pBackend, pDXContext, soid); 6158 6159 return VINF_SUCCESS; 5939 6160 } 5940 6161 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r91375 r91441 454 454 DECLCALLBACKMEMBER(int, pfnDXDefineStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid, SVGACOTableDXStreamOutputEntry const *pEntry)); 455 455 DECLCALLBACKMEMBER(int, pfnDXDestroyStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid)); 456 DECLCALLBACKMEMBER(int, pfnDXSetStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext ));456 DECLCALLBACKMEMBER(int, pfnDXSetStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid)); 457 457 DECLCALLBACKMEMBER(int, pfnDXSetCOTable, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t cValidEntries)); 458 458 DECLCALLBACKMEMBER(int, pfnDXBufferCopy, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); … … 583 583 int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd); 584 584 int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd); 585 int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext );585 int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd); 586 586 int vmsvga3dDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, PVMSVGAMOB pMob); 587 587 int vmsvga3dDXReadbackCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackCOTable const *pCmd);
Note:
See TracChangeset
for help on using the changeset viewer.