VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.cpp@ 69136

Last change on this file since 69136 was 69136, checked in by vboxsync, 7 years ago

Devices/Graphics: VMSVGA support for cubemaps and compressed textures (incomplete, only D3D backend); vertex/index buffer fixes; saved state fixes; cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 43.3 KB
Line 
1/* $Id: DevVGA-SVGA3d-shared.cpp 69136 2017-10-20 07:13:09Z vboxsync $ */
2/** @file
3 * DevVMWare - VMWare SVGA device
4 */
5
6/*
7 * Copyright (C) 2013-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
23#include <VBox/vmm/pdmdev.h>
24#include <VBox/version.h>
25#include <VBox/err.h>
26#include <VBox/log.h>
27#include <VBox/vmm/pgm.h>
28
29#include <iprt/assert.h>
30#include <iprt/semaphore.h>
31#include <iprt/uuid.h>
32#include <iprt/mem.h>
33#include <iprt/avl.h>
34
35#include <VBoxVideo.h> /* required by DevVGA.h */
36
37/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
38#include "DevVGA.h"
39
40#include "DevVGA-SVGA.h"
41#include "DevVGA-SVGA3d.h"
42#define VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
43#include "DevVGA-SVGA3d-internal.h"
44
45
46#ifdef RT_OS_WINDOWS
47# define VMSVGA3D_WNDCLASSNAME "VMSVGA3DWNDCLS"
48
49static LONG WINAPI vmsvga3dWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
50
51
52/**
53 * Send a message to the async window thread and wait for a reply
54 *
55 * @returns VBox status code.
56 * @param pWindowThread Thread handle
57 * @param WndRequestSem Semaphore handle for waiting
58 * @param msg Message id
59 * @param wParam First parameter
60 * @param lParam Second parameter
61 */
62int vmsvga3dSendThreadMessage(RTTHREAD pWindowThread, RTSEMEVENT WndRequestSem, UINT msg, WPARAM wParam, LPARAM lParam)
63{
64 int rc;
65 BOOL ret;
66
67 ret = PostThreadMessage(RTThreadGetNative(pWindowThread), msg, wParam, lParam);
68 AssertMsgReturn(ret, ("PostThreadMessage %x failed with %d\n", RTThreadGetNative(pWindowThread), GetLastError()), VERR_INTERNAL_ERROR);
69
70 rc = RTSemEventWait(WndRequestSem, RT_INDEFINITE_WAIT);
71 Assert(RT_SUCCESS(rc));
72
73 return rc;
74}
75
76/**
77 * The async window handling thread
78 *
79 * @returns VBox status code.
80 * @param hThreadSelf This thread.
81 * @param pvUser Request sempahore handle.
82 */
83DECLCALLBACK(int) vmsvga3dWindowThread(RTTHREAD hThreadSelf, void *pvUser)
84{
85 RT_NOREF(hThreadSelf);
86 RTSEMEVENT WndRequestSem = (RTSEMEVENT)pvUser;
87 WNDCLASSEX wc;
88
89 /* Register our own window class. */
90 wc.cbSize = sizeof(wc);
91 wc.style = CS_OWNDC;
92 wc.lpfnWndProc = (WNDPROC) vmsvga3dWndProc;
93 wc.cbClsExtra = 0;
94 wc.cbWndExtra = 0;
95 wc.hInstance = GetModuleHandle("VBoxDD.dll"); /** @todo hardcoded name.. */
96 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
97 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
98 wc.hbrBackground = NULL;
99 wc.lpszMenuName = NULL;
100 wc.lpszClassName = VMSVGA3D_WNDCLASSNAME;
101 wc.hIconSm = NULL;
102
103 if (!RegisterClassEx(&wc))
104 {
105 Log(("RegisterClass failed with %x\n", GetLastError()));
106 return VERR_INTERNAL_ERROR;
107 }
108
109 LogFlow(("vmsvga3dWindowThread: started loop\n"));
110 while (true)
111 {
112 MSG msg;
113
114 if (GetMessage(&msg, 0, 0, 0))
115 {
116 if (msg.message == WM_VMSVGA3D_EXIT)
117 {
118 /* Signal to the caller that we're done. */
119 RTSemEventSignal(WndRequestSem);
120 break;
121 }
122
123 if (msg.message == WM_VMSVGA3D_WAKEUP)
124 {
125 continue;
126 }
127 if (msg.message == WM_VMSVGA3D_CREATEWINDOW)
128 {
129 HWND *pHwnd = (HWND *)msg.wParam;
130 LPCREATESTRUCT pCS = (LPCREATESTRUCT) msg.lParam;
131
132#ifdef DEBUG_GFX_WINDOW
133 RECT rectClient;
134
135 rectClient.left = 0;
136 rectClient.top = 0;
137 rectClient.right = pCS->cx;
138 rectClient.bottom = pCS->cy;
139 AdjustWindowRectEx(&rectClient, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_CAPTION, FALSE, WS_EX_NOACTIVATE | WS_EX_NOPARENTNOTIFY | WS_EX_TRANSPARENT);
140 pCS->cx = rectClient.right - rectClient.left;
141 pCS->cy = rectClient.bottom - rectClient.top;
142#endif
143 *pHwnd = CreateWindowEx(pCS->dwExStyle,
144 VMSVGA3D_WNDCLASSNAME,
145 pCS->lpszName,
146 pCS->style,
147#ifdef DEBUG_GFX_WINDOW
148 0,
149 0,
150#else
151 pCS->x,
152 pCS->y,
153#endif
154 pCS->cx,
155 pCS->cy,
156#ifdef DEBUG_GFX_WINDOW
157 0,
158#else
159 pCS->hwndParent,
160#endif
161 pCS->hMenu,
162 pCS->hInstance,
163 NULL);
164 AssertMsg(*pHwnd, ("CreateWindowEx %x %s %s %x (%d,%d)(%d,%d), %x %x %x error=%x\n", pCS->dwExStyle, pCS->lpszName, VMSVGA3D_WNDCLASSNAME, pCS->style, pCS->x,
165 pCS->y, pCS->cx, pCS->cy,pCS->hwndParent, pCS->hMenu, pCS->hInstance, GetLastError()));
166
167 /* Signal to the caller that we're done. */
168 RTSemEventSignal(WndRequestSem);
169 continue;
170 }
171 if (msg.message == WM_VMSVGA3D_DESTROYWINDOW)
172 {
173 BOOL fRc = DestroyWindow((HWND)msg.wParam);
174 Assert(fRc); NOREF(fRc);
175 /* Signal to the caller that we're done. */
176 RTSemEventSignal(WndRequestSem);
177 continue;
178 }
179 if (msg.message == WM_VMSVGA3D_RESIZEWINDOW)
180 {
181 HWND hwnd = (HWND)msg.wParam;
182 LPCREATESTRUCT pCS = (LPCREATESTRUCT) msg.lParam;
183
184#ifdef DEBUG_GFX_WINDOW
185 RECT rectClient;
186
187 rectClient.left = 0;
188 rectClient.top = 0;
189 rectClient.right = pCS->cx;
190 rectClient.bottom = pCS->cy;
191 AdjustWindowRectEx(&rectClient, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_CAPTION, FALSE, WS_EX_NOACTIVATE | WS_EX_NOPARENTNOTIFY | WS_EX_TRANSPARENT);
192 pCS->cx = rectClient.right - rectClient.left;
193 pCS->cy = rectClient.bottom - rectClient.top;
194#endif
195 BOOL fRc = SetWindowPos(hwnd, 0, pCS->x, pCS->y, pCS->cx, pCS->cy, SWP_NOZORDER | SWP_NOMOVE);
196 Assert(fRc); NOREF(fRc);
197
198 /* Signal to the caller that we're done. */
199 RTSemEventSignal(WndRequestSem);
200 continue;
201 }
202
203 TranslateMessage(&msg);
204 DispatchMessage(&msg);
205 }
206 else
207 {
208 Log(("GetMessage failed with %x\n", GetLastError()));
209 break;
210 }
211 }
212
213 Log(("vmsvga3dWindowThread: end loop\n"));
214 return VINF_SUCCESS;
215}
216
217/* Window procedure for our top level window overlays. */
218static LONG WINAPI vmsvga3dWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
219{
220 switch (uMsg)
221 {
222 case WM_CLOSE:
223 Log7(("vmsvga3dWndProc(%p): WM_CLOSE\n", hwnd));
224 break;
225
226 case WM_DESTROY:
227 Log7(("vmsvga3dWndProc(%p): WM_DESTROY\n", hwnd));
228 break;
229
230 case WM_NCHITTEST:
231 Log7(("vmsvga3dWndProc(%p): WM_NCHITTEST\n", hwnd));
232 return HTNOWHERE;
233
234# if 0 /* flicker experiment, no help here. */
235 case WM_PAINT:
236 Log7(("vmsvga3dWndProc(%p): WM_PAINT %p %p\n", hwnd, wParam, lParam));
237 ValidateRect(hwnd, NULL);
238 return 0;
239 case WM_ERASEBKGND:
240 Log7(("vmsvga3dWndProc(%p): WM_ERASEBKGND %p %p\n", hwnd, wParam, lParam));
241 return TRUE;
242 case WM_NCPAINT:
243 Log7(("vmsvga3dWndProc(%p): WM_NCPAINT %p %p\n", hwnd, wParam, lParam));
244 break;
245 case WM_WINDOWPOSCHANGING:
246 {
247 PWINDOWPOS pPos = (PWINDOWPOS)lParam;
248 Log7(("vmsvga3dWndProc(%p): WM_WINDOWPOSCHANGING %p %p pos=(%d,%d) size=(%d,%d) flags=%#x\n",
249 hwnd, wParam, lParam, pPos->x, pPos->y, pPos->cx, pPos->cy, pPos->flags));
250 break;
251 }
252 case WM_WINDOWPOSCHANGED:
253 {
254 PWINDOWPOS pPos = (PWINDOWPOS)lParam;
255 Log7(("vmsvga3dWndProc(%p): WM_WINDOWPOSCHANGED %p %p pos=(%d,%d) size=(%d,%d) flags=%#x\n",
256 hwnd, wParam, lParam, pPos->x, pPos->y, pPos->cx, pPos->cy, pPos->flags));
257 break;
258 }
259 case WM_MOVE:
260 Log7(("vmsvga3dWndProc(%p): WM_MOVE %p %p\n", hwnd, wParam, lParam));
261 break;
262 case WM_SIZE:
263 Log7(("vmsvga3dWndProc(%p): WM_SIZE %p %p\n", hwnd, wParam, lParam));
264 break;
265
266 default:
267 Log7(("vmsvga3dWndProc(%p): %#x %p %p\n", hwnd, uMsg, wParam, lParam));
268# endif
269 }
270 return DefWindowProc(hwnd, uMsg, wParam, lParam);
271}
272
273#endif /* RT_OS_WINDOWS */
274
275
276/**
277 * Calculate the size and dimensions of one block.
278 */
279uint32_t vmsvga3dSurfaceFormatSize(SVGA3dSurfaceFormat format,
280 uint32_t *pcxBlock,
281 uint32_t *pcyBlock)
282{
283 uint32_t u32 = 0;
284 if (!pcxBlock) pcxBlock = &u32;
285 if (!pcyBlock) pcyBlock = &u32;
286
287 switch (format)
288 {
289 case SVGA3D_X8R8G8B8:
290 case SVGA3D_A8R8G8B8:
291 *pcxBlock = 1;
292 *pcyBlock = 1;
293 return 4;
294
295 case SVGA3D_R5G6B5:
296 case SVGA3D_X1R5G5B5:
297 case SVGA3D_A1R5G5B5:
298 case SVGA3D_A4R4G4B4:
299 *pcxBlock = 1;
300 *pcyBlock = 1;
301 return 2;
302
303 case SVGA3D_Z_D32:
304 case SVGA3D_Z_D24S8:
305 case SVGA3D_Z_D24X8:
306 case SVGA3D_Z_DF24:
307 case SVGA3D_Z_D24S8_INT:
308 *pcxBlock = 1;
309 *pcyBlock = 1;
310 return 4;
311
312 case SVGA3D_Z_D16:
313 case SVGA3D_Z_DF16:
314 case SVGA3D_Z_D15S1:
315 *pcxBlock = 1;
316 *pcyBlock = 1;
317 return 2;
318
319 case SVGA3D_LUMINANCE8:
320 case SVGA3D_LUMINANCE4_ALPHA4:
321 *pcxBlock = 1;
322 *pcyBlock = 1;
323 return 1;
324
325 case SVGA3D_LUMINANCE16:
326 case SVGA3D_LUMINANCE8_ALPHA8:
327 *pcxBlock = 1;
328 *pcyBlock = 1;
329 return 2;
330
331 case SVGA3D_DXT1:
332 case SVGA3D_DXT2:
333 *pcxBlock = 4;
334 *pcyBlock = 4;
335 return 8;
336
337 case SVGA3D_DXT3:
338 case SVGA3D_DXT4:
339 case SVGA3D_DXT5:
340 *pcxBlock = 4;
341 *pcyBlock = 4;
342 return 16;
343
344 case SVGA3D_BUMPU8V8:
345 case SVGA3D_BUMPL6V5U5:
346 *pcxBlock = 1;
347 *pcyBlock = 1;
348 return 2;
349
350 case SVGA3D_BUMPX8L8V8U8:
351 case SVGA3D_Q8W8V8U8:
352 *pcxBlock = 1;
353 *pcyBlock = 1;
354 return 4;
355
356 case SVGA3D_V8U8:
357 case SVGA3D_CxV8U8:
358 *pcxBlock = 1;
359 *pcyBlock = 1;
360 return 2;
361
362 case SVGA3D_X8L8V8U8:
363 case SVGA3D_A2W10V10U10:
364 *pcxBlock = 1;
365 *pcyBlock = 1;
366 return 4;
367
368 case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */
369 *pcxBlock = 1;
370 *pcyBlock = 1;
371 return 2;
372 case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */
373 *pcxBlock = 1;
374 *pcyBlock = 1;
375 return 4;
376
377 case SVGA3D_A2R10G10B10:
378 *pcxBlock = 1;
379 *pcyBlock = 1;
380 return 4;
381
382 case SVGA3D_ALPHA8:
383 *pcxBlock = 1;
384 *pcyBlock = 1;
385 return 1;
386
387 case SVGA3D_R_S10E5:
388 *pcxBlock = 1;
389 *pcyBlock = 1;
390 return 2;
391
392 case SVGA3D_R_S23E8:
393 case SVGA3D_RG_S10E5:
394 *pcxBlock = 1;
395 *pcyBlock = 1;
396 return 4;
397
398 case SVGA3D_RG_S23E8:
399 *pcxBlock = 1;
400 *pcyBlock = 1;
401 return 8;
402
403 /*
404 * Any surface can be used as a buffer object, but SVGA3D_BUFFER is
405 * the most efficient format to use when creating new surfaces
406 * expressly for index or vertex data.
407 */
408 case SVGA3D_BUFFER:
409 *pcxBlock = 1;
410 *pcyBlock = 1;
411 return 1;
412
413 case SVGA3D_NV12:
414 *pcxBlock = 1;
415 *pcyBlock = 1;
416 return 1;
417
418 case SVGA3D_V16U16:
419 *pcxBlock = 1;
420 *pcyBlock = 1;
421 return 4;
422
423 case SVGA3D_G16R16:
424 *pcxBlock = 1;
425 *pcyBlock = 1;
426 return 32;
427 case SVGA3D_A16B16G16R16:
428 *pcxBlock = 1;
429 *pcyBlock = 1;
430 return 8;
431
432 default:
433 *pcxBlock = 1;
434 *pcyBlock = 1;
435 AssertFailedReturn(4);
436 }
437}
438
439#ifdef LOG_ENABLED
440
441const char *vmsvga3dGetCapString(uint32_t idxCap)
442{
443 switch (idxCap)
444 {
445 case SVGA3D_DEVCAP_3D:
446 return "SVGA3D_DEVCAP_3D";
447 case SVGA3D_DEVCAP_MAX_LIGHTS:
448 return "SVGA3D_DEVCAP_MAX_LIGHTS";
449 case SVGA3D_DEVCAP_MAX_TEXTURES:
450 return "SVGA3D_DEVCAP_MAX_TEXTURES";
451 case SVGA3D_DEVCAP_MAX_CLIP_PLANES:
452 return "SVGA3D_DEVCAP_MAX_CLIP_PLANES";
453 case SVGA3D_DEVCAP_VERTEX_SHADER_VERSION:
454 return "SVGA3D_DEVCAP_VERTEX_SHADER_VERSION";
455 case SVGA3D_DEVCAP_VERTEX_SHADER:
456 return "SVGA3D_DEVCAP_VERTEX_SHADER";
457 case SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION:
458 return "SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION";
459 case SVGA3D_DEVCAP_FRAGMENT_SHADER:
460 return "SVGA3D_DEVCAP_FRAGMENT_SHADER";
461 case SVGA3D_DEVCAP_MAX_RENDER_TARGETS:
462 return "SVGA3D_DEVCAP_MAX_RENDER_TARGETS";
463 case SVGA3D_DEVCAP_S23E8_TEXTURES:
464 return "SVGA3D_DEVCAP_S23E8_TEXTURES";
465 case SVGA3D_DEVCAP_S10E5_TEXTURES:
466 return "SVGA3D_DEVCAP_S10E5_TEXTURES";
467 case SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND:
468 return "SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND";
469 case SVGA3D_DEVCAP_D16_BUFFER_FORMAT:
470 return "SVGA3D_DEVCAP_D16_BUFFER_FORMAT";
471 case SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT:
472 return "SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT";
473 case SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT:
474 return "SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT";
475 case SVGA3D_DEVCAP_QUERY_TYPES:
476 return "SVGA3D_DEVCAP_QUERY_TYPES";
477 case SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING:
478 return "SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING";
479 case SVGA3D_DEVCAP_MAX_POINT_SIZE:
480 return "SVGA3D_DEVCAP_MAX_POINT_SIZE";
481 case SVGA3D_DEVCAP_MAX_SHADER_TEXTURES:
482 return "SVGA3D_DEVCAP_MAX_SHADER_TEXTURES";
483 case SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH:
484 return "SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH";
485 case SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT:
486 return "SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT";
487 case SVGA3D_DEVCAP_MAX_VOLUME_EXTENT:
488 return "SVGA3D_DEVCAP_MAX_VOLUME_EXTENT";
489 case SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT:
490 return "SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT";
491 case SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO:
492 return "SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO";
493 case SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY:
494 return "SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY";
495 case SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT:
496 return "SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT";
497 case SVGA3D_DEVCAP_MAX_VERTEX_INDEX:
498 return "SVGA3D_DEVCAP_MAX_VERTEX_INDEX";
499 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS:
500 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS";
501 case SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS:
502 return "SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS";
503 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS:
504 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS";
505 case SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS:
506 return "SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS";
507 case SVGA3D_DEVCAP_TEXTURE_OPS:
508 return "SVGA3D_DEVCAP_TEXTURE_OPS";
509 case SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES:
510 return "SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES";
511 case SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES:
512 return "SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES";
513 case SVGA3D_DEVCAP_ALPHATOCOVERAGE:
514 return "SVGA3D_DEVCAP_ALPHATOCOVERAGE";
515 case SVGA3D_DEVCAP_SUPERSAMPLE:
516 return "SVGA3D_DEVCAP_SUPERSAMPLE";
517 case SVGA3D_DEVCAP_AUTOGENMIPMAPS:
518 return "SVGA3D_DEVCAP_AUTOGENMIPMAPS";
519 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES:
520 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES";
521 case SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS:
522 return "SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS";
523 case SVGA3D_DEVCAP_MAX_CONTEXT_IDS:
524 return "SVGA3D_DEVCAP_MAX_CONTEXT_IDS";
525 case SVGA3D_DEVCAP_MAX_SURFACE_IDS:
526 return "SVGA3D_DEVCAP_MAX_SURFACE_IDS";
527 case SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8:
528 return "SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8";
529 case SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8:
530 return "SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8";
531 case SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10:
532 return "SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10";
533 case SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5:
534 return "SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5";
535 case SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5:
536 return "SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5";
537 case SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4:
538 return "SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4";
539 case SVGA3D_DEVCAP_SURFACEFMT_R5G6B5:
540 return "SVGA3D_DEVCAP_SURFACEFMT_R5G6B5";
541 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16:
542 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16";
543 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8:
544 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8";
545 case SVGA3D_DEVCAP_SURFACEFMT_ALPHA8:
546 return "SVGA3D_DEVCAP_SURFACEFMT_ALPHA8";
547 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8:
548 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8";
549 case SVGA3D_DEVCAP_SURFACEFMT_Z_D16:
550 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D16";
551 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8:
552 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8";
553 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8:
554 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8";
555 case SVGA3D_DEVCAP_SURFACEFMT_Z_DF16:
556 return "SVGA3D_DEVCAP_SURFACEFMT_Z_DF16";
557 case SVGA3D_DEVCAP_SURFACEFMT_Z_DF24:
558 return "SVGA3D_DEVCAP_SURFACEFMT_Z_DF24";
559 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT:
560 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT";
561 case SVGA3D_DEVCAP_SURFACEFMT_DXT1:
562 return "SVGA3D_DEVCAP_SURFACEFMT_DXT1";
563 case SVGA3D_DEVCAP_SURFACEFMT_DXT2:
564 return "SVGA3D_DEVCAP_SURFACEFMT_DXT2";
565 case SVGA3D_DEVCAP_SURFACEFMT_DXT3:
566 return "SVGA3D_DEVCAP_SURFACEFMT_DXT3";
567 case SVGA3D_DEVCAP_SURFACEFMT_DXT4:
568 return "SVGA3D_DEVCAP_SURFACEFMT_DXT4";
569 case SVGA3D_DEVCAP_SURFACEFMT_DXT5:
570 return "SVGA3D_DEVCAP_SURFACEFMT_DXT5";
571 case SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8:
572 return "SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8";
573 case SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10:
574 return "SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10";
575 case SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8:
576 return "SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8";
577 case SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8:
578 return "SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8";
579 case SVGA3D_DEVCAP_SURFACEFMT_CxV8U8:
580 return "SVGA3D_DEVCAP_SURFACEFMT_CxV8U8";
581 case SVGA3D_DEVCAP_SURFACEFMT_R_S10E5:
582 return "SVGA3D_DEVCAP_SURFACEFMT_R_S10E5";
583 case SVGA3D_DEVCAP_SURFACEFMT_R_S23E8:
584 return "SVGA3D_DEVCAP_SURFACEFMT_R_S23E8";
585 case SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5:
586 return "SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5";
587 case SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8:
588 return "SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8";
589 case SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5:
590 return "SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5";
591 case SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8:
592 return "SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8";
593 case SVGA3D_DEVCAP_SURFACEFMT_V16U16:
594 return "SVGA3D_DEVCAP_SURFACEFMT_V16U16";
595 case SVGA3D_DEVCAP_SURFACEFMT_G16R16:
596 return "SVGA3D_DEVCAP_SURFACEFMT_G16R16";
597 case SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16:
598 return "SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16";
599 case SVGA3D_DEVCAP_SURFACEFMT_UYVY:
600 return "SVGA3D_DEVCAP_SURFACEFMT_UYVY";
601 case SVGA3D_DEVCAP_SURFACEFMT_YUY2:
602 return "SVGA3D_DEVCAP_SURFACEFMT_YUY2";
603 case SVGA3D_DEVCAP_SURFACEFMT_NV12:
604 return "SVGA3D_DEVCAP_SURFACEFMT_NV12";
605 case SVGA3D_DEVCAP_SURFACEFMT_AYUV:
606 return "SVGA3D_DEVCAP_SURFACEFMT_AYUV";
607 case SVGA3D_DEVCAP_SURFACEFMT_BC4_UNORM:
608 return "SVGA3D_DEVCAP_SURFACEFMT_BC4_UNORM";
609 case SVGA3D_DEVCAP_SURFACEFMT_BC5_UNORM:
610 return "SVGA3D_DEVCAP_SURFACEFMT_BC5_UNORM";
611 default:
612 return "UNEXPECTED";
613 }
614}
615
616const char *vmsvga3dGet3dFormatString(uint32_t format)
617{
618 static char szFormat[1024];
619
620 szFormat[0] = 0;
621
622 if (format & SVGA3DFORMAT_OP_TEXTURE)
623 strcat(szFormat, " - SVGA3DFORMAT_OP_TEXTURE\n");
624 if (format & SVGA3DFORMAT_OP_VOLUMETEXTURE)
625 strcat(szFormat, " - SVGA3DFORMAT_OP_VOLUMETEXTURE\n");
626 if (format & SVGA3DFORMAT_OP_CUBETEXTURE)
627 strcat(szFormat, " - SVGA3DFORMAT_OP_CUBETEXTURE\n");
628 if (format & SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET)
629 strcat(szFormat, " - SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET\n");
630 if (format & SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET)
631 strcat(szFormat, " - SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET\n");
632 if (format & SVGA3DFORMAT_OP_ZSTENCIL)
633 strcat(szFormat, " - SVGA3DFORMAT_OP_ZSTENCIL\n");
634 if (format & SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH)
635 strcat(szFormat, " - SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH\n");
636 if (format & SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET)
637 strcat(szFormat, " - SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET\n");
638 if (format & SVGA3DFORMAT_OP_DISPLAYMODE)
639 strcat(szFormat, " - SVGA3DFORMAT_OP_DISPLAYMODE\n");
640 if (format & SVGA3DFORMAT_OP_3DACCELERATION)
641 strcat(szFormat, " - SVGA3DFORMAT_OP_3DACCELERATION\n");
642 if (format & SVGA3DFORMAT_OP_PIXELSIZE)
643 strcat(szFormat, " - SVGA3DFORMAT_OP_PIXELSIZE\n");
644 if (format & SVGA3DFORMAT_OP_CONVERT_TO_ARGB)
645 strcat(szFormat, " - SVGA3DFORMAT_OP_CONVERT_TO_ARGB\n");
646 if (format & SVGA3DFORMAT_OP_OFFSCREENPLAIN)
647 strcat(szFormat, " - SVGA3DFORMAT_OP_OFFSCREENPLAIN\n");
648 if (format & SVGA3DFORMAT_OP_SRGBREAD)
649 strcat(szFormat, " - SVGA3DFORMAT_OP_SRGBREAD\n");
650 if (format & SVGA3DFORMAT_OP_BUMPMAP)
651 strcat(szFormat, " - SVGA3DFORMAT_OP_BUMPMAP\n");
652 if (format & SVGA3DFORMAT_OP_DMAP)
653 strcat(szFormat, " - SVGA3DFORMAT_OP_DMAP\n");
654 if (format & SVGA3DFORMAT_OP_NOFILTER)
655 strcat(szFormat, " - SVGA3DFORMAT_OP_NOFILTER\n");
656 if (format & SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB)
657 strcat(szFormat, " - SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB\n");
658 if (format & SVGA3DFORMAT_OP_SRGBWRITE)
659 strcat(szFormat, " - SVGA3DFORMAT_OP_SRGBWRITE\n");
660 if (format & SVGA3DFORMAT_OP_NOALPHABLEND)
661 strcat(szFormat, " - SVGA3DFORMAT_OP_NOALPHABLEND\n");
662 if (format & SVGA3DFORMAT_OP_AUTOGENMIPMAP)
663 strcat(szFormat, " - SVGA3DFORMAT_OP_AUTOGENMIPMAP\n");
664 if (format & SVGA3DFORMAT_OP_VERTEXTEXTURE)
665 strcat(szFormat, " - SVGA3DFORMAT_OP_VERTEXTEXTURE\n");
666 if (format & SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP)
667 strcat(szFormat, " - SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP\n");
668 return szFormat;
669}
670
671const char *vmsvga3dGetRenderStateName(uint32_t state)
672{
673 switch (state)
674 {
675 case SVGA3D_RS_ZENABLE: /* SVGA3dBool */
676 return "SVGA3D_RS_ZENABLE";
677 case SVGA3D_RS_ZWRITEENABLE: /* SVGA3dBool */
678 return "SVGA3D_RS_ZWRITEENABLE";
679 case SVGA3D_RS_ALPHATESTENABLE: /* SVGA3dBool */
680 return "SVGA3D_RS_ALPHATESTENABLE";
681 case SVGA3D_RS_DITHERENABLE: /* SVGA3dBool */
682 return "SVGA3D_RS_DITHERENABLE";
683 case SVGA3D_RS_BLENDENABLE: /* SVGA3dBool */
684 return "SVGA3D_RS_BLENDENABLE";
685 case SVGA3D_RS_FOGENABLE: /* SVGA3dBool */
686 return "SVGA3D_RS_FOGENABLE";
687 case SVGA3D_RS_SPECULARENABLE: /* SVGA3dBool */
688 return "SVGA3D_RS_SPECULARENABLE";
689 case SVGA3D_RS_STENCILENABLE: /* SVGA3dBool */
690 return "SVGA3D_RS_STENCILENABLE";
691 case SVGA3D_RS_LIGHTINGENABLE: /* SVGA3dBool */
692 return "SVGA3D_RS_LIGHTINGENABLE";
693 case SVGA3D_RS_NORMALIZENORMALS: /* SVGA3dBool */
694 return "SVGA3D_RS_NORMALIZENORMALS";
695 case SVGA3D_RS_POINTSPRITEENABLE: /* SVGA3dBool */
696 return "SVGA3D_RS_POINTSPRITEENABLE";
697 case SVGA3D_RS_POINTSCALEENABLE: /* SVGA3dBool */
698 return "SVGA3D_RS_POINTSCALEENABLE";
699 case SVGA3D_RS_STENCILREF: /* uint32_t */
700 return "SVGA3D_RS_STENCILREF";
701 case SVGA3D_RS_STENCILMASK: /* uint32_t */
702 return "SVGA3D_RS_STENCILMASK";
703 case SVGA3D_RS_STENCILWRITEMASK: /* uint32_t */
704 return "SVGA3D_RS_STENCILWRITEMASK";
705 case SVGA3D_RS_POINTSIZE: /* float */
706 return "SVGA3D_RS_POINTSIZE";
707 case SVGA3D_RS_POINTSIZEMIN: /* float */
708 return "SVGA3D_RS_POINTSIZEMIN";
709 case SVGA3D_RS_POINTSIZEMAX: /* float */
710 return "SVGA3D_RS_POINTSIZEMAX";
711 case SVGA3D_RS_POINTSCALE_A: /* float */
712 return "SVGA3D_RS_POINTSCALE_A";
713 case SVGA3D_RS_POINTSCALE_B: /* float */
714 return "SVGA3D_RS_POINTSCALE_B";
715 case SVGA3D_RS_POINTSCALE_C: /* float */
716 return "SVGA3D_RS_POINTSCALE_C";
717 case SVGA3D_RS_AMBIENT: /* SVGA3dColor - identical */
718 return "SVGA3D_RS_AMBIENT";
719 case SVGA3D_RS_CLIPPLANEENABLE: /* SVGA3dClipPlanes - identical */
720 return "SVGA3D_RS_CLIPPLANEENABLE";
721 case SVGA3D_RS_FOGCOLOR: /* SVGA3dColor - identical */
722 return "SVGA3D_RS_FOGCOLOR";
723 case SVGA3D_RS_FOGSTART: /* float */
724 return "SVGA3D_RS_FOGSTART";
725 case SVGA3D_RS_FOGEND: /* float */
726 return "SVGA3D_RS_FOGEND";
727 case SVGA3D_RS_FOGDENSITY: /* float */
728 return "SVGA3D_RS_FOGDENSITY";
729 case SVGA3D_RS_RANGEFOGENABLE: /* SVGA3dBool */
730 return "SVGA3D_RS_RANGEFOGENABLE";
731 case SVGA3D_RS_FOGMODE: /* SVGA3dFogMode */
732 return "SVGA3D_RS_FOGMODE";
733 case SVGA3D_RS_FILLMODE: /* SVGA3dFillMode */
734 return "SVGA3D_RS_FILLMODE";
735 case SVGA3D_RS_SHADEMODE: /* SVGA3dShadeMode */
736 return "SVGA3D_RS_SHADEMODE";
737 case SVGA3D_RS_LINEPATTERN: /* SVGA3dLinePattern */
738 return "SVGA3D_RS_LINEPATTERN";
739 case SVGA3D_RS_SRCBLEND: /* SVGA3dBlendOp */
740 return "SVGA3D_RS_SRCBLEND";
741 case SVGA3D_RS_DSTBLEND: /* SVGA3dBlendOp */
742 return "SVGA3D_RS_DSTBLEND";
743 case SVGA3D_RS_BLENDEQUATION: /* SVGA3dBlendEquation */
744 return "SVGA3D_RS_BLENDEQUATION";
745 case SVGA3D_RS_CULLMODE: /* SVGA3dFace */
746 return "SVGA3D_RS_CULLMODE";
747 case SVGA3D_RS_ZFUNC: /* SVGA3dCmpFunc */
748 return "SVGA3D_RS_ZFUNC";
749 case SVGA3D_RS_ALPHAFUNC: /* SVGA3dCmpFunc */
750 return "SVGA3D_RS_ALPHAFUNC";
751 case SVGA3D_RS_STENCILFUNC: /* SVGA3dCmpFunc */
752 return "SVGA3D_RS_STENCILFUNC";
753 case SVGA3D_RS_STENCILFAIL: /* SVGA3dStencilOp */
754 return "SVGA3D_RS_STENCILFAIL";
755 case SVGA3D_RS_STENCILZFAIL: /* SVGA3dStencilOp */
756 return "SVGA3D_RS_STENCILZFAIL";
757 case SVGA3D_RS_STENCILPASS: /* SVGA3dStencilOp */
758 return "SVGA3D_RS_STENCILPASS";
759 case SVGA3D_RS_ALPHAREF: /* float (0.0 .. 1.0) */
760 return "SVGA3D_RS_ALPHAREF";
761 case SVGA3D_RS_FRONTWINDING: /* SVGA3dFrontWinding */
762 return "SVGA3D_RS_FRONTWINDING";
763 case SVGA3D_RS_COORDINATETYPE: /* SVGA3dCoordinateType */
764 return "SVGA3D_RS_COORDINATETYPE";
765 case SVGA3D_RS_ZBIAS: /* float */
766 return "SVGA3D_RS_ZBIAS";
767 case SVGA3D_RS_COLORWRITEENABLE: /* SVGA3dColorMask */
768 return "SVGA3D_RS_COLORWRITEENABLE";
769 case SVGA3D_RS_VERTEXMATERIALENABLE: /* SVGA3dBool */
770 return "SVGA3D_RS_VERTEXMATERIALENABLE";
771 case SVGA3D_RS_DIFFUSEMATERIALSOURCE: /* SVGA3dVertexMaterial */
772 return "SVGA3D_RS_DIFFUSEMATERIALSOURCE";
773 case SVGA3D_RS_SPECULARMATERIALSOURCE: /* SVGA3dVertexMaterial */
774 return "SVGA3D_RS_SPECULARMATERIALSOURCE";
775 case SVGA3D_RS_AMBIENTMATERIALSOURCE: /* SVGA3dVertexMaterial */
776 return "SVGA3D_RS_AMBIENTMATERIALSOURCE";
777 case SVGA3D_RS_EMISSIVEMATERIALSOURCE: /* SVGA3dVertexMaterial */
778 return "SVGA3D_RS_EMISSIVEMATERIALSOURCE";
779 case SVGA3D_RS_TEXTUREFACTOR: /* SVGA3dColor */
780 return "SVGA3D_RS_TEXTUREFACTOR";
781 case SVGA3D_RS_LOCALVIEWER: /* SVGA3dBool */
782 return "SVGA3D_RS_LOCALVIEWER";
783 case SVGA3D_RS_SCISSORTESTENABLE: /* SVGA3dBool */
784 return "SVGA3D_RS_SCISSORTESTENABLE";
785 case SVGA3D_RS_BLENDCOLOR: /* SVGA3dColor */
786 return "SVGA3D_RS_BLENDCOLOR";
787 case SVGA3D_RS_STENCILENABLE2SIDED: /* SVGA3dBool */
788 return "SVGA3D_RS_STENCILENABLE2SIDED";
789 case SVGA3D_RS_CCWSTENCILFUNC: /* SVGA3dCmpFunc */
790 return "SVGA3D_RS_CCWSTENCILFUNC";
791 case SVGA3D_RS_CCWSTENCILFAIL: /* SVGA3dStencilOp */
792 return "SVGA3D_RS_CCWSTENCILFAIL";
793 case SVGA3D_RS_CCWSTENCILZFAIL: /* SVGA3dStencilOp */
794 return "SVGA3D_RS_CCWSTENCILZFAIL";
795 case SVGA3D_RS_CCWSTENCILPASS: /* SVGA3dStencilOp */
796 return "SVGA3D_RS_CCWSTENCILPASS";
797 case SVGA3D_RS_VERTEXBLEND: /* SVGA3dVertexBlendFlags */
798 return "SVGA3D_RS_VERTEXBLEND";
799 case SVGA3D_RS_SLOPESCALEDEPTHBIAS: /* float */
800 return "SVGA3D_RS_SLOPESCALEDEPTHBIAS";
801 case SVGA3D_RS_DEPTHBIAS: /* float */
802 return "SVGA3D_RS_DEPTHBIAS";
803 case SVGA3D_RS_OUTPUTGAMMA: /* float */
804 return "SVGA3D_RS_OUTPUTGAMMA";
805 case SVGA3D_RS_ZVISIBLE: /* SVGA3dBool */
806 return "SVGA3D_RS_ZVISIBLE";
807 case SVGA3D_RS_LASTPIXEL: /* SVGA3dBool */
808 return "SVGA3D_RS_LASTPIXEL";
809 case SVGA3D_RS_CLIPPING: /* SVGA3dBool */
810 return "SVGA3D_RS_CLIPPING";
811 case SVGA3D_RS_WRAP0: /* SVGA3dWrapFlags */
812 return "SVGA3D_RS_WRAP0";
813 case SVGA3D_RS_WRAP1: /* SVGA3dWrapFlags */
814 return "SVGA3D_RS_WRAP1";
815 case SVGA3D_RS_WRAP2: /* SVGA3dWrapFlags */
816 return "SVGA3D_RS_WRAP2";
817 case SVGA3D_RS_WRAP3: /* SVGA3dWrapFlags */
818 return "SVGA3D_RS_WRAP3";
819 case SVGA3D_RS_WRAP4: /* SVGA3dWrapFlags */
820 return "SVGA3D_RS_WRAP4";
821 case SVGA3D_RS_WRAP5: /* SVGA3dWrapFlags */
822 return "SVGA3D_RS_WRAP5";
823 case SVGA3D_RS_WRAP6: /* SVGA3dWrapFlags */
824 return "SVGA3D_RS_WRAP6";
825 case SVGA3D_RS_WRAP7: /* SVGA3dWrapFlags */
826 return "SVGA3D_RS_WRAP7";
827 case SVGA3D_RS_WRAP8: /* SVGA3dWrapFlags */
828 return "SVGA3D_RS_WRAP8";
829 case SVGA3D_RS_WRAP9: /* SVGA3dWrapFlags */
830 return "SVGA3D_RS_WRAP9";
831 case SVGA3D_RS_WRAP10: /* SVGA3dWrapFlags */
832 return "SVGA3D_RS_WRAP10";
833 case SVGA3D_RS_WRAP11: /* SVGA3dWrapFlags */
834 return "SVGA3D_RS_WRAP11";
835 case SVGA3D_RS_WRAP12: /* SVGA3dWrapFlags */
836 return "SVGA3D_RS_WRAP12";
837 case SVGA3D_RS_WRAP13: /* SVGA3dWrapFlags */
838 return "SVGA3D_RS_WRAP13";
839 case SVGA3D_RS_WRAP14: /* SVGA3dWrapFlags */
840 return "SVGA3D_RS_WRAP14";
841 case SVGA3D_RS_WRAP15: /* SVGA3dWrapFlags */
842 return "SVGA3D_RS_WRAP15";
843 case SVGA3D_RS_MULTISAMPLEANTIALIAS: /* SVGA3dBool */
844 return "SVGA3D_RS_MULTISAMPLEANTIALIAS";
845 case SVGA3D_RS_MULTISAMPLEMASK: /* uint32_t */
846 return "SVGA3D_RS_MULTISAMPLEMASK";
847 case SVGA3D_RS_INDEXEDVERTEXBLENDENABLE: /* SVGA3dBool */
848 return "SVGA3D_RS_INDEXEDVERTEXBLENDENABLE";
849 case SVGA3D_RS_TWEENFACTOR: /* float */
850 return "SVGA3D_RS_TWEENFACTOR";
851 case SVGA3D_RS_ANTIALIASEDLINEENABLE: /* SVGA3dBool */
852 return "SVGA3D_RS_ANTIALIASEDLINEENABLE";
853 case SVGA3D_RS_COLORWRITEENABLE1: /* SVGA3dColorMask */
854 return "SVGA3D_RS_COLORWRITEENABLE1";
855 case SVGA3D_RS_COLORWRITEENABLE2: /* SVGA3dColorMask */
856 return "SVGA3D_RS_COLORWRITEENABLE2";
857 case SVGA3D_RS_COLORWRITEENABLE3: /* SVGA3dColorMask */
858 return "SVGA3D_RS_COLORWRITEENABLE3";
859 case SVGA3D_RS_SEPARATEALPHABLENDENABLE: /* SVGA3dBool */
860 return "SVGA3D_RS_SEPARATEALPHABLENDENABLE";
861 case SVGA3D_RS_SRCBLENDALPHA: /* SVGA3dBlendOp */
862 return "SVGA3D_RS_SRCBLENDALPHA";
863 case SVGA3D_RS_DSTBLENDALPHA: /* SVGA3dBlendOp */
864 return "SVGA3D_RS_DSTBLENDALPHA";
865 case SVGA3D_RS_BLENDEQUATIONALPHA: /* SVGA3dBlendEquation */
866 return "SVGA3D_RS_BLENDEQUATIONALPHA";
867 case SVGA3D_RS_TRANSPARENCYANTIALIAS: /* SVGA3dTransparencyAntialiasType */
868 return "SVGA3D_RS_TRANSPARENCYANTIALIAS";
869 case SVGA3D_RS_LINEAA: /* SVGA3dBool */
870 return "SVGA3D_RS_LINEAA";
871 case SVGA3D_RS_LINEWIDTH: /* float */
872 return "SVGA3D_RS_LINEWIDTH";
873 default:
874 return "UNKNOWN";
875 }
876}
877
878const char *vmsvga3dTextureStateToString(SVGA3dTextureStateName textureState)
879{
880 switch (textureState)
881 {
882 case SVGA3D_TS_BIND_TEXTURE:
883 return "SVGA3D_TS_BIND_TEXTURE";
884 case SVGA3D_TS_COLOROP:
885 return "SVGA3D_TS_COLOROP";
886 case SVGA3D_TS_COLORARG1:
887 return "SVGA3D_TS_COLORARG1";
888 case SVGA3D_TS_COLORARG2:
889 return "SVGA3D_TS_COLORARG2";
890 case SVGA3D_TS_ALPHAOP:
891 return "SVGA3D_TS_ALPHAOP";
892 case SVGA3D_TS_ALPHAARG1:
893 return "SVGA3D_TS_ALPHAARG1";
894 case SVGA3D_TS_ALPHAARG2:
895 return "SVGA3D_TS_ALPHAARG2";
896 case SVGA3D_TS_ADDRESSU:
897 return "SVGA3D_TS_ADDRESSU";
898 case SVGA3D_TS_ADDRESSV:
899 return "SVGA3D_TS_ADDRESSV";
900 case SVGA3D_TS_MIPFILTER:
901 return "SVGA3D_TS_MIPFILTER";
902 case SVGA3D_TS_MAGFILTER:
903 return "SVGA3D_TS_MAGFILTER";
904 case SVGA3D_TS_MINFILTER:
905 return "SVGA3D_TS_MINFILTER";
906 case SVGA3D_TS_BORDERCOLOR:
907 return "SVGA3D_TS_BORDERCOLOR";
908 case SVGA3D_TS_TEXCOORDINDEX:
909 return "SVGA3D_TS_TEXCOORDINDEX";
910 case SVGA3D_TS_TEXTURETRANSFORMFLAGS:
911 return "SVGA3D_TS_TEXTURETRANSFORMFLAGS";
912 case SVGA3D_TS_TEXCOORDGEN:
913 return "SVGA3D_TS_TEXCOORDGEN";
914 case SVGA3D_TS_BUMPENVMAT00:
915 return "SVGA3D_TS_BUMPENVMAT00";
916 case SVGA3D_TS_BUMPENVMAT01:
917 return "SVGA3D_TS_BUMPENVMAT01";
918 case SVGA3D_TS_BUMPENVMAT10:
919 return "SVGA3D_TS_BUMPENVMAT10";
920 case SVGA3D_TS_BUMPENVMAT11:
921 return "SVGA3D_TS_BUMPENVMAT11";
922 case SVGA3D_TS_TEXTURE_MIPMAP_LEVEL:
923 return "SVGA3D_TS_TEXTURE_MIPMAP_LEVEL";
924 case SVGA3D_TS_TEXTURE_LOD_BIAS:
925 return "SVGA3D_TS_TEXTURE_LOD_BIAS";
926 case SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL:
927 return "SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL";
928 case SVGA3D_TS_ADDRESSW:
929 return "SVGA3D_TS_ADDRESSW";
930 case SVGA3D_TS_GAMMA:
931 return "SVGA3D_TS_GAMMA";
932 case SVGA3D_TS_BUMPENVLSCALE:
933 return "SVGA3D_TS_BUMPENVLSCALE";
934 case SVGA3D_TS_BUMPENVLOFFSET:
935 return "SVGA3D_TS_BUMPENVLOFFSET";
936 case SVGA3D_TS_COLORARG0:
937 return "SVGA3D_TS_COLORARG0";
938 case SVGA3D_TS_ALPHAARG0:
939 return "SVGA3D_TS_ALPHAARG0";
940 default:
941 return "UNKNOWN";
942 }
943}
944
945const char *vmsvgaTransformToString(SVGA3dTransformType type)
946{
947 switch (type)
948 {
949 case SVGA3D_TRANSFORM_INVALID:
950 return "SVGA3D_TRANSFORM_INVALID";
951 case SVGA3D_TRANSFORM_WORLD:
952 return "SVGA3D_TRANSFORM_WORLD";
953 case SVGA3D_TRANSFORM_VIEW:
954 return "SVGA3D_TRANSFORM_VIEW";
955 case SVGA3D_TRANSFORM_PROJECTION:
956 return "SVGA3D_TRANSFORM_PROJECTION";
957 case SVGA3D_TRANSFORM_TEXTURE0:
958 return "SVGA3D_TRANSFORM_TEXTURE0";
959 case SVGA3D_TRANSFORM_TEXTURE1:
960 return "SVGA3D_TRANSFORM_TEXTURE1";
961 case SVGA3D_TRANSFORM_TEXTURE2:
962 return "SVGA3D_TRANSFORM_TEXTURE2";
963 case SVGA3D_TRANSFORM_TEXTURE3:
964 return "SVGA3D_TRANSFORM_TEXTURE3";
965 case SVGA3D_TRANSFORM_TEXTURE4:
966 return "SVGA3D_TRANSFORM_TEXTURE4";
967 case SVGA3D_TRANSFORM_TEXTURE5:
968 return "SVGA3D_TRANSFORM_TEXTURE5";
969 case SVGA3D_TRANSFORM_TEXTURE6:
970 return "SVGA3D_TRANSFORM_TEXTURE6";
971 case SVGA3D_TRANSFORM_TEXTURE7:
972 return "SVGA3D_TRANSFORM_TEXTURE7";
973 case SVGA3D_TRANSFORM_WORLD1:
974 return "SVGA3D_TRANSFORM_WORLD1";
975 case SVGA3D_TRANSFORM_WORLD2:
976 return "SVGA3D_TRANSFORM_WORLD2";
977 case SVGA3D_TRANSFORM_WORLD3:
978 return "SVGA3D_TRANSFORM_WORLD3";
979 default:
980 return "UNKNOWN";
981 }
982}
983
984const char *vmsvgaDeclUsage2String(SVGA3dDeclUsage usage)
985{
986 switch (usage)
987 {
988 case SVGA3D_DECLUSAGE_POSITION:
989 return "SVGA3D_DECLUSAGE_POSITION";
990 case SVGA3D_DECLUSAGE_BLENDWEIGHT:
991 return "SVGA3D_DECLUSAGE_BLENDWEIGHT";
992 case SVGA3D_DECLUSAGE_BLENDINDICES:
993 return "SVGA3D_DECLUSAGE_BLENDINDICES";
994 case SVGA3D_DECLUSAGE_NORMAL:
995 return "SVGA3D_DECLUSAGE_NORMAL";
996 case SVGA3D_DECLUSAGE_PSIZE:
997 return "SVGA3D_DECLUSAGE_PSIZE";
998 case SVGA3D_DECLUSAGE_TEXCOORD:
999 return "SVGA3D_DECLUSAGE_TEXCOORD";
1000 case SVGA3D_DECLUSAGE_TANGENT:
1001 return "SVGA3D_DECLUSAGE_TANGENT";
1002 case SVGA3D_DECLUSAGE_BINORMAL:
1003 return "SVGA3D_DECLUSAGE_BINORMAL";
1004 case SVGA3D_DECLUSAGE_TESSFACTOR:
1005 return "SVGA3D_DECLUSAGE_TESSFACTOR";
1006 case SVGA3D_DECLUSAGE_POSITIONT:
1007 return "SVGA3D_DECLUSAGE_POSITIONT";
1008 case SVGA3D_DECLUSAGE_COLOR:
1009 return "SVGA3D_DECLUSAGE_COLOR";
1010 case SVGA3D_DECLUSAGE_FOG:
1011 return "SVGA3D_DECLUSAGE_FOG";
1012 case SVGA3D_DECLUSAGE_DEPTH:
1013 return "SVGA3D_DECLUSAGE_DEPTH";
1014 case SVGA3D_DECLUSAGE_SAMPLE:
1015 return "SVGA3D_DECLUSAGE_SAMPLE";
1016 default:
1017 return "UNKNOWN!!";
1018 }
1019}
1020
1021const char *vmsvgaDeclMethod2String(SVGA3dDeclMethod method)
1022{
1023 switch (method)
1024 {
1025 case SVGA3D_DECLMETHOD_DEFAULT:
1026 return "SVGA3D_DECLMETHOD_DEFAULT";
1027 case SVGA3D_DECLMETHOD_PARTIALU:
1028 return "SVGA3D_DECLMETHOD_PARTIALU";
1029 case SVGA3D_DECLMETHOD_PARTIALV:
1030 return "SVGA3D_DECLMETHOD_PARTIALV";
1031 case SVGA3D_DECLMETHOD_CROSSUV:
1032 return "SVGA3D_DECLMETHOD_CROSSUV";
1033 case SVGA3D_DECLMETHOD_UV:
1034 return "SVGA3D_DECLMETHOD_UV";
1035 case SVGA3D_DECLMETHOD_LOOKUP:
1036 return "SVGA3D_DECLMETHOD_LOOKUP";
1037 case SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED:
1038 return "SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED";
1039 default:
1040 return "UNKNOWN!!";
1041 }
1042}
1043
1044const char *vmsvgaDeclType2String(SVGA3dDeclType type)
1045{
1046 switch (type)
1047 {
1048 case SVGA3D_DECLTYPE_FLOAT1:
1049 return "SVGA3D_DECLTYPE_FLOAT1";
1050 case SVGA3D_DECLTYPE_FLOAT2:
1051 return "SVGA3D_DECLTYPE_FLOAT2";
1052 case SVGA3D_DECLTYPE_FLOAT3:
1053 return "SVGA3D_DECLTYPE_FLOAT3";
1054 case SVGA3D_DECLTYPE_FLOAT4:
1055 return "SVGA3D_DECLTYPE_FLOAT4";
1056 case SVGA3D_DECLTYPE_D3DCOLOR:
1057 return "SVGA3D_DECLTYPE_D3DCOLOR";
1058 case SVGA3D_DECLTYPE_UBYTE4:
1059 return "SVGA3D_DECLTYPE_UBYTE4";
1060 case SVGA3D_DECLTYPE_SHORT2:
1061 return "SVGA3D_DECLTYPE_SHORT2";
1062 case SVGA3D_DECLTYPE_SHORT4:
1063 return "SVGA3D_DECLTYPE_SHORT4";
1064 case SVGA3D_DECLTYPE_UBYTE4N:
1065 return "SVGA3D_DECLTYPE_UBYTE4N";
1066 case SVGA3D_DECLTYPE_SHORT2N:
1067 return "SVGA3D_DECLTYPE_SHORT2N";
1068 case SVGA3D_DECLTYPE_SHORT4N:
1069 return "SVGA3D_DECLTYPE_SHORT4N";
1070 case SVGA3D_DECLTYPE_USHORT2N:
1071 return "SVGA3D_DECLTYPE_USHORT2N";
1072 case SVGA3D_DECLTYPE_USHORT4N:
1073 return "SVGA3D_DECLTYPE_USHORT4N";
1074 case SVGA3D_DECLTYPE_UDEC3:
1075 return "SVGA3D_DECLTYPE_UDEC3";
1076 case SVGA3D_DECLTYPE_DEC3N:
1077 return "SVGA3D_DECLTYPE_DEC3N";
1078 case SVGA3D_DECLTYPE_FLOAT16_2:
1079 return "SVGA3D_DECLTYPE_FLOAT16_2";
1080 case SVGA3D_DECLTYPE_FLOAT16_4:
1081 return "SVGA3D_DECLTYPE_FLOAT16_4";
1082 default:
1083 return "UNKNOWN!!";
1084 }
1085}
1086
1087const char *vmsvga3dPrimitiveType2String(SVGA3dPrimitiveType PrimitiveType)
1088{
1089 switch (PrimitiveType)
1090 {
1091 case SVGA3D_PRIMITIVE_TRIANGLELIST:
1092 return "SVGA3D_PRIMITIVE_TRIANGLELIST";
1093 case SVGA3D_PRIMITIVE_POINTLIST:
1094 return "SVGA3D_PRIMITIVE_POINTLIST";
1095 case SVGA3D_PRIMITIVE_LINELIST:
1096 return "SVGA3D_PRIMITIVE_LINELIST";
1097 case SVGA3D_PRIMITIVE_LINESTRIP:
1098 return "SVGA3D_PRIMITIVE_LINESTRIP";
1099 case SVGA3D_PRIMITIVE_TRIANGLESTRIP:
1100 return "SVGA3D_PRIMITIVE_TRIANGLESTRIP";
1101 case SVGA3D_PRIMITIVE_TRIANGLEFAN:
1102 return "SVGA3D_PRIMITIVE_TRIANGLEFAN";
1103 default:
1104 return "UNKNOWN";
1105 }
1106}
1107
1108#endif /* LOG_ENABLED */
1109
1110/** Unsigned coordinates in pBox. Clip to [0; pSizeSrc), [0;pSizeDest).
1111 *
1112 * @param pSizeSrc Source surface dimensions.
1113 * @param pSizeDest Destination surface dimensions.
1114 * @param pBox Coordinates to be clipped.
1115 */
1116void vmsvgaClipCopyBox(const SVGA3dSize *pSizeSrc,
1117 const SVGA3dSize *pSizeDest,
1118 SVGA3dCopyBox *pBox)
1119{
1120 /* Src x, w */
1121 if (pBox->srcx > pSizeSrc->width)
1122 pBox->srcx = pSizeSrc->width;
1123 if (pBox->w > pSizeSrc->width - pBox->srcx)
1124 pBox->w = pSizeSrc->width - pBox->srcx;
1125
1126 /* Src y, h */
1127 if (pBox->srcy > pSizeSrc->height)
1128 pBox->srcy = pSizeSrc->height;
1129 if (pBox->h > pSizeSrc->height - pBox->srcy)
1130 pBox->h = pSizeSrc->height - pBox->srcy;
1131
1132 /* Src z, d */
1133 if (pBox->srcz > pSizeSrc->depth)
1134 pBox->srcz = pSizeSrc->depth;
1135 if (pBox->d > pSizeSrc->depth - pBox->srcz)
1136 pBox->d = pSizeSrc->depth - pBox->srcz;
1137
1138 /* Dest x, w */
1139 if (pBox->x > pSizeDest->width)
1140 pBox->x = pSizeDest->width;
1141 if (pBox->w > pSizeDest->width - pBox->x)
1142 pBox->w = pSizeDest->width - pBox->x;
1143
1144 /* Dest y, h */
1145 if (pBox->y > pSizeDest->height)
1146 pBox->y = pSizeDest->height;
1147 if (pBox->h > pSizeDest->height - pBox->y)
1148 pBox->h = pSizeDest->height - pBox->y;
1149
1150 /* Dest z, d */
1151 if (pBox->z > pSizeDest->depth)
1152 pBox->z = pSizeDest->depth;
1153 if (pBox->d > pSizeDest->depth - pBox->z)
1154 pBox->d = pSizeDest->depth - pBox->z;
1155}
1156
1157/** Unsigned coordinates in pBox. Clip to [0; pSize).
1158 *
1159 * @param pSize Source surface dimensions.
1160 * @param pBox Coordinates to be clipped.
1161 */
1162void vmsvgaClipBox(const SVGA3dSize *pSize,
1163 SVGA3dBox *pBox)
1164{
1165 /* x, w */
1166 if (pBox->x > pSize->width)
1167 pBox->x = pSize->width;
1168 if (pBox->w > pSize->width - pBox->x)
1169 pBox->w = pSize->width - pBox->x;
1170
1171 /* y, h */
1172 if (pBox->y > pSize->height)
1173 pBox->y = pSize->height;
1174 if (pBox->h > pSize->height - pBox->y)
1175 pBox->h = pSize->height - pBox->y;
1176
1177 /* z, d */
1178 if (pBox->z > pSize->depth)
1179 pBox->z = pSize->depth;
1180 if (pBox->d > pSize->depth - pBox->z)
1181 pBox->d = pSize->depth - pBox->z;
1182}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette