- Timestamp:
- Nov 25, 2019 11:56:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDdi.cpp
r81904 r82169 2648 2648 if (SUCCEEDED(hr)) 2649 2649 { 2650 /* Convert input data to appropriate DrawIndexedPrimitiveUP parameters. 2651 * In particular prepare zero based vertex array becuase wine does not 2652 * handle MinVertexIndex correctly. 2650 hr = pDevice9If->DrawIndexedPrimitiveUP(pData->PrimitiveType, 2651 pData->MinIndex, 2652 pData->NumVertices, 2653 pData->PrimitiveCount, 2654 (uint8_t *)pIndexBuffer + pData->StartIndexOffset, 2655 dwIndicesSize == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, 2656 pu8VertexBuffer + pData->BaseVertexOffset, 2657 cbVertexStride); 2658 2659 if (SUCCEEDED(hr)) 2660 hr = S_OK; 2661 else 2662 WARN(("DrawIndexedPrimitiveUP failed hr = 0x%x", hr)); 2663 2664 /* Following any IDirect3DDevice9::DrawIndexedPrimitiveUP call, the stream 0 settings, 2665 * referenced by IDirect3DDevice9::GetStreamSource, are set to NULL. Also, the index 2666 * buffer setting for IDirect3DDevice9::SetIndices is set to NULL. 2653 2667 */ 2654 2655 /* Take the offset, which corresponds to the index == 0, into account. */ 2656 const uint8_t *pu8VertexStart = pu8VertexBuffer + pData->BaseVertexOffset; 2657 2658 /* Where the pData->MinIndex starts. */ 2659 pu8VertexStart += pData->MinIndex * cbVertexStride; 2660 2661 /* Convert indexes to zero based relative to pData->MinIndex. */ 2662 const uint8_t *pu8IndicesStartSrc = (uint8_t *)pIndexBuffer + pData->StartIndexOffset; 2663 UINT cIndices = vboxWddmVertexCountFromPrimitive(pData->PrimitiveType, pData->PrimitiveCount); 2664 2665 /* Allocate memory for converted indices. */ 2666 uint8_t *pu8IndicesStartConv = (uint8_t *)RTMemAlloc(cIndices * dwIndicesSize); 2667 if (pu8IndicesStartConv != NULL) 2668 { 2669 UINT i; 2670 if (dwIndicesSize == 2) 2671 { 2672 uint16_t *pu16Src = (uint16_t *)pu8IndicesStartSrc; 2673 uint16_t *pu16Dst = (uint16_t *)pu8IndicesStartConv; 2674 for (i = 0; i < cIndices; ++i, ++pu16Dst, ++pu16Src) 2675 { 2676 *pu16Dst = *pu16Src - pData->MinIndex; 2677 } 2678 } 2679 else 2680 { 2681 uint32_t *pu32Src = (uint32_t *)pu8IndicesStartSrc; 2682 uint32_t *pu32Dst = (uint32_t *)pu8IndicesStartConv; 2683 for (i = 0; i < cIndices; ++i, ++pu32Dst, ++pu32Src) 2684 { 2685 *pu32Dst = *pu32Src - pData->MinIndex; 2686 } 2687 } 2688 2689 hr = pDevice9If->DrawIndexedPrimitiveUP(pData->PrimitiveType, 2690 0, 2691 pData->NumVertices, 2692 pData->PrimitiveCount, 2693 pu8IndicesStartConv, 2694 dwIndicesSize == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, 2695 pu8VertexStart, 2696 cbVertexStride); 2697 2698 if (SUCCEEDED(hr)) 2699 hr = S_OK; 2700 else 2701 WARN(("DrawIndexedPrimitiveUP failed hr = 0x%x", hr)); 2702 2703 RTMemFree(pu8IndicesStartConv); 2704 2705 /* Following any IDirect3DDevice9::DrawIndexedPrimitiveUP call, the stream 0 settings, 2706 * referenced by IDirect3DDevice9::GetStreamSource, are set to NULL. Also, the index 2707 * buffer setting for IDirect3DDevice9::SetIndices is set to NULL. 2708 */ 2709 if (pDevice->aStreamSource[0]) 2710 { 2711 HRESULT tmpHr = pDevice9If->SetStreamSource(0, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[0]->pD3DIf, 2712 pDevice->StreamSourceInfo[0].uiOffset, 2713 pDevice->StreamSourceInfo[0].uiStride); 2714 if(!SUCCEEDED(tmpHr)) 2715 WARN(("SetStreamSource failed hr = 0x%x", tmpHr)); 2716 } 2717 2718 if (pDevice->IndiciesInfo.pIndicesAlloc) 2719 { 2720 HRESULT tmpHr = pDevice9If->SetIndices((IDirect3DIndexBuffer9*)pDevice->IndiciesInfo.pIndicesAlloc->pD3DIf); 2721 if(!SUCCEEDED(tmpHr)) 2722 WARN(("SetIndices failed hr = 0x%x", tmpHr)); 2723 } 2724 } 2725 else 2726 { 2727 hr = E_OUTOFMEMORY; 2668 if (pDevice->aStreamSource[0]) 2669 { 2670 HRESULT tmpHr = pDevice9If->SetStreamSource(0, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[0]->pD3DIf, 2671 pDevice->StreamSourceInfo[0].uiOffset, 2672 pDevice->StreamSourceInfo[0].uiStride); 2673 if(!SUCCEEDED(tmpHr)) 2674 WARN(("SetStreamSource failed hr = 0x%x", tmpHr)); 2675 } 2676 2677 if (pDevice->IndiciesInfo.pIndicesAlloc) 2678 { 2679 HRESULT tmpHr = pDevice9If->SetIndices((IDirect3DIndexBuffer9*)pDevice->IndiciesInfo.pIndicesAlloc->pD3DIf); 2680 if(!SUCCEEDED(tmpHr)) 2681 WARN(("SetIndices failed hr = 0x%x", tmpHr)); 2728 2682 } 2729 2683 }
Note:
See TracChangeset
for help on using the changeset viewer.