widl: Silence a gcc warning.
[wine.git] / dlls / d3d10 / utils.c
blob223b33a80171930c5e7b443c8cd7be716a314a14
1 /*
2 * Copyright 2008-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 "config.h"
21 #include "wine/port.h"
23 #include "d3d10_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
27 #define WINE_D3D10_TO_STR(x) case x: return #x
29 const char *debug_d3d10_driver_type(D3D10_DRIVER_TYPE driver_type)
31 switch(driver_type)
33 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_HARDWARE);
34 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_REFERENCE);
35 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_NULL);
36 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_SOFTWARE);
37 WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_WARP);
38 default:
39 FIXME("Unrecognized D3D10_DRIVER_TYPE %#x\n", driver_type);
40 return "unrecognized";
44 const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c)
46 switch (c)
48 WINE_D3D10_TO_STR(D3D10_SVC_SCALAR);
49 WINE_D3D10_TO_STR(D3D10_SVC_VECTOR);
50 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS);
51 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS);
52 WINE_D3D10_TO_STR(D3D10_SVC_OBJECT);
53 WINE_D3D10_TO_STR(D3D10_SVC_STRUCT);
54 default:
55 FIXME("Unrecognized D3D10_SHADER_VARIABLE_CLASS %#x.\n", c);
56 return "unrecognized";
60 const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t)
62 switch (t)
64 WINE_D3D10_TO_STR(D3D10_SVT_VOID);
65 WINE_D3D10_TO_STR(D3D10_SVT_BOOL);
66 WINE_D3D10_TO_STR(D3D10_SVT_INT);
67 WINE_D3D10_TO_STR(D3D10_SVT_FLOAT);
68 WINE_D3D10_TO_STR(D3D10_SVT_STRING);
69 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE);
70 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D);
71 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D);
72 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D);
73 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE);
74 WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER);
75 WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER);
76 WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER);
77 WINE_D3D10_TO_STR(D3D10_SVT_UINT);
78 WINE_D3D10_TO_STR(D3D10_SVT_UINT8);
79 WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER);
80 WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER);
81 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL);
82 WINE_D3D10_TO_STR(D3D10_SVT_BLEND);
83 WINE_D3D10_TO_STR(D3D10_SVT_BUFFER);
84 WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER);
85 WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER);
86 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY);
87 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY);
88 WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW);
89 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW);
90 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS);
91 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY);
92 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY);
93 default:
94 FIXME("Unrecognized D3D10_SHADER_VARIABLE_TYPE %#x.\n", t);
95 return "unrecognized";
99 const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t)
101 switch (t)
103 WINE_D3D10_TO_STR(D3D10_DST_SO_BUFFERS);
104 WINE_D3D10_TO_STR(D3D10_DST_OM_RENDER_TARGETS);
105 WINE_D3D10_TO_STR(D3D10_DST_DEPTH_STENCIL_STATE);
106 WINE_D3D10_TO_STR(D3D10_DST_BLEND_STATE);
107 WINE_D3D10_TO_STR(D3D10_DST_VS);
108 WINE_D3D10_TO_STR(D3D10_DST_VS_SAMPLERS);
109 WINE_D3D10_TO_STR(D3D10_DST_VS_SHADER_RESOURCES);
110 WINE_D3D10_TO_STR(D3D10_DST_VS_CONSTANT_BUFFERS);
111 WINE_D3D10_TO_STR(D3D10_DST_GS);
112 WINE_D3D10_TO_STR(D3D10_DST_GS_SAMPLERS);
113 WINE_D3D10_TO_STR(D3D10_DST_GS_SHADER_RESOURCES);
114 WINE_D3D10_TO_STR(D3D10_DST_GS_CONSTANT_BUFFERS);
115 WINE_D3D10_TO_STR(D3D10_DST_PS);
116 WINE_D3D10_TO_STR(D3D10_DST_PS_SAMPLERS);
117 WINE_D3D10_TO_STR(D3D10_DST_PS_SHADER_RESOURCES);
118 WINE_D3D10_TO_STR(D3D10_DST_PS_CONSTANT_BUFFERS);
119 WINE_D3D10_TO_STR(D3D10_DST_IA_VERTEX_BUFFERS);
120 WINE_D3D10_TO_STR(D3D10_DST_IA_INDEX_BUFFER);
121 WINE_D3D10_TO_STR(D3D10_DST_IA_INPUT_LAYOUT);
122 WINE_D3D10_TO_STR(D3D10_DST_IA_PRIMITIVE_TOPOLOGY);
123 WINE_D3D10_TO_STR(D3D10_DST_RS_VIEWPORTS);
124 WINE_D3D10_TO_STR(D3D10_DST_RS_SCISSOR_RECTS);
125 WINE_D3D10_TO_STR(D3D10_DST_RS_RASTERIZER_STATE);
126 WINE_D3D10_TO_STR(D3D10_DST_PREDICATION);
127 default:
128 FIXME("Unrecognized D3D10_DEVICE_STATE_TYPES %#x.\n", t);
129 return "unrecognized";
133 #undef WINE_D3D10_TO_STR
135 void skip_dword_unknown(const char *location, const char **ptr, unsigned int count)
137 unsigned int i;
138 DWORD d;
140 FIXME("Skipping %u unknown DWORDs (%s):\n", count, location);
141 for (i = 0; i < count; ++i)
143 read_dword(ptr, &d);
144 FIXME("\t0x%08x\n", d);
148 void write_dword_unknown(char **ptr, DWORD d)
150 FIXME("Writing unknown DWORD 0x%08x\n", d);
151 write_dword(ptr, d);
154 HRESULT parse_dxbc(const char *data, SIZE_T data_size,
155 HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
157 const char *ptr = data;
158 HRESULT hr = S_OK;
159 DWORD chunk_count;
160 DWORD total_size;
161 unsigned int i;
162 DWORD version;
163 DWORD tag;
165 if (!data)
167 WARN("No data supplied.\n");
168 return E_FAIL;
171 read_dword(&ptr, &tag);
172 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
174 if (tag != TAG_DXBC)
176 WARN("Wrong tag.\n");
177 return E_FAIL;
180 /* checksum? */
181 skip_dword_unknown("DXBC header", &ptr, 4);
183 read_dword(&ptr, &version);
184 TRACE("version: %#x.\n", version);
185 if (version != 0x00000001)
187 WARN("Got unexpected DXBC version %#x.\n", version);
188 return E_FAIL;
191 read_dword(&ptr, &total_size);
192 TRACE("total size: %#x\n", total_size);
194 if (data_size != total_size)
196 WARN("Wrong size supplied.\n");
197 return E_FAIL;
200 read_dword(&ptr, &chunk_count);
201 TRACE("chunk count: %#x\n", chunk_count);
203 for (i = 0; i < chunk_count; ++i)
205 DWORD chunk_tag, chunk_size;
206 const char *chunk_ptr;
207 DWORD chunk_offset;
209 read_dword(&ptr, &chunk_offset);
210 TRACE("chunk %u at offset %#x\n", i, chunk_offset);
212 if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
214 WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
215 return E_FAIL;
218 chunk_ptr = data + chunk_offset;
220 read_dword(&chunk_ptr, &chunk_tag);
221 read_dword(&chunk_ptr, &chunk_size);
223 if (!require_space(chunk_ptr - data, 1, chunk_size, data_size))
225 WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset);
226 return E_FAIL;
229 hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
230 if (FAILED(hr)) break;
233 return hr;