d3dx9: Apply current transform in ID3DXSprite_Draw instead of ID3DXSprite_Flush.
[wine/d3dx9TW.git] / dlls / d3dx9_36 / shader.c
blob48499ac6df1a29bce990d1c3b516e9662097c5e1
1 /*
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
19 #include "config.h"
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "windef.h"
23 #include "wingdi.h"
24 #include "d3dx9.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
28 LPCSTR WINAPI D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device)
30 D3DCAPS9 caps;
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):
41 return "ps_1_1";
43 case D3DPS_VERSION(1, 2):
44 return "ps_1_2";
46 case D3DPS_VERSION(1, 3):
47 return "ps_1_3";
49 case D3DPS_VERSION(1, 4):
50 return "ps_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))
60 return "ps_2_a";
62 if ((caps.PS20Caps.NumTemps>=32) &&
63 (caps.PS20Caps.Caps&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT))
65 return "ps_2_b";
67 return "ps_2_0";
69 case D3DPS_VERSION(3, 0):
70 return "ps_3_0";
73 return NULL;
76 UINT WINAPI D3DXGetShaderSize(const DWORD *byte_code)
78 const DWORD *ptr = byte_code;
80 TRACE("byte_code %p\n", byte_code);
82 if (!ptr) return 0;
84 /* Look for the END token, skipping the VERSION token */
85 while (*++ptr != D3DSIO_END)
87 /* Skip comments */
88 if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)
90 ptr += ((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT);
93 ++ptr;
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)
108 D3DCAPS9 caps;
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):
119 return "vs_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))
125 return "vs_2_a";
127 return "vs_2_0";
128 case D3DVS_VERSION(3, 0):
129 return "vs_3_0";
132 return NULL;