user32: Make ddeml.dll into a stand-alone 16bit module.
[wine] / dlls / wined3d / shader_sm4.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20 #include "wine/port.h"
21
22 #include "wined3d_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
25
26 #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT    24
27 #define WINED3D_SM4_INSTRUCTION_LENGTH_MASK     (0xf << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
28
29 #define WINED3D_SM4_OPCODE_MASK                 0xff
30
31 struct wined3d_sm4_data
32 {
33     const DWORD *end;
34 };
35
36 static void *shader_sm4_init(const DWORD *byte_code)
37 {
38     struct wined3d_sm4_data *priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv));
39     if (!priv)
40     {
41         ERR("Failed to allocate private data\n");
42         return NULL;
43     }
44
45     return priv;
46 }
47
48 static void shader_sm4_free(void *data)
49 {
50     HeapFree(GetProcessHeap(), 0, data);
51 }
52
53 static void shader_sm4_read_header(void *data, const DWORD **ptr, DWORD *shader_version)
54 {
55     struct wined3d_sm4_data *priv = data;
56     priv->end = *ptr;
57
58     TRACE("version: 0x%08x\n", **ptr);
59     *shader_version = *(*ptr)++;
60     TRACE("token count: %u\n", **ptr);
61     priv->end += *(*ptr)++;
62 }
63
64 static void shader_sm4_read_opcode(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins,
65         UINT *param_size, DWORD shader_version)
66 {
67     DWORD token = *(*ptr)++;
68     DWORD opcode = token & WINED3D_SM4_OPCODE_MASK;
69
70     FIXME("Unrecognized opcode %#x, token 0x%08x\n", opcode, token);
71
72     ins->handler_idx = WINED3DSIH_TABLE_SIZE;
73     ins->flags = 0;
74     ins->coissue = 0;
75     ins->predicate = 0;
76     ins->dst_count = 0;
77     ins->src_count = 0;
78     *param_size = ((token & WINED3D_SM4_INSTRUCTION_LENGTH_MASK) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT) - 1;
79 }
80
81 static void shader_sm4_read_src_param(const DWORD **ptr, struct wined3d_shader_src_param *src_param,
82         struct wined3d_shader_src_param *src_rel_addr, DWORD shader_version)
83 {
84     FIXME("ptr %p, src_param %p, src_rel_addr %p, shader_version %#x stub!\n",
85             ptr, src_param, src_rel_addr, shader_version);
86 }
87
88 static void shader_sm4_read_dst_param(const DWORD **ptr, struct wined3d_shader_dst_param *dst_param,
89         struct wined3d_shader_src_param *dst_rel_addr, DWORD shader_version)
90 {
91     FIXME("ptr %p, dst_param %p, dst_rel_addr %p, shader_version %#x stub!\n",
92             ptr, dst_param, dst_rel_addr, shader_version);
93 }
94
95 static void shader_sm4_read_semantic(const DWORD **ptr, struct wined3d_shader_semantic *semantic)
96 {
97     FIXME("ptr %p, semantic %p stub!\n", ptr, semantic);
98 }
99
100 static void shader_sm4_read_comment(const DWORD **ptr, const char **comment)
101 {
102     FIXME("ptr %p, comment %p stub!\n", ptr, comment);
103     *comment = NULL;
104 }
105
106 static BOOL shader_sm4_is_end(void *data, const DWORD **ptr)
107 {
108     struct wined3d_sm4_data *priv = data;
109     return *ptr == priv->end;
110 }
111
112 const struct wined3d_shader_frontend sm4_shader_frontend =
113 {
114     shader_sm4_init,
115     shader_sm4_free,
116     shader_sm4_read_header,
117     shader_sm4_read_opcode,
118     shader_sm4_read_src_param,
119     shader_sm4_read_dst_param,
120     shader_sm4_read_semantic,
121     shader_sm4_read_comment,
122     shader_sm4_is_end,
123 };