[PATCH 3/5] d3dx9_36: Parse structure type information in parse_ctab_constant_type

Travis Athougies iammisc at gmail.com
Tue Jul 5 16:45:02 CDT 2011


---
 dlls/d3dx9_36/shader.c |   48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index 2679528..b3b7bbc 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -1192,7 +1192,7 @@ static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl =
     ID3DXConstantTableImpl_SetMatrixTransposePointerArray
 };
 
-static HRESULT parse_ctab_constant_type(const D3DXSHADER_TYPEINFO *type, ctab_constant *constant)
+static HRESULT parse_ctab_constant_type(const D3DXSHADER_TYPEINFO *type, ctab_constant *constant, char *ctab)
 {
     constant->desc.Class = type->Class;
     constant->desc.Type = type->Type;
@@ -1207,8 +1207,48 @@ static HRESULT parse_ctab_constant_type(const D3DXSHADER_TYPEINFO *type, ctab_co
 
     if ((constant->desc.Class == D3DXPC_STRUCT) && constant->desc.StructMembers)
     {
-        FIXME("Struct not supported yet\n");
-        return E_NOTIMPL;
+        D3DXSHADER_STRUCTMEMBERINFO* members = (LPD3DXSHADER_STRUCTMEMBERINFO)(ctab + type->StructMemberInfo);
+        UINT i;
+        WORD cur_reg = constant->desc.RegisterIndex;
+        DWORD default_value_offset = 0;
+        HRESULT hr;
+
+        constant->member_count = constant->desc.StructMembers;
+        constant->members = HeapAlloc(GetProcessHeap(), 0, sizeof(ctab_constant) * constant->member_count);
+
+        for (i = 0; i < constant->member_count; i++)
+        {
+            constant->members[i].desc.Name = ctab + members[i].Name;
+            TRACE("  name = %s (under %s)\n", constant->members[i].desc.Name, constant->desc.Name);
+
+            constant->members[i].desc.RegisterSet = constant->desc.RegisterSet;
+            constant->members[i].desc.RegisterIndex = cur_reg;
+
+            /* This will be calculated when the type description is parsed (in a recursive call to parse_ctab_constant_type) */
+            constant->members[i].desc.RegisterCount = 0;
+
+            constant->members[i].desc.DefaultValue = (LPVOID)((DWORD_PTR)constant->desc.DefaultValue + default_value_offset);
+
+            hr = parse_ctab_constant_type((LPD3DXSHADER_TYPEINFO)(ctab + members[i].TypeInfo), &constant->members[i], ctab);
+            if (hr != D3D_OK)
+                return E_FAIL;
+
+            cur_reg += constant->members[i].desc.RegisterCount;
+            default_value_offset += constant->members[i].desc.Bytes;
+        }
+
+        if (constant->desc.RegisterCount == 0)
+            /* If RegisterCount wasn't calculated for us, we have to calculate it */
+            constant->desc.RegisterCount = cur_reg - constant->desc.RegisterIndex;
+    }
+    else
+    {
+        constant->member_count = 0;
+        constant->members = NULL;
+
+        if (constant->desc.RegisterCount == 0)
+            /* If RegisterCount wasn't calculated for us, we have to calculate it */
+            constant->desc.RegisterCount = constant->desc.Elements * constant->desc.Rows;
     }
 
     constant->desc.Bytes = calc_constant_size(&constant->desc);
@@ -1308,7 +1348,7 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* byte_code,
         object->constants[i].desc.DefaultValue = object->ctab + constant_info[i].DefaultValue;
 
         hr = parse_ctab_constant_type((LPD3DXSHADER_TYPEINFO)(object->ctab + constant_info[i].TypeInfo),
-             &object->constants[i]);
+             &object->constants[i], object->ctab);
         if (hr != D3D_OK)
             goto error;
     }
-- 
1.6.4.4




More information about the wine-patches mailing list