2 * Copyright 2009 Henri Verbeet for CodeWeavers
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"
22 #include "wined3d_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
26 #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24
27 #define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0xf << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
29 #define WINED3D_SM4_OPCODE_MASK 0xff
31 struct wined3d_sm4_data
36 static void *shader_sm4_init(const DWORD *byte_code)
38 struct wined3d_sm4_data *priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv));
41 ERR("Failed to allocate private data\n");
48 static void shader_sm4_free(void *data)
50 HeapFree(GetProcessHeap(), 0, data);
53 static void shader_sm4_read_header(void *data, const DWORD **ptr, DWORD *shader_version)
55 struct wined3d_sm4_data *priv = data;
58 TRACE("version: 0x%08x\n", **ptr);
59 *shader_version = *(*ptr)++;
60 TRACE("token count: %u\n", **ptr);
61 priv->end += *(*ptr)++;
64 static void shader_sm4_read_opcode(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins,
65 UINT *param_size, DWORD shader_version)
67 DWORD token = *(*ptr)++;
68 DWORD opcode = token & WINED3D_SM4_OPCODE_MASK;
70 FIXME("Unrecognized opcode %#x, token 0x%08x\n", opcode, token);
72 ins->handler_idx = WINED3DSIH_TABLE_SIZE;
78 *param_size = ((token & WINED3D_SM4_INSTRUCTION_LENGTH_MASK) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT) - 1;
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)
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);
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)
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);
95 static void shader_sm4_read_semantic(const DWORD **ptr, struct wined3d_shader_semantic *semantic)
97 FIXME("ptr %p, semantic %p stub!\n", ptr, semantic);
100 static void shader_sm4_read_comment(const DWORD **ptr, const char **comment)
102 FIXME("ptr %p, comment %p stub!\n", ptr, comment);
106 static BOOL shader_sm4_is_end(void *data, const DWORD **ptr)
108 struct wined3d_sm4_data *priv = data;
109 return *ptr == priv->end;
112 const struct wined3d_shader_frontend sm4_shader_frontend =
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,