Subject: [PATCH] modified: dlls/d3dx9_36/effect.c

From: root <[email-masked]>
Date: Wed, 26 Oct 2016 20:19:17 +0200

---
 dlls/d3dx9_36/effect.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index 42f5aea..c69b73c 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -150,6 +150,7 @@ struct d3dx9_base_effect
     UINT parameter_count;
     UINT technique_count;
     UINT object_count;
+    BOOL clonable;
 
     struct d3dx_parameter *parameters;
     struct d3dx_technique *techniques;
@@ -999,6 +1000,11 @@ static HRESULT d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect *base,
         D3DXHANDLE pass, D3DXPASS_DESC *desc)
 {
     struct d3dx_pass *p = get_valid_pass(base, pass);
+    struct d3dx_state *s;
+    struct d3dx_parameter *param;
+    IDirect3DVertexShader9 *vshader;
+    IDirect3DPixelShader9 *pshader;
+    UINT i, size;
 
     if (!desc || !p)
     {
@@ -1008,11 +1014,45 @@ static HRESULT d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect *base,
 
     desc->Name = p->name;
     desc->Annotations = p->annotation_count;
-
-    FIXME("Pixel shader and vertex shader are not supported, yet.\n");
     desc->pVertexShaderFunction = NULL;
     desc->pPixelShaderFunction = NULL;
 
+    if (base->clonable)
+    {
+        for (i=0; i < p->state_count; i++)
+        {
+            s = p->states + i;
+            if (state_table[s->operation].class == SC_VERTEXSHADER)
+            {
+                param = &(s->parameter);
+                vshader = *(struct IDirect3DVertexShader9 **)param->data;
+                if (vshader)
+                {
+                    IDirect3DVertexShader9_GetFunction(vshader, NULL, &size);
+                    if (desc->pVertexShaderFunction)
+                        free((void *)desc->pVertexShaderFunction);
+                    desc->pVertexShaderFunction = malloc(size);
+                    IDirect3DVertexShader9_GetFunction(vshader, (void *)(desc->pVertexShaderFunction), &size);
+                }
+            }
+            if (state_table[s->operation].class == SC_PIXELSHADER)
+            {
+                param = &(s->parameter);
+                pshader = *(struct IDirect3DPixelShader9 **)param->data;
+                if (pshader)
+                {
+                    IDirect3DPixelShader9_GetFunction(pshader, NULL, &size);
+                    if (desc->pPixelShaderFunction)
+                        free((void *)desc->pPixelShaderFunction);
+                    desc->pPixelShaderFunction = malloc(size);
+                    IDirect3DPixelShader9_GetFunction(pshader, (void *)(desc->pPixelShaderFunction), &size);
+                }
+            }
+        }
+    }
+
+    TRACE("Pass '%s': %i annots. Vertexshader %p and Pixelshader %p\n", desc->Name, desc->Annotations, desc->pVertexShaderFunction, desc->pPixelShaderFunction);
+
     return D3D_OK;
 }
 
@@ -5955,6 +5995,8 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base,
 
     base->effect = effect;
 
+    base->clonable = TRUE;
+
     read_dword(&ptr, &tag);
     TRACE("Tag: %x\n", tag);
 
-- 
2.7.4