--- dlls/d3dx9_36/Makefile.in | 3 ++- dlls/d3dx9_36/d3dx9_36.spec | 2 +- dlls/d3dx9_36/shader.c | 50 +++++++++++++++++++++++++++++++++++++++++++ include/d3dx9.h | 1 + include/d3dx9shader.h | 26 ++++++++++++++++++++++ 5 files changed, 80 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..a1c7ddb --- /dev/null +++ b/dlls/d3dx9_36/shader.c @@ -0,0 +1,50 @@ +/* + * 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/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..0431560 --- /dev/null +++ b/include/d3dx9shader.h @@ -0,0 +1,26 @@ +/* + * Copyright 2008 Henri Verbeet + * + * 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 "d3dx9.h" + +#ifndef __D3DX9SHADER_H__ +#define __D3DX9SHADER_H__ + +UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code); + +#endif /* __D3DX9SHADER_H__ */