2 * Copyright 2008 Luis Busquets
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/port.h"
21 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
28 LPCSTR WINAPI D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device)
32 TRACE("device %p\n", device);
34 if (!device) return NULL;
36 IDirect3DDevice9_GetDeviceCaps(device,&caps);
38 switch (caps.PixelShaderVersion)
40 case D3DPS_VERSION(1, 1):
43 case D3DPS_VERSION(1, 2):
46 case D3DPS_VERSION(1, 3):
49 case D3DPS_VERSION(1, 4):
52 case D3DPS_VERSION(2, 0):
53 if ((caps.PS20Caps.NumTemps>=22) &&
54 (caps.PS20Caps.Caps&D3DPS20CAPS_ARBITRARYSWIZZLE) &&
55 (caps.PS20Caps.Caps&D3DPS20CAPS_GRADIENTINSTRUCTIONS) &&
56 (caps.PS20Caps.Caps&D3DPS20CAPS_PREDICATION) &&
57 (caps.PS20Caps.Caps&D3DPS20CAPS_NODEPENDENTREADLIMIT) &&
58 (caps.PS20Caps.Caps&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT))
62 if ((caps.PS20Caps.NumTemps>=32) &&
63 (caps.PS20Caps.Caps&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT))
69 case D3DPS_VERSION(3, 0):
76 UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code)
78 const DWORD *ptr = byte_code;
80 TRACE("byte_code %p\n", byte_code);
84 /* Look for the END token, skipping the VERSION token */
85 while (*++ptr != D3DSIO_END)
88 if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)
90 ptr += ((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT);
95 /* Return the shader size in bytes */
96 return (ptr - byte_code) * sizeof(*ptr);
99 DWORD WINAPI D3DXGetShaderVersion(const DWORD *byte_code)
101 TRACE("byte_code %p\n", byte_code);
103 return byte_code ? *byte_code : 0;
106 LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device)
110 TRACE("device %p\n", device);
112 if (!device) return NULL;
114 IDirect3DDevice9_GetDeviceCaps(device,&caps);
116 switch (caps.VertexShaderVersion)
118 case D3DVS_VERSION(1, 1):
120 case D3DVS_VERSION(2, 0):
121 if ((caps.VS20Caps.NumTemps>=13) &&
122 (caps.VS20Caps.DynamicFlowControlDepth==24) &&
123 (caps.VS20Caps.Caps&D3DPS20CAPS_PREDICATION))
128 case D3DVS_VERSION(3, 0):