[2/2] wined3d: Get rid of the BaseVertexIndex parameter to IWineD3DDeviceImpl_SetIndices, use SetBaseVertexIndex instead

H. Verbeet hverbeet at gmail.com
Tue Jun 5 11:52:21 CDT 2007


Wined3d doesn't need the BaseVertexIndex parameter, and d3d9's
SetIndices doesn't even have it.

Changelog:
  - Get rid of the BaseVertexIndex parameter to
IWineD3DDeviceImpl_SetIndices, use SetBaseVertexIndex instead
-------------- next part --------------
---

 dlls/d3d8/device.c               |    4 ++--
 dlls/d3d9/device.c               |    5 ++---
 dlls/ddraw/device.c              |    9 +++------
 dlls/ddraw/surface.c             |    2 +-
 dlls/wined3d/device.c            |   14 +++-----------
 dlls/wined3d/stateblock.c        |    6 ++++--
 include/wine/wined3d_interface.h |    4 ++--
 7 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index da3280d..9b718a4 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1444,9 +1444,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV
 static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
     TRACE("(%p) Relay\n", This);
+    IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
     return IWineD3DDevice_SetIndices(This->WineD3DDevice,
-                                     NULL == pIndexData ? NULL : ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer,
-                                     baseVertexIndex);
+            pIndexData ? ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
 }
 
 static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index c42f456..436b2a1 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -910,9 +910,8 @@ static HRESULT  WINAPI  IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVIC
 static HRESULT  WINAPI  IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData) {
     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     TRACE("(%p) Relay\n", This);
-    return IWineD3DDevice_SetIndices(This->WineD3DDevice, 
-                                     pIndexData==NULL ? NULL:((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer, 
-                                     0);
+    return IWineD3DDevice_SetIndices(This->WineD3DDevice,
+            pIndexData ? ((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
 }
 
 static HRESULT  WINAPI  IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9 **ppIndexData) {
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 5f423a1..38c7677 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -288,9 +288,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
 
         EnterCriticalSection(&ddraw_cs);
         /* Free the index buffer. */
-        IWineD3DDevice_SetIndices(This->wineD3DDevice,
-                                  NULL,
-                                  0);
+        IWineD3DDevice_SetIndices(This->wineD3DDevice, NULL);
         IWineD3DIndexBuffer_GetParent(This->indexbuffer,
                                       (IUnknown **) &IndexBufferParent);
         IParent_Release(IndexBufferParent); /* Once for the getParent */
@@ -3896,9 +3894,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
     }
 
     /* Set the index stream */
-    hr = IWineD3DDevice_SetIndices(This->wineD3DDevice,
-                                   This->indexbuffer,
-                                   StartVertex);
+    IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex);
+    hr = IWineD3DDevice_SetIndices(This->wineD3DDevice, This->indexbuffer);
 
     /* Set the vertex stream source */
     hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 2baac81..43c8448 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -311,7 +311,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
             TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
 
             /* Unset any index buffer, just to be sure */
-            IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL, 0);
+            IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL);
             IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
 
             if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface, D3D7CB_DestroySwapChain) != D3D_OK)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 61e3888..afa34c5 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2751,19 +2751,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINE
 /*****
  * Get / Set Indices
  *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer* pIndexData,
-                                             UINT BaseVertexIndex) {
+static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer* pIndexData) {
     IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DIndexBuffer *oldIdxs;
-    UINT oldBaseIndex = This->updateStateBlock->baseVertexIndex;
 
-    TRACE("(%p) : Setting to %p, base %d\n", This, pIndexData, BaseVertexIndex);
+    TRACE("(%p) : Setting to %p\n", This, pIndexData);
     oldIdxs = This->updateStateBlock->pIndexData;
 
     This->updateStateBlock->changed.indices = TRUE;
     This->updateStateBlock->set.indices = TRUE;
     This->updateStateBlock->pIndexData = pIndexData;
-    This->updateStateBlock->baseVertexIndex = BaseVertexIndex;
 
     /* Handle recording of state blocks */
     if (This->isRecordingState) {
@@ -2771,12 +2768,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWine
         return WINED3D_OK;
     }
 
-    /* The base vertex index affects the stream sources, while
-     * The index buffer is a seperate index buffer state
-     */
-    if(BaseVertexIndex != oldBaseIndex) {
-        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
-    }
     if(oldIdxs != pIndexData) {
         IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
     }
@@ -2817,6 +2808,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetBaseVertexIndex(IWineD3DDevice *ifac
         TRACE("Recording... not performing anything\n");
         return WINED3D_OK;
     }
+    /* The base vertex index affects the stream sources */
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
     return WINED3D_OK;
 }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 4213084..39051f1 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -711,8 +711,10 @@ should really perform a delta so that only the changes get updated*/
                 IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
         }
 
-        if (This->set.indices && This->changed.indices)
-            IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->baseVertexIndex);
+        if (This->set.indices && This->changed.indices) {
+            IWineD3DDevice_SetIndices(pDevice, This->pIndexData);
+            IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
+        }
 
         if (This->set.material && This->changed.material )
             IWineD3DDevice_SetMaterial(pDevice, &This->material);
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index c1bbd6b..abefdaf 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -403,7 +403,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
     STDMETHOD(GetFVF)(THIS_ DWORD * pfvf) PURE;
     STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain, DWORD Flags, CONST WINED3DGAMMARAMP* pRamp) PURE;
     STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain, WINED3DGAMMARAMP* pRamp) PURE;
-    STDMETHOD(SetIndices)(THIS_ struct IWineD3DIndexBuffer * pIndexData,UINT  BaseVertexIndex) PURE;
+    STDMETHOD(SetIndices)(THIS_ struct IWineD3DIndexBuffer * pIndexData) PURE;
     STDMETHOD(GetIndices)(THIS_ struct IWineD3DIndexBuffer ** ppIndexData,UINT * pBaseVertexIndex) PURE;
     STDMETHOD(SetBaseVertexIndex)(THIS_ UINT baseIndex);
     STDMETHOD(SetLight)(THIS_ DWORD  Index,CONST WINED3DLIGHT * pLight) PURE;
@@ -539,7 +539,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
 #define IWineD3DDevice_GetDepthStencilSurface(p,a)              (p)->lpVtbl->GetDepthStencilSurface(p,a)
 #define IWineD3DDevice_SetGammaRamp(p,a,b,c)                    (p)->lpVtbl->SetGammaRamp(p,a,b,c)
 #define IWineD3DDevice_GetGammaRamp(p,a,b)                      (p)->lpVtbl->GetGammaRamp(p,a,b)
-#define IWineD3DDevice_SetIndices(p,a,b)                        (p)->lpVtbl->SetIndices(p,a,b)
+#define IWineD3DDevice_SetIndices(p,a)                          (p)->lpVtbl->SetIndices(p,a)
 #define IWineD3DDevice_GetIndices(p,a,b)                        (p)->lpVtbl->GetIndices(p,a,b)
 #define IWineD3DDevice_SetBaseVertexIndex(p, a)                 (p)->lpVtbl->SetBaseVertexIndex(p, a)
 #define IWineD3DDevice_SetLight(p,a,b)                          (p)->lpVtbl->SetLight(p,a,b)


More information about the wine-patches mailing list