1 | /** @file
|
---|
2 | *
|
---|
3 | * VBoxVideo Display D3D User mode dll
|
---|
4 | *
|
---|
5 | * Copyright (C) 2010 Oracle Corporation
|
---|
6 | *
|
---|
7 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | * available from http://www.virtualbox.org. This file is free software;
|
---|
9 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | * General Public License (GPL) as published by the Free Software
|
---|
11 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | */
|
---|
15 | #include <iprt/initterm.h>
|
---|
16 | #include <iprt/log.h>
|
---|
17 | #include <iprt/mem.h>
|
---|
18 |
|
---|
19 | #include <VBox/Log.h>
|
---|
20 |
|
---|
21 | #include <VBox/VBoxGuestLib.h>
|
---|
22 |
|
---|
23 | #include "VBoxDispD3DCmn.h"
|
---|
24 | #include "VBoxDispD3D.h"
|
---|
25 |
|
---|
26 | #ifdef VBOXDISPMP_TEST
|
---|
27 | HRESULT vboxDispMpTstStart();
|
---|
28 | HRESULT vboxDispMpTstStop();
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #ifdef VBOXWDDMDISP_DEBUG
|
---|
32 | # include <stdio.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #define VBOXWDDMDISP_WITH_TMPWORKAROUND 1
|
---|
36 |
|
---|
37 | #define VBOXWDDMOVERLAY_TEST
|
---|
38 |
|
---|
39 | static FORMATOP gVBoxFormatOps3D[] = {
|
---|
40 | {D3DDDIFMT_A8R8G8B8,
|
---|
41 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
42 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
43 | FORMATOP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET|
|
---|
44 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
45 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
46 | FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
47 |
|
---|
48 | {D3DDDIFMT_X8R8G8B8,
|
---|
49 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
50 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
51 | FORMATOP_DISPLAYMODE|FORMATOP_3DACCELERATION|
|
---|
52 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
53 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
54 | FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
55 |
|
---|
56 | {D3DDDIFMT_A2R10G10B10,
|
---|
57 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
58 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
59 | 0|
|
---|
60 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
61 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
62 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
63 |
|
---|
64 | {D3DDDIFMT_X1R5G5B5,
|
---|
65 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
66 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
67 | 0|
|
---|
68 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
69 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
70 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
71 |
|
---|
72 | {D3DDDIFMT_A1R5G5B5,
|
---|
73 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
74 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
75 | FORMATOP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET|
|
---|
76 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
77 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
78 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
79 |
|
---|
80 | {D3DDDIFMT_A4R4G4B4,
|
---|
81 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
82 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
83 | FORMATOP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET|
|
---|
84 | FORMATOP_OFFSCREENPLAIN|
|
---|
85 | 0|
|
---|
86 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
87 |
|
---|
88 | {D3DDDIFMT_R5G6B5,
|
---|
89 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
90 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
91 | FORMATOP_DISPLAYMODE|FORMATOP_3DACCELERATION|
|
---|
92 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
93 | FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
94 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
95 |
|
---|
96 | {D3DDDIFMT_L16,
|
---|
97 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
98 | 0|
|
---|
99 | 0|
|
---|
100 | FORMATOP_OFFSCREENPLAIN|
|
---|
101 | 0|
|
---|
102 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
103 |
|
---|
104 | {D3DDDIFMT_A8L8,
|
---|
105 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
106 | 0|
|
---|
107 | 0|
|
---|
108 | FORMATOP_OFFSCREENPLAIN|
|
---|
109 | 0|
|
---|
110 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
111 |
|
---|
112 | {D3DDDIFMT_A8,
|
---|
113 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
114 | 0|
|
---|
115 | 0|
|
---|
116 | FORMATOP_OFFSCREENPLAIN|
|
---|
117 | 0|
|
---|
118 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
119 |
|
---|
120 | {D3DDDIFMT_L8,
|
---|
121 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
122 | 0|
|
---|
123 | 0|
|
---|
124 | FORMATOP_OFFSCREENPLAIN|
|
---|
125 | 0|
|
---|
126 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
127 |
|
---|
128 | {D3DDDIFMT_D16, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
129 | {D3DDDIFMT_D24S8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
130 | {D3DDDIFMT_D24X8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
131 | {D3DDDIFMT_D16_LOCKABLE, FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
132 | {D3DDDIFMT_X8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
133 | {D3DDDIFMT_D32F_LOCKABLE, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
134 | {D3DDDIFMT_S8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
|
---|
135 |
|
---|
136 | {D3DDDIFMT_DXT1,
|
---|
137 | FORMATOP_TEXTURE|FORMATOP_CUBETEXTURE|
|
---|
138 | 0|
|
---|
139 | 0|
|
---|
140 | FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
141 | 0|
|
---|
142 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
143 |
|
---|
144 | {D3DDDIFMT_DXT2,
|
---|
145 | FORMATOP_TEXTURE|FORMATOP_CUBETEXTURE|
|
---|
146 | 0|
|
---|
147 | 0|
|
---|
148 | FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
149 | 0|
|
---|
150 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
151 |
|
---|
152 | {D3DDDIFMT_DXT3,
|
---|
153 | FORMATOP_TEXTURE|FORMATOP_CUBETEXTURE|
|
---|
154 | 0|
|
---|
155 | 0|
|
---|
156 | FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
157 | 0|
|
---|
158 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
159 |
|
---|
160 | {D3DDDIFMT_DXT4,
|
---|
161 | FORMATOP_TEXTURE|FORMATOP_CUBETEXTURE|
|
---|
162 | 0|
|
---|
163 | 0|
|
---|
164 | FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
165 | 0|
|
---|
166 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
167 |
|
---|
168 | {D3DDDIFMT_DXT5,
|
---|
169 | FORMATOP_TEXTURE|FORMATOP_CUBETEXTURE|
|
---|
170 | 0|
|
---|
171 | 0|
|
---|
172 | FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
173 | 0|
|
---|
174 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
175 |
|
---|
176 | {D3DDDIFMT_X8L8V8U8,
|
---|
177 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
178 | 0|
|
---|
179 | 0|
|
---|
180 | 0|
|
---|
181 | FORMATOP_BUMPMAP|
|
---|
182 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
183 |
|
---|
184 | {D3DDDIFMT_A2W10V10U10,
|
---|
185 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
186 | 0|
|
---|
187 | 0|
|
---|
188 | 0|
|
---|
189 | FORMATOP_BUMPMAP|
|
---|
190 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
191 |
|
---|
192 | {D3DDDIFMT_V8U8,
|
---|
193 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
194 | 0|
|
---|
195 | 0|
|
---|
196 | 0|
|
---|
197 | FORMATOP_BUMPMAP|
|
---|
198 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
199 |
|
---|
200 | {D3DDDIFMT_Q8W8V8U8,
|
---|
201 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
202 | 0|
|
---|
203 | 0|
|
---|
204 | FORMATOP_OFFSCREENPLAIN|
|
---|
205 | FORMATOP_BUMPMAP|
|
---|
206 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
207 |
|
---|
208 | {D3DDDIFMT_CxV8U8, FORMATOP_NOFILTER|FORMATOP_NOALPHABLEND|FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
|
---|
209 |
|
---|
210 | {D3DDDIFMT_R16F,
|
---|
211 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
212 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
213 | 0|
|
---|
214 | FORMATOP_OFFSCREENPLAIN|
|
---|
215 | 0|
|
---|
216 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
217 |
|
---|
218 | {D3DDDIFMT_R32F,
|
---|
219 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
220 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
221 | 0|
|
---|
222 | FORMATOP_OFFSCREENPLAIN|
|
---|
223 | 0|
|
---|
224 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
225 |
|
---|
226 | {D3DDDIFMT_G16R16F,
|
---|
227 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
228 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
229 | 0|
|
---|
230 | FORMATOP_OFFSCREENPLAIN|
|
---|
231 | 0|
|
---|
232 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
233 |
|
---|
234 | {D3DDDIFMT_G32R32F,
|
---|
235 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
236 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
237 | 0|
|
---|
238 | FORMATOP_OFFSCREENPLAIN|
|
---|
239 | 0|
|
---|
240 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
241 |
|
---|
242 | {D3DDDIFMT_A16B16G16R16F,
|
---|
243 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
244 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
245 | 0|
|
---|
246 | FORMATOP_OFFSCREENPLAIN|
|
---|
247 | 0|
|
---|
248 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
249 |
|
---|
250 | {D3DDDIFMT_A32B32G32R32F,
|
---|
251 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
252 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
253 | 0|
|
---|
254 | FORMATOP_OFFSCREENPLAIN|
|
---|
255 | 0|
|
---|
256 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
257 |
|
---|
258 | {D3DDDIFMT_G16R16,
|
---|
259 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
260 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
261 | 0|
|
---|
262 | FORMATOP_OFFSCREENPLAIN|
|
---|
263 | 0|
|
---|
264 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
265 |
|
---|
266 | {D3DDDIFMT_A16B16G16R16,
|
---|
267 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
268 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
269 | 0|
|
---|
270 | FORMATOP_OFFSCREENPLAIN|
|
---|
271 | 0|
|
---|
272 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
273 |
|
---|
274 | {D3DDDIFMT_V16U16,
|
---|
275 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
276 | 0|
|
---|
277 | 0|
|
---|
278 | 0|
|
---|
279 | FORMATOP_BUMPMAP|
|
---|
280 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
281 |
|
---|
282 | {D3DDDIFMT_P8, FORMATOP_DISPLAYMODE|FORMATOP_3DACCELERATION|FORMATOP_OFFSCREENPLAIN, 0, 0, 0},
|
---|
283 |
|
---|
284 | {D3DDDIFMT_UYVY,
|
---|
285 | 0|
|
---|
286 | 0|
|
---|
287 | 0|
|
---|
288 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
289 | FORMATOP_NOFILTER|
|
---|
290 | FORMATOP_NOALPHABLEND|
|
---|
291 | FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
|
---|
292 |
|
---|
293 | {D3DDDIFMT_YUY2,
|
---|
294 | 0|
|
---|
295 | 0|
|
---|
296 | 0|
|
---|
297 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
298 | FORMATOP_NOFILTER|
|
---|
299 | FORMATOP_NOALPHABLEND|
|
---|
300 | FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
|
---|
301 |
|
---|
302 | {D3DDDIFMT_Q16W16V16U16,
|
---|
303 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
304 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
305 | 0|
|
---|
306 | FORMATOP_OFFSCREENPLAIN|
|
---|
307 | FORMATOP_BUMPMAP|FORMATOP_DMAP|
|
---|
308 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
309 |
|
---|
310 | {D3DDDIFMT_X8B8G8R8,
|
---|
311 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
312 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
313 | FORMATOP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET|
|
---|
314 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|FORMATOP_SRGBREAD|
|
---|
315 | FORMATOP_DMAP|FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
316 | FORMATOP_SRGBWRITE|FORMATOP_AUTOGENMIPMAP|FORMATOP_VERTEXTEXTURE|
|
---|
317 | FORMATOP_OVERLAY, 0, 0, 0},
|
---|
318 |
|
---|
319 | {D3DDDIFMT_BINARYBUFFER, FORMATOP_OFFSCREENPLAIN, 0, 0, 0},
|
---|
320 |
|
---|
321 | {D3DDDIFMT_A4L4,
|
---|
322 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|
|
---|
323 | 0|
|
---|
324 | 0|
|
---|
325 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
326 | FORMATOP_DMAP|
|
---|
327 | FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
328 |
|
---|
329 | {D3DDDIFMT_A2B10G10R10,
|
---|
330 | FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
|
---|
331 | FORMATOP_SAME_FORMAT_RENDERTARGET|
|
---|
332 | 0|
|
---|
333 | FORMATOP_CONVERT_TO_ARGB|FORMATOP_OFFSCREENPLAIN|
|
---|
334 | FORMATOP_DMAP|FORMATOP_MEMBEROFGROUP_ARGB|
|
---|
335 | FORMATOP_AUTOGENMIPMAP|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
|
---|
336 | };
|
---|
337 |
|
---|
338 | static FORMATOP gVBoxFormatOpsBase[] = {
|
---|
339 | {D3DDDIFMT_X8R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
|
---|
340 |
|
---|
341 | {D3DDDIFMT_R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
|
---|
342 |
|
---|
343 | {D3DDDIFMT_R5G6B5, FORMATOP_DISPLAYMODE, 0, 0, 0},
|
---|
344 |
|
---|
345 | {D3DDDIFMT_P8, FORMATOP_DISPLAYMODE, 0, 0, 0},
|
---|
346 | };
|
---|
347 |
|
---|
348 | static DDSURFACEDESC gVBoxSurfDescsBase[] = {
|
---|
349 | {
|
---|
350 | sizeof (DDSURFACEDESC), /* DWORD dwSize; */
|
---|
351 | DDSD_CAPS | DDSD_PIXELFORMAT, /* DWORD dwFlags; */
|
---|
352 | 0, /* DWORD dwHeight; */
|
---|
353 | 0, /* DWORD dwWidth; */
|
---|
354 | {
|
---|
355 | 0, /* Union */
|
---|
356 | /* LONG lPitch; */
|
---|
357 | /* DWORD dwLinearSize; */
|
---|
358 | },
|
---|
359 | 0, /* DWORD dwBackBufferCount; */
|
---|
360 | {
|
---|
361 | 0, /* Union */
|
---|
362 | /* DWORD dwMipMapCount; */
|
---|
363 | /* DWORD dwZBufferBitDepth; */
|
---|
364 | /* DWORD dwRefreshRate; */
|
---|
365 | },
|
---|
366 | 0, /* DWORD dwAlphaBitDepth; */
|
---|
367 | 0, /* DWORD dwReserved; */
|
---|
368 | NULL, /* LPVOID lpSurface; */
|
---|
369 | {
|
---|
370 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
371 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
372 | }, /* DDCOLORKEY ddckCKDestOverlay; */
|
---|
373 | {
|
---|
374 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
375 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
376 | }, /* DDCOLORKEY ddckCKDestBlt; */
|
---|
377 | {
|
---|
378 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
379 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
380 | }, /* DDCOLORKEY ddckCKSrcOverlay; */
|
---|
381 | {
|
---|
382 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
383 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
384 | }, /* DDCOLORKEY ddckCKSrcBlt; */
|
---|
385 | {
|
---|
386 | sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
|
---|
387 | DDPF_RGB, /* DWORD dwFlags; */
|
---|
388 | 0, /* DWORD dwFourCC; */
|
---|
389 | {
|
---|
390 | 32, /* union */
|
---|
391 | /* DWORD dwRGBBitCount; */
|
---|
392 | /* DWORD dwYUVBitCount; */
|
---|
393 | /* DWORD dwZBufferBitDepth; */
|
---|
394 | /* DWORD dwAlphaBitDepth; */
|
---|
395 | /* DWORD dwLuminanceBitCount; */
|
---|
396 | /* DWORD dwBumpBitCount; */
|
---|
397 | },
|
---|
398 | {
|
---|
399 | 0xff0000, /* union */
|
---|
400 | /* DWORD dwRBitMask; */
|
---|
401 | /* DWORD dwYBitMask; */
|
---|
402 | /* DWORD dwStencilBitDepth; */
|
---|
403 | /* DWORD dwLuminanceBitMask; */
|
---|
404 | /* DWORD dwBumpDuBitMask; */
|
---|
405 | },
|
---|
406 | {
|
---|
407 | 0xff00,
|
---|
408 | /* DWORD dwGBitMask; */
|
---|
409 | /* DWORD dwUBitMask; */
|
---|
410 | /* DWORD dwZBitMask; */
|
---|
411 | /* DWORD dwBumpDvBitMask; */
|
---|
412 | },
|
---|
413 | {
|
---|
414 | 0xff,
|
---|
415 | /* DWORD dwBBitMask; */
|
---|
416 | /* DWORD dwVBitMask; */
|
---|
417 | /* DWORD dwStencilBitMask; */
|
---|
418 | /* DWORD dwBumpLuminanceBitMask; */
|
---|
419 | },
|
---|
420 | {
|
---|
421 | 0,
|
---|
422 | /* DWORD dwRGBAlphaBitMask; */
|
---|
423 | /* DWORD dwYUVAlphaBitMask; */
|
---|
424 | /* DWORD dwLuminanceAlphaBitMask; */
|
---|
425 | /* DWORD dwRGBZBitMask; */
|
---|
426 | /* DWORD dwYUVZBitMask; */
|
---|
427 | },
|
---|
428 | }, /* DDPIXELFORMAT ddpfPixelFormat; */
|
---|
429 | {
|
---|
430 | DDSCAPS_BACKBUFFER
|
---|
431 | | DDSCAPS_COMPLEX
|
---|
432 | | DDSCAPS_FLIP
|
---|
433 | | DDSCAPS_FRONTBUFFER
|
---|
434 | | DDSCAPS_LOCALVIDMEM
|
---|
435 | | DDSCAPS_PRIMARYSURFACE
|
---|
436 | | DDSCAPS_VIDEOMEMORY
|
---|
437 | | DDSCAPS_VISIBLE /* DWORD dwCaps; */
|
---|
438 | } /* DDSCAPS ddsCaps; */
|
---|
439 | },
|
---|
440 | {
|
---|
441 | sizeof (DDSURFACEDESC), /* DWORD dwSize; */
|
---|
442 | DDSD_CAPS | DDSD_PIXELFORMAT, /* DWORD dwFlags; */
|
---|
443 | 0, /* DWORD dwHeight; */
|
---|
444 | 0, /* DWORD dwWidth; */
|
---|
445 | {
|
---|
446 | 0, /* Union */
|
---|
447 | /* LONG lPitch; */
|
---|
448 | /* DWORD dwLinearSize; */
|
---|
449 | },
|
---|
450 | 0, /* DWORD dwBackBufferCount; */
|
---|
451 | {
|
---|
452 | 0, /* Union */
|
---|
453 | /* DWORD dwMipMapCount; */
|
---|
454 | /* DWORD dwZBufferBitDepth; */
|
---|
455 | /* DWORD dwRefreshRate; */
|
---|
456 | },
|
---|
457 | 0, /* DWORD dwAlphaBitDepth; */
|
---|
458 | 0, /* DWORD dwReserved; */
|
---|
459 | NULL, /* LPVOID lpSurface; */
|
---|
460 | {
|
---|
461 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
462 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
463 | }, /* DDCOLORKEY ddckCKDestOverlay; */
|
---|
464 | {
|
---|
465 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
466 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
467 | }, /* DDCOLORKEY ddckCKDestBlt; */
|
---|
468 | {
|
---|
469 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
470 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
471 | }, /* DDCOLORKEY ddckCKSrcOverlay; */
|
---|
472 | {
|
---|
473 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
474 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
475 | }, /* DDCOLORKEY ddckCKSrcBlt; */
|
---|
476 | {
|
---|
477 | sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
|
---|
478 | DDPF_RGB, /* DWORD dwFlags; */
|
---|
479 | 0, /* DWORD dwFourCC; */
|
---|
480 | {
|
---|
481 | 24, /* union */
|
---|
482 | /* DWORD dwRGBBitCount; */
|
---|
483 | /* DWORD dwYUVBitCount; */
|
---|
484 | /* DWORD dwZBufferBitDepth; */
|
---|
485 | /* DWORD dwAlphaBitDepth; */
|
---|
486 | /* DWORD dwLuminanceBitCount; */
|
---|
487 | /* DWORD dwBumpBitCount; */
|
---|
488 | },
|
---|
489 | {
|
---|
490 | 0xff0000, /* union */
|
---|
491 | /* DWORD dwRBitMask; */
|
---|
492 | /* DWORD dwYBitMask; */
|
---|
493 | /* DWORD dwStencilBitDepth; */
|
---|
494 | /* DWORD dwLuminanceBitMask; */
|
---|
495 | /* DWORD dwBumpDuBitMask; */
|
---|
496 | },
|
---|
497 | {
|
---|
498 | 0xff00,
|
---|
499 | /* DWORD dwGBitMask; */
|
---|
500 | /* DWORD dwUBitMask; */
|
---|
501 | /* DWORD dwZBitMask; */
|
---|
502 | /* DWORD dwBumpDvBitMask; */
|
---|
503 | },
|
---|
504 | {
|
---|
505 | 0xff,
|
---|
506 | /* DWORD dwBBitMask; */
|
---|
507 | /* DWORD dwVBitMask; */
|
---|
508 | /* DWORD dwStencilBitMask; */
|
---|
509 | /* DWORD dwBumpLuminanceBitMask; */
|
---|
510 | },
|
---|
511 | {
|
---|
512 | 0,
|
---|
513 | /* DWORD dwRGBAlphaBitMask; */
|
---|
514 | /* DWORD dwYUVAlphaBitMask; */
|
---|
515 | /* DWORD dwLuminanceAlphaBitMask; */
|
---|
516 | /* DWORD dwRGBZBitMask; */
|
---|
517 | /* DWORD dwYUVZBitMask; */
|
---|
518 | },
|
---|
519 | }, /* DDPIXELFORMAT ddpfPixelFormat; */
|
---|
520 | {
|
---|
521 | DDSCAPS_BACKBUFFER
|
---|
522 | | DDSCAPS_COMPLEX
|
---|
523 | | DDSCAPS_FLIP
|
---|
524 | | DDSCAPS_FRONTBUFFER
|
---|
525 | | DDSCAPS_LOCALVIDMEM
|
---|
526 | | DDSCAPS_PRIMARYSURFACE
|
---|
527 | | DDSCAPS_VIDEOMEMORY
|
---|
528 | | DDSCAPS_VISIBLE /* DWORD dwCaps; */
|
---|
529 | } /* DDSCAPS ddsCaps; */
|
---|
530 | },
|
---|
531 | {
|
---|
532 | sizeof (DDSURFACEDESC), /* DWORD dwSize; */
|
---|
533 | DDSD_CAPS | DDSD_PIXELFORMAT, /* DWORD dwFlags; */
|
---|
534 | 0, /* DWORD dwHeight; */
|
---|
535 | 0, /* DWORD dwWidth; */
|
---|
536 | {
|
---|
537 | 0, /* Union */
|
---|
538 | /* LONG lPitch; */
|
---|
539 | /* DWORD dwLinearSize; */
|
---|
540 | },
|
---|
541 | 0, /* DWORD dwBackBufferCount; */
|
---|
542 | {
|
---|
543 | 0, /* Union */
|
---|
544 | /* DWORD dwMipMapCount; */
|
---|
545 | /* DWORD dwZBufferBitDepth; */
|
---|
546 | /* DWORD dwRefreshRate; */
|
---|
547 | },
|
---|
548 | 0, /* DWORD dwAlphaBitDepth; */
|
---|
549 | 0, /* DWORD dwReserved; */
|
---|
550 | NULL, /* LPVOID lpSurface; */
|
---|
551 | {
|
---|
552 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
553 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
554 | }, /* DDCOLORKEY ddckCKDestOverlay; */
|
---|
555 | {
|
---|
556 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
557 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
558 | }, /* DDCOLORKEY ddckCKDestBlt; */
|
---|
559 | {
|
---|
560 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
561 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
562 | }, /* DDCOLORKEY ddckCKSrcOverlay; */
|
---|
563 | {
|
---|
564 | 0, /* DWORD dwColorSpaceLowValue; */
|
---|
565 | 0, /* DWORD dwColorSpaceHighValue; */
|
---|
566 | }, /* DDCOLORKEY ddckCKSrcBlt; */
|
---|
567 | {
|
---|
568 | sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
|
---|
569 | DDPF_RGB, /* DWORD dwFlags; */
|
---|
570 | 0, /* DWORD dwFourCC; */
|
---|
571 | {
|
---|
572 | 16, /* union */
|
---|
573 | /* DWORD dwRGBBitCount; */
|
---|
574 | /* DWORD dwYUVBitCount; */
|
---|
575 | /* DWORD dwZBufferBitDepth; */
|
---|
576 | /* DWORD dwAlphaBitDepth; */
|
---|
577 | /* DWORD dwLuminanceBitCount; */
|
---|
578 | /* DWORD dwBumpBitCount; */
|
---|
579 | },
|
---|
580 | {
|
---|
581 | 0xf800, /* union */
|
---|
582 | /* DWORD dwRBitMask; */
|
---|
583 | /* DWORD dwYBitMask; */
|
---|
584 | /* DWORD dwStencilBitDepth; */
|
---|
585 | /* DWORD dwLuminanceBitMask; */
|
---|
586 | /* DWORD dwBumpDuBitMask; */
|
---|
587 | },
|
---|
588 | {
|
---|
589 | 0x7e0,
|
---|
590 | /* DWORD dwGBitMask; */
|
---|
591 | /* DWORD dwUBitMask; */
|
---|
592 | /* DWORD dwZBitMask; */
|
---|
593 | /* DWORD dwBumpDvBitMask; */
|
---|
594 | },
|
---|
595 | {
|
---|
596 | 0x1f,
|
---|
597 | /* DWORD dwBBitMask; */
|
---|
598 | /* DWORD dwVBitMask; */
|
---|
599 | /* DWORD dwStencilBitMask; */
|
---|
600 | /* DWORD dwBumpLuminanceBitMask; */
|
---|
601 | },
|
---|
602 | {
|
---|
603 | 0,
|
---|
604 | /* DWORD dwRGBAlphaBitMask; */
|
---|
605 | /* DWORD dwYUVAlphaBitMask; */
|
---|
606 | /* DWORD dwLuminanceAlphaBitMask; */
|
---|
607 | /* DWORD dwRGBZBitMask; */
|
---|
608 | /* DWORD dwYUVZBitMask; */
|
---|
609 | },
|
---|
610 | }, /* DDPIXELFORMAT ddpfPixelFormat; */
|
---|
611 | {
|
---|
612 | DDSCAPS_BACKBUFFER
|
---|
613 | | DDSCAPS_COMPLEX
|
---|
614 | | DDSCAPS_FLIP
|
---|
615 | | DDSCAPS_FRONTBUFFER
|
---|
616 | | DDSCAPS_LOCALVIDMEM
|
---|
617 | | DDSCAPS_PRIMARYSURFACE
|
---|
618 | | DDSCAPS_VIDEOMEMORY
|
---|
619 | | DDSCAPS_VISIBLE /* DWORD dwCaps; */
|
---|
620 | } /* DDSCAPS ddsCaps; */
|
---|
621 | },
|
---|
622 | };
|
---|
623 |
|
---|
624 | static D3DDDIQUERYTYPE gVBoxQueryTypes[] = {
|
---|
625 | D3DDDIQUERYTYPE_EVENT,
|
---|
626 | D3DDDIQUERYTYPE_OCCLUSION
|
---|
627 | };
|
---|
628 |
|
---|
629 | #define VBOX_QUERYTYPE_COUNT() RT_ELEMENTS(gVBoxQueryTypes)
|
---|
630 |
|
---|
631 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
632 |
|
---|
633 | static bool vboxVhwaIsEnabled(PVBOXWDDMDISP_ADAPTER pAdapter)
|
---|
634 | {
|
---|
635 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
636 | {
|
---|
637 | if (pAdapter->aHeads[i].Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)
|
---|
638 | return true;
|
---|
639 | }
|
---|
640 | return false;
|
---|
641 | }
|
---|
642 |
|
---|
643 | static bool vboxVhwaHasCKeying(PVBOXWDDMDISP_ADAPTER pAdapter)
|
---|
644 | {
|
---|
645 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
646 | {
|
---|
647 | VBOXVHWA_INFO* pSettings = &pAdapter->aHeads[i].Vhwa.Settings;
|
---|
648 | if ((pSettings->fFlags & VBOXVHWA_F_ENABLED)
|
---|
649 | && ((pSettings->fFlags & VBOXVHWA_F_CKEY_DST)
|
---|
650 | || (pSettings->fFlags & VBOXVHWA_F_CKEY_SRC))
|
---|
651 | )
|
---|
652 | return true;
|
---|
653 | }
|
---|
654 | return false;
|
---|
655 | }
|
---|
656 |
|
---|
657 | static void vboxVhwaPopulateOverlayFourccSurfDesc(DDSURFACEDESC *pDesc, uint32_t fourcc)
|
---|
658 | {
|
---|
659 | memset(pDesc, 0, sizeof (DDSURFACEDESC));
|
---|
660 |
|
---|
661 | pDesc->dwSize = sizeof (DDSURFACEDESC);
|
---|
662 | pDesc->dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT;
|
---|
663 | pDesc->ddpfPixelFormat.dwSize = sizeof (DDPIXELFORMAT);
|
---|
664 | pDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC;
|
---|
665 | pDesc->ddpfPixelFormat.dwFourCC = fourcc;
|
---|
666 | pDesc->ddsCaps.dwCaps = DDSCAPS_BACKBUFFER
|
---|
667 | | DDSCAPS_COMPLEX
|
---|
668 | | DDSCAPS_FLIP
|
---|
669 | | DDSCAPS_FRONTBUFFER
|
---|
670 | | DDSCAPS_LOCALVIDMEM
|
---|
671 | | DDSCAPS_OVERLAY
|
---|
672 | | DDSCAPS_VIDEOMEMORY
|
---|
673 | | DDSCAPS_VISIBLE;
|
---|
674 | }
|
---|
675 |
|
---|
676 | #endif
|
---|
677 |
|
---|
678 | static bool vboxPixFormatMatch(DDPIXELFORMAT *pFormat1, DDPIXELFORMAT *pFormat2)
|
---|
679 | {
|
---|
680 | return !memcmp(pFormat1, pFormat2, sizeof (DDPIXELFORMAT));
|
---|
681 | }
|
---|
682 |
|
---|
683 | int vboxSurfDescMerge(DDSURFACEDESC *paDescs, uint32_t *pcDescs, uint32_t cMaxDescs, DDSURFACEDESC *pDesc)
|
---|
684 | {
|
---|
685 | uint32_t cDescs = *pcDescs;
|
---|
686 |
|
---|
687 | Assert(cMaxDescs >= cDescs);
|
---|
688 | Assert(pDesc->dwFlags == (DDSD_CAPS | DDSD_PIXELFORMAT));
|
---|
689 | if (pDesc->dwFlags != (DDSD_CAPS | DDSD_PIXELFORMAT))
|
---|
690 | return VERR_INVALID_PARAMETER;
|
---|
691 |
|
---|
692 | for (uint32_t i = 0; i < cDescs; ++i)
|
---|
693 | {
|
---|
694 | DDSURFACEDESC *pCur = &paDescs[i];
|
---|
695 | if (vboxPixFormatMatch(&pCur->ddpfPixelFormat, &pDesc->ddpfPixelFormat))
|
---|
696 | {
|
---|
697 | if (pDesc->dwFlags & DDSD_CAPS)
|
---|
698 | {
|
---|
699 | pCur->dwFlags |= DDSD_CAPS;
|
---|
700 | pCur->ddsCaps.dwCaps |= pDesc->ddsCaps.dwCaps;
|
---|
701 | }
|
---|
702 | return VINF_SUCCESS;
|
---|
703 | }
|
---|
704 | }
|
---|
705 |
|
---|
706 | if (cMaxDescs > cDescs)
|
---|
707 | {
|
---|
708 | paDescs[cDescs] = *pDesc;
|
---|
709 | ++cDescs;
|
---|
710 | *pcDescs = cDescs;
|
---|
711 | return VINF_SUCCESS;
|
---|
712 | }
|
---|
713 | return VERR_BUFFER_OVERFLOW;
|
---|
714 | }
|
---|
715 |
|
---|
716 | int vboxFormatOpsMerge(FORMATOP *paOps, uint32_t *pcOps, uint32_t cMaxOps, FORMATOP *pOp)
|
---|
717 | {
|
---|
718 | uint32_t cOps = *pcOps;
|
---|
719 |
|
---|
720 | Assert(cMaxOps >= cOps);
|
---|
721 |
|
---|
722 | for (uint32_t i = 0; i < cOps; ++i)
|
---|
723 | {
|
---|
724 | FORMATOP *pCur = &paOps[i];
|
---|
725 | if (pCur->Format == pOp->Format)
|
---|
726 | {
|
---|
727 | pCur->Operations |= pOp->Operations;
|
---|
728 | Assert(pCur->FlipMsTypes == pOp->FlipMsTypes);
|
---|
729 | Assert(pCur->BltMsTypes == pOp->BltMsTypes);
|
---|
730 | Assert(pCur->PrivateFormatBitCount == pOp->PrivateFormatBitCount);
|
---|
731 | return VINF_SUCCESS;
|
---|
732 | }
|
---|
733 | }
|
---|
734 |
|
---|
735 | if (cMaxOps > cOps)
|
---|
736 | {
|
---|
737 | paOps[cOps] = *pOp;
|
---|
738 | ++cOps;
|
---|
739 | *pcOps = cOps;
|
---|
740 | return VINF_SUCCESS;
|
---|
741 | }
|
---|
742 | return VERR_BUFFER_OVERFLOW;
|
---|
743 | }
|
---|
744 |
|
---|
745 | int vboxCapsInit(PVBOXWDDMDISP_ADAPTER pAdapter)
|
---|
746 | {
|
---|
747 | pAdapter->cFormstOps = 0;
|
---|
748 | pAdapter->paFormstOps = NULL;
|
---|
749 | pAdapter->cSurfDescs = 0;
|
---|
750 | pAdapter->paSurfDescs = NULL;
|
---|
751 |
|
---|
752 | if (pAdapter->uIfVersion > 7)
|
---|
753 | {
|
---|
754 | if (pAdapter->pD3D9If)
|
---|
755 | {
|
---|
756 | pAdapter->paFormstOps = (FORMATOP*)RTMemAllocZ(sizeof (gVBoxFormatOps3D));
|
---|
757 | Assert(pAdapter->paFormstOps);
|
---|
758 | if (pAdapter->paFormstOps)
|
---|
759 | {
|
---|
760 | memcpy (pAdapter->paFormstOps , gVBoxFormatOps3D, sizeof (gVBoxFormatOps3D));
|
---|
761 | pAdapter->cFormstOps = RT_ELEMENTS(gVBoxFormatOps3D);
|
---|
762 | }
|
---|
763 | else
|
---|
764 | return VERR_OUT_OF_RESOURCES;
|
---|
765 |
|
---|
766 | /* @todo: do we need surface caps here ? */
|
---|
767 | }
|
---|
768 | }
|
---|
769 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
770 | else
|
---|
771 | {
|
---|
772 | /* just calc the max number of formats */
|
---|
773 | uint32_t cFormats = RT_ELEMENTS(gVBoxFormatOpsBase);
|
---|
774 | uint32_t cSurfDescs = RT_ELEMENTS(gVBoxSurfDescsBase);
|
---|
775 | uint32_t cOverlayFormats = 0;
|
---|
776 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
777 | {
|
---|
778 | VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
|
---|
779 | if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
|
---|
780 | {
|
---|
781 | cOverlayFormats += pVhwa->Settings.cFormats;
|
---|
782 | }
|
---|
783 | }
|
---|
784 |
|
---|
785 | cFormats += cOverlayFormats;
|
---|
786 | cSurfDescs += cOverlayFormats;
|
---|
787 |
|
---|
788 | uint32_t cbFormatOps = cFormats * sizeof (FORMATOP);
|
---|
789 | cbFormatOps = (cbFormatOps + 7) & ~3;
|
---|
790 | /* ensure the surf descs are 8 byte alligned */
|
---|
791 | uint32_t offSurfDescs = (cbFormatOps + 7) & ~3;
|
---|
792 | uint32_t cbSurfDescs = cSurfDescs * sizeof (DDSURFACEDESC);
|
---|
793 | uint32_t cbBuf = offSurfDescs + cbSurfDescs;
|
---|
794 | uint8_t* pvBuf = (uint8_t*)RTMemAllocZ(cbBuf);
|
---|
795 | Assert(pvBuf);
|
---|
796 | if (pvBuf)
|
---|
797 | {
|
---|
798 | pAdapter->paFormstOps = (FORMATOP*)pvBuf;
|
---|
799 | memcpy (pAdapter->paFormstOps , gVBoxFormatOpsBase, sizeof (gVBoxFormatOpsBase));
|
---|
800 | pAdapter->cFormstOps = RT_ELEMENTS(gVBoxFormatOpsBase);
|
---|
801 |
|
---|
802 | FORMATOP fo = {D3DDDIFMT_UNKNOWN, 0, 0, 0, 0};
|
---|
803 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
804 | {
|
---|
805 | VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
|
---|
806 | if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
|
---|
807 | {
|
---|
808 | for (uint32_t j = 0; j < pVhwa->Settings.cFormats; ++j)
|
---|
809 | {
|
---|
810 | fo.Format = pVhwa->Settings.aFormats[j];
|
---|
811 | fo.Operations = FORMATOP_OVERLAY;
|
---|
812 | int rc = vboxFormatOpsMerge(pAdapter->paFormstOps, &pAdapter->cFormstOps, cFormats, &fo);
|
---|
813 | AssertRC(rc);
|
---|
814 | }
|
---|
815 | }
|
---|
816 | }
|
---|
817 |
|
---|
818 | pAdapter->paSurfDescs = (DDSURFACEDESC*)(pvBuf + offSurfDescs);
|
---|
819 | memcpy (pAdapter->paSurfDescs , gVBoxSurfDescsBase, sizeof (gVBoxSurfDescsBase));
|
---|
820 | pAdapter->cSurfDescs = RT_ELEMENTS(gVBoxSurfDescsBase);
|
---|
821 |
|
---|
822 | DDSURFACEDESC sd;
|
---|
823 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
824 | {
|
---|
825 | VBOXDISPVHWA_INFO *pVhwa = &pAdapter->aHeads[i].Vhwa;
|
---|
826 | if (pVhwa->Settings.fFlags & VBOXVHWA_F_ENABLED)
|
---|
827 | {
|
---|
828 | for (uint32_t j = 0; j < pVhwa->Settings.cFormats; ++j)
|
---|
829 | {
|
---|
830 | uint32_t fourcc = vboxWddmFormatToFourcc(pVhwa->Settings.aFormats[j]);
|
---|
831 | if (fourcc)
|
---|
832 | {
|
---|
833 | vboxVhwaPopulateOverlayFourccSurfDesc(&sd, fourcc);
|
---|
834 | int rc = vboxSurfDescMerge(pAdapter->paSurfDescs, &pAdapter->cSurfDescs, cSurfDescs, &sd);
|
---|
835 | AssertRC(rc);
|
---|
836 | }
|
---|
837 | }
|
---|
838 | }
|
---|
839 | }
|
---|
840 | }
|
---|
841 | else
|
---|
842 | return VERR_OUT_OF_RESOURCES;
|
---|
843 | }
|
---|
844 | #endif
|
---|
845 |
|
---|
846 | return VINF_SUCCESS;
|
---|
847 | }
|
---|
848 |
|
---|
849 | void vboxCapsFree(PVBOXWDDMDISP_ADAPTER pAdapter)
|
---|
850 | {
|
---|
851 | if (pAdapter->paFormstOps)
|
---|
852 | RTMemFree(pAdapter->paFormstOps);
|
---|
853 | }
|
---|
854 |
|
---|
855 | static PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs)
|
---|
856 | {
|
---|
857 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
|
---|
858 | Assert(pRc);
|
---|
859 | if (pRc)
|
---|
860 | {
|
---|
861 | pRc->cAllocations = cAllocs;
|
---|
862 | return pRc;
|
---|
863 | }
|
---|
864 | return NULL;
|
---|
865 | }
|
---|
866 |
|
---|
867 | static void vboxWddmLockUnlockMemSynch(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DLOCKED_RECT *pLockInfo, RECT *pRect, bool bToLockInfo)
|
---|
868 | {
|
---|
869 | Assert(pAlloc->SurfDesc.pitch);
|
---|
870 | Assert(pAlloc->pvMem);
|
---|
871 |
|
---|
872 | if (!pRect)
|
---|
873 | {
|
---|
874 | if (pAlloc->SurfDesc.pitch == pLockInfo->Pitch)
|
---|
875 | {
|
---|
876 | if (bToLockInfo)
|
---|
877 | memcpy(pLockInfo->pBits, pAlloc->pvMem, pAlloc->SurfDesc.pitch * pAlloc->SurfDesc.height);
|
---|
878 | else
|
---|
879 | memcpy(pAlloc->pvMem, pLockInfo->pBits, pAlloc->SurfDesc.pitch * pAlloc->SurfDesc.height);
|
---|
880 | }
|
---|
881 | else
|
---|
882 | {
|
---|
883 | uint8_t *pvSrc, *pvDst;
|
---|
884 | uint32_t srcPitch, dstPitch;
|
---|
885 | if (bToLockInfo)
|
---|
886 | {
|
---|
887 | pvSrc = (uint8_t *)pAlloc->pvMem;
|
---|
888 | pvDst = (uint8_t *)pLockInfo->pBits;
|
---|
889 | srcPitch = pAlloc->SurfDesc.pitch;
|
---|
890 | dstPitch = pLockInfo->Pitch;
|
---|
891 | }
|
---|
892 | else
|
---|
893 | {
|
---|
894 | pvDst = (uint8_t *)pAlloc->pvMem;
|
---|
895 | pvSrc = (uint8_t *)pLockInfo->pBits;
|
---|
896 | dstPitch = pAlloc->SurfDesc.pitch;
|
---|
897 | srcPitch = (uint32_t)pLockInfo->Pitch;
|
---|
898 | }
|
---|
899 |
|
---|
900 | uint32_t pitch = RT_MIN(srcPitch, dstPitch);
|
---|
901 | Assert(pitch);
|
---|
902 | for (UINT j = 0; j < pAlloc->SurfDesc.height; ++j)
|
---|
903 | {
|
---|
904 | memcpy(pvDst, pvSrc, pitch);
|
---|
905 | pvSrc += srcPitch;
|
---|
906 | pvDst += dstPitch;
|
---|
907 | }
|
---|
908 | }
|
---|
909 | }
|
---|
910 | else
|
---|
911 | {
|
---|
912 | uint8_t *pvSrc, *pvDst;
|
---|
913 | uint32_t srcPitch, dstPitch;
|
---|
914 | /* @todo: this is not entirely correct */
|
---|
915 | uint8_t * pvAllocMemStart = (uint8_t *)pAlloc->pvMem;
|
---|
916 | uint32_t cbPP = pAlloc->SurfDesc.pitch/pAlloc->SurfDesc.width;
|
---|
917 | pvAllocMemStart += pAlloc->SurfDesc.pitch * pRect->top + pRect->left * cbPP;
|
---|
918 |
|
---|
919 | if (bToLockInfo)
|
---|
920 | {
|
---|
921 | pvSrc = (uint8_t *)pvAllocMemStart;
|
---|
922 | pvDst = (uint8_t *)pLockInfo->pBits;
|
---|
923 | srcPitch = pAlloc->SurfDesc.pitch;
|
---|
924 | dstPitch = pLockInfo->Pitch;
|
---|
925 | }
|
---|
926 | else
|
---|
927 | {
|
---|
928 | pvDst = (uint8_t *)pvAllocMemStart;
|
---|
929 | pvSrc = (uint8_t *)pLockInfo->pBits;
|
---|
930 | dstPitch = pAlloc->SurfDesc.pitch;
|
---|
931 | srcPitch = (uint32_t)pLockInfo->Pitch;
|
---|
932 | }
|
---|
933 |
|
---|
934 | uint32_t cPixCopyLine = pRect->right - pRect->left;
|
---|
935 |
|
---|
936 | if (cPixCopyLine == pAlloc->SurfDesc.width && srcPitch == dstPitch)
|
---|
937 | {
|
---|
938 | memcpy(pvDst, pvSrc, pAlloc->SurfDesc.pitch * (pRect->bottom - pRect->top));
|
---|
939 | }
|
---|
940 | else
|
---|
941 | {
|
---|
942 | uint32_t pitch = RT_MIN(srcPitch, dstPitch);
|
---|
943 | uint32_t cbCopyLine = cPixCopyLine * cbPP;
|
---|
944 | Assert(pitch);
|
---|
945 | for (int j = pRect->top; j < pRect->bottom; ++j)
|
---|
946 | {
|
---|
947 | memcpy(pvDst, pvSrc, cbCopyLine);
|
---|
948 | pvSrc += srcPitch;
|
---|
949 | pvDst += dstPitch;
|
---|
950 | }
|
---|
951 | }
|
---|
952 | }
|
---|
953 | }
|
---|
954 |
|
---|
955 | #if 0
|
---|
956 | static HRESULT vboxWddmRectBltPerform(uint8_t *pvDstSurf, const uint8_t *pvSrcSurf,
|
---|
957 | RECT *pDstRect, RECT *pSrcRect,
|
---|
958 | uint32_t DstPitch, uint32_t SrcPitch, uint32_t bpp,
|
---|
959 | RECT *pDstCopyRect, RECT *pSrcCopyRect)
|
---|
960 | {
|
---|
961 | uint32_t DstCopyWidth = pDstCopyRect->left - pDstCopyRect->right;
|
---|
962 | uint32_t DstCopyHeight = pDstCopyRect->bottom - pDstCopyRect->top;
|
---|
963 | uint32_t SrcCopyWidth = pSrcCopyRect->left - pSrcCopyRect->right;
|
---|
964 | uint32_t SrcCopyHeight = pSrcCopyRect->bottom - pSrcCopyRect->top;
|
---|
965 | uint32_t srcBpp = bpp;
|
---|
966 | uint32_t dstBpp = bpp;
|
---|
967 | /* we do not support stretching */
|
---|
968 | Assert(DstCopyWidth == SrcCopyWidth);
|
---|
969 | Assert(DstCopyHeight == SrcCopyWidth);
|
---|
970 | if (DstCopyWidth != SrcCopyWidth)
|
---|
971 | return E_FAIL;
|
---|
972 | if (DstCopyHeight != SrcCopyWidth)
|
---|
973 | return E_FAIL;
|
---|
974 |
|
---|
975 | uint32_t DstWidth = pDstRect->left - pDstRect->right;
|
---|
976 | uint32_t DstHeight = pDstRect->bottom - pDstRect->top;
|
---|
977 | uint32_t SrcWidth = pSrcRect->left - pSrcRect->right;
|
---|
978 | uint32_t SrcHeight = pSrcRect->bottom - pSrcRect->top;
|
---|
979 |
|
---|
980 | if (DstWidth == DstCopyWidth
|
---|
981 | && SrcWidth == SrcCopyWidth
|
---|
982 | && SrcWidth == DstWidth)
|
---|
983 | {
|
---|
984 | Assert(!pDstCopyRect->left);
|
---|
985 | Assert(!pSrcCopyRect->left);
|
---|
986 | uint32_t cbOff = DstPitch * pDstCopyRect->top;
|
---|
987 | uint32_t cbSize = DstPitch * DstCopyHeight;
|
---|
988 | memcpy(pvDstSurf + cbOff, pvSrcSurf + cbOff, cbSize);
|
---|
989 | }
|
---|
990 | else
|
---|
991 | {
|
---|
992 | uint32_t offDstLineStart = pDstCopyRect->left * dstBpp >> 3;
|
---|
993 | uint32_t offDstLineEnd = ((pDstCopyRect->left * dstBpp + 7) >> 3) + ((dstBpp * DstCopyWidth + 7) >> 3);
|
---|
994 | uint32_t cbDstLine = offDstLineEnd - offDstLineStart;
|
---|
995 | uint32_t offDstStart = DstPitch * pDstCopyRect->top + offDstLineStart;
|
---|
996 | Assert(cbDstLine <= DstPitch);
|
---|
997 | uint32_t cbDstSkip = DstPitch;
|
---|
998 | uint8_t * pvDstStart = pvDstSurf + offDstStart;
|
---|
999 |
|
---|
1000 | uint32_t offSrcLineStart = pSrcCopyRect->left * srcBpp >> 3;
|
---|
1001 | uint32_t offSrcLineEnd = ((pSrcCopyRect->left * srcBpp + 7) >> 3) + ((srcBpp * SrcCopyWidth + 7) >> 3);
|
---|
1002 | uint32_t cbSrcLine = offSrcLineEnd - offSrcLineStart;
|
---|
1003 | uint32_t offSrcStart = SrcPitch * pSrcCopyRect->top + offSrcLineStart;
|
---|
1004 | Assert(cbSrcLine <= SrcPitch);
|
---|
1005 | uint32_t cbSrcSkip = SrcPitch;
|
---|
1006 | const uint8_t * pvSrcStart = pvSrcSurf + offSrcStart;
|
---|
1007 |
|
---|
1008 | Assert(cbDstLine == cbSrcLine);
|
---|
1009 |
|
---|
1010 | for (uint32_t i = 0; ; ++i)
|
---|
1011 | {
|
---|
1012 | memcpy (pvDstStart, pvSrcStart, cbDstLine);
|
---|
1013 | if (i == DstCopyHeight)
|
---|
1014 | break;
|
---|
1015 | pvDstStart += cbDstSkip;
|
---|
1016 | pvSrcStart += cbSrcSkip;
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 | return S_OK;
|
---|
1020 | }
|
---|
1021 | #endif
|
---|
1022 |
|
---|
1023 | static HRESULT vboxWddmRectBltPerform(uint8_t *pvDstSurf, const uint8_t *pvSrcSurf,
|
---|
1024 | const RECT *pDstRect, const RECT *pSrcRect,
|
---|
1025 | uint32_t DstPitch, uint32_t SrcPitch, uint32_t bpp)
|
---|
1026 | {
|
---|
1027 | uint32_t DstWidth = pDstRect->left - pDstRect->right;
|
---|
1028 | uint32_t DstHeight = pDstRect->bottom - pDstRect->top;
|
---|
1029 | uint32_t SrcWidth = pSrcRect->left - pSrcRect->right;
|
---|
1030 | uint32_t SrcHeight = pSrcRect->bottom - pSrcRect->top;
|
---|
1031 | uint32_t srcBpp = bpp;
|
---|
1032 | uint32_t dstBpp = bpp;
|
---|
1033 | /* we do not support stretching */
|
---|
1034 | Assert(DstWidth == SrcWidth);
|
---|
1035 | Assert(DstHeight == SrcWidth);
|
---|
1036 | if (DstWidth != SrcWidth)
|
---|
1037 | return E_FAIL;
|
---|
1038 | if (DstHeight != SrcWidth)
|
---|
1039 | return E_FAIL;
|
---|
1040 |
|
---|
1041 | if (DstPitch == SrcPitch
|
---|
1042 | && ((DstWidth * bpp)/8) == DstPitch)
|
---|
1043 | {
|
---|
1044 | Assert(!pDstRect->left);
|
---|
1045 | Assert(!pSrcRect->left);
|
---|
1046 | uint32_t cbOff = DstPitch * pDstRect->top;
|
---|
1047 | uint32_t cbSize = DstPitch * DstHeight;
|
---|
1048 | memcpy(pvDstSurf + cbOff, pvSrcSurf + cbOff, cbSize);
|
---|
1049 | }
|
---|
1050 | else
|
---|
1051 | {
|
---|
1052 |
|
---|
1053 | uint32_t cbDstLine = (((DstWidth * dstBpp) + 7) >> 3);
|
---|
1054 | for (uint32_t i = 0; ; ++i)
|
---|
1055 | {
|
---|
1056 | memcpy (pvDstSurf, pvSrcSurf, cbDstLine);
|
---|
1057 | if (i == DstHeight)
|
---|
1058 | break;
|
---|
1059 | pvDstSurf += DstPitch;
|
---|
1060 | pvSrcSurf += SrcPitch;
|
---|
1061 | }
|
---|
1062 | }
|
---|
1063 | return S_OK;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format)
|
---|
1067 | {
|
---|
1068 | /* @todo: check they are all equal */
|
---|
1069 | return (D3DFORMAT)format;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | D3DMULTISAMPLE_TYPE vboxDDI2D3DMultiSampleType(D3DDDIMULTISAMPLE_TYPE enmType)
|
---|
1073 | {
|
---|
1074 | /* @todo: check they are all equal */
|
---|
1075 | return (D3DMULTISAMPLE_TYPE)enmType;
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | D3DPOOL vboxDDI2D3DPool(D3DDDI_POOL enmPool)
|
---|
1079 | {
|
---|
1080 | /* @todo: check they are all equal */
|
---|
1081 | switch (enmPool)
|
---|
1082 | {
|
---|
1083 | case D3DDDIPOOL_SYSTEMMEM:
|
---|
1084 | return D3DPOOL_SYSTEMMEM;
|
---|
1085 | case D3DDDIPOOL_VIDEOMEMORY:
|
---|
1086 | case D3DDDIPOOL_LOCALVIDMEM:
|
---|
1087 | case D3DDDIPOOL_NONLOCALVIDMEM:
|
---|
1088 | /* @todo: what would be propper here? */
|
---|
1089 | return D3DPOOL_DEFAULT;
|
---|
1090 | default:
|
---|
1091 | AssertBreakpoint();
|
---|
1092 | }
|
---|
1093 | return D3DPOOL_DEFAULT;
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | D3DRENDERSTATETYPE vboxDDI2D3DRenderStateType(D3DDDIRENDERSTATETYPE enmType)
|
---|
1097 | {
|
---|
1098 | /* @todo: @fixme: not entirely correct, need to check */
|
---|
1099 | return (D3DRENDERSTATETYPE)enmType;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | VBOXWDDMDISP_TSS_LOOKUP vboxDDI2D3DTestureStageStateType(D3DDDITEXTURESTAGESTATETYPE enmType)
|
---|
1103 | {
|
---|
1104 | static const VBOXWDDMDISP_TSS_LOOKUP lookup[] =
|
---|
1105 | {
|
---|
1106 | {FALSE, D3DTSS_FORCE_DWORD}, /* 0, D3DDDITSS_TEXTUREMAP */
|
---|
1107 | {FALSE, D3DTSS_COLOROP}, /* 1, D3DDDITSS_COLOROP */
|
---|
1108 | {FALSE, D3DTSS_COLORARG1}, /* 2, D3DDDITSS_COLORARG1 */
|
---|
1109 | {FALSE, D3DTSS_COLORARG2}, /* 3, D3DDDITSS_COLORARG2 */
|
---|
1110 | {FALSE, D3DTSS_ALPHAOP}, /* 4, D3DDDITSS_ALPHAOP */
|
---|
1111 | {FALSE, D3DTSS_ALPHAARG1}, /* 5, D3DDDITSS_ALPHAARG1 */
|
---|
1112 | {FALSE, D3DTSS_ALPHAARG2}, /* 6, D3DDDITSS_ALPHAARG2 */
|
---|
1113 | {FALSE, D3DTSS_BUMPENVMAT00}, /* 7, D3DDDITSS_BUMPENVMAT00 */
|
---|
1114 | {FALSE, D3DTSS_BUMPENVMAT01}, /* 8, D3DDDITSS_BUMPENVMAT01 */
|
---|
1115 | {FALSE, D3DTSS_BUMPENVMAT10}, /* 9, D3DDDITSS_BUMPENVMAT10 */
|
---|
1116 | {FALSE, D3DTSS_BUMPENVMAT11}, /* 10, D3DDDITSS_BUMPENVMAT11 */
|
---|
1117 | {FALSE, D3DTSS_TEXCOORDINDEX}, /* 11, D3DDDITSS_TEXCOORDINDEX */
|
---|
1118 | {FALSE, D3DTSS_FORCE_DWORD}, /* 12, unused */
|
---|
1119 | {TRUE, D3DSAMP_ADDRESSU}, /* 13, D3DDDITSS_ADDRESSU */
|
---|
1120 | {TRUE, D3DSAMP_ADDRESSV}, /* 14, D3DDDITSS_ADDRESSV */
|
---|
1121 | {TRUE, D3DSAMP_BORDERCOLOR}, /* 15, D3DDDITSS_BORDERCOLOR */
|
---|
1122 | {TRUE, D3DSAMP_MAGFILTER}, /* 16, D3DDDITSS_MAGFILTER */
|
---|
1123 | {TRUE, D3DSAMP_MINFILTER}, /* 17, D3DDDITSS_MINFILTER */
|
---|
1124 | {TRUE, D3DSAMP_MIPFILTER}, /* 18, D3DDDITSS_MIPFILTER */
|
---|
1125 | {TRUE, D3DSAMP_MIPMAPLODBIAS}, /* 19, D3DDDITSS_MIPMAPLODBIAS */
|
---|
1126 | {TRUE, D3DSAMP_MAXMIPLEVEL}, /* 20, D3DDDITSS_MAXMIPLEVEL */
|
---|
1127 | {TRUE, D3DSAMP_MAXANISOTROPY}, /* 21, D3DDDITSS_MAXANISOTROPY */
|
---|
1128 | {FALSE, D3DTSS_BUMPENVLSCALE}, /* 22, D3DDDITSS_BUMPENVLSCALE */
|
---|
1129 | {FALSE, D3DTSS_BUMPENVLOFFSET}, /* 23, D3DDDITSS_BUMPENVLOFFSET */
|
---|
1130 | {FALSE, D3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DDDITSS_TEXTURETRANSFORMFLAGS */
|
---|
1131 | {TRUE, D3DSAMP_ADDRESSW}, /* 25, D3DDDITSS_ADDRESSW */
|
---|
1132 | {FALSE, D3DTSS_COLORARG0}, /* 26, D3DDDITSS_COLORARG0 */
|
---|
1133 | {FALSE, D3DTSS_ALPHAARG0}, /* 27, D3DDDITSS_ALPHAARG0 */
|
---|
1134 | {FALSE, D3DTSS_RESULTARG}, /* 28, D3DDDITSS_RESULTARG */
|
---|
1135 | {FALSE, D3DTSS_FORCE_DWORD}, /* 29, D3DDDITSS_SRGBTEXTURE */
|
---|
1136 | {FALSE, D3DTSS_FORCE_DWORD}, /* 30, D3DDDITSS_ELEMENTINDEX */
|
---|
1137 | {FALSE, D3DTSS_FORCE_DWORD}, /* 31, D3DDDITSS_DMAPOFFSET */
|
---|
1138 | {FALSE, D3DTSS_CONSTANT}, /* 32, D3DDDITSS_CONSTANT */
|
---|
1139 | {FALSE, D3DTSS_FORCE_DWORD}, /* 33, D3DDDITSS_DISABLETEXTURECOLORKEY */
|
---|
1140 | {FALSE, D3DTSS_FORCE_DWORD}, /* 34, D3DDDITSS_TEXTURECOLORKEYVAL */
|
---|
1141 | };
|
---|
1142 |
|
---|
1143 | return lookup[enmType];
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | DWORD vboxDDI2D3DUsage(D3DDDI_RESOURCEFLAGS fFlags)
|
---|
1147 | {
|
---|
1148 | DWORD fUsage = 0;
|
---|
1149 | if (fFlags.Dynamic)
|
---|
1150 | fUsage |= D3DUSAGE_DYNAMIC;
|
---|
1151 | if (fFlags.AutogenMipmap)
|
---|
1152 | fUsage |= D3DUSAGE_AUTOGENMIPMAP;
|
---|
1153 | if (fFlags.DMap)
|
---|
1154 | fUsage |= D3DUSAGE_DMAP;
|
---|
1155 | if (fFlags.WriteOnly)
|
---|
1156 | fUsage |= D3DUSAGE_WRITEONLY;
|
---|
1157 | if (fFlags.NPatches)
|
---|
1158 | fUsage |= D3DUSAGE_NPATCHES;
|
---|
1159 | if (fFlags.Points)
|
---|
1160 | fUsage |= D3DUSAGE_POINTS;
|
---|
1161 | if (fFlags.RenderTarget)
|
---|
1162 | fUsage |= D3DUSAGE_RENDERTARGET;
|
---|
1163 | if (fFlags.RtPatches)
|
---|
1164 | fUsage |= D3DUSAGE_RTPATCHES;
|
---|
1165 | if (fFlags.TextApi)
|
---|
1166 | fUsage |= D3DUSAGE_TEXTAPI;
|
---|
1167 | if (fFlags.WriteOnly)
|
---|
1168 | fUsage |= D3DUSAGE_WRITEONLY;
|
---|
1169 | //below are wddm 1.1-specific
|
---|
1170 | // if (fFlags.RestrictedContent)
|
---|
1171 | // fUsage |= D3DUSAGE_RESTRICTED_CONTENT;
|
---|
1172 | // if (fFlags.RestrictSharedAccess)
|
---|
1173 | // fUsage |= D3DUSAGE_RESTRICT_SHARED_RESOURCE;
|
---|
1174 | return fUsage;
|
---|
1175 | }
|
---|
1176 |
|
---|
1177 | DWORD vboxDDI2D3DLockFlags(D3DDDI_LOCKFLAGS fLockFlags)
|
---|
1178 | {
|
---|
1179 | DWORD fFlags = 0;
|
---|
1180 | if (fLockFlags.Discard)
|
---|
1181 | fFlags |= D3DLOCK_DISCARD;
|
---|
1182 | if (fLockFlags.NoOverwrite)
|
---|
1183 | fFlags |= D3DLOCK_NOOVERWRITE;
|
---|
1184 | if (fLockFlags.ReadOnly)
|
---|
1185 | fFlags |= D3DLOCK_READONLY;
|
---|
1186 | if (fLockFlags.DoNotWait)
|
---|
1187 | fFlags |= D3DLOCK_DONOTWAIT;
|
---|
1188 | return fFlags;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 | D3DTEXTUREFILTERTYPE vboxDDI2D3DBltFlags(D3DDDI_BLTFLAGS fFlags)
|
---|
1192 | {
|
---|
1193 | if (fFlags.Point)
|
---|
1194 | {
|
---|
1195 | /* no flags other than [Begin|Continue|End]PresentToDwm are set */
|
---|
1196 | Assert((fFlags.Value & (~(0x00000100 | 0x00000200 | 0x00000400))) == 1);
|
---|
1197 | return D3DTEXF_POINT;
|
---|
1198 | }
|
---|
1199 | if (fFlags.Linear)
|
---|
1200 | {
|
---|
1201 | /* no flags other than [Begin|Continue|End]PresentToDwm are set */
|
---|
1202 | Assert((fFlags.Value & (~(0x00000100 | 0x00000200 | 0x00000400))) == 2);
|
---|
1203 | return D3DTEXF_LINEAR;
|
---|
1204 | }
|
---|
1205 | /* no flags other than [Begin|Continue|End]PresentToDwm are set */
|
---|
1206 | Assert((fFlags.Value & (~(0x00000100 | 0x00000200 | 0x00000400))) == 0);
|
---|
1207 | return D3DTEXF_NONE;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | static void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc)
|
---|
1211 | {
|
---|
1212 | RTMemFree(pRc);
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | /**
|
---|
1216 | * DLL entry point.
|
---|
1217 | */
|
---|
1218 | BOOL WINAPI DllMain(HINSTANCE hInstance,
|
---|
1219 | DWORD dwReason,
|
---|
1220 | LPVOID lpReserved)
|
---|
1221 | {
|
---|
1222 | BOOL bOk = TRUE;
|
---|
1223 |
|
---|
1224 | switch (dwReason)
|
---|
1225 | {
|
---|
1226 | case DLL_PROCESS_ATTACH:
|
---|
1227 | {
|
---|
1228 | RTR3Init();
|
---|
1229 |
|
---|
1230 | HRESULT hr = vboxDispCmInit();
|
---|
1231 | Assert(hr == S_OK);
|
---|
1232 | #ifdef VBOXDISPMP_TEST
|
---|
1233 | if (hr == S_OK)
|
---|
1234 | {
|
---|
1235 | hr = vboxDispMpTstStart();
|
---|
1236 | Assert(hr == S_OK);
|
---|
1237 | }
|
---|
1238 | #endif
|
---|
1239 | if (hr == S_OK)
|
---|
1240 | vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
|
---|
1241 | else
|
---|
1242 | bOk = FALSE;
|
---|
1243 |
|
---|
1244 | // VbglR3Init();
|
---|
1245 | break;
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | case DLL_PROCESS_DETACH:
|
---|
1249 | {
|
---|
1250 | HRESULT hr;
|
---|
1251 | #ifdef VBOXDISPMP_TEST
|
---|
1252 | hr = vboxDispMpTstStop();
|
---|
1253 | Assert(hr == S_OK);
|
---|
1254 | if (hr == S_OK)
|
---|
1255 | #endif
|
---|
1256 | {
|
---|
1257 | hr = vboxDispCmTerm();
|
---|
1258 | Assert(hr == S_OK);
|
---|
1259 | if (hr == S_OK)
|
---|
1260 | vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n"));
|
---|
1261 | else
|
---|
1262 | bOk = FALSE;
|
---|
1263 | }
|
---|
1264 | // VbglR3Term();
|
---|
1265 | /// @todo RTR3Term();
|
---|
1266 | break;
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | default:
|
---|
1270 | break;
|
---|
1271 | }
|
---|
1272 | return bOk;
|
---|
1273 | }
|
---|
1274 |
|
---|
1275 | static HRESULT APIENTRY vboxWddmDispGetCaps (HANDLE hAdapter, CONST D3DDDIARG_GETCAPS* pData)
|
---|
1276 | {
|
---|
1277 | vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p), caps type(%d)\n", hAdapter, pData->Type));
|
---|
1278 |
|
---|
1279 | HRESULT hr = S_OK;
|
---|
1280 | PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
|
---|
1281 |
|
---|
1282 | switch (pData->Type)
|
---|
1283 | {
|
---|
1284 | case D3DDDICAPS_DDRAW:
|
---|
1285 | {
|
---|
1286 | Assert(!VBOXDISPMODE_IS_3D(pAdapter));
|
---|
1287 | Assert(pData->DataSize == sizeof (DDRAW_CAPS));
|
---|
1288 | if (pData->DataSize >= sizeof (DDRAW_CAPS))
|
---|
1289 | {
|
---|
1290 | memset(pData->pData, 0, sizeof (DDRAW_CAPS));
|
---|
1291 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1292 | if (vboxVhwaHasCKeying(pAdapter))
|
---|
1293 | {
|
---|
1294 | DDRAW_CAPS *pCaps = (DDRAW_CAPS*)pData->pData;
|
---|
1295 | pCaps->Caps |= DDRAW_CAPS_COLORKEY;
|
---|
1296 | // pCaps->Caps2 |= DDRAW_CAPS2_FLIPNOVSYNC;
|
---|
1297 | }
|
---|
1298 | #endif
|
---|
1299 | }
|
---|
1300 | else
|
---|
1301 | hr = E_INVALIDARG;
|
---|
1302 | break;
|
---|
1303 | }
|
---|
1304 | case D3DDDICAPS_DDRAW_MODE_SPECIFIC:
|
---|
1305 | {
|
---|
1306 | Assert(!VBOXDISPMODE_IS_3D(pAdapter));
|
---|
1307 | Assert(pData->DataSize == sizeof (DDRAW_MODE_SPECIFIC_CAPS));
|
---|
1308 | if (pData->DataSize >= sizeof (DDRAW_MODE_SPECIFIC_CAPS))
|
---|
1309 | {
|
---|
1310 | DDRAW_MODE_SPECIFIC_CAPS * pCaps = (DDRAW_MODE_SPECIFIC_CAPS*)pData->pData;
|
---|
1311 | memset(&pCaps->Caps /* do not cleanup the first "Head" field,
|
---|
1312 | zero starting with the one following "Head", i.e. Caps */,
|
---|
1313 | 0, sizeof (DDRAW_MODE_SPECIFIC_CAPS) - RT_OFFSETOF(DDRAW_MODE_SPECIFIC_CAPS, Caps));
|
---|
1314 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1315 | VBOXVHWA_INFO *pSettings = &pAdapter->aHeads[pCaps->Head].Vhwa.Settings;
|
---|
1316 | if (pSettings->fFlags & VBOXVHWA_F_ENABLED)
|
---|
1317 | {
|
---|
1318 | pCaps->Caps |= MODE_CAPS_OVERLAY | MODE_CAPS_OVERLAYSTRETCH;
|
---|
1319 |
|
---|
1320 | if (pSettings->fFlags & VBOXVHWA_F_CKEY_DST)
|
---|
1321 | {
|
---|
1322 | pCaps->CKeyCaps |= MODE_CKEYCAPS_DESTOVERLAY
|
---|
1323 | | MODE_CKEYCAPS_DESTOVERLAYYUV /* ?? */
|
---|
1324 | ;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | if (pSettings->fFlags & VBOXVHWA_F_CKEY_SRC)
|
---|
1328 | {
|
---|
1329 | pCaps->CKeyCaps |= MODE_CKEYCAPS_SRCOVERLAY
|
---|
1330 | | MODE_CKEYCAPS_SRCOVERLAYCLRSPACE /* ?? */
|
---|
1331 | | MODE_CKEYCAPS_SRCOVERLAYCLRSPACEYUV /* ?? */
|
---|
1332 | | MODE_CKEYCAPS_SRCOVERLAYYUV /* ?? */
|
---|
1333 | ;
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | pCaps->FxCaps = MODE_FXCAPS_OVERLAYSHRINKX
|
---|
1337 | | MODE_FXCAPS_OVERLAYSHRINKY
|
---|
1338 | | MODE_FXCAPS_OVERLAYSTRETCHX
|
---|
1339 | | MODE_FXCAPS_OVERLAYSTRETCHY;
|
---|
1340 |
|
---|
1341 |
|
---|
1342 | pCaps->MaxVisibleOverlays = pSettings->cOverlaysSupported;
|
---|
1343 | pCaps->MinOverlayStretch = 1;
|
---|
1344 | pCaps->MaxOverlayStretch = 32000;
|
---|
1345 | }
|
---|
1346 | #endif
|
---|
1347 | }
|
---|
1348 | else
|
---|
1349 | hr = E_INVALIDARG;
|
---|
1350 | break;
|
---|
1351 | }
|
---|
1352 | case D3DDDICAPS_GETFORMATCOUNT:
|
---|
1353 | *((uint32_t*)pData->pData) = pAdapter->cFormstOps;
|
---|
1354 | break;
|
---|
1355 | case D3DDDICAPS_GETFORMATDATA:
|
---|
1356 | Assert(pData->DataSize == pAdapter->cFormstOps * sizeof (FORMATOP));
|
---|
1357 | memcpy(pData->pData, pAdapter->paFormstOps, pAdapter->cFormstOps * sizeof (FORMATOP));
|
---|
1358 | break;
|
---|
1359 | case D3DDDICAPS_GETD3DQUERYCOUNT:
|
---|
1360 | #if 0
|
---|
1361 | *((uint32_t*)pData->pData) = VBOX_QUERYTYPE_COUNT();
|
---|
1362 | #else
|
---|
1363 | *((uint32_t*)pData->pData) = 0;
|
---|
1364 | #endif
|
---|
1365 | break;
|
---|
1366 | case D3DDDICAPS_GETD3DQUERYDATA:
|
---|
1367 | #if 0
|
---|
1368 | Assert(pData->DataSize == VBOX_QUERYTYPE_COUNT() * sizeof (D3DDDIQUERYTYPE));
|
---|
1369 | memcpy(pData->pData, gVBoxQueryTypes, VBOX_QUERYTYPE_COUNT() * sizeof (D3DDDIQUERYTYPE));
|
---|
1370 | #else
|
---|
1371 | AssertBreakpoint();
|
---|
1372 | memset(pData->pData, 0, pData->DataSize);
|
---|
1373 | #endif
|
---|
1374 | break;
|
---|
1375 | case D3DDDICAPS_GETD3D3CAPS:
|
---|
1376 | Assert(!VBOXDISPMODE_IS_3D(pAdapter));
|
---|
1377 | Assert(pData->DataSize == sizeof (D3DHAL_GLOBALDRIVERDATA));
|
---|
1378 | if (pData->DataSize >= sizeof (D3DHAL_GLOBALDRIVERDATA))
|
---|
1379 | {
|
---|
1380 | D3DHAL_GLOBALDRIVERDATA *pCaps = (D3DHAL_GLOBALDRIVERDATA *)pData->pData;
|
---|
1381 | memset (pCaps, 0, sizeof (D3DHAL_GLOBALDRIVERDATA));
|
---|
1382 | pCaps->dwSize = sizeof (D3DHAL_GLOBALDRIVERDATA);
|
---|
1383 | pCaps->hwCaps.dwSize = sizeof (D3DDEVICEDESC_V1);
|
---|
1384 | pCaps->hwCaps.dwFlags = D3DDD_COLORMODEL
|
---|
1385 | | D3DDD_DEVCAPS
|
---|
1386 | | D3DDD_DEVICERENDERBITDEPTH;
|
---|
1387 |
|
---|
1388 | pCaps->hwCaps.dcmColorModel = D3DCOLOR_RGB;
|
---|
1389 | pCaps->hwCaps.dwDevCaps = D3DDEVCAPS_CANRENDERAFTERFLIP
|
---|
1390 | // | D3DDEVCAPS_DRAWPRIMTLVERTEX
|
---|
1391 | | D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
---|
1392 | | D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
---|
1393 | // | D3DDEVCAPS_FLOATTLVERTEX
|
---|
1394 | | D3DDEVCAPS_HWRASTERIZATION
|
---|
1395 | // | D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
---|
1396 | // | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
---|
1397 | // | D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
---|
1398 | ;
|
---|
1399 | pCaps->hwCaps.dtcTransformCaps.dwSize = sizeof (D3DTRANSFORMCAPS);
|
---|
1400 | pCaps->hwCaps.dtcTransformCaps.dwCaps = 0;
|
---|
1401 | pCaps->hwCaps.bClipping = FALSE;
|
---|
1402 | pCaps->hwCaps.dlcLightingCaps.dwSize = sizeof (D3DLIGHTINGCAPS);
|
---|
1403 | pCaps->hwCaps.dlcLightingCaps.dwCaps = 0;
|
---|
1404 | pCaps->hwCaps.dlcLightingCaps.dwLightingModel = 0;
|
---|
1405 | pCaps->hwCaps.dlcLightingCaps.dwNumLights = 0;
|
---|
1406 | pCaps->hwCaps.dpcLineCaps.dwSize = sizeof (D3DPRIMCAPS);
|
---|
1407 | pCaps->hwCaps.dpcLineCaps.dwMiscCaps = 0;
|
---|
1408 | pCaps->hwCaps.dpcLineCaps.dwRasterCaps = 0;
|
---|
1409 | pCaps->hwCaps.dpcLineCaps.dwZCmpCaps = 0;
|
---|
1410 | pCaps->hwCaps.dpcLineCaps.dwSrcBlendCaps = 0;
|
---|
1411 | pCaps->hwCaps.dpcLineCaps.dwDestBlendCaps = 0;
|
---|
1412 | pCaps->hwCaps.dpcLineCaps.dwAlphaCmpCaps = 0;
|
---|
1413 | pCaps->hwCaps.dpcLineCaps.dwShadeCaps = 0;
|
---|
1414 | pCaps->hwCaps.dpcLineCaps.dwTextureCaps = 0;
|
---|
1415 | pCaps->hwCaps.dpcLineCaps.dwTextureFilterCaps = 0;
|
---|
1416 | pCaps->hwCaps.dpcLineCaps.dwTextureBlendCaps = 0;
|
---|
1417 | pCaps->hwCaps.dpcLineCaps.dwTextureAddressCaps = 0;
|
---|
1418 | pCaps->hwCaps.dpcLineCaps.dwStippleWidth = 0;
|
---|
1419 | pCaps->hwCaps.dpcLineCaps.dwStippleHeight = 0;
|
---|
1420 |
|
---|
1421 | pCaps->hwCaps.dpcTriCaps.dwSize = sizeof (D3DPRIMCAPS);
|
---|
1422 | pCaps->hwCaps.dpcTriCaps.dwMiscCaps = 0;
|
---|
1423 | pCaps->hwCaps.dpcTriCaps.dwRasterCaps = 0;
|
---|
1424 | pCaps->hwCaps.dpcTriCaps.dwZCmpCaps = 0;
|
---|
1425 | pCaps->hwCaps.dpcTriCaps.dwSrcBlendCaps = 0;
|
---|
1426 | pCaps->hwCaps.dpcTriCaps.dwDestBlendCaps = 0;
|
---|
1427 | pCaps->hwCaps.dpcTriCaps.dwAlphaCmpCaps = 0;
|
---|
1428 | pCaps->hwCaps.dpcTriCaps.dwShadeCaps = 0;
|
---|
1429 | pCaps->hwCaps.dpcTriCaps.dwTextureCaps = 0;
|
---|
1430 | pCaps->hwCaps.dpcTriCaps.dwTextureFilterCaps = 0;
|
---|
1431 | pCaps->hwCaps.dpcTriCaps.dwTextureBlendCaps = 0;
|
---|
1432 | pCaps->hwCaps.dpcTriCaps.dwTextureAddressCaps = 0;
|
---|
1433 | pCaps->hwCaps.dpcTriCaps.dwStippleWidth = 0;
|
---|
1434 | pCaps->hwCaps.dpcTriCaps.dwStippleHeight = 0;
|
---|
1435 | pCaps->hwCaps.dwDeviceRenderBitDepth = DDBD_8 | DDBD_16 | DDBD_24 | DDBD_32;
|
---|
1436 | pCaps->hwCaps.dwDeviceZBufferBitDepth = 0;
|
---|
1437 | pCaps->hwCaps.dwMaxBufferSize = 0;
|
---|
1438 | pCaps->hwCaps.dwMaxVertexCount = 0;
|
---|
1439 |
|
---|
1440 |
|
---|
1441 | pCaps->dwNumVertices = 0;
|
---|
1442 | pCaps->dwNumClipVertices = 0;
|
---|
1443 | pCaps->dwNumTextureFormats = 0;//pAdapter->cSurfDescs;
|
---|
1444 | pCaps->lpTextureFormats = NULL;//pAdapter->paSurfDescs;
|
---|
1445 | }
|
---|
1446 | else
|
---|
1447 | hr = E_INVALIDARG;
|
---|
1448 | break;
|
---|
1449 | case D3DDDICAPS_GETD3D7CAPS:
|
---|
1450 | Assert(!VBOXDISPMODE_IS_3D(pAdapter));
|
---|
1451 | Assert(pData->DataSize == sizeof (D3DHAL_D3DEXTENDEDCAPS));
|
---|
1452 | if (pData->DataSize >= sizeof (D3DHAL_D3DEXTENDEDCAPS))
|
---|
1453 | {
|
---|
1454 | memset(pData->pData, 0, sizeof (D3DHAL_D3DEXTENDEDCAPS));
|
---|
1455 | D3DHAL_D3DEXTENDEDCAPS *pCaps = (D3DHAL_D3DEXTENDEDCAPS*)pData->pData;
|
---|
1456 | pCaps->dwSize = sizeof (D3DHAL_D3DEXTENDEDCAPS);
|
---|
1457 | }
|
---|
1458 | else
|
---|
1459 | hr = E_INVALIDARG;
|
---|
1460 | break;
|
---|
1461 | case D3DDDICAPS_GETD3D9CAPS:
|
---|
1462 | {
|
---|
1463 | Assert(pData->DataSize >= sizeof (D3DCAPS9));
|
---|
1464 | // AssertBreakpoint();
|
---|
1465 | if (pData->DataSize >= sizeof (D3DCAPS9))
|
---|
1466 | {
|
---|
1467 | Assert(VBOXDISPMODE_IS_3D(pAdapter));
|
---|
1468 | if (VBOXDISPMODE_IS_3D(pAdapter))
|
---|
1469 | {
|
---|
1470 | D3DCAPS9* pCaps = (D3DCAPS9*)pData->pData;
|
---|
1471 | hr = pAdapter->pD3D9If->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pCaps);
|
---|
1472 | Assert(hr == S_OK);
|
---|
1473 | if (hr == S_OK)
|
---|
1474 | {
|
---|
1475 | pCaps->Caps2 |= D3DCAPS2_CANSHARERESOURCE | 0x00080000 /*D3DCAPS2_CANRENDERWINDOWED*/;
|
---|
1476 | pCaps->DevCaps |= D3DDEVCAPS_FLOATTLVERTEX /* <- must be set according to the docs */
|
---|
1477 | /*| D3DDEVCAPS_HWVERTEXBUFFER | D3DDEVCAPS_HWINDEXBUFFER | D3DDEVCAPS_SUBVOLUMELOCK */;
|
---|
1478 | pCaps->PrimitiveMiscCaps |= D3DPMISCCAPS_INDEPENDENTWRITEMASKS
|
---|
1479 | | D3DPMISCCAPS_FOGINFVF
|
---|
1480 | | D3DPMISCCAPS_SEPARATEALPHABLEND | D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS;
|
---|
1481 | pCaps->RasterCaps |= D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_COLORPERSPECTIVE /* keep */;
|
---|
1482 | pCaps->TextureCaps |= D3DPTEXTURECAPS_TRANSPARENCY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE;
|
---|
1483 | pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
|
---|
1484 | pCaps->VolumeTextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
|
---|
1485 | pCaps->GuardBandLeft = -8192.;
|
---|
1486 | pCaps->GuardBandTop = -8192.;
|
---|
1487 | pCaps->GuardBandRight = 8192.;
|
---|
1488 | pCaps->GuardBandBottom = 8192.;
|
---|
1489 | pCaps->StencilCaps |= D3DSTENCILCAPS_TWOSIDED;
|
---|
1490 | pCaps->DeclTypes |= D3DDTCAPS_FLOAT16_2 | D3DDTCAPS_FLOAT16_4;
|
---|
1491 | pCaps->VS20Caps.DynamicFlowControlDepth = 24;
|
---|
1492 | pCaps->VS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS;
|
---|
1493 | pCaps->PS20Caps.DynamicFlowControlDepth = 24;
|
---|
1494 | pCaps->PS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS;
|
---|
1495 | pCaps->VertexTextureFilterCaps |= D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MAGFPOINT;
|
---|
1496 | #if 1 /* workaround for wine not returning InstructionSlots correctly for shaders v3.0 */
|
---|
1497 | if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300)
|
---|
1498 | {
|
---|
1499 | pCaps->MaxVertexShader30InstructionSlots = RT_MIN(32768, pCaps->MaxVertexShader30InstructionSlots);
|
---|
1500 | pCaps->MaxPixelShader30InstructionSlots = RT_MIN(32768, pCaps->MaxPixelShader30InstructionSlots);
|
---|
1501 | }
|
---|
1502 | #endif
|
---|
1503 | #ifdef DEBUG
|
---|
1504 | if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300)
|
---|
1505 | {
|
---|
1506 | Assert(pCaps->MaxVertexShader30InstructionSlots >= 512);
|
---|
1507 | Assert(pCaps->MaxVertexShader30InstructionSlots <= 32768);
|
---|
1508 | Assert(pCaps->MaxPixelShader30InstructionSlots >= 512);
|
---|
1509 | Assert(pCaps->MaxPixelShader30InstructionSlots <= 32768);
|
---|
1510 | }
|
---|
1511 | else if ((pCaps->VertexShaderVersion & 0xff00) == 0x0200)
|
---|
1512 | {
|
---|
1513 | Assert(pCaps->MaxVertexShader30InstructionSlots == 0);
|
---|
1514 | Assert(pCaps->MaxPixelShader30InstructionSlots == 0);
|
---|
1515 | }
|
---|
1516 | else
|
---|
1517 | {
|
---|
1518 | AssertBreakpoint();
|
---|
1519 | }
|
---|
1520 | #endif
|
---|
1521 | break;
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | vboxVDbgPrintR((__FUNCTION__": GetDeviceCaps hr(%d)\n", hr));
|
---|
1525 | /* let's fall back to the 3D disabled case */
|
---|
1526 | hr = S_OK;
|
---|
1527 | }
|
---|
1528 |
|
---|
1529 | memset(pData->pData, 0, sizeof (D3DCAPS9));
|
---|
1530 | }
|
---|
1531 | else
|
---|
1532 | hr = E_INVALIDARG;
|
---|
1533 | break;
|
---|
1534 | }
|
---|
1535 | case D3DDDICAPS_GETGAMMARAMPCAPS:
|
---|
1536 | *((uint32_t*)pData->pData) = 0;
|
---|
1537 | break;
|
---|
1538 | case D3DDDICAPS_GETVIDEOPROCESSORCAPS:
|
---|
1539 | case D3DDDICAPS_GETEXTENSIONGUIDCOUNT:
|
---|
1540 | case D3DDDICAPS_GETDECODEGUIDCOUNT:
|
---|
1541 | case D3DDDICAPS_GETVIDEOPROCESSORDEVICEGUIDCOUNT:
|
---|
1542 | if (pData->pData && pData->DataSize)
|
---|
1543 | memset(pData->pData, 0, pData->DataSize);
|
---|
1544 | break;
|
---|
1545 | case D3DDDICAPS_GETMULTISAMPLEQUALITYLEVELS:
|
---|
1546 | case D3DDDICAPS_GETD3D5CAPS:
|
---|
1547 | case D3DDDICAPS_GETD3D6CAPS:
|
---|
1548 | case D3DDDICAPS_GETD3D8CAPS:
|
---|
1549 | case D3DDDICAPS_GETDECODEGUIDS:
|
---|
1550 | case D3DDDICAPS_GETDECODERTFORMATCOUNT:
|
---|
1551 | case D3DDDICAPS_GETDECODERTFORMATS:
|
---|
1552 | case D3DDDICAPS_GETDECODECOMPRESSEDBUFFERINFOCOUNT:
|
---|
1553 | case D3DDDICAPS_GETDECODECOMPRESSEDBUFFERINFO:
|
---|
1554 | case D3DDDICAPS_GETDECODECONFIGURATIONCOUNT:
|
---|
1555 | case D3DDDICAPS_GETDECODECONFIGURATIONS:
|
---|
1556 | case D3DDDICAPS_GETVIDEOPROCESSORDEVICEGUIDS:
|
---|
1557 | case D3DDDICAPS_GETVIDEOPROCESSORRTFORMATCOUNT:
|
---|
1558 | case D3DDDICAPS_GETVIDEOPROCESSORRTFORMATS:
|
---|
1559 | case D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATCOUNT:
|
---|
1560 | case D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATS:
|
---|
1561 | case D3DDDICAPS_GETPROCAMPRANGE:
|
---|
1562 | case D3DDDICAPS_FILTERPROPERTYRANGE:
|
---|
1563 | case D3DDDICAPS_GETEXTENSIONGUIDS:
|
---|
1564 | case D3DDDICAPS_GETEXTENSIONCAPS:
|
---|
1565 | vboxVDbgPrint((__FUNCTION__": unimplemented caps type(%d)\n", pData->Type));
|
---|
1566 | AssertBreakpoint();
|
---|
1567 | if (pData->pData && pData->DataSize)
|
---|
1568 | memset(pData->pData, 0, pData->DataSize);
|
---|
1569 | break;
|
---|
1570 | default:
|
---|
1571 | vboxVDbgPrint((__FUNCTION__": unknown caps type(%d)\n", pData->Type));
|
---|
1572 | AssertBreakpoint();
|
---|
1573 | }
|
---|
1574 |
|
---|
1575 | vboxVDbgPrint(("<== "__FUNCTION__", hAdapter(0x%p), caps type(%d)\n", hAdapter, pData->Type));
|
---|
1576 |
|
---|
1577 | return S_OK;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | static HRESULT APIENTRY vboxWddmDDevSetRenderState(HANDLE hDevice, CONST D3DDDIARG_RENDERSTATE* pData)
|
---|
1581 | {
|
---|
1582 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1583 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1584 | Assert(pDevice);
|
---|
1585 | Assert(pDevice->pDevice9If);
|
---|
1586 | HRESULT hr = pDevice->pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value);
|
---|
1587 | Assert(hr == S_OK);
|
---|
1588 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1589 | return hr;
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | static HRESULT APIENTRY vboxWddmDDevUpdateWInfo(HANDLE hDevice, CONST D3DDDIARG_WINFO* pData)
|
---|
1593 | {
|
---|
1594 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1595 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1596 | return S_OK;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | static HRESULT APIENTRY vboxWddmDDevValidateDevice(HANDLE hDevice, D3DDDIARG_VALIDATETEXTURESTAGESTATE* pData)
|
---|
1600 | {
|
---|
1601 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1602 | AssertBreakpoint();
|
---|
1603 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1604 | return E_FAIL;
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 | static HRESULT APIENTRY vboxWddmDDevSetTextureStageState(HANDLE hDevice, CONST D3DDDIARG_TEXTURESTAGESTATE* pData)
|
---|
1608 | {
|
---|
1609 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1610 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1611 | Assert(pDevice);
|
---|
1612 | Assert(pDevice->pDevice9If);
|
---|
1613 |
|
---|
1614 | VBOXWDDMDISP_TSS_LOOKUP lookup = vboxDDI2D3DTestureStageStateType(pData->State);
|
---|
1615 | HRESULT hr;
|
---|
1616 |
|
---|
1617 | if (!lookup.bSamplerState)
|
---|
1618 | {
|
---|
1619 | hr = pDevice->pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);
|
---|
1620 | }
|
---|
1621 | else
|
---|
1622 | {
|
---|
1623 | hr = pDevice->pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value);
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | Assert(hr == S_OK);
|
---|
1627 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1628 | return hr;
|
---|
1629 | }
|
---|
1630 |
|
---|
1631 | static HRESULT APIENTRY vboxWddmDDevSetTexture(HANDLE hDevice, UINT Stage, HANDLE hTexture)
|
---|
1632 | {
|
---|
1633 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1634 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1635 | Assert(pDevice);
|
---|
1636 | Assert(pDevice->pDevice9If);
|
---|
1637 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hTexture;
|
---|
1638 | // Assert(pRc);
|
---|
1639 | IDirect3DTexture9 *pD3DIfTex;
|
---|
1640 | if (pRc)
|
---|
1641 | {
|
---|
1642 | Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE);
|
---|
1643 | pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;
|
---|
1644 | }
|
---|
1645 | else
|
---|
1646 | pD3DIfTex = NULL;
|
---|
1647 |
|
---|
1648 | // Assert(pD3DIfTex);
|
---|
1649 | HRESULT hr = pDevice->pDevice9If->SetTexture(Stage, pD3DIfTex);
|
---|
1650 | Assert(hr == S_OK);
|
---|
1651 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1652 | return hr;
|
---|
1653 | }
|
---|
1654 |
|
---|
1655 | static HRESULT APIENTRY vboxWddmDDevSetPixelShader(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
1656 | {
|
---|
1657 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1658 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1659 | Assert(pDevice);
|
---|
1660 | Assert(pDevice->pDevice9If);
|
---|
1661 | IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle;
|
---|
1662 | Assert(pShader);
|
---|
1663 | HRESULT hr = pDevice->pDevice9If->SetPixelShader(pShader);
|
---|
1664 | Assert(hr == S_OK);
|
---|
1665 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1666 | return hr;
|
---|
1667 | }
|
---|
1668 |
|
---|
1669 | static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONST* pData, CONST FLOAT* pRegisters)
|
---|
1670 | {
|
---|
1671 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1672 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1673 | Assert(pDevice);
|
---|
1674 | Assert(pDevice->pDevice9If);
|
---|
1675 | HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count);
|
---|
1676 | Assert(hr == S_OK);
|
---|
1677 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1678 | return hr;
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 | static HRESULT APIENTRY vboxWddmDDevSetStreamSourceUm(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEUM* pData, CONST VOID* pUMBuffer )
|
---|
1682 | {
|
---|
1683 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1684 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1685 | Assert(pDevice);
|
---|
1686 | Assert(pDevice->pDevice9If);
|
---|
1687 | HRESULT hr = S_OK;
|
---|
1688 | // IDirect3DVertexBuffer9 *pStreamData;
|
---|
1689 | // UINT cbOffset;
|
---|
1690 | // UINT cbStride;
|
---|
1691 | // hr = pDevice->pDevice9If->GetStreamSource(pData->Stream, &pStreamData, &cbOffset, &cbStride);
|
---|
1692 | // Assert(hr == S_OK);
|
---|
1693 | // if (hr == S_OK)
|
---|
1694 | // {
|
---|
1695 | // if (pStreamData)
|
---|
1696 | // {
|
---|
1697 | // AssertBreakpoint();
|
---|
1698 | // /* @todo: impl! */
|
---|
1699 | // }
|
---|
1700 | // else
|
---|
1701 | // {
|
---|
1702 | Assert(pData->Stream < RT_ELEMENTS(pDevice->aStreamSourceUm));
|
---|
1703 | PVBOXWDDMDISP_STREAMSOURCEUM pStrSrcUm = &pDevice->aStreamSourceUm[pData->Stream];
|
---|
1704 | pStrSrcUm->pvBuffer = pUMBuffer;
|
---|
1705 | pStrSrcUm->cbStride = pData->Stride;
|
---|
1706 | // }
|
---|
1707 | // }
|
---|
1708 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1709 | return hr;
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | static HRESULT APIENTRY vboxWddmDDevSetIndices(HANDLE hDevice, CONST D3DDDIARG_SETINDICES* pData)
|
---|
1713 | {
|
---|
1714 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1715 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1716 | Assert(pDevice);
|
---|
1717 | Assert(pDevice->pDevice9If);
|
---|
1718 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hIndexBuffer;
|
---|
1719 | PVBOXWDDMDISP_ALLOCATION pAlloc = NULL;
|
---|
1720 | IDirect3DIndexBuffer9 *pIndexBuffer = NULL;
|
---|
1721 | if (pRc)
|
---|
1722 | {
|
---|
1723 | Assert(pRc->cAllocations == 1);
|
---|
1724 | pAlloc = &pRc->aAllocations[0];
|
---|
1725 | Assert(pAlloc->pD3DIf);
|
---|
1726 | pIndexBuffer = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf;
|
---|
1727 | }
|
---|
1728 | HRESULT hr = pDevice->pDevice9If->SetIndices(pIndexBuffer);
|
---|
1729 | Assert(hr == S_OK);
|
---|
1730 | if (hr == S_OK)
|
---|
1731 | {
|
---|
1732 | pDevice->pIndicesAlloc = pAlloc;
|
---|
1733 | pDevice->IndiciesInfo.uiStride = pData->Stride;
|
---|
1734 | }
|
---|
1735 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1736 | return hr;
|
---|
1737 | }
|
---|
1738 |
|
---|
1739 | static HRESULT APIENTRY vboxWddmDDevSetIndicesUm(HANDLE hDevice, UINT IndexSize, CONST VOID* pUMBuffer)
|
---|
1740 | {
|
---|
1741 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1742 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1743 | Assert(pDevice);
|
---|
1744 | Assert(pDevice->pDevice9If);
|
---|
1745 | HRESULT hr = S_OK;
|
---|
1746 | pDevice->IndiciesUm.pvBuffer = pUMBuffer;
|
---|
1747 | pDevice->IndiciesUm.cbSize = IndexSize;
|
---|
1748 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1749 | return hr;
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 | static HRESULT APIENTRY vboxWddmDDevDrawPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE* pData, CONST UINT* pFlagBuffer)
|
---|
1753 | {
|
---|
1754 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
1755 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
1756 | Assert(pDevice);
|
---|
1757 | Assert(pDevice->pDevice9If);
|
---|
1758 | Assert(!pFlagBuffer);
|
---|
1759 | HRESULT hr = S_OK;
|
---|
1760 |
|
---|
1761 | if (!pDevice->cStreamSources)
|
---|
1762 | {
|
---|
1763 | if (pDevice->aStreamSourceUm[0].pvBuffer)
|
---|
1764 | {
|
---|
1765 | #ifdef DEBUG
|
---|
1766 | for (UINT i = 1; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
|
---|
1767 | {
|
---|
1768 | Assert(!pDevice->aStreamSourceUm[i].pvBuffer);
|
---|
1769 | }
|
---|
1770 | #endif
|
---|
1771 | hr = pDevice->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType,
|
---|
1772 | pData->PrimitiveCount,
|
---|
1773 | ((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride,
|
---|
1774 | pDevice->aStreamSourceUm[0].cbStride);
|
---|
1775 | Assert(hr == S_OK);
|
---|
1776 | }
|
---|
1777 | else
|
---|
1778 | {
|
---|
1779 | /* todo: impl */
|
---|
1780 | AssertBreakpoint();
|
---|
1781 | }
|
---|
1782 | }
|
---|
1783 | else
|
---|
1784 | {
|
---|
1785 | hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType,
|
---|
1786 | pData->VStart,
|
---|
1787 | pData->PrimitiveCount);
|
---|
1788 | Assert(hr == S_OK);
|
---|
1789 | #if 0
|
---|
1790 | IDirect3DVertexDeclaration9* pDecl;
|
---|
1791 | hr = pDevice->pDevice9If->GetVertexDeclaration(&pDecl);
|
---|
1792 | Assert(hr == S_OK);
|
---|
1793 | if (hr == S_OK)
|
---|
1794 | {
|
---|
1795 | Assert(pDecl);
|
---|
1796 | D3DVERTEXELEMENT9 aDecls9[MAXD3DDECLLENGTH];
|
---|
1797 | UINT cDecls9 = 0;
|
---|
1798 | hr = pDecl->GetDeclaration(aDecls9, &cDecls9);
|
---|
1799 | Assert(hr == S_OK);
|
---|
1800 | if (hr == S_OK)
|
---|
1801 | {
|
---|
1802 | Assert(cDecls9);
|
---|
1803 | for (UINT i = 0; i < cDecls9 - 1 /* the last one is D3DDECL_END */; ++i)
|
---|
1804 | {
|
---|
1805 | D3DVERTEXELEMENT9 *pDecl9 = &aDecls9[i];
|
---|
1806 | Assert(pDecl9->Stream < RT_ELEMENTS(pDevice->aStreamSourceUm) || pDecl9->Stream == 0xff);
|
---|
1807 | if (pDecl9->Stream != 0xff)
|
---|
1808 | {
|
---|
1809 | PVBOXWDDMDISP_STREAMSOURCEUM pStrSrc = &pDevice->aStreamSourceUm[pDecl9->Stream];
|
---|
1810 | if (pStrSrc->pvBuffer)
|
---|
1811 | {
|
---|
1812 | WORD iStream = pDecl9->Stream;
|
---|
1813 | D3DVERTEXELEMENT9 *pLastCDecl9 = pDecl9;
|
---|
1814 | for (UINT j = i+1; j < cDecls9 - 1 /* the last one is D3DDECL_END */; ++j)
|
---|
1815 | {
|
---|
1816 | pDecl9 = &aDecls9[j];
|
---|
1817 | if (iStream == pDecl9->Stream)
|
---|
1818 | {
|
---|
1819 | pDecl9->Stream = 0xff; /* mark as done */
|
---|
1820 | Assert(pDecl9->Offset != pLastCDecl9->Offset);
|
---|
1821 | if (pDecl9->Offset > pLastCDecl9->Offset)
|
---|
1822 | pLastCDecl9 = pDecl9;
|
---|
1823 | }
|
---|
1824 | }
|
---|
1825 | /* vertex size is MAX(all Offset's) + sizeof (data_type with MAX offset) + stride*/
|
---|
1826 | UINT cbVertex = pLastCDecl9->Offset + pStrSrc->cbStride;
|
---|
1827 | UINT cbType;
|
---|
1828 | switch (pLastCDecl9->Type)
|
---|
1829 | {
|
---|
1830 | case D3DDECLTYPE_FLOAT1:
|
---|
1831 | cbType = sizeof (float);
|
---|
1832 | break;
|
---|
1833 | case D3DDECLTYPE_FLOAT2:
|
---|
1834 | cbType = sizeof (float) * 2;
|
---|
1835 | break;
|
---|
1836 | case D3DDECLTYPE_FLOAT3:
|
---|
1837 | cbType = sizeof (float) * 3;
|
---|
1838 | break;
|
---|
1839 | case D3DDECLTYPE_FLOAT4:
|
---|
1840 | cbType = sizeof (float) * 4;
|
---|
1841 | break;
|
---|
1842 | case D3DDECLTYPE_D3DCOLOR:
|
---|
1843 | cbType = 4;
|
---|
1844 | break;
|
---|
1845 | case D3DDECLTYPE_UBYTE4:
|
---|
1846 | cbType = 4;
|
---|
1847 | break;
|
---|
1848 | case D3DDECLTYPE_SHORT2:
|
---|
1849 | cbType = sizeof (short) * 2;
|
---|
1850 | break;
|
---|
1851 | case D3DDECLTYPE_SHORT4:
|
---|
1852 | cbType = sizeof (short) * 4;
|
---|
1853 | break;
|
---|
1854 | case D3DDECLTYPE_UBYTE4N:
|
---|
1855 | cbType = 4;
|
---|
1856 | break;
|
---|
1857 | case D3DDECLTYPE_SHORT2N:
|
---|
1858 | cbType = sizeof (short) * 2;
|
---|
1859 | break;
|
---|
1860 | case D3DDECLTYPE_SHORT4N:
|
---|
1861 | cbType = sizeof (short) * 4;
|
---|
1862 | break;
|
---|
1863 | case D3DDECLTYPE_USHORT2N:
|
---|
1864 | cbType = sizeof (short) * 2;
|
---|
1865 | break;
|
---|
1866 | case D3DDECLTYPE_USHORT4N:
|
---|
1867 | cbType = sizeof (short) * 4;
|
---|
1868 | break;
|
---|
1869 | case D3DDECLTYPE_UDEC3:
|
---|
1870 | cbType = sizeof (signed) * 3;
|
---|
1871 | break;
|
---|
1872 | case D3DDECLTYPE_DEC3N:
|
---|
1873 | cbType = sizeof (unsigned) * 3;
|
---|
1874 | break;
|
---|
1875 | case D3DDECLTYPE_FLOAT16_2:
|
---|
1876 | cbType = 2 * 2;
|
---|
1877 | break;
|
---|
1878 | case D3DDECLTYPE_FLOAT16_4:
|
---|
1879 | cbType = 2 * 4;
|
---|
1880 | break;
|
---|
1881 | default:
|
---|
1882 | AssertBreakpoint();
|
---|
1883 | cbType = 1;
|
---|
1884 | }
|
---|
1885 | cbVertex += cbType;
|
---|
1886 |
|
---|
1887 | UINT cVertexes;
|
---|
1888 | switch (pData->PrimitiveType)
|
---|
1889 | {
|
---|
1890 | case D3DPT_POINTLIST:
|
---|
1891 | cVertexes = pData->PrimitiveCount;
|
---|
1892 | break;
|
---|
1893 | case D3DPT_LINELIST:
|
---|
1894 | cVertexes = pData->PrimitiveCount * 2;
|
---|
1895 | break;
|
---|
1896 | case D3DPT_LINESTRIP:
|
---|
1897 | cVertexes = pData->PrimitiveCount + 1;
|
---|
1898 | break;
|
---|
1899 | case D3DPT_TRIANGLELIST:
|
---|
1900 | cVertexes = pData->PrimitiveCount * 3;
|
---|
1901 | break;
|
---|
1902 | case D3DPT_TRIANGLESTRIP:
|
---|
1903 | cVertexes = pData->PrimitiveCount + 2;
|
---|
1904 | break;
|
---|
1905 | case D3DPT_TRIANGLEFAN:
|
---|
1906 | cVertexes = pData->PrimitiveCount + 2;
|
---|
1907 | break;
|
---|
1908 | default:
|
---|
1909 | AssertBreakpoint();
|
---|
1910 | cVertexes = pData->PrimitiveCount;
|
---|
1911 | }
|
---|
1912 | UINT cbVertexes = cVertexes * cbVertex;
|
---|
1913 | IDirect3DVertexBuffer9 *pCurVb = NULL, *pVb = NULL;
|
---|
1914 | UINT cbOffset;
|
---|
1915 | UINT cbStride;
|
---|
1916 | hr = pDevice->pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride);
|
---|
1917 | Assert(hr == S_OK);
|
---|
1918 | if (hr == S_OK)
|
---|
1919 | {
|
---|
1920 | if (pCurVb)
|
---|
1921 | {
|
---|
1922 | if (cbStride == pStrSrc->cbStride)
|
---|
1923 | {
|
---|
1924 | /* ensure our data feets in the buffer */
|
---|
1925 | D3DVERTEXBUFFER_DESC Desc;
|
---|
1926 | hr = pCurVb->GetDesc(&Desc);
|
---|
1927 | Assert(hr == S_OK);
|
---|
1928 | if (hr == S_OK)
|
---|
1929 | {
|
---|
1930 | if (Desc.Size >= cbVertexes)
|
---|
1931 | pVb = pCurVb;
|
---|
1932 | }
|
---|
1933 | }
|
---|
1934 | }
|
---|
1935 | }
|
---|
1936 | else
|
---|
1937 | {
|
---|
1938 | pCurVb = NULL;
|
---|
1939 | }
|
---|
1940 |
|
---|
1941 | if (!pVb)
|
---|
1942 | {
|
---|
1943 | hr = pDevice->pDevice9If->CreateVertexBuffer(cbVertexes,
|
---|
1944 | 0, /* DWORD Usage */
|
---|
1945 | 0, /* DWORD FVF */
|
---|
1946 | D3DPOOL_DEFAULT, /* D3DPOOL Pool */
|
---|
1947 | &pVb,
|
---|
1948 | NULL /*HANDLE* pSharedHandle*/);
|
---|
1949 | Assert(hr == S_OK);
|
---|
1950 | if (hr == S_OK)
|
---|
1951 | {
|
---|
1952 | hr = pDevice->pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride);
|
---|
1953 | Assert(hr == S_OK);
|
---|
1954 | if (hr == S_OK)
|
---|
1955 | {
|
---|
1956 | if (pCurVb)
|
---|
1957 | pCurVb->Release();
|
---|
1958 | }
|
---|
1959 | else
|
---|
1960 | {
|
---|
1961 | pVb->Release();
|
---|
1962 | pVb = NULL;
|
---|
1963 | }
|
---|
1964 | }
|
---|
1965 | }
|
---|
1966 |
|
---|
1967 | if (pVb)
|
---|
1968 | {
|
---|
1969 | Assert(hr == S_OK);
|
---|
1970 | VOID *pvData;
|
---|
1971 | hr = pVb->Lock(0, /* UINT OffsetToLock */
|
---|
1972 | cbVertexes,
|
---|
1973 | &pvData,
|
---|
1974 | D3DLOCK_DISCARD);
|
---|
1975 | Assert(hr == S_OK);
|
---|
1976 | if (hr == S_OK)
|
---|
1977 | {
|
---|
1978 | memcpy (pvData, ((uint8_t*)pStrSrc->pvBuffer) + pData->VStart * cbVertex, cbVertexes);
|
---|
1979 | HRESULT tmpHr = pVb->Unlock();
|
---|
1980 | Assert(tmpHr == S_OK);
|
---|
1981 | }
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 | }
|
---|
1985 | }
|
---|
1986 | }
|
---|
1987 | if (hr == S_OK)
|
---|
1988 | {
|
---|
1989 | hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType,
|
---|
1990 | 0 /* <- since we use our owne StreamSource buffer which has data at the very beginning*/,
|
---|
1991 | pData->PrimitiveCount);
|
---|
1992 | Assert(hr == S_OK);
|
---|
1993 | }
|
---|
1994 | }
|
---|
1995 | #endif
|
---|
1996 | }
|
---|
1997 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
1998 | return hr;
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 | static HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE* pData)
|
---|
2002 | {
|
---|
2003 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2004 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2005 | Assert(pDevice);
|
---|
2006 | Assert(pDevice->pDevice9If);
|
---|
2007 | HRESULT hr = pDevice->pDevice9If->DrawIndexedPrimitive(
|
---|
2008 | pData->PrimitiveType,
|
---|
2009 | pData->BaseVertexIndex,
|
---|
2010 | pData->MinIndex,
|
---|
2011 | pData->NumVertices,
|
---|
2012 | pData->StartIndex,
|
---|
2013 | pData->PrimitiveCount);
|
---|
2014 | Assert(hr == S_OK);
|
---|
2015 |
|
---|
2016 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2017 | return hr;
|
---|
2018 | }
|
---|
2019 |
|
---|
2020 | static HRESULT APIENTRY vboxWddmDDevDrawRectPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWRECTPATCH* pData, CONST D3DDDIRECTPATCH_INFO* pInfo, CONST FLOAT* pPatch)
|
---|
2021 | {
|
---|
2022 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2023 | AssertBreakpoint();
|
---|
2024 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2025 | return E_FAIL;
|
---|
2026 | }
|
---|
2027 |
|
---|
2028 | static HRESULT APIENTRY vboxWddmDDevDrawTriPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWTRIPATCH* pData, CONST D3DDDITRIPATCH_INFO* pInfo, CONST FLOAT* pPatch)
|
---|
2029 | {
|
---|
2030 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2031 | AssertBreakpoint();
|
---|
2032 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2033 | return E_FAIL;
|
---|
2034 | }
|
---|
2035 |
|
---|
2036 | static HRESULT APIENTRY vboxWddmDDevDrawPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE2* pData)
|
---|
2037 | {
|
---|
2038 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2039 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2040 | Assert(pDevice);
|
---|
2041 | Assert(pDevice->pDevice9If);
|
---|
2042 | HRESULT hr;
|
---|
2043 |
|
---|
2044 | #if 0
|
---|
2045 | int stream;
|
---|
2046 | for (stream=0; stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS; ++stream)
|
---|
2047 | {
|
---|
2048 | if (pDevice->aStreamSource[stream] && pDevice->aStreamSource[stream]->LockInfo.cLocks)
|
---|
2049 | {
|
---|
2050 | VBOXWDDMDISP_LOCKINFO *pLock = &pDevice->aStreamSource[stream]->LockInfo;
|
---|
2051 | if (pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite))
|
---|
2052 | {
|
---|
2053 | IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf;
|
---|
2054 | Assert(pLock->fFlags.RangeValid);
|
---|
2055 | pD3D9VBuf->Lock(pLock->Range.Offset, pLock->Range.Size,
|
---|
2056 | &pLock->LockedRect.pBits,
|
---|
2057 | vboxDDI2D3DLockFlags(pLock->fFlags));
|
---|
2058 | RECT r;
|
---|
2059 | r.top = 0;
|
---|
2060 | r.left = pLock->Range.Offset;
|
---|
2061 | r.bottom = 1;
|
---|
2062 | r.right = pLock->Range.Offset + pLock->Range.Size;
|
---|
2063 |
|
---|
2064 | vboxWddmLockUnlockMemSynch(pDevice->aStreamSource[stream], &pLock->LockedRect, &r, true /*bool bToLockInfo*/);
|
---|
2065 |
|
---|
2066 | pD3D9VBuf->Unlock();
|
---|
2067 | }
|
---|
2068 | }
|
---|
2069 | }
|
---|
2070 |
|
---|
2071 | hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);
|
---|
2072 | #else
|
---|
2073 | int stream;
|
---|
2074 | for (stream=0; stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS; ++stream)
|
---|
2075 | {
|
---|
2076 | if (pDevice->aStreamSource[stream])
|
---|
2077 | {
|
---|
2078 | Assert(stream==0); /*only stream 0 should be accessed here*/
|
---|
2079 | Assert(pDevice->StreamSourceInfo[stream].uiStride!=0);
|
---|
2080 | VBOXWDDMDISP_LOCKINFO *pLock = &pDevice->aStreamSource[stream]->LockInfo;
|
---|
2081 |
|
---|
2082 | if (pDevice->aStreamSource[stream]->LockInfo.cLocks)
|
---|
2083 | {
|
---|
2084 | Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite));
|
---|
2085 | hr = pDevice->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount,
|
---|
2086 | (void*)((uintptr_t)pDevice->aStreamSource[stream]->pvMem+pDevice->StreamSourceInfo[stream].uiOffset+pData->FirstVertexOffset),
|
---|
2087 | pDevice->StreamSourceInfo[stream].uiStride);
|
---|
2088 | Assert(hr == S_OK);
|
---|
2089 | hr = pDevice->pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);
|
---|
2090 | }
|
---|
2091 | else
|
---|
2092 | {
|
---|
2093 | hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
|
---|
2094 | }
|
---|
2095 | }
|
---|
2096 | }
|
---|
2097 | #endif
|
---|
2098 |
|
---|
2099 | Assert(hr == S_OK);
|
---|
2100 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2101 | return hr;
|
---|
2102 | }
|
---|
2103 |
|
---|
2104 | static HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE2* pData, UINT dwIndicesSize, CONST VOID* pIndexBuffer, CONST UINT* pFlagBuffer)
|
---|
2105 | {
|
---|
2106 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2107 | AssertBreakpoint();
|
---|
2108 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2109 | return E_FAIL;
|
---|
2110 | }
|
---|
2111 |
|
---|
2112 | static HRESULT APIENTRY vboxWddmDDevVolBlt(HANDLE hDevice, CONST D3DDDIARG_VOLUMEBLT* pData)
|
---|
2113 | {
|
---|
2114 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2115 | AssertBreakpoint();
|
---|
2116 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2117 | return E_FAIL;
|
---|
2118 | }
|
---|
2119 |
|
---|
2120 | static HRESULT APIENTRY vboxWddmDDevBufBlt(HANDLE hDevice, CONST D3DDDIARG_BUFFERBLT* pData)
|
---|
2121 | {
|
---|
2122 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2123 | AssertBreakpoint();
|
---|
2124 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2125 | return E_FAIL;
|
---|
2126 | }
|
---|
2127 |
|
---|
2128 | static HRESULT APIENTRY vboxWddmDDevTexBlt(HANDLE hDevice, CONST D3DDDIARG_TEXBLT* pData)
|
---|
2129 | {
|
---|
2130 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2131 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2132 | Assert(pDevice);
|
---|
2133 | Assert(pDevice->pDevice9If);
|
---|
2134 | PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
|
---|
2135 | PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
|
---|
2136 | IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcRc->aAllocations[0].pD3DIf;
|
---|
2137 | IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstRc->aAllocations[0].pD3DIf;
|
---|
2138 | Assert(pD3DIfSrcTex);
|
---|
2139 | Assert(pD3DIfDstTex);
|
---|
2140 | HRESULT hr = S_OK;
|
---|
2141 |
|
---|
2142 | if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width
|
---|
2143 | && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height
|
---|
2144 | && pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat)
|
---|
2145 | {
|
---|
2146 | /* first check if we can do IDirect3DDevice9::UpdateTexture */
|
---|
2147 | if (pData->DstPoint.x == 0 && pData->DstPoint.y == 0
|
---|
2148 | && pData->SrcRect.left == 0 && pData->SrcRect.top == 0
|
---|
2149 | && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width
|
---|
2150 | && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height)
|
---|
2151 | {
|
---|
2152 | hr = pDevice->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);
|
---|
2153 | Assert(hr == S_OK);
|
---|
2154 | }
|
---|
2155 | else
|
---|
2156 | {
|
---|
2157 | AssertBreakpoint();
|
---|
2158 | /* @todo: impl */
|
---|
2159 | }
|
---|
2160 | }
|
---|
2161 | else
|
---|
2162 | {
|
---|
2163 | AssertBreakpoint();
|
---|
2164 | /* @todo: impl */
|
---|
2165 | }
|
---|
2166 |
|
---|
2167 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2168 | return hr;
|
---|
2169 | }
|
---|
2170 |
|
---|
2171 | static HRESULT APIENTRY vboxWddmDDevStateSet(HANDLE hDevice, D3DDDIARG_STATESET* pData)
|
---|
2172 | {
|
---|
2173 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2174 | AssertBreakpoint();
|
---|
2175 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2176 | return E_FAIL;
|
---|
2177 | }
|
---|
2178 | static HRESULT APIENTRY vboxWddmDDevSetPriority(HANDLE hDevice, CONST D3DDDIARG_SETPRIORITY* pData)
|
---|
2179 | {
|
---|
2180 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2181 | AssertBreakpoint();
|
---|
2182 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2183 | return E_FAIL;
|
---|
2184 | }
|
---|
2185 | AssertCompile(sizeof (RECT) == sizeof (D3DRECT));
|
---|
2186 | AssertCompile(RT_SIZEOFMEMB(RECT, left) == RT_SIZEOFMEMB(D3DRECT, x1));
|
---|
2187 | AssertCompile(RT_SIZEOFMEMB(RECT, right) == RT_SIZEOFMEMB(D3DRECT, x2));
|
---|
2188 | AssertCompile(RT_SIZEOFMEMB(RECT, top) == RT_SIZEOFMEMB(D3DRECT, y1));
|
---|
2189 | AssertCompile(RT_SIZEOFMEMB(RECT, bottom) == RT_SIZEOFMEMB(D3DRECT, y2));
|
---|
2190 | AssertCompile(RT_OFFSETOF(RECT, left) == RT_OFFSETOF(D3DRECT, x1));
|
---|
2191 | AssertCompile(RT_OFFSETOF(RECT, right) == RT_OFFSETOF(D3DRECT, x2));
|
---|
2192 | AssertCompile(RT_OFFSETOF(RECT, top) == RT_OFFSETOF(D3DRECT, y1));
|
---|
2193 | AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(D3DRECT, y2));
|
---|
2194 |
|
---|
2195 | static HRESULT APIENTRY vboxWddmDDevClear(HANDLE hDevice, CONST D3DDDIARG_CLEAR* pData, UINT NumRect, CONST RECT* pRect)
|
---|
2196 | {
|
---|
2197 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2198 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2199 | Assert(pDevice);
|
---|
2200 | Assert(pDevice->pDevice9If);
|
---|
2201 | HRESULT hr = pDevice->pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */,
|
---|
2202 | pData->Flags,
|
---|
2203 | pData->FillColor,
|
---|
2204 | pData->FillDepth,
|
---|
2205 | pData->FillStencil);
|
---|
2206 | Assert(hr == S_OK);
|
---|
2207 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2208 | return hr;
|
---|
2209 | }
|
---|
2210 | static HRESULT APIENTRY vboxWddmDDevUpdatePalette(HANDLE hDevice, CONST D3DDDIARG_UPDATEPALETTE* pData, CONST PALETTEENTRY* pPaletteData)
|
---|
2211 | {
|
---|
2212 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2213 | AssertBreakpoint();
|
---|
2214 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2215 | return E_FAIL;
|
---|
2216 | }
|
---|
2217 |
|
---|
2218 | static HRESULT APIENTRY vboxWddmDDevSetPalette(HANDLE hDevice, CONST D3DDDIARG_SETPALETTE* pData)
|
---|
2219 | {
|
---|
2220 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2221 | AssertBreakpoint();
|
---|
2222 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2223 | return E_FAIL;
|
---|
2224 | }
|
---|
2225 |
|
---|
2226 | static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONST* pData , CONST VOID* pRegisters)
|
---|
2227 | {
|
---|
2228 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2229 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2230 | Assert(pDevice);
|
---|
2231 | Assert(pDevice->pDevice9If);
|
---|
2232 | HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantF(
|
---|
2233 | pData->Register,
|
---|
2234 | (CONST float*)pRegisters,
|
---|
2235 | pData->Count);
|
---|
2236 | Assert(hr == S_OK);
|
---|
2237 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2238 | return hr;
|
---|
2239 | }
|
---|
2240 | static HRESULT APIENTRY vboxWddmDDevMultiplyTransform(HANDLE hDevice, CONST D3DDDIARG_MULTIPLYTRANSFORM* pData)
|
---|
2241 | {
|
---|
2242 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2243 | AssertBreakpoint();
|
---|
2244 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2245 | return E_FAIL;
|
---|
2246 | }
|
---|
2247 | static HRESULT APIENTRY vboxWddmDDevSetTransform(HANDLE hDevice, CONST D3DDDIARG_SETTRANSFORM* pData)
|
---|
2248 | {
|
---|
2249 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2250 | AssertBreakpoint();
|
---|
2251 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2252 | return E_FAIL;
|
---|
2253 | }
|
---|
2254 | static HRESULT APIENTRY vboxWddmDDevSetViewport(HANDLE hDevice, CONST D3DDDIARG_VIEWPORTINFO* pData)
|
---|
2255 | {
|
---|
2256 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2257 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2258 | Assert(pDevice);
|
---|
2259 | Assert(pDevice->pDevice9If);
|
---|
2260 | pDevice->ViewPort.X = pData->X;
|
---|
2261 | pDevice->ViewPort.Y = pData->Y;
|
---|
2262 | pDevice->ViewPort.Width = pData->Width;
|
---|
2263 | pDevice->ViewPort.Height = pData->Height;
|
---|
2264 | HRESULT hr = pDevice->pDevice9If->SetViewport(&pDevice->ViewPort);
|
---|
2265 | Assert(hr == S_OK);
|
---|
2266 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2267 | return hr;
|
---|
2268 | }
|
---|
2269 | static HRESULT APIENTRY vboxWddmDDevSetZRange(HANDLE hDevice, CONST D3DDDIARG_ZRANGE* pData)
|
---|
2270 | {
|
---|
2271 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2272 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2273 | Assert(pDevice);
|
---|
2274 | Assert(pDevice->pDevice9If);
|
---|
2275 | pDevice->ViewPort.MinZ = pData->MinZ;
|
---|
2276 | pDevice->ViewPort.MaxZ = pData->MaxZ;
|
---|
2277 | HRESULT hr = pDevice->pDevice9If->SetViewport(&pDevice->ViewPort);
|
---|
2278 | Assert(hr == S_OK);
|
---|
2279 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2280 | return hr;
|
---|
2281 | }
|
---|
2282 | static HRESULT APIENTRY vboxWddmDDevSetMaterial(HANDLE hDevice, CONST D3DDDIARG_SETMATERIAL* pData)
|
---|
2283 | {
|
---|
2284 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2285 | AssertBreakpoint();
|
---|
2286 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2287 | return E_FAIL;
|
---|
2288 | }
|
---|
2289 | static HRESULT APIENTRY vboxWddmDDevSetLight(HANDLE hDevice, CONST D3DDDIARG_SETLIGHT* pData, CONST D3DDDI_LIGHT* pLightProperties)
|
---|
2290 | {
|
---|
2291 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2292 | AssertBreakpoint();
|
---|
2293 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2294 | return E_FAIL;
|
---|
2295 | }
|
---|
2296 | static HRESULT APIENTRY vboxWddmDDevCreateLight(HANDLE hDevice, CONST D3DDDIARG_CREATELIGHT* pData)
|
---|
2297 | {
|
---|
2298 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2299 | AssertBreakpoint();
|
---|
2300 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2301 | return E_FAIL;
|
---|
2302 | }
|
---|
2303 | static HRESULT APIENTRY vboxWddmDDevDestroyLight(HANDLE hDevice, CONST D3DDDIARG_DESTROYLIGHT* pData)
|
---|
2304 | {
|
---|
2305 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2306 | AssertBreakpoint();
|
---|
2307 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2308 | return E_FAIL;
|
---|
2309 | }
|
---|
2310 | static HRESULT APIENTRY vboxWddmDDevSetClipPlane(HANDLE hDevice, CONST D3DDDIARG_SETCLIPPLANE* pData)
|
---|
2311 | {
|
---|
2312 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2313 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2314 | Assert(pDevice);
|
---|
2315 | Assert(pDevice->pDevice9If);
|
---|
2316 | HRESULT hr = pDevice->pDevice9If->SetClipPlane(pData->Index, pData->Plane);
|
---|
2317 | Assert(hr == S_OK);
|
---|
2318 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
2319 | return hr;
|
---|
2320 | }
|
---|
2321 |
|
---|
2322 | static HRESULT APIENTRY vboxWddmDDevGetInfo(HANDLE hDevice, UINT DevInfoID, VOID* pDevInfoStruct, UINT DevInfoSize)
|
---|
2323 | {
|
---|
2324 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2325 | AssertBreakpoint();
|
---|
2326 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2327 | return E_NOTIMPL;
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | static HRESULT APIENTRY vboxWddmDDevLock(HANDLE hDevice, D3DDDIARG_LOCK* pData)
|
---|
2331 | {
|
---|
2332 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2333 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2334 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource;
|
---|
2335 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2336 | if (pData->SubResourceIndex >= pRc->cAllocations)
|
---|
2337 | return E_INVALIDARG;
|
---|
2338 |
|
---|
2339 | HRESULT hr = S_OK;
|
---|
2340 |
|
---|
2341 | if (VBOXDISPMODE_IS_3D(pDevice->pAdapter))
|
---|
2342 | {
|
---|
2343 | if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE)
|
---|
2344 | {
|
---|
2345 | PVBOXWDDMDISP_ALLOCATION pTexAlloc = &pRc->aAllocations[0];
|
---|
2346 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2347 | PVBOXWDDMDISP_ALLOCATION pLockAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2348 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pTexAlloc->pD3DIf;
|
---|
2349 | Assert(pD3DIfTex);
|
---|
2350 | RECT *pRect = NULL;
|
---|
2351 | bool bNeedResynch = false;
|
---|
2352 | Assert(!pData->Flags.RangeValid);
|
---|
2353 | Assert(!pData->Flags.BoxValid);
|
---|
2354 | if (pData->Flags.AreaValid)
|
---|
2355 | {
|
---|
2356 | pRect = &pData->Area;
|
---|
2357 | }
|
---|
2358 |
|
---|
2359 | /* else - we lock the entire texture, pRect == NULL */
|
---|
2360 |
|
---|
2361 | // Assert(!pLockAlloc->LockInfo.cLocks);
|
---|
2362 | if (!pLockAlloc->LockInfo.cLocks)
|
---|
2363 | {
|
---|
2364 | hr = pD3DIfTex->LockRect(pData->SubResourceIndex,
|
---|
2365 | &pLockAlloc->LockInfo.LockedRect,
|
---|
2366 | pRect,
|
---|
2367 | vboxDDI2D3DLockFlags(pData->Flags));
|
---|
2368 | Assert(hr == S_OK);
|
---|
2369 | if (hr == S_OK)
|
---|
2370 | {
|
---|
2371 |
|
---|
2372 | // Assert(pLockAlloc->LockInfo.fFlags.Value == 0);
|
---|
2373 | pLockAlloc->LockInfo.fFlags = pData->Flags;
|
---|
2374 | if (pRect)
|
---|
2375 | {
|
---|
2376 | pLockAlloc->LockInfo.Area = *pRect;
|
---|
2377 | Assert(pLockAlloc->LockInfo.fFlags.AreaValid == 1);
|
---|
2378 | // pLockAlloc->LockInfo.fFlags.AreaValid = 1;
|
---|
2379 | }
|
---|
2380 | else
|
---|
2381 | {
|
---|
2382 | Assert(pLockAlloc->LockInfo.fFlags.AreaValid == 0);
|
---|
2383 | // pLockAlloc->LockInfo.fFlags.AreaValid = 0;
|
---|
2384 | }
|
---|
2385 |
|
---|
2386 | bNeedResynch = !pData->Flags.Discard;
|
---|
2387 | }
|
---|
2388 | }
|
---|
2389 | else
|
---|
2390 | {
|
---|
2391 | // Assert(pLockAlloc->LockInfo.fFlags.Value == pData->Flags.Value);
|
---|
2392 | // if (pLockAlloc->LockInfo.fFlags.Value != pData->Flags.Value)
|
---|
2393 | // {
|
---|
2394 | // }
|
---|
2395 | Assert(pLockAlloc->LockInfo.fFlags.AreaValid == pData->Flags.AreaValid);
|
---|
2396 | if (pLockAlloc->LockInfo.fFlags.AreaValid && pData->Flags.AreaValid)
|
---|
2397 | {
|
---|
2398 | Assert(pLockAlloc->LockInfo.Area.left == pData->Area.left);
|
---|
2399 | Assert(pLockAlloc->LockInfo.Area.top == pData->Area.top);
|
---|
2400 | Assert(pLockAlloc->LockInfo.Area.right == pData->Area.right);
|
---|
2401 | Assert(pLockAlloc->LockInfo.Area.bottom == pData->Area.bottom);
|
---|
2402 | }
|
---|
2403 | Assert(pLockAlloc->LockInfo.LockedRect.pBits);
|
---|
2404 |
|
---|
2405 | bNeedResynch = pLockAlloc->LockInfo.fFlags.Discard && !pData->Flags.Discard;
|
---|
2406 |
|
---|
2407 | Assert(!bNeedResynch);
|
---|
2408 |
|
---|
2409 | if (/*(pLockAlloc->LockInfo.fFlags.Discard && !pData->Flags.Discard)
|
---|
2410 | || */
|
---|
2411 | (pLockAlloc->LockInfo.fFlags.ReadOnly && !pData->Flags.ReadOnly))
|
---|
2412 | {
|
---|
2413 | hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex);
|
---|
2414 | Assert(hr == S_OK);
|
---|
2415 | if (hr == S_OK)
|
---|
2416 | {
|
---|
2417 | hr = pD3DIfTex->LockRect(pData->SubResourceIndex,
|
---|
2418 | &pLockAlloc->LockInfo.LockedRect,
|
---|
2419 | pRect,
|
---|
2420 | vboxDDI2D3DLockFlags(pData->Flags));
|
---|
2421 | Assert(hr == S_OK);
|
---|
2422 | pLockAlloc->LockInfo.fFlags.ReadOnly = 0;
|
---|
2423 | }
|
---|
2424 | }
|
---|
2425 | }
|
---|
2426 |
|
---|
2427 | if (hr == S_OK)
|
---|
2428 | {
|
---|
2429 | ++pLockAlloc->LockInfo.cLocks;
|
---|
2430 |
|
---|
2431 | if (!pData->Flags.NotifyOnly)
|
---|
2432 | {
|
---|
2433 | pData->pSurfData = pLockAlloc->LockInfo.LockedRect.pBits;
|
---|
2434 | pData->Pitch = pLockAlloc->LockInfo.LockedRect.Pitch;
|
---|
2435 | pData->SlicePitch = 0;
|
---|
2436 | Assert(pLockAlloc->SurfDesc.slicePitch == 0);
|
---|
2437 | Assert(!pLockAlloc->pvMem);
|
---|
2438 | }
|
---|
2439 | else
|
---|
2440 | {
|
---|
2441 | Assert(pLockAlloc->pvMem);
|
---|
2442 | Assert(pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
|
---|
2443 |
|
---|
2444 | if (bNeedResynch)
|
---|
2445 | vboxWddmLockUnlockMemSynch(pLockAlloc, &pLockAlloc->LockInfo.LockedRect, pRect, false /*bool bToLockInfo*/);
|
---|
2446 | }
|
---|
2447 | }
|
---|
2448 | }
|
---|
2449 | else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VERTEXBUFFER)
|
---|
2450 | {
|
---|
2451 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2452 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2453 | IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pAlloc->pD3DIf;
|
---|
2454 | BOOL bLocked = false;
|
---|
2455 | Assert(pD3D9VBuf);
|
---|
2456 | Assert(!pData->Flags.AreaValid);
|
---|
2457 | Assert(!pData->Flags.BoxValid);
|
---|
2458 | D3DDDIRANGE *pRange = NULL;
|
---|
2459 | if (pData->Flags.RangeValid)
|
---|
2460 | {
|
---|
2461 | pRange = &pData->Range;
|
---|
2462 | }
|
---|
2463 |
|
---|
2464 | /* else - we lock the entire vertex buffer, pRect == NULL */
|
---|
2465 |
|
---|
2466 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
2467 | if (!pAlloc->LockInfo.cLocks)
|
---|
2468 | {
|
---|
2469 | if (!pData->Flags.MightDrawFromLocked || (!pData->Flags.Discard && !pData->Flags.NoOverwrite))
|
---|
2470 | {
|
---|
2471 | hr = pD3D9VBuf->Lock(pRange ? pRange->Offset : 0,
|
---|
2472 | pRange ? pRange->Size : 0,
|
---|
2473 | &pAlloc->LockInfo.LockedRect.pBits,
|
---|
2474 | vboxDDI2D3DLockFlags(pData->Flags));
|
---|
2475 | bLocked = true;
|
---|
2476 | }
|
---|
2477 |
|
---|
2478 | Assert(hr == S_OK);
|
---|
2479 | if (hr == S_OK)
|
---|
2480 | {
|
---|
2481 | pAlloc->LockInfo.LockedRect.Pitch = pAlloc->SurfDesc.width;
|
---|
2482 | // Assert(pLockAlloc->LockInfo.fFlags.Value == 0);
|
---|
2483 | pAlloc->LockInfo.fFlags = pData->Flags;
|
---|
2484 | if (pRange)
|
---|
2485 | {
|
---|
2486 | pAlloc->LockInfo.Range = *pRange;
|
---|
2487 | Assert(pAlloc->LockInfo.fFlags.RangeValid == 1);
|
---|
2488 | // pAlloc->LockInfo.fFlags.RangeValid = 1;
|
---|
2489 | }
|
---|
2490 | else
|
---|
2491 | {
|
---|
2492 | Assert(pAlloc->LockInfo.fFlags.RangeValid == 0);
|
---|
2493 | // pAlloc->LockInfo.fFlags.RangeValid = 0;
|
---|
2494 | }
|
---|
2495 | }
|
---|
2496 | }
|
---|
2497 | else
|
---|
2498 | {
|
---|
2499 | // Assert(pAlloc->LockInfo.fFlags.Value == pData->Flags.Value);
|
---|
2500 | // if (pAlloc->LockInfo.fFlags.Value != pData->Flags.Value)
|
---|
2501 | // {
|
---|
2502 | // }
|
---|
2503 | Assert(pAlloc->LockInfo.fFlags.RangeValid == pData->Flags.RangeValid);
|
---|
2504 | if (pAlloc->LockInfo.fFlags.RangeValid && pData->Flags.RangeValid)
|
---|
2505 | {
|
---|
2506 | Assert(pAlloc->LockInfo.Range.Offset == pData->Range.Offset);
|
---|
2507 | Assert(pAlloc->LockInfo.Range.Size == pData->Range.Size);
|
---|
2508 | }
|
---|
2509 | Assert(pAlloc->LockInfo.LockedRect.pBits);
|
---|
2510 | }
|
---|
2511 |
|
---|
2512 | if (hr == S_OK)
|
---|
2513 | {
|
---|
2514 | ++pAlloc->LockInfo.cLocks;
|
---|
2515 |
|
---|
2516 | if (!pData->Flags.NotifyOnly)
|
---|
2517 | {
|
---|
2518 | pData->pSurfData = pAlloc->LockInfo.LockedRect.pBits;
|
---|
2519 | pData->Pitch = pAlloc->LockInfo.LockedRect.Pitch;
|
---|
2520 | pData->SlicePitch = 0;
|
---|
2521 | Assert(pAlloc->SurfDesc.slicePitch == 0);
|
---|
2522 | Assert(!pAlloc->pvMem);
|
---|
2523 | }
|
---|
2524 | else
|
---|
2525 | {
|
---|
2526 | Assert(pAlloc->pvMem);
|
---|
2527 | Assert(pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
|
---|
2528 | if (bLocked && !pData->Flags.Discard)
|
---|
2529 | {
|
---|
2530 | RECT r, *pr;
|
---|
2531 | if (pRange)
|
---|
2532 | {
|
---|
2533 | r.top = 0;
|
---|
2534 | r.left = pRange->Offset;
|
---|
2535 | r.bottom = 1;
|
---|
2536 | r.right = pRange->Offset + pRange->Size;
|
---|
2537 | pr = &r;
|
---|
2538 | }
|
---|
2539 | else
|
---|
2540 | pr = NULL;
|
---|
2541 | vboxWddmLockUnlockMemSynch(pAlloc, &pAlloc->LockInfo.LockedRect, pr, false /*bool bToLockInfo*/);
|
---|
2542 | }
|
---|
2543 | }
|
---|
2544 | }
|
---|
2545 | }
|
---|
2546 | else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_INDEXBUFFER)
|
---|
2547 | {
|
---|
2548 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2549 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2550 | IDirect3DIndexBuffer9 *pD3D9IBuf = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf;
|
---|
2551 | BOOL bLocked = false;
|
---|
2552 | Assert(pD3D9IBuf);
|
---|
2553 | Assert(!pData->Flags.AreaValid);
|
---|
2554 | Assert(!pData->Flags.BoxValid);
|
---|
2555 | D3DDDIRANGE *pRange = NULL;
|
---|
2556 | if (pData->Flags.RangeValid)
|
---|
2557 | {
|
---|
2558 | pRange = &pData->Range;
|
---|
2559 | }
|
---|
2560 |
|
---|
2561 | /* else - we lock the entire vertex buffer, pRect == NULL */
|
---|
2562 |
|
---|
2563 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
2564 | if (!pAlloc->LockInfo.cLocks)
|
---|
2565 | {
|
---|
2566 | if (!pData->Flags.MightDrawFromLocked || (!pData->Flags.Discard && !pData->Flags.NoOverwrite))
|
---|
2567 | {
|
---|
2568 | hr = pD3D9IBuf->Lock(pRange ? pRange->Offset : 0,
|
---|
2569 | pRange ? pRange->Size : 0,
|
---|
2570 | &pAlloc->LockInfo.LockedRect.pBits,
|
---|
2571 | vboxDDI2D3DLockFlags(pData->Flags));
|
---|
2572 | bLocked = true;
|
---|
2573 | }
|
---|
2574 |
|
---|
2575 | Assert(hr == S_OK);
|
---|
2576 | if (hr == S_OK)
|
---|
2577 | {
|
---|
2578 | pAlloc->LockInfo.LockedRect.Pitch = pAlloc->SurfDesc.width;
|
---|
2579 | // Assert(pLockAlloc->LockInfo.fFlags.Value == 0);
|
---|
2580 | pAlloc->LockInfo.fFlags = pData->Flags;
|
---|
2581 | if (pRange)
|
---|
2582 | {
|
---|
2583 | pAlloc->LockInfo.Range = *pRange;
|
---|
2584 | Assert(pAlloc->LockInfo.fFlags.RangeValid == 1);
|
---|
2585 | // pAlloc->LockInfo.fFlags.RangeValid = 1;
|
---|
2586 | }
|
---|
2587 | else
|
---|
2588 | {
|
---|
2589 | Assert(pAlloc->LockInfo.fFlags.RangeValid == 0);
|
---|
2590 | // pAlloc->LockInfo.fFlags.RangeValid = 0;
|
---|
2591 | }
|
---|
2592 | }
|
---|
2593 | }
|
---|
2594 | else
|
---|
2595 | {
|
---|
2596 | // Assert(pAlloc->LockInfo.fFlags.Value == pData->Flags.Value);
|
---|
2597 | // if (pAlloc->LockInfo.fFlags.Value != pData->Flags.Value)
|
---|
2598 | // {
|
---|
2599 | // }
|
---|
2600 | Assert(pAlloc->LockInfo.fFlags.RangeValid == pData->Flags.RangeValid);
|
---|
2601 | if (pAlloc->LockInfo.fFlags.RangeValid && pData->Flags.RangeValid)
|
---|
2602 | {
|
---|
2603 | Assert(pAlloc->LockInfo.Range.Offset == pData->Range.Offset);
|
---|
2604 | Assert(pAlloc->LockInfo.Range.Size == pData->Range.Size);
|
---|
2605 | }
|
---|
2606 | Assert(pAlloc->LockInfo.LockedRect.pBits);
|
---|
2607 | }
|
---|
2608 |
|
---|
2609 | if (hr == S_OK)
|
---|
2610 | {
|
---|
2611 | ++pAlloc->LockInfo.cLocks;
|
---|
2612 |
|
---|
2613 | if (!pData->Flags.NotifyOnly)
|
---|
2614 | {
|
---|
2615 | pData->pSurfData = pAlloc->LockInfo.LockedRect.pBits;
|
---|
2616 | pData->Pitch = pAlloc->LockInfo.LockedRect.Pitch;
|
---|
2617 | pData->SlicePitch = 0;
|
---|
2618 | Assert(pAlloc->SurfDesc.slicePitch == 0);
|
---|
2619 | Assert(!pAlloc->pvMem);
|
---|
2620 | }
|
---|
2621 | else
|
---|
2622 | {
|
---|
2623 | Assert(pAlloc->pvMem);
|
---|
2624 | Assert(pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
|
---|
2625 | if (bLocked && !pData->Flags.Discard)
|
---|
2626 | {
|
---|
2627 | RECT r, *pr;
|
---|
2628 | if (pRange)
|
---|
2629 | {
|
---|
2630 | r.top = 0;
|
---|
2631 | r.left = pRange->Offset;
|
---|
2632 | r.bottom = 1;
|
---|
2633 | r.right = pRange->Offset + pRange->Size;
|
---|
2634 | pr = &r;
|
---|
2635 | }
|
---|
2636 | else
|
---|
2637 | pr = NULL;
|
---|
2638 | vboxWddmLockUnlockMemSynch(pAlloc, &pAlloc->LockInfo.LockedRect, pr, false /*bool bToLockInfo*/);
|
---|
2639 | }
|
---|
2640 | }
|
---|
2641 | }
|
---|
2642 | }
|
---|
2643 | else
|
---|
2644 | {
|
---|
2645 | AssertBreakpoint();
|
---|
2646 | }
|
---|
2647 | }
|
---|
2648 | else
|
---|
2649 | {
|
---|
2650 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2651 | D3DDDICB_LOCK LockData;
|
---|
2652 | LockData.hAllocation = pAlloc->hAllocation;
|
---|
2653 | LockData.PrivateDriverData = 0;
|
---|
2654 | LockData.NumPages = 0;
|
---|
2655 | LockData.pPages = NULL;
|
---|
2656 | LockData.pData = NULL; /* out */
|
---|
2657 | LockData.Flags.Value = 0;
|
---|
2658 | LockData.Flags.Discard = pData->Flags.Discard;
|
---|
2659 | LockData.Flags.DonotWait = pData->Flags.DoNotWait;
|
---|
2660 |
|
---|
2661 |
|
---|
2662 | hr = pDevice->RtCallbacks.pfnLockCb(pDevice->hDevice, &LockData);
|
---|
2663 | Assert(hr == S_OK || (hr == D3DERR_WASSTILLDRAWING && pData->Flags.DoNotWait));
|
---|
2664 | if (hr == S_OK)
|
---|
2665 | {
|
---|
2666 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
2667 |
|
---|
2668 | uintptr_t offset;
|
---|
2669 | if (pData->Flags.AreaValid)
|
---|
2670 | {
|
---|
2671 | offset = pAlloc->SurfDesc.pitch * pData->Area.top +
|
---|
2672 | ((pAlloc->SurfDesc.bpp * pData->Area.left) >> 3);
|
---|
2673 | }
|
---|
2674 | else if (pData->Flags.RangeValid)
|
---|
2675 | {
|
---|
2676 | offset = pData->Range.Offset;
|
---|
2677 | }
|
---|
2678 | else if (pData->Flags.BoxValid)
|
---|
2679 | {
|
---|
2680 | vboxVDbgPrintF((__FUNCTION__": Implement Box area"));
|
---|
2681 | AssertBreakpoint();
|
---|
2682 | }
|
---|
2683 | else
|
---|
2684 | {
|
---|
2685 | offset = 0;
|
---|
2686 | }
|
---|
2687 |
|
---|
2688 | if (!pData->Flags.ReadOnly)
|
---|
2689 | {
|
---|
2690 | if (pData->Flags.AreaValid)
|
---|
2691 | vboxWddmDirtyRegionAddRect(&pAlloc->DirtyRegion, &pData->Area);
|
---|
2692 | else
|
---|
2693 | {
|
---|
2694 | Assert(!pData->Flags.RangeValid);
|
---|
2695 | Assert(!pData->Flags.BoxValid);
|
---|
2696 | vboxWddmDirtyRegionAddRect(&pAlloc->DirtyRegion, NULL); /* <- NULL means the entire surface */
|
---|
2697 | }
|
---|
2698 | }
|
---|
2699 |
|
---|
2700 | if (pData->Flags.Discard)
|
---|
2701 | {
|
---|
2702 | /* check if the surface was renamed */
|
---|
2703 | if (LockData.hAllocation)
|
---|
2704 | pAlloc->hAllocation = LockData.hAllocation;
|
---|
2705 | }
|
---|
2706 |
|
---|
2707 | pData->pSurfData = ((uint8_t*)LockData.pData) + offset;
|
---|
2708 | pData->Pitch = pAlloc->SurfDesc.pitch;
|
---|
2709 | pData->SlicePitch = pAlloc->SurfDesc.slicePitch;
|
---|
2710 |
|
---|
2711 | Assert(hr == S_OK);
|
---|
2712 | ++pAlloc->LockInfo.cLocks;
|
---|
2713 | }
|
---|
2714 | }
|
---|
2715 |
|
---|
2716 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(%d)\n", hDevice, hr));
|
---|
2717 | return hr;
|
---|
2718 | }
|
---|
2719 | static HRESULT APIENTRY vboxWddmDDevUnlock(HANDLE hDevice, CONST D3DDDIARG_UNLOCK* pData)
|
---|
2720 | {
|
---|
2721 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2722 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2723 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource;
|
---|
2724 | HRESULT hr = S_OK;
|
---|
2725 |
|
---|
2726 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2727 | if (pData->SubResourceIndex >= pRc->cAllocations)
|
---|
2728 | return E_INVALIDARG;
|
---|
2729 |
|
---|
2730 | if (VBOXDISPMODE_IS_3D(pDevice->pAdapter))
|
---|
2731 | {
|
---|
2732 | if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE)
|
---|
2733 | {
|
---|
2734 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2735 | PVBOXWDDMDISP_ALLOCATION pLockAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2736 |
|
---|
2737 | --pLockAlloc->LockInfo.cLocks;
|
---|
2738 | Assert(pLockAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2739 | // pLockAlloc->LockInfo.cLocks = 0;
|
---|
2740 | if (!pLockAlloc->LockInfo.cLocks)
|
---|
2741 | {
|
---|
2742 | PVBOXWDDMDISP_ALLOCATION pTexAlloc = &pRc->aAllocations[0];
|
---|
2743 | // Assert(!pLockAlloc->LockInfo.cLocks);
|
---|
2744 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pTexAlloc->pD3DIf;
|
---|
2745 | Assert(pD3DIfTex);
|
---|
2746 | /* this is a sysmem texture, update */
|
---|
2747 | if (pLockAlloc->pvMem && !pLockAlloc->LockInfo.fFlags.ReadOnly)
|
---|
2748 | {
|
---|
2749 | vboxWddmLockUnlockMemSynch(pLockAlloc, &pLockAlloc->LockInfo.LockedRect,
|
---|
2750 | pLockAlloc->LockInfo.fFlags.AreaValid ? &pLockAlloc->LockInfo.Area : NULL,
|
---|
2751 | true /*bool bToLockInfo*/);
|
---|
2752 | }
|
---|
2753 | hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex);
|
---|
2754 | Assert(hr == S_OK);
|
---|
2755 | }
|
---|
2756 | else
|
---|
2757 | {
|
---|
2758 | Assert(pLockAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2759 | }
|
---|
2760 | }
|
---|
2761 | else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VERTEXBUFFER)
|
---|
2762 | {
|
---|
2763 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2764 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2765 |
|
---|
2766 | --pAlloc->LockInfo.cLocks;
|
---|
2767 | Assert(pAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2768 | if (!pAlloc->LockInfo.cLocks
|
---|
2769 | && (!pAlloc->LockInfo.fFlags.MightDrawFromLocked
|
---|
2770 | || (!pAlloc->LockInfo.fFlags.Discard && !pAlloc->LockInfo.fFlags.NoOverwrite)))
|
---|
2771 | {
|
---|
2772 | // Assert(!pAlloc->LockInfo.cLocks);
|
---|
2773 | IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pAlloc->pD3DIf;
|
---|
2774 | Assert(pD3D9VBuf);
|
---|
2775 | /* this is a sysmem texture, update */
|
---|
2776 | if (pAlloc->pvMem && !pAlloc->LockInfo.fFlags.ReadOnly)
|
---|
2777 | {
|
---|
2778 | RECT r, *pr;
|
---|
2779 | if (pAlloc->LockInfo.fFlags.RangeValid)
|
---|
2780 | {
|
---|
2781 | r.top = 0;
|
---|
2782 | r.left = pAlloc->LockInfo.Range.Offset;
|
---|
2783 | r.bottom = 1;
|
---|
2784 | r.right = pAlloc->LockInfo.Range.Offset + pAlloc->LockInfo.Range.Size;
|
---|
2785 | pr = &r;
|
---|
2786 | }
|
---|
2787 | else
|
---|
2788 | pr = NULL;
|
---|
2789 | vboxWddmLockUnlockMemSynch(pAlloc, &pAlloc->LockInfo.LockedRect,
|
---|
2790 | pr,
|
---|
2791 | true /*bool bToLockInfo*/);
|
---|
2792 | }
|
---|
2793 | hr = pD3D9VBuf->Unlock();
|
---|
2794 | Assert(hr == S_OK);
|
---|
2795 | }
|
---|
2796 | else
|
---|
2797 | {
|
---|
2798 | Assert(pAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2799 | }
|
---|
2800 | }
|
---|
2801 | else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_INDEXBUFFER)
|
---|
2802 | {
|
---|
2803 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
2804 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2805 |
|
---|
2806 | --pAlloc->LockInfo.cLocks;
|
---|
2807 | Assert(pAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2808 | if (!pAlloc->LockInfo.cLocks
|
---|
2809 | && (!pAlloc->LockInfo.fFlags.MightDrawFromLocked
|
---|
2810 | || (!pAlloc->LockInfo.fFlags.Discard && !pAlloc->LockInfo.fFlags.NoOverwrite)))
|
---|
2811 | {
|
---|
2812 | // Assert(!pAlloc->LockInfo.cLocks);
|
---|
2813 | IDirect3DIndexBuffer9 *pD3D9IBuf = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf;
|
---|
2814 | Assert(pD3D9IBuf);
|
---|
2815 | /* this is a sysmem texture, update */
|
---|
2816 | if (pAlloc->pvMem && !pAlloc->LockInfo.fFlags.ReadOnly)
|
---|
2817 | {
|
---|
2818 | RECT r, *pr;
|
---|
2819 | if (pAlloc->LockInfo.fFlags.RangeValid)
|
---|
2820 | {
|
---|
2821 | r.top = 0;
|
---|
2822 | r.left = pAlloc->LockInfo.Range.Offset;
|
---|
2823 | r.bottom = 1;
|
---|
2824 | r.right = pAlloc->LockInfo.Range.Offset + pAlloc->LockInfo.Range.Size;
|
---|
2825 | pr = &r;
|
---|
2826 | }
|
---|
2827 | else
|
---|
2828 | pr = NULL;
|
---|
2829 | vboxWddmLockUnlockMemSynch(pAlloc, &pAlloc->LockInfo.LockedRect,
|
---|
2830 | pr,
|
---|
2831 | true /*bool bToLockInfo*/);
|
---|
2832 | }
|
---|
2833 | hr = pD3D9IBuf->Unlock();
|
---|
2834 | Assert(hr == S_OK);
|
---|
2835 | }
|
---|
2836 | else
|
---|
2837 | {
|
---|
2838 | Assert(pAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2839 | }
|
---|
2840 | }
|
---|
2841 | else
|
---|
2842 | {
|
---|
2843 | AssertBreakpoint();
|
---|
2844 | }
|
---|
2845 | }
|
---|
2846 | else
|
---|
2847 | {
|
---|
2848 | struct
|
---|
2849 | {
|
---|
2850 | D3DDDICB_UNLOCK Unlock;
|
---|
2851 | D3DKMT_HANDLE hAllocation;
|
---|
2852 | } UnlockData;
|
---|
2853 |
|
---|
2854 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
2855 |
|
---|
2856 | UnlockData.Unlock.NumAllocations = 1;
|
---|
2857 | UnlockData.Unlock.phAllocations = &UnlockData.hAllocation;
|
---|
2858 | UnlockData.hAllocation = pAlloc->hAllocation;
|
---|
2859 |
|
---|
2860 | hr = pDevice->RtCallbacks.pfnUnlockCb(pDevice->hDevice, &UnlockData.Unlock);
|
---|
2861 | Assert(hr == S_OK);
|
---|
2862 | if (hr == S_OK)
|
---|
2863 | {
|
---|
2864 | Assert(pAlloc->LockInfo.cLocks);
|
---|
2865 | --pAlloc->LockInfo.cLocks;
|
---|
2866 | Assert(pAlloc->LockInfo.cLocks < UINT32_MAX);
|
---|
2867 | }
|
---|
2868 | }
|
---|
2869 |
|
---|
2870 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2871 | return hr;
|
---|
2872 | }
|
---|
2873 | static HRESULT APIENTRY vboxWddmDDevLockAsync(HANDLE hDevice, D3DDDIARG_LOCKASYNC* pData)
|
---|
2874 | {
|
---|
2875 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2876 | AssertBreakpoint();
|
---|
2877 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2878 | return E_FAIL;
|
---|
2879 | }
|
---|
2880 | static HRESULT APIENTRY vboxWddmDDevUnlockAsync(HANDLE hDevice, CONST D3DDDIARG_UNLOCKASYNC* pData)
|
---|
2881 | {
|
---|
2882 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2883 | AssertBreakpoint();
|
---|
2884 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2885 | return E_FAIL;
|
---|
2886 | }
|
---|
2887 | static HRESULT APIENTRY vboxWddmDDevRename(HANDLE hDevice, CONST D3DDDIARG_RENAME* pData)
|
---|
2888 | {
|
---|
2889 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2890 | AssertBreakpoint();
|
---|
2891 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2892 | return E_FAIL;
|
---|
2893 | }
|
---|
2894 |
|
---|
2895 | static void vboxWddmRequestAllocFree(D3DDDICB_ALLOCATE* pAlloc)
|
---|
2896 | {
|
---|
2897 | RTMemFree(pAlloc);
|
---|
2898 | }
|
---|
2899 |
|
---|
2900 | static D3DDDICB_ALLOCATE* vboxWddmRequestAllocAlloc(D3DDDIARG_CREATERESOURCE* pResource)
|
---|
2901 | {
|
---|
2902 | /* allocate buffer for D3DDDICB_ALLOCATE + D3DDDI_ALLOCATIONINFO * numAllocs + PVBOXWDDM_RCINFO with aAllocInfos[numAllocs] */
|
---|
2903 | uint32_t cbBuf = sizeof (D3DDDICB_ALLOCATE);
|
---|
2904 | uint32_t offDdiAllocInfos = (cbBuf + 7) & ~3;
|
---|
2905 | uint32_t cbDdiAllocInfos = sizeof (D3DDDI_ALLOCATIONINFO) * pResource->SurfCount;
|
---|
2906 | cbBuf = offDdiAllocInfos + cbDdiAllocInfos;
|
---|
2907 | uint32_t offRcInfo = (cbBuf + 7) & ~3;
|
---|
2908 | uint32_t cbRcInfo = sizeof (VBOXWDDM_RCINFO);
|
---|
2909 | cbBuf = offRcInfo + cbRcInfo;
|
---|
2910 | uint32_t offAllocInfos = (cbBuf + 7) & ~3;
|
---|
2911 | uint32_t cbAllocInfos = sizeof (VBOXWDDM_ALLOCINFO) * pResource->SurfCount;
|
---|
2912 | cbBuf = offAllocInfos + cbAllocInfos;
|
---|
2913 | uint8_t *pvBuf = (uint8_t*)RTMemAllocZ(cbBuf);
|
---|
2914 | Assert(pvBuf);
|
---|
2915 | if (pvBuf)
|
---|
2916 | {
|
---|
2917 | D3DDDICB_ALLOCATE* pAlloc = (D3DDDICB_ALLOCATE*)pvBuf;
|
---|
2918 | pAlloc->NumAllocations = pResource->SurfCount;
|
---|
2919 | pAlloc->pAllocationInfo = (D3DDDI_ALLOCATIONINFO*)(pvBuf + offDdiAllocInfos);
|
---|
2920 | PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)(pvBuf + offRcInfo);
|
---|
2921 | pAlloc->PrivateDriverDataSize = cbRcInfo;
|
---|
2922 | pAlloc->pPrivateDriverData = pRcInfo;
|
---|
2923 | pAlloc->hResource = pResource->hResource;
|
---|
2924 | PVBOXWDDM_ALLOCINFO pAllocInfos = (PVBOXWDDM_ALLOCINFO)(pvBuf + offAllocInfos);
|
---|
2925 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
2926 | {
|
---|
2927 | D3DDDI_ALLOCATIONINFO* pDdiAllocInfo = &pAlloc->pAllocationInfo[i];
|
---|
2928 | PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i];
|
---|
2929 | pDdiAllocInfo->pPrivateDriverData = pAllocInfo;
|
---|
2930 | pDdiAllocInfo->PrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO);
|
---|
2931 | }
|
---|
2932 | return pAlloc;
|
---|
2933 | }
|
---|
2934 | return NULL;
|
---|
2935 | }
|
---|
2936 | static HRESULT APIENTRY vboxWddmDDevCreateResource(HANDLE hDevice, D3DDDIARG_CREATERESOURCE* pResource)
|
---|
2937 | {
|
---|
2938 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
2939 | HRESULT hr = S_OK;
|
---|
2940 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
2941 | Assert(pDevice);
|
---|
2942 | Assert(pResource);
|
---|
2943 | PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;
|
---|
2944 |
|
---|
2945 | PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount);
|
---|
2946 | Assert(pRc);
|
---|
2947 | if (pRc)
|
---|
2948 | {
|
---|
2949 | bool bIssueCreateResource = false;
|
---|
2950 |
|
---|
2951 | pRc->hResource = pResource->hResource;
|
---|
2952 | pRc->hKMResource = NULL;
|
---|
2953 | pRc->pDevice = pDevice;
|
---|
2954 | pRc->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC;
|
---|
2955 | pRc->RcDesc.fFlags = pResource->Flags;
|
---|
2956 | pRc->RcDesc.enmFormat = pResource->Format;
|
---|
2957 | pRc->RcDesc.enmPool = pResource->Pool;
|
---|
2958 | pRc->RcDesc.enmMultisampleType = pResource->MultisampleType;
|
---|
2959 | pRc->RcDesc.MultisampleQuality = pResource->MultisampleQuality;
|
---|
2960 | pRc->RcDesc.MipLevels = pResource->MipLevels;
|
---|
2961 | pRc->RcDesc.Fvf = pResource->Fvf;
|
---|
2962 | pRc->RcDesc.VidPnSourceId = pResource->VidPnSourceId;
|
---|
2963 | pRc->RcDesc.RefreshRate = pResource->RefreshRate;
|
---|
2964 | pRc->RcDesc.enmRotation = pResource->Rotation;
|
---|
2965 | pRc->cAllocations = pResource->SurfCount;
|
---|
2966 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
2967 | {
|
---|
2968 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
2969 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i];
|
---|
2970 | pAllocation->hAllocation = NULL;
|
---|
2971 | pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC;
|
---|
2972 | pAllocation->pvMem = (void*)pSurf->pSysMem;
|
---|
2973 | pAllocation->SurfDesc.pitch = pSurf->SysMemPitch;
|
---|
2974 | pAllocation->SurfDesc.slicePitch = pSurf->SysMemSlicePitch;
|
---|
2975 | pAllocation->SurfDesc.depth = pSurf->Depth;
|
---|
2976 | pAllocation->SurfDesc.width = pSurf->Width;
|
---|
2977 | pAllocation->SurfDesc.height = pSurf->Height;
|
---|
2978 | pAllocation->SurfDesc.format = pResource->Format;
|
---|
2979 | }
|
---|
2980 |
|
---|
2981 | if (VBOXDISPMODE_IS_3D(pAdapter))
|
---|
2982 | {
|
---|
2983 | if (pResource->Flags.SharedResource)
|
---|
2984 | {
|
---|
2985 | AssertBreakpoint(); /* <-- need to test that */
|
---|
2986 | bIssueCreateResource = true;
|
---|
2987 | }
|
---|
2988 |
|
---|
2989 | if (pResource->Flags.ZBuffer)
|
---|
2990 | {
|
---|
2991 | Assert(pDevice->pDevice9If);
|
---|
2992 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
2993 | {
|
---|
2994 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
2995 | IDirect3DSurface9 *pD3D9Surf;
|
---|
2996 | hr = pDevice->pDevice9If->CreateDepthStencilSurface(pAllocation->SurfDesc.width,
|
---|
2997 | pAllocation->SurfDesc.height,
|
---|
2998 | vboxDDI2D3DFormat(pResource->Format),
|
---|
2999 | vboxDDI2D3DMultiSampleType(pResource->MultisampleType),
|
---|
3000 | pResource->MultisampleQuality,
|
---|
3001 | TRUE /* @todo: BOOL Discard */,
|
---|
3002 | &pD3D9Surf,
|
---|
3003 | NULL /*HANDLE* pSharedHandle*/);
|
---|
3004 | Assert(hr == S_OK);
|
---|
3005 | if (hr == S_OK)
|
---|
3006 | {
|
---|
3007 | Assert(pD3D9Surf);
|
---|
3008 | pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
|
---|
3009 | pAllocation->pD3DIf = pD3D9Surf;
|
---|
3010 | if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
|
---|
3011 | {
|
---|
3012 | Assert(pAllocation->pvMem);
|
---|
3013 | D3DLOCKED_RECT lockInfo;
|
---|
3014 | hr = pD3D9Surf->LockRect(&lockInfo, NULL, D3DLOCK_DISCARD);
|
---|
3015 | Assert(hr == S_OK);
|
---|
3016 | if (hr == S_OK)
|
---|
3017 | {
|
---|
3018 | vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);
|
---|
3019 | HRESULT tmpHr = pD3D9Surf->UnlockRect();
|
---|
3020 | Assert(tmpHr == S_OK);
|
---|
3021 | }
|
---|
3022 | }
|
---|
3023 | else
|
---|
3024 | {
|
---|
3025 | Assert(!pAllocation->pvMem);
|
---|
3026 | }
|
---|
3027 | }
|
---|
3028 | else
|
---|
3029 | {
|
---|
3030 | for (UINT j = 0; j < i; ++j)
|
---|
3031 | {
|
---|
3032 | pRc->aAllocations[j].pD3DIf->Release();
|
---|
3033 | }
|
---|
3034 | break;
|
---|
3035 | }
|
---|
3036 | }
|
---|
3037 | }
|
---|
3038 | else if (pResource->Flags.VertexBuffer)
|
---|
3039 | {
|
---|
3040 | Assert(pDevice->pDevice9If);
|
---|
3041 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3042 | {
|
---|
3043 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3044 | IDirect3DVertexBuffer9 *pD3D9VBuf;
|
---|
3045 | hr = pDevice->pDevice9If->CreateVertexBuffer(pAllocation->SurfDesc.width,
|
---|
3046 | vboxDDI2D3DUsage(pResource->Flags),
|
---|
3047 | pResource->Fvf,
|
---|
3048 | vboxDDI2D3DPool(pResource->Pool),
|
---|
3049 | &pD3D9VBuf,
|
---|
3050 | NULL /*HANDLE* pSharedHandle*/);
|
---|
3051 | Assert(hr == S_OK);
|
---|
3052 | if (hr == S_OK)
|
---|
3053 | {
|
---|
3054 | Assert(pD3D9VBuf);
|
---|
3055 | pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_VERTEXBUFFER;
|
---|
3056 | pAllocation->pD3DIf = pD3D9VBuf;
|
---|
3057 | if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
|
---|
3058 | {
|
---|
3059 | Assert(pAllocation->pvMem);
|
---|
3060 | D3DLOCKED_RECT lockInfo;
|
---|
3061 | hr = pD3D9VBuf->Lock(0, pAllocation->SurfDesc.width, &lockInfo.pBits, D3DLOCK_DISCARD);
|
---|
3062 | Assert(hr == S_OK);
|
---|
3063 | if (hr == S_OK)
|
---|
3064 | {
|
---|
3065 | lockInfo.Pitch = pAllocation->SurfDesc.pitch;
|
---|
3066 | vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);
|
---|
3067 | HRESULT tmpHr = pD3D9VBuf->Unlock();
|
---|
3068 | Assert(tmpHr == S_OK);
|
---|
3069 | }
|
---|
3070 | }
|
---|
3071 | else
|
---|
3072 | {
|
---|
3073 | Assert(!pAllocation->pvMem);
|
---|
3074 | }
|
---|
3075 | }
|
---|
3076 | else
|
---|
3077 | {
|
---|
3078 | for (UINT j = 0; j < i; ++j)
|
---|
3079 | {
|
---|
3080 | pRc->aAllocations[j].pD3DIf->Release();
|
---|
3081 | }
|
---|
3082 | break;
|
---|
3083 | }
|
---|
3084 | }
|
---|
3085 | }
|
---|
3086 | else if (pResource->Flags.IndexBuffer)
|
---|
3087 | {
|
---|
3088 | Assert(pDevice->pDevice9If);
|
---|
3089 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3090 | {
|
---|
3091 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3092 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i];
|
---|
3093 | IDirect3DIndexBuffer9 *pD3D9IBuf;
|
---|
3094 | hr = pDevice->pDevice9If->CreateIndexBuffer(pSurf->Width,
|
---|
3095 | vboxDDI2D3DUsage(pResource->Flags),
|
---|
3096 | vboxDDI2D3DFormat(pResource->Format),
|
---|
3097 | vboxDDI2D3DPool(pResource->Pool),
|
---|
3098 | &pD3D9IBuf,
|
---|
3099 | NULL /*HANDLE* pSharedHandle*/
|
---|
3100 | );
|
---|
3101 | Assert(hr == S_OK);
|
---|
3102 | if (hr == S_OK)
|
---|
3103 | {
|
---|
3104 | Assert(pD3D9IBuf);
|
---|
3105 | pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_INDEXBUFFER;
|
---|
3106 | pAllocation->pD3DIf = pD3D9IBuf;
|
---|
3107 | if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
|
---|
3108 | {
|
---|
3109 | Assert(pAllocation->pvMem);
|
---|
3110 | D3DLOCKED_RECT lockInfo;
|
---|
3111 | hr = pD3D9IBuf->Lock(0, pAllocation->SurfDesc.width, &lockInfo.pBits, D3DLOCK_DISCARD);
|
---|
3112 | Assert(hr == S_OK);
|
---|
3113 | if (hr == S_OK)
|
---|
3114 | {
|
---|
3115 | lockInfo.Pitch = pAllocation->SurfDesc.pitch;
|
---|
3116 | vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);
|
---|
3117 | HRESULT tmpHr = pD3D9IBuf->Unlock();
|
---|
3118 | Assert(tmpHr == S_OK);
|
---|
3119 | }
|
---|
3120 | }
|
---|
3121 | else
|
---|
3122 | {
|
---|
3123 | Assert(!pAllocation->pvMem);
|
---|
3124 | }
|
---|
3125 | }
|
---|
3126 | else
|
---|
3127 | {
|
---|
3128 | for (UINT j = 0; j < i; ++j)
|
---|
3129 | {
|
---|
3130 | pRc->aAllocations[j].pD3DIf->Release();
|
---|
3131 | }
|
---|
3132 | break;
|
---|
3133 | }
|
---|
3134 | }
|
---|
3135 | }
|
---|
3136 | else if (pResource->Flags.Texture || pResource->Flags.Value == 0)
|
---|
3137 | {
|
---|
3138 | Assert(pDevice->pDevice9If);
|
---|
3139 | #ifdef DEBUG
|
---|
3140 | {
|
---|
3141 | uint32_t tstW = pResource->pSurfList[0].Width;
|
---|
3142 | uint32_t tstH = pResource->pSurfList[0].Height;
|
---|
3143 | for (UINT i = 1; i < pResource->SurfCount; ++i)
|
---|
3144 | {
|
---|
3145 | tstW /= 2;
|
---|
3146 | tstH /= 2;
|
---|
3147 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i];
|
---|
3148 | Assert(pSurf->Width == tstW);
|
---|
3149 | Assert(pSurf->Height == tstH);
|
---|
3150 | }
|
---|
3151 | }
|
---|
3152 | #endif
|
---|
3153 |
|
---|
3154 | if (pResource->Flags.RenderTarget)
|
---|
3155 | bIssueCreateResource = true;
|
---|
3156 |
|
---|
3157 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0];
|
---|
3158 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0];
|
---|
3159 | IDirect3DTexture9 *pD3DIfTex;
|
---|
3160 | hr = pDevice->pDevice9If->CreateTexture(pSurf->Width,
|
---|
3161 | pSurf->Height,
|
---|
3162 | pResource->SurfCount,
|
---|
3163 | vboxDDI2D3DUsage(pResource->Flags),
|
---|
3164 | vboxDDI2D3DFormat(pResource->Format),
|
---|
3165 | vboxDDI2D3DPool(pResource->Pool),
|
---|
3166 | &pD3DIfTex,
|
---|
3167 | NULL /* HANDLE* pSharedHandle */
|
---|
3168 | );
|
---|
3169 | Assert(hr == S_OK);
|
---|
3170 | if (hr == S_OK)
|
---|
3171 | {
|
---|
3172 | Assert(pD3DIfTex);
|
---|
3173 | pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE;
|
---|
3174 | pAllocation->pD3DIf = pD3DIfTex;
|
---|
3175 | if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
|
---|
3176 | {
|
---|
3177 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3178 | {
|
---|
3179 | D3DLOCKED_RECT lockInfo;
|
---|
3180 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3181 | Assert(pAllocation->pvMem);
|
---|
3182 | hr = pD3DIfTex->LockRect(i, &lockInfo, NULL, D3DLOCK_DISCARD);
|
---|
3183 | Assert(hr == S_OK);
|
---|
3184 | if (hr == S_OK)
|
---|
3185 | {
|
---|
3186 | vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);
|
---|
3187 | HRESULT tmpHr = pD3DIfTex->UnlockRect(i);
|
---|
3188 | Assert(tmpHr == S_OK);
|
---|
3189 | }
|
---|
3190 | else
|
---|
3191 | {
|
---|
3192 | pD3DIfTex->Release();
|
---|
3193 | break;
|
---|
3194 | }
|
---|
3195 | }
|
---|
3196 | }
|
---|
3197 | }
|
---|
3198 | #ifdef DEBUG
|
---|
3199 | else
|
---|
3200 | {
|
---|
3201 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3202 | {
|
---|
3203 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3204 | Assert(!pAllocation->pvMem);
|
---|
3205 | }
|
---|
3206 | }
|
---|
3207 | #endif
|
---|
3208 | }
|
---|
3209 | else if (pResource->Flags.RenderTarget)
|
---|
3210 | {
|
---|
3211 | HWND hWnd = NULL;
|
---|
3212 | bool bDevCreated = false;
|
---|
3213 | Assert(pResource->SurfCount);
|
---|
3214 | if (!pDevice->pDevice9If)
|
---|
3215 | {
|
---|
3216 | Assert(!pDevice->hWnd);
|
---|
3217 | hr = VBoxDispWndCreate(pAdapter, pResource->pSurfList[0].Width, pResource->pSurfList[0].Height, &hWnd);
|
---|
3218 | Assert(hr == S_OK);
|
---|
3219 | if (hr == S_OK)
|
---|
3220 | {
|
---|
3221 | DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
---|
3222 | if (pDevice->fFlags.AllowMultithreading)
|
---|
3223 | fFlags |= D3DCREATE_MULTITHREADED;
|
---|
3224 |
|
---|
3225 | IDirect3DDevice9 *pDevice9If = NULL;
|
---|
3226 | D3DPRESENT_PARAMETERS params;
|
---|
3227 | memset(¶ms, 0, sizeof (params));
|
---|
3228 | // params.BackBufferWidth = 0;
|
---|
3229 | // params.BackBufferHeight = 0;
|
---|
3230 | params.BackBufferFormat = vboxDDI2D3DFormat(pResource->Format);
|
---|
3231 | Assert(pResource->SurfCount);
|
---|
3232 | params.BackBufferCount = pResource->SurfCount - 1;
|
---|
3233 | params.MultiSampleType = vboxDDI2D3DMultiSampleType(pResource->MultisampleType);
|
---|
3234 | if (pResource->Flags.DiscardRenderTarget)
|
---|
3235 | params.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
---|
3236 | params.hDeviceWindow = hWnd;
|
---|
3237 | /* @todo: it seems there should be a way to detect this correctly since
|
---|
3238 | * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */
|
---|
3239 | params.Windowed = TRUE;
|
---|
3240 | // params.EnableAutoDepthStencil = FALSE;
|
---|
3241 | // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
|
---|
3242 | // params.Flags;
|
---|
3243 | // params.FullScreen_RefreshRateInHz;
|
---|
3244 | // params.FullScreen_PresentationInterval;
|
---|
3245 | hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, ¶ms, &pDevice9If);
|
---|
3246 | Assert(hr == S_OK);
|
---|
3247 | if (hr == S_OK)
|
---|
3248 | {
|
---|
3249 | pDevice->pDevice9If = pDevice9If;
|
---|
3250 | pDevice->hWnd = hWnd;
|
---|
3251 | bDevCreated = true;
|
---|
3252 | }
|
---|
3253 | }
|
---|
3254 | }
|
---|
3255 | else
|
---|
3256 | {
|
---|
3257 | Assert(pDevice->hWnd);
|
---|
3258 | }
|
---|
3259 |
|
---|
3260 | if (hr == S_OK)
|
---|
3261 | {
|
---|
3262 | Assert(pDevice->pDevice9If);
|
---|
3263 | bIssueCreateResource = true;
|
---|
3264 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3265 | {
|
---|
3266 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3267 |
|
---|
3268 | IDirect3DSurface9* pD3D9Surf;
|
---|
3269 | hr = pDevice->pDevice9If->CreateRenderTarget(pAllocation->SurfDesc.width,
|
---|
3270 | pAllocation->SurfDesc.height,
|
---|
3271 | vboxDDI2D3DFormat(pResource->Format),
|
---|
3272 | vboxDDI2D3DMultiSampleType(pResource->MultisampleType),
|
---|
3273 | pResource->MultisampleQuality,
|
---|
3274 | !pResource->Flags.NotLockable /* BOOL Lockable */,
|
---|
3275 | &pD3D9Surf,
|
---|
3276 | NULL /* HANDLE* pSharedHandle */
|
---|
3277 | );
|
---|
3278 | Assert(hr == S_OK);
|
---|
3279 | if (hr == S_OK)
|
---|
3280 | {
|
---|
3281 | Assert(pD3D9Surf);
|
---|
3282 | pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
|
---|
3283 | pAllocation->pD3DIf = pD3D9Surf;
|
---|
3284 | if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)
|
---|
3285 | {
|
---|
3286 | Assert(pAllocation->pvMem);
|
---|
3287 | D3DLOCKED_RECT lockInfo;
|
---|
3288 | hr = pD3D9Surf->LockRect(&lockInfo, NULL, D3DLOCK_DISCARD);
|
---|
3289 | Assert(hr == S_OK);
|
---|
3290 | if (hr == S_OK)
|
---|
3291 | {
|
---|
3292 | vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);
|
---|
3293 | HRESULT tmpHr = pD3D9Surf->UnlockRect();
|
---|
3294 | Assert(tmpHr == S_OK);
|
---|
3295 | }
|
---|
3296 | }
|
---|
3297 | else
|
---|
3298 | {
|
---|
3299 | Assert(!pAllocation->pvMem);
|
---|
3300 | }
|
---|
3301 | }
|
---|
3302 | else
|
---|
3303 | {
|
---|
3304 | for (UINT j = 0; j < i; ++j)
|
---|
3305 | {
|
---|
3306 | pRc->aAllocations[j].pD3DIf->Release();
|
---|
3307 | }
|
---|
3308 | break;
|
---|
3309 | }
|
---|
3310 | }
|
---|
3311 | }
|
---|
3312 |
|
---|
3313 | if (hr != S_OK)
|
---|
3314 | {
|
---|
3315 | if (bDevCreated)
|
---|
3316 | {
|
---|
3317 | VBoxDispWndDestroy(pAdapter, hWnd);
|
---|
3318 | pDevice->pDevice9If->Release();
|
---|
3319 | }
|
---|
3320 | }
|
---|
3321 | }
|
---|
3322 | else
|
---|
3323 | {
|
---|
3324 | Assert(pDevice->pDevice9If);
|
---|
3325 | Assert(0);
|
---|
3326 | }
|
---|
3327 | }
|
---|
3328 | else
|
---|
3329 | bIssueCreateResource = true;
|
---|
3330 |
|
---|
3331 |
|
---|
3332 | if (hr == S_OK && bIssueCreateResource)
|
---|
3333 | {
|
---|
3334 | D3DDDICB_ALLOCATE *pDdiAllocate = vboxWddmRequestAllocAlloc(pResource);
|
---|
3335 | Assert(pDdiAllocate);
|
---|
3336 | if (pDdiAllocate)
|
---|
3337 | {
|
---|
3338 | Assert(pDdiAllocate->pPrivateDriverData);
|
---|
3339 | Assert(pDdiAllocate->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO));
|
---|
3340 | PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pDdiAllocate->pPrivateDriverData;
|
---|
3341 | pRcInfo->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC;
|
---|
3342 | pRcInfo->RcDesc = pRc->RcDesc;
|
---|
3343 | pRcInfo->cAllocInfos = pResource->SurfCount;
|
---|
3344 |
|
---|
3345 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3346 | {
|
---|
3347 | D3DDDI_ALLOCATIONINFO *pDdiAllocI = &pDdiAllocate->pAllocationInfo[i];
|
---|
3348 | Assert(pDdiAllocI->pPrivateDriverData);
|
---|
3349 | Assert(pDdiAllocI->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO));
|
---|
3350 | PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocI->pPrivateDriverData;
|
---|
3351 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i];
|
---|
3352 | pDdiAllocI->hAllocation = NULL;
|
---|
3353 | pDdiAllocI->pSystemMem = pSurf->pSysMem;
|
---|
3354 | Assert((!!(pSurf->pSysMem)) == (pResource->Pool == D3DDDIPOOL_SYSTEMMEM));
|
---|
3355 | pDdiAllocI->VidPnSourceId = pResource->VidPnSourceId;
|
---|
3356 | pDdiAllocI->Flags.Value = 0;
|
---|
3357 | if (pResource->Flags.Primary)
|
---|
3358 | {
|
---|
3359 | Assert(pResource->Flags.RenderTarget);
|
---|
3360 | pDdiAllocI->Flags.Primary = 1;
|
---|
3361 | }
|
---|
3362 |
|
---|
3363 | pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC;
|
---|
3364 | pAllocInfo->fFlags = pResource->Flags;
|
---|
3365 | pAllocInfo->SurfDesc.width = pSurf->Width;
|
---|
3366 | pAllocInfo->SurfDesc.height = pSurf->Height;
|
---|
3367 | pAllocInfo->SurfDesc.format = pResource->Format;
|
---|
3368 | if (!vboxWddmFormatToFourcc(pResource->Format))
|
---|
3369 | pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pResource->Format);
|
---|
3370 | else
|
---|
3371 | pAllocInfo->SurfDesc.bpp = 0;
|
---|
3372 |
|
---|
3373 | if (pSurf->SysMemPitch)
|
---|
3374 | {
|
---|
3375 | pAllocInfo->SurfDesc.pitch = pSurf->SysMemPitch;
|
---|
3376 | #ifdef DEBUG
|
---|
3377 | UINT tst = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp);
|
---|
3378 | Assert(tst == pSurf->SysMemPitch);
|
---|
3379 | #endif
|
---|
3380 | }
|
---|
3381 | else
|
---|
3382 | pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp);
|
---|
3383 |
|
---|
3384 | pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
|
---|
3385 | pAllocInfo->SurfDesc.depth = pSurf->Depth;
|
---|
3386 | pAllocInfo->SurfDesc.slicePitch = pSurf->SysMemSlicePitch;
|
---|
3387 | pAllocInfo->SurfDesc.VidPnSourceId = pResource->VidPnSourceId;
|
---|
3388 | pAllocInfo->SurfDesc.RefreshRate = pResource->RefreshRate;
|
---|
3389 | }
|
---|
3390 |
|
---|
3391 | hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate);
|
---|
3392 | Assert(hr == S_OK);
|
---|
3393 | Assert(pDdiAllocate->hKMResource);
|
---|
3394 | if (hr == S_OK)
|
---|
3395 | {
|
---|
3396 | pRc->hKMResource = pDdiAllocate->hKMResource;
|
---|
3397 |
|
---|
3398 | for (UINT i = 0; i < pResource->SurfCount; ++i)
|
---|
3399 | {
|
---|
3400 | PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
|
---|
3401 | D3DDDI_ALLOCATIONINFO *pDdiAllocI = &pDdiAllocate->pAllocationInfo[i];
|
---|
3402 | PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocI->pPrivateDriverData;
|
---|
3403 | CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i];
|
---|
3404 | pAllocation->hAllocation = pDdiAllocI->hAllocation;
|
---|
3405 | pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC;
|
---|
3406 | pAllocation->pvMem = (void*)pSurf->pSysMem;
|
---|
3407 | pAllocation->SurfDesc = pAllocInfo->SurfDesc;
|
---|
3408 | }
|
---|
3409 | }
|
---|
3410 |
|
---|
3411 | vboxWddmRequestAllocFree(pDdiAllocate);
|
---|
3412 | }
|
---|
3413 | else
|
---|
3414 | {
|
---|
3415 | hr = E_OUTOFMEMORY;
|
---|
3416 | }
|
---|
3417 |
|
---|
3418 | if (hr == S_OK)
|
---|
3419 | pResource->hResource = pRc;
|
---|
3420 | else
|
---|
3421 | vboxResourceFree(pRc);
|
---|
3422 | }
|
---|
3423 |
|
---|
3424 | if (hr == S_OK)
|
---|
3425 | pResource->hResource = pRc;
|
---|
3426 | else
|
---|
3427 | vboxResourceFree(pRc);
|
---|
3428 | }
|
---|
3429 | else
|
---|
3430 | {
|
---|
3431 | hr = E_OUTOFMEMORY;
|
---|
3432 | }
|
---|
3433 |
|
---|
3434 |
|
---|
3435 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3436 | return hr;
|
---|
3437 | }
|
---|
3438 |
|
---|
3439 | static HRESULT APIENTRY vboxWddmDDevDestroyResource(HANDLE hDevice, HANDLE hResource)
|
---|
3440 | {
|
---|
3441 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3442 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3443 | PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;
|
---|
3444 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hResource;
|
---|
3445 |
|
---|
3446 | HRESULT hr = S_OK;
|
---|
3447 |
|
---|
3448 | Assert(pDevice);
|
---|
3449 | Assert(hResource);
|
---|
3450 |
|
---|
3451 | if (VBOXDISPMODE_IS_3D(pAdapter))
|
---|
3452 | {
|
---|
3453 | if (pRc->RcDesc.fFlags.RenderTarget)
|
---|
3454 | {
|
---|
3455 | Assert(pDevice->hWnd);
|
---|
3456 | Assert(pDevice->pDevice9If);
|
---|
3457 | }
|
---|
3458 |
|
---|
3459 | for (UINT i = 0; i < pRc->cAllocations; ++i)
|
---|
3460 | {
|
---|
3461 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
|
---|
3462 | if (pAlloc->pD3DIf)
|
---|
3463 | pAlloc->pD3DIf->Release();
|
---|
3464 | }
|
---|
3465 | }
|
---|
3466 |
|
---|
3467 | Assert(pRc->hResource);
|
---|
3468 | Assert(pRc->hKMResource || VBOXDISPMODE_IS_3D(pAdapter));
|
---|
3469 | if (pRc->hKMResource)
|
---|
3470 | {
|
---|
3471 | if (!(pRc->fFlags & VBOXWDDM_RESOURCE_F_OPENNED))
|
---|
3472 | {
|
---|
3473 | D3DDDICB_DEALLOCATE Dealloc;
|
---|
3474 | Dealloc.hResource = pRc->hResource;
|
---|
3475 | /* according to the docs the below two are ignored in case we set the hResource */
|
---|
3476 | Dealloc.NumAllocations = 0;
|
---|
3477 | Dealloc.HandleList = NULL;
|
---|
3478 | hr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc);
|
---|
3479 | Assert(hr == S_OK);
|
---|
3480 | // for (UINT j = 0; j < pRc->cAllocations; ++j)
|
---|
3481 | // {
|
---|
3482 | // D3DDDICB_DEALLOCATE Dealloc;
|
---|
3483 | // Dealloc.hResource = NULL;
|
---|
3484 | // Dealloc.NumAllocations = 1;
|
---|
3485 | // Dealloc.HandleList = &pRc->aAllocations[j].hAllocation;
|
---|
3486 | // HRESULT tmpHr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc);
|
---|
3487 | // Assert(tmpHr = S_OK);
|
---|
3488 | // }
|
---|
3489 | }
|
---|
3490 | }
|
---|
3491 |
|
---|
3492 | vboxResourceFree(pRc);
|
---|
3493 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3494 | return hr;
|
---|
3495 | }
|
---|
3496 | static HRESULT APIENTRY vboxWddmDDevSetDisplayMode(HANDLE hDevice, CONST D3DDDIARG_SETDISPLAYMODE* pData)
|
---|
3497 | {
|
---|
3498 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3499 | HRESULT hr = S_OK;
|
---|
3500 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3501 | Assert(pDevice);
|
---|
3502 | Assert(VBOXDISPMODE_IS_3D(pDevice->pAdapter));
|
---|
3503 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource;
|
---|
3504 | Assert(pRc);
|
---|
3505 | Assert(pRc->cAllocations > pData->SubResourceIndex);
|
---|
3506 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex];
|
---|
3507 | Assert(pRc->RcDesc.fFlags.RenderTarget);
|
---|
3508 | Assert(pRc->aAllocations[pData->SubResourceIndex].enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
|
---|
3509 | Assert(pAlloc->hAllocation);
|
---|
3510 | D3DDDICB_SETDISPLAYMODE DdiDm = {0};
|
---|
3511 | DdiDm.hPrimaryAllocation = pAlloc->hAllocation;
|
---|
3512 | // DdiDm.PrivateDriverFormatAttribute = 0;
|
---|
3513 | hr = pDevice->RtCallbacks.pfnSetDisplayModeCb(pDevice->hDevice, &DdiDm);
|
---|
3514 | Assert(hr == S_OK);
|
---|
3515 |
|
---|
3516 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3517 | return hr;
|
---|
3518 | }
|
---|
3519 | static HRESULT APIENTRY vboxWddmDDevPresent(HANDLE hDevice, CONST D3DDDIARG_PRESENT* pData)
|
---|
3520 | {
|
---|
3521 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3522 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3523 | Assert(pDevice);
|
---|
3524 | HRESULT hr = S_OK;
|
---|
3525 | if (VBOXDISPMODE_IS_3D(pDevice->pAdapter))
|
---|
3526 | {
|
---|
3527 | Assert(pDevice->pDevice9If);
|
---|
3528 | #if 0
|
---|
3529 | hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */
|
---|
3530 | NULL, /* CONST RECT * pDestRect */
|
---|
3531 | NULL, /* HWND hDestWindowOverride */
|
---|
3532 | NULL /*CONST RGNDATA * pDirtyRegion */
|
---|
3533 | );
|
---|
3534 | Assert(hr == S_OK);
|
---|
3535 | #endif
|
---|
3536 | }
|
---|
3537 | #if 0
|
---|
3538 | else
|
---|
3539 | #endif
|
---|
3540 | {
|
---|
3541 | D3DDDICB_PRESENT DdiPresent = {0};
|
---|
3542 | if (pData->hSrcResource)
|
---|
3543 | {
|
---|
3544 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
|
---|
3545 | Assert(pRc->hKMResource);
|
---|
3546 | Assert(pRc->cAllocations > pData->SrcSubResourceIndex);
|
---|
3547 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SrcSubResourceIndex];
|
---|
3548 | Assert(pAlloc->hAllocation);
|
---|
3549 | DdiPresent.hSrcAllocation = pAlloc->hAllocation;
|
---|
3550 | }
|
---|
3551 | if (pData->hDstResource)
|
---|
3552 | {
|
---|
3553 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
|
---|
3554 | Assert(pRc->hKMResource);
|
---|
3555 | Assert(pRc->cAllocations > pData->DstSubResourceIndex);
|
---|
3556 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->DstSubResourceIndex];
|
---|
3557 | Assert(pAlloc->hAllocation);
|
---|
3558 | DdiPresent.hDstAllocation = pAlloc->hAllocation;
|
---|
3559 | }
|
---|
3560 | DdiPresent.hContext = pDevice->DefaultContext.ContextInfo.hContext;
|
---|
3561 | // DdiPresent.BroadcastContextCount;
|
---|
3562 | // DdiPresent.BroadcastContext[D3DDDI_MAX_BROADCAST_CONTEXT];
|
---|
3563 |
|
---|
3564 | hr = pDevice->RtCallbacks.pfnPresentCb(pDevice->hDevice, &DdiPresent);
|
---|
3565 | Assert(hr == S_OK);
|
---|
3566 | }
|
---|
3567 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3568 | return hr;
|
---|
3569 | }
|
---|
3570 | static HRESULT APIENTRY vboxWddmDDevFlush(HANDLE hDevice)
|
---|
3571 | {
|
---|
3572 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3573 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3574 | Assert(pDevice);
|
---|
3575 | HRESULT hr = S_OK;
|
---|
3576 | if (VBOXDISPMODE_IS_3D(pDevice->pAdapter))
|
---|
3577 | {
|
---|
3578 | Assert(pDevice->pDevice9If);
|
---|
3579 | hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */
|
---|
3580 | NULL, /* CONST RECT * pDestRect */
|
---|
3581 | NULL, /* HWND hDestWindowOverride */
|
---|
3582 | NULL /*CONST RGNDATA * pDirtyRegion */
|
---|
3583 | );
|
---|
3584 | Assert(hr == S_OK);
|
---|
3585 | }
|
---|
3586 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3587 | return hr;
|
---|
3588 | }
|
---|
3589 |
|
---|
3590 | AssertCompile(sizeof (D3DDDIVERTEXELEMENT) == sizeof (D3DVERTEXELEMENT9));
|
---|
3591 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Stream) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Stream));
|
---|
3592 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Offset) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Offset));
|
---|
3593 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Type) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Type));
|
---|
3594 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Method) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Method));
|
---|
3595 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Usage) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Usage));
|
---|
3596 | AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, UsageIndex) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, UsageIndex));
|
---|
3597 |
|
---|
3598 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, Stream) == RT_OFFSETOF(D3DVERTEXELEMENT9, Stream));
|
---|
3599 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, Offset) == RT_OFFSETOF(D3DVERTEXELEMENT9, Offset));
|
---|
3600 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, Type) == RT_OFFSETOF(D3DVERTEXELEMENT9, Type));
|
---|
3601 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, Method) == RT_OFFSETOF(D3DVERTEXELEMENT9, Method));
|
---|
3602 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, Usage) == RT_OFFSETOF(D3DVERTEXELEMENT9, Usage));
|
---|
3603 | AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, UsageIndex) == RT_OFFSETOF(D3DVERTEXELEMENT9, UsageIndex));
|
---|
3604 |
|
---|
3605 | static HRESULT APIENTRY vboxWddmDDevCreateVertexShaderDecl(HANDLE hDevice, D3DDDIARG_CREATEVERTEXSHADERDECL* pData, CONST D3DDDIVERTEXELEMENT* pVertexElements)
|
---|
3606 | {
|
---|
3607 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3608 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3609 | Assert(pDevice);
|
---|
3610 | Assert(pDevice->pDevice9If);
|
---|
3611 | IDirect3DVertexDeclaration9 *pDecl;
|
---|
3612 | static D3DVERTEXELEMENT9 DeclEnd = D3DDECL_END();
|
---|
3613 | Assert(!memcmp(&DeclEnd, &pVertexElements[pData->NumVertexElements], sizeof (DeclEnd)));
|
---|
3614 | HRESULT hr = pDevice->pDevice9If->CreateVertexDeclaration(
|
---|
3615 | (CONST D3DVERTEXELEMENT9*)pVertexElements,
|
---|
3616 | &pDecl
|
---|
3617 | );
|
---|
3618 | Assert(hr == S_OK);
|
---|
3619 | if (hr == S_OK)
|
---|
3620 | {
|
---|
3621 | Assert(pDecl);
|
---|
3622 | pData->ShaderHandle = pDecl;
|
---|
3623 | }
|
---|
3624 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3625 | return hr;
|
---|
3626 | }
|
---|
3627 | static HRESULT APIENTRY vboxWddmDDevSetVertexShaderDecl(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
3628 | {
|
---|
3629 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3630 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3631 | Assert(pDevice);
|
---|
3632 | Assert(pDevice->pDevice9If);
|
---|
3633 | IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle;
|
---|
3634 | Assert(pDecl);
|
---|
3635 | HRESULT hr = pDevice->pDevice9If->SetVertexDeclaration(pDecl);
|
---|
3636 | Assert(hr == S_OK);
|
---|
3637 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3638 | return hr;
|
---|
3639 | }
|
---|
3640 | static HRESULT APIENTRY vboxWddmDDevDeleteVertexShaderDecl(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
3641 | {
|
---|
3642 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3643 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3644 | Assert(pDevice);
|
---|
3645 | Assert(pDevice->pDevice9If);
|
---|
3646 | IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle;
|
---|
3647 | HRESULT hr = S_OK;
|
---|
3648 | pDecl->Release();
|
---|
3649 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3650 | return hr;
|
---|
3651 | }
|
---|
3652 | static HRESULT APIENTRY vboxWddmDDevCreateVertexShaderFunc(HANDLE hDevice, D3DDDIARG_CREATEVERTEXSHADERFUNC* pData, CONST UINT* pCode)
|
---|
3653 | {
|
---|
3654 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3655 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3656 | Assert(pDevice);
|
---|
3657 | Assert(pDevice->pDevice9If);
|
---|
3658 | IDirect3DVertexShader9 *pShader;
|
---|
3659 | Assert(*((UINT*)((uint8_t*)pCode + pData->Size-4)) == 0x0000FFFF /* end token */);
|
---|
3660 | HRESULT hr = pDevice->pDevice9If->CreateVertexShader((const DWORD *)pCode, &pShader);
|
---|
3661 | Assert(hr == S_OK);
|
---|
3662 | if (hr == S_OK)
|
---|
3663 | {
|
---|
3664 | Assert(pShader);
|
---|
3665 | pData->ShaderHandle = pShader;
|
---|
3666 | }
|
---|
3667 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3668 | return hr;
|
---|
3669 | }
|
---|
3670 | static HRESULT APIENTRY vboxWddmDDevSetVertexShaderFunc(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
3671 | {
|
---|
3672 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3673 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3674 | Assert(pDevice);
|
---|
3675 | Assert(pDevice->pDevice9If);
|
---|
3676 | IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle;
|
---|
3677 | Assert(pShader);
|
---|
3678 | HRESULT hr = pDevice->pDevice9If->SetVertexShader(pShader);
|
---|
3679 | Assert(hr == S_OK);
|
---|
3680 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3681 | return hr;
|
---|
3682 | }
|
---|
3683 | static HRESULT APIENTRY vboxWddmDDevDeleteVertexShaderFunc(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
3684 | {
|
---|
3685 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3686 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3687 | Assert(pDevice);
|
---|
3688 | Assert(pDevice->pDevice9If);
|
---|
3689 | IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle;
|
---|
3690 | HRESULT hr = S_OK;
|
---|
3691 | pShader->Release();
|
---|
3692 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3693 | return hr;
|
---|
3694 | }
|
---|
3695 | static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConstI(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONSTI* pData, CONST INT* pRegisters)
|
---|
3696 | {
|
---|
3697 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3698 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3699 | Assert(pDevice);
|
---|
3700 | Assert(pDevice->pDevice9If);
|
---|
3701 | HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantI(pData->Register, pRegisters, pData->Count);
|
---|
3702 | Assert(hr == S_OK);
|
---|
3703 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3704 | return hr;
|
---|
3705 | }
|
---|
3706 | static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConstB(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONSTB* pData, CONST BOOL* pRegisters)
|
---|
3707 | {
|
---|
3708 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3709 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3710 | Assert(pDevice);
|
---|
3711 | Assert(pDevice->pDevice9If);
|
---|
3712 | HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantB(pData->Register, pRegisters, pData->Count);
|
---|
3713 | Assert(hr == S_OK);
|
---|
3714 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3715 | return hr;
|
---|
3716 | }
|
---|
3717 | static HRESULT APIENTRY vboxWddmDDevSetScissorRect(HANDLE hDevice, CONST RECT* pRect)
|
---|
3718 | {
|
---|
3719 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3720 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3721 | Assert(pDevice);
|
---|
3722 | Assert(pDevice->pDevice9If);
|
---|
3723 | HRESULT hr = pDevice->pDevice9If->SetScissorRect(pRect);
|
---|
3724 | Assert(hr == S_OK);
|
---|
3725 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3726 | return hr;
|
---|
3727 | }
|
---|
3728 | static HRESULT APIENTRY vboxWddmDDevSetStreamSource(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCE* pData)
|
---|
3729 | {
|
---|
3730 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3731 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3732 | Assert(pDevice);
|
---|
3733 | Assert(pDevice->pDevice9If);
|
---|
3734 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hVertexBuffer;
|
---|
3735 | PVBOXWDDMDISP_ALLOCATION pAlloc = NULL;
|
---|
3736 | IDirect3DVertexBuffer9 *pStreamData = NULL;
|
---|
3737 | if (pRc)
|
---|
3738 | {
|
---|
3739 | Assert(pRc->cAllocations == 1);
|
---|
3740 | pAlloc = &pRc->aAllocations[0];
|
---|
3741 | Assert(pAlloc->pD3DIf);
|
---|
3742 | pStreamData = (IDirect3DVertexBuffer9*)pAlloc->pD3DIf;
|
---|
3743 | }
|
---|
3744 | HRESULT hr = pDevice->pDevice9If->SetStreamSource(pData->Stream, pStreamData, pData->Offset, pData->Stride);
|
---|
3745 | Assert(hr == S_OK);
|
---|
3746 | Assert(pData->Stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS);
|
---|
3747 | if (hr == S_OK)
|
---|
3748 | {
|
---|
3749 | if (pDevice->aStreamSource[pData->Stream] && !pAlloc)
|
---|
3750 | {
|
---|
3751 | --pDevice->cStreamSources;
|
---|
3752 | Assert(pDevice->cStreamSources < UINT32_MAX/2);
|
---|
3753 | }
|
---|
3754 | else if (!pDevice->aStreamSource[pData->Stream] && pAlloc)
|
---|
3755 | {
|
---|
3756 | ++pDevice->cStreamSources;
|
---|
3757 | Assert(pDevice->cStreamSources <= RT_ELEMENTS(pDevice->aStreamSource));
|
---|
3758 | }
|
---|
3759 | pDevice->aStreamSource[pData->Stream] = pAlloc;
|
---|
3760 | pDevice->StreamSourceInfo[pData->Stream].uiOffset = pData->Offset;
|
---|
3761 | pDevice->StreamSourceInfo[pData->Stream].uiStride = pData->Stride;
|
---|
3762 | }
|
---|
3763 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
3764 | return hr;
|
---|
3765 | }
|
---|
3766 | static HRESULT APIENTRY vboxWddmDDevSetStreamSourceFreq(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEFREQ* pData)
|
---|
3767 | {
|
---|
3768 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3769 | AssertBreakpoint();
|
---|
3770 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3771 | return E_FAIL;
|
---|
3772 | }
|
---|
3773 | static HRESULT APIENTRY vboxWddmDDevSetConvolutionKernelMono(HANDLE hDevice, CONST D3DDDIARG_SETCONVOLUTIONKERNELMONO* pData)
|
---|
3774 | {
|
---|
3775 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3776 | AssertBreakpoint();
|
---|
3777 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3778 | return E_FAIL;
|
---|
3779 | }
|
---|
3780 | static HRESULT APIENTRY vboxWddmDDevComposeRects(HANDLE hDevice, CONST D3DDDIARG_COMPOSERECTS* pData)
|
---|
3781 | {
|
---|
3782 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3783 | AssertBreakpoint();
|
---|
3784 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3785 | return E_FAIL;
|
---|
3786 | }
|
---|
3787 | static HRESULT vboxWddmLockRect(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc,
|
---|
3788 | D3DLOCKED_RECT * pLockedRect,
|
---|
3789 | CONST RECT *pRect,
|
---|
3790 | DWORD fLockFlags)
|
---|
3791 | {
|
---|
3792 | HRESULT hr = E_FAIL;
|
---|
3793 | Assert(!pRc->aAllocations[iAlloc].LockInfo.cLocks);
|
---|
3794 | Assert(pRc->cAllocations > iAlloc);
|
---|
3795 | switch (pRc->aAllocations[0].enmD3DIfType)
|
---|
3796 | {
|
---|
3797 | case VBOXDISP_D3DIFTYPE_SURFACE:
|
---|
3798 | {
|
---|
3799 | IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pRc->aAllocations[iAlloc].pD3DIf;
|
---|
3800 | Assert(pD3DIfSurf);
|
---|
3801 | hr = pD3DIfSurf->LockRect(pLockedRect, pRect, fLockFlags);
|
---|
3802 | Assert(hr == S_OK);
|
---|
3803 | break;
|
---|
3804 | }
|
---|
3805 | case VBOXDISP_D3DIFTYPE_TEXTURE:
|
---|
3806 | {
|
---|
3807 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;
|
---|
3808 | Assert(pD3DIfTex);
|
---|
3809 | hr = pD3DIfTex->LockRect(iAlloc, pLockedRect, pRect, fLockFlags);
|
---|
3810 | Assert(hr == S_OK);
|
---|
3811 | break;
|
---|
3812 | }
|
---|
3813 | default:
|
---|
3814 | AssertBreakpoint();
|
---|
3815 | break;
|
---|
3816 | }
|
---|
3817 | return hr;
|
---|
3818 | }
|
---|
3819 | static HRESULT vboxWddmUnlockRect(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc)
|
---|
3820 | {
|
---|
3821 | HRESULT hr = S_OK;
|
---|
3822 | Assert(pRc->cAllocations > iAlloc);
|
---|
3823 | switch (pRc->aAllocations[0].enmD3DIfType)
|
---|
3824 | {
|
---|
3825 | case VBOXDISP_D3DIFTYPE_SURFACE:
|
---|
3826 | {
|
---|
3827 | IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pRc->aAllocations[iAlloc].pD3DIf;
|
---|
3828 | Assert(pD3DIfSurf);
|
---|
3829 | hr = pD3DIfSurf->UnlockRect();
|
---|
3830 | Assert(hr == S_OK);
|
---|
3831 | break;
|
---|
3832 | }
|
---|
3833 | case VBOXDISP_D3DIFTYPE_TEXTURE:
|
---|
3834 | {
|
---|
3835 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;
|
---|
3836 | Assert(pD3DIfTex);
|
---|
3837 | hr = pD3DIfTex->UnlockRect(iAlloc);
|
---|
3838 | Assert(hr == S_OK);
|
---|
3839 | break;
|
---|
3840 | }
|
---|
3841 | default:
|
---|
3842 | AssertBreakpoint();
|
---|
3843 | hr = E_FAIL;
|
---|
3844 | break;
|
---|
3845 | }
|
---|
3846 | return hr;
|
---|
3847 | }
|
---|
3848 |
|
---|
3849 | /* on success increments the surface ref counter,
|
---|
3850 | * i.e. one must call pSurf->Release() once the surface is not needed*/
|
---|
3851 | static HRESULT vboxWddmSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf)
|
---|
3852 | {
|
---|
3853 | HRESULT hr = S_OK;
|
---|
3854 | Assert(pRc->cAllocations > iAlloc);
|
---|
3855 | switch (pRc->aAllocations[0].enmD3DIfType)
|
---|
3856 | {
|
---|
3857 | case VBOXDISP_D3DIFTYPE_SURFACE:
|
---|
3858 | {
|
---|
3859 | IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pRc->aAllocations[iAlloc].pD3DIf;
|
---|
3860 | Assert(pD3DIfSurf);
|
---|
3861 | pD3DIfSurf->AddRef();
|
---|
3862 | *ppSurf = pD3DIfSurf;
|
---|
3863 | break;
|
---|
3864 | }
|
---|
3865 | case VBOXDISP_D3DIFTYPE_TEXTURE:
|
---|
3866 | {
|
---|
3867 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;
|
---|
3868 | IDirect3DSurface9 *pSurfaceLevel;
|
---|
3869 | Assert(pD3DIfTex);
|
---|
3870 | hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel);
|
---|
3871 | Assert(hr == S_OK);
|
---|
3872 | if (hr == S_OK)
|
---|
3873 | {
|
---|
3874 | *ppSurf = pSurfaceLevel;
|
---|
3875 | }
|
---|
3876 | break;
|
---|
3877 | }
|
---|
3878 | default:
|
---|
3879 | AssertBreakpoint();
|
---|
3880 | hr = E_FAIL;
|
---|
3881 | break;
|
---|
3882 | }
|
---|
3883 | return hr;
|
---|
3884 | }
|
---|
3885 |
|
---|
3886 | static HRESULT APIENTRY vboxWddmDDevBlt(HANDLE hDevice, CONST D3DDDIARG_BLT* pData)
|
---|
3887 | {
|
---|
3888 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
3889 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
3890 | Assert(pDevice);
|
---|
3891 | Assert(pDevice->pDevice9If);
|
---|
3892 | PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
|
---|
3893 | PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
|
---|
3894 | Assert(pDstRc->cAllocations > pData->DstSubResourceIndex);
|
---|
3895 | Assert(pSrcRc->cAllocations > pData->SrcSubResourceIndex);
|
---|
3896 | HRESULT hr = S_OK;
|
---|
3897 | /* try StretchRect */
|
---|
3898 | IDirect3DSurface9 *pSrcSurfIf = NULL;
|
---|
3899 | IDirect3DSurface9 *pDstSurfIf = NULL;
|
---|
3900 | hr = vboxWddmSurfGet(pSrcRc, pData->SrcSubResourceIndex, &pSrcSurfIf);
|
---|
3901 | Assert(hr == S_OK);
|
---|
3902 | if (hr == S_OK)
|
---|
3903 | {
|
---|
3904 | Assert(pSrcSurfIf);
|
---|
3905 | hr = vboxWddmSurfGet(pDstRc, pData->DstSubResourceIndex, &pDstSurfIf);
|
---|
3906 | Assert(hr == S_OK);
|
---|
3907 | if (hr == S_OK)
|
---|
3908 | {
|
---|
3909 | Assert(pDstSurfIf);
|
---|
3910 | /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */
|
---|
3911 | Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0);
|
---|
3912 | hr = pDevice->pDevice9If->StretchRect(pSrcSurfIf,
|
---|
3913 | &pData->SrcRect,
|
---|
3914 | pDstSurfIf,
|
---|
3915 | &pData->DstRect,
|
---|
3916 | vboxDDI2D3DBltFlags(pData->Flags));
|
---|
3917 | Assert(hr == S_OK);
|
---|
3918 | pDstSurfIf->Release();
|
---|
3919 | }
|
---|
3920 | pSrcSurfIf->Release();
|
---|
3921 | }
|
---|
3922 |
|
---|
3923 | if (hr != S_OK)
|
---|
3924 | {
|
---|
3925 | /* todo: fallback to memcpy or whatever ? */
|
---|
3926 | AssertBreakpoint();
|
---|
3927 | }
|
---|
3928 |
|
---|
3929 |
|
---|
3930 | #if 0
|
---|
3931 | if ((use pAlloc->enmD3DIfType instead!!! pDstRc->RcDesc.fFlags.Texture || pDstRc->RcDesc.fFlags.Value == 0)
|
---|
3932 | && (pSrcRc->RcDesc.fFlags.Texture || pSrcRc->RcDesc.fFlags.Value == 0))
|
---|
3933 | {
|
---|
3934 | IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcAlloc->pD3DIf;
|
---|
3935 | IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstAlloc->pD3DIf;
|
---|
3936 | Assert(pD3DIfSrcTex);
|
---|
3937 | Assert(pD3DIfDstTex);
|
---|
3938 |
|
---|
3939 | if (pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat)
|
---|
3940 | {
|
---|
3941 | if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width
|
---|
3942 | && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height
|
---|
3943 | && pData->DstRect.left == 0 && pData->DstRect.top == 0
|
---|
3944 | && pData->SrcRect.left == 0 && pData->SrcRect.top == 0
|
---|
3945 | && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width
|
---|
3946 | && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height
|
---|
3947 | && pData->DstRect.right - pData->DstRect.left == pDstRc->aAllocations[0].SurfDesc.width
|
---|
3948 | && pData->DstRect.bottom - pData->DstRect.top == pDstRc->aAllocations[0].SurfDesc.height
|
---|
3949 | )
|
---|
3950 | {
|
---|
3951 | hr = pDevice->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);
|
---|
3952 | Assert(hr == S_OK);
|
---|
3953 | }
|
---|
3954 | else if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left
|
---|
3955 | && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top)
|
---|
3956 | {
|
---|
3957 | Assert(pDstAlloc->SurfDesc.bpp);
|
---|
3958 | Assert(pSrcAlloc->SurfDesc.bpp);
|
---|
3959 | Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp);
|
---|
3960 | D3DLOCKED_RECT DstRect, SrcRect;
|
---|
3961 | Assert(!pSrcAlloc->LockInfo.cLocks);
|
---|
3962 | Assert(!pDstAlloc->LockInfo.cLocks);
|
---|
3963 | hr = pD3DIfDstTex->LockRect(pData->DstSubResourceIndex, &DstRect, &pData->DstRect, D3DLOCK_DISCARD);
|
---|
3964 | Assert(hr == S_OK);
|
---|
3965 | if (hr == S_OK)
|
---|
3966 | {
|
---|
3967 | hr = pD3DIfSrcTex->LockRect(pData->SrcSubResourceIndex, &SrcRect, &pData->SrcRect, D3DLOCK_READONLY);
|
---|
3968 | Assert(hr == S_OK);
|
---|
3969 | if (hr == S_OK)
|
---|
3970 | {
|
---|
3971 | hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits,
|
---|
3972 | &pData->DstRect, &pData->SrcRect,
|
---|
3973 | DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp);
|
---|
3974 | Assert(hr == S_OK);
|
---|
3975 |
|
---|
3976 | pD3DIfSrcTex->UnlockRect(pData->SrcSubResourceIndex);
|
---|
3977 | }
|
---|
3978 | pD3DIfDstTex->UnlockRect(pData->DstSubResourceIndex);
|
---|
3979 | }
|
---|
3980 | }
|
---|
3981 | else
|
---|
3982 | {
|
---|
3983 |
|
---|
3984 | AssertBreakpoint();
|
---|
3985 | /* @todo: impl */
|
---|
3986 | }
|
---|
3987 | }
|
---|
3988 | else
|
---|
3989 | {
|
---|
3990 | AssertBreakpoint();
|
---|
3991 | /* @todo: impl */
|
---|
3992 | }
|
---|
3993 | }
|
---|
3994 | else
|
---|
3995 | {
|
---|
3996 | if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left
|
---|
3997 | && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top)
|
---|
3998 | {
|
---|
3999 | Assert(pDstAlloc->SurfDesc.bpp);
|
---|
4000 | Assert(pSrcAlloc->SurfDesc.bpp);
|
---|
4001 | Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp);
|
---|
4002 |
|
---|
4003 | D3DLOCKED_RECT DstRect, SrcRect;
|
---|
4004 | hr = vboxWddmLockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags,
|
---|
4005 | &DstRect, &pData->DstRect, D3DLOCK_DISCARD);
|
---|
4006 | Assert(hr == S_OK);
|
---|
4007 | if (hr == S_OK)
|
---|
4008 | {
|
---|
4009 | hr = vboxWddmLockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags,
|
---|
4010 | &SrcRect, &pData->SrcRect, D3DLOCK_READONLY);
|
---|
4011 | Assert(hr == S_OK);
|
---|
4012 | if (hr == S_OK)
|
---|
4013 | {
|
---|
4014 | hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits,
|
---|
4015 | &pData->DstRect, &pData->SrcRect,
|
---|
4016 | DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp);
|
---|
4017 | Assert(hr == S_OK);
|
---|
4018 |
|
---|
4019 | HRESULT tmpHr = vboxWddmUnlockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags);
|
---|
4020 | Assert(tmpHr == S_OK);
|
---|
4021 | }
|
---|
4022 | HRESULT tmpHr = vboxWddmUnlockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags);
|
---|
4023 | Assert(tmpHr == S_OK);
|
---|
4024 | }
|
---|
4025 | }
|
---|
4026 | else
|
---|
4027 | {
|
---|
4028 | AssertBreakpoint();
|
---|
4029 | /* @todo: impl */
|
---|
4030 | }
|
---|
4031 | }
|
---|
4032 | #endif
|
---|
4033 |
|
---|
4034 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4035 | return hr;
|
---|
4036 | }
|
---|
4037 | static HRESULT APIENTRY vboxWddmDDevColorFill(HANDLE hDevice, CONST D3DDDIARG_COLORFILL* pData)
|
---|
4038 | {
|
---|
4039 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4040 | AssertBreakpoint();
|
---|
4041 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4042 | return E_FAIL;
|
---|
4043 | }
|
---|
4044 | static HRESULT APIENTRY vboxWddmDDevDepthFill(HANDLE hDevice, CONST D3DDDIARG_DEPTHFILL* pData)
|
---|
4045 | {
|
---|
4046 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4047 | AssertBreakpoint();
|
---|
4048 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4049 | return E_FAIL;
|
---|
4050 | }
|
---|
4051 | static HRESULT APIENTRY vboxWddmDDevCreateQuery(HANDLE hDevice, D3DDDIARG_CREATEQUERY* pData)
|
---|
4052 | {
|
---|
4053 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4054 | AssertBreakpoint();
|
---|
4055 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4056 | return E_FAIL;
|
---|
4057 | }
|
---|
4058 | static HRESULT APIENTRY vboxWddmDDevDestroyQuery(HANDLE hDevice, HANDLE hQuery)
|
---|
4059 | {
|
---|
4060 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4061 | AssertBreakpoint();
|
---|
4062 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4063 | return E_FAIL;
|
---|
4064 | }
|
---|
4065 | static HRESULT APIENTRY vboxWddmDDevIssueQuery(HANDLE hDevice, CONST D3DDDIARG_ISSUEQUERY* pData)
|
---|
4066 | {
|
---|
4067 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4068 | AssertBreakpoint();
|
---|
4069 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4070 | return E_FAIL;
|
---|
4071 | }
|
---|
4072 | static HRESULT APIENTRY vboxWddmDDevGetQueryData(HANDLE hDevice, CONST D3DDDIARG_GETQUERYDATA* pData)
|
---|
4073 | {
|
---|
4074 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4075 | AssertBreakpoint();
|
---|
4076 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4077 | return E_FAIL;
|
---|
4078 | }
|
---|
4079 | static HRESULT APIENTRY vboxWddmDDevSetRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETRENDERTARGET* pData)
|
---|
4080 | {
|
---|
4081 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4082 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4083 | Assert(pDevice);
|
---|
4084 | Assert(pDevice->pDevice9If);
|
---|
4085 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hRenderTarget;
|
---|
4086 | Assert(pRc);
|
---|
4087 | Assert(pData->SubResourceIndex < pRc->cAllocations);
|
---|
4088 | IDirect3DSurface9 *pD3D9Surf = (IDirect3DSurface9*)pRc->aAllocations[pData->SubResourceIndex].pD3DIf;
|
---|
4089 | Assert(pD3D9Surf);
|
---|
4090 | HRESULT hr = pDevice->pDevice9If->SetRenderTarget(pData->RenderTargetIndex, pD3D9Surf);
|
---|
4091 | Assert(hr == S_OK);
|
---|
4092 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4093 | return hr;
|
---|
4094 | }
|
---|
4095 | static HRESULT APIENTRY vboxWddmDDevSetDepthStencil(HANDLE hDevice, CONST D3DDDIARG_SETDEPTHSTENCIL* pData)
|
---|
4096 | {
|
---|
4097 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4098 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4099 | Assert(pDevice);
|
---|
4100 | Assert(pDevice->pDevice9If);
|
---|
4101 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hZBuffer;
|
---|
4102 | IDirect3DSurface9 *pD3D9Surf = NULL;
|
---|
4103 | if (pRc)
|
---|
4104 | {
|
---|
4105 | Assert(pRc->cAllocations == 1);
|
---|
4106 | pD3D9Surf = (IDirect3DSurface9*)pRc->aAllocations[0].pD3DIf;
|
---|
4107 | Assert(pD3D9Surf);
|
---|
4108 | }
|
---|
4109 | HRESULT hr = pDevice->pDevice9If->SetDepthStencilSurface(pD3D9Surf);
|
---|
4110 | Assert(hr == S_OK);
|
---|
4111 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4112 | return hr;
|
---|
4113 | }
|
---|
4114 | static HRESULT APIENTRY vboxWddmDDevGenerateMipSubLevels(HANDLE hDevice, CONST D3DDDIARG_GENERATEMIPSUBLEVELS* pData)
|
---|
4115 | {
|
---|
4116 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4117 | AssertBreakpoint();
|
---|
4118 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4119 | return E_FAIL;
|
---|
4120 | }
|
---|
4121 | static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConstI(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONSTI* pData, CONST INT* pRegisters)
|
---|
4122 | {
|
---|
4123 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4124 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4125 | Assert(pDevice);
|
---|
4126 | Assert(pDevice->pDevice9If);
|
---|
4127 | HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantI(pData->Register, pRegisters, pData->Count);
|
---|
4128 | Assert(hr == S_OK);
|
---|
4129 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4130 | return hr;
|
---|
4131 | }
|
---|
4132 | static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConstB(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONSTB* pData, CONST BOOL* pRegisters)
|
---|
4133 | {
|
---|
4134 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4135 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4136 | Assert(pDevice);
|
---|
4137 | Assert(pDevice->pDevice9If);
|
---|
4138 | HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantB(pData->Register, pRegisters, pData->Count);
|
---|
4139 | Assert(hr == S_OK);
|
---|
4140 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4141 | return hr;
|
---|
4142 | }
|
---|
4143 | static HRESULT APIENTRY vboxWddmDDevCreatePixelShader(HANDLE hDevice, D3DDDIARG_CREATEPIXELSHADER* pData, CONST UINT* pCode)
|
---|
4144 | {
|
---|
4145 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4146 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4147 | Assert(pDevice);
|
---|
4148 | Assert(pDevice->pDevice9If);
|
---|
4149 | IDirect3DPixelShader9 *pShader;
|
---|
4150 | Assert(*((UINT*)((uint8_t*)pCode + pData->CodeSize-4)) == 0x0000FFFF /* end token */);
|
---|
4151 | HRESULT hr = pDevice->pDevice9If->CreatePixelShader((const DWORD *)pCode, &pShader);
|
---|
4152 | Assert(hr == S_OK);
|
---|
4153 | if (hr == S_OK)
|
---|
4154 | {
|
---|
4155 | Assert(pShader);
|
---|
4156 | pData->ShaderHandle = pShader;
|
---|
4157 | }
|
---|
4158 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4159 | return hr;
|
---|
4160 | }
|
---|
4161 | static HRESULT APIENTRY vboxWddmDDevDeletePixelShader(HANDLE hDevice, HANDLE hShaderHandle)
|
---|
4162 | {
|
---|
4163 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4164 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4165 | Assert(pDevice);
|
---|
4166 | Assert(pDevice->pDevice9If);
|
---|
4167 | IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle;
|
---|
4168 | HRESULT hr = S_OK;
|
---|
4169 | pShader->Release();
|
---|
4170 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
|
---|
4171 | return hr;
|
---|
4172 | }
|
---|
4173 | static HRESULT APIENTRY vboxWddmDDevCreateDecodeDevice(HANDLE hDevice, D3DDDIARG_CREATEDECODEDEVICE* pData)
|
---|
4174 | {
|
---|
4175 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4176 | AssertBreakpoint();
|
---|
4177 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4178 | return E_FAIL;
|
---|
4179 | }
|
---|
4180 | static HRESULT APIENTRY vboxWddmDDevDestroyDecodeDevice(HANDLE hDevice, HANDLE hDecodeDevice)
|
---|
4181 | {
|
---|
4182 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4183 | AssertBreakpoint();
|
---|
4184 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4185 | return E_FAIL;
|
---|
4186 | }
|
---|
4187 | static HRESULT APIENTRY vboxWddmDDevSetDecodeRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETDECODERENDERTARGET* pData)
|
---|
4188 | {
|
---|
4189 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4190 | AssertBreakpoint();
|
---|
4191 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4192 | return E_FAIL;
|
---|
4193 | }
|
---|
4194 | static HRESULT APIENTRY vboxWddmDDevDecodeBeginFrame(HANDLE hDevice, D3DDDIARG_DECODEBEGINFRAME* pData)
|
---|
4195 | {
|
---|
4196 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4197 | AssertBreakpoint();
|
---|
4198 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4199 | return E_FAIL;
|
---|
4200 | }
|
---|
4201 | static HRESULT APIENTRY vboxWddmDDevDecodeEndFrame(HANDLE hDevice, D3DDDIARG_DECODEENDFRAME* pData)
|
---|
4202 | {
|
---|
4203 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4204 | AssertBreakpoint();
|
---|
4205 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4206 | return E_FAIL;
|
---|
4207 | }
|
---|
4208 | static HRESULT APIENTRY vboxWddmDDevDecodeExecute(HANDLE hDevice, CONST D3DDDIARG_DECODEEXECUTE* pData)
|
---|
4209 | {
|
---|
4210 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4211 | AssertBreakpoint();
|
---|
4212 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4213 | return E_FAIL;
|
---|
4214 | }
|
---|
4215 | static HRESULT APIENTRY vboxWddmDDevDecodeExtensionExecute(HANDLE hDevice, CONST D3DDDIARG_DECODEEXTENSIONEXECUTE* pData)
|
---|
4216 | {
|
---|
4217 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4218 | AssertBreakpoint();
|
---|
4219 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4220 | return E_FAIL;
|
---|
4221 | }
|
---|
4222 | static HRESULT APIENTRY vboxWddmDDevCreateVideoProcessDevice(HANDLE hDevice, D3DDDIARG_CREATEVIDEOPROCESSDEVICE* pData)
|
---|
4223 | {
|
---|
4224 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4225 | AssertBreakpoint();
|
---|
4226 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4227 | return E_FAIL;
|
---|
4228 | }
|
---|
4229 | static HRESULT APIENTRY vboxWddmDDevDestroyVideoProcessDevice(HANDLE hDevice, HANDLE hVideoProcessor)
|
---|
4230 | {
|
---|
4231 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4232 | AssertBreakpoint();
|
---|
4233 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4234 | return E_FAIL;
|
---|
4235 | }
|
---|
4236 | static HRESULT APIENTRY vboxWddmDDevVideoProcessBeginFrame(HANDLE hDevice, HANDLE hVideoProcess)
|
---|
4237 | {
|
---|
4238 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4239 | AssertBreakpoint();
|
---|
4240 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4241 | return E_FAIL;
|
---|
4242 | }
|
---|
4243 | static HRESULT APIENTRY vboxWddmDDevVideoProcessEndFrame(HANDLE hDevice, D3DDDIARG_VIDEOPROCESSENDFRAME* pData)
|
---|
4244 | {
|
---|
4245 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4246 | AssertBreakpoint();
|
---|
4247 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4248 | return E_FAIL;
|
---|
4249 | }
|
---|
4250 | static HRESULT APIENTRY vboxWddmDDevSetVideoProcessRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETVIDEOPROCESSRENDERTARGET* pData)
|
---|
4251 | {
|
---|
4252 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4253 | AssertBreakpoint();
|
---|
4254 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4255 | return E_FAIL;
|
---|
4256 | }
|
---|
4257 | static HRESULT APIENTRY vboxWddmDDevVideoProcessBlt(HANDLE hDevice, CONST D3DDDIARG_VIDEOPROCESSBLT* pData)
|
---|
4258 | {
|
---|
4259 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4260 | AssertBreakpoint();
|
---|
4261 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4262 | return E_FAIL;
|
---|
4263 | }
|
---|
4264 | static HRESULT APIENTRY vboxWddmDDevCreateExtensionDevice(HANDLE hDevice, D3DDDIARG_CREATEEXTENSIONDEVICE* pData)
|
---|
4265 | {
|
---|
4266 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4267 | AssertBreakpoint();
|
---|
4268 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4269 | return E_FAIL;
|
---|
4270 | }
|
---|
4271 | static HRESULT APIENTRY vboxWddmDDevDestroyExtensionDevice(HANDLE hDevice, HANDLE hExtension)
|
---|
4272 | {
|
---|
4273 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4274 | AssertBreakpoint();
|
---|
4275 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4276 | return E_FAIL;
|
---|
4277 | }
|
---|
4278 | static HRESULT APIENTRY vboxWddmDDevExtensionExecute(HANDLE hDevice, CONST D3DDDIARG_EXTENSIONEXECUTE* pData)
|
---|
4279 | {
|
---|
4280 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4281 | AssertBreakpoint();
|
---|
4282 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4283 | return E_FAIL;
|
---|
4284 | }
|
---|
4285 | static HRESULT APIENTRY vboxWddmDDevDestroyDevice(IN HANDLE hDevice)
|
---|
4286 | {
|
---|
4287 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4288 |
|
---|
4289 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4290 | PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;
|
---|
4291 | if (pDevice->pDevice9If)
|
---|
4292 | {
|
---|
4293 | pDevice->pDevice9If->Release();
|
---|
4294 | Assert(pDevice->hWnd);
|
---|
4295 | HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pDevice->hWnd);
|
---|
4296 | Assert(tmpHr == S_OK);
|
---|
4297 | }
|
---|
4298 | HRESULT hr = vboxDispCmCtxDestroy(pDevice, &pDevice->DefaultContext);
|
---|
4299 | Assert(hr == S_OK);
|
---|
4300 | if (hr == S_OK)
|
---|
4301 | RTMemFree(pDevice);
|
---|
4302 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4303 | return hr;
|
---|
4304 | }
|
---|
4305 |
|
---|
4306 | AssertCompile(sizeof (RECT) == sizeof (D3DDDIRECT));
|
---|
4307 | AssertCompile(RT_SIZEOFMEMB(RECT, left) == RT_SIZEOFMEMB(D3DDDIRECT, left));
|
---|
4308 | AssertCompile(RT_SIZEOFMEMB(RECT, right) == RT_SIZEOFMEMB(D3DDDIRECT, right));
|
---|
4309 | AssertCompile(RT_SIZEOFMEMB(RECT, top) == RT_SIZEOFMEMB(D3DDDIRECT, top));
|
---|
4310 | AssertCompile(RT_SIZEOFMEMB(RECT, bottom) == RT_SIZEOFMEMB(D3DDDIRECT, bottom));
|
---|
4311 | AssertCompile(RT_OFFSETOF(RECT, left) == RT_OFFSETOF(D3DDDIRECT, left));
|
---|
4312 | AssertCompile(RT_OFFSETOF(RECT, right) == RT_OFFSETOF(D3DDDIRECT, right));
|
---|
4313 | AssertCompile(RT_OFFSETOF(RECT, top) == RT_OFFSETOF(D3DDDIRECT, top));
|
---|
4314 | AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(D3DDDIRECT, bottom));
|
---|
4315 |
|
---|
4316 | static HRESULT APIENTRY vboxWddmDDevCreateOverlay(HANDLE hDevice, D3DDDIARG_CREATEOVERLAY* pData)
|
---|
4317 | {
|
---|
4318 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4319 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4320 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->OverlayInfo.hResource;
|
---|
4321 | Assert(pRc);
|
---|
4322 | Assert(pRc->cAllocations > pData->OverlayInfo.SubResourceIndex);
|
---|
4323 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->OverlayInfo.SubResourceIndex];
|
---|
4324 | HRESULT hr = S_OK;
|
---|
4325 | PVBOXWDDMDISP_OVERLAY pOverlay = (PVBOXWDDMDISP_OVERLAY)RTMemAllocZ(sizeof (VBOXWDDMDISP_OVERLAY));
|
---|
4326 | Assert(pOverlay);
|
---|
4327 | if (pOverlay)
|
---|
4328 | {
|
---|
4329 | VBOXWDDM_OVERLAY_INFO OurInfo;
|
---|
4330 | OurInfo.OverlayDesc.DstColorKeyLow = pData->OverlayInfo.DstColorKeyLow;
|
---|
4331 | OurInfo.OverlayDesc.DstColorKeyHigh = pData->OverlayInfo.DstColorKeyHigh;
|
---|
4332 | OurInfo.OverlayDesc.SrcColorKeyLow = pData->OverlayInfo.SrcColorKeyLow;
|
---|
4333 | OurInfo.OverlayDesc.SrcColorKeyHigh = pData->OverlayInfo.SrcColorKeyHigh;
|
---|
4334 | OurInfo.OverlayDesc.fFlags = pData->OverlayInfo.Flags.Value;
|
---|
4335 | vboxWddmDirtyRegionClear(&OurInfo.DirtyRegion);
|
---|
4336 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4337 | vboxWddmDirtyRegionUnite(&OurInfo.DirtyRegion, &pAlloc->DirtyRegion);
|
---|
4338 | D3DDDICB_CREATEOVERLAY OverInfo;
|
---|
4339 | OverInfo.VidPnSourceId = pData->VidPnSourceId;
|
---|
4340 | OverInfo.OverlayInfo.hAllocation = pAlloc->hAllocation;
|
---|
4341 | Assert(pAlloc->hAllocation);
|
---|
4342 | OverInfo.OverlayInfo.DstRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.DstRect);
|
---|
4343 | OverInfo.OverlayInfo.SrcRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.SrcRect);
|
---|
4344 | OverInfo.OverlayInfo.pPrivateDriverData = &OurInfo;
|
---|
4345 | OverInfo.OverlayInfo.PrivateDriverDataSize = sizeof (OurInfo);
|
---|
4346 | OverInfo.hKernelOverlay = NULL; /* <-- out */
|
---|
4347 | #ifndef VBOXWDDMOVERLAY_TEST
|
---|
4348 | hr = pDevice->RtCallbacks.pfnCreateOverlayCb(pDevice->hDevice, &OverInfo);
|
---|
4349 | Assert(hr == S_OK);
|
---|
4350 | if (hr == S_OK)
|
---|
4351 | {
|
---|
4352 | Assert(OverInfo.hKernelOverlay);
|
---|
4353 | pOverlay->hOverlay = OverInfo.hKernelOverlay;
|
---|
4354 | pOverlay->VidPnSourceId = pData->VidPnSourceId;
|
---|
4355 |
|
---|
4356 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4357 | if (!pAlloc->LockInfo.cLocks)
|
---|
4358 | {
|
---|
4359 | /* we have reported the dirty rect, may clear it if no locks are pending currently */
|
---|
4360 | vboxWddmDirtyRegionClear(&pAlloc->DirtyRegion);
|
---|
4361 | }
|
---|
4362 |
|
---|
4363 | pData->hOverlay = pOverlay;
|
---|
4364 | }
|
---|
4365 | else
|
---|
4366 | {
|
---|
4367 | RTMemFree(pOverlay);
|
---|
4368 | }
|
---|
4369 | #else
|
---|
4370 | pData->hOverlay = pOverlay;
|
---|
4371 | #endif
|
---|
4372 | }
|
---|
4373 | else
|
---|
4374 | hr = E_OUTOFMEMORY;
|
---|
4375 |
|
---|
4376 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4377 | return hr;
|
---|
4378 | }
|
---|
4379 | static HRESULT APIENTRY vboxWddmDDevUpdateOverlay(HANDLE hDevice, CONST D3DDDIARG_UPDATEOVERLAY* pData)
|
---|
4380 | {
|
---|
4381 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4382 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4383 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->OverlayInfo.hResource;
|
---|
4384 | Assert(pRc);
|
---|
4385 | Assert(pRc->cAllocations > pData->OverlayInfo.SubResourceIndex);
|
---|
4386 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->OverlayInfo.SubResourceIndex];
|
---|
4387 | HRESULT hr = S_OK;
|
---|
4388 | PVBOXWDDMDISP_OVERLAY pOverlay = (PVBOXWDDMDISP_OVERLAY)pData->hOverlay;
|
---|
4389 | VBOXWDDM_OVERLAY_INFO OurInfo;
|
---|
4390 | OurInfo.OverlayDesc.DstColorKeyLow = pData->OverlayInfo.DstColorKeyLow;
|
---|
4391 | OurInfo.OverlayDesc.DstColorKeyHigh = pData->OverlayInfo.DstColorKeyHigh;
|
---|
4392 | OurInfo.OverlayDesc.SrcColorKeyLow = pData->OverlayInfo.SrcColorKeyLow;
|
---|
4393 | OurInfo.OverlayDesc.SrcColorKeyHigh = pData->OverlayInfo.SrcColorKeyHigh;
|
---|
4394 | OurInfo.OverlayDesc.fFlags = pData->OverlayInfo.Flags.Value;
|
---|
4395 | vboxWddmDirtyRegionClear(&OurInfo.DirtyRegion);
|
---|
4396 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4397 | vboxWddmDirtyRegionUnite(&OurInfo.DirtyRegion, &pAlloc->DirtyRegion);
|
---|
4398 | D3DDDICB_UPDATEOVERLAY OverInfo;
|
---|
4399 | OverInfo.hKernelOverlay = pOverlay->hOverlay;
|
---|
4400 | OverInfo.OverlayInfo.hAllocation = pAlloc->hAllocation;
|
---|
4401 | OverInfo.OverlayInfo.DstRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.DstRect);
|
---|
4402 | OverInfo.OverlayInfo.SrcRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.SrcRect);
|
---|
4403 | OverInfo.OverlayInfo.pPrivateDriverData = &OurInfo;
|
---|
4404 | OverInfo.OverlayInfo.PrivateDriverDataSize = sizeof (OurInfo);
|
---|
4405 | #ifndef VBOXWDDMOVERLAY_TEST
|
---|
4406 | hr = pDevice->RtCallbacks.pfnUpdateOverlayCb(pDevice->hDevice, &OverInfo);
|
---|
4407 | Assert(hr == S_OK);
|
---|
4408 | if (hr == S_OK)
|
---|
4409 | #endif
|
---|
4410 | {
|
---|
4411 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4412 | if (!pAlloc->LockInfo.cLocks)
|
---|
4413 | {
|
---|
4414 | /* we have reported the dirty rect, may clear it if no locks are pending currently */
|
---|
4415 | vboxWddmDirtyRegionClear(&pAlloc->DirtyRegion);
|
---|
4416 | }
|
---|
4417 | }
|
---|
4418 |
|
---|
4419 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4420 | return hr;
|
---|
4421 | }
|
---|
4422 | static HRESULT APIENTRY vboxWddmDDevFlipOverlay(HANDLE hDevice, CONST D3DDDIARG_FLIPOVERLAY* pData)
|
---|
4423 | {
|
---|
4424 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4425 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4426 | PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSource;
|
---|
4427 | Assert(pRc);
|
---|
4428 | Assert(pRc->cAllocations > pData->SourceIndex);
|
---|
4429 | PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SourceIndex];
|
---|
4430 | HRESULT hr = S_OK;
|
---|
4431 | PVBOXWDDMDISP_OVERLAY pOverlay = (PVBOXWDDMDISP_OVERLAY)pData->hOverlay;
|
---|
4432 | VBOXWDDM_OVERLAYFLIP_INFO OurInfo;
|
---|
4433 | vboxWddmDirtyRegionClear(&OurInfo.DirtyRegion);
|
---|
4434 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4435 | vboxWddmDirtyRegionUnite(&OurInfo.DirtyRegion, &pAlloc->DirtyRegion);
|
---|
4436 | D3DDDICB_FLIPOVERLAY OverInfo;
|
---|
4437 | OverInfo.hKernelOverlay = pOverlay->hOverlay;
|
---|
4438 | OverInfo.hSource = pAlloc->hAllocation;
|
---|
4439 | OverInfo.pPrivateDriverData = &OurInfo;
|
---|
4440 | OverInfo.PrivateDriverDataSize = sizeof (OurInfo);
|
---|
4441 | #ifndef VBOXWDDMOVERLAY_TEST
|
---|
4442 | hr = pDevice->RtCallbacks.pfnFlipOverlayCb(pDevice->hDevice, &OverInfo);
|
---|
4443 | Assert(hr == S_OK);
|
---|
4444 | if (hr == S_OK)
|
---|
4445 | #endif
|
---|
4446 | {
|
---|
4447 | Assert(!pAlloc->LockInfo.cLocks);
|
---|
4448 | if (!pAlloc->LockInfo.cLocks)
|
---|
4449 | {
|
---|
4450 | /* we have reported the dirty rect, may clear it if no locks are pending currently */
|
---|
4451 | vboxWddmDirtyRegionClear(&pAlloc->DirtyRegion);
|
---|
4452 | }
|
---|
4453 | }
|
---|
4454 |
|
---|
4455 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4456 | return hr;
|
---|
4457 | }
|
---|
4458 | static HRESULT APIENTRY vboxWddmDDevGetOverlayColorControls(HANDLE hDevice, D3DDDIARG_GETOVERLAYCOLORCONTROLS* pData)
|
---|
4459 | {
|
---|
4460 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4461 | AssertBreakpoint();
|
---|
4462 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4463 | return E_FAIL;
|
---|
4464 | }
|
---|
4465 | static HRESULT APIENTRY vboxWddmDDevSetOverlayColorControls(HANDLE hDevice, CONST D3DDDIARG_SETOVERLAYCOLORCONTROLS* pData)
|
---|
4466 | {
|
---|
4467 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4468 | AssertBreakpoint();
|
---|
4469 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4470 | return E_FAIL;
|
---|
4471 | }
|
---|
4472 | static HRESULT APIENTRY vboxWddmDDevDestroyOverlay(HANDLE hDevice, CONST D3DDDIARG_DESTROYOVERLAY* pData)
|
---|
4473 | {
|
---|
4474 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4475 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4476 | PVBOXWDDMDISP_OVERLAY pOverlay = (PVBOXWDDMDISP_OVERLAY)pData->hOverlay;
|
---|
4477 | D3DDDICB_DESTROYOVERLAY OverInfo;
|
---|
4478 | OverInfo.hKernelOverlay = pOverlay->hOverlay;
|
---|
4479 | #ifndef VBOXWDDMOVERLAY_TEST
|
---|
4480 | HRESULT hr = pDevice->RtCallbacks.pfnDestroyOverlayCb(pDevice->hDevice, &OverInfo);
|
---|
4481 | Assert(hr == S_OK);
|
---|
4482 | if (hr == S_OK)
|
---|
4483 | #else
|
---|
4484 | HRESULT hr = S_OK;
|
---|
4485 | #endif
|
---|
4486 | {
|
---|
4487 | RTMemFree(pOverlay);
|
---|
4488 | }
|
---|
4489 |
|
---|
4490 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4491 | return hr;
|
---|
4492 | }
|
---|
4493 | static HRESULT APIENTRY vboxWddmDDevQueryResourceResidency(HANDLE hDevice, CONST D3DDDIARG_QUERYRESOURCERESIDENCY* pData)
|
---|
4494 | {
|
---|
4495 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4496 | AssertBreakpoint();
|
---|
4497 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4498 | return E_FAIL;
|
---|
4499 | }
|
---|
4500 |
|
---|
4501 | static HRESULT vboxAllocationInit(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DDDI_OPENALLOCATIONINFO *pInfo)
|
---|
4502 | {
|
---|
4503 | HRESULT hr = S_OK;
|
---|
4504 | pAlloc->hAllocation = pInfo->hAllocation;
|
---|
4505 | Assert(pInfo->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO));
|
---|
4506 | Assert(pInfo->pPrivateDriverData);
|
---|
4507 | if (pInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO))
|
---|
4508 | {
|
---|
4509 | PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pInfo->pPrivateDriverData;
|
---|
4510 | pAlloc->enmType = pAllocInfo->enmType;
|
---|
4511 | Assert(pAllocInfo->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
|
---|
4512 | || VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE
|
---|
4513 | || VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE);
|
---|
4514 | pAlloc->pvMem = NULL;
|
---|
4515 | pAlloc->SurfDesc = pAllocInfo->SurfDesc;
|
---|
4516 | }
|
---|
4517 | else
|
---|
4518 | {
|
---|
4519 | vboxVDbgPrintR((__FUNCTION__": ERROR: PrivateDriverDataSize(%d) < (%d)\n", pInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO)));
|
---|
4520 | hr = E_INVALIDARG;
|
---|
4521 | }
|
---|
4522 | return hr;
|
---|
4523 | }
|
---|
4524 |
|
---|
4525 | static HRESULT APIENTRY vboxWddmDDevOpenResource(HANDLE hDevice, D3DDDIARG_OPENRESOURCE* pData)
|
---|
4526 | {
|
---|
4527 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4528 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
|
---|
4529 | HRESULT hr = S_OK;
|
---|
4530 |
|
---|
4531 | Assert(pDevice);
|
---|
4532 | Assert(pData->NumAllocations);
|
---|
4533 | PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pData->NumAllocations);
|
---|
4534 | Assert(pRc);
|
---|
4535 | if (pRc)
|
---|
4536 | {
|
---|
4537 | pRc->hResource = pData->hResource;
|
---|
4538 | pRc->hKMResource = pData->hKMResource;
|
---|
4539 | pRc->pDevice = pDevice;
|
---|
4540 | pRc->RcDesc.enmRotation = pData->Rotation;
|
---|
4541 | pRc->fFlags = VBOXWDDM_RESOURCE_F_OPENNED;
|
---|
4542 | if (!pData->pPrivateDriverData || !pData->PrivateDriverDataSize)
|
---|
4543 | {
|
---|
4544 | /* this is a "standard" allocation resource */
|
---|
4545 |
|
---|
4546 | /* both should be actually zero */
|
---|
4547 | Assert(!pData->pPrivateDriverData && !pData->PrivateDriverDataSize);
|
---|
4548 | pRc->RcDesc.enmPool = D3DDDIPOOL_LOCALVIDMEM;
|
---|
4549 | pRc->RcDesc.enmMultisampleType = D3DDDIMULTISAMPLE_NONE;
|
---|
4550 | pRc->RcDesc.MultisampleQuality = 0;
|
---|
4551 | pRc->RcDesc.MipLevels = 0;
|
---|
4552 | pRc->RcDesc.Fvf;
|
---|
4553 | pRc->RcDesc.fFlags.Value = 0;
|
---|
4554 |
|
---|
4555 | Assert(pData->NumAllocations);
|
---|
4556 | D3DDDI_OPENALLOCATIONINFO* pDdiAllocInfo = &pData->pOpenAllocationInfo[0];
|
---|
4557 | Assert(pDdiAllocInfo->pPrivateDriverData);
|
---|
4558 | Assert(pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO));
|
---|
4559 | if (pDdiAllocInfo->pPrivateDriverData && pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO))
|
---|
4560 | {
|
---|
4561 | PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocInfo->pPrivateDriverData;
|
---|
4562 | switch(pAllocInfo->enmType)
|
---|
4563 | {
|
---|
4564 | case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE:
|
---|
4565 | pRc->RcDesc.fFlags.Primary = 1;
|
---|
4566 | case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
|
---|
4567 | case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE:
|
---|
4568 | pRc->RcDesc.enmFormat = pAllocInfo->SurfDesc.format;
|
---|
4569 | pRc->RcDesc.VidPnSourceId = pAllocInfo->SurfDesc.VidPnSourceId;
|
---|
4570 | pRc->RcDesc.RefreshRate = pAllocInfo->SurfDesc.RefreshRate;
|
---|
4571 | break;
|
---|
4572 | default:
|
---|
4573 | AssertBreakpoint();
|
---|
4574 | hr = E_INVALIDARG;
|
---|
4575 | }
|
---|
4576 | }
|
---|
4577 | else
|
---|
4578 | hr = E_INVALIDARG;
|
---|
4579 | }
|
---|
4580 | else
|
---|
4581 | {
|
---|
4582 | AssertBreakpoint(); /* <-- need to test that */
|
---|
4583 |
|
---|
4584 | /* this is a "generic" resource whose creation is initiaded by the UMD */
|
---|
4585 | Assert(pData->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO));
|
---|
4586 | if (pData->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO))
|
---|
4587 | {
|
---|
4588 | VBOXWDDM_RCINFO *pRcInfo = (VBOXWDDM_RCINFO*)pData->pPrivateDriverData;
|
---|
4589 | Assert(pRcInfo->fFlags == VBOXWDDM_RESOURCE_F_TYPE_GENERIC);
|
---|
4590 | Assert(pRcInfo->cAllocInfos == pData->NumAllocations);
|
---|
4591 | pRc->fFlags = pRcInfo->fFlags | VBOXWDDM_RESOURCE_F_OPENNED;
|
---|
4592 | pRc->RcDesc = pRcInfo->RcDesc;
|
---|
4593 | pRc->cAllocations = pData->NumAllocations;
|
---|
4594 | }
|
---|
4595 | else
|
---|
4596 | hr = E_INVALIDARG;
|
---|
4597 | }
|
---|
4598 |
|
---|
4599 | if (hr == S_OK)
|
---|
4600 | {
|
---|
4601 | for (UINT i = 0; i < pData->NumAllocations; ++i)
|
---|
4602 | {
|
---|
4603 | hr = vboxAllocationInit(&pRc->aAllocations[i], &pData->pOpenAllocationInfo[i]);
|
---|
4604 | Assert(hr == S_OK);
|
---|
4605 | if (hr != S_OK)
|
---|
4606 | break;
|
---|
4607 | }
|
---|
4608 | }
|
---|
4609 |
|
---|
4610 | if (hr == S_OK)
|
---|
4611 | pData->hResource = pRc;
|
---|
4612 | else
|
---|
4613 | vboxResourceFree(pRc);
|
---|
4614 | }
|
---|
4615 | else
|
---|
4616 | {
|
---|
4617 | vboxVDbgPrintR((__FUNCTION__": vboxResourceAlloc failed for hDevice(0x%p), NumAllocations(%d)\n", hDevice, pData->NumAllocations));
|
---|
4618 | hr = E_OUTOFMEMORY;
|
---|
4619 | }
|
---|
4620 |
|
---|
4621 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4622 | return hr;
|
---|
4623 | }
|
---|
4624 | static HRESULT APIENTRY vboxWddmDDevGetCaptureAllocationHandle(HANDLE hDevice, D3DDDIARG_GETCAPTUREALLOCATIONHANDLE* pData)
|
---|
4625 | {
|
---|
4626 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4627 | AssertBreakpoint();
|
---|
4628 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4629 | return E_FAIL;
|
---|
4630 | }
|
---|
4631 |
|
---|
4632 | static HRESULT APIENTRY vboxWddmDDevCaptureToSysMem(HANDLE hDevice, CONST D3DDDIARG_CAPTURETOSYSMEM* pData)
|
---|
4633 | {
|
---|
4634 | vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4635 | AssertBreakpoint();
|
---|
4636 | vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
|
---|
4637 | return E_FAIL;
|
---|
4638 | }
|
---|
4639 |
|
---|
4640 | static HRESULT APIENTRY vboxWddmDispCreateDevice (IN HANDLE hAdapter, IN D3DDDIARG_CREATEDEVICE* pCreateData)
|
---|
4641 | {
|
---|
4642 | HRESULT hr = S_OK;
|
---|
4643 | vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p), Interface(%d), Version(%d)\n", hAdapter, pCreateData->Interface, pCreateData->Version));
|
---|
4644 |
|
---|
4645 | // AssertBreakpoint();
|
---|
4646 |
|
---|
4647 | PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)RTMemAllocZ(sizeof (VBOXWDDMDISP_DEVICE));
|
---|
4648 | if (pDevice)
|
---|
4649 | {
|
---|
4650 | PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
|
---|
4651 |
|
---|
4652 | pDevice->hDevice = pCreateData->hDevice;
|
---|
4653 | pDevice->pAdapter = pAdapter;
|
---|
4654 | pDevice->u32IfVersion = pCreateData->Interface;
|
---|
4655 | pDevice->uRtVersion = pCreateData->Version;
|
---|
4656 | pDevice->RtCallbacks = *pCreateData->pCallbacks;
|
---|
4657 | pDevice->pvCmdBuffer = pCreateData->pCommandBuffer;
|
---|
4658 | pDevice->cbCmdBuffer = pCreateData->CommandBufferSize;
|
---|
4659 | pDevice->fFlags = pCreateData->Flags;
|
---|
4660 | /* Set Viewport to some default values */
|
---|
4661 | pDevice->ViewPort.X = 0;
|
---|
4662 | pDevice->ViewPort.Y = 0;
|
---|
4663 | pDevice->ViewPort.Width = 1;
|
---|
4664 | pDevice->ViewPort.Height = 1;
|
---|
4665 | pDevice->ViewPort.MinZ = 0.;
|
---|
4666 | pDevice->ViewPort.MaxZ = 1.;
|
---|
4667 |
|
---|
4668 | Assert(!pCreateData->AllocationListSize);
|
---|
4669 | Assert(!pCreateData->PatchLocationListSize);
|
---|
4670 |
|
---|
4671 | pCreateData->hDevice = pDevice;
|
---|
4672 |
|
---|
4673 | pCreateData->pDeviceFuncs->pfnSetRenderState = vboxWddmDDevSetRenderState;
|
---|
4674 | pCreateData->pDeviceFuncs->pfnUpdateWInfo = vboxWddmDDevUpdateWInfo;
|
---|
4675 | pCreateData->pDeviceFuncs->pfnValidateDevice = vboxWddmDDevValidateDevice;
|
---|
4676 | pCreateData->pDeviceFuncs->pfnSetTextureStageState = vboxWddmDDevSetTextureStageState;
|
---|
4677 | pCreateData->pDeviceFuncs->pfnSetTexture = vboxWddmDDevSetTexture;
|
---|
4678 | pCreateData->pDeviceFuncs->pfnSetPixelShader = vboxWddmDDevSetPixelShader;
|
---|
4679 | pCreateData->pDeviceFuncs->pfnSetPixelShaderConst = vboxWddmDDevSetPixelShaderConst;
|
---|
4680 | pCreateData->pDeviceFuncs->pfnSetStreamSourceUm = vboxWddmDDevSetStreamSourceUm;
|
---|
4681 | pCreateData->pDeviceFuncs->pfnSetIndices = vboxWddmDDevSetIndices;
|
---|
4682 | pCreateData->pDeviceFuncs->pfnSetIndicesUm = vboxWddmDDevSetIndicesUm;
|
---|
4683 | pCreateData->pDeviceFuncs->pfnDrawPrimitive = vboxWddmDDevDrawPrimitive;
|
---|
4684 | pCreateData->pDeviceFuncs->pfnDrawIndexedPrimitive = vboxWddmDDevDrawIndexedPrimitive;
|
---|
4685 | pCreateData->pDeviceFuncs->pfnDrawRectPatch = vboxWddmDDevDrawRectPatch;
|
---|
4686 | pCreateData->pDeviceFuncs->pfnDrawTriPatch = vboxWddmDDevDrawTriPatch;
|
---|
4687 | pCreateData->pDeviceFuncs->pfnDrawPrimitive2 = vboxWddmDDevDrawPrimitive2;
|
---|
4688 | pCreateData->pDeviceFuncs->pfnDrawIndexedPrimitive2 = vboxWddmDDevDrawIndexedPrimitive2;
|
---|
4689 | pCreateData->pDeviceFuncs->pfnVolBlt = vboxWddmDDevVolBlt;
|
---|
4690 | pCreateData->pDeviceFuncs->pfnBufBlt = vboxWddmDDevBufBlt;
|
---|
4691 | pCreateData->pDeviceFuncs->pfnTexBlt = vboxWddmDDevTexBlt;
|
---|
4692 | pCreateData->pDeviceFuncs->pfnStateSet = vboxWddmDDevStateSet;
|
---|
4693 | pCreateData->pDeviceFuncs->pfnSetPriority = vboxWddmDDevSetPriority;
|
---|
4694 | pCreateData->pDeviceFuncs->pfnClear = vboxWddmDDevClear;
|
---|
4695 | pCreateData->pDeviceFuncs->pfnUpdatePalette = vboxWddmDDevUpdatePalette;
|
---|
4696 | pCreateData->pDeviceFuncs->pfnSetPalette = vboxWddmDDevSetPalette;
|
---|
4697 | pCreateData->pDeviceFuncs->pfnSetVertexShaderConst = vboxWddmDDevSetVertexShaderConst;
|
---|
4698 | pCreateData->pDeviceFuncs->pfnMultiplyTransform = vboxWddmDDevMultiplyTransform;
|
---|
4699 | pCreateData->pDeviceFuncs->pfnSetTransform = vboxWddmDDevSetTransform;
|
---|
4700 | pCreateData->pDeviceFuncs->pfnSetViewport = vboxWddmDDevSetViewport;
|
---|
4701 | pCreateData->pDeviceFuncs->pfnSetZRange = vboxWddmDDevSetZRange;
|
---|
4702 | pCreateData->pDeviceFuncs->pfnSetMaterial = vboxWddmDDevSetMaterial;
|
---|
4703 | pCreateData->pDeviceFuncs->pfnSetLight = vboxWddmDDevSetLight;
|
---|
4704 | pCreateData->pDeviceFuncs->pfnCreateLight = vboxWddmDDevCreateLight;
|
---|
4705 | pCreateData->pDeviceFuncs->pfnDestroyLight = vboxWddmDDevDestroyLight;
|
---|
4706 | pCreateData->pDeviceFuncs->pfnSetClipPlane = vboxWddmDDevSetClipPlane;
|
---|
4707 | pCreateData->pDeviceFuncs->pfnGetInfo = vboxWddmDDevGetInfo;
|
---|
4708 | pCreateData->pDeviceFuncs->pfnLock = vboxWddmDDevLock;
|
---|
4709 | pCreateData->pDeviceFuncs->pfnUnlock = vboxWddmDDevUnlock;
|
---|
4710 | pCreateData->pDeviceFuncs->pfnCreateResource = vboxWddmDDevCreateResource;
|
---|
4711 | pCreateData->pDeviceFuncs->pfnDestroyResource = vboxWddmDDevDestroyResource;
|
---|
4712 | pCreateData->pDeviceFuncs->pfnSetDisplayMode = vboxWddmDDevSetDisplayMode;
|
---|
4713 | pCreateData->pDeviceFuncs->pfnPresent = vboxWddmDDevPresent;
|
---|
4714 | pCreateData->pDeviceFuncs->pfnFlush = vboxWddmDDevFlush;
|
---|
4715 | pCreateData->pDeviceFuncs->pfnCreateVertexShaderFunc = vboxWddmDDevCreateVertexShaderFunc;
|
---|
4716 | pCreateData->pDeviceFuncs->pfnDeleteVertexShaderFunc = vboxWddmDDevDeleteVertexShaderFunc;
|
---|
4717 | pCreateData->pDeviceFuncs->pfnSetVertexShaderFunc = vboxWddmDDevSetVertexShaderFunc;
|
---|
4718 | pCreateData->pDeviceFuncs->pfnCreateVertexShaderDecl = vboxWddmDDevCreateVertexShaderDecl;
|
---|
4719 | pCreateData->pDeviceFuncs->pfnDeleteVertexShaderDecl = vboxWddmDDevDeleteVertexShaderDecl;
|
---|
4720 | pCreateData->pDeviceFuncs->pfnSetVertexShaderDecl = vboxWddmDDevSetVertexShaderDecl;
|
---|
4721 | pCreateData->pDeviceFuncs->pfnSetVertexShaderConstI = vboxWddmDDevSetVertexShaderConstI;
|
---|
4722 | pCreateData->pDeviceFuncs->pfnSetVertexShaderConstB = vboxWddmDDevSetVertexShaderConstB;
|
---|
4723 | pCreateData->pDeviceFuncs->pfnSetScissorRect = vboxWddmDDevSetScissorRect;
|
---|
4724 | pCreateData->pDeviceFuncs->pfnSetStreamSource = vboxWddmDDevSetStreamSource;
|
---|
4725 | pCreateData->pDeviceFuncs->pfnSetStreamSourceFreq = vboxWddmDDevSetStreamSourceFreq;
|
---|
4726 | pCreateData->pDeviceFuncs->pfnSetConvolutionKernelMono = vboxWddmDDevSetConvolutionKernelMono;
|
---|
4727 | pCreateData->pDeviceFuncs->pfnComposeRects = vboxWddmDDevComposeRects;
|
---|
4728 | pCreateData->pDeviceFuncs->pfnBlt = vboxWddmDDevBlt;
|
---|
4729 | pCreateData->pDeviceFuncs->pfnColorFill = vboxWddmDDevColorFill;
|
---|
4730 | pCreateData->pDeviceFuncs->pfnDepthFill = vboxWddmDDevDepthFill;
|
---|
4731 | pCreateData->pDeviceFuncs->pfnCreateQuery = vboxWddmDDevCreateQuery;
|
---|
4732 | pCreateData->pDeviceFuncs->pfnDestroyQuery = vboxWddmDDevDestroyQuery;
|
---|
4733 | pCreateData->pDeviceFuncs->pfnIssueQuery = vboxWddmDDevIssueQuery;
|
---|
4734 | pCreateData->pDeviceFuncs->pfnGetQueryData = vboxWddmDDevGetQueryData;
|
---|
4735 | pCreateData->pDeviceFuncs->pfnSetRenderTarget = vboxWddmDDevSetRenderTarget;
|
---|
4736 | pCreateData->pDeviceFuncs->pfnSetDepthStencil = vboxWddmDDevSetDepthStencil;
|
---|
4737 | pCreateData->pDeviceFuncs->pfnGenerateMipSubLevels = vboxWddmDDevGenerateMipSubLevels;
|
---|
4738 | pCreateData->pDeviceFuncs->pfnSetPixelShaderConstI = vboxWddmDDevSetPixelShaderConstI;
|
---|
4739 | pCreateData->pDeviceFuncs->pfnSetPixelShaderConstB = vboxWddmDDevSetPixelShaderConstB;
|
---|
4740 | pCreateData->pDeviceFuncs->pfnCreatePixelShader = vboxWddmDDevCreatePixelShader;
|
---|
4741 | pCreateData->pDeviceFuncs->pfnDeletePixelShader = vboxWddmDDevDeletePixelShader;
|
---|
4742 | pCreateData->pDeviceFuncs->pfnCreateDecodeDevice = vboxWddmDDevCreateDecodeDevice;
|
---|
4743 | pCreateData->pDeviceFuncs->pfnDestroyDecodeDevice = vboxWddmDDevDestroyDecodeDevice;
|
---|
4744 | pCreateData->pDeviceFuncs->pfnSetDecodeRenderTarget = vboxWddmDDevSetDecodeRenderTarget;
|
---|
4745 | pCreateData->pDeviceFuncs->pfnDecodeBeginFrame = vboxWddmDDevDecodeBeginFrame;
|
---|
4746 | pCreateData->pDeviceFuncs->pfnDecodeEndFrame = vboxWddmDDevDecodeEndFrame;
|
---|
4747 | pCreateData->pDeviceFuncs->pfnDecodeExecute = vboxWddmDDevDecodeExecute;
|
---|
4748 | pCreateData->pDeviceFuncs->pfnDecodeExtensionExecute = vboxWddmDDevDecodeExtensionExecute;
|
---|
4749 | pCreateData->pDeviceFuncs->pfnCreateVideoProcessDevice = vboxWddmDDevCreateVideoProcessDevice;
|
---|
4750 | pCreateData->pDeviceFuncs->pfnDestroyVideoProcessDevice = vboxWddmDDevDestroyVideoProcessDevice;
|
---|
4751 | pCreateData->pDeviceFuncs->pfnVideoProcessBeginFrame = vboxWddmDDevVideoProcessBeginFrame;
|
---|
4752 | pCreateData->pDeviceFuncs->pfnVideoProcessEndFrame = vboxWddmDDevVideoProcessEndFrame;
|
---|
4753 | pCreateData->pDeviceFuncs->pfnSetVideoProcessRenderTarget = vboxWddmDDevSetVideoProcessRenderTarget;
|
---|
4754 | pCreateData->pDeviceFuncs->pfnVideoProcessBlt = vboxWddmDDevVideoProcessBlt;
|
---|
4755 | pCreateData->pDeviceFuncs->pfnCreateExtensionDevice = vboxWddmDDevCreateExtensionDevice;
|
---|
4756 | pCreateData->pDeviceFuncs->pfnDestroyExtensionDevice = vboxWddmDDevDestroyExtensionDevice;
|
---|
4757 | pCreateData->pDeviceFuncs->pfnExtensionExecute = vboxWddmDDevExtensionExecute;
|
---|
4758 | pCreateData->pDeviceFuncs->pfnCreateOverlay = vboxWddmDDevCreateOverlay;
|
---|
4759 | pCreateData->pDeviceFuncs->pfnUpdateOverlay = vboxWddmDDevUpdateOverlay;
|
---|
4760 | pCreateData->pDeviceFuncs->pfnFlipOverlay = vboxWddmDDevFlipOverlay;
|
---|
4761 | pCreateData->pDeviceFuncs->pfnGetOverlayColorControls = vboxWddmDDevGetOverlayColorControls;
|
---|
4762 | pCreateData->pDeviceFuncs->pfnSetOverlayColorControls = vboxWddmDDevSetOverlayColorControls;
|
---|
4763 | pCreateData->pDeviceFuncs->pfnDestroyOverlay = vboxWddmDDevDestroyOverlay;
|
---|
4764 | pCreateData->pDeviceFuncs->pfnDestroyDevice = vboxWddmDDevDestroyDevice;
|
---|
4765 | pCreateData->pDeviceFuncs->pfnQueryResourceResidency = vboxWddmDDevQueryResourceResidency;
|
---|
4766 | pCreateData->pDeviceFuncs->pfnOpenResource = vboxWddmDDevOpenResource;
|
---|
4767 | pCreateData->pDeviceFuncs->pfnGetCaptureAllocationHandle = vboxWddmDDevGetCaptureAllocationHandle;
|
---|
4768 | pCreateData->pDeviceFuncs->pfnCaptureToSysMem = vboxWddmDDevCaptureToSysMem;
|
---|
4769 | pCreateData->pDeviceFuncs->pfnLockAsync = NULL; //vboxWddmDDevLockAsync;
|
---|
4770 | pCreateData->pDeviceFuncs->pfnUnlockAsync = NULL; //vboxWddmDDevUnlockAsync;
|
---|
4771 | pCreateData->pDeviceFuncs->pfnRename = NULL; //vboxWddmDDevRename;
|
---|
4772 |
|
---|
4773 |
|
---|
4774 | do
|
---|
4775 | {
|
---|
4776 | Assert(!pCreateData->AllocationListSize
|
---|
4777 | && !pCreateData->PatchLocationListSize);
|
---|
4778 | if (!pCreateData->AllocationListSize
|
---|
4779 | && !pCreateData->PatchLocationListSize)
|
---|
4780 | {
|
---|
4781 | hr = vboxDispCmCtxCreate(pDevice, &pDevice->DefaultContext);
|
---|
4782 | Assert(hr == S_OK);
|
---|
4783 | if (hr == S_OK)
|
---|
4784 | break;
|
---|
4785 | }
|
---|
4786 | else
|
---|
4787 | {
|
---|
4788 | vboxVDbgPrintR((__FUNCTION__": Not implemented: PatchLocationListSize(%d), AllocationListSize(%d)\n",
|
---|
4789 | pCreateData->PatchLocationListSize, pCreateData->AllocationListSize));
|
---|
4790 | //pCreateData->pAllocationList = ??
|
---|
4791 | hr = E_FAIL;
|
---|
4792 | }
|
---|
4793 |
|
---|
4794 | RTMemFree(pDevice);
|
---|
4795 | } while (0);
|
---|
4796 | }
|
---|
4797 | else
|
---|
4798 | {
|
---|
4799 | vboxVDbgPrintR((__FUNCTION__": RTMemAllocZ returned NULL\n"));
|
---|
4800 | hr = E_OUTOFMEMORY;
|
---|
4801 | }
|
---|
4802 |
|
---|
4803 | vboxVDbgPrint(("<== "__FUNCTION__", hAdapter(0x%p)\n", hAdapter));
|
---|
4804 |
|
---|
4805 | return hr;
|
---|
4806 | }
|
---|
4807 |
|
---|
4808 | static HRESULT APIENTRY vboxWddmDispCloseAdapter (IN HANDLE hAdapter)
|
---|
4809 | {
|
---|
4810 | vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p)\n", hAdapter));
|
---|
4811 |
|
---|
4812 | // AssertBreakpoint();
|
---|
4813 |
|
---|
4814 | PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
|
---|
4815 | if (VBOXDISPMODE_IS_3D(pAdapter))
|
---|
4816 | {
|
---|
4817 | HRESULT hr = VBoxDispWorkerDestroy(&pAdapter->WndWorker);
|
---|
4818 | Assert(hr == S_OK);
|
---|
4819 | pAdapter->pD3D9If->Release();
|
---|
4820 | VBoxDispD3DClose(&pAdapter->D3D);
|
---|
4821 | }
|
---|
4822 |
|
---|
4823 | vboxCapsFree(pAdapter);
|
---|
4824 |
|
---|
4825 | RTMemFree(pAdapter);
|
---|
4826 |
|
---|
4827 | vboxVDbgPrint(("<== "__FUNCTION__", hAdapter(0x%p)\n", hAdapter));
|
---|
4828 |
|
---|
4829 | return S_OK;
|
---|
4830 | }
|
---|
4831 |
|
---|
4832 | HRESULT APIENTRY OpenAdapter (__inout D3DDDIARG_OPENADAPTER* pOpenData)
|
---|
4833 | {
|
---|
4834 | vboxVDbgPrint(("==> "__FUNCTION__"\n"));
|
---|
4835 |
|
---|
4836 | VBOXWDDM_QI Query;
|
---|
4837 | D3DDDICB_QUERYADAPTERINFO DdiQuery;
|
---|
4838 | DdiQuery.PrivateDriverDataSize = sizeof(Query);
|
---|
4839 | DdiQuery.pPrivateDriverData = &Query;
|
---|
4840 | HRESULT hr = pOpenData->pAdapterCallbacks->pfnQueryAdapterInfoCb(pOpenData->hAdapter, &DdiQuery);
|
---|
4841 | Assert(hr == S_OK);
|
---|
4842 | if (hr != S_OK)
|
---|
4843 | {
|
---|
4844 | vboxVDbgPrintR((__FUNCTION__": pfnQueryAdapterInfoCb failed, hr (%d)\n", hr));
|
---|
4845 | return E_FAIL;
|
---|
4846 | }
|
---|
4847 |
|
---|
4848 | /* check the miniport version match display version */
|
---|
4849 | if (Query.u32Version != VBOXVIDEOIF_VERSION)
|
---|
4850 | {
|
---|
4851 | vboxVDbgPrintR((__FUNCTION__": miniport version mismatch, expected (%d), but was (%d)\n",
|
---|
4852 | VBOXVIDEOIF_VERSION,
|
---|
4853 | Query.u32Version));
|
---|
4854 | return E_FAIL;
|
---|
4855 | }
|
---|
4856 |
|
---|
4857 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
4858 | Assert(Query.cInfos >= 1);
|
---|
4859 | PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_ADAPTER, aHeads[Query.cInfos]));
|
---|
4860 | #else
|
---|
4861 | PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(sizeof (VBOXWDDMDISP_ADAPTER));
|
---|
4862 | #endif
|
---|
4863 | Assert(pAdapter);
|
---|
4864 | if (pAdapter)
|
---|
4865 | {
|
---|
4866 | pAdapter->hAdapter = pOpenData->hAdapter;
|
---|
4867 | pAdapter->uIfVersion = pOpenData->Interface;
|
---|
4868 | pAdapter->uRtVersion= pOpenData->Version;
|
---|
4869 | pAdapter->RtCallbacks = *pOpenData->pAdapterCallbacks;
|
---|
4870 |
|
---|
4871 | pAdapter->cHeads = Query.cInfos;
|
---|
4872 |
|
---|
4873 |
|
---|
4874 | pOpenData->hAdapter = pAdapter;
|
---|
4875 | pOpenData->pAdapterFuncs->pfnGetCaps = vboxWddmDispGetCaps;
|
---|
4876 | pOpenData->pAdapterFuncs->pfnCreateDevice = vboxWddmDispCreateDevice;
|
---|
4877 | pOpenData->pAdapterFuncs->pfnCloseAdapter = vboxWddmDispCloseAdapter;
|
---|
4878 | pOpenData->DriverVersion = D3D_UMD_INTERFACE_VERSION;
|
---|
4879 | /*
|
---|
4880 | * here we detect whether we are called by the d3d or ddraw.
|
---|
4881 | * in the d3d case we init our d3d environment
|
---|
4882 | * in the ddraw case we init 2D acceleration
|
---|
4883 | * if interface version is > 7, this is D3D, treat it as so
|
---|
4884 | * otherwise treat it as ddraw
|
---|
4885 | * @todo: need a more clean way of doing this */
|
---|
4886 |
|
---|
4887 | if (pAdapter->uIfVersion > 7)
|
---|
4888 | {
|
---|
4889 | do
|
---|
4890 | {
|
---|
4891 | /* try enable the 3D */
|
---|
4892 | hr = VBoxDispD3DOpen(&pAdapter->D3D);
|
---|
4893 | Assert(hr == S_OK);
|
---|
4894 | if (hr == S_OK)
|
---|
4895 | {
|
---|
4896 | hr = pAdapter->D3D.pfnDirect3DCreate9Ex(D3D_SDK_VERSION, &pAdapter->pD3D9If);
|
---|
4897 | Assert(hr == S_OK);
|
---|
4898 | if (hr == S_OK)
|
---|
4899 | {
|
---|
4900 | hr = VBoxDispWorkerCreate(&pAdapter->WndWorker);
|
---|
4901 | Assert(hr == S_OK);
|
---|
4902 | if (hr == S_OK)
|
---|
4903 | {
|
---|
4904 | vboxVDbgPrint((__FUNCTION__": SUCCESS 3D Enabled, pAdapter (0x%p)\n", pAdapter));
|
---|
4905 | break;
|
---|
4906 | }
|
---|
4907 | pAdapter->pD3D9If->Release();
|
---|
4908 | }
|
---|
4909 | else
|
---|
4910 | vboxVDbgPrintR((__FUNCTION__": pfnDirect3DCreate9Ex failed, hr (%d)\n", hr));
|
---|
4911 | VBoxDispD3DClose(&pAdapter->D3D);
|
---|
4912 | }
|
---|
4913 | else
|
---|
4914 | vboxVDbgPrintR((__FUNCTION__": VBoxDispD3DOpen failed, hr (%d)\n", hr));
|
---|
4915 | } while (0);
|
---|
4916 | }
|
---|
4917 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
4918 | else
|
---|
4919 | {
|
---|
4920 | for (uint32_t i = 0; i < pAdapter->cHeads; ++i)
|
---|
4921 | {
|
---|
4922 | pAdapter->aHeads[i].Vhwa.Settings = Query.aInfos[i];
|
---|
4923 | }
|
---|
4924 | }
|
---|
4925 | #endif
|
---|
4926 |
|
---|
4927 | vboxCapsInit(pAdapter);
|
---|
4928 | hr = S_OK;
|
---|
4929 | // RTMemFree(pAdapter);
|
---|
4930 | }
|
---|
4931 | else
|
---|
4932 | {
|
---|
4933 | vboxVDbgPrintR((__FUNCTION__": RTMemAllocZ returned NULL\n"));
|
---|
4934 | hr = E_OUTOFMEMORY;
|
---|
4935 | }
|
---|
4936 |
|
---|
4937 | vboxVDbgPrint(("<== "__FUNCTION__", hr (%d)\n", hr));
|
---|
4938 |
|
---|
4939 | return hr;
|
---|
4940 | }
|
---|
4941 |
|
---|
4942 | #ifdef VBOXWDDMDISP_DEBUG
|
---|
4943 | VOID vboxVDbgDoPrint(LPCSTR szString, ...)
|
---|
4944 | {
|
---|
4945 | char szBuffer[1024] = {0};
|
---|
4946 | va_list pArgList;
|
---|
4947 | va_start(pArgList, szString);
|
---|
4948 | _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList);
|
---|
4949 | va_end(pArgList);
|
---|
4950 |
|
---|
4951 | OutputDebugStringA(szBuffer);
|
---|
4952 | }
|
---|
4953 | #endif
|
---|