[PATCH 2/5] d3dx9_36: Separate calculation of Bytes from D3DXGetShaderConstantTableEx

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


---
 dlls/d3dx9_36/shader.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index e3068c9..2679528 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -756,6 +756,19 @@ static WORD new_handle(ID3DXConstantTableImpl* This, ctab_constant* constant)
     return handle;
 }
 
+static DWORD calc_constant_size(D3DXCONSTANT_DESC *desc)
+{
+    if (desc->RegisterSet != D3DXRS_FLOAT4 && desc->RegisterSet != D3DXRS_SAMPLER)
+        FIXME("Don't know how to calculate Bytes for constants of type %d\n",
+                desc->RegisterSet);
+
+    /*
+     * D3DXRS_FLOAT4 and D3DXRS_SAMPLER have a base size of 4
+     * (not taking into account dimensions and element count)
+     */
+    return 4 * desc->Elements * desc->Rows * desc->Columns;
+}
+
 static HRESULT WINAPI ID3DXConstantTableImpl_GetDesc(ID3DXConstantTable* iface, D3DXCONSTANTTABLE_DESC *desc)
 {
     ID3DXConstantTableImpl *This = impl_from_ID3DXConstantTable(iface);
@@ -1198,6 +1211,8 @@ static HRESULT parse_ctab_constant_type(const D3DXSHADER_TYPEINFO *type, ctab_co
         return E_NOTIMPL;
     }
 
+    constant->desc.Bytes = calc_constant_size(&constant->desc);
+
     return D3D_OK;
 }
 
@@ -1296,22 +1311,6 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* byte_code,
              &object->constants[i]);
         if (hr != D3D_OK)
             goto error;
-
-        if (constant_info[i].RegisterSet != D3DXRS_FLOAT4 &&
-                constant_info[i].RegisterSet != D3DXRS_SAMPLER)
-            FIXME("Don't know how to calculate Bytes for constants of type %d\n",
-                    constant_info[i].RegisterSet);
-
-        /*
-         * D3DXRS_FLOAT4 and D3DXRS_SAMPLER have a base size of 4
-         * (not taking into account dimensions and element count)
-         */
-        object->constants[i].desc.Bytes = 4;
-
-        /* Take into account dimensions and elements */
-        object->constants[i].desc.Bytes *= object->constants[i].desc.Elements;
-        object->constants[i].desc.Bytes *= object->constants[i].desc.Rows *
-                object->constants[i].desc.Columns;
     }
 
     *constant_table = &object->ID3DXConstantTable_iface;
-- 
1.6.4.4




More information about the wine-patches mailing list