VirtualBox

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

Last change on this file since 73705 was 73194, checked in by vboxsync, 6 years ago

DevVGA-SVGA: added new parameters for vmsvgaGMRTransfer in order to reduce code duplication, adjusted callers accordingly

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.8 KB
Line 
1/* $Id: DevVGA-SVGA3d-shared.cpp 73194 2018-07-18 07:14:24Z 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 8;
372 case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */
373 *pcxBlock = 1;
374 *pcyBlock = 1;
375 return 16;
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 4;
427 case SVGA3D_A16B16G16R16:
428 *pcxBlock = 1;
429 *pcyBlock = 1;
430 return 8;
431 case SVGA3D_R8G8B8A8_UNORM:
432 case SVGA3D_R8G8B8A8_SNORM:
433 *pcxBlock = 1;
434 *pcyBlock = 1;
435 return 4;
436 case SVGA3D_R16G16_UNORM:
437 *pcxBlock = 1;
438 *pcyBlock = 1;
439 return 4;
440
441 default:
442 *pcxBlock = 1;
443 *pcyBlock = 1;
444 AssertFailedReturn(4);
445 }
446}
447
448#ifdef LOG_ENABLED
449
450const char *vmsvga3dGetCapString(uint32_t idxCap)
451{
452 switch (idxCap)
453 {
454 case SVGA3D_DEVCAP_3D:
455 return "SVGA3D_DEVCAP_3D";
456 case SVGA3D_DEVCAP_MAX_LIGHTS:
457 return "SVGA3D_DEVCAP_MAX_LIGHTS";
458 case SVGA3D_DEVCAP_MAX_TEXTURES:
459 return "SVGA3D_DEVCAP_MAX_TEXTURES";
460 case SVGA3D_DEVCAP_MAX_CLIP_PLANES:
461 return "SVGA3D_DEVCAP_MAX_CLIP_PLANES";
462 case SVGA3D_DEVCAP_VERTEX_SHADER_VERSION:
463 return "SVGA3D_DEVCAP_VERTEX_SHADER_VERSION";
464 case SVGA3D_DEVCAP_VERTEX_SHADER:
465 return "SVGA3D_DEVCAP_VERTEX_SHADER";
466 case SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION:
467 return "SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION";
468 case SVGA3D_DEVCAP_FRAGMENT_SHADER:
469 return "SVGA3D_DEVCAP_FRAGMENT_SHADER";
470 case SVGA3D_DEVCAP_MAX_RENDER_TARGETS:
471 return "SVGA3D_DEVCAP_MAX_RENDER_TARGETS";
472 case SVGA3D_DEVCAP_S23E8_TEXTURES:
473 return "SVGA3D_DEVCAP_S23E8_TEXTURES";
474 case SVGA3D_DEVCAP_S10E5_TEXTURES:
475 return "SVGA3D_DEVCAP_S10E5_TEXTURES";
476 case SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND:
477 return "SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND";
478 case SVGA3D_DEVCAP_D16_BUFFER_FORMAT:
479 return "SVGA3D_DEVCAP_D16_BUFFER_FORMAT";
480 case SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT:
481 return "SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT";
482 case SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT:
483 return "SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT";
484 case SVGA3D_DEVCAP_QUERY_TYPES:
485 return "SVGA3D_DEVCAP_QUERY_TYPES";
486 case SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING:
487 return "SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING";
488 case SVGA3D_DEVCAP_MAX_POINT_SIZE:
489 return "SVGA3D_DEVCAP_MAX_POINT_SIZE";
490 case SVGA3D_DEVCAP_MAX_SHADER_TEXTURES:
491 return "SVGA3D_DEVCAP_MAX_SHADER_TEXTURES";
492 case SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH:
493 return "SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH";
494 case SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT:
495 return "SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT";
496 case SVGA3D_DEVCAP_MAX_VOLUME_EXTENT:
497 return "SVGA3D_DEVCAP_MAX_VOLUME_EXTENT";
498 case SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT:
499 return "SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT";
500 case SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO:
501 return "SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO";
502 case SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY:
503 return "SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY";
504 case SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT:
505 return "SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT";
506 case SVGA3D_DEVCAP_MAX_VERTEX_INDEX:
507 return "SVGA3D_DEVCAP_MAX_VERTEX_INDEX";
508 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS:
509 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS";
510 case SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS:
511 return "SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS";
512 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS:
513 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS";
514 case SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS:
515 return "SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS";
516 case SVGA3D_DEVCAP_TEXTURE_OPS:
517 return "SVGA3D_DEVCAP_TEXTURE_OPS";
518 case SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES:
519 return "SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES";
520 case SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES:
521 return "SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES";
522 case SVGA3D_DEVCAP_ALPHATOCOVERAGE:
523 return "SVGA3D_DEVCAP_ALPHATOCOVERAGE";
524 case SVGA3D_DEVCAP_SUPERSAMPLE:
525 return "SVGA3D_DEVCAP_SUPERSAMPLE";
526 case SVGA3D_DEVCAP_AUTOGENMIPMAPS:
527 return "SVGA3D_DEVCAP_AUTOGENMIPMAPS";
528 case SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES:
529 return "SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES";
530 case SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS:
531 return "SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS";
532 case SVGA3D_DEVCAP_MAX_CONTEXT_IDS:
533 return "SVGA3D_DEVCAP_MAX_CONTEXT_IDS";
534 case SVGA3D_DEVCAP_MAX_SURFACE_IDS:
535 return "SVGA3D_DEVCAP_MAX_SURFACE_IDS";
536 case SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8:
537 return "SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8";
538 case SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8:
539 return "SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8";
540 case SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10:
541 return "SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10";
542 case SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5:
543 return "SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5";
544 case SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5:
545 return "SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5";
546 case SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4:
547 return "SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4";
548 case SVGA3D_DEVCAP_SURFACEFMT_R5G6B5:
549 return "SVGA3D_DEVCAP_SURFACEFMT_R5G6B5";
550 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16:
551 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16";
552 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8:
553 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8";
554 case SVGA3D_DEVCAP_SURFACEFMT_ALPHA8:
555 return "SVGA3D_DEVCAP_SURFACEFMT_ALPHA8";
556 case SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8:
557 return "SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8";
558 case SVGA3D_DEVCAP_SURFACEFMT_Z_D16:
559 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D16";
560 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8:
561 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8";
562 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8:
563 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8";
564 case SVGA3D_DEVCAP_SURFACEFMT_Z_DF16:
565 return "SVGA3D_DEVCAP_SURFACEFMT_Z_DF16";
566 case SVGA3D_DEVCAP_SURFACEFMT_Z_DF24:
567 return "SVGA3D_DEVCAP_SURFACEFMT_Z_DF24";
568 case SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT:
569 return "SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT";
570 case SVGA3D_DEVCAP_SURFACEFMT_DXT1:
571 return "SVGA3D_DEVCAP_SURFACEFMT_DXT1";
572 case SVGA3D_DEVCAP_SURFACEFMT_DXT2:
573 return "SVGA3D_DEVCAP_SURFACEFMT_DXT2";
574 case SVGA3D_DEVCAP_SURFACEFMT_DXT3:
575 return "SVGA3D_DEVCAP_SURFACEFMT_DXT3";
576 case SVGA3D_DEVCAP_SURFACEFMT_DXT4:
577 return "SVGA3D_DEVCAP_SURFACEFMT_DXT4";
578 case SVGA3D_DEVCAP_SURFACEFMT_DXT5:
579 return "SVGA3D_DEVCAP_SURFACEFMT_DXT5";
580 case SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8:
581 return "SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8";
582 case SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10:
583 return "SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10";
584 case SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8:
585 return "SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8";
586 case SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8:
587 return "SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8";
588 case SVGA3D_DEVCAP_SURFACEFMT_CxV8U8:
589 return "SVGA3D_DEVCAP_SURFACEFMT_CxV8U8";
590 case SVGA3D_DEVCAP_SURFACEFMT_R_S10E5:
591 return "SVGA3D_DEVCAP_SURFACEFMT_R_S10E5";
592 case SVGA3D_DEVCAP_SURFACEFMT_R_S23E8:
593 return "SVGA3D_DEVCAP_SURFACEFMT_R_S23E8";
594 case SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5:
595 return "SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5";
596 case SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8:
597 return "SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8";
598 case SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5:
599 return "SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5";
600 case SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8:
601 return "SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8";
602 case SVGA3D_DEVCAP_SURFACEFMT_V16U16:
603 return "SVGA3D_DEVCAP_SURFACEFMT_V16U16";
604 case SVGA3D_DEVCAP_SURFACEFMT_G16R16:
605 return "SVGA3D_DEVCAP_SURFACEFMT_G16R16";
606 case SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16:
607 return "SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16";
608 case SVGA3D_DEVCAP_SURFACEFMT_UYVY:
609 return "SVGA3D_DEVCAP_SURFACEFMT_UYVY";
610 case SVGA3D_DEVCAP_SURFACEFMT_YUY2:
611 return "SVGA3D_DEVCAP_SURFACEFMT_YUY2";
612 case SVGA3D_DEVCAP_SURFACEFMT_NV12:
613 return "SVGA3D_DEVCAP_SURFACEFMT_NV12";
614 case SVGA3D_DEVCAP_SURFACEFMT_AYUV:
615 return "SVGA3D_DEVCAP_SURFACEFMT_AYUV";
616 case SVGA3D_DEVCAP_SURFACEFMT_BC4_UNORM:
617 return "SVGA3D_DEVCAP_SURFACEFMT_BC4_UNORM";
618 case SVGA3D_DEVCAP_SURFACEFMT_BC5_UNORM:
619 return "SVGA3D_DEVCAP_SURFACEFMT_BC5_UNORM";
620 default:
621 return "UNEXPECTED";
622 }
623}
624
625const char *vmsvga3dGet3dFormatString(uint32_t format)
626{
627 static char szFormat[1024];
628
629 szFormat[0] = 0;
630
631 if (format & SVGA3DFORMAT_OP_TEXTURE)
632 strcat(szFormat, " - SVGA3DFORMAT_OP_TEXTURE\n");
633 if (format & SVGA3DFORMAT_OP_VOLUMETEXTURE)
634 strcat(szFormat, " - SVGA3DFORMAT_OP_VOLUMETEXTURE\n");
635 if (format & SVGA3DFORMAT_OP_CUBETEXTURE)
636 strcat(szFormat, " - SVGA3DFORMAT_OP_CUBETEXTURE\n");
637 if (format & SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET)
638 strcat(szFormat, " - SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET\n");
639 if (format & SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET)
640 strcat(szFormat, " - SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET\n");
641 if (format & SVGA3DFORMAT_OP_ZSTENCIL)
642 strcat(szFormat, " - SVGA3DFORMAT_OP_ZSTENCIL\n");
643 if (format & SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH)
644 strcat(szFormat, " - SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH\n");
645 if (format & SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET)
646 strcat(szFormat, " - SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET\n");
647 if (format & SVGA3DFORMAT_OP_DISPLAYMODE)
648 strcat(szFormat, " - SVGA3DFORMAT_OP_DISPLAYMODE\n");
649 if (format & SVGA3DFORMAT_OP_3DACCELERATION)
650 strcat(szFormat, " - SVGA3DFORMAT_OP_3DACCELERATION\n");
651 if (format & SVGA3DFORMAT_OP_PIXELSIZE)
652 strcat(szFormat, " - SVGA3DFORMAT_OP_PIXELSIZE\n");
653 if (format & SVGA3DFORMAT_OP_CONVERT_TO_ARGB)
654 strcat(szFormat, " - SVGA3DFORMAT_OP_CONVERT_TO_ARGB\n");
655 if (format & SVGA3DFORMAT_OP_OFFSCREENPLAIN)
656 strcat(szFormat, " - SVGA3DFORMAT_OP_OFFSCREENPLAIN\n");
657 if (format & SVGA3DFORMAT_OP_SRGBREAD)
658 strcat(szFormat, " - SVGA3DFORMAT_OP_SRGBREAD\n");
659 if (format & SVGA3DFORMAT_OP_BUMPMAP)
660 strcat(szFormat, " - SVGA3DFORMAT_OP_BUMPMAP\n");
661 if (format & SVGA3DFORMAT_OP_DMAP)
662 strcat(szFormat, " - SVGA3DFORMAT_OP_DMAP\n");
663 if (format & SVGA3DFORMAT_OP_NOFILTER)
664 strcat(szFormat, " - SVGA3DFORMAT_OP_NOFILTER\n");
665 if (format & SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB)
666 strcat(szFormat, " - SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB\n");
667 if (format & SVGA3DFORMAT_OP_SRGBWRITE)
668 strcat(szFormat, " - SVGA3DFORMAT_OP_SRGBWRITE\n");
669 if (format & SVGA3DFORMAT_OP_NOALPHABLEND)
670 strcat(szFormat, " - SVGA3DFORMAT_OP_NOALPHABLEND\n");
671 if (format & SVGA3DFORMAT_OP_AUTOGENMIPMAP)
672 strcat(szFormat, " - SVGA3DFORMAT_OP_AUTOGENMIPMAP\n");
673 if (format & SVGA3DFORMAT_OP_VERTEXTEXTURE)
674 strcat(szFormat, " - SVGA3DFORMAT_OP_VERTEXTEXTURE\n");
675 if (format & SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP)
676 strcat(szFormat, " - SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP\n");
677 return szFormat;
678}
679
680const char *vmsvga3dGetRenderStateName(uint32_t state)
681{
682 switch (state)
683 {
684 case SVGA3D_RS_ZENABLE: /* SVGA3dBool */
685 return "SVGA3D_RS_ZENABLE";
686 case SVGA3D_RS_ZWRITEENABLE: /* SVGA3dBool */
687 return "SVGA3D_RS_ZWRITEENABLE";
688 case SVGA3D_RS_ALPHATESTENABLE: /* SVGA3dBool */
689 return "SVGA3D_RS_ALPHATESTENABLE";
690 case SVGA3D_RS_DITHERENABLE: /* SVGA3dBool */
691 return "SVGA3D_RS_DITHERENABLE";
692 case SVGA3D_RS_BLENDENABLE: /* SVGA3dBool */
693 return "SVGA3D_RS_BLENDENABLE";
694 case SVGA3D_RS_FOGENABLE: /* SVGA3dBool */
695 return "SVGA3D_RS_FOGENABLE";
696 case SVGA3D_RS_SPECULARENABLE: /* SVGA3dBool */
697 return "SVGA3D_RS_SPECULARENABLE";
698 case SVGA3D_RS_STENCILENABLE: /* SVGA3dBool */
699 return "SVGA3D_RS_STENCILENABLE";
700 case SVGA3D_RS_LIGHTINGENABLE: /* SVGA3dBool */
701 return "SVGA3D_RS_LIGHTINGENABLE";
702 case SVGA3D_RS_NORMALIZENORMALS: /* SVGA3dBool */
703 return "SVGA3D_RS_NORMALIZENORMALS";
704 case SVGA3D_RS_POINTSPRITEENABLE: /* SVGA3dBool */
705 return "SVGA3D_RS_POINTSPRITEENABLE";
706 case SVGA3D_RS_POINTSCALEENABLE: /* SVGA3dBool */
707 return "SVGA3D_RS_POINTSCALEENABLE";
708 case SVGA3D_RS_STENCILREF: /* uint32_t */
709 return "SVGA3D_RS_STENCILREF";
710 case SVGA3D_RS_STENCILMASK: /* uint32_t */
711 return "SVGA3D_RS_STENCILMASK";
712 case SVGA3D_RS_STENCILWRITEMASK: /* uint32_t */
713 return "SVGA3D_RS_STENCILWRITEMASK";
714 case SVGA3D_RS_POINTSIZE: /* float */
715 return "SVGA3D_RS_POINTSIZE";
716 case SVGA3D_RS_POINTSIZEMIN: /* float */
717 return "SVGA3D_RS_POINTSIZEMIN";
718 case SVGA3D_RS_POINTSIZEMAX: /* float */
719 return "SVGA3D_RS_POINTSIZEMAX";
720 case SVGA3D_RS_POINTSCALE_A: /* float */
721 return "SVGA3D_RS_POINTSCALE_A";
722 case SVGA3D_RS_POINTSCALE_B: /* float */
723 return "SVGA3D_RS_POINTSCALE_B";
724 case SVGA3D_RS_POINTSCALE_C: /* float */
725 return "SVGA3D_RS_POINTSCALE_C";
726 case SVGA3D_RS_AMBIENT: /* SVGA3dColor - identical */
727 return "SVGA3D_RS_AMBIENT";
728 case SVGA3D_RS_CLIPPLANEENABLE: /* SVGA3dClipPlanes - identical */
729 return "SVGA3D_RS_CLIPPLANEENABLE";
730 case SVGA3D_RS_FOGCOLOR: /* SVGA3dColor - identical */
731 return "SVGA3D_RS_FOGCOLOR";
732 case SVGA3D_RS_FOGSTART: /* float */
733 return "SVGA3D_RS_FOGSTART";
734 case SVGA3D_RS_FOGEND: /* float */
735 return "SVGA3D_RS_FOGEND";
736 case SVGA3D_RS_FOGDENSITY: /* float */
737 return "SVGA3D_RS_FOGDENSITY";
738 case SVGA3D_RS_RANGEFOGENABLE: /* SVGA3dBool */
739 return "SVGA3D_RS_RANGEFOGENABLE";
740 case SVGA3D_RS_FOGMODE: /* SVGA3dFogMode */
741 return "SVGA3D_RS_FOGMODE";
742 case SVGA3D_RS_FILLMODE: /* SVGA3dFillMode */
743 return "SVGA3D_RS_FILLMODE";
744 case SVGA3D_RS_SHADEMODE: /* SVGA3dShadeMode */
745 return "SVGA3D_RS_SHADEMODE";
746 case SVGA3D_RS_LINEPATTERN: /* SVGA3dLinePattern */
747 return "SVGA3D_RS_LINEPATTERN";
748 case SVGA3D_RS_SRCBLEND: /* SVGA3dBlendOp */
749 return "SVGA3D_RS_SRCBLEND";
750 case SVGA3D_RS_DSTBLEND: /* SVGA3dBlendOp */
751 return "SVGA3D_RS_DSTBLEND";
752 case SVGA3D_RS_BLENDEQUATION: /* SVGA3dBlendEquation */
753 return "SVGA3D_RS_BLENDEQUATION";
754 case SVGA3D_RS_CULLMODE: /* SVGA3dFace */
755 return "SVGA3D_RS_CULLMODE";
756 case SVGA3D_RS_ZFUNC: /* SVGA3dCmpFunc */
757 return "SVGA3D_RS_ZFUNC";
758 case SVGA3D_RS_ALPHAFUNC: /* SVGA3dCmpFunc */
759 return "SVGA3D_RS_ALPHAFUNC";
760 case SVGA3D_RS_STENCILFUNC: /* SVGA3dCmpFunc */
761 return "SVGA3D_RS_STENCILFUNC";
762 case SVGA3D_RS_STENCILFAIL: /* SVGA3dStencilOp */
763 return "SVGA3D_RS_STENCILFAIL";
764 case SVGA3D_RS_STENCILZFAIL: /* SVGA3dStencilOp */
765 return "SVGA3D_RS_STENCILZFAIL";
766 case SVGA3D_RS_STENCILPASS: /* SVGA3dStencilOp */
767 return "SVGA3D_RS_STENCILPASS";
768 case SVGA3D_RS_ALPHAREF: /* float (0.0 .. 1.0) */
769 return "SVGA3D_RS_ALPHAREF";
770 case SVGA3D_RS_FRONTWINDING: /* SVGA3dFrontWinding */
771 return "SVGA3D_RS_FRONTWINDING";
772 case SVGA3D_RS_COORDINATETYPE: /* SVGA3dCoordinateType */
773 return "SVGA3D_RS_COORDINATETYPE";
774 case SVGA3D_RS_ZBIAS: /* float */
775 return "SVGA3D_RS_ZBIAS";
776 case SVGA3D_RS_COLORWRITEENABLE: /* SVGA3dColorMask */
777 return "SVGA3D_RS_COLORWRITEENABLE";
778 case SVGA3D_RS_VERTEXMATERIALENABLE: /* SVGA3dBool */
779 return "SVGA3D_RS_VERTEXMATERIALENABLE";
780 case SVGA3D_RS_DIFFUSEMATERIALSOURCE: /* SVGA3dVertexMaterial */
781 return "SVGA3D_RS_DIFFUSEMATERIALSOURCE";
782 case SVGA3D_RS_SPECULARMATERIALSOURCE: /* SVGA3dVertexMaterial */
783 return "SVGA3D_RS_SPECULARMATERIALSOURCE";
784 case SVGA3D_RS_AMBIENTMATERIALSOURCE: /* SVGA3dVertexMaterial */
785 return "SVGA3D_RS_AMBIENTMATERIALSOURCE";
786 case SVGA3D_RS_EMISSIVEMATERIALSOURCE: /* SVGA3dVertexMaterial */
787 return "SVGA3D_RS_EMISSIVEMATERIALSOURCE";
788 case SVGA3D_RS_TEXTUREFACTOR: /* SVGA3dColor */
789 return "SVGA3D_RS_TEXTUREFACTOR";
790 case SVGA3D_RS_LOCALVIEWER: /* SVGA3dBool */
791 return "SVGA3D_RS_LOCALVIEWER";
792 case SVGA3D_RS_SCISSORTESTENABLE: /* SVGA3dBool */
793 return "SVGA3D_RS_SCISSORTESTENABLE";
794 case SVGA3D_RS_BLENDCOLOR: /* SVGA3dColor */
795 return "SVGA3D_RS_BLENDCOLOR";
796 case SVGA3D_RS_STENCILENABLE2SIDED: /* SVGA3dBool */
797 return "SVGA3D_RS_STENCILENABLE2SIDED";
798 case SVGA3D_RS_CCWSTENCILFUNC: /* SVGA3dCmpFunc */
799 return "SVGA3D_RS_CCWSTENCILFUNC";
800 case SVGA3D_RS_CCWSTENCILFAIL: /* SVGA3dStencilOp */
801 return "SVGA3D_RS_CCWSTENCILFAIL";
802 case SVGA3D_RS_CCWSTENCILZFAIL: /* SVGA3dStencilOp */
803 return "SVGA3D_RS_CCWSTENCILZFAIL";
804 case SVGA3D_RS_CCWSTENCILPASS: /* SVGA3dStencilOp */
805 return "SVGA3D_RS_CCWSTENCILPASS";
806 case SVGA3D_RS_VERTEXBLEND: /* SVGA3dVertexBlendFlags */
807 return "SVGA3D_RS_VERTEXBLEND";
808 case SVGA3D_RS_SLOPESCALEDEPTHBIAS: /* float */
809 return "SVGA3D_RS_SLOPESCALEDEPTHBIAS";
810 case SVGA3D_RS_DEPTHBIAS: /* float */
811 return "SVGA3D_RS_DEPTHBIAS";
812 case SVGA3D_RS_OUTPUTGAMMA: /* float */
813 return "SVGA3D_RS_OUTPUTGAMMA";
814 case SVGA3D_RS_ZVISIBLE: /* SVGA3dBool */
815 return "SVGA3D_RS_ZVISIBLE";
816 case SVGA3D_RS_LASTPIXEL: /* SVGA3dBool */
817 return "SVGA3D_RS_LASTPIXEL";
818 case SVGA3D_RS_CLIPPING: /* SVGA3dBool */
819 return "SVGA3D_RS_CLIPPING";
820 case SVGA3D_RS_WRAP0: /* SVGA3dWrapFlags */
821 return "SVGA3D_RS_WRAP0";
822 case SVGA3D_RS_WRAP1: /* SVGA3dWrapFlags */
823 return "SVGA3D_RS_WRAP1";
824 case SVGA3D_RS_WRAP2: /* SVGA3dWrapFlags */
825 return "SVGA3D_RS_WRAP2";
826 case SVGA3D_RS_WRAP3: /* SVGA3dWrapFlags */
827 return "SVGA3D_RS_WRAP3";
828 case SVGA3D_RS_WRAP4: /* SVGA3dWrapFlags */
829 return "SVGA3D_RS_WRAP4";
830 case SVGA3D_RS_WRAP5: /* SVGA3dWrapFlags */
831 return "SVGA3D_RS_WRAP5";
832 case SVGA3D_RS_WRAP6: /* SVGA3dWrapFlags */
833 return "SVGA3D_RS_WRAP6";
834 case SVGA3D_RS_WRAP7: /* SVGA3dWrapFlags */
835 return "SVGA3D_RS_WRAP7";
836 case SVGA3D_RS_WRAP8: /* SVGA3dWrapFlags */
837 return "SVGA3D_RS_WRAP8";
838 case SVGA3D_RS_WRAP9: /* SVGA3dWrapFlags */
839 return "SVGA3D_RS_WRAP9";
840 case SVGA3D_RS_WRAP10: /* SVGA3dWrapFlags */
841 return "SVGA3D_RS_WRAP10";
842 case SVGA3D_RS_WRAP11: /* SVGA3dWrapFlags */
843 return "SVGA3D_RS_WRAP11";
844 case SVGA3D_RS_WRAP12: /* SVGA3dWrapFlags */
845 return "SVGA3D_RS_WRAP12";
846 case SVGA3D_RS_WRAP13: /* SVGA3dWrapFlags */
847 return "SVGA3D_RS_WRAP13";
848 case SVGA3D_RS_WRAP14: /* SVGA3dWrapFlags */
849 return "SVGA3D_RS_WRAP14";
850 case SVGA3D_RS_WRAP15: /* SVGA3dWrapFlags */
851 return "SVGA3D_RS_WRAP15";
852 case SVGA3D_RS_MULTISAMPLEANTIALIAS: /* SVGA3dBool */
853 return "SVGA3D_RS_MULTISAMPLEANTIALIAS";
854 case SVGA3D_RS_MULTISAMPLEMASK: /* uint32_t */
855 return "SVGA3D_RS_MULTISAMPLEMASK";
856 case SVGA3D_RS_INDEXEDVERTEXBLENDENABLE: /* SVGA3dBool */
857 return "SVGA3D_RS_INDEXEDVERTEXBLENDENABLE";
858 case SVGA3D_RS_TWEENFACTOR: /* float */
859 return "SVGA3D_RS_TWEENFACTOR";
860 case SVGA3D_RS_ANTIALIASEDLINEENABLE: /* SVGA3dBool */
861 return "SVGA3D_RS_ANTIALIASEDLINEENABLE";
862 case SVGA3D_RS_COLORWRITEENABLE1: /* SVGA3dColorMask */
863 return "SVGA3D_RS_COLORWRITEENABLE1";
864 case SVGA3D_RS_COLORWRITEENABLE2: /* SVGA3dColorMask */
865 return "SVGA3D_RS_COLORWRITEENABLE2";
866 case SVGA3D_RS_COLORWRITEENABLE3: /* SVGA3dColorMask */
867 return "SVGA3D_RS_COLORWRITEENABLE3";
868 case SVGA3D_RS_SEPARATEALPHABLENDENABLE: /* SVGA3dBool */
869 return "SVGA3D_RS_SEPARATEALPHABLENDENABLE";
870 case SVGA3D_RS_SRCBLENDALPHA: /* SVGA3dBlendOp */
871 return "SVGA3D_RS_SRCBLENDALPHA";
872 case SVGA3D_RS_DSTBLENDALPHA: /* SVGA3dBlendOp */
873 return "SVGA3D_RS_DSTBLENDALPHA";
874 case SVGA3D_RS_BLENDEQUATIONALPHA: /* SVGA3dBlendEquation */
875 return "SVGA3D_RS_BLENDEQUATIONALPHA";
876 case SVGA3D_RS_TRANSPARENCYANTIALIAS: /* SVGA3dTransparencyAntialiasType */
877 return "SVGA3D_RS_TRANSPARENCYANTIALIAS";
878 case SVGA3D_RS_LINEAA: /* SVGA3dBool */
879 return "SVGA3D_RS_LINEAA";
880 case SVGA3D_RS_LINEWIDTH: /* float */
881 return "SVGA3D_RS_LINEWIDTH";
882 default:
883 return "UNKNOWN";
884 }
885}
886
887const char *vmsvga3dTextureStateToString(SVGA3dTextureStateName textureState)
888{
889 switch (textureState)
890 {
891 case SVGA3D_TS_BIND_TEXTURE:
892 return "SVGA3D_TS_BIND_TEXTURE";
893 case SVGA3D_TS_COLOROP:
894 return "SVGA3D_TS_COLOROP";
895 case SVGA3D_TS_COLORARG1:
896 return "SVGA3D_TS_COLORARG1";
897 case SVGA3D_TS_COLORARG2:
898 return "SVGA3D_TS_COLORARG2";
899 case SVGA3D_TS_ALPHAOP:
900 return "SVGA3D_TS_ALPHAOP";
901 case SVGA3D_TS_ALPHAARG1:
902 return "SVGA3D_TS_ALPHAARG1";
903 case SVGA3D_TS_ALPHAARG2:
904 return "SVGA3D_TS_ALPHAARG2";
905 case SVGA3D_TS_ADDRESSU:
906 return "SVGA3D_TS_ADDRESSU";
907 case SVGA3D_TS_ADDRESSV:
908 return "SVGA3D_TS_ADDRESSV";
909 case SVGA3D_TS_MIPFILTER:
910 return "SVGA3D_TS_MIPFILTER";
911 case SVGA3D_TS_MAGFILTER:
912 return "SVGA3D_TS_MAGFILTER";
913 case SVGA3D_TS_MINFILTER:
914 return "SVGA3D_TS_MINFILTER";
915 case SVGA3D_TS_BORDERCOLOR:
916 return "SVGA3D_TS_BORDERCOLOR";
917 case SVGA3D_TS_TEXCOORDINDEX:
918 return "SVGA3D_TS_TEXCOORDINDEX";
919 case SVGA3D_TS_TEXTURETRANSFORMFLAGS:
920 return "SVGA3D_TS_TEXTURETRANSFORMFLAGS";
921 case SVGA3D_TS_TEXCOORDGEN:
922 return "SVGA3D_TS_TEXCOORDGEN";
923 case SVGA3D_TS_BUMPENVMAT00:
924 return "SVGA3D_TS_BUMPENVMAT00";
925 case SVGA3D_TS_BUMPENVMAT01:
926 return "SVGA3D_TS_BUMPENVMAT01";
927 case SVGA3D_TS_BUMPENVMAT10:
928 return "SVGA3D_TS_BUMPENVMAT10";
929 case SVGA3D_TS_BUMPENVMAT11:
930 return "SVGA3D_TS_BUMPENVMAT11";
931 case SVGA3D_TS_TEXTURE_MIPMAP_LEVEL:
932 return "SVGA3D_TS_TEXTURE_MIPMAP_LEVEL";
933 case SVGA3D_TS_TEXTURE_LOD_BIAS:
934 return "SVGA3D_TS_TEXTURE_LOD_BIAS";
935 case SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL:
936 return "SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL";
937 case SVGA3D_TS_ADDRESSW:
938 return "SVGA3D_TS_ADDRESSW";
939 case SVGA3D_TS_GAMMA:
940 return "SVGA3D_TS_GAMMA";
941 case SVGA3D_TS_BUMPENVLSCALE:
942 return "SVGA3D_TS_BUMPENVLSCALE";
943 case SVGA3D_TS_BUMPENVLOFFSET:
944 return "SVGA3D_TS_BUMPENVLOFFSET";
945 case SVGA3D_TS_COLORARG0:
946 return "SVGA3D_TS_COLORARG0";
947 case SVGA3D_TS_ALPHAARG0:
948 return "SVGA3D_TS_ALPHAARG0";
949 default:
950 return "UNKNOWN";
951 }
952}
953
954const char *vmsvgaTransformToString(SVGA3dTransformType type)
955{
956 switch (type)
957 {
958 case SVGA3D_TRANSFORM_INVALID:
959 return "SVGA3D_TRANSFORM_INVALID";
960 case SVGA3D_TRANSFORM_WORLD:
961 return "SVGA3D_TRANSFORM_WORLD";
962 case SVGA3D_TRANSFORM_VIEW:
963 return "SVGA3D_TRANSFORM_VIEW";
964 case SVGA3D_TRANSFORM_PROJECTION:
965 return "SVGA3D_TRANSFORM_PROJECTION";
966 case SVGA3D_TRANSFORM_TEXTURE0:
967 return "SVGA3D_TRANSFORM_TEXTURE0";
968 case SVGA3D_TRANSFORM_TEXTURE1:
969 return "SVGA3D_TRANSFORM_TEXTURE1";
970 case SVGA3D_TRANSFORM_TEXTURE2:
971 return "SVGA3D_TRANSFORM_TEXTURE2";
972 case SVGA3D_TRANSFORM_TEXTURE3:
973 return "SVGA3D_TRANSFORM_TEXTURE3";
974 case SVGA3D_TRANSFORM_TEXTURE4:
975 return "SVGA3D_TRANSFORM_TEXTURE4";
976 case SVGA3D_TRANSFORM_TEXTURE5:
977 return "SVGA3D_TRANSFORM_TEXTURE5";
978 case SVGA3D_TRANSFORM_TEXTURE6:
979 return "SVGA3D_TRANSFORM_TEXTURE6";
980 case SVGA3D_TRANSFORM_TEXTURE7:
981 return "SVGA3D_TRANSFORM_TEXTURE7";
982 case SVGA3D_TRANSFORM_WORLD1:
983 return "SVGA3D_TRANSFORM_WORLD1";
984 case SVGA3D_TRANSFORM_WORLD2:
985 return "SVGA3D_TRANSFORM_WORLD2";
986 case SVGA3D_TRANSFORM_WORLD3:
987 return "SVGA3D_TRANSFORM_WORLD3";
988 default:
989 return "UNKNOWN";
990 }
991}
992
993const char *vmsvgaDeclUsage2String(SVGA3dDeclUsage usage)
994{
995 switch (usage)
996 {
997 case SVGA3D_DECLUSAGE_POSITION:
998 return "SVGA3D_DECLUSAGE_POSITION";
999 case SVGA3D_DECLUSAGE_BLENDWEIGHT:
1000 return "SVGA3D_DECLUSAGE_BLENDWEIGHT";
1001 case SVGA3D_DECLUSAGE_BLENDINDICES:
1002 return "SVGA3D_DECLUSAGE_BLENDINDICES";
1003 case SVGA3D_DECLUSAGE_NORMAL:
1004 return "SVGA3D_DECLUSAGE_NORMAL";
1005 case SVGA3D_DECLUSAGE_PSIZE:
1006 return "SVGA3D_DECLUSAGE_PSIZE";
1007 case SVGA3D_DECLUSAGE_TEXCOORD:
1008 return "SVGA3D_DECLUSAGE_TEXCOORD";
1009 case SVGA3D_DECLUSAGE_TANGENT:
1010 return "SVGA3D_DECLUSAGE_TANGENT";
1011 case SVGA3D_DECLUSAGE_BINORMAL:
1012 return "SVGA3D_DECLUSAGE_BINORMAL";
1013 case SVGA3D_DECLUSAGE_TESSFACTOR:
1014 return "SVGA3D_DECLUSAGE_TESSFACTOR";
1015 case SVGA3D_DECLUSAGE_POSITIONT:
1016 return "SVGA3D_DECLUSAGE_POSITIONT";
1017 case SVGA3D_DECLUSAGE_COLOR:
1018 return "SVGA3D_DECLUSAGE_COLOR";
1019 case SVGA3D_DECLUSAGE_FOG:
1020 return "SVGA3D_DECLUSAGE_FOG";
1021 case SVGA3D_DECLUSAGE_DEPTH:
1022 return "SVGA3D_DECLUSAGE_DEPTH";
1023 case SVGA3D_DECLUSAGE_SAMPLE:
1024 return "SVGA3D_DECLUSAGE_SAMPLE";
1025 default:
1026 return "UNKNOWN!!";
1027 }
1028}
1029
1030const char *vmsvgaDeclMethod2String(SVGA3dDeclMethod method)
1031{
1032 switch (method)
1033 {
1034 case SVGA3D_DECLMETHOD_DEFAULT:
1035 return "SVGA3D_DECLMETHOD_DEFAULT";
1036 case SVGA3D_DECLMETHOD_PARTIALU:
1037 return "SVGA3D_DECLMETHOD_PARTIALU";
1038 case SVGA3D_DECLMETHOD_PARTIALV:
1039 return "SVGA3D_DECLMETHOD_PARTIALV";
1040 case SVGA3D_DECLMETHOD_CROSSUV:
1041 return "SVGA3D_DECLMETHOD_CROSSUV";
1042 case SVGA3D_DECLMETHOD_UV:
1043 return "SVGA3D_DECLMETHOD_UV";
1044 case SVGA3D_DECLMETHOD_LOOKUP:
1045 return "SVGA3D_DECLMETHOD_LOOKUP";
1046 case SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED:
1047 return "SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED";
1048 default:
1049 return "UNKNOWN!!";
1050 }
1051}
1052
1053const char *vmsvgaDeclType2String(SVGA3dDeclType type)
1054{
1055 switch (type)
1056 {
1057 case SVGA3D_DECLTYPE_FLOAT1:
1058 return "SVGA3D_DECLTYPE_FLOAT1";
1059 case SVGA3D_DECLTYPE_FLOAT2:
1060 return "SVGA3D_DECLTYPE_FLOAT2";
1061 case SVGA3D_DECLTYPE_FLOAT3:
1062 return "SVGA3D_DECLTYPE_FLOAT3";
1063 case SVGA3D_DECLTYPE_FLOAT4:
1064 return "SVGA3D_DECLTYPE_FLOAT4";
1065 case SVGA3D_DECLTYPE_D3DCOLOR:
1066 return "SVGA3D_DECLTYPE_D3DCOLOR";
1067 case SVGA3D_DECLTYPE_UBYTE4:
1068 return "SVGA3D_DECLTYPE_UBYTE4";
1069 case SVGA3D_DECLTYPE_SHORT2:
1070 return "SVGA3D_DECLTYPE_SHORT2";
1071 case SVGA3D_DECLTYPE_SHORT4:
1072 return "SVGA3D_DECLTYPE_SHORT4";
1073 case SVGA3D_DECLTYPE_UBYTE4N:
1074 return "SVGA3D_DECLTYPE_UBYTE4N";
1075 case SVGA3D_DECLTYPE_SHORT2N:
1076 return "SVGA3D_DECLTYPE_SHORT2N";
1077 case SVGA3D_DECLTYPE_SHORT4N:
1078 return "SVGA3D_DECLTYPE_SHORT4N";
1079 case SVGA3D_DECLTYPE_USHORT2N:
1080 return "SVGA3D_DECLTYPE_USHORT2N";
1081 case SVGA3D_DECLTYPE_USHORT4N:
1082 return "SVGA3D_DECLTYPE_USHORT4N";
1083 case SVGA3D_DECLTYPE_UDEC3:
1084 return "SVGA3D_DECLTYPE_UDEC3";
1085 case SVGA3D_DECLTYPE_DEC3N:
1086 return "SVGA3D_DECLTYPE_DEC3N";
1087 case SVGA3D_DECLTYPE_FLOAT16_2:
1088 return "SVGA3D_DECLTYPE_FLOAT16_2";
1089 case SVGA3D_DECLTYPE_FLOAT16_4:
1090 return "SVGA3D_DECLTYPE_FLOAT16_4";
1091 default:
1092 return "UNKNOWN!!";
1093 }
1094}
1095
1096const char *vmsvga3dPrimitiveType2String(SVGA3dPrimitiveType PrimitiveType)
1097{
1098 switch (PrimitiveType)
1099 {
1100 case SVGA3D_PRIMITIVE_TRIANGLELIST:
1101 return "SVGA3D_PRIMITIVE_TRIANGLELIST";
1102 case SVGA3D_PRIMITIVE_POINTLIST:
1103 return "SVGA3D_PRIMITIVE_POINTLIST";
1104 case SVGA3D_PRIMITIVE_LINELIST:
1105 return "SVGA3D_PRIMITIVE_LINELIST";
1106 case SVGA3D_PRIMITIVE_LINESTRIP:
1107 return "SVGA3D_PRIMITIVE_LINESTRIP";
1108 case SVGA3D_PRIMITIVE_TRIANGLESTRIP:
1109 return "SVGA3D_PRIMITIVE_TRIANGLESTRIP";
1110 case SVGA3D_PRIMITIVE_TRIANGLEFAN:
1111 return "SVGA3D_PRIMITIVE_TRIANGLEFAN";
1112 default:
1113 return "UNKNOWN";
1114 }
1115}
1116
1117#endif /* LOG_ENABLED */
1118
1119/** Unsigned coordinates in pBox. Clip to [0; pSizeSrc), [0;pSizeDest).
1120 *
1121 * @param pSizeSrc Source surface dimensions.
1122 * @param pSizeDest Destination surface dimensions.
1123 * @param pBox Coordinates to be clipped.
1124 */
1125void vmsvgaClipCopyBox(const SVGA3dSize *pSizeSrc,
1126 const SVGA3dSize *pSizeDest,
1127 SVGA3dCopyBox *pBox)
1128{
1129 /* Src x, w */
1130 if (pBox->srcx > pSizeSrc->width)
1131 pBox->srcx = pSizeSrc->width;
1132 if (pBox->w > pSizeSrc->width - pBox->srcx)
1133 pBox->w = pSizeSrc->width - pBox->srcx;
1134
1135 /* Src y, h */
1136 if (pBox->srcy > pSizeSrc->height)
1137 pBox->srcy = pSizeSrc->height;
1138 if (pBox->h > pSizeSrc->height - pBox->srcy)
1139 pBox->h = pSizeSrc->height - pBox->srcy;
1140
1141 /* Src z, d */
1142 if (pBox->srcz > pSizeSrc->depth)
1143 pBox->srcz = pSizeSrc->depth;
1144 if (pBox->d > pSizeSrc->depth - pBox->srcz)
1145 pBox->d = pSizeSrc->depth - pBox->srcz;
1146
1147 /* Dest x, w */
1148 if (pBox->x > pSizeDest->width)
1149 pBox->x = pSizeDest->width;
1150 if (pBox->w > pSizeDest->width - pBox->x)
1151 pBox->w = pSizeDest->width - pBox->x;
1152
1153 /* Dest y, h */
1154 if (pBox->y > pSizeDest->height)
1155 pBox->y = pSizeDest->height;
1156 if (pBox->h > pSizeDest->height - pBox->y)
1157 pBox->h = pSizeDest->height - pBox->y;
1158
1159 /* Dest z, d */
1160 if (pBox->z > pSizeDest->depth)
1161 pBox->z = pSizeDest->depth;
1162 if (pBox->d > pSizeDest->depth - pBox->z)
1163 pBox->d = pSizeDest->depth - pBox->z;
1164}
1165
1166/** Unsigned coordinates in pBox. Clip to [0; pSize).
1167 *
1168 * @param pSize Source surface dimensions.
1169 * @param pBox Coordinates to be clipped.
1170 */
1171void vmsvgaClipBox(const SVGA3dSize *pSize,
1172 SVGA3dBox *pBox)
1173{
1174 /* x, w */
1175 if (pBox->x > pSize->width)
1176 pBox->x = pSize->width;
1177 if (pBox->w > pSize->width - pBox->x)
1178 pBox->w = pSize->width - pBox->x;
1179
1180 /* y, h */
1181 if (pBox->y > pSize->height)
1182 pBox->y = pSize->height;
1183 if (pBox->h > pSize->height - pBox->y)
1184 pBox->h = pSize->height - pBox->y;
1185
1186 /* z, d */
1187 if (pBox->z > pSize->depth)
1188 pBox->z = pSize->depth;
1189 if (pBox->d > pSize->depth - pBox->z)
1190 pBox->d = pSize->depth - pBox->z;
1191}
1192
1193/** Clip.
1194 *
1195 * @param pBound Bounding rectangle.
1196 * @param pRect Rectangle to be clipped.
1197 */
1198void vmsvgaClipRect(SVGASignedRect const *pBound,
1199 SVGASignedRect *pRect)
1200{
1201 int32_t left;
1202 int32_t top;
1203 int32_t right;
1204 int32_t bottom;
1205
1206 /* Right order. */
1207 Assert(pBound->left <= pBound->right && pBound->top <= pBound->bottom);
1208 if (pRect->left < pRect->right)
1209 {
1210 left = pRect->left;
1211 right = pRect->right;
1212 }
1213 else
1214 {
1215 left = pRect->right;
1216 right = pRect->left;
1217 }
1218 if (pRect->top < pRect->bottom)
1219 {
1220 top = pRect->top;
1221 bottom = pRect->bottom;
1222 }
1223 else
1224 {
1225 top = pRect->bottom;
1226 bottom = pRect->top;
1227 }
1228
1229 if (left < pBound->left)
1230 left = pBound->left;
1231 if (right < pBound->left)
1232 right = pBound->left;
1233
1234 if (left > pBound->right)
1235 left = pBound->right;
1236 if (right > pBound->right)
1237 right = pBound->right;
1238
1239 if (top < pBound->top)
1240 top = pBound->top;
1241 if (bottom < pBound->top)
1242 bottom = pBound->top;
1243
1244 if (top > pBound->bottom)
1245 top = pBound->bottom;
1246 if (bottom > pBound->bottom)
1247 bottom = pBound->bottom;
1248
1249 pRect->left = left;
1250 pRect->right = right;
1251 pRect->top = top;
1252 pRect->bottom = bottom;
1253}
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