Henri Verbeet : wined3d: Move the vertex declaration to wined3d_state.

Alexandre Julliard julliard at winehq.org
Sat Sep 18 07:42:21 CDT 2010


Module: wine
Branch: master
Commit: e31ea51bab250f2ea65f8d608da637f65ee29042
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e31ea51bab250f2ea65f8d608da637f65ee29042

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Sep 17 11:59:41 2010 +0200

wined3d: Move the vertex declaration to wined3d_state.

---

 dlls/wined3d/buffer.c          |    2 +-
 dlls/wined3d/device.c          |   22 +++++++++++++---------
 dlls/wined3d/stateblock.c      |   23 ++++++++++++++---------
 dlls/wined3d/utils.c           |    2 +-
 dlls/wined3d/wined3d_private.h |    7 +++----
 5 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 4660333..31ef339 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -467,7 +467,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
          * analyse the strided streams in depth, just set them up for no conversion. Return decl changed
          * if we used conversion before
          */
-        if (!((IWineD3DVertexDeclarationImpl *) device->stateBlock->vertexDecl)->half_float_conv_needed)
+        if (!device->stateBlock->state.vertex_declaration->half_float_conv_needed)
         {
             if (This->conversion_map)
             {
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 7bf601b..3a54f42 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -177,7 +177,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
         BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup)
 {
     /* We need to deal with frequency data! */
-    IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
+    IWineD3DVertexDeclarationImpl *declaration = This->stateBlock->state.vertex_declaration;
     unsigned int i;
 
     stream_info->use_map = 0;
@@ -426,7 +426,7 @@ void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_
 
     if (vs && !stream_info->position_transformed)
     {
-        if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup)
+        if (stateblock->state.vertex_declaration->half_float_conv_needed && !fixup)
         {
             TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n");
             device->useDrawStridedSlow = TRUE;
@@ -3164,14 +3164,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, R
 
 static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
-    IWineD3DVertexDeclaration *oldDecl = This->updateStateBlock->vertexDecl;
+    IWineD3DVertexDeclaration *oldDecl = (IWineD3DVertexDeclaration *)This->updateStateBlock->state.vertex_declaration;
 
     TRACE("(%p) : pDecl=%p\n", This, pDecl);
 
     if (pDecl) IWineD3DVertexDeclaration_AddRef(pDecl);
     if (oldDecl) IWineD3DVertexDeclaration_Release(oldDecl);
 
-    This->updateStateBlock->vertexDecl = pDecl;
+    This->updateStateBlock->state.vertex_declaration = (IWineD3DVertexDeclarationImpl *)pDecl;
     This->updateStateBlock->changed.vertexDecl = TRUE;
 
     if (This->isRecordingState) {
@@ -3192,7 +3192,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* if
 
     TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
 
-    *ppDecl = This->stateBlock->vertexDecl;
+    *ppDecl = (IWineD3DVertexDeclaration *)This->stateBlock->state.vertex_declaration;
     if (*ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
     return WINED3D_OK;
 }
@@ -4671,7 +4671,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UI
 
     TRACE("(%p) : start %u, count %u\n", This, StartVertex, vertex_count);
 
-    if(!This->stateBlock->vertexDecl) {
+    if (!This->stateBlock->state.vertex_declaration)
+    {
         WARN("(%p) : Called without a valid vertex declaration set\n", This);
         return WINED3DERR_INVALIDCALL;
     }
@@ -4709,7 +4710,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
         return WINED3DERR_INVALIDCALL;
     }
 
-    if(!This->stateBlock->vertexDecl) {
+    if (!This->stateBlock->state.vertex_declaration)
+    {
         WARN("(%p) : Called without a valid vertex declaration set\n", This);
         return WINED3DERR_INVALIDCALL;
     }
@@ -4749,7 +4751,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
     TRACE("(%p) : vertex count %u, pVtxData %p, stride %u\n",
             This, vertex_count, pVertexStreamZeroData, VertexStreamZeroStride);
 
-    if(!This->stateBlock->vertexDecl) {
+    if (!This->stateBlock->state.vertex_declaration)
+    {
         WARN("(%p) : Called without a valid vertex declaration set\n", This);
         return WINED3DERR_INVALIDCALL;
     }
@@ -4792,7 +4795,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
     TRACE("(%p) : index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u.\n",
             This, index_count, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
 
-    if(!This->stateBlock->vertexDecl) {
+    if (!This->stateBlock->state.vertex_declaration)
+    {
         WARN("(%p) : Called without a valid vertex declaration set\n", This);
         return WINED3DERR_INVALIDCALL;
     }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index c06e14b..ac5accb 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -492,7 +492,8 @@ static ULONG  WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
     if (!refCount) {
         int counter;
 
-        if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
+        if (This->state.vertex_declaration)
+            IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
 
         for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
         {
@@ -731,13 +732,17 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
         This->IndexFmt = targetStateBlock->IndexFmt;
     }
 
-    if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl)
+    if (This->changed.vertexDecl && This->state.vertex_declaration != targetStateBlock->state.vertex_declaration)
     {
-        TRACE("Updating vertex declaration from %p to %p.\n", This->vertexDecl, targetStateBlock->vertexDecl);
+        TRACE("Updating vertex declaration from %p to %p.\n",
+                This->state.vertex_declaration, targetStateBlock->state.vertex_declaration);
 
-        if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
-        if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
-        This->vertexDecl = targetStateBlock->vertexDecl;
+        if (targetStateBlock->state.vertex_declaration)
+                IWineD3DVertexDeclaration_AddRef(
+                        (IWineD3DVertexDeclaration *)targetStateBlock->state.vertex_declaration);
+        if (This->state.vertex_declaration)
+                IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
+        This->state.vertex_declaration = targetStateBlock->state.vertex_declaration;
     }
 
     if (This->changed.material && memcmp(&targetStateBlock->state.material,
@@ -989,9 +994,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
         IWineD3DDevice_SetBaseVertexIndex(device, This->baseVertexIndex);
     }
 
-    if (This->changed.vertexDecl && This->vertexDecl)
+    if (This->changed.vertexDecl && This->state.vertex_declaration)
     {
-        IWineD3DDevice_SetVertexDeclaration(device, This->vertexDecl);
+        IWineD3DDevice_SetVertexDeclaration(device, (IWineD3DVertexDeclaration *)This->state.vertex_declaration);
     }
 
     if (This->changed.material)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 994c1e2..9457bf4 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2897,7 +2897,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
     }
     else if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
     {
-        if (use_vs(stateblock) || ((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed)
+        if (use_vs(stateblock) || stateblock->state.vertex_declaration->position_transformed)
         {
             settings->fog = FOG_LINEAR;
         }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c54be90..10ddc4a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2349,6 +2349,8 @@ struct wined3d_stream_state
 
 struct wined3d_state
 {
+    IWineD3DVertexDeclarationImpl *vertex_declaration;
+
     IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
     DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
     DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
@@ -2376,9 +2378,6 @@ struct IWineD3DStateBlockImpl
     SAVEDSTATES               changed;
     struct wined3d_state state;
 
-    /* Vertex Shader Declaration */
-    IWineD3DVertexDeclaration *vertexDecl;
-
     IWineD3DVertexShader      *vertexShader;
 
     /* Vertex Shader Constants */
@@ -3036,7 +3035,7 @@ static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
      * stateblock->vertexShader implies a vertex declaration instead of ddraw
      * style strided data. */
     return (stateblock->vertexShader
-            && !((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed
+            && !stateblock->state.vertex_declaration->position_transformed
             && stateblock->device->vs_selected_mode != SHADER_NONE);
 }
 




More information about the wine-cvs mailing list