[PATCH 4/5] d3dx9_36: Implement D3DXFindShaderComment (based on code from Luis Busquets)

Christian Costa titan.costa at wanadoo.fr
Sun Feb 21 15:30:45 CST 2010


---

 dlls/d3dx9_36/d3dx9_36.spec |    2 +-
 dlls/d3dx9_36/shader.c      |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)
-------------- next part --------------
diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec
index d22ab5f..7924081 100644
--- a/dlls/d3dx9_36/d3dx9_36.spec
+++ b/dlls/d3dx9_36/d3dx9_36.spec
@@ -129,7 +129,7 @@
 @ stub D3DXFillVolumeTexture
 @ stub D3DXFillVolumeTextureTX
 @ stub D3DXFilterTexture
-@ stub D3DXFindShaderComment
+@ stdcall D3DXFindShaderComment(ptr long ptr ptr)
 @ stub D3DXFloat16To32Array
 @ stub D3DXFloat32To16Array
 @ stub D3DXFrameAppendChild
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index c697132..09306f0 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -135,6 +135,35 @@ LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device)
     return NULL;
 }
 
+HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* pFunction, DWORD FourCC, LPCVOID* ppData, UINT* pSizeInBytes)
+{
+    CONST DWORD *ptr = pFunction;
+
+    TRACE("(%p, %x, %p, %p)", pFunction, FourCC, ppData, pSizeInBytes);
+
+    if (!pFunction || !ppData || !pSizeInBytes)
+        return D3DERR_INVALIDCALL;
+
+    while (*++ptr != D3DSIO_END)
+    {
+        /* Check if it is a comment */
+        if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)
+        {
+            /* Check if this is the comment we are looking for */
+            if (*(ptr + 1) == FourCC)
+            {
+                *pSizeInBytes = (((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT) - 1) * sizeof(DWORD);
+                *ppData = (LPCVOID)(ptr + 2);
+                TRACE("Returning comment data at %p with size %d\n", *ppData, *pSizeInBytes);
+                return D3D_OK;
+            }
+            ptr += ((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT);
+        }
+    }
+
+    return S_FALSE;
+}
+
 HRESULT WINAPI D3DXAssembleShader(LPCSTR data,
                                   UINT data_len,
                                   CONST D3DXMACRO* defines,


More information about the wine-patches mailing list