Luis Busquets : d3dx9: Implement D3DXGetShaderSize().

Alexandre Julliard julliard at winehq.org
Wed Jul 16 13:32:58 CDT 2008


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

Author: Luis Busquets <luis.busquets at ilidium.com>
Date:   Mon Jul 14 22:47:19 2008 +0200

d3dx9: Implement D3DXGetShaderSize().

---

 dlls/d3dx9_36/Makefile.in   |    3 +-
 dlls/d3dx9_36/d3dx9_36.spec |    2 +-
 dlls/d3dx9_36/shader.c      |   49 +++++++++++++++++++++++++++++++++++++++++++
 include/Makefile.in         |    1 +
 include/d3dx9.h             |    1 +
 include/d3dx9shader.h       |   34 +++++++++++++++++++++++++++++
 6 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in
index 4c3f09a..78cfd97 100644
--- a/dlls/d3dx9_36/Makefile.in
+++ b/dlls/d3dx9_36/Makefile.in
@@ -9,7 +9,8 @@ IMPORTS   = d3d9 d3dx8 kernel32
 C_SRCS = \
 	d3dx9_36_main.c \
 	font.c \
-	math.c
+	math.c \
+	shader.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec
index e616d23..93ba132 100644
--- a/dlls/d3dx9_36/d3dx9_36.spec
+++ b/dlls/d3dx9_36/d3dx9_36.spec
@@ -162,7 +162,7 @@
 @ stub D3DXGetShaderInputSemantics
 @ stub D3DXGetShaderOutputSemantics
 @ stub D3DXGetShaderSamplers
-@ stub D3DXGetShaderSize
+@ stdcall D3DXGetShaderSize(ptr)
 @ stub D3DXGetShaderVersion
 @ stub D3DXGetVertexShaderProfile
 @ stdcall D3DXIntersect(ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr) d3dx8.D3DXIntersect
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
new file mode 100644
index 0000000..bbda961
--- /dev/null
+++ b/dlls/d3dx9_36/shader.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2008 Luis Busquets
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+#include "wine/debug.h"
+#include "windef.h"
+#include "wingdi.h"
+#include "d3dx9.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+
+UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code)
+{
+    const DWORD *ptr = byte_code;
+
+    TRACE("byte_code %p\n", byte_code);
+
+    if (!ptr) return 0;
+
+    /* Look for the END token, skipping the VERSION token */
+    while (*++ptr != D3DSIO_END)
+    {
+        /* Skip comments */
+        if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)
+        {
+            ptr += ((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT);
+        }
+    }
+    ++ptr;
+
+    /* Return the shader size in bytes */
+    return (ptr - byte_code) * sizeof(*ptr);
+}
diff --git a/include/Makefile.in b/include/Makefile.in
index 5631199..56cc587 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -133,6 +133,7 @@ SRCDIR_INCLUDES = \
 	d3dx9core.h \
 	d3dx9math.h \
 	d3dx9math.inl \
+	d3dx9shader.h \
 	d3dx9tex.h \
 	dbghelp.h \
 	dbinit.idl \
diff --git a/include/d3dx9.h b/include/d3dx9.h
index 50b1b5a..b551eba 100644
--- a/include/d3dx9.h
+++ b/include/d3dx9.h
@@ -24,6 +24,7 @@
 #include "d3d9.h"
 #include "d3dx9math.h"
 #include "d3dx9core.h"
+#include "d3dx9shader.h"
 #include "d3dx9tex.h"
 
 #define _FACDD 0x876
diff --git a/include/d3dx9shader.h b/include/d3dx9shader.h
new file mode 100644
index 0000000..5eb4fe6
--- /dev/null
+++ b/include/d3dx9shader.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Luis Busquets
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __D3DX9SHADER_H__
+#define __D3DX9SHADER_H__
+
+#include "d3dx9.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __D3DX9SHADER_H__ */




More information about the wine-cvs mailing list