VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp@ 95685

Last change on this file since 95685 was 95288, checked in by vboxsync, 2 years ago

Devices/Graphics: generic screen update function. bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 276.3 KB
Line 
1/* $Id: DevVGA-SVGA-cmd.cpp 95288 2022-06-15 15:11:14Z vboxsync $ */
2/** @file
3 * VMware SVGA device - implementation of VMSVGA commands.
4 */
5
6/*
7 * Copyright (C) 2013-2022 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#ifndef IN_RING3
19# error "DevVGA-SVGA-cmd.cpp is only for ring-3 code"
20#endif
21
22
23#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
24#include <iprt/mem.h>
25#include <VBox/AssertGuest.h>
26#include <VBox/log.h>
27#include <VBox/vmm/pdmdev.h>
28#include <VBoxVideo.h>
29
30/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
31#include "DevVGA.h"
32
33/* Should be included after DevVGA.h/DevVGA-SVGA.h to pick all defines. */
34#ifdef VBOX_WITH_VMSVGA3D
35# include "DevVGA-SVGA3d.h"
36#endif
37#include "DevVGA-SVGA-internal.h"
38
39#include <iprt/formats/bmp.h>
40#include <stdio.h>
41
42#if defined(LOG_ENABLED) || defined(VBOX_STRICT)
43# define SVGA_CASE_ID2STR(idx) case idx: return #idx
44
45static const char *vmsvgaFifo3dCmdToString(SVGAFifo3dCmdId enmCmdId)
46{
47 switch (enmCmdId)
48 {
49 SVGA_CASE_ID2STR(SVGA_3D_CMD_LEGACY_BASE);
50 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DEFINE);
51 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DESTROY);
52 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_COPY);
53 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_STRETCHBLT);
54 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DMA);
55 SVGA_CASE_ID2STR(SVGA_3D_CMD_CONTEXT_DEFINE);
56 SVGA_CASE_ID2STR(SVGA_3D_CMD_CONTEXT_DESTROY);
57 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETTRANSFORM);
58 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETZRANGE);
59 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETRENDERSTATE);
60 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETRENDERTARGET);
61 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETTEXTURESTATE);
62 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETMATERIAL);
63 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETLIGHTDATA);
64 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETLIGHTENABLED);
65 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETVIEWPORT);
66 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETCLIPPLANE);
67 SVGA_CASE_ID2STR(SVGA_3D_CMD_CLEAR);
68 SVGA_CASE_ID2STR(SVGA_3D_CMD_PRESENT);
69 SVGA_CASE_ID2STR(SVGA_3D_CMD_SHADER_DEFINE);
70 SVGA_CASE_ID2STR(SVGA_3D_CMD_SHADER_DESTROY);
71 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_SHADER);
72 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_SHADER_CONST);
73 SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW_PRIMITIVES);
74 SVGA_CASE_ID2STR(SVGA_3D_CMD_SETSCISSORRECT);
75 SVGA_CASE_ID2STR(SVGA_3D_CMD_BEGIN_QUERY);
76 SVGA_CASE_ID2STR(SVGA_3D_CMD_END_QUERY);
77 SVGA_CASE_ID2STR(SVGA_3D_CMD_WAIT_FOR_QUERY);
78 SVGA_CASE_ID2STR(SVGA_3D_CMD_PRESENT_READBACK);
79 SVGA_CASE_ID2STR(SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN);
80 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DEFINE_V2);
81 SVGA_CASE_ID2STR(SVGA_3D_CMD_GENERATE_MIPMAPS);
82 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD4); /* SVGA_3D_CMD_VIDEO_CREATE_DECODER */
83 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD5); /* SVGA_3D_CMD_VIDEO_DESTROY_DECODER */
84 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD6); /* SVGA_3D_CMD_VIDEO_CREATE_PROCESSOR */
85 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD7); /* SVGA_3D_CMD_VIDEO_DESTROY_PROCESSOR */
86 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD8); /* SVGA_3D_CMD_VIDEO_DECODE_START_FRAME */
87 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD9); /* SVGA_3D_CMD_VIDEO_DECODE_RENDER */
88 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD10); /* SVGA_3D_CMD_VIDEO_DECODE_END_FRAME */
89 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD11); /* SVGA_3D_CMD_VIDEO_PROCESS_FRAME */
90 SVGA_CASE_ID2STR(SVGA_3D_CMD_ACTIVATE_SURFACE);
91 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEACTIVATE_SURFACE);
92 SVGA_CASE_ID2STR(SVGA_3D_CMD_SCREEN_DMA);
93 SVGA_CASE_ID2STR(SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION); /* SVGA_3D_CMD_DEAD1 */
94 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD2);
95 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD12); /* Old SVGA_3D_CMD_LOGICOPS_BITBLT */
96 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD13); /* Old SVGA_3D_CMD_LOGICOPS_TRANSBLT */
97 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD14); /* Old SVGA_3D_CMD_LOGICOPS_STRETCHBLT */
98 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD15); /* Old SVGA_3D_CMD_LOGICOPS_COLORFILL */
99 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD16); /* Old SVGA_3D_CMD_LOGICOPS_ALPHABLEND */
100 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD17); /* Old SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND */
101 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_OTABLE_BASE);
102 SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_OTABLE);
103 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_MOB);
104 SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_MOB);
105 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD3);
106 SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING);
107 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE);
108 SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SURFACE);
109 SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SURFACE);
110 SVGA_CASE_ID2STR(SVGA_3D_CMD_COND_BIND_GB_SURFACE);
111 SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_IMAGE);
112 SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_SURFACE);
113 SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_IMAGE);
114 SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_SURFACE);
115 SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_IMAGE);
116 SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_SURFACE);
117 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_CONTEXT);
118 SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_CONTEXT);
119 SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_CONTEXT);
120 SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_CONTEXT);
121 SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_CONTEXT);
122 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SHADER);
123 SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SHADER);
124 SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SHADER);
125 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_OTABLE_BASE64);
126 SVGA_CASE_ID2STR(SVGA_3D_CMD_BEGIN_GB_QUERY);
127 SVGA_CASE_ID2STR(SVGA_3D_CMD_END_GB_QUERY);
128 SVGA_CASE_ID2STR(SVGA_3D_CMD_WAIT_FOR_GB_QUERY);
129 SVGA_CASE_ID2STR(SVGA_3D_CMD_NOP);
130 SVGA_CASE_ID2STR(SVGA_3D_CMD_ENABLE_GART);
131 SVGA_CASE_ID2STR(SVGA_3D_CMD_DISABLE_GART);
132 SVGA_CASE_ID2STR(SVGA_3D_CMD_MAP_MOB_INTO_GART);
133 SVGA_CASE_ID2STR(SVGA_3D_CMD_UNMAP_GART_RANGE);
134 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SCREENTARGET);
135 SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SCREENTARGET);
136 SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SCREENTARGET);
137 SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_SCREENTARGET);
138 SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL);
139 SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL);
140 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE);
141 SVGA_CASE_ID2STR(SVGA_3D_CMD_GB_SCREEN_DMA);
142 SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH);
143 SVGA_CASE_ID2STR(SVGA_3D_CMD_GB_MOB_FENCE);
144 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V2);
145 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_MOB64);
146 SVGA_CASE_ID2STR(SVGA_3D_CMD_REDEFINE_GB_MOB64);
147 SVGA_CASE_ID2STR(SVGA_3D_CMD_NOP_ERROR);
148 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_STREAMS);
149 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_DECLS);
150 SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_DIVISORS);
151 SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW);
152 SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW_INDEXED);
153 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_CONTEXT);
154 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_CONTEXT);
155 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_CONTEXT);
156 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_CONTEXT);
157 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_INVALIDATE_CONTEXT);
158 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER);
159 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER_RESOURCES);
160 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER);
161 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SAMPLERS);
162 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW);
163 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED);
164 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INSTANCED);
165 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED);
166 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_AUTO);
167 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_INPUT_LAYOUT);
168 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS);
169 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_INDEX_BUFFER);
170 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_TOPOLOGY);
171 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_RENDERTARGETS);
172 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_BLEND_STATE);
173 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE);
174 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_RASTERIZER_STATE);
175 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_QUERY);
176 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_QUERY);
177 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_QUERY);
178 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_QUERY_OFFSET);
179 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BEGIN_QUERY);
180 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_END_QUERY);
181 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_QUERY);
182 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_PREDICATION);
183 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SOTARGETS);
184 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VIEWPORTS);
185 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SCISSORRECTS);
186 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW);
187 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW);
188 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_COPY_REGION);
189 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_COPY);
190 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRESENTBLT);
191 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_GENMIPS);
192 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE);
193 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_SUBRESOURCE);
194 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE);
195 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW);
196 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW);
197 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW);
198 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW);
199 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW);
200 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW);
201 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT);
202 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT);
203 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_BLEND_STATE);
204 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_BLEND_STATE);
205 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE);
206 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE);
207 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE);
208 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE);
209 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE);
210 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE);
211 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SHADER);
212 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SHADER);
213 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_SHADER);
214 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT);
215 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT);
216 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_STREAMOUTPUT);
217 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_COTABLE);
218 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_COTABLE);
219 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BUFFER_COPY);
220 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER);
221 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK);
222 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_MOVE_QUERY);
223 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_ALL_QUERY);
224 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_ALL_QUERY);
225 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER);
226 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_MOB_FENCE_64);
227 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_ALL_SHADER);
228 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_HINT);
229 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BUFFER_UPDATE);
230 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET);
231 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET);
232 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET);
233 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET);
234 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET);
235 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET);
236 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER);
237 SVGA_CASE_ID2STR(SVGA_3D_CMD_SCREEN_COPY);
238 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED1);
239 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2);
240 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED3);
241 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED4);
242 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED5);
243 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED6);
244 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED7);
245 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED8);
246 SVGA_CASE_ID2STR(SVGA_3D_CMD_GROW_OTABLE);
247 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_GROW_COTABLE);
248 SVGA_CASE_ID2STR(SVGA_3D_CMD_INTRA_SURFACE_COPY);
249 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V3);
250 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_RESOLVE_COPY);
251 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_RESOLVE_COPY);
252 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_CONVERT_REGION);
253 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_CONVERT);
254 SVGA_CASE_ID2STR(SVGA_3D_CMD_WHOLE_SURFACE_COPY);
255 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_UA_VIEW);
256 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_UA_VIEW);
257 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT);
258 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT);
259 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT);
260 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_UA_VIEWS);
261 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT);
262 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT);
263 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DISPATCH);
264 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DISPATCH_INDIRECT);
265 SVGA_CASE_ID2STR(SVGA_3D_CMD_WRITE_ZERO_SURFACE);
266 SVGA_CASE_ID2STR(SVGA_3D_CMD_HINT_ZERO_SURFACE);
267 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER);
268 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT);
269 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_BITBLT);
270 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_TRANSBLT);
271 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_STRETCHBLT);
272 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_COLORFILL);
273 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_ALPHABLEND);
274 SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND);
275 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_1);
276 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_2);
277 SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V4);
278 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_CS_UA_VIEWS);
279 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_MIN_LOD);
280 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_3);
281 SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_4);
282 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2);
283 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB);
284 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER_IFACE);
285 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_STREAMOUTPUT);
286 SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS);
287 SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_SHADER_IFACE);
288 SVGA_CASE_ID2STR(SVGA_3D_CMD_MAX);
289 SVGA_CASE_ID2STR(SVGA_3D_CMD_FUTURE_MAX);
290 }
291 return "UNKNOWN_3D";
292}
293
294/**
295 * FIFO command name lookup
296 *
297 * @returns FIFO command string or "UNKNOWN"
298 * @param u32Cmd FIFO command
299 */
300const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd)
301{
302 switch (u32Cmd)
303 {
304 SVGA_CASE_ID2STR(SVGA_CMD_INVALID_CMD);
305 SVGA_CASE_ID2STR(SVGA_CMD_UPDATE);
306 SVGA_CASE_ID2STR(SVGA_CMD_RECT_FILL);
307 SVGA_CASE_ID2STR(SVGA_CMD_RECT_COPY);
308 SVGA_CASE_ID2STR(SVGA_CMD_RECT_ROP_COPY);
309 SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_CURSOR);
310 SVGA_CASE_ID2STR(SVGA_CMD_DISPLAY_CURSOR);
311 SVGA_CASE_ID2STR(SVGA_CMD_MOVE_CURSOR);
312 SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_ALPHA_CURSOR);
313 SVGA_CASE_ID2STR(SVGA_CMD_UPDATE_VERBOSE);
314 SVGA_CASE_ID2STR(SVGA_CMD_FRONT_ROP_FILL);
315 SVGA_CASE_ID2STR(SVGA_CMD_FENCE);
316 SVGA_CASE_ID2STR(SVGA_CMD_ESCAPE);
317 SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_SCREEN);
318 SVGA_CASE_ID2STR(SVGA_CMD_DESTROY_SCREEN);
319 SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_GMRFB);
320 SVGA_CASE_ID2STR(SVGA_CMD_BLIT_GMRFB_TO_SCREEN);
321 SVGA_CASE_ID2STR(SVGA_CMD_BLIT_SCREEN_TO_GMRFB);
322 SVGA_CASE_ID2STR(SVGA_CMD_ANNOTATION_FILL);
323 SVGA_CASE_ID2STR(SVGA_CMD_ANNOTATION_COPY);
324 SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_GMR2);
325 SVGA_CASE_ID2STR(SVGA_CMD_REMAP_GMR2);
326 SVGA_CASE_ID2STR(SVGA_CMD_DEAD);
327 SVGA_CASE_ID2STR(SVGA_CMD_DEAD_2);
328 SVGA_CASE_ID2STR(SVGA_CMD_NOP);
329 SVGA_CASE_ID2STR(SVGA_CMD_NOP_ERROR);
330 SVGA_CASE_ID2STR(SVGA_CMD_MAX);
331 default:
332 if ( u32Cmd >= SVGA_3D_CMD_BASE
333 && u32Cmd < SVGA_3D_CMD_MAX)
334 return vmsvgaFifo3dCmdToString((SVGAFifo3dCmdId)u32Cmd);
335 }
336 return "UNKNOWN";
337}
338# undef SVGA_CASE_ID2STR
339#endif /* LOG_ENABLED || VBOX_STRICT */
340
341
342/*
343 *
344 * Guest-Backed Objects (GBO).
345 *
346 */
347
348/**
349 * HC access handler for GBOs which require write protection, i.e. OTables, etc.
350 *
351 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
352 * @param pVM VM Handle.
353 * @param pVCpu The cross context CPU structure for the calling EMT.
354 * @param GCPhys The physical address the guest is writing to.
355 * @param pvPhys The HC mapping of that address.
356 * @param pvBuf What the guest is reading/writing.
357 * @param cbBuf How much it's reading/writing.
358 * @param enmAccessType The access type.
359 * @param enmOrigin Who is making the access.
360 * @param uUser The VMM automatically sets this to the address of
361 * the device instance.
362 */
363DECLCALLBACK(VBOXSTRICTRC)
364vmsvgaR3GboAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
365 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)
366{
367 RT_NOREF(pVM, pVCpu, pvPhys, enmAccessType);
368
369 if (RT_LIKELY(enmOrigin == PGMACCESSORIGIN_DEVICE || enmOrigin == PGMACCESSORIGIN_DEBUGGER))
370 return VINF_PGM_HANDLER_DO_DEFAULT;
371
372 PPDMDEVINS pDevIns = (PPDMDEVINS)uUser;
373 AssertPtrReturn(pDevIns, VERR_INTERNAL_ERROR_4);
374 AssertReturn(pDevIns->u32Version == PDM_DEVINSR3_VERSION, VERR_INTERNAL_ERROR_5);
375 PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
376 PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
377 PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;
378
379 /*
380 * The guest is not allowed to access the memory.
381 * Set the error condition.
382 */
383 ASMAtomicWriteBool(&pThis->svga.fBadGuest, true);
384
385 /* Try to find the GBO which the guest is accessing. */
386 char const *pszTarget = NULL;
387 for (uint32_t i = 0; i < RT_ELEMENTS(pSvgaR3State->aGboOTables) && !pszTarget; ++i)
388 {
389 PVMSVGAGBO pGbo = &pSvgaR3State->aGboOTables[i];
390 if (pGbo->cDescriptors)
391 {
392 for (uint32_t j = 0; j < pGbo->cDescriptors; ++j)
393 {
394 if ( GCPhys >= pGbo->paDescriptors[j].GCPhys
395 && GCPhys < pGbo->paDescriptors[j].GCPhys + pGbo->paDescriptors[j].cPages * GUEST_PAGE_SIZE)
396 {
397 switch (i)
398 {
399 case SVGA_OTABLE_MOB: pszTarget = "SVGA_OTABLE_MOB"; break;
400 case SVGA_OTABLE_SURFACE: pszTarget = "SVGA_OTABLE_SURFACE"; break;
401 case SVGA_OTABLE_CONTEXT: pszTarget = "SVGA_OTABLE_CONTEXT"; break;
402 case SVGA_OTABLE_SHADER: pszTarget = "SVGA_OTABLE_SHADER"; break;
403 case SVGA_OTABLE_SCREENTARGET: pszTarget = "SVGA_OTABLE_SCREENTARGET"; break;
404 case SVGA_OTABLE_DXCONTEXT: pszTarget = "SVGA_OTABLE_DXCONTEXT"; break;
405 default: pszTarget = "Unknown OTABLE"; break;
406 }
407 break;
408 }
409 }
410 }
411 }
412
413 LogRelMax(8, ("VMSVGA: invalid guest access to page %RGp, target %s:\n"
414 "%.*Rhxd\n",
415 GCPhys, pszTarget ? pszTarget : "unknown", RT_MIN(cbBuf, 256), pvBuf));
416
417 return VINF_PGM_HANDLER_DO_DEFAULT;
418}
419
420#ifdef VBOX_WITH_VMSVGA3D
421
422static int vmsvgaR3GboCreate(PVMSVGAR3STATE pSvgaR3State, SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, bool fWriteProtected, PVMSVGAGBO pGbo)
423{
424 ASSERT_GUEST_RETURN(sizeInBytes <= _128M, VERR_INVALID_PARAMETER); /** @todo Less than SVGA_REG_MOB_MAX_SIZE */
425
426 /*
427 * The 'baseAddress' is a page number and points to the 'root page' of the GBO.
428 * Content of the root page depends on the ptDepth value:
429 * SVGA3D_MOBFMT_PTDEPTH[64]_0 - the only data page;
430 * SVGA3D_MOBFMT_PTDEPTH[64]_1 - array of page numbers for data pages;
431 * SVGA3D_MOBFMT_PTDEPTH[64]_2 - array of page numbers for SVGA3D_MOBFMT_PTDEPTH[64]_1 pages.
432 * The code below extracts the page addresses of the GBO.
433 */
434
435 /* Verify and normalize the ptDepth value. */
436 bool fGCPhys64; /* Whether the page table contains 64 bit page numbers. */
437 if (RT_LIKELY( ptDepth == SVGA3D_MOBFMT_PTDEPTH64_0
438 || ptDepth == SVGA3D_MOBFMT_PTDEPTH64_1
439 || ptDepth == SVGA3D_MOBFMT_PTDEPTH64_2))
440 fGCPhys64 = true;
441 else if ( ptDepth == SVGA3D_MOBFMT_PTDEPTH_0
442 || ptDepth == SVGA3D_MOBFMT_PTDEPTH_1
443 || ptDepth == SVGA3D_MOBFMT_PTDEPTH_2)
444 {
445 fGCPhys64 = false;
446 /* Shift ptDepth to the SVGA3D_MOBFMT_PTDEPTH64_x range. */
447 ptDepth = (SVGAMobFormat)(ptDepth + SVGA3D_MOBFMT_PTDEPTH64_0 - SVGA3D_MOBFMT_PTDEPTH_0);
448 }
449 else if (ptDepth == SVGA3D_MOBFMT_RANGE)
450 fGCPhys64 = false; /* Does not matter, there is no page table. */
451 else
452 ASSERT_GUEST_FAILED_RETURN(VERR_INVALID_PARAMETER);
453
454 uint32_t const cPPNsPerPage = X86_PAGE_SIZE / (fGCPhys64 ? sizeof(PPN64) : sizeof(PPN));
455
456 pGbo->cbTotal = sizeInBytes;
457 pGbo->cTotalPages = (sizeInBytes + X86_PAGE_SIZE - 1) >> X86_PAGE_SHIFT;
458
459 /* Allocate the maximum amount possible (everything non-continuous) */
460 PVMSVGAGBODESCRIPTOR paDescriptors = (PVMSVGAGBODESCRIPTOR)RTMemAlloc(pGbo->cTotalPages * sizeof(VMSVGAGBODESCRIPTOR));
461 AssertReturn(paDescriptors, VERR_NO_MEMORY);
462
463 int rc = VINF_SUCCESS;
464 if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_0)
465 {
466 ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages == 1,
467 RTMemFree(paDescriptors),
468 VERR_INVALID_PARAMETER);
469
470 RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
471 GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
472 paDescriptors[0].GCPhys = GCPhys;
473 paDescriptors[0].cPages = 1;
474 }
475 else if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_1)
476 {
477 ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages <= cPPNsPerPage,
478 RTMemFree(paDescriptors),
479 VERR_INVALID_PARAMETER);
480
481 /* Read the root page. */
482 uint8_t au8RootPage[X86_PAGE_SIZE];
483 RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
484 rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhys, &au8RootPage, sizeof(au8RootPage));
485 if (RT_SUCCESS(rc))
486 {
487 PPN64 *paPPN64 = (PPN64 *)&au8RootPage[0];
488 PPN *paPPN32 = (PPN *)&au8RootPage[0];
489 for (uint32_t iPPN = 0; iPPN < pGbo->cTotalPages; ++iPPN)
490 {
491 GCPhys = (RTGCPHYS)(fGCPhys64 ? paPPN64[iPPN] : paPPN32[iPPN]) << X86_PAGE_SHIFT;
492 GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
493 paDescriptors[iPPN].GCPhys = GCPhys;
494 paDescriptors[iPPN].cPages = 1;
495 }
496 }
497 }
498 else if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_2)
499 {
500 ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages <= cPPNsPerPage * cPPNsPerPage,
501 RTMemFree(paDescriptors),
502 VERR_INVALID_PARAMETER);
503
504 /* Read the Level2 root page. */
505 uint8_t au8RootPageLevel2[X86_PAGE_SIZE];
506 RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
507 rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhys, &au8RootPageLevel2, sizeof(au8RootPageLevel2));
508 if (RT_SUCCESS(rc))
509 {
510 uint32_t cPagesLeft = pGbo->cTotalPages;
511
512 PPN64 *paPPN64Level2 = (PPN64 *)&au8RootPageLevel2[0];
513 PPN *paPPN32Level2 = (PPN *)&au8RootPageLevel2[0];
514
515 uint32_t const cPPNsLevel2 = (pGbo->cTotalPages + cPPNsPerPage - 1) / cPPNsPerPage;
516 for (uint32_t iPPNLevel2 = 0; iPPNLevel2 < cPPNsLevel2; ++iPPNLevel2)
517 {
518 /* Read the Level1 root page. */
519 uint8_t au8RootPage[X86_PAGE_SIZE];
520 RTGCPHYS GCPhysLevel1 = (RTGCPHYS)(fGCPhys64 ? paPPN64Level2[iPPNLevel2] : paPPN32Level2[iPPNLevel2]) << X86_PAGE_SHIFT;
521 GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
522 rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhysLevel1, &au8RootPage, sizeof(au8RootPage));
523 if (RT_SUCCESS(rc))
524 {
525 PPN64 *paPPN64 = (PPN64 *)&au8RootPage[0];
526 PPN *paPPN32 = (PPN *)&au8RootPage[0];
527
528 uint32_t const cPPNs = RT_MIN(cPagesLeft, cPPNsPerPage);
529 for (uint32_t iPPN = 0; iPPN < cPPNs; ++iPPN)
530 {
531 GCPhys = (RTGCPHYS)(fGCPhys64 ? paPPN64[iPPN] : paPPN32[iPPN]) << X86_PAGE_SHIFT;
532 GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
533 paDescriptors[iPPN + iPPNLevel2 * cPPNsPerPage].GCPhys = GCPhys;
534 paDescriptors[iPPN + iPPNLevel2 * cPPNsPerPage].cPages = 1;
535 }
536 cPagesLeft -= cPPNs;
537 }
538 }
539 }
540 }
541 else if (ptDepth == SVGA3D_MOBFMT_RANGE)
542 {
543 RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
544 GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
545 paDescriptors[0].GCPhys = GCPhys;
546 paDescriptors[0].cPages = pGbo->cTotalPages;
547 }
548 else
549 {
550 AssertFailed();
551 return VERR_INTERNAL_ERROR; /* ptDepth should be already verified. */
552 }
553
554 /* Compress the descriptors. */
555 if (ptDepth != SVGA3D_MOBFMT_RANGE)
556 {
557 uint32_t iDescriptor = 0;
558 for (uint32_t i = 1; i < pGbo->cTotalPages; ++i)
559 {
560 /* Continuous physical memory? */
561 if (paDescriptors[i].GCPhys == paDescriptors[iDescriptor].GCPhys + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE)
562 {
563 Assert(paDescriptors[iDescriptor].cPages);
564 paDescriptors[iDescriptor].cPages++;
565 Log5Func(("Page %x GCPhys=%RGp successor\n", i, paDescriptors[i].GCPhys));
566 }
567 else
568 {
569 iDescriptor++;
570 paDescriptors[iDescriptor].GCPhys = paDescriptors[i].GCPhys;
571 paDescriptors[iDescriptor].cPages = 1;
572 Log5Func(("Page %x GCPhys=%RGp\n", i, paDescriptors[iDescriptor].GCPhys));
573 }
574 }
575
576 pGbo->cDescriptors = iDescriptor + 1;
577 Log5Func(("Nr of descriptors %d\n", pGbo->cDescriptors));
578 }
579 else
580 pGbo->cDescriptors = 1;
581
582 if (RT_LIKELY(pGbo->cDescriptors < pGbo->cTotalPages))
583 {
584 pGbo->paDescriptors = (PVMSVGAGBODESCRIPTOR)RTMemRealloc(paDescriptors, pGbo->cDescriptors * sizeof(VMSVGAGBODESCRIPTOR));
585 AssertReturn(pGbo->paDescriptors, VERR_NO_MEMORY);
586 }
587 else
588 pGbo->paDescriptors = paDescriptors;
589
590#if 1 /// @todo PGMHandlerPhysicalRegister asserts deep in PGM code with enmKind of a page being out of range.
591fWriteProtected = false;
592#endif
593 if (fWriteProtected)
594 {
595 pGbo->fGboFlags |= VMSVGAGBO_F_WRITE_PROTECTED;
596 for (uint32_t i = 0; i < pGbo->cDescriptors; ++i)
597 {
598 rc = PDMDevHlpPGMHandlerPhysicalRegister(pSvgaR3State->pDevIns,
599 pGbo->paDescriptors[i].GCPhys,
600 pGbo->paDescriptors[i].GCPhys
601 + pGbo->paDescriptors[i].cPages * GUEST_PAGE_SIZE - 1,
602 pSvgaR3State->hGboAccessHandlerType, "VMSVGA GBO");
603 AssertRC(rc);
604 }
605 }
606
607 return VINF_SUCCESS;
608}
609
610
611static void vmsvgaR3GboDestroy(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
612{
613 if (RT_LIKELY(VMSVGA_IS_GBO_CREATED(pGbo)))
614 {
615 if (pGbo->fGboFlags & VMSVGAGBO_F_WRITE_PROTECTED)
616 {
617 for (uint32_t i = 0; i < pGbo->cDescriptors; ++i)
618 {
619 int rc = PDMDevHlpPGMHandlerPhysicalDeregister(pSvgaR3State->pDevIns, pGbo->paDescriptors[i].GCPhys);
620 AssertRC(rc);
621 }
622 }
623 RTMemFree(pGbo->paDescriptors);
624 RT_ZERO(pGbo);
625 }
626}
627
628/** @todo static void vmsvgaR3GboWriteProtect(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo, bool fWriteProtect) */
629
630typedef enum VMSVGAGboTransferDirection
631{
632 VMSVGAGboTransferDirection_Read,
633 VMSVGAGboTransferDirection_Write,
634} VMSVGAGboTransferDirection;
635
636static int vmsvgaR3GboTransfer(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
637 uint32_t off, void *pvData, uint32_t cbData,
638 VMSVGAGboTransferDirection enmDirection)
639{
640 //DEBUG_BREAKPOINT_TEST();
641 int rc = VINF_SUCCESS;
642 uint8_t *pu8CurrentHost = (uint8_t *)pvData;
643
644 /* Find the right descriptor */
645 PCVMSVGAGBODESCRIPTOR const paDescriptors = pGbo->paDescriptors;
646 uint32_t iDescriptor = 0; /* Index in the descriptor array. */
647 uint32_t offDescriptor = 0; /* GMR offset of the current descriptor. */
648 while (offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE <= off)
649 {
650 offDescriptor += paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE;
651 AssertReturn(offDescriptor < pGbo->cbTotal, VERR_INTERNAL_ERROR); /* overflow protection */
652 ++iDescriptor;
653 AssertReturn(iDescriptor < pGbo->cDescriptors, VERR_INTERNAL_ERROR);
654 }
655
656 while (cbData)
657 {
658 uint32_t cbToCopy;
659 if (off + cbData <= offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE)
660 cbToCopy = cbData;
661 else
662 {
663 cbToCopy = (offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE - off);
664 AssertReturn(cbToCopy <= cbData, VERR_INVALID_PARAMETER);
665 }
666
667 RTGCPHYS const GCPhys = paDescriptors[iDescriptor].GCPhys + off - offDescriptor;
668 Log5Func(("%s phys=%RGp\n", (enmDirection == VMSVGAGboTransferDirection_Read) ? "READ" : "WRITE", GCPhys));
669
670 /*
671 * We are deliberately using the non-PCI version of PDMDevHlpPCIPhys[Read|Write] as the
672 * guest-side VMSVGA driver seems to allocate non-DMA (regular physical) addresses,
673 * see @bugref{9654#c75}.
674 */
675 if (enmDirection == VMSVGAGboTransferDirection_Read)
676 rc = PDMDevHlpPhysRead(pSvgaR3State->pDevIns, GCPhys, pu8CurrentHost, cbToCopy);
677 else
678 rc = PDMDevHlpPhysWrite(pSvgaR3State->pDevIns, GCPhys, pu8CurrentHost, cbToCopy);
679 AssertRCBreak(rc);
680
681 cbData -= cbToCopy;
682 off += cbToCopy;
683 pu8CurrentHost += cbToCopy;
684
685 /* Go to the next descriptor if there's anything left. */
686 if (cbData)
687 {
688 offDescriptor += paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE;
689 AssertReturn(offDescriptor < pGbo->cbTotal, VERR_INTERNAL_ERROR);
690 ++iDescriptor;
691 AssertReturn(iDescriptor < pGbo->cDescriptors, VERR_INTERNAL_ERROR);
692 }
693 }
694 return rc;
695}
696
697
698static int vmsvgaR3GboWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
699 uint32_t off, void const *pvData, uint32_t cbData)
700{
701 return vmsvgaR3GboTransfer(pSvgaR3State, pGbo,
702 off, (void *)pvData, cbData,
703 VMSVGAGboTransferDirection_Write);
704}
705
706
707static int vmsvgaR3GboRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
708 uint32_t off, void *pvData, uint32_t cbData)
709{
710 return vmsvgaR3GboTransfer(pSvgaR3State, pGbo,
711 off, pvData, cbData,
712 VMSVGAGboTransferDirection_Read);
713}
714
715
716static int vmsvgaR3GboBackingStoreCreate(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo, uint32_t cbValid)
717{
718 int rc;
719
720 /* Just reread the data if pvHost has been allocated already. */
721 if (!(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED))
722 pGbo->pvHost = RTMemAllocZ(pGbo->cbTotal);
723
724 if (pGbo->pvHost)
725 {
726 cbValid = RT_MIN(cbValid, pGbo->cbTotal);
727 rc = vmsvgaR3GboRead(pSvgaR3State, pGbo, 0, pGbo->pvHost, cbValid);
728 }
729 else
730 rc = VERR_NO_MEMORY;
731
732 if (RT_SUCCESS(rc))
733 pGbo->fGboFlags |= VMSVGAGBO_F_HOST_BACKED;
734 else
735 {
736 RTMemFree(pGbo->pvHost);
737 pGbo->pvHost = NULL;
738 }
739 return rc;
740}
741
742
743static void vmsvgaR3GboBackingStoreDelete(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
744{
745 RT_NOREF(pSvgaR3State);
746 AssertReturnVoid(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED);
747 RTMemFree(pGbo->pvHost);
748 pGbo->pvHost = NULL;
749 pGbo->fGboFlags &= ~VMSVGAGBO_F_HOST_BACKED;
750}
751
752
753static int vmsvgaR3GboBackingStoreWriteToGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
754{
755 AssertReturn(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED, VERR_INVALID_STATE);
756 return vmsvgaR3GboWrite(pSvgaR3State, pGbo, 0, pGbo->pvHost, pGbo->cbTotal);
757}
758
759
760static int vmsvgaR3GboBackingStoreReadFromGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
761{
762 AssertReturn(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED, VERR_INVALID_STATE);
763 return vmsvgaR3GboRead(pSvgaR3State, pGbo, 0, pGbo->pvHost, pGbo->cbTotal);
764}
765
766static int vmsvgaR3GboCopy(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboDst, uint32_t offDst,
767 PVMSVGAGBO pGboSrc, uint32_t offSrc, uint32_t cbCopy)
768{
769 uint32_t const cbTmpBuf = GUEST_PAGE_SIZE;
770 void *pvTmpBuf = RTMemTmpAlloc(cbTmpBuf);
771 AssertPtrReturn(pvTmpBuf, VERR_NO_MEMORY);
772
773 int rc = VINF_SUCCESS;
774 while (cbCopy > 0)
775 {
776 uint32_t const cbToCopy = RT_MIN(cbTmpBuf, cbCopy);
777
778 rc = vmsvgaR3GboRead(pSvgaR3State, pGboSrc, offSrc, pvTmpBuf, cbToCopy);
779 AssertRCBreak(rc);
780
781 rc = vmsvgaR3GboWrite(pSvgaR3State, pGboDst, offDst, pvTmpBuf, cbToCopy);
782 AssertRCBreak(rc);
783
784 offSrc += cbToCopy;
785 offDst += cbToCopy;
786 cbCopy -= cbToCopy;
787 }
788
789 RTMemTmpFree(pvTmpBuf);
790 return rc;
791}
792
793
794/*
795 *
796 * Object Tables.
797 *
798 */
799
800static int vmsvgaR3OTableSetOrGrow(PVMSVGAR3STATE pSvgaR3State, SVGAOTableType type, PPN64 baseAddress,
801 uint32_t sizeInBytes, uint32 validSizeInBytes, SVGAMobFormat ptDepth, bool fGrow)
802{
803 ASSERT_GUEST_RETURN(type <= RT_ELEMENTS(pSvgaR3State->aGboOTables), VERR_INVALID_PARAMETER);
804 ASSERT_GUEST_RETURN(sizeInBytes >= validSizeInBytes, VERR_INVALID_PARAMETER);
805 RT_UNTRUSTED_VALIDATED_FENCE();
806
807 ASSERT_GUEST_RETURN(pSvgaR3State->aGboOTables[type].cbTotal >= validSizeInBytes, VERR_INVALID_PARAMETER);
808
809 if (sizeInBytes > 0)
810 {
811 /* Create a new guest backed object for the object table. */
812 VMSVGAGBO gbo;
813 int rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, /* fWriteProtected = */ true, &gbo);
814 AssertRCReturn(rc, rc);
815
816 if (fGrow && validSizeInBytes)
817 {
818 /* Copy data from old gbo to the new one. */
819 rc = vmsvgaR3GboCopy(pSvgaR3State, &gbo, 0, &pSvgaR3State->aGboOTables[type], 0, validSizeInBytes);
820 AssertRCReturnStmt(rc, vmsvgaR3GboDestroy(pSvgaR3State, &gbo), rc);
821 }
822
823 vmsvgaR3GboDestroy(pSvgaR3State, &pSvgaR3State->aGboOTables[type]);
824 pSvgaR3State->aGboOTables[type] = gbo;
825
826 }
827 else
828 vmsvgaR3GboDestroy(pSvgaR3State, &pSvgaR3State->aGboOTables[type]);
829
830 return VINF_SUCCESS;
831}
832
833
834static int vmsvgaR3OTableVerifyIndex(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
835 uint32_t idx, uint32_t cbEntry)
836{
837 RT_NOREF(pSvgaR3State);
838
839 /* The table must exist and the index must be within the table. */
840 ASSERT_GUEST_RETURN(VMSVGA_IS_GBO_CREATED(pGboOTable), VERR_INVALID_PARAMETER);
841 ASSERT_GUEST_RETURN(idx < pGboOTable->cbTotal / cbEntry, VERR_INVALID_PARAMETER);
842 RT_UNTRUSTED_VALIDATED_FENCE();
843 return VINF_SUCCESS;
844}
845
846
847static int vmsvgaR3OTableRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
848 uint32_t idx, uint32_t cbEntry,
849 void *pvData, uint32_t cbData)
850{
851 AssertReturn(cbData <= cbEntry, VERR_INVALID_PARAMETER);
852
853 int rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, pGboOTable, idx, cbEntry);
854 if (RT_SUCCESS(rc))
855 {
856 uint32_t const off = idx * cbEntry;
857 rc = vmsvgaR3GboRead(pSvgaR3State, pGboOTable, off, pvData, cbData);
858 }
859 return rc;
860}
861
862static int vmsvgaR3OTableWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
863 uint32_t idx, uint32_t cbEntry,
864 void const *pvData, uint32_t cbData)
865{
866 AssertReturn(cbData <= cbEntry, VERR_INVALID_PARAMETER);
867
868 int rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, pGboOTable, idx, cbEntry);
869 if (RT_SUCCESS(rc))
870 {
871 uint32_t const off = idx * cbEntry;
872 rc = vmsvgaR3GboWrite(pSvgaR3State, pGboOTable, off, pvData, cbData);
873 }
874 return rc;
875}
876
877
878int vmsvgaR3OTableReadSurface(PVMSVGAR3STATE pSvgaR3State, uint32_t sid, SVGAOTableSurfaceEntry *pEntrySurface)
879{
880 return vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
881 sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, pEntrySurface, sizeof(SVGAOTableSurfaceEntry));
882}
883
884
885/*
886 *
887 * The guest's Memory OBjects (MOB).
888 *
889 */
890
891static int vmsvgaR3MobCreate(PVMSVGAR3STATE pSvgaR3State,
892 SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, SVGAMobId mobid,
893 PVMSVGAMOB pMob)
894{
895 RT_ZERO(*pMob);
896
897 /* Update the entry in the pSvgaR3State->pGboOTableMob. */
898 SVGAOTableMobEntry entry;
899 entry.ptDepth = ptDepth;
900 entry.sizeInBytes = sizeInBytes;
901 entry.base = baseAddress;
902 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
903 mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE, &entry, sizeof(entry));
904 if (RT_SUCCESS(rc))
905 {
906 /* Create the corresponding GBO. */
907 rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, /* fWriteProtected = */ false, &pMob->Gbo);
908 if (RT_SUCCESS(rc))
909 {
910 /* If a mob with this id already exists, then delete it. */
911 PVMSVGAMOB pOldMob = (PVMSVGAMOB)RTAvlU32Remove(&pSvgaR3State->MOBTree, mobid);
912 if (pOldMob)
913 {
914 /* This should not happen. */
915 ASSERT_GUEST_FAILED();
916 RTListNodeRemove(&pOldMob->nodeLRU);
917 vmsvgaR3GboDestroy(pSvgaR3State, &pOldMob->Gbo);
918 RTMemFree(pOldMob);
919 }
920
921 /* Add to the tree of known MOBs and the LRU list. */
922 pMob->Core.Key = mobid;
923 if (RTAvlU32Insert(&pSvgaR3State->MOBTree, &pMob->Core))
924 {
925 RTListPrepend(&pSvgaR3State->MOBLRUList, &pMob->nodeLRU);
926 return VINF_SUCCESS;
927 }
928
929 AssertFailedStmt(rc = VERR_INVALID_STATE);
930 vmsvgaR3GboDestroy(pSvgaR3State, &pMob->Gbo);
931 }
932 }
933
934 return rc;
935}
936
937
938static int vmsvgaR3MobDestroy(PVMSVGAR3STATE pSvgaR3State, SVGAMobId mobid)
939{
940 /* Update the entry in the pSvgaR3State->pGboOTableMob. */
941 SVGAOTableMobEntry entry;
942 RT_ZERO(entry);
943 vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
944 mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE, &entry, sizeof(entry));
945
946 PVMSVGAMOB pMob = (PVMSVGAMOB)RTAvlU32Remove(&pSvgaR3State->MOBTree, mobid);
947 if (pMob)
948 {
949 RTListNodeRemove(&pMob->nodeLRU);
950 vmsvgaR3GboDestroy(pSvgaR3State, &pMob->Gbo);
951 RTMemFree(pMob);
952 return VINF_SUCCESS;
953 }
954
955 return VERR_INVALID_PARAMETER;
956}
957
958
959PVMSVGAMOB vmsvgaR3MobGet(PVMSVGAR3STATE pSvgaR3State, SVGAMobId RT_UNTRUSTED_GUEST mobid)
960{
961 if (mobid == SVGA_ID_INVALID)
962 return NULL;
963
964 PVMSVGAMOB pMob = (PVMSVGAMOB)RTAvlU32Get(&pSvgaR3State->MOBTree, mobid);
965 if (pMob)
966 {
967 /* Move to the head of the LRU list. */
968 RTListNodeRemove(&pMob->nodeLRU);
969 RTListPrepend(&pSvgaR3State->MOBLRUList, &pMob->nodeLRU);
970 }
971 else
972 ASSERT_GUEST_FAILED();
973
974 return pMob;
975}
976
977
978int vmsvgaR3MobWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob,
979 uint32_t off, void const *pvData, uint32_t cbData)
980{
981 return vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, off, pvData, cbData);
982}
983
984
985int vmsvgaR3MobRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob,
986 uint32_t off, void *pvData, uint32_t cbData)
987{
988 return vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, off, pvData, cbData);
989}
990
991
992/** Create a host ring-3 pointer to the MOB data.
993 * Current approach is to allocate a host memory buffer and copy the guest MOB data if necessary.
994 * @param pSvgaR3State R3 device state.
995 * @param pMob The MOB.
996 * @param cbValid How many bytes of the guest backing memory contain valid data.
997 * @return VBox status.
998 */
999/** @todo uint32_t cbValid -> uint32_t offStart, uint32_t cbData */
1000int vmsvgaR3MobBackingStoreCreate(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob, uint32_t cbValid)
1001{
1002 AssertReturn(pMob, VERR_INVALID_PARAMETER);
1003 return vmsvgaR3GboBackingStoreCreate(pSvgaR3State, &pMob->Gbo, cbValid);
1004}
1005
1006
1007void vmsvgaR3MobBackingStoreDelete(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
1008{
1009 if (pMob)
1010 vmsvgaR3GboBackingStoreDelete(pSvgaR3State, &pMob->Gbo);
1011}
1012
1013
1014int vmsvgaR3MobBackingStoreWriteToGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
1015{
1016 if (pMob)
1017 return vmsvgaR3GboBackingStoreWriteToGuest(pSvgaR3State, &pMob->Gbo);
1018 return VERR_INVALID_PARAMETER;
1019}
1020
1021
1022int vmsvgaR3MobBackingStoreReadFromGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
1023{
1024 if (pMob)
1025 return vmsvgaR3GboBackingStoreReadFromGuest(pSvgaR3State, &pMob->Gbo);
1026 return VERR_INVALID_PARAMETER;
1027}
1028
1029
1030void *vmsvgaR3MobBackingStorePtr(PVMSVGAMOB pMob, uint32_t off)
1031{
1032 if (pMob && (pMob->Gbo.fGboFlags & VMSVGAGBO_F_HOST_BACKED))
1033 {
1034 if (off <= pMob->Gbo.cbTotal)
1035 return (uint8_t *)pMob->Gbo.pvHost + off;
1036 }
1037 return NULL;
1038}
1039
1040#endif /* VBOX_WITH_VMSVGA3D */
1041
1042/*
1043 * Screen objects.
1044 */
1045VMSVGASCREENOBJECT *vmsvgaR3GetScreenObject(PVGASTATECC pThisCC, uint32_t idScreen)
1046{
1047 PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
1048 if ( idScreen < (uint32_t)RT_ELEMENTS(pSVGAState->aScreens)
1049 && pSVGAState
1050 && pSVGAState->aScreens[idScreen].fDefined)
1051 {
1052 return &pSVGAState->aScreens[idScreen];
1053 }
1054 return NULL;
1055}
1056
1057void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC)
1058{
1059#ifdef VBOX_WITH_VMSVGA3D
1060 if (pThis->svga.f3DEnabled)
1061 {
1062 for (uint32_t idScreen = 0; idScreen < (uint32_t)RT_ELEMENTS(pThisCC->svga.pSvgaR3State->aScreens); ++idScreen)
1063 {
1064 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, idScreen);
1065 if (pScreen)
1066 vmsvga3dDestroyScreen(pThisCC, pScreen);
1067 }
1068 }
1069#else
1070 RT_NOREF(pThis, pThisCC);
1071#endif
1072}
1073
1074
1075/**
1076 * Copy a rectangle of pixels within guest VRAM.
1077 */
1078static void vmsvgaR3RectCopy(PVGASTATECC pThisCC, VMSVGASCREENOBJECT const *pScreen, uint32_t srcX, uint32_t srcY,
1079 uint32_t dstX, uint32_t dstY, uint32_t width, uint32_t height, unsigned cbFrameBuffer)
1080{
1081 if (!width || !height)
1082 return; /* Nothing to do, don't even bother. */
1083
1084 /*
1085 * The guest VRAM (aka GFB) is considered to be a bitmap in the format
1086 * corresponding to the current display mode.
1087 */
1088 uint32_t const cbPixel = RT_ALIGN(pScreen->cBpp, 8) / 8;
1089 uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch : width * cbPixel;
1090 uint8_t const *pSrc;
1091 uint8_t *pDst;
1092 unsigned const cbRectWidth = width * cbPixel;
1093 unsigned uMaxOffset;
1094
1095 uMaxOffset = (RT_MAX(srcY, dstY) + height) * cbScanline + (RT_MAX(srcX, dstX) + width) * cbPixel;
1096 if (uMaxOffset >= cbFrameBuffer)
1097 {
1098 Log(("Max offset (%u) too big for framebuffer (%u bytes), ignoring!\n", uMaxOffset, cbFrameBuffer));
1099 return; /* Just don't listen to a bad guest. */
1100 }
1101
1102 pSrc = pDst = pThisCC->pbVRam;
1103 pSrc += srcY * cbScanline + srcX * cbPixel;
1104 pDst += dstY * cbScanline + dstX * cbPixel;
1105
1106 if (srcY >= dstY)
1107 {
1108 /* Source below destination, copy top to bottom. */
1109 for (; height > 0; height--)
1110 {
1111 memmove(pDst, pSrc, cbRectWidth);
1112 pSrc += cbScanline;
1113 pDst += cbScanline;
1114 }
1115 }
1116 else
1117 {
1118 /* Source above destination, copy bottom to top. */
1119 pSrc += cbScanline * (height - 1);
1120 pDst += cbScanline * (height - 1);
1121 for (; height > 0; height--)
1122 {
1123 memmove(pDst, pSrc, cbRectWidth);
1124 pSrc -= cbScanline;
1125 pDst -= cbScanline;
1126 }
1127 }
1128}
1129
1130
1131/**
1132 * Common worker for changing the pointer shape.
1133 *
1134 * @param pThisCC The VGA/VMSVGA state for ring-3.
1135 * @param pSVGAState The VMSVGA ring-3 instance data.
1136 * @param fAlpha Whether there is alpha or not.
1137 * @param xHot Hotspot x coordinate.
1138 * @param yHot Hotspot y coordinate.
1139 * @param cx Width.
1140 * @param cy Height.
1141 * @param pbData Heap copy of the cursor data. Consumed.
1142 * @param cbData The size of the data.
1143 */
1144static void vmsvgaR3InstallNewCursor(PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState, bool fAlpha,
1145 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, uint8_t *pbData, uint32_t cbData)
1146{
1147 LogRel2(("vmsvgaR3InstallNewCursor: cx=%d cy=%d xHot=%d yHot=%d fAlpha=%d cbData=%#x\n", cx, cy, xHot, yHot, fAlpha, cbData));
1148#ifdef LOG_ENABLED
1149 if (LogIs2Enabled())
1150 {
1151 uint32_t cbAndLine = RT_ALIGN(cx, 8) / 8;
1152 if (!fAlpha)
1153 {
1154 Log2(("VMSVGA Cursor AND mask (%d,%d):\n", cx, cy));
1155 for (uint32_t y = 0; y < cy; y++)
1156 {
1157 Log2(("%3u:", y));
1158 uint8_t const *pbLine = &pbData[y * cbAndLine];
1159 for (uint32_t x = 0; x < cx; x += 8)
1160 {
1161 uint8_t b = pbLine[x / 8];
1162 char szByte[12];
1163 szByte[0] = b & 0x80 ? '*' : ' '; /* most significant bit first */
1164 szByte[1] = b & 0x40 ? '*' : ' ';
1165 szByte[2] = b & 0x20 ? '*' : ' ';
1166 szByte[3] = b & 0x10 ? '*' : ' ';
1167 szByte[4] = b & 0x08 ? '*' : ' ';
1168 szByte[5] = b & 0x04 ? '*' : ' ';
1169 szByte[6] = b & 0x02 ? '*' : ' ';
1170 szByte[7] = b & 0x01 ? '*' : ' ';
1171 szByte[8] = '\0';
1172 Log2(("%s", szByte));
1173 }
1174 Log2(("\n"));
1175 }
1176 }
1177
1178 Log2(("VMSVGA Cursor XOR mask (%d,%d):\n", cx, cy));
1179 uint32_t const *pu32Xor = (uint32_t const *)&pbData[RT_ALIGN_32(cbAndLine * cy, 4)];
1180 for (uint32_t y = 0; y < cy; y++)
1181 {
1182 Log2(("%3u:", y));
1183 uint32_t const *pu32Line = &pu32Xor[y * cx];
1184 for (uint32_t x = 0; x < cx; x++)
1185 Log2((" %08x", pu32Line[x]));
1186 Log2(("\n"));
1187 }
1188 }
1189#endif
1190
1191 int rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, true /*fVisible*/, fAlpha, xHot, yHot, cx, cy, pbData);
1192 AssertRC(rc);
1193
1194 if (pSVGAState->Cursor.fActive)
1195 RTMemFreeZ(pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData);
1196
1197 pSVGAState->Cursor.fActive = true;
1198 pSVGAState->Cursor.xHotspot = xHot;
1199 pSVGAState->Cursor.yHotspot = yHot;
1200 pSVGAState->Cursor.width = cx;
1201 pSVGAState->Cursor.height = cy;
1202 pSVGAState->Cursor.cbData = cbData;
1203 pSVGAState->Cursor.pData = pbData;
1204}
1205
1206
1207#ifdef VBOX_WITH_VMSVGA3D
1208
1209/*
1210 * SVGA_3D_CMD_* handlers.
1211 */
1212
1213
1214/** SVGA_3D_CMD_SURFACE_DEFINE 1040, SVGA_3D_CMD_SURFACE_DEFINE_V2 1070
1215 *
1216 * @param pThisCC The VGA/VMSVGA state for the current context.
1217 * @param pCmd The VMSVGA command.
1218 * @param cMipLevelSizes Number of elements in the paMipLevelSizes array.
1219 * @param paMipLevelSizes Arrays of surface sizes for each face and miplevel.
1220 */
1221static void vmsvga3dCmdDefineSurface(PVGASTATECC pThisCC, SVGA3dCmdDefineSurface_v2 const *pCmd,
1222 uint32_t cMipLevelSizes, SVGA3dSize *paMipLevelSizes)
1223{
1224 ASSERT_GUEST_RETURN_VOID(pCmd->sid < SVGA3D_MAX_SURFACE_IDS);
1225 ASSERT_GUEST_RETURN_VOID(cMipLevelSizes >= 1);
1226 RT_UNTRUSTED_VALIDATED_FENCE();
1227
1228 /* Number of faces (cFaces) is specified as the number of the first non-zero elements in the 'face' array.
1229 * Since only plain surfaces (cFaces == 1) and cubemaps (cFaces == 6) are supported
1230 * (see also SVGA3dCmdDefineSurface definition in svga3d_reg.h), we ignore anything else.
1231 */
1232 uint32_t cRemainingMipLevels = cMipLevelSizes;
1233 uint32_t cFaces = 0;
1234 for (uint32_t i = 0; i < SVGA3D_MAX_SURFACE_FACES; ++i)
1235 {
1236 if (pCmd->face[i].numMipLevels == 0)
1237 break;
1238
1239 /* All SVGA3dSurfaceFace structures must have the same value of numMipLevels field */
1240 ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels == pCmd->face[0].numMipLevels);
1241
1242 /* numMipLevels value can't be greater than the number of remaining elements in the paMipLevelSizes array. */
1243 ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels <= cRemainingMipLevels);
1244 cRemainingMipLevels -= pCmd->face[i].numMipLevels;
1245
1246 ++cFaces;
1247 }
1248 for (uint32_t i = cFaces; i < SVGA3D_MAX_SURFACE_FACES; ++i)
1249 ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels == 0);
1250
1251 /* cFaces must be 6 for a cubemap and 1 otherwise. */
1252 ASSERT_GUEST_RETURN_VOID(cFaces == (uint32_t)((pCmd->surfaceFlags & SVGA3D_SURFACE_CUBEMAP) ? 6 : 1));
1253
1254 /* Sum of face[i].numMipLevels must be equal to cMipLevels. */
1255 ASSERT_GUEST_RETURN_VOID(cRemainingMipLevels == 0);
1256 RT_UNTRUSTED_VALIDATED_FENCE();
1257
1258 /* Verify paMipLevelSizes */
1259 uint32_t cWidth = paMipLevelSizes[0].width;
1260 uint32_t cHeight = paMipLevelSizes[0].height;
1261 uint32_t cDepth = paMipLevelSizes[0].depth;
1262 for (uint32_t i = 1; i < pCmd->face[0].numMipLevels; ++i)
1263 {
1264 cWidth >>= 1;
1265 if (cWidth == 0) cWidth = 1;
1266 cHeight >>= 1;
1267 if (cHeight == 0) cHeight = 1;
1268 cDepth >>= 1;
1269 if (cDepth == 0) cDepth = 1;
1270 for (uint32_t iFace = 0; iFace < cFaces; ++iFace)
1271 {
1272 uint32_t const iMipLevelSize = iFace * pCmd->face[0].numMipLevels + i;
1273 ASSERT_GUEST_RETURN_VOID( cWidth == paMipLevelSizes[iMipLevelSize].width
1274 && cHeight == paMipLevelSizes[iMipLevelSize].height
1275 && cDepth == paMipLevelSizes[iMipLevelSize].depth);
1276 }
1277 }
1278 RT_UNTRUSTED_VALIDATED_FENCE();
1279
1280 /* Create the surface. */
1281 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
1282 pCmd->multisampleCount, pCmd->autogenFilter,
1283 pCmd->face[0].numMipLevels, &paMipLevelSizes[0], /* arraySize = */ 0, /* fAllocMipLevels = */ true);
1284}
1285
1286
1287/* SVGA_3D_CMD_SET_OTABLE_BASE 1091 */
1288static void vmsvga3dCmdSetOTableBase(PVGASTATECC pThisCC, SVGA3dCmdSetOTableBase const *pCmd)
1289{
1290 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1291 vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
1292 pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ false);
1293}
1294
1295
1296/* SVGA_3D_CMD_DEFINE_GB_MOB 1093 */
1297static void vmsvga3dCmdDefineGBMob(PVGASTATECC pThisCC, SVGA3dCmdDefineGBMob const *pCmd)
1298{
1299 DEBUG_BREAKPOINT_TEST();
1300 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1301
1302 ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
1303
1304 /* Maybe just update the OTable and create Gbo when the MOB is actually accessed? */
1305 /* Allocate a structure for the MOB. */
1306 PVMSVGAMOB pMob = (PVMSVGAMOB)RTMemAllocZ(sizeof(*pMob));
1307 AssertPtrReturnVoid(pMob);
1308
1309 int rc = vmsvgaR3MobCreate(pSvgaR3State, pCmd->ptDepth, pCmd->base, pCmd->sizeInBytes, pCmd->mobid, pMob);
1310 if (RT_SUCCESS(rc))
1311 {
1312 return;
1313 }
1314
1315 AssertFailed();
1316
1317 RTMemFree(pMob);
1318}
1319
1320
1321/* SVGA_3D_CMD_DESTROY_GB_MOB 1094 */
1322static void vmsvga3dCmdDestroyGBMob(PVGASTATECC pThisCC, SVGA3dCmdDestroyGBMob const *pCmd)
1323{
1324 //DEBUG_BREAKPOINT_TEST();
1325 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1326
1327 ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
1328
1329 int rc = vmsvgaR3MobDestroy(pSvgaR3State, pCmd->mobid);
1330 if (RT_SUCCESS(rc))
1331 {
1332 return;
1333 }
1334
1335 AssertFailed();
1336}
1337
1338
1339/* SVGA_3D_CMD_DEFINE_GB_SURFACE 1097 */
1340static void vmsvga3dCmdDefineGBSurface(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface const *pCmd)
1341{
1342 //DEBUG_BREAKPOINT_TEST();
1343 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1344
1345 /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
1346 SVGAOTableSurfaceEntry entry;
1347 RT_ZERO(entry);
1348 entry.format = pCmd->format;
1349 entry.surface1Flags = pCmd->surfaceFlags;
1350 entry.numMipLevels = pCmd->numMipLevels;
1351 entry.multisampleCount = pCmd->multisampleCount;
1352 entry.autogenFilter = pCmd->autogenFilter;
1353 entry.size = pCmd->size;
1354 entry.mobid = SVGA_ID_INVALID;
1355 // entry.arraySize = 0;
1356 // entry.mobPitch = 0;
1357 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1358 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
1359 if (RT_SUCCESS(rc))
1360 {
1361 /* Create the host surface. */
1362 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
1363 pCmd->multisampleCount, pCmd->autogenFilter,
1364 pCmd->numMipLevels, &pCmd->size, /* arraySize = */ 0, /* fAllocMipLevels = */ false);
1365 }
1366}
1367
1368
1369/* SVGA_3D_CMD_DESTROY_GB_SURFACE 1098 */
1370static void vmsvga3dCmdDestroyGBSurface(PVGASTATECC pThisCC, SVGA3dCmdDestroyGBSurface const *pCmd)
1371{
1372 //DEBUG_BREAKPOINT_TEST();
1373 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1374
1375 /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
1376 SVGAOTableSurfaceEntry entry;
1377 RT_ZERO(entry);
1378 entry.mobid = SVGA_ID_INVALID;
1379 vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1380 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
1381
1382 vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid);
1383}
1384
1385
1386/* SVGA_3D_CMD_BIND_GB_SURFACE 1099 */
1387static void vmsvga3dCmdBindGBSurface(PVGASTATECC pThisCC, SVGA3dCmdBindGBSurface const *pCmd)
1388{
1389 //DEBUG_BREAKPOINT_TEST();
1390 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1391
1392 /* Assign the mobid to the surface. */
1393 int rc = VINF_SUCCESS;
1394 if (pCmd->mobid != SVGA_ID_INVALID)
1395 rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
1396 pCmd->mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE);
1397 if (RT_SUCCESS(rc))
1398 {
1399 SVGAOTableSurfaceEntry entry;
1400 rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1401 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
1402 if (RT_SUCCESS(rc))
1403 {
1404 entry.mobid = pCmd->mobid;
1405 rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1406 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
1407 if (RT_SUCCESS(rc))
1408 {
1409 /* */
1410 }
1411 }
1412 }
1413}
1414
1415
1416typedef union
1417{
1418 float f;
1419 uint32_t u;
1420} Unsigned2Float;
1421
1422float float16ToFloat(uint16_t f16)
1423{
1424 /* Format specs from Wiki: [15] = sign, [14:10] = exponent, [9:0] = fraction */
1425 uint16_t const f = f16 & 0x3FF;
1426 uint16_t const e = (f16 >> 10) & 0x1F;
1427 uint16_t const s = (f16 >> 15) & 0x1;
1428 Unsigned2Float u2f;
1429
1430 if (e == 0)
1431 {
1432 if (f == 0)
1433 {
1434 /* zero, -0 */
1435 u2f.u = (s << 31) | (0 << 23) | 0;
1436 return u2f.f;
1437 }
1438
1439 /* subnormal numbers: (-1)^signbit * 2^-14 * 0.significantbits */
1440 float const k = 1.0f / 16384.0f; /* 2^-14 */
1441 return (s ? -1.0f : 1.0f) * k * (float)f / 1024.0f;
1442 }
1443
1444 if (e == 31)
1445 {
1446 if (f == 0)
1447 {
1448 /* +-infinity */
1449 u2f.u = (s << 31) | (0xFF << 23) | 0;
1450 return u2f.f;
1451 }
1452
1453 /* NaN */
1454 u2f.u = (s << 31) | (0xFF << 23) | 1;
1455 return u2f.f;
1456 }
1457
1458 /* normalized value: (-1)^signbit * 2^(exponent - 15) * 1.significantbits */
1459 /* Build the float, adjusting for exponent bias (float32 bias is 127, float16 is 15)
1460 * and number of bits in the fraction (float32 has 23, float16 has 10). */
1461 u2f.u = (s << 31) | ((e + 127 - 15) << 23) | (f << (23 - 10));
1462 return u2f.f;
1463}
1464
1465
1466static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap)
1467{
1468 if ( pMap->cbBlock != 4 && pMap->cbBlock != 1
1469 && pMap->format != SVGA3D_R16G16B16A16_FLOAT
1470 && pMap->format != SVGA3D_R32G32B32A32_FLOAT)
1471 return VERR_NOT_SUPPORTED;
1472
1473 int const w = pMap->cbRow / pMap->cbBlock;
1474 int const h = pMap->cRows;
1475
1476 const int cbBitmap = pMap->cbRow * pMap->cRows * 4;
1477
1478 FILE *f = fopen(pszFilename, "wb");
1479 if (!f)
1480 return VERR_FILE_NOT_FOUND;
1481
1482 {
1483 BMPFILEHDR fileHdr;
1484 RT_ZERO(fileHdr);
1485 fileHdr.uType = BMP_HDR_MAGIC;
1486 fileHdr.cbFileSize = sizeof(BMPFILEHDR) + sizeof(BMPWIN3XINFOHDR) + cbBitmap;
1487 fileHdr.offBits = sizeof(BMPFILEHDR) + sizeof(BMPWIN3XINFOHDR);
1488
1489 BMPWIN3XINFOHDR coreHdr;
1490 RT_ZERO(coreHdr);
1491 coreHdr.cbSize = sizeof(coreHdr);
1492 coreHdr.uWidth = w;
1493 coreHdr.uHeight = -h;
1494 coreHdr.cPlanes = 1;
1495 coreHdr.cBits = 32;
1496 coreHdr.cbSizeImage = cbBitmap;
1497
1498 fwrite(&fileHdr, 1, sizeof(fileHdr), f);
1499 fwrite(&coreHdr, 1, sizeof(coreHdr), f);
1500 }
1501
1502 if (pMap->format == SVGA3D_R16G16B16A16_FLOAT)
1503 {
1504 const uint8_t *s = (uint8_t *)pMap->pvData;
1505 for (int32_t y = 0; y < h; ++y)
1506 {
1507 for (int32_t x = 0; x < w; ++x)
1508 {
1509 uint16_t const *pu16Pixel = (uint16_t *)(s + x * 8);
1510 uint8_t r = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[0]));
1511 uint8_t g = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[1]));
1512 uint8_t b = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[2]));
1513 uint8_t a = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[3]));
1514 uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24);
1515 fwrite(&u32Pixel, 1, 4, f);
1516 }
1517
1518 s += pMap->cbRowPitch;
1519 }
1520 }
1521 else if (pMap->format == SVGA3D_R32G32B32A32_FLOAT)
1522 {
1523 const uint8_t *s = (uint8_t *)pMap->pvData;
1524 for (int32_t y = 0; y < h; ++y)
1525 {
1526 for (int32_t x = 0; x < w; ++x)
1527 {
1528 float const *pPixel = (float *)(s + x * 8);
1529 uint8_t r = (uint8_t)(255.0 * pPixel[0]);
1530 uint8_t g = (uint8_t)(255.0 * pPixel[1]);
1531 uint8_t b = (uint8_t)(255.0 * pPixel[2]);
1532 uint8_t a = (uint8_t)(255.0 * pPixel[3]);
1533 uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24);
1534 fwrite(&u32Pixel, 1, 4, f);
1535 }
1536
1537 s += pMap->cbRowPitch;
1538 }
1539 }
1540 else if (pMap->cbBlock == 4)
1541 {
1542 const uint8_t *s = (uint8_t *)pMap->pvData;
1543 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow)
1544 {
1545 fwrite(s, 1, pMap->cbRow, f);
1546
1547 s += pMap->cbRowPitch;
1548 }
1549 }
1550 else if (pMap->cbBlock == 1)
1551 {
1552 const uint8_t *s = (uint8_t *)pMap->pvData;
1553 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow)
1554 {
1555 for (int32_t x = 0; x < w; ++x)
1556 {
1557 uint32_t u32Pixel = s[x];
1558 fwrite(&u32Pixel, 1, 4, f);
1559 }
1560
1561 s += pMap->cbRowPitch;
1562 }
1563 }
1564
1565 fclose(f);
1566
1567 return VINF_SUCCESS;
1568}
1569
1570
1571void vmsvga3dMapWriteBmpFile(VMSVGA3D_MAPPED_SURFACE const *pMap, char const *pszPrefix)
1572{
1573 static int idxBitmap = 0;
1574 char *pszFilename = RTStrAPrintf2("bmp\\%s%d.bmp", pszPrefix, idxBitmap++);
1575 int rc = vmsvga3dBmpWrite(pszFilename, pMap);
1576 Log(("WriteBmpFile %s format %d %Rrc\n", pszFilename, pMap->format, rc)); RT_NOREF(rc);
1577 RTStrFree(pszFilename);
1578}
1579
1580
1581static int vmsvgaR3TransferSurfaceLevel(PVGASTATECC pThisCC,
1582 PVMSVGAMOB pMob,
1583 SVGA3dSurfaceImageId const *pImage,
1584 SVGA3dBox const *pBox,
1585 SVGA3dTransferType enmTransfer)
1586{
1587 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1588
1589 VMSVGA3D_SURFACE_MAP enmMapType;
1590 if (enmTransfer == SVGA3D_WRITE_HOST_VRAM)
1591 enmMapType = pBox
1592 ? VMSVGA3D_SURFACE_MAP_WRITE
1593 : VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;
1594 else if (enmTransfer == SVGA3D_READ_HOST_VRAM)
1595 enmMapType = VMSVGA3D_SURFACE_MAP_READ;
1596 else
1597 AssertFailedReturn(VERR_INVALID_PARAMETER);
1598
1599 VMSVGA3D_MAPPED_SURFACE map;
1600 int rc = vmsvga3dSurfaceMap(pThisCC, pImage, pBox, enmMapType, &map);
1601 if (RT_SUCCESS(rc))
1602 {
1603 /* Copy mapped surface <-> MOB. */
1604 VMSGA3D_BOX_DIMENSIONS dims;
1605 rc = vmsvga3dGetBoxDimensions(pThisCC, pImage, pBox, &dims);
1606 if (RT_SUCCESS(rc))
1607 {
1608 for (uint32_t z = 0; z < map.box.d; ++z)
1609 {
1610 uint8_t *pu8Map = (uint8_t *)map.pvData + z * map.cbDepthPitch;
1611 uint32_t offMob = dims.offSubresource + dims.offBox + z * dims.cbDepthPitch;
1612
1613 for (uint32_t iRow = 0; iRow < map.cRows; ++iRow)
1614 {
1615 if (enmTransfer == SVGA3D_READ_HOST_VRAM)
1616 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow);
1617 else
1618 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow);
1619 AssertRCBreak(rc);
1620
1621 pu8Map += map.cbRowPitch;
1622 offMob += dims.cbPitch;
1623 }
1624 }
1625 }
1626
1627 // vmsvga3dMapWriteBmpFile(&map, "Dynamic");
1628
1629 bool const fWritten = (enmTransfer == SVGA3D_WRITE_HOST_VRAM);
1630 vmsvga3dSurfaceUnmap(pThisCC, pImage, &map, fWritten);
1631 }
1632
1633 return rc;
1634}
1635
1636
1637/* SVGA_3D_CMD_UPDATE_GB_IMAGE 1101 */
1638static void vmsvga3dCmdUpdateGBImage(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBImage const *pCmd)
1639{
1640 //DEBUG_BREAKPOINT_TEST();
1641 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1642
1643 LogFlowFunc(("sid=%u @%u,%u,%u %ux%ux%u\n",
1644 pCmd->image.sid, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.d));
1645
1646/*
1647 SVGA3dSurfaceFormat format;
1648 SVGA3dSurface1Flags surface1Flags;
1649 uint32 numMipLevels;
1650 uint32 multisampleCount;
1651 SVGA3dTextureFilter autogenFilter;
1652 SVGA3dSize size;
1653 SVGAMobId mobid;
1654 uint32 arraySize;
1655 uint32 mobPitch;
1656 SVGA3dSurface2Flags surface2Flags;
1657 uint8 multisamplePattern;
1658 uint8 qualityLevel;
1659 uint16 bufferByteStride;
1660 float minLOD;
1661*/
1662
1663 /* "update a surface from its backing MOB." */
1664 SVGAOTableSurfaceEntry entrySurface;
1665 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1666 pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
1667 if (RT_SUCCESS(rc))
1668 {
1669 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
1670 if (pMob)
1671 {
1672 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM);
1673 AssertRC(rc);
1674 }
1675 }
1676}
1677
1678
1679/* SVGA_3D_CMD_UPDATE_GB_SURFACE 1102 */
1680static void vmsvga3dCmdUpdateGBSurface(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBSurface const *pCmd)
1681{
1682 //DEBUG_BREAKPOINT_TEST();
1683 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1684
1685 LogFlowFunc(("sid=%u\n",
1686 pCmd->sid));
1687
1688 /* "update a surface from its backing MOB." */
1689 SVGAOTableSurfaceEntry entrySurface;
1690 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1691 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
1692 if (RT_SUCCESS(rc))
1693 {
1694 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
1695 if (pMob)
1696 {
1697 uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid);
1698 for (uint32_t iArray = 0; iArray < arraySize; ++iArray)
1699 {
1700 for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap)
1701 {
1702 SVGA3dSurfaceImageId image;
1703 image.sid = pCmd->sid;
1704 image.face = iArray;
1705 image.mipmap = iMipmap;
1706
1707 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_WRITE_HOST_VRAM);
1708 AssertRCBreak(rc);
1709 }
1710 }
1711 }
1712 }
1713}
1714
1715
1716/* SVGA_3D_CMD_READBACK_GB_IMAGE 1103 */
1717static void vmsvga3dCmdReadbackGBImage(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBImage const *pCmd)
1718{
1719 //DEBUG_BREAKPOINT_TEST();
1720 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1721
1722 LogFlowFunc(("sid=%u, face=%u, mipmap=%u\n",
1723 pCmd->image.sid, pCmd->image.face, pCmd->image.mipmap));
1724
1725 /* Read a surface to its backing MOB. */
1726 SVGAOTableSurfaceEntry entrySurface;
1727 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1728 pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
1729 if (RT_SUCCESS(rc))
1730 {
1731 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
1732 if (pMob)
1733 {
1734 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
1735 AssertRC(rc);
1736 }
1737 }
1738}
1739
1740
1741/* SVGA_3D_CMD_READBACK_GB_SURFACE 1104 */
1742static void vmsvga3dCmdReadbackGBSurface(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBSurface const *pCmd)
1743{
1744 //DEBUG_BREAKPOINT_TEST();
1745 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1746
1747 LogFlowFunc(("sid=%u\n",
1748 pCmd->sid));
1749
1750 /* Read a surface to its backing MOB. */
1751 SVGAOTableSurfaceEntry entrySurface;
1752 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1753 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
1754 if (RT_SUCCESS(rc))
1755 {
1756 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
1757 if (pMob)
1758 {
1759 uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid);
1760 for (uint32_t iArray = 0; iArray < arraySize; ++iArray)
1761 {
1762 for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap)
1763 {
1764 SVGA3dSurfaceImageId image;
1765 image.sid = pCmd->sid;
1766 image.face = iArray;
1767 image.mipmap = iMipmap;
1768
1769 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
1770 AssertRCBreak(rc);
1771 }
1772 }
1773 }
1774 }
1775}
1776
1777
1778/* SVGA_3D_CMD_INVALIDATE_GB_IMAGE 1105 */
1779static void vmsvga3dCmdInvalidateGBImage(PVGASTATECC pThisCC, SVGA3dCmdInvalidateGBImage const *pCmd)
1780{
1781 //DEBUG_BREAKPOINT_TEST();
1782 vmsvga3dSurfaceInvalidate(pThisCC, pCmd->image.sid, pCmd->image.face, pCmd->image.mipmap);
1783}
1784
1785
1786/* SVGA_3D_CMD_INVALIDATE_GB_SURFACE 1106 */
1787static void vmsvga3dCmdInvalidateGBSurface(PVGASTATECC pThisCC, SVGA3dCmdInvalidateGBSurface const *pCmd)
1788{
1789 //DEBUG_BREAKPOINT_TEST();
1790 vmsvga3dSurfaceInvalidate(pThisCC, pCmd->sid, SVGA_ID_INVALID, SVGA_ID_INVALID);
1791}
1792
1793
1794/* SVGA_3D_CMD_SET_OTABLE_BASE64 1115 */
1795static void vmsvga3dCmdSetOTableBase64(PVGASTATECC pThisCC, SVGA3dCmdSetOTableBase64 const *pCmd)
1796{
1797 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1798 vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
1799 pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ false);
1800}
1801
1802
1803/* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET 1124 */
1804static void vmsvga3dCmdDefineGBScreenTarget(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dCmdDefineGBScreenTarget const *pCmd)
1805{
1806 //DEBUG_BREAKPOINT_TEST();
1807 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1808
1809 ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
1810 ASSERT_GUEST_RETURN_VOID(pCmd->width > 0 && pCmd->width <= pThis->svga.u32MaxWidth); /* SVGA_REG_SCREENTARGET_MAX_WIDTH */
1811 ASSERT_GUEST_RETURN_VOID(pCmd->height > 0 && pCmd->height <= pThis->svga.u32MaxHeight); /* SVGA_REG_SCREENTARGET_MAX_HEIGHT */
1812 RT_UNTRUSTED_VALIDATED_FENCE();
1813
1814 /* Update the entry in the pSvgaR3State->pGboOTableScreenTarget. */
1815 SVGAOTableScreenTargetEntry entry;
1816 RT_ZERO(entry);
1817 entry.image.sid = SVGA_ID_INVALID;
1818 // entry.image.face = 0;
1819 // entry.image.mipmap = 0;
1820 entry.width = pCmd->width;
1821 entry.height = pCmd->height;
1822 entry.xRoot = pCmd->xRoot;
1823 entry.yRoot = pCmd->yRoot;
1824 entry.flags = pCmd->flags;
1825 entry.dpi = pCmd->dpi;
1826
1827 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
1828 pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
1829 if (RT_SUCCESS(rc))
1830 {
1831 /* Screen objects and screen targets are similar, therefore we will use the same for both. */
1832 /** @todo Generic screen object/target interface. */
1833 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
1834 pScreen->fDefined = true;
1835 pScreen->fModified = true;
1836 pScreen->fuScreen = SVGA_SCREEN_MUST_BE_SET
1837 | (RT_BOOL(pCmd->flags & SVGA_STFLAG_PRIMARY) ? SVGA_SCREEN_IS_PRIMARY : 0);
1838 pScreen->idScreen = pCmd->stid;
1839
1840 pScreen->xOrigin = pCmd->xRoot;
1841 pScreen->yOrigin = pCmd->yRoot;
1842 pScreen->cWidth = pCmd->width;
1843 pScreen->cHeight = pCmd->height;
1844 pScreen->offVRAM = 0; /* Not applicable for screen targets, they use either a separate memory buffer or a host window. */
1845 pScreen->cbPitch = pCmd->width * 4;
1846 pScreen->cBpp = 32;
1847
1848 if (RT_LIKELY(pThis->svga.f3DEnabled))
1849 vmsvga3dDefineScreen(pThis, pThisCC, pScreen);
1850
1851 if (!pScreen->pHwScreen)
1852 {
1853 /* System memory buffer. */
1854 pScreen->pvScreenBitmap = RTMemAllocZ(pScreen->cHeight * pScreen->cbPitch);
1855 }
1856
1857 pThis->svga.fGFBRegisters = false;
1858 vmsvgaR3ChangeMode(pThis, pThisCC);
1859 }
1860}
1861
1862
1863/* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET 1125 */
1864static void vmsvga3dCmdDestroyGBScreenTarget(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dCmdDestroyGBScreenTarget const *pCmd)
1865{
1866 //DEBUG_BREAKPOINT_TEST();
1867 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1868
1869 ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
1870 RT_UNTRUSTED_VALIDATED_FENCE();
1871
1872 /* Update the entry in the pSvgaR3State->pGboOTableScreenTarget. */
1873 SVGAOTableScreenTargetEntry entry;
1874 RT_ZERO(entry);
1875 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
1876 pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
1877 if (RT_SUCCESS(rc))
1878 {
1879 /* Screen objects and screen targets are similar, therefore we will use the same for both. */
1880 /** @todo Generic screen object/target interface. */
1881 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
1882 pScreen->fModified = true;
1883 pScreen->fDefined = false;
1884 pScreen->idScreen = pCmd->stid;
1885
1886 if (RT_LIKELY(pThis->svga.f3DEnabled))
1887 vmsvga3dDestroyScreen(pThisCC, pScreen);
1888
1889 vmsvgaR3ChangeMode(pThis, pThisCC);
1890
1891 RTMemFree(pScreen->pvScreenBitmap);
1892 pScreen->pvScreenBitmap = NULL;
1893 }
1894}
1895
1896
1897/* SVGA_3D_CMD_BIND_GB_SCREENTARGET 1126 */
1898static void vmsvga3dCmdBindGBScreenTarget(PVGASTATECC pThisCC, SVGA3dCmdBindGBScreenTarget const *pCmd)
1899{
1900 //DEBUG_BREAKPOINT_TEST();
1901 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1902
1903 /* "Binding a surface to a Screen Target the same as flipping" */
1904
1905 ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
1906 ASSERT_GUEST_RETURN_VOID(pCmd->image.face == 0 && pCmd->image.mipmap == 0);
1907 RT_UNTRUSTED_VALIDATED_FENCE();
1908
1909 /* Assign the surface to the screen target. */
1910 int rc = VINF_SUCCESS;
1911 if (pCmd->image.sid != SVGA_ID_INVALID)
1912 rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1913 pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE);
1914 if (RT_SUCCESS(rc))
1915 {
1916 SVGAOTableScreenTargetEntry entry;
1917 rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
1918 pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
1919 if (RT_SUCCESS(rc))
1920 {
1921 entry.image = pCmd->image;
1922 rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
1923 pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
1924 if (RT_SUCCESS(rc))
1925 {
1926 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
1927 rc = pSvgaR3State->pFuncsGBO->pfnScreenTargetBind(pThisCC, pScreen, pCmd->image.sid);
1928 AssertRC(rc);
1929 }
1930 }
1931 }
1932}
1933
1934
1935/* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET 1127 */
1936static void vmsvga3dCmdUpdateGBScreenTarget(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBScreenTarget const *pCmd)
1937{
1938 //DEBUG_BREAKPOINT_TEST();
1939 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1940
1941 /* Update the screen target from its backing surface. */
1942 ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
1943 RT_UNTRUSTED_VALIDATED_FENCE();
1944
1945 /* Get the screen target info. */
1946 SVGAOTableScreenTargetEntry entryScreenTarget;
1947 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
1948 pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entryScreenTarget, sizeof(entryScreenTarget));
1949 if (RT_SUCCESS(rc))
1950 {
1951 ASSERT_GUEST_RETURN_VOID(entryScreenTarget.image.face == 0 && entryScreenTarget.image.mipmap == 0);
1952 RT_UNTRUSTED_VALIDATED_FENCE();
1953
1954 if (entryScreenTarget.image.sid != SVGA_ID_INVALID)
1955 {
1956 SVGAOTableSurfaceEntry entrySurface;
1957 rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
1958 entryScreenTarget.image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
1959 if (RT_SUCCESS(rc))
1960 {
1961 /* Copy entrySurface.mobid content to the screen target. */
1962 if (entrySurface.mobid != SVGA_ID_INVALID)
1963 {
1964 RT_UNTRUSTED_VALIDATED_FENCE();
1965 SVGA3dRect targetRect = pCmd->rect;
1966
1967 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
1968 if (pScreen->pHwScreen)
1969 {
1970 /* Copy the screen target surface to the backend's screen. */
1971 pSvgaR3State->pFuncsGBO->pfnScreenTargetUpdate(pThisCC, pScreen, &targetRect);
1972 }
1973 else
1974 {
1975 SVGASignedRect r;
1976 r.left = pCmd->rect.x;
1977 r.top = pCmd->rect.y;
1978 r.right = pCmd->rect.x + pCmd->rect.w;
1979 r.bottom = pCmd->rect.y + pCmd->rect.h;
1980 vmsvga3dScreenUpdate(pThisCC, pCmd->stid, r, entryScreenTarget.image, r, 0, NULL);
1981 }
1982 }
1983 }
1984 }
1985 }
1986}
1987
1988
1989/* SVGA_3D_CMD_DEFINE_GB_SURFACE_V2 1134 */
1990static void vmsvga3dCmdDefineGBSurface_v2(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v2 const *pCmd)
1991{
1992 //DEBUG_BREAKPOINT_TEST();
1993 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1994
1995 /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
1996 SVGAOTableSurfaceEntry entry;
1997 RT_ZERO(entry);
1998 entry.format = pCmd->format;
1999 entry.surface1Flags = pCmd->surfaceFlags;
2000 entry.numMipLevels = pCmd->numMipLevels;
2001 entry.multisampleCount = pCmd->multisampleCount;
2002 entry.autogenFilter = pCmd->autogenFilter;
2003 entry.size = pCmd->size;
2004 entry.mobid = SVGA_ID_INVALID;
2005 entry.arraySize = pCmd->arraySize;
2006 // entry.mobPitch = 0;
2007 // entry.mobPitch = 0;
2008 // entry.surface2Flags = 0;
2009 // entry.multisamplePattern = 0;
2010 // entry.qualityLevel = 0;
2011 // entry.bufferByteStride = 0;
2012 // entry.minLOD = 0;
2013
2014 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
2015 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
2016 if (RT_SUCCESS(rc))
2017 {
2018 /* Create the host surface. */
2019 /** @todo SVGAOTableSurfaceEntry as input parameter? */
2020 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
2021 pCmd->multisampleCount, pCmd->autogenFilter,
2022 pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* fAllocMipLevels = */ false);
2023 }
2024}
2025
2026
2027/* SVGA_3D_CMD_DEFINE_GB_MOB64 1135 */
2028static void vmsvga3dCmdDefineGBMob64(PVGASTATECC pThisCC, SVGA3dCmdDefineGBMob64 const *pCmd)
2029{
2030 //DEBUG_BREAKPOINT_TEST();
2031 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2032
2033 ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
2034
2035 /* Maybe just update the OTable and create Gbo when the MOB is actually accessed? */
2036 /* Allocate a structure for the MOB. */
2037 PVMSVGAMOB pMob = (PVMSVGAMOB)RTMemAllocZ(sizeof(*pMob));
2038 AssertPtrReturnVoid(pMob);
2039
2040 int rc = vmsvgaR3MobCreate(pSvgaR3State, pCmd->ptDepth, pCmd->base, pCmd->sizeInBytes, pCmd->mobid, pMob);
2041 if (RT_SUCCESS(rc))
2042 {
2043 return;
2044 }
2045
2046 RTMemFree(pMob);
2047}
2048
2049
2050/* SVGA_3D_CMD_DX_DEFINE_CONTEXT 1143 */
2051static int vmsvga3dCmdDXDefineContext(PVGASTATECC pThisCC, SVGA3dCmdDXDefineContext const *pCmd, uint32_t cbCmd)
2052{
2053#ifdef VMSVGA3D_DX
2054 //DEBUG_BREAKPOINT_TEST();
2055 RT_NOREF(cbCmd);
2056
2057 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2058
2059 /* Update the entry in the pSvgaR3State->pGboOTable[SVGA_OTABLE_DXCONTEXT]. */
2060 SVGAOTableDXContextEntry entry;
2061 RT_ZERO(entry);
2062 entry.cid = pCmd->cid;
2063 entry.mobid = SVGA_ID_INVALID;
2064 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
2065 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
2066 if (RT_SUCCESS(rc))
2067 {
2068 /* Create the host context. */
2069 rc = vmsvga3dDXDefineContext(pThisCC, pCmd->cid);
2070 }
2071
2072 return rc;
2073#else
2074 RT_NOREF(pThisCC, pCmd, cbCmd);
2075 return VERR_NOT_SUPPORTED;
2076#endif
2077}
2078
2079
2080/* SVGA_3D_CMD_DX_DESTROY_CONTEXT 1144 */
2081static int vmsvga3dCmdDXDestroyContext(PVGASTATECC pThisCC, SVGA3dCmdDXDestroyContext const *pCmd, uint32_t cbCmd)
2082{
2083#ifdef VMSVGA3D_DX
2084 //DEBUG_BREAKPOINT_TEST();
2085 RT_NOREF(cbCmd);
2086
2087 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2088
2089 /* Update the entry in the pSvgaR3State->pGboOTable[SVGA_OTABLE_DXCONTEXT]. */
2090 SVGAOTableDXContextEntry entry;
2091 RT_ZERO(entry);
2092 vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
2093 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
2094
2095 return vmsvga3dDXDestroyContext(pThisCC, pCmd->cid);
2096#else
2097 RT_NOREF(pThisCC, pCmd, cbCmd);
2098 return VERR_NOT_SUPPORTED;
2099#endif
2100}
2101
2102
2103/* SVGA_3D_CMD_DX_BIND_CONTEXT 1145 */
2104static int vmsvga3dCmdDXBindContext(PVGASTATECC pThisCC, SVGA3dCmdDXBindContext const *pCmd, uint32_t cbCmd)
2105{
2106#ifdef VMSVGA3D_DX
2107 //DEBUG_BREAKPOINT_TEST();
2108 RT_NOREF(cbCmd);
2109
2110 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2111
2112 /* Assign a mobid to a cid. */
2113 int rc = VINF_SUCCESS;
2114 if (pCmd->mobid != SVGA_ID_INVALID)
2115 rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
2116 pCmd->mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE);
2117 if (RT_SUCCESS(rc))
2118 {
2119 SVGAOTableDXContextEntry entry;
2120 rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
2121 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
2122 if (RT_SUCCESS(rc))
2123 {
2124 SVGADXContextMobFormat *pSvgaDXContext = NULL;
2125 if (pCmd->mobid != entry.mobid && entry.mobid != SVGA_ID_INVALID)
2126 {
2127 /* Unbind notification to the DX backend. Copy the context data to the guest backing memory. */
2128 pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
2129 if (pSvgaDXContext)
2130 {
2131 rc = vmsvga3dDXUnbindContext(pThisCC, pCmd->cid, pSvgaDXContext);
2132 if (RT_SUCCESS(rc))
2133 {
2134 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entry.mobid);
2135 if (pMob)
2136 {
2137 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
2138 }
2139 }
2140
2141 RTMemFree(pSvgaDXContext);
2142 pSvgaDXContext = NULL;
2143 }
2144 }
2145
2146 if (pCmd->mobid != SVGA_ID_INVALID)
2147 {
2148 /* Bind a new context. Copy existing data from the guest backing memory. */
2149 if (pCmd->validContents)
2150 {
2151 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
2152 if (pMob)
2153 {
2154 pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
2155 if (pSvgaDXContext)
2156 {
2157 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
2158 if (RT_FAILURE(rc))
2159 {
2160 RTMemFree(pSvgaDXContext);
2161 pSvgaDXContext = NULL;
2162 }
2163 }
2164 }
2165 }
2166
2167 rc = vmsvga3dDXBindContext(pThisCC, pCmd->cid, pSvgaDXContext);
2168
2169 RTMemFree(pSvgaDXContext);
2170 }
2171
2172 /* Update the object table. */
2173 entry.mobid = pCmd->mobid;
2174 rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
2175 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
2176 }
2177 }
2178
2179 return rc;
2180#else
2181 RT_NOREF(pThisCC, pCmd, cbCmd);
2182 return VERR_NOT_SUPPORTED;
2183#endif
2184}
2185
2186
2187/* SVGA_3D_CMD_DX_READBACK_CONTEXT 1146 */
2188static int vmsvga3dCmdDXReadbackContext(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackContext const *pCmd, uint32_t cbCmd)
2189{
2190#ifdef VMSVGA3D_DX
2191 //DEBUG_BREAKPOINT_TEST();
2192 RT_NOREF(cbCmd);
2193
2194 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2195
2196 /* "Request that the device flush the contents back into guest memory." */
2197 SVGAOTableDXContextEntry entry;
2198 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
2199 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
2200 if (RT_SUCCESS(rc))
2201 {
2202 if (entry.mobid != SVGA_ID_INVALID)
2203 {
2204 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entry.mobid);
2205 if (pMob)
2206 {
2207 /* Get the content. */
2208 SVGADXContextMobFormat *pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
2209 if (pSvgaDXContext)
2210 {
2211 rc = vmsvga3dDXReadbackContext(pThisCC, pCmd->cid, pSvgaDXContext);
2212 if (RT_SUCCESS(rc))
2213 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
2214
2215 RTMemFree(pSvgaDXContext);
2216 }
2217 else
2218 rc = VERR_NO_MEMORY;
2219 }
2220 }
2221 }
2222
2223 return rc;
2224#else
2225 RT_NOREF(pThisCC, pCmd, cbCmd);
2226 return VERR_NOT_SUPPORTED;
2227#endif
2228}
2229
2230
2231/* SVGA_3D_CMD_DX_INVALIDATE_CONTEXT 1147 */
2232static int vmsvga3dCmdDXInvalidateContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXInvalidateContext const *pCmd, uint32_t cbCmd)
2233{
2234#ifdef VMSVGA3D_DX
2235 DEBUG_BREAKPOINT_TEST();
2236 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2237 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
2238 return vmsvga3dDXInvalidateContext(pThisCC, idDXContext);
2239#else
2240 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2241 return VERR_NOT_SUPPORTED;
2242#endif
2243}
2244
2245
2246/* SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER 1148 */
2247static int vmsvga3dCmdDXSetSingleConstantBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSingleConstantBuffer const *pCmd, uint32_t cbCmd)
2248{
2249#ifdef VMSVGA3D_DX
2250 //DEBUG_BREAKPOINT_TEST();
2251 RT_NOREF(cbCmd);
2252 return vmsvga3dDXSetSingleConstantBuffer(pThisCC, idDXContext, pCmd);
2253#else
2254 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2255 return VERR_NOT_SUPPORTED;
2256#endif
2257}
2258
2259
2260/* SVGA_3D_CMD_DX_SET_SHADER_RESOURCES 1149 */
2261static int vmsvga3dCmdDXSetShaderResources(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderResources const *pCmd, uint32_t cbCmd)
2262{
2263#ifdef VMSVGA3D_DX
2264 //DEBUG_BREAKPOINT_TEST();
2265 SVGA3dShaderResourceViewId const *paShaderResourceViewId = (SVGA3dShaderResourceViewId *)&pCmd[1];
2266 uint32_t const cShaderResourceViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dShaderResourceViewId);
2267 return vmsvga3dDXSetShaderResources(pThisCC, idDXContext, pCmd, cShaderResourceViewId, paShaderResourceViewId);
2268#else
2269 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2270 return VERR_NOT_SUPPORTED;
2271#endif
2272}
2273
2274
2275/* SVGA_3D_CMD_DX_SET_SHADER 1150 */
2276static int vmsvga3dCmdDXSetShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShader const *pCmd, uint32_t cbCmd)
2277{
2278#ifdef VMSVGA3D_DX
2279 //DEBUG_BREAKPOINT_TEST();
2280 RT_NOREF(cbCmd);
2281 return vmsvga3dDXSetShader(pThisCC, idDXContext, pCmd);
2282#else
2283 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2284 return VERR_NOT_SUPPORTED;
2285#endif
2286}
2287
2288
2289/* SVGA_3D_CMD_DX_SET_SAMPLERS 1151 */
2290static int vmsvga3dCmdDXSetSamplers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSamplers const *pCmd, uint32_t cbCmd)
2291{
2292#ifdef VMSVGA3D_DX
2293 //DEBUG_BREAKPOINT_TEST();
2294 SVGA3dSamplerId const *paSamplerId = (SVGA3dSamplerId *)&pCmd[1];
2295 uint32_t const cSamplerId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSamplerId);
2296 return vmsvga3dDXSetSamplers(pThisCC, idDXContext, pCmd, cSamplerId, paSamplerId);
2297#else
2298 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2299 return VERR_NOT_SUPPORTED;
2300#endif
2301}
2302
2303
2304/* SVGA_3D_CMD_DX_DRAW 1152 */
2305static int vmsvga3dCmdDXDraw(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDraw const *pCmd, uint32_t cbCmd)
2306{
2307#ifdef VMSVGA3D_DX
2308 //DEBUG_BREAKPOINT_TEST();
2309 RT_NOREF(cbCmd);
2310 return vmsvga3dDXDraw(pThisCC, idDXContext, pCmd);
2311#else
2312 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2313 return VERR_NOT_SUPPORTED;
2314#endif
2315}
2316
2317
2318/* SVGA_3D_CMD_DX_DRAW_INDEXED 1153 */
2319static int vmsvga3dCmdDXDrawIndexed(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexed const *pCmd, uint32_t cbCmd)
2320{
2321#ifdef VMSVGA3D_DX
2322 //DEBUG_BREAKPOINT_TEST();
2323 RT_NOREF(cbCmd);
2324 return vmsvga3dDXDrawIndexed(pThisCC, idDXContext, pCmd);
2325#else
2326 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2327 return VERR_NOT_SUPPORTED;
2328#endif
2329}
2330
2331
2332/* SVGA_3D_CMD_DX_DRAW_INSTANCED 1154 */
2333static int vmsvga3dCmdDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd, uint32_t cbCmd)
2334{
2335#ifdef VMSVGA3D_DX
2336 //DEBUG_BREAKPOINT_TEST();
2337 RT_NOREF(cbCmd);
2338 return vmsvga3dDXDrawInstanced(pThisCC, idDXContext, pCmd);
2339#else
2340 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2341 return VERR_NOT_SUPPORTED;
2342#endif
2343}
2344
2345
2346/* SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED 1155 */
2347static int vmsvga3dCmdDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd, uint32_t cbCmd)
2348{
2349#ifdef VMSVGA3D_DX
2350 //DEBUG_BREAKPOINT_TEST();
2351 RT_NOREF(cbCmd);
2352 return vmsvga3dDXDrawIndexedInstanced(pThisCC, idDXContext, pCmd);
2353#else
2354 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2355 return VERR_NOT_SUPPORTED;
2356#endif
2357}
2358
2359
2360/* SVGA_3D_CMD_DX_DRAW_AUTO 1156 */
2361static int vmsvga3dCmdDXDrawAuto(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawAuto const *pCmd, uint32_t cbCmd)
2362{
2363#ifdef VMSVGA3D_DX
2364 //DEBUG_BREAKPOINT_TEST();
2365 RT_NOREF(pCmd, cbCmd);
2366 return vmsvga3dDXDrawAuto(pThisCC, idDXContext);
2367#else
2368 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2369 return VERR_NOT_SUPPORTED;
2370#endif
2371}
2372
2373
2374/* SVGA_3D_CMD_DX_SET_INPUT_LAYOUT 1157 */
2375static int vmsvga3dCmdDXSetInputLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetInputLayout const *pCmd, uint32_t cbCmd)
2376{
2377#ifdef VMSVGA3D_DX
2378 //DEBUG_BREAKPOINT_TEST();
2379 RT_NOREF(cbCmd);
2380 return vmsvga3dDXSetInputLayout(pThisCC, idDXContext, pCmd->elementLayoutId);
2381#else
2382 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2383 return VERR_NOT_SUPPORTED;
2384#endif
2385}
2386
2387
2388/* SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS 1158 */
2389static int vmsvga3dCmdDXSetVertexBuffers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetVertexBuffers const *pCmd, uint32_t cbCmd)
2390{
2391#ifdef VMSVGA3D_DX
2392 //DEBUG_BREAKPOINT_TEST();
2393 SVGA3dVertexBuffer const *paVertexBuffer = (SVGA3dVertexBuffer *)&pCmd[1];
2394 uint32_t const cVertexBuffer = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dVertexBuffer);
2395 return vmsvga3dDXSetVertexBuffers(pThisCC, idDXContext, pCmd->startBuffer, cVertexBuffer, paVertexBuffer);
2396#else
2397 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2398 return VERR_NOT_SUPPORTED;
2399#endif
2400}
2401
2402
2403/* SVGA_3D_CMD_DX_SET_INDEX_BUFFER 1159 */
2404static int vmsvga3dCmdDXSetIndexBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetIndexBuffer const *pCmd, uint32_t cbCmd)
2405{
2406#ifdef VMSVGA3D_DX
2407 //DEBUG_BREAKPOINT_TEST();
2408 RT_NOREF(cbCmd);
2409 return vmsvga3dDXSetIndexBuffer(pThisCC, idDXContext, pCmd);
2410#else
2411 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2412 return VERR_NOT_SUPPORTED;
2413#endif
2414}
2415
2416
2417/* SVGA_3D_CMD_DX_SET_TOPOLOGY 1160 */
2418static int vmsvga3dCmdDXSetTopology(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetTopology const *pCmd, uint32_t cbCmd)
2419{
2420#ifdef VMSVGA3D_DX
2421 //DEBUG_BREAKPOINT_TEST();
2422 RT_NOREF(cbCmd);
2423 return vmsvga3dDXSetTopology(pThisCC, idDXContext, pCmd->topology);
2424#else
2425 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2426 return VERR_NOT_SUPPORTED;
2427#endif
2428}
2429
2430
2431/* SVGA_3D_CMD_DX_SET_RENDERTARGETS 1161 */
2432static int vmsvga3dCmdDXSetRenderTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetRenderTargets const *pCmd, uint32_t cbCmd)
2433{
2434#ifdef VMSVGA3D_DX
2435 //DEBUG_BREAKPOINT_TEST();
2436 SVGA3dRenderTargetViewId const *paRenderTargetViewId = (SVGA3dRenderTargetViewId *)&pCmd[1];
2437 uint32_t const cRenderTargetViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderTargetViewId);
2438 return vmsvga3dDXSetRenderTargets(pThisCC, idDXContext, pCmd->depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId);
2439#else
2440 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2441 return VERR_NOT_SUPPORTED;
2442#endif
2443}
2444
2445
2446/* SVGA_3D_CMD_DX_SET_BLEND_STATE 1162 */
2447static int vmsvga3dCmdDXSetBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetBlendState const *pCmd, uint32_t cbCmd)
2448{
2449#ifdef VMSVGA3D_DX
2450 //DEBUG_BREAKPOINT_TEST();
2451 RT_NOREF(cbCmd);
2452 return vmsvga3dDXSetBlendState(pThisCC, idDXContext, pCmd);
2453#else
2454 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2455 return VERR_NOT_SUPPORTED;
2456#endif
2457}
2458
2459
2460/* SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE 1163 */
2461static int vmsvga3dCmdDXSetDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDepthStencilState const *pCmd, uint32_t cbCmd)
2462{
2463#ifdef VMSVGA3D_DX
2464 //DEBUG_BREAKPOINT_TEST();
2465 RT_NOREF(cbCmd);
2466 return vmsvga3dDXSetDepthStencilState(pThisCC, idDXContext, pCmd);
2467#else
2468 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2469 return VERR_NOT_SUPPORTED;
2470#endif
2471}
2472
2473
2474/* SVGA_3D_CMD_DX_SET_RASTERIZER_STATE 1164 */
2475static int vmsvga3dCmdDXSetRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetRasterizerState const *pCmd, uint32_t cbCmd)
2476{
2477#ifdef VMSVGA3D_DX
2478 //DEBUG_BREAKPOINT_TEST();
2479 RT_NOREF(cbCmd);
2480 return vmsvga3dDXSetRasterizerState(pThisCC, idDXContext, pCmd->rasterizerId);
2481#else
2482 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2483 return VERR_NOT_SUPPORTED;
2484#endif
2485}
2486
2487
2488/* SVGA_3D_CMD_DX_DEFINE_QUERY 1165 */
2489static int vmsvga3dCmdDXDefineQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineQuery const *pCmd, uint32_t cbCmd)
2490{
2491#ifdef VMSVGA3D_DX
2492 //DEBUG_BREAKPOINT_TEST();
2493 RT_NOREF(cbCmd);
2494 return vmsvga3dDXDefineQuery(pThisCC, idDXContext, pCmd);
2495#else
2496 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2497 return VERR_NOT_SUPPORTED;
2498#endif
2499}
2500
2501
2502/* SVGA_3D_CMD_DX_DESTROY_QUERY 1166 */
2503static int vmsvga3dCmdDXDestroyQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyQuery const *pCmd, uint32_t cbCmd)
2504{
2505#ifdef VMSVGA3D_DX
2506 //DEBUG_BREAKPOINT_TEST();
2507 RT_NOREF(cbCmd);
2508 return vmsvga3dDXDestroyQuery(pThisCC, idDXContext, pCmd);
2509#else
2510 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2511 return VERR_NOT_SUPPORTED;
2512#endif
2513}
2514
2515
2516/* SVGA_3D_CMD_DX_BIND_QUERY 1167 */
2517static int vmsvga3dCmdDXBindQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindQuery const *pCmd, uint32_t cbCmd)
2518{
2519#ifdef VMSVGA3D_DX
2520 //DEBUG_BREAKPOINT_TEST();
2521 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2522 RT_NOREF(cbCmd);
2523 /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
2524 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
2525 return vmsvga3dDXBindQuery(pThisCC, idDXContext, pCmd, pMob);
2526#else
2527 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2528 return VERR_NOT_SUPPORTED;
2529#endif
2530}
2531
2532
2533/* SVGA_3D_CMD_DX_SET_QUERY_OFFSET 1168 */
2534static int vmsvga3dCmdDXSetQueryOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetQueryOffset const *pCmd, uint32_t cbCmd)
2535{
2536#ifdef VMSVGA3D_DX
2537 //DEBUG_BREAKPOINT_TEST();
2538 RT_NOREF(cbCmd);
2539 return vmsvga3dDXSetQueryOffset(pThisCC, idDXContext, pCmd);
2540#else
2541 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2542 return VERR_NOT_SUPPORTED;
2543#endif
2544}
2545
2546
2547/* SVGA_3D_CMD_DX_BEGIN_QUERY 1169 */
2548static int vmsvga3dCmdDXBeginQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBeginQuery const *pCmd, uint32_t cbCmd)
2549{
2550#ifdef VMSVGA3D_DX
2551 //DEBUG_BREAKPOINT_TEST();
2552 RT_NOREF(cbCmd);
2553 return vmsvga3dDXBeginQuery(pThisCC, idDXContext, pCmd);
2554#else
2555 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2556 return VERR_NOT_SUPPORTED;
2557#endif
2558}
2559
2560
2561/* SVGA_3D_CMD_DX_END_QUERY 1170 */
2562static int vmsvga3dCmdDXEndQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXEndQuery const *pCmd, uint32_t cbCmd)
2563{
2564#ifdef VMSVGA3D_DX
2565 //DEBUG_BREAKPOINT_TEST();
2566 RT_NOREF(cbCmd);
2567 return vmsvga3dDXEndQuery(pThisCC, idDXContext, pCmd);
2568#else
2569 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2570 return VERR_NOT_SUPPORTED;
2571#endif
2572}
2573
2574
2575/* SVGA_3D_CMD_DX_READBACK_QUERY 1171 */
2576static int vmsvga3dCmdDXReadbackQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackQuery const *pCmd, uint32_t cbCmd)
2577{
2578#ifdef VMSVGA3D_DX
2579 //DEBUG_BREAKPOINT_TEST();
2580 RT_NOREF(cbCmd);
2581 return vmsvga3dDXReadbackQuery(pThisCC, idDXContext, pCmd);
2582#else
2583 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2584 return VERR_NOT_SUPPORTED;
2585#endif
2586}
2587
2588
2589/* SVGA_3D_CMD_DX_SET_PREDICATION 1172 */
2590static int vmsvga3dCmdDXSetPredication(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetPredication const *pCmd, uint32_t cbCmd)
2591{
2592#ifdef VMSVGA3D_DX
2593 //DEBUG_BREAKPOINT_TEST();
2594 RT_NOREF(cbCmd);
2595 return vmsvga3dDXSetPredication(pThisCC, idDXContext, pCmd);
2596#else
2597 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2598 return VERR_NOT_SUPPORTED;
2599#endif
2600}
2601
2602
2603/* SVGA_3D_CMD_DX_SET_SOTARGETS 1173 */
2604static int vmsvga3dCmdDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSOTargets const *pCmd, uint32_t cbCmd)
2605{
2606#ifdef VMSVGA3D_DX
2607 //DEBUG_BREAKPOINT_TEST();
2608 SVGA3dSoTarget const *paSoTarget = (SVGA3dSoTarget *)&pCmd[1];
2609 uint32_t const cSoTarget = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSoTarget);
2610 return vmsvga3dDXSetSOTargets(pThisCC, idDXContext, cSoTarget, paSoTarget);
2611#else
2612 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2613 return VERR_NOT_SUPPORTED;
2614#endif
2615}
2616
2617
2618/* SVGA_3D_CMD_DX_SET_VIEWPORTS 1174 */
2619static int vmsvga3dCmdDXSetViewports(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetViewports const *pCmd, uint32_t cbCmd)
2620{
2621#ifdef VMSVGA3D_DX
2622 //DEBUG_BREAKPOINT_TEST();
2623 SVGA3dViewport const *paViewport = (SVGA3dViewport *)&pCmd[1];
2624 uint32_t const cViewport = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dViewport);
2625 return vmsvga3dDXSetViewports(pThisCC, idDXContext, cViewport, paViewport);
2626#else
2627 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2628 return VERR_NOT_SUPPORTED;
2629#endif
2630}
2631
2632
2633/* SVGA_3D_CMD_DX_SET_SCISSORRECTS 1175 */
2634static int vmsvga3dCmdDXSetScissorRects(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetScissorRects const *pCmd, uint32_t cbCmd)
2635{
2636#ifdef VMSVGA3D_DX
2637 //DEBUG_BREAKPOINT_TEST();
2638 SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
2639 uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
2640 return vmsvga3dDXSetScissorRects(pThisCC, idDXContext, cRect, paRect);
2641#else
2642 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2643 return VERR_NOT_SUPPORTED;
2644#endif
2645}
2646
2647
2648/* SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW 1176 */
2649static int vmsvga3dCmdDXClearRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearRenderTargetView const *pCmd, uint32_t cbCmd)
2650{
2651#ifdef VMSVGA3D_DX
2652 //DEBUG_BREAKPOINT_TEST();
2653 RT_NOREF(cbCmd);
2654 return vmsvga3dDXClearRenderTargetView(pThisCC, idDXContext, pCmd);
2655#else
2656 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2657 return VERR_NOT_SUPPORTED;
2658#endif
2659}
2660
2661
2662/* SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW 1177 */
2663static int vmsvga3dCmdDXClearDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearDepthStencilView const *pCmd, uint32_t cbCmd)
2664{
2665#ifdef VMSVGA3D_DX
2666 //DEBUG_BREAKPOINT_TEST();
2667 RT_NOREF(cbCmd);
2668 return vmsvga3dDXClearDepthStencilView(pThisCC, idDXContext, pCmd);
2669#else
2670 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2671 return VERR_NOT_SUPPORTED;
2672#endif
2673}
2674
2675
2676/* SVGA_3D_CMD_DX_PRED_COPY_REGION 1178 */
2677static int vmsvga3dCmdDXPredCopyRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopyRegion const *pCmd, uint32_t cbCmd)
2678{
2679#ifdef VMSVGA3D_DX
2680 //DEBUG_BREAKPOINT_TEST();
2681 RT_NOREF(cbCmd);
2682 return vmsvga3dDXPredCopyRegion(pThisCC, idDXContext, pCmd);
2683#else
2684 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2685 return VERR_NOT_SUPPORTED;
2686#endif
2687}
2688
2689
2690/* SVGA_3D_CMD_DX_PRED_COPY 1179 */
2691static int vmsvga3dCmdDXPredCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopy const *pCmd, uint32_t cbCmd)
2692{
2693#ifdef VMSVGA3D_DX
2694 //DEBUG_BREAKPOINT_TEST();
2695 RT_NOREF(cbCmd);
2696 return vmsvga3dDXPredCopy(pThisCC, idDXContext, pCmd);
2697#else
2698 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2699 return VERR_NOT_SUPPORTED;
2700#endif
2701}
2702
2703
2704/* SVGA_3D_CMD_DX_PRESENTBLT 1180 */
2705static int vmsvga3dCmdDXPresentBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPresentBlt const *pCmd, uint32_t cbCmd)
2706{
2707#ifdef VMSVGA3D_DX
2708 //DEBUG_BREAKPOINT_TEST();
2709 RT_NOREF(cbCmd);
2710 return vmsvga3dDXPresentBlt(pThisCC, idDXContext, pCmd);
2711#else
2712 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2713 return VERR_NOT_SUPPORTED;
2714#endif
2715}
2716
2717
2718/* SVGA_3D_CMD_DX_GENMIPS 1181 */
2719static int vmsvga3dCmdDXGenMips(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXGenMips const *pCmd, uint32_t cbCmd)
2720{
2721#ifdef VMSVGA3D_DX
2722 //DEBUG_BREAKPOINT_TEST();
2723 RT_NOREF(cbCmd);
2724 return vmsvga3dDXGenMips(pThisCC, idDXContext, pCmd);
2725#else
2726 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2727 return VERR_NOT_SUPPORTED;
2728#endif
2729}
2730
2731
2732/* SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE 1182 */
2733static int vmsvga3dCmdDXUpdateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXUpdateSubResource const *pCmd, uint32_t cbCmd)
2734{
2735#ifdef VMSVGA3D_DX
2736 //DEBUG_BREAKPOINT_TEST();
2737 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2738 RT_NOREF(cbCmd);
2739
2740 LogFlowFunc(("sid=%u, subResource=%u, box=%d,%d,%d %ux%ux%u\n",
2741 pCmd->sid, pCmd->subResource, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.z));
2742
2743 /* "Inform the device that the guest-contents have been updated." */
2744 SVGAOTableSurfaceEntry entrySurface;
2745 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
2746 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
2747 if (RT_SUCCESS(rc))
2748 {
2749 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
2750 if (pMob)
2751 {
2752 uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid);
2753 ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER);
2754 /* pCmd->box will be verified by the mapping function. */
2755 RT_UNTRUSTED_VALIDATED_FENCE();
2756
2757 /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */
2758 SVGA3dSurfaceImageId image;
2759 image.sid = pCmd->sid;
2760 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face);
2761
2762 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM);
2763 AssertRC(rc);
2764 }
2765 }
2766
2767 return rc;
2768#else
2769 RT_NOREF(pThisCC, pCmd, cbCmd);
2770 return VERR_NOT_SUPPORTED;
2771#endif
2772}
2773
2774
2775/* SVGA_3D_CMD_DX_READBACK_SUBRESOURCE 1183 */
2776static int vmsvga3dCmdDXReadbackSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackSubResource const *pCmd, uint32_t cbCmd)
2777{
2778#ifdef VMSVGA3D_DX
2779 //DEBUG_BREAKPOINT_TEST();
2780 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2781 RT_NOREF(cbCmd);
2782
2783 LogFlowFunc(("sid=%u, subResource=%u\n",
2784 pCmd->sid, pCmd->subResource));
2785
2786 /* "Request the device to flush the dirty contents into the guest." */
2787 SVGAOTableSurfaceEntry entrySurface;
2788 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
2789 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
2790 if (RT_SUCCESS(rc))
2791 {
2792 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
2793 if (pMob)
2794 {
2795 uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid);
2796 ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER);
2797 RT_UNTRUSTED_VALIDATED_FENCE();
2798
2799 /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */
2800 SVGA3dSurfaceImageId image;
2801 image.sid = pCmd->sid;
2802 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face);
2803
2804 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
2805 AssertRC(rc);
2806 }
2807 }
2808
2809 return rc;
2810#else
2811 RT_NOREF(pThisCC, pCmd, cbCmd);
2812 return VERR_NOT_SUPPORTED;
2813#endif
2814}
2815
2816
2817/* SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE 1184 */
2818static int vmsvga3dCmdDXInvalidateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXInvalidateSubResource const *pCmd, uint32_t cbCmd)
2819{
2820#ifdef VMSVGA3D_DX
2821 DEBUG_BREAKPOINT_TEST();
2822 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2823 RT_NOREF(cbCmd);
2824
2825 LogFlowFunc(("sid=%u, subResource=%u\n",
2826 pCmd->sid, pCmd->subResource));
2827
2828 /* "Notify the device that the contents can be lost." */
2829 SVGAOTableSurfaceEntry entrySurface;
2830 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
2831 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
2832 if (RT_SUCCESS(rc))
2833 {
2834 uint32_t iFace;
2835 uint32_t iMipmap;
2836 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &iMipmap, &iFace);
2837 vmsvga3dSurfaceInvalidate(pThisCC, pCmd->sid, iFace, iMipmap);
2838 }
2839
2840 return rc;
2841#else
2842 RT_NOREF(pThisCC, pCmd, cbCmd);
2843 return VERR_NOT_SUPPORTED;
2844#endif
2845}
2846
2847
2848/* SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW 1185 */
2849static int vmsvga3dCmdDXDefineShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShaderResourceView const *pCmd, uint32_t cbCmd)
2850{
2851#ifdef VMSVGA3D_DX
2852 //DEBUG_BREAKPOINT_TEST();
2853 RT_NOREF(cbCmd);
2854 return vmsvga3dDXDefineShaderResourceView(pThisCC, idDXContext, pCmd);
2855#else
2856 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2857 return VERR_NOT_SUPPORTED;
2858#endif
2859}
2860
2861
2862/* SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW 1186 */
2863static int vmsvga3dCmdDXDestroyShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShaderResourceView const *pCmd, uint32_t cbCmd)
2864{
2865#ifdef VMSVGA3D_DX
2866 //DEBUG_BREAKPOINT_TEST();
2867 RT_NOREF(cbCmd);
2868 return vmsvga3dDXDestroyShaderResourceView(pThisCC, idDXContext, pCmd);
2869#else
2870 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2871 return VERR_NOT_SUPPORTED;
2872#endif
2873}
2874
2875
2876/* SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW 1187 */
2877static int vmsvga3dCmdDXDefineRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRenderTargetView const *pCmd, uint32_t cbCmd)
2878{
2879#ifdef VMSVGA3D_DX
2880 //DEBUG_BREAKPOINT_TEST();
2881 RT_NOREF(cbCmd);
2882 return vmsvga3dDXDefineRenderTargetView(pThisCC, idDXContext, pCmd);
2883#else
2884 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2885 return VERR_NOT_SUPPORTED;
2886#endif
2887}
2888
2889
2890/* SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW 1188 */
2891static int vmsvga3dCmdDXDestroyRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRenderTargetView const *pCmd, uint32_t cbCmd)
2892{
2893#ifdef VMSVGA3D_DX
2894 //DEBUG_BREAKPOINT_TEST();
2895 RT_NOREF(cbCmd);
2896 return vmsvga3dDXDestroyRenderTargetView(pThisCC, idDXContext, pCmd);
2897#else
2898 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2899 return VERR_NOT_SUPPORTED;
2900#endif
2901}
2902
2903
2904/* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW 1189 */
2905static int vmsvga3dCmdDXDefineDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView const *pCmd, uint32_t cbCmd)
2906{
2907#ifdef VMSVGA3D_DX
2908 //DEBUG_BREAKPOINT_TEST();
2909 RT_NOREF(cbCmd);
2910 SVGA3dCmdDXDefineDepthStencilView_v2 cmd;
2911 cmd.depthStencilViewId = pCmd->depthStencilViewId;
2912 cmd.sid = pCmd->sid;
2913 cmd.format = pCmd->format;
2914 cmd.resourceDimension = pCmd->resourceDimension;
2915 cmd.mipSlice = pCmd->mipSlice;
2916 cmd.firstArraySlice = pCmd->firstArraySlice;
2917 cmd.arraySize = pCmd->arraySize;
2918 cmd.flags = 0;
2919 return vmsvga3dDXDefineDepthStencilView(pThisCC, idDXContext, &cmd);
2920#else
2921 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2922 return VERR_NOT_SUPPORTED;
2923#endif
2924}
2925
2926
2927/* SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW 1190 */
2928static int vmsvga3dCmdDXDestroyDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilView const *pCmd, uint32_t cbCmd)
2929{
2930#ifdef VMSVGA3D_DX
2931 //DEBUG_BREAKPOINT_TEST();
2932 RT_NOREF(cbCmd);
2933 return vmsvga3dDXDestroyDepthStencilView(pThisCC, idDXContext, pCmd);
2934#else
2935 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2936 return VERR_NOT_SUPPORTED;
2937#endif
2938}
2939
2940
2941/* SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT 1191 */
2942static int vmsvga3dCmdDXDefineElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineElementLayout const *pCmd, uint32_t cbCmd)
2943{
2944#ifdef VMSVGA3D_DX
2945 //DEBUG_BREAKPOINT_TEST();
2946 SVGA3dInputElementDesc const *paDesc = (SVGA3dInputElementDesc *)&pCmd[1];
2947 uint32_t const cDesc = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dInputElementDesc);
2948 return vmsvga3dDXDefineElementLayout(pThisCC, idDXContext, pCmd->elementLayoutId, cDesc, paDesc);
2949#else
2950 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2951 return VERR_NOT_SUPPORTED;
2952#endif
2953}
2954
2955
2956/* SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT 1192 */
2957static int vmsvga3dCmdDXDestroyElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyElementLayout const *pCmd, uint32_t cbCmd)
2958{
2959#ifdef VMSVGA3D_DX
2960 //DEBUG_BREAKPOINT_TEST();
2961 RT_NOREF(cbCmd);
2962 return vmsvga3dDXDestroyElementLayout(pThisCC, idDXContext, pCmd);
2963#else
2964 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2965 return VERR_NOT_SUPPORTED;
2966#endif
2967}
2968
2969
2970/* SVGA_3D_CMD_DX_DEFINE_BLEND_STATE 1193 */
2971static int vmsvga3dCmdDXDefineBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineBlendState const *pCmd, uint32_t cbCmd)
2972{
2973#ifdef VMSVGA3D_DX
2974 //DEBUG_BREAKPOINT_TEST();
2975 RT_NOREF(cbCmd);
2976 return vmsvga3dDXDefineBlendState(pThisCC, idDXContext, pCmd);
2977#else
2978 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2979 return VERR_NOT_SUPPORTED;
2980#endif
2981}
2982
2983
2984/* SVGA_3D_CMD_DX_DESTROY_BLEND_STATE 1194 */
2985static int vmsvga3dCmdDXDestroyBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyBlendState const *pCmd, uint32_t cbCmd)
2986{
2987#ifdef VMSVGA3D_DX
2988 //DEBUG_BREAKPOINT_TEST();
2989 RT_NOREF(cbCmd);
2990 return vmsvga3dDXDestroyBlendState(pThisCC, idDXContext, pCmd);
2991#else
2992 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
2993 return VERR_NOT_SUPPORTED;
2994#endif
2995}
2996
2997
2998/* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE 1195 */
2999static int vmsvga3dCmdDXDefineDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilState const *pCmd, uint32_t cbCmd)
3000{
3001#ifdef VMSVGA3D_DX
3002 //DEBUG_BREAKPOINT_TEST();
3003 RT_NOREF(cbCmd);
3004 return vmsvga3dDXDefineDepthStencilState(pThisCC, idDXContext, pCmd);
3005#else
3006 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3007 return VERR_NOT_SUPPORTED;
3008#endif
3009}
3010
3011
3012/* SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE 1196 */
3013static int vmsvga3dCmdDXDestroyDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilState const *pCmd, uint32_t cbCmd)
3014{
3015#ifdef VMSVGA3D_DX
3016 //DEBUG_BREAKPOINT_TEST();
3017 RT_NOREF(cbCmd);
3018 return vmsvga3dDXDestroyDepthStencilState(pThisCC, idDXContext, pCmd);
3019#else
3020 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3021 return VERR_NOT_SUPPORTED;
3022#endif
3023}
3024
3025
3026/* SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE 1197 */
3027static int vmsvga3dCmdDXDefineRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRasterizerState const *pCmd, uint32_t cbCmd)
3028{
3029#ifdef VMSVGA3D_DX
3030 //DEBUG_BREAKPOINT_TEST();
3031 RT_NOREF(cbCmd);
3032 return vmsvga3dDXDefineRasterizerState(pThisCC, idDXContext, pCmd);
3033#else
3034 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3035 return VERR_NOT_SUPPORTED;
3036#endif
3037}
3038
3039
3040/* SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE 1198 */
3041static int vmsvga3dCmdDXDestroyRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRasterizerState const *pCmd, uint32_t cbCmd)
3042{
3043#ifdef VMSVGA3D_DX
3044 //DEBUG_BREAKPOINT_TEST();
3045 RT_NOREF(cbCmd);
3046 return vmsvga3dDXDestroyRasterizerState(pThisCC, idDXContext, pCmd);
3047#else
3048 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3049 return VERR_NOT_SUPPORTED;
3050#endif
3051}
3052
3053
3054/* SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE 1199 */
3055static int vmsvga3dCmdDXDefineSamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineSamplerState const *pCmd, uint32_t cbCmd)
3056{
3057#ifdef VMSVGA3D_DX
3058 //DEBUG_BREAKPOINT_TEST();
3059 RT_NOREF(cbCmd);
3060 return vmsvga3dDXDefineSamplerState(pThisCC, idDXContext, pCmd);
3061#else
3062 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3063 return VERR_NOT_SUPPORTED;
3064#endif
3065}
3066
3067
3068/* SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE 1200 */
3069static int vmsvga3dCmdDXDestroySamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroySamplerState const *pCmd, uint32_t cbCmd)
3070{
3071#ifdef VMSVGA3D_DX
3072 //DEBUG_BREAKPOINT_TEST();
3073 RT_NOREF(cbCmd);
3074 return vmsvga3dDXDestroySamplerState(pThisCC, idDXContext, pCmd);
3075#else
3076 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3077 return VERR_NOT_SUPPORTED;
3078#endif
3079}
3080
3081
3082/* SVGA_3D_CMD_DX_DEFINE_SHADER 1201 */
3083static int vmsvga3dCmdDXDefineShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShader const *pCmd, uint32_t cbCmd)
3084{
3085#ifdef VMSVGA3D_DX
3086 //DEBUG_BREAKPOINT_TEST();
3087 RT_NOREF(cbCmd);
3088 return vmsvga3dDXDefineShader(pThisCC, idDXContext, pCmd);
3089#else
3090 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3091 return VERR_NOT_SUPPORTED;
3092#endif
3093}
3094
3095
3096/* SVGA_3D_CMD_DX_DESTROY_SHADER 1202 */
3097static int vmsvga3dCmdDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd, uint32_t cbCmd)
3098{
3099#ifdef VMSVGA3D_DX
3100 //DEBUG_BREAKPOINT_TEST();
3101 RT_NOREF(cbCmd);
3102 return vmsvga3dDXDestroyShader(pThisCC, idDXContext, pCmd);
3103#else
3104 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3105 return VERR_NOT_SUPPORTED;
3106#endif
3107}
3108
3109
3110/* SVGA_3D_CMD_DX_BIND_SHADER 1203 */
3111static int vmsvga3dCmdDXBindShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindShader const *pCmd, uint32_t cbCmd)
3112{
3113#ifdef VMSVGA3D_DX
3114 //DEBUG_BREAKPOINT_TEST();
3115 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3116 RT_NOREF(idDXContext, cbCmd);
3117 /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
3118 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
3119 return vmsvga3dDXBindShader(pThisCC, pCmd, pMob);
3120#else
3121 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3122 return VERR_NOT_SUPPORTED;
3123#endif
3124}
3125
3126
3127/* SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT 1204 */
3128static int vmsvga3dCmdDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd, uint32_t cbCmd)
3129{
3130#ifdef VMSVGA3D_DX
3131 //DEBUG_BREAKPOINT_TEST();
3132 RT_NOREF(cbCmd);
3133 return vmsvga3dDXDefineStreamOutput(pThisCC, idDXContext, pCmd);
3134#else
3135 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3136 return VERR_NOT_SUPPORTED;
3137#endif
3138}
3139
3140
3141/* SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT 1205 */
3142static int vmsvga3dCmdDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd, uint32_t cbCmd)
3143{
3144#ifdef VMSVGA3D_DX
3145 //DEBUG_BREAKPOINT_TEST();
3146 RT_NOREF(cbCmd);
3147 return vmsvga3dDXDestroyStreamOutput(pThisCC, idDXContext, pCmd);
3148#else
3149 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3150 return VERR_NOT_SUPPORTED;
3151#endif
3152}
3153
3154
3155/* SVGA_3D_CMD_DX_SET_STREAMOUTPUT 1206 */
3156static int vmsvga3dCmdDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd, uint32_t cbCmd)
3157{
3158#ifdef VMSVGA3D_DX
3159 //DEBUG_BREAKPOINT_TEST();
3160 RT_NOREF(cbCmd);
3161 return vmsvga3dDXSetStreamOutput(pThisCC, idDXContext, pCmd);
3162#else
3163 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3164 return VERR_NOT_SUPPORTED;
3165#endif
3166}
3167
3168
3169/* SVGA_3D_CMD_DX_SET_COTABLE 1207 */
3170static int vmsvga3dCmdDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, uint32_t cbCmd)
3171{
3172#ifdef VMSVGA3D_DX
3173 //DEBUG_BREAKPOINT_TEST();
3174 RT_NOREF(cbCmd);
3175 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3176 /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
3177 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
3178 return vmsvga3dDXSetCOTable(pThisCC, pCmd, pMob);
3179#else
3180 RT_NOREF(pThisCC, pCmd, cbCmd);
3181 return VERR_NOT_SUPPORTED;
3182#endif
3183}
3184
3185
3186/* SVGA_3D_CMD_DX_READBACK_COTABLE 1208 */
3187static int vmsvga3dCmdDXReadbackCOTable(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackCOTable const *pCmd, uint32_t cbCmd)
3188{
3189#ifdef VMSVGA3D_DX
3190 //DEBUG_BREAKPOINT_TEST();
3191 RT_NOREF(idDXContext, cbCmd);
3192 return vmsvga3dDXReadbackCOTable(pThisCC, pCmd);
3193#else
3194 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3195 return VERR_NOT_SUPPORTED;
3196#endif
3197}
3198
3199
3200/* SVGA_3D_CMD_DX_BUFFER_COPY 1209 */
3201static int vmsvga3dCmdDXBufferCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBufferCopy const *pCmd, uint32_t cbCmd)
3202{
3203#ifdef VMSVGA3D_DX
3204 //DEBUG_BREAKPOINT_TEST();
3205 RT_NOREF(idDXContext, cbCmd);
3206
3207 int rc;
3208
3209 /** @todo Backend should o the copy is both buffers have a hardware resource. */
3210 SVGA3dSurfaceImageId imageBufferSrc;
3211 imageBufferSrc.sid = pCmd->src;
3212 imageBufferSrc.face = 0;
3213 imageBufferSrc.mipmap = 0;
3214
3215 SVGA3dSurfaceImageId imageBufferDest;
3216 imageBufferDest.sid = pCmd->dest;
3217 imageBufferDest.face = 0;
3218 imageBufferDest.mipmap = 0;
3219
3220 /*
3221 * Map the source buffer.
3222 */
3223 VMSVGA3D_MAPPED_SURFACE mapBufferSrc;
3224 rc = vmsvga3dSurfaceMap(pThisCC, &imageBufferSrc, NULL, VMSVGA3D_SURFACE_MAP_READ, &mapBufferSrc);
3225 if (RT_SUCCESS(rc))
3226 {
3227 /*
3228 * Map the destination buffer.
3229 */
3230 VMSVGA3D_MAPPED_SURFACE mapBufferDest;
3231 rc = vmsvga3dSurfaceMap(pThisCC, &imageBufferDest, NULL, VMSVGA3D_SURFACE_MAP_WRITE, &mapBufferDest);
3232 if (RT_SUCCESS(rc))
3233 {
3234 /*
3235 * Copy the source buffer to the destination.
3236 */
3237 uint8_t const *pu8BufferSrc = (uint8_t *)mapBufferSrc.pvData;
3238 uint32_t const cbBufferSrc = mapBufferSrc.cbRow;
3239
3240 uint8_t *pu8BufferDest = (uint8_t *)mapBufferDest.pvData;
3241 uint32_t const cbBufferDest = mapBufferDest.cbRow;
3242
3243 if ( pCmd->srcX < cbBufferSrc
3244 && pCmd->width <= cbBufferSrc- pCmd->srcX
3245 && pCmd->destX < cbBufferDest
3246 && pCmd->width <= cbBufferDest - pCmd->destX)
3247 {
3248 RT_UNTRUSTED_VALIDATED_FENCE();
3249
3250 memcpy(&pu8BufferDest[pCmd->destX], &pu8BufferSrc[pCmd->srcX], pCmd->width);
3251 }
3252 else
3253 ASSERT_GUEST_FAILED_STMT(rc = VERR_INVALID_PARAMETER);
3254
3255 vmsvga3dSurfaceUnmap(pThisCC, &imageBufferDest, &mapBufferDest, true);
3256 }
3257
3258 vmsvga3dSurfaceUnmap(pThisCC, &imageBufferSrc, &mapBufferSrc, false);
3259 }
3260
3261 return rc;
3262#else
3263 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3264 return VERR_NOT_SUPPORTED;
3265#endif
3266}
3267
3268
3269/* SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER 1210 */
3270static int vmsvga3dCmdDXTransferFromBuffer(PVGASTATECC pThisCC, SVGA3dCmdDXTransferFromBuffer const *pCmd, uint32_t cbCmd)
3271{
3272#ifdef VMSVGA3D_DX
3273 //DEBUG_BREAKPOINT_TEST();
3274 RT_NOREF(cbCmd);
3275
3276 /* Plan:
3277 * - map the buffer;
3278 * - map the surface;
3279 * - copy from buffer map to the surface map.
3280 */
3281
3282 int rc;
3283
3284 SVGA3dSurfaceImageId imageBuffer;
3285 imageBuffer.sid = pCmd->srcSid;
3286 imageBuffer.face = 0;
3287 imageBuffer.mipmap = 0;
3288
3289 SVGA3dSurfaceImageId imageSurface;
3290 imageSurface.sid = pCmd->destSid;
3291 rc = vmsvga3dCalcSurfaceMipmapAndFace(pThisCC, pCmd->destSid, pCmd->destSubResource, &imageSurface.mipmap, &imageSurface.face);
3292 AssertRCReturn(rc, rc);
3293
3294 /*
3295 * Map the buffer.
3296 */
3297 VMSVGA3D_MAPPED_SURFACE mapBuffer;
3298 rc = vmsvga3dSurfaceMap(pThisCC, &imageBuffer, NULL, VMSVGA3D_SURFACE_MAP_READ, &mapBuffer);
3299 if (RT_SUCCESS(rc))
3300 {
3301 /*
3302 * Map the surface.
3303 */
3304 VMSVGA3D_MAPPED_SURFACE mapSurface;
3305 rc = vmsvga3dSurfaceMap(pThisCC, &imageSurface, &pCmd->destBox, VMSVGA3D_SURFACE_MAP_WRITE, &mapSurface);
3306 if (RT_SUCCESS(rc))
3307 {
3308 /*
3309 * Copy the mapped buffer to the surface. "Raw byte wise transfer"
3310 */
3311 uint8_t const *pu8Buffer = (uint8_t *)mapBuffer.pvData;
3312 uint32_t const cbBuffer = mapBuffer.cbRow;
3313
3314 if (pCmd->srcOffset <= cbBuffer)
3315 {
3316 RT_UNTRUSTED_VALIDATED_FENCE();
3317 uint8_t const *pu8BufferBegin = pu8Buffer;
3318 uint8_t const *pu8BufferEnd = pu8Buffer + cbBuffer;
3319
3320 pu8Buffer += pCmd->srcOffset;
3321
3322 uint8_t *pu8Surface = (uint8_t *)mapSurface.pvData;
3323
3324 uint32_t const cbRowCopy = RT_MIN(pCmd->srcPitch, mapSurface.cbRow);
3325 for (uint32_t z = 0; z < mapSurface.box.d && RT_SUCCESS(rc); ++z)
3326 {
3327 uint8_t const *pu8BufferRow = pu8Buffer;
3328 uint8_t *pu8SurfaceRow = pu8Surface;
3329 for (uint32_t iRow = 0; iRow < mapSurface.cRows; ++iRow)
3330 {
3331 ASSERT_GUEST_STMT_BREAK( (uintptr_t)pu8BufferRow >= (uintptr_t)pu8BufferBegin
3332 && (uintptr_t)pu8BufferRow < (uintptr_t)pu8BufferEnd
3333 && (uintptr_t)pu8BufferRow < (uintptr_t)(pu8BufferRow + cbRowCopy)
3334 && (uintptr_t)(pu8BufferRow + cbRowCopy) > (uintptr_t)pu8BufferBegin
3335 && (uintptr_t)(pu8BufferRow + cbRowCopy) <= (uintptr_t)pu8BufferEnd,
3336 rc = VERR_INVALID_PARAMETER);
3337
3338 memcpy(pu8SurfaceRow, pu8BufferRow, cbRowCopy);
3339
3340 pu8SurfaceRow += mapSurface.cbRowPitch;
3341 pu8BufferRow += pCmd->srcPitch;
3342 }
3343
3344 pu8Buffer += pCmd->srcSlicePitch;
3345 pu8Surface += mapSurface.cbDepthPitch;
3346 }
3347 }
3348 else
3349 ASSERT_GUEST_FAILED_STMT(rc = VERR_INVALID_PARAMETER);
3350
3351 vmsvga3dSurfaceUnmap(pThisCC, &imageSurface, &mapSurface, true);
3352 }
3353
3354 vmsvga3dSurfaceUnmap(pThisCC, &imageBuffer, &mapBuffer, false);
3355 }
3356
3357 return rc;
3358#else
3359 RT_NOREF(pThisCC, pCmd, cbCmd);
3360 return VERR_NOT_SUPPORTED;
3361#endif
3362}
3363
3364
3365/* SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK 1211 */
3366static int vmsvga3dCmdDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSurfaceCopyAndReadback const *pCmd, uint32_t cbCmd)
3367{
3368#ifdef VMSVGA3D_DX
3369 DEBUG_BREAKPOINT_TEST();
3370 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3371 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3372 return vmsvga3dDXSurfaceCopyAndReadback(pThisCC, idDXContext);
3373#else
3374 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3375 return VERR_NOT_SUPPORTED;
3376#endif
3377}
3378
3379
3380/* SVGA_3D_CMD_DX_MOVE_QUERY 1212 */
3381static int vmsvga3dCmdDXMoveQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXMoveQuery const *pCmd, uint32_t cbCmd)
3382{
3383#ifdef VMSVGA3D_DX
3384 DEBUG_BREAKPOINT_TEST();
3385 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3386 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3387 return vmsvga3dDXMoveQuery(pThisCC, idDXContext);
3388#else
3389 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3390 return VERR_NOT_SUPPORTED;
3391#endif
3392}
3393
3394
3395/* SVGA_3D_CMD_DX_BIND_ALL_QUERY 1213 */
3396static int vmsvga3dCmdDXBindAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindAllQuery const *pCmd, uint32_t cbCmd)
3397{
3398#ifdef VMSVGA3D_DX
3399 //DEBUG_BREAKPOINT_TEST();
3400 RT_NOREF(cbCmd);
3401 return vmsvga3dDXBindAllQuery(pThisCC, idDXContext, pCmd);
3402#else
3403 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3404 return VERR_NOT_SUPPORTED;
3405#endif
3406}
3407
3408
3409/* SVGA_3D_CMD_DX_READBACK_ALL_QUERY 1214 */
3410static int vmsvga3dCmdDXReadbackAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackAllQuery const *pCmd, uint32_t cbCmd)
3411{
3412#ifdef VMSVGA3D_DX
3413 //DEBUG_BREAKPOINT_TEST();
3414 RT_NOREF(cbCmd);
3415 return vmsvga3dDXReadbackAllQuery(pThisCC, idDXContext, pCmd);
3416#else
3417 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3418 return VERR_NOT_SUPPORTED;
3419#endif
3420}
3421
3422
3423/* SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER 1215 */
3424static int vmsvga3dCmdDXPredTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredTransferFromBuffer const *pCmd, uint32_t cbCmd)
3425{
3426#ifdef VMSVGA3D_DX
3427 //DEBUG_BREAKPOINT_TEST();
3428 RT_NOREF(idDXContext, cbCmd);
3429
3430 /* This command is executed in a context: "The context is implied from the command buffer header."
3431 * However the device design allows to do the transfer without a context, so re-use context-less command handler.
3432 */
3433 SVGA3dCmdDXTransferFromBuffer cmd;
3434 cmd.srcSid = pCmd->srcSid;
3435 cmd.srcOffset = pCmd->srcOffset;
3436 cmd.srcPitch = pCmd->srcPitch;
3437 cmd.srcSlicePitch = pCmd->srcSlicePitch;
3438 cmd.destSid = pCmd->destSid;
3439 cmd.destSubResource = pCmd->destSubResource;
3440 cmd.destBox = pCmd->destBox;
3441 return vmsvga3dCmdDXTransferFromBuffer(pThisCC, &cmd, sizeof(cmd));
3442#else
3443 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3444 return VERR_NOT_SUPPORTED;
3445#endif
3446}
3447
3448
3449/* SVGA_3D_CMD_DX_MOB_FENCE_64 1216 */
3450static int vmsvga3dCmdDXMobFence64(PVGASTATECC pThisCC, SVGA3dCmdDXMobFence64 const *pCmd, uint32_t cbCmd)
3451{
3452#ifdef VMSVGA3D_DX
3453 //DEBUG_BREAKPOINT_TEST();
3454 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3455 RT_NOREF(cbCmd);
3456
3457 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobId);
3458 ASSERT_GUEST_RETURN(pMob, VERR_INVALID_PARAMETER);
3459
3460 int rc = vmsvgaR3MobWrite(pSvgaR3State, pMob, pCmd->mobOffset, &pCmd->value, sizeof(pCmd->value));
3461 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
3462
3463 return VINF_SUCCESS;
3464#else
3465 RT_NOREF(pThisCC, pCmd, cbCmd);
3466 return VERR_NOT_SUPPORTED;
3467#endif
3468}
3469
3470
3471/* SVGA_3D_CMD_DX_BIND_ALL_SHADER 1217 */
3472static int vmsvga3dCmdDXBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindAllShader const *pCmd, uint32_t cbCmd)
3473{
3474#ifdef VMSVGA3D_DX
3475 DEBUG_BREAKPOINT_TEST();
3476 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3477 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3478 return vmsvga3dDXBindAllShader(pThisCC, idDXContext);
3479#else
3480 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3481 return VERR_NOT_SUPPORTED;
3482#endif
3483}
3484
3485
3486/* SVGA_3D_CMD_DX_HINT 1218 */
3487static int vmsvga3dCmdDXHint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXHint const *pCmd, uint32_t cbCmd)
3488{
3489#ifdef VMSVGA3D_DX
3490 DEBUG_BREAKPOINT_TEST();
3491 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3492 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3493 return vmsvga3dDXHint(pThisCC, idDXContext);
3494#else
3495 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3496 return VERR_NOT_SUPPORTED;
3497#endif
3498}
3499
3500
3501/* SVGA_3D_CMD_DX_BUFFER_UPDATE 1219 */
3502static int vmsvga3dCmdDXBufferUpdate(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBufferUpdate const *pCmd, uint32_t cbCmd)
3503{
3504#ifdef VMSVGA3D_DX
3505 DEBUG_BREAKPOINT_TEST();
3506 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3507 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3508 return vmsvga3dDXBufferUpdate(pThisCC, idDXContext);
3509#else
3510 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3511 return VERR_NOT_SUPPORTED;
3512#endif
3513}
3514
3515
3516/* SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET 1220 */
3517static int vmsvga3dCmdDXSetVSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetVSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3518{
3519#ifdef VMSVGA3D_DX
3520 DEBUG_BREAKPOINT_TEST();
3521 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3522 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3523 return vmsvga3dDXSetVSConstantBufferOffset(pThisCC, idDXContext);
3524#else
3525 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3526 return VERR_NOT_SUPPORTED;
3527#endif
3528}
3529
3530
3531/* SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET 1221 */
3532static int vmsvga3dCmdDXSetPSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetPSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3533{
3534#ifdef VMSVGA3D_DX
3535 DEBUG_BREAKPOINT_TEST();
3536 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3537 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3538 return vmsvga3dDXSetPSConstantBufferOffset(pThisCC, idDXContext);
3539#else
3540 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3541 return VERR_NOT_SUPPORTED;
3542#endif
3543}
3544
3545
3546/* SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET 1222 */
3547static int vmsvga3dCmdDXSetGSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetGSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3548{
3549#ifdef VMSVGA3D_DX
3550 DEBUG_BREAKPOINT_TEST();
3551 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3552 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3553 return vmsvga3dDXSetGSConstantBufferOffset(pThisCC, idDXContext);
3554#else
3555 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3556 return VERR_NOT_SUPPORTED;
3557#endif
3558}
3559
3560
3561/* SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET 1223 */
3562static int vmsvga3dCmdDXSetHSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetHSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3563{
3564#ifdef VMSVGA3D_DX
3565 DEBUG_BREAKPOINT_TEST();
3566 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3567 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3568 return vmsvga3dDXSetHSConstantBufferOffset(pThisCC, idDXContext);
3569#else
3570 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3571 return VERR_NOT_SUPPORTED;
3572#endif
3573}
3574
3575
3576/* SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET 1224 */
3577static int vmsvga3dCmdDXSetDSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3578{
3579#ifdef VMSVGA3D_DX
3580 DEBUG_BREAKPOINT_TEST();
3581 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3582 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3583 return vmsvga3dDXSetDSConstantBufferOffset(pThisCC, idDXContext);
3584#else
3585 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3586 return VERR_NOT_SUPPORTED;
3587#endif
3588}
3589
3590
3591/* SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET 1225 */
3592static int vmsvga3dCmdDXSetCSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetCSConstantBufferOffset const *pCmd, uint32_t cbCmd)
3593{
3594#ifdef VMSVGA3D_DX
3595 DEBUG_BREAKPOINT_TEST();
3596 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3597 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3598 return vmsvga3dDXSetCSConstantBufferOffset(pThisCC, idDXContext);
3599#else
3600 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3601 return VERR_NOT_SUPPORTED;
3602#endif
3603}
3604
3605
3606/* SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER 1226 */
3607static int vmsvga3dCmdDXCondBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCondBindAllShader const *pCmd, uint32_t cbCmd)
3608{
3609#ifdef VMSVGA3D_DX
3610 DEBUG_BREAKPOINT_TEST();
3611 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3612 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3613 return vmsvga3dDXCondBindAllShader(pThisCC, idDXContext);
3614#else
3615 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3616 return VERR_NOT_SUPPORTED;
3617#endif
3618}
3619
3620
3621/* SVGA_3D_CMD_SCREEN_COPY 1227 */
3622static int vmsvga3dCmdScreenCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdScreenCopy const *pCmd, uint32_t cbCmd)
3623{
3624#ifdef VMSVGA3D_DX
3625 DEBUG_BREAKPOINT_TEST();
3626 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3627 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3628 return vmsvga3dScreenCopy(pThisCC, idDXContext);
3629#else
3630 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3631 return VERR_NOT_SUPPORTED;
3632#endif
3633}
3634
3635
3636/* SVGA_3D_CMD_GROW_OTABLE 1236 */
3637static int vmsvga3dCmdGrowOTable(PVGASTATECC pThisCC, SVGA3dCmdGrowOTable const *pCmd, uint32_t cbCmd)
3638{
3639#ifdef VMSVGA3D_DX
3640 //DEBUG_BREAKPOINT_TEST();
3641 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3642 RT_NOREF(cbCmd);
3643 return vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
3644 pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ true);
3645#else
3646 RT_NOREF(pThisCC, pCmd, cbCmd);
3647 return VERR_NOT_SUPPORTED;
3648#endif
3649}
3650
3651
3652/* SVGA_3D_CMD_DX_GROW_COTABLE 1237 */
3653static int vmsvga3dCmdDXGrowCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXGrowCOTable const *pCmd, uint32_t cbCmd)
3654{
3655#ifdef VMSVGA3D_DX
3656 //DEBUG_BREAKPOINT_TEST();
3657 RT_NOREF(cbCmd);
3658 return vmsvga3dDXGrowCOTable(pThisCC, pCmd);
3659#else
3660 RT_NOREF(pThisCC, pCmd, cbCmd);
3661 return VERR_NOT_SUPPORTED;
3662#endif
3663}
3664
3665
3666/* SVGA_3D_CMD_INTRA_SURFACE_COPY 1238 */
3667static int vmsvga3dCmdIntraSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdIntraSurfaceCopy const *pCmd, uint32_t cbCmd)
3668{
3669#ifdef VMSVGA3D_DX
3670 DEBUG_BREAKPOINT_TEST();
3671 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3672 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3673 return vmsvga3dIntraSurfaceCopy(pThisCC, idDXContext);
3674#else
3675 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3676 return VERR_NOT_SUPPORTED;
3677#endif
3678}
3679
3680
3681/* SVGA_3D_CMD_DEFINE_GB_SURFACE_V3 1239 */
3682static int vmsvga3dCmdDefineGBSurface_v3(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v3 const *pCmd)
3683{
3684#ifdef VMSVGA3D_DX
3685 DEBUG_BREAKPOINT_TEST();
3686 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3687
3688 /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
3689 SVGAOTableSurfaceEntry entry;
3690 RT_ZERO(entry);
3691 entry.format = pCmd->format;
3692 entry.surface1Flags = (uint32_t)(pCmd->surfaceFlags);
3693 entry.numMipLevels = pCmd->numMipLevels;
3694 entry.multisampleCount = pCmd->multisampleCount;
3695 entry.autogenFilter = pCmd->autogenFilter;
3696 entry.size = pCmd->size;
3697 entry.mobid = SVGA_ID_INVALID;
3698 entry.arraySize = pCmd->arraySize;
3699 // entry.mobPitch = 0;
3700 // entry.mobPitch = 0;
3701 entry.surface2Flags = (uint32_t)(pCmd->surfaceFlags >> UINT64_C(32));
3702 // entry.multisamplePattern = 0;
3703 // entry.qualityLevel = 0;
3704 // entry.bufferByteStride = 0;
3705 // entry.minLOD = 0;
3706
3707 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
3708 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
3709 if (RT_SUCCESS(rc))
3710 {
3711 /* Create the host surface. */
3712 /** @todo SVGAOTableSurfaceEntry as input parameter? */
3713 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
3714 pCmd->multisampleCount, pCmd->autogenFilter,
3715 pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* fAllocMipLevels = */ false);
3716 }
3717 return rc;
3718#else
3719 RT_NOREF(pThisCC, pCmd);
3720 return VERR_NOT_SUPPORTED;
3721#endif
3722}
3723
3724
3725/* SVGA_3D_CMD_DX_RESOLVE_COPY 1240 */
3726static int vmsvga3dCmdDXResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXResolveCopy const *pCmd, uint32_t cbCmd)
3727{
3728#ifdef VMSVGA3D_DX
3729 DEBUG_BREAKPOINT_TEST();
3730 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3731 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3732 return vmsvga3dDXResolveCopy(pThisCC, idDXContext);
3733#else
3734 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3735 return VERR_NOT_SUPPORTED;
3736#endif
3737}
3738
3739
3740/* SVGA_3D_CMD_DX_PRED_RESOLVE_COPY 1241 */
3741static int vmsvga3dCmdDXPredResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredResolveCopy const *pCmd, uint32_t cbCmd)
3742{
3743#ifdef VMSVGA3D_DX
3744 DEBUG_BREAKPOINT_TEST();
3745 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3746 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3747 return vmsvga3dDXPredResolveCopy(pThisCC, idDXContext);
3748#else
3749 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3750 return VERR_NOT_SUPPORTED;
3751#endif
3752}
3753
3754
3755/* SVGA_3D_CMD_DX_PRED_CONVERT_REGION 1242 */
3756static int vmsvga3dCmdDXPredConvertRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredConvertRegion const *pCmd, uint32_t cbCmd)
3757{
3758#ifdef VMSVGA3D_DX
3759 DEBUG_BREAKPOINT_TEST();
3760 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3761 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3762 return vmsvga3dDXPredConvertRegion(pThisCC, idDXContext);
3763#else
3764 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3765 return VERR_NOT_SUPPORTED;
3766#endif
3767}
3768
3769
3770/* SVGA_3D_CMD_DX_PRED_CONVERT 1243 */
3771static int vmsvga3dCmdDXPredConvert(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredConvert const *pCmd, uint32_t cbCmd)
3772{
3773#ifdef VMSVGA3D_DX
3774 DEBUG_BREAKPOINT_TEST();
3775 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3776 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3777 return vmsvga3dDXPredConvert(pThisCC, idDXContext);
3778#else
3779 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3780 return VERR_NOT_SUPPORTED;
3781#endif
3782}
3783
3784
3785/* SVGA_3D_CMD_WHOLE_SURFACE_COPY 1244 */
3786static int vmsvga3dCmdWholeSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdWholeSurfaceCopy const *pCmd, uint32_t cbCmd)
3787{
3788#ifdef VMSVGA3D_DX
3789 DEBUG_BREAKPOINT_TEST();
3790 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3791 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3792 return vmsvga3dWholeSurfaceCopy(pThisCC, idDXContext);
3793#else
3794 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3795 return VERR_NOT_SUPPORTED;
3796#endif
3797}
3798
3799
3800/* SVGA_3D_CMD_DX_DEFINE_UA_VIEW 1245 */
3801static int vmsvga3dCmdDXDefineUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineUAView const *pCmd, uint32_t cbCmd)
3802{
3803#ifdef VMSVGA3D_DX
3804 //DEBUG_BREAKPOINT_TEST();
3805 RT_NOREF(cbCmd);
3806 return vmsvga3dDXDefineUAView(pThisCC, idDXContext, pCmd);
3807#else
3808 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3809 return VERR_NOT_SUPPORTED;
3810#endif
3811}
3812
3813
3814/* SVGA_3D_CMD_DX_DESTROY_UA_VIEW 1246 */
3815static int vmsvga3dCmdDXDestroyUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyUAView const *pCmd, uint32_t cbCmd)
3816{
3817#ifdef VMSVGA3D_DX
3818 //DEBUG_BREAKPOINT_TEST();
3819 RT_NOREF(cbCmd);
3820 return vmsvga3dDXDestroyUAView(pThisCC, idDXContext, pCmd);
3821#else
3822 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3823 return VERR_NOT_SUPPORTED;
3824#endif
3825}
3826
3827
3828/* SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT 1247 */
3829static int vmsvga3dCmdDXClearUAViewUint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewUint const *pCmd, uint32_t cbCmd)
3830{
3831#ifdef VMSVGA3D_DX
3832 DEBUG_BREAKPOINT_TEST();
3833 RT_NOREF(cbCmd);
3834 return vmsvga3dDXClearUAViewUint(pThisCC, idDXContext, pCmd);
3835#else
3836 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3837 return VERR_NOT_SUPPORTED;
3838#endif
3839}
3840
3841
3842/* SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT 1248 */
3843static int vmsvga3dCmdDXClearUAViewFloat(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewFloat const *pCmd, uint32_t cbCmd)
3844{
3845#ifdef VMSVGA3D_DX
3846 DEBUG_BREAKPOINT_TEST();
3847 RT_NOREF(cbCmd);
3848 return vmsvga3dDXClearUAViewFloat(pThisCC, idDXContext, pCmd);
3849#else
3850 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3851 return VERR_NOT_SUPPORTED;
3852#endif
3853}
3854
3855
3856/* SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT 1249 */
3857static int vmsvga3dCmdDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCopyStructureCount const *pCmd, uint32_t cbCmd)
3858{
3859#ifdef VMSVGA3D_DX
3860 //DEBUG_BREAKPOINT_TEST();
3861 RT_NOREF(cbCmd);
3862 return vmsvga3dDXCopyStructureCount(pThisCC, idDXContext, pCmd);
3863#else
3864 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3865 return VERR_NOT_SUPPORTED;
3866#endif
3867}
3868
3869
3870/* SVGA_3D_CMD_DX_SET_UA_VIEWS 1250 */
3871static int vmsvga3dCmdDXSetUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetUAViews const *pCmd, uint32_t cbCmd)
3872{
3873#ifdef VMSVGA3D_DX
3874 //DEBUG_BREAKPOINT_TEST();
3875 SVGA3dUAViewId const *paUAViewId = (SVGA3dUAViewId *)&pCmd[1];
3876 uint32_t const cUAViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dUAViewId);
3877 return vmsvga3dDXSetUAViews(pThisCC, idDXContext, pCmd, cUAViewId, paUAViewId);
3878#else
3879 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3880 return VERR_NOT_SUPPORTED;
3881#endif
3882}
3883
3884
3885/* SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT 1251 */
3886static int vmsvga3dCmdDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstancedIndirect const *pCmd, uint32_t cbCmd)
3887{
3888#ifdef VMSVGA3D_DX
3889 //DEBUG_BREAKPOINT_TEST();
3890 RT_NOREF(cbCmd);
3891 return vmsvga3dDXDrawIndexedInstancedIndirect(pThisCC, idDXContext, pCmd);
3892#else
3893 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3894 return VERR_NOT_SUPPORTED;
3895#endif
3896}
3897
3898
3899/* SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT 1252 */
3900static int vmsvga3dCmdDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstancedIndirect const *pCmd, uint32_t cbCmd)
3901{
3902#ifdef VMSVGA3D_DX
3903 //DEBUG_BREAKPOINT_TEST();
3904 RT_NOREF(cbCmd);
3905 return vmsvga3dDXDrawInstancedIndirect(pThisCC, idDXContext, pCmd);
3906#else
3907 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3908 return VERR_NOT_SUPPORTED;
3909#endif
3910}
3911
3912
3913/* SVGA_3D_CMD_DX_DISPATCH 1253 */
3914static int vmsvga3dCmdDXDispatch(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatch const *pCmd, uint32_t cbCmd)
3915{
3916#ifdef VMSVGA3D_DX
3917 //DEBUG_BREAKPOINT_TEST();
3918 RT_NOREF(cbCmd);
3919 return vmsvga3dDXDispatch(pThisCC, idDXContext, pCmd);
3920#else
3921 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3922 return VERR_NOT_SUPPORTED;
3923#endif
3924}
3925
3926
3927/* SVGA_3D_CMD_DX_DISPATCH_INDIRECT 1254 */
3928static int vmsvga3dCmdDXDispatchIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatchIndirect const *pCmd, uint32_t cbCmd)
3929{
3930#ifdef VMSVGA3D_DX
3931 DEBUG_BREAKPOINT_TEST();
3932 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3933 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3934 return vmsvga3dDXDispatchIndirect(pThisCC, idDXContext);
3935#else
3936 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3937 return VERR_NOT_SUPPORTED;
3938#endif
3939}
3940
3941
3942/* SVGA_3D_CMD_WRITE_ZERO_SURFACE 1255 */
3943static int vmsvga3dCmdWriteZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdWriteZeroSurface const *pCmd, uint32_t cbCmd)
3944{
3945#ifdef VMSVGA3D_DX
3946 DEBUG_BREAKPOINT_TEST();
3947 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3948 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3949 return vmsvga3dWriteZeroSurface(pThisCC, idDXContext);
3950#else
3951 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3952 return VERR_NOT_SUPPORTED;
3953#endif
3954}
3955
3956
3957/* SVGA_3D_CMD_HINT_ZERO_SURFACE 1256 */
3958static int vmsvga3dCmdHintZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdHintZeroSurface const *pCmd, uint32_t cbCmd)
3959{
3960#ifdef VMSVGA3D_DX
3961 DEBUG_BREAKPOINT_TEST();
3962 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3963 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3964 return vmsvga3dHintZeroSurface(pThisCC, idDXContext);
3965#else
3966 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3967 return VERR_NOT_SUPPORTED;
3968#endif
3969}
3970
3971
3972/* SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER 1257 */
3973static int vmsvga3dCmdDXTransferToBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXTransferToBuffer const *pCmd, uint32_t cbCmd)
3974{
3975#ifdef VMSVGA3D_DX
3976 DEBUG_BREAKPOINT_TEST();
3977 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
3978 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
3979 return vmsvga3dDXTransferToBuffer(pThisCC, idDXContext);
3980#else
3981 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3982 return VERR_NOT_SUPPORTED;
3983#endif
3984}
3985
3986
3987/* SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT 1258 */
3988static int vmsvga3dCmdDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStructureCount const *pCmd, uint32_t cbCmd)
3989{
3990#ifdef VMSVGA3D_DX
3991 //DEBUG_BREAKPOINT_TEST();
3992 RT_NOREF(cbCmd);
3993 return vmsvga3dDXSetStructureCount(pThisCC, idDXContext, pCmd);
3994#else
3995 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
3996 return VERR_NOT_SUPPORTED;
3997#endif
3998}
3999
4000
4001/* SVGA_3D_CMD_LOGICOPS_BITBLT 1259 */
4002static int vmsvga3dCmdLogicOpsBitBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsBitBlt const *pCmd, uint32_t cbCmd)
4003{
4004#ifdef VMSVGA3D_DX
4005 DEBUG_BREAKPOINT_TEST();
4006 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4007 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4008 return vmsvga3dLogicOpsBitBlt(pThisCC, idDXContext);
4009#else
4010 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4011 return VERR_NOT_SUPPORTED;
4012#endif
4013}
4014
4015
4016/* SVGA_3D_CMD_LOGICOPS_TRANSBLT 1260 */
4017static int vmsvga3dCmdLogicOpsTransBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsTransBlt const *pCmd, uint32_t cbCmd)
4018{
4019#ifdef VMSVGA3D_DX
4020 DEBUG_BREAKPOINT_TEST();
4021 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4022 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4023 return vmsvga3dLogicOpsTransBlt(pThisCC, idDXContext);
4024#else
4025 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4026 return VERR_NOT_SUPPORTED;
4027#endif
4028}
4029
4030
4031/* SVGA_3D_CMD_LOGICOPS_STRETCHBLT 1261 */
4032static int vmsvga3dCmdLogicOpsStretchBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsStretchBlt const *pCmd, uint32_t cbCmd)
4033{
4034#ifdef VMSVGA3D_DX
4035 DEBUG_BREAKPOINT_TEST();
4036 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4037 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4038 return vmsvga3dLogicOpsStretchBlt(pThisCC, idDXContext);
4039#else
4040 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4041 return VERR_NOT_SUPPORTED;
4042#endif
4043}
4044
4045
4046/* SVGA_3D_CMD_LOGICOPS_COLORFILL 1262 */
4047static int vmsvga3dCmdLogicOpsColorFill(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsColorFill const *pCmd, uint32_t cbCmd)
4048{
4049#ifdef VMSVGA3D_DX
4050 DEBUG_BREAKPOINT_TEST();
4051 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4052 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4053 return vmsvga3dLogicOpsColorFill(pThisCC, idDXContext);
4054#else
4055 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4056 return VERR_NOT_SUPPORTED;
4057#endif
4058}
4059
4060
4061/* SVGA_3D_CMD_LOGICOPS_ALPHABLEND 1263 */
4062static int vmsvga3dCmdLogicOpsAlphaBlend(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsAlphaBlend const *pCmd, uint32_t cbCmd)
4063{
4064#ifdef VMSVGA3D_DX
4065 DEBUG_BREAKPOINT_TEST();
4066 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4067 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4068 return vmsvga3dLogicOpsAlphaBlend(pThisCC, idDXContext);
4069#else
4070 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4071 return VERR_NOT_SUPPORTED;
4072#endif
4073}
4074
4075
4076/* SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND 1264 */
4077static int vmsvga3dCmdLogicOpsClearTypeBlend(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsClearTypeBlend const *pCmd, uint32_t cbCmd)
4078{
4079#ifdef VMSVGA3D_DX
4080 DEBUG_BREAKPOINT_TEST();
4081 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4082 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4083 return vmsvga3dLogicOpsClearTypeBlend(pThisCC, idDXContext);
4084#else
4085 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4086 return VERR_NOT_SUPPORTED;
4087#endif
4088}
4089
4090
4091/* SVGA_3D_CMD_DEFINE_GB_SURFACE_V4 1267 */
4092static int vmsvga3dCmdDefineGBSurface_v4(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v4 const *pCmd)
4093{
4094#ifdef VMSVGA3D_DX
4095 //DEBUG_BREAKPOINT_TEST();
4096 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4097
4098 /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
4099 SVGAOTableSurfaceEntry entry;
4100 RT_ZERO(entry);
4101 entry.format = pCmd->format;
4102 entry.surface1Flags = (uint32_t)(pCmd->surfaceFlags);
4103 entry.numMipLevels = pCmd->numMipLevels;
4104 entry.multisampleCount = pCmd->multisampleCount;
4105 entry.autogenFilter = pCmd->autogenFilter;
4106 entry.size = pCmd->size;
4107 entry.mobid = SVGA_ID_INVALID;
4108 entry.arraySize = pCmd->arraySize;
4109 // entry.mobPitch = 0;
4110 // entry.mobPitch = 0;
4111 entry.surface2Flags = (uint32_t)(pCmd->surfaceFlags >> UINT64_C(32));
4112 // entry.multisamplePattern = 0;
4113 // entry.qualityLevel = 0;
4114 entry.bufferByteStride = pCmd->bufferByteStride;
4115 // entry.minLOD = 0;
4116
4117 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
4118 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
4119 if (RT_SUCCESS(rc))
4120 {
4121 /* Create the host surface. */
4122 /** @todo SVGAOTableSurfaceEntry as input parameter? */
4123 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
4124 pCmd->multisampleCount, pCmd->autogenFilter,
4125 pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* fAllocMipLevels = */ false);
4126 }
4127 return rc;
4128#else
4129 RT_NOREF(pThisCC, pCmd);
4130 return VERR_NOT_SUPPORTED;
4131#endif
4132}
4133
4134
4135/* SVGA_3D_CMD_DX_SET_CS_UA_VIEWS 1268 */
4136static int vmsvga3dCmdDXSetCSUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetCSUAViews const *pCmd, uint32_t cbCmd)
4137{
4138#ifdef VMSVGA3D_DX
4139 //DEBUG_BREAKPOINT_TEST();
4140 SVGA3dUAViewId const *paUAViewId = (SVGA3dUAViewId *)&pCmd[1];
4141 uint32_t const cUAViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dUAViewId);
4142 return vmsvga3dDXSetCSUAViews(pThisCC, idDXContext, pCmd, cUAViewId, paUAViewId);
4143#else
4144 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4145 return VERR_NOT_SUPPORTED;
4146#endif
4147}
4148
4149
4150/* SVGA_3D_CMD_DX_SET_MIN_LOD 1269 */
4151static int vmsvga3dCmdDXSetMinLOD(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetMinLOD const *pCmd, uint32_t cbCmd)
4152{
4153#ifdef VMSVGA3D_DX
4154 DEBUG_BREAKPOINT_TEST();
4155 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4156 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4157 return vmsvga3dDXSetMinLOD(pThisCC, idDXContext);
4158#else
4159 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4160 return VERR_NOT_SUPPORTED;
4161#endif
4162}
4163
4164
4165/* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2 1272 */
4166static int vmsvga3dCmdDXDefineDepthStencilView_v2(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView_v2 const *pCmd, uint32_t cbCmd)
4167{
4168#ifdef VMSVGA3D_DX
4169 //DEBUG_BREAKPOINT_TEST();
4170 RT_NOREF(cbCmd);
4171 return vmsvga3dDXDefineDepthStencilView(pThisCC, idDXContext, pCmd);
4172#else
4173 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4174 return VERR_NOT_SUPPORTED;
4175#endif
4176}
4177
4178
4179/* SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB 1273 */
4180static int vmsvga3dCmdDXDefineStreamOutputWithMob(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutputWithMob const *pCmd, uint32_t cbCmd)
4181{
4182#ifdef VMSVGA3D_DX
4183 //DEBUG_BREAKPOINT_TEST();
4184 RT_NOREF(cbCmd);
4185 return vmsvga3dDXDefineStreamOutputWithMob(pThisCC, idDXContext, pCmd);
4186#else
4187 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4188 return VERR_NOT_SUPPORTED;
4189#endif
4190}
4191
4192
4193/* SVGA_3D_CMD_DX_SET_SHADER_IFACE 1274 */
4194static int vmsvga3dCmdDXSetShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderIface const *pCmd, uint32_t cbCmd)
4195{
4196#ifdef VMSVGA3D_DX
4197 DEBUG_BREAKPOINT_TEST();
4198 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4199 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4200 return vmsvga3dDXSetShaderIface(pThisCC, idDXContext);
4201#else
4202 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4203 return VERR_NOT_SUPPORTED;
4204#endif
4205}
4206
4207
4208/* SVGA_3D_CMD_DX_BIND_STREAMOUTPUT 1275 */
4209static int vmsvga3dCmdDXBindStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindStreamOutput const *pCmd, uint32_t cbCmd)
4210{
4211#ifdef VMSVGA3D_DX
4212 //DEBUG_BREAKPOINT_TEST();
4213 RT_NOREF(cbCmd);
4214 return vmsvga3dDXBindStreamOutput(pThisCC, idDXContext, pCmd);
4215#else
4216 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4217 return VERR_NOT_SUPPORTED;
4218#endif
4219}
4220
4221
4222/* SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS 1276 */
4223static int vmsvga3dCmdSurfaceStretchBltNonMSToMS(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdSurfaceStretchBltNonMSToMS const *pCmd, uint32_t cbCmd)
4224{
4225#ifdef VMSVGA3D_DX
4226 DEBUG_BREAKPOINT_TEST();
4227 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4228 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4229 return vmsvga3dSurfaceStretchBltNonMSToMS(pThisCC, idDXContext);
4230#else
4231 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4232 return VERR_NOT_SUPPORTED;
4233#endif
4234}
4235
4236
4237/* SVGA_3D_CMD_DX_BIND_SHADER_IFACE 1277 */
4238static int vmsvga3dCmdDXBindShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindShaderIface const *pCmd, uint32_t cbCmd)
4239{
4240#ifdef VMSVGA3D_DX
4241 DEBUG_BREAKPOINT_TEST();
4242 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
4243 RT_NOREF(pSvgaR3State, pCmd, cbCmd);
4244 return vmsvga3dDXBindShaderIface(pThisCC, idDXContext);
4245#else
4246 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4247 return VERR_NOT_SUPPORTED;
4248#endif
4249}
4250
4251
4252/* SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION 1083 */
4253static int vmsvga3dCmdVBDXClearRenderTargetViewRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdVBDXClearRenderTargetViewRegion *pCmd, uint32_t cbCmd)
4254{
4255#ifdef VMSVGA3D_DX
4256 //DEBUG_BREAKPOINT_TEST();
4257 SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
4258 uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
4259 return vmsvga3dVBDXClearRenderTargetViewRegion(pThisCC, idDXContext, pCmd, cRect, paRect);
4260#else
4261 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
4262 return VERR_NOT_SUPPORTED;
4263#endif
4264}
4265
4266
4267/** @def VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK
4268 * Check that the 3D command has at least a_cbMin of payload bytes after the
4269 * header. Will break out of the switch if it doesn't.
4270 */
4271# define VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(a_cbMin) \
4272 if (1) { \
4273 AssertMsgBreak(cbCmd >= (a_cbMin), ("size=%#x a_cbMin=%#zx\n", cbCmd, (size_t)(a_cbMin))); \
4274 RT_UNTRUSTED_VALIDATED_FENCE(); \
4275 } else do {} while (0)
4276
4277# define VMSVGA_3D_CMD_NOTIMPL() \
4278 if (1) { \
4279 AssertMsgFailed(("Not implemented %d %s\n", enmCmdId, vmsvgaR3FifoCmdToString(enmCmdId))); \
4280 } else do {} while (0)
4281
4282/** SVGA_3D_CMD_* handler.
4283 * This function parses the command and calls the corresponding command handler.
4284 *
4285 * @param pThis The shared VGA/VMSVGA state.
4286 * @param pThisCC The VGA/VMSVGA state for the current context.
4287 * @param idDXContext VGPU10 DX context of the commands or SVGA3D_INVALID_ID if they are not for a specific context.
4288 * @param enmCmdId SVGA_3D_CMD_* command identifier.
4289 * @param cbCmd Size of the command in bytes.
4290 * @param pvCmd Pointer to the command.
4291 * @returns VBox status code if an error was detected parsing a command.
4292 */
4293int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDXContext, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd)
4294{
4295 if (enmCmdId > SVGA_3D_CMD_MAX)
4296 {
4297 LogRelMax(16, ("VMSVGA: unsupported 3D command %d\n", enmCmdId));
4298 ASSERT_GUEST_FAILED_RETURN(VERR_NOT_IMPLEMENTED);
4299 }
4300
4301 int rcParse = VINF_SUCCESS;
4302 PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;
4303
4304 switch (enmCmdId)
4305 {
4306 case SVGA_3D_CMD_SURFACE_DEFINE:
4307 {
4308 SVGA3dCmdDefineSurface *pCmd = (SVGA3dCmdDefineSurface *)pvCmd;
4309 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4310 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefine);
4311
4312 SVGA3dCmdDefineSurface_v2 cmd;
4313 cmd.sid = pCmd->sid;
4314 cmd.surfaceFlags = pCmd->surfaceFlags;
4315 cmd.format = pCmd->format;
4316 memcpy(cmd.face, pCmd->face, sizeof(cmd.face));
4317 cmd.multisampleCount = 0;
4318 cmd.autogenFilter = SVGA3D_TEX_FILTER_NONE;
4319
4320 uint32_t const cMipLevelSizes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize);
4321 vmsvga3dCmdDefineSurface(pThisCC, &cmd, cMipLevelSizes, (SVGA3dSize *)(pCmd + 1));
4322# ifdef DEBUG_GMR_ACCESS
4323 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
4324# endif
4325 break;
4326 }
4327
4328 case SVGA_3D_CMD_SURFACE_DEFINE_V2:
4329 {
4330 SVGA3dCmdDefineSurface_v2 *pCmd = (SVGA3dCmdDefineSurface_v2 *)pvCmd;
4331 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4332 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefineV2);
4333
4334 uint32_t const cMipLevelSizes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize);
4335 vmsvga3dCmdDefineSurface(pThisCC, pCmd, cMipLevelSizes, (SVGA3dSize *)(pCmd + 1));
4336# ifdef DEBUG_GMR_ACCESS
4337 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
4338# endif
4339 break;
4340 }
4341
4342 case SVGA_3D_CMD_SURFACE_DESTROY:
4343 {
4344 SVGA3dCmdDestroySurface *pCmd = (SVGA3dCmdDestroySurface *)pvCmd;
4345 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4346 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDestroy);
4347
4348 vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid);
4349 break;
4350 }
4351
4352 case SVGA_3D_CMD_SURFACE_COPY:
4353 {
4354 SVGA3dCmdSurfaceCopy *pCmd = (SVGA3dCmdSurfaceCopy *)pvCmd;
4355 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4356 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceCopy);
4357
4358 uint32_t const cCopyBoxes = (cbCmd - sizeof(pCmd)) / sizeof(SVGA3dCopyBox);
4359 vmsvga3dSurfaceCopy(pThisCC, pCmd->dest, pCmd->src, cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
4360 break;
4361 }
4362
4363 case SVGA_3D_CMD_SURFACE_STRETCHBLT:
4364 {
4365 SVGA3dCmdSurfaceStretchBlt *pCmd = (SVGA3dCmdSurfaceStretchBlt *)pvCmd;
4366 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4367 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceStretchBlt);
4368
4369 vmsvga3dSurfaceStretchBlt(pThis, pThisCC, &pCmd->dest, &pCmd->boxDest,
4370 &pCmd->src, &pCmd->boxSrc, pCmd->mode);
4371 break;
4372 }
4373
4374 case SVGA_3D_CMD_SURFACE_DMA:
4375 {
4376 SVGA3dCmdSurfaceDMA *pCmd = (SVGA3dCmdSurfaceDMA *)pvCmd;
4377 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4378 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDma);
4379
4380 uint64_t u64NanoTS = 0;
4381 if (LogRelIs3Enabled())
4382 u64NanoTS = RTTimeNanoTS();
4383 uint32_t const cCopyBoxes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyBox);
4384 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a);
4385 vmsvga3dSurfaceDMA(pThis, pThisCC, pCmd->guest, pCmd->host, pCmd->transfer,
4386 cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
4387 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a);
4388 if (LogRelIs3Enabled())
4389 {
4390 if (cCopyBoxes)
4391 {
4392 SVGA3dCopyBox *pFirstBox = (SVGA3dCopyBox *)(pCmd + 1);
4393 LogRel3(("VMSVGA: SURFACE_DMA: %d us %d boxes %d,%d %dx%d%s\n",
4394 (RTTimeNanoTS() - u64NanoTS) / 1000ULL, cCopyBoxes,
4395 pFirstBox->x, pFirstBox->y, pFirstBox->w, pFirstBox->h,
4396 pCmd->transfer == SVGA3D_READ_HOST_VRAM ? " readback!!!" : ""));
4397 }
4398 }
4399 break;
4400 }
4401
4402 case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN:
4403 {
4404 SVGA3dCmdBlitSurfaceToScreen *pCmd = (SVGA3dCmdBlitSurfaceToScreen *)pvCmd;
4405 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4406 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceScreen);
4407
4408 static uint64_t u64FrameStartNanoTS = 0;
4409 static uint64_t u64ElapsedPerSecNano = 0;
4410 static int cFrames = 0;
4411 uint64_t u64NanoTS = 0;
4412 if (LogRelIs3Enabled())
4413 u64NanoTS = RTTimeNanoTS();
4414 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
4415 STAM_REL_PROFILE_START(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a);
4416 vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage,
4417 pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1));
4418 STAM_REL_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a);
4419 if (LogRelIs3Enabled())
4420 {
4421 uint64_t u64ElapsedNano = RTTimeNanoTS() - u64NanoTS;
4422 u64ElapsedPerSecNano += u64ElapsedNano;
4423
4424 SVGASignedRect *pFirstRect = cRects ? (SVGASignedRect *)(pCmd + 1) : &pCmd->destRect;
4425 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: %d us %d rects %d,%d %dx%d\n",
4426 (u64ElapsedNano) / 1000ULL, cRects,
4427 pFirstRect->left, pFirstRect->top,
4428 pFirstRect->right - pFirstRect->left, pFirstRect->bottom - pFirstRect->top));
4429
4430 ++cFrames;
4431 if (u64NanoTS - u64FrameStartNanoTS >= UINT64_C(1000000000))
4432 {
4433 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: FPS %d, elapsed %llu us\n",
4434 cFrames, u64ElapsedPerSecNano / 1000ULL));
4435 u64FrameStartNanoTS = u64NanoTS;
4436 cFrames = 0;
4437 u64ElapsedPerSecNano = 0;
4438 }
4439 }
4440 break;
4441 }
4442
4443 case SVGA_3D_CMD_CONTEXT_DEFINE:
4444 {
4445 SVGA3dCmdDefineContext *pCmd = (SVGA3dCmdDefineContext *)pvCmd;
4446 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4447 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDefine);
4448
4449 vmsvga3dContextDefine(pThisCC, pCmd->cid);
4450 break;
4451 }
4452
4453 case SVGA_3D_CMD_CONTEXT_DESTROY:
4454 {
4455 SVGA3dCmdDestroyContext *pCmd = (SVGA3dCmdDestroyContext *)pvCmd;
4456 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4457 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDestroy);
4458
4459 vmsvga3dContextDestroy(pThisCC, pCmd->cid);
4460 break;
4461 }
4462
4463 case SVGA_3D_CMD_SETTRANSFORM:
4464 {
4465 SVGA3dCmdSetTransform *pCmd = (SVGA3dCmdSetTransform *)pvCmd;
4466 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4467 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTransform);
4468
4469 vmsvga3dSetTransform(pThisCC, pCmd->cid, pCmd->type, pCmd->matrix);
4470 break;
4471 }
4472
4473 case SVGA_3D_CMD_SETZRANGE:
4474 {
4475 SVGA3dCmdSetZRange *pCmd = (SVGA3dCmdSetZRange *)pvCmd;
4476 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4477 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetZRange);
4478
4479 vmsvga3dSetZRange(pThisCC, pCmd->cid, pCmd->zRange);
4480 break;
4481 }
4482
4483 case SVGA_3D_CMD_SETRENDERSTATE:
4484 {
4485 SVGA3dCmdSetRenderState *pCmd = (SVGA3dCmdSetRenderState *)pvCmd;
4486 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4487 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderState);
4488
4489 uint32_t const cRenderStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderState);
4490 vmsvga3dSetRenderState(pThisCC, pCmd->cid, cRenderStates, (SVGA3dRenderState *)(pCmd + 1));
4491 break;
4492 }
4493
4494 case SVGA_3D_CMD_SETRENDERTARGET:
4495 {
4496 SVGA3dCmdSetRenderTarget *pCmd = (SVGA3dCmdSetRenderTarget *)pvCmd;
4497 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4498 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderTarget);
4499
4500 vmsvga3dSetRenderTarget(pThisCC, pCmd->cid, pCmd->type, pCmd->target);
4501 break;
4502 }
4503
4504 case SVGA_3D_CMD_SETTEXTURESTATE:
4505 {
4506 SVGA3dCmdSetTextureState *pCmd = (SVGA3dCmdSetTextureState *)pvCmd;
4507 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4508 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTextureState);
4509
4510 uint32_t const cTextureStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dTextureState);
4511 vmsvga3dSetTextureState(pThisCC, pCmd->cid, cTextureStates, (SVGA3dTextureState *)(pCmd + 1));
4512 break;
4513 }
4514
4515 case SVGA_3D_CMD_SETMATERIAL:
4516 {
4517 SVGA3dCmdSetMaterial *pCmd = (SVGA3dCmdSetMaterial *)pvCmd;
4518 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4519 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetMaterial);
4520
4521 vmsvga3dSetMaterial(pThisCC, pCmd->cid, pCmd->face, &pCmd->material);
4522 break;
4523 }
4524
4525 case SVGA_3D_CMD_SETLIGHTDATA:
4526 {
4527 SVGA3dCmdSetLightData *pCmd = (SVGA3dCmdSetLightData *)pvCmd;
4528 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4529 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetLightData);
4530
4531 vmsvga3dSetLightData(pThisCC, pCmd->cid, pCmd->index, &pCmd->data);
4532 break;
4533 }
4534
4535 case SVGA_3D_CMD_SETLIGHTENABLED:
4536 {
4537 SVGA3dCmdSetLightEnabled *pCmd = (SVGA3dCmdSetLightEnabled *)pvCmd;
4538 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4539 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetLightEnable);
4540
4541 vmsvga3dSetLightEnabled(pThisCC, pCmd->cid, pCmd->index, pCmd->enabled);
4542 break;
4543 }
4544
4545 case SVGA_3D_CMD_SETVIEWPORT:
4546 {
4547 SVGA3dCmdSetViewport *pCmd = (SVGA3dCmdSetViewport *)pvCmd;
4548 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4549 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetViewPort);
4550
4551 vmsvga3dSetViewPort(pThisCC, pCmd->cid, &pCmd->rect);
4552 break;
4553 }
4554
4555 case SVGA_3D_CMD_SETCLIPPLANE:
4556 {
4557 SVGA3dCmdSetClipPlane *pCmd = (SVGA3dCmdSetClipPlane *)pvCmd;
4558 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4559 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetClipPlane);
4560
4561 vmsvga3dSetClipPlane(pThisCC, pCmd->cid, pCmd->index, pCmd->plane);
4562 break;
4563 }
4564
4565 case SVGA_3D_CMD_CLEAR:
4566 {
4567 SVGA3dCmdClear *pCmd = (SVGA3dCmdClear *)pvCmd;
4568 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4569 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dClear);
4570
4571 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRect);
4572 vmsvga3dCommandClear(pThisCC, pCmd->cid, pCmd->clearFlag, pCmd->color, pCmd->depth, pCmd->stencil, cRects, (SVGA3dRect *)(pCmd + 1));
4573 break;
4574 }
4575
4576 case SVGA_3D_CMD_PRESENT:
4577 case SVGA_3D_CMD_PRESENT_READBACK: /** @todo SVGA_3D_CMD_PRESENT_READBACK isn't quite the same as present... */
4578 {
4579 SVGA3dCmdPresent *pCmd = (SVGA3dCmdPresent *)pvCmd;
4580 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4581 if (enmCmdId == SVGA_3D_CMD_PRESENT)
4582 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dPresent);
4583 else
4584 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dPresentReadBack);
4585
4586 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyRect);
4587 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dPresentProf, a);
4588 vmsvga3dCommandPresent(pThis, pThisCC, pCmd->sid, cRects, (SVGA3dCopyRect *)(pCmd + 1));
4589 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dPresentProf, a);
4590 break;
4591 }
4592
4593 case SVGA_3D_CMD_SHADER_DEFINE:
4594 {
4595 SVGA3dCmdDefineShader *pCmd = (SVGA3dCmdDefineShader *)pvCmd;
4596 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4597 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dShaderDefine);
4598
4599 uint32_t const cbData = (cbCmd - sizeof(*pCmd));
4600 vmsvga3dShaderDefine(pThisCC, pCmd->cid, pCmd->shid, pCmd->type, cbData, (uint32_t *)(pCmd + 1));
4601 break;
4602 }
4603
4604 case SVGA_3D_CMD_SHADER_DESTROY:
4605 {
4606 SVGA3dCmdDestroyShader *pCmd = (SVGA3dCmdDestroyShader *)pvCmd;
4607 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4608 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dShaderDestroy);
4609
4610 vmsvga3dShaderDestroy(pThisCC, pCmd->cid, pCmd->shid, pCmd->type);
4611 break;
4612 }
4613
4614 case SVGA_3D_CMD_SET_SHADER:
4615 {
4616 SVGA3dCmdSetShader *pCmd = (SVGA3dCmdSetShader *)pvCmd;
4617 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4618 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetShader);
4619
4620 vmsvga3dShaderSet(pThisCC, NULL, pCmd->cid, pCmd->type, pCmd->shid);
4621 break;
4622 }
4623
4624 case SVGA_3D_CMD_SET_SHADER_CONST:
4625 {
4626 SVGA3dCmdSetShaderConst *pCmd = (SVGA3dCmdSetShaderConst *)pvCmd;
4627 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4628 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetShaderConst);
4629
4630 uint32_t const cRegisters = (cbCmd - sizeof(*pCmd)) / sizeof(pCmd->values) + 1;
4631 vmsvga3dShaderSetConst(pThisCC, pCmd->cid, pCmd->reg, pCmd->type, pCmd->ctype, cRegisters, pCmd->values);
4632 break;
4633 }
4634
4635 case SVGA_3D_CMD_DRAW_PRIMITIVES:
4636 {
4637 SVGA3dCmdDrawPrimitives *pCmd = (SVGA3dCmdDrawPrimitives *)pvCmd;
4638 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4639 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dDrawPrimitives);
4640
4641 ASSERT_GUEST_STMT_BREAK(pCmd->numRanges <= SVGA3D_MAX_DRAW_PRIMITIVE_RANGES, rcParse = VERR_INVALID_PARAMETER);
4642 ASSERT_GUEST_STMT_BREAK(pCmd->numVertexDecls <= SVGA3D_MAX_VERTEX_ARRAYS, rcParse = VERR_INVALID_PARAMETER);
4643 uint32_t const cbRangesAndVertexDecls = pCmd->numVertexDecls * sizeof(SVGA3dVertexDecl)
4644 + pCmd->numRanges * sizeof(SVGA3dPrimitiveRange);
4645 ASSERT_GUEST_STMT_BREAK(cbRangesAndVertexDecls <= cbCmd - sizeof(*pCmd), rcParse = VERR_INVALID_PARAMETER);
4646
4647 uint32_t const cVertexDivisor = (cbCmd - sizeof(*pCmd) - cbRangesAndVertexDecls) / sizeof(uint32_t);
4648 ASSERT_GUEST_STMT_BREAK(!cVertexDivisor || cVertexDivisor == pCmd->numVertexDecls, rcParse = VERR_INVALID_PARAMETER);
4649 RT_UNTRUSTED_VALIDATED_FENCE();
4650
4651 SVGA3dVertexDecl *pVertexDecl = (SVGA3dVertexDecl *)(pCmd + 1);
4652 SVGA3dPrimitiveRange *pNumRange = (SVGA3dPrimitiveRange *)&pVertexDecl[pCmd->numVertexDecls];
4653 SVGA3dVertexDivisor *pVertexDivisor = cVertexDivisor ? (SVGA3dVertexDivisor *)&pNumRange[pCmd->numRanges] : NULL;
4654
4655 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dDrawPrimitivesProf, a);
4656 vmsvga3dDrawPrimitives(pThisCC, pCmd->cid, pCmd->numVertexDecls, pVertexDecl, pCmd->numRanges,
4657 pNumRange, cVertexDivisor, pVertexDivisor);
4658 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dDrawPrimitivesProf, a);
4659 break;
4660 }
4661
4662 case SVGA_3D_CMD_SETSCISSORRECT:
4663 {
4664 SVGA3dCmdSetScissorRect *pCmd = (SVGA3dCmdSetScissorRect *)pvCmd;
4665 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4666 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetScissorRect);
4667
4668 vmsvga3dSetScissorRect(pThisCC, pCmd->cid, &pCmd->rect);
4669 break;
4670 }
4671
4672 case SVGA_3D_CMD_BEGIN_QUERY:
4673 {
4674 SVGA3dCmdBeginQuery *pCmd = (SVGA3dCmdBeginQuery *)pvCmd;
4675 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4676 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dBeginQuery);
4677
4678 vmsvga3dQueryBegin(pThisCC, pCmd->cid, pCmd->type);
4679 break;
4680 }
4681
4682 case SVGA_3D_CMD_END_QUERY:
4683 {
4684 SVGA3dCmdEndQuery *pCmd = (SVGA3dCmdEndQuery *)pvCmd;
4685 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4686 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dEndQuery);
4687
4688 vmsvga3dQueryEnd(pThisCC, pCmd->cid, pCmd->type);
4689 break;
4690 }
4691
4692 case SVGA_3D_CMD_WAIT_FOR_QUERY:
4693 {
4694 SVGA3dCmdWaitForQuery *pCmd = (SVGA3dCmdWaitForQuery *)pvCmd;
4695 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4696 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dWaitForQuery);
4697
4698 vmsvga3dQueryWait(pThisCC, pCmd->cid, pCmd->type, pThis, &pCmd->guestResult);
4699 break;
4700 }
4701
4702 case SVGA_3D_CMD_GENERATE_MIPMAPS:
4703 {
4704 SVGA3dCmdGenerateMipmaps *pCmd = (SVGA3dCmdGenerateMipmaps *)pvCmd;
4705 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4706 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dGenerateMipmaps);
4707
4708 vmsvga3dGenerateMipmaps(pThisCC, pCmd->sid, pCmd->filter);
4709 break;
4710 }
4711
4712 case SVGA_3D_CMD_ACTIVATE_SURFACE:
4713 /* context id + surface id? */
4714 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dActivateSurface);
4715 break;
4716
4717 case SVGA_3D_CMD_DEACTIVATE_SURFACE:
4718 /* context id + surface id? */
4719 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dDeactivateSurface);
4720 break;
4721
4722 /*
4723 *
4724 * VPGU10: SVGA_CAP_GBOBJECTS+ commands.
4725 *
4726 */
4727 case SVGA_3D_CMD_SCREEN_DMA:
4728 {
4729 SVGA3dCmdScreenDMA *pCmd = (SVGA3dCmdScreenDMA *)pvCmd;
4730 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4731 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4732 break;
4733 }
4734
4735 /* case SVGA_3D_CMD_DEAD1: New SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION */
4736 case SVGA_3D_CMD_DEAD2:
4737 case SVGA_3D_CMD_DEAD12: /* Old SVGA_3D_CMD_LOGICOPS_BITBLT */
4738 case SVGA_3D_CMD_DEAD13: /* Old SVGA_3D_CMD_LOGICOPS_TRANSBLT */
4739 case SVGA_3D_CMD_DEAD14: /* Old SVGA_3D_CMD_LOGICOPS_STRETCHBLT */
4740 case SVGA_3D_CMD_DEAD15: /* Old SVGA_3D_CMD_LOGICOPS_COLORFILL */
4741 case SVGA_3D_CMD_DEAD16: /* Old SVGA_3D_CMD_LOGICOPS_ALPHABLEND */
4742 case SVGA_3D_CMD_DEAD17: /* Old SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND */
4743 {
4744 VMSVGA_3D_CMD_NOTIMPL();
4745 break;
4746 }
4747
4748 case SVGA_3D_CMD_SET_OTABLE_BASE:
4749 {
4750 SVGA3dCmdSetOTableBase *pCmd = (SVGA3dCmdSetOTableBase *)pvCmd;
4751 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4752 vmsvga3dCmdSetOTableBase(pThisCC, pCmd);
4753 break;
4754 }
4755
4756 case SVGA_3D_CMD_READBACK_OTABLE:
4757 {
4758 SVGA3dCmdReadbackOTable *pCmd = (SVGA3dCmdReadbackOTable *)pvCmd;
4759 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4760 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4761 break;
4762 }
4763
4764 case SVGA_3D_CMD_DEFINE_GB_MOB:
4765 {
4766 SVGA3dCmdDefineGBMob *pCmd = (SVGA3dCmdDefineGBMob *)pvCmd;
4767 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4768 vmsvga3dCmdDefineGBMob(pThisCC, pCmd);
4769 break;
4770 }
4771
4772 case SVGA_3D_CMD_DESTROY_GB_MOB:
4773 {
4774 SVGA3dCmdDestroyGBMob *pCmd = (SVGA3dCmdDestroyGBMob *)pvCmd;
4775 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4776 vmsvga3dCmdDestroyGBMob(pThisCC, pCmd);
4777 break;
4778 }
4779
4780 case SVGA_3D_CMD_DEAD3:
4781 {
4782 VMSVGA_3D_CMD_NOTIMPL();
4783 break;
4784 }
4785
4786 case SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING:
4787 {
4788 SVGA3dCmdUpdateGBMobMapping *pCmd = (SVGA3dCmdUpdateGBMobMapping *)pvCmd;
4789 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4790 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4791 break;
4792 }
4793
4794 case SVGA_3D_CMD_DEFINE_GB_SURFACE:
4795 {
4796 SVGA3dCmdDefineGBSurface *pCmd = (SVGA3dCmdDefineGBSurface *)pvCmd;
4797 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4798 vmsvga3dCmdDefineGBSurface(pThisCC, pCmd);
4799 break;
4800 }
4801
4802 case SVGA_3D_CMD_DESTROY_GB_SURFACE:
4803 {
4804 SVGA3dCmdDestroyGBSurface *pCmd = (SVGA3dCmdDestroyGBSurface *)pvCmd;
4805 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4806 vmsvga3dCmdDestroyGBSurface(pThisCC, pCmd);
4807 break;
4808 }
4809
4810 case SVGA_3D_CMD_BIND_GB_SURFACE:
4811 {
4812 SVGA3dCmdBindGBSurface *pCmd = (SVGA3dCmdBindGBSurface *)pvCmd;
4813 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4814 vmsvga3dCmdBindGBSurface(pThisCC, pCmd);
4815 break;
4816 }
4817
4818 case SVGA_3D_CMD_COND_BIND_GB_SURFACE:
4819 {
4820 SVGA3dCmdCondBindGBSurface *pCmd = (SVGA3dCmdCondBindGBSurface *)pvCmd;
4821 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4822 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4823 break;
4824 }
4825
4826 case SVGA_3D_CMD_UPDATE_GB_IMAGE:
4827 {
4828 SVGA3dCmdUpdateGBImage *pCmd = (SVGA3dCmdUpdateGBImage *)pvCmd;
4829 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4830 vmsvga3dCmdUpdateGBImage(pThisCC, pCmd);
4831 break;
4832 }
4833
4834 case SVGA_3D_CMD_UPDATE_GB_SURFACE:
4835 {
4836 SVGA3dCmdUpdateGBSurface *pCmd = (SVGA3dCmdUpdateGBSurface *)pvCmd;
4837 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4838 vmsvga3dCmdUpdateGBSurface(pThisCC, pCmd);
4839 break;
4840 }
4841
4842 case SVGA_3D_CMD_READBACK_GB_IMAGE:
4843 {
4844 SVGA3dCmdReadbackGBImage *pCmd = (SVGA3dCmdReadbackGBImage *)pvCmd;
4845 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4846 vmsvga3dCmdReadbackGBImage(pThisCC, pCmd);
4847 break;
4848 }
4849
4850 case SVGA_3D_CMD_READBACK_GB_SURFACE:
4851 {
4852 SVGA3dCmdReadbackGBSurface *pCmd = (SVGA3dCmdReadbackGBSurface *)pvCmd;
4853 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4854 vmsvga3dCmdReadbackGBSurface(pThisCC, pCmd);
4855 break;
4856 }
4857
4858 case SVGA_3D_CMD_INVALIDATE_GB_IMAGE:
4859 {
4860 SVGA3dCmdInvalidateGBImage *pCmd = (SVGA3dCmdInvalidateGBImage *)pvCmd;
4861 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4862 vmsvga3dCmdInvalidateGBImage(pThisCC, pCmd);
4863 break;
4864 }
4865
4866 case SVGA_3D_CMD_INVALIDATE_GB_SURFACE:
4867 {
4868 SVGA3dCmdInvalidateGBSurface *pCmd = (SVGA3dCmdInvalidateGBSurface *)pvCmd;
4869 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4870 vmsvga3dCmdInvalidateGBSurface(pThisCC, pCmd);
4871 break;
4872 }
4873
4874 case SVGA_3D_CMD_DEFINE_GB_CONTEXT:
4875 {
4876 SVGA3dCmdDefineGBContext *pCmd = (SVGA3dCmdDefineGBContext *)pvCmd;
4877 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4878 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4879 break;
4880 }
4881
4882 case SVGA_3D_CMD_DESTROY_GB_CONTEXT:
4883 {
4884 SVGA3dCmdDestroyGBContext *pCmd = (SVGA3dCmdDestroyGBContext *)pvCmd;
4885 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4886 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4887 break;
4888 }
4889
4890 case SVGA_3D_CMD_BIND_GB_CONTEXT:
4891 {
4892 SVGA3dCmdBindGBContext *pCmd = (SVGA3dCmdBindGBContext *)pvCmd;
4893 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4894 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4895 break;
4896 }
4897
4898 case SVGA_3D_CMD_READBACK_GB_CONTEXT:
4899 {
4900 SVGA3dCmdReadbackGBContext *pCmd = (SVGA3dCmdReadbackGBContext *)pvCmd;
4901 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4902 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4903 break;
4904 }
4905
4906 case SVGA_3D_CMD_INVALIDATE_GB_CONTEXT:
4907 {
4908 SVGA3dCmdInvalidateGBContext *pCmd = (SVGA3dCmdInvalidateGBContext *)pvCmd;
4909 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4910 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4911 break;
4912 }
4913
4914 case SVGA_3D_CMD_DEFINE_GB_SHADER:
4915 {
4916 SVGA3dCmdDefineGBShader *pCmd = (SVGA3dCmdDefineGBShader *)pvCmd;
4917 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4918 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4919 break;
4920 }
4921
4922 case SVGA_3D_CMD_DESTROY_GB_SHADER:
4923 {
4924 SVGA3dCmdDestroyGBShader *pCmd = (SVGA3dCmdDestroyGBShader *)pvCmd;
4925 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4926 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4927 break;
4928 }
4929
4930 case SVGA_3D_CMD_BIND_GB_SHADER:
4931 {
4932 SVGA3dCmdBindGBShader *pCmd = (SVGA3dCmdBindGBShader *)pvCmd;
4933 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4934 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4935 break;
4936 }
4937
4938 case SVGA_3D_CMD_SET_OTABLE_BASE64:
4939 {
4940 SVGA3dCmdSetOTableBase64 *pCmd = (SVGA3dCmdSetOTableBase64 *)pvCmd;
4941 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4942 vmsvga3dCmdSetOTableBase64(pThisCC, pCmd);
4943 break;
4944 }
4945
4946 case SVGA_3D_CMD_BEGIN_GB_QUERY:
4947 {
4948 SVGA3dCmdBeginGBQuery *pCmd = (SVGA3dCmdBeginGBQuery *)pvCmd;
4949 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4950 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4951 break;
4952 }
4953
4954 case SVGA_3D_CMD_END_GB_QUERY:
4955 {
4956 SVGA3dCmdEndGBQuery *pCmd = (SVGA3dCmdEndGBQuery *)pvCmd;
4957 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4958 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4959 break;
4960 }
4961
4962 case SVGA_3D_CMD_WAIT_FOR_GB_QUERY:
4963 {
4964 SVGA3dCmdWaitForGBQuery *pCmd = (SVGA3dCmdWaitForGBQuery *)pvCmd;
4965 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4966 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4967 break;
4968 }
4969
4970 case SVGA_3D_CMD_NOP:
4971 {
4972 /* Apparently there is nothing to do. */
4973 break;
4974 }
4975
4976 case SVGA_3D_CMD_ENABLE_GART:
4977 {
4978 SVGA3dCmdEnableGart *pCmd = (SVGA3dCmdEnableGart *)pvCmd;
4979 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4980 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4981 break;
4982 }
4983
4984 case SVGA_3D_CMD_DISABLE_GART:
4985 {
4986 /* No corresponding SVGA3dCmd structure. */
4987 VMSVGA_3D_CMD_NOTIMPL();
4988 break;
4989 }
4990
4991 case SVGA_3D_CMD_MAP_MOB_INTO_GART:
4992 {
4993 SVGA3dCmdMapMobIntoGart *pCmd = (SVGA3dCmdMapMobIntoGart *)pvCmd;
4994 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
4995 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
4996 break;
4997 }
4998
4999 case SVGA_3D_CMD_UNMAP_GART_RANGE:
5000 {
5001 SVGA3dCmdUnmapGartRange *pCmd = (SVGA3dCmdUnmapGartRange *)pvCmd;
5002 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5003 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5004 break;
5005 }
5006
5007 case SVGA_3D_CMD_DEFINE_GB_SCREENTARGET:
5008 {
5009 SVGA3dCmdDefineGBScreenTarget *pCmd = (SVGA3dCmdDefineGBScreenTarget *)pvCmd;
5010 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5011 vmsvga3dCmdDefineGBScreenTarget(pThis, pThisCC, pCmd);
5012 break;
5013 }
5014
5015 case SVGA_3D_CMD_DESTROY_GB_SCREENTARGET:
5016 {
5017 SVGA3dCmdDestroyGBScreenTarget *pCmd = (SVGA3dCmdDestroyGBScreenTarget *)pvCmd;
5018 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5019 vmsvga3dCmdDestroyGBScreenTarget(pThis, pThisCC, pCmd);
5020 break;
5021 }
5022
5023 case SVGA_3D_CMD_BIND_GB_SCREENTARGET:
5024 {
5025 SVGA3dCmdBindGBScreenTarget *pCmd = (SVGA3dCmdBindGBScreenTarget *)pvCmd;
5026 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5027 vmsvga3dCmdBindGBScreenTarget(pThisCC, pCmd);
5028 break;
5029 }
5030
5031 case SVGA_3D_CMD_UPDATE_GB_SCREENTARGET:
5032 {
5033 SVGA3dCmdUpdateGBScreenTarget *pCmd = (SVGA3dCmdUpdateGBScreenTarget *)pvCmd;
5034 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5035 vmsvga3dCmdUpdateGBScreenTarget(pThisCC, pCmd);
5036 break;
5037 }
5038
5039 case SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL:
5040 {
5041 SVGA3dCmdReadbackGBImagePartial *pCmd = (SVGA3dCmdReadbackGBImagePartial *)pvCmd;
5042 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5043 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5044 break;
5045 }
5046
5047 case SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL:
5048 {
5049 SVGA3dCmdInvalidateGBImagePartial *pCmd = (SVGA3dCmdInvalidateGBImagePartial *)pvCmd;
5050 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5051 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5052 break;
5053 }
5054
5055 case SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE:
5056 {
5057 SVGA3dCmdSetGBShaderConstInline *pCmd = (SVGA3dCmdSetGBShaderConstInline *)pvCmd;
5058 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5059 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5060 break;
5061 }
5062
5063 case SVGA_3D_CMD_GB_SCREEN_DMA:
5064 {
5065 SVGA3dCmdGBScreenDMA *pCmd = (SVGA3dCmdGBScreenDMA *)pvCmd;
5066 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5067 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5068 break;
5069 }
5070
5071 case SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH:
5072 {
5073 SVGA3dCmdBindGBSurfaceWithPitch *pCmd = (SVGA3dCmdBindGBSurfaceWithPitch *)pvCmd;
5074 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5075 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5076 break;
5077 }
5078
5079 case SVGA_3D_CMD_GB_MOB_FENCE:
5080 {
5081 SVGA3dCmdGBMobFence *pCmd = (SVGA3dCmdGBMobFence *)pvCmd;
5082 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5083 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5084 break;
5085 }
5086
5087 case SVGA_3D_CMD_DEFINE_GB_SURFACE_V2:
5088 {
5089 SVGA3dCmdDefineGBSurface_v2 *pCmd = (SVGA3dCmdDefineGBSurface_v2 *)pvCmd;
5090 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5091 vmsvga3dCmdDefineGBSurface_v2(pThisCC, pCmd);
5092 break;
5093 }
5094
5095 case SVGA_3D_CMD_DEFINE_GB_MOB64:
5096 {
5097 SVGA3dCmdDefineGBMob64 *pCmd = (SVGA3dCmdDefineGBMob64 *)pvCmd;
5098 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5099 vmsvga3dCmdDefineGBMob64(pThisCC, pCmd);
5100 break;
5101 }
5102
5103 case SVGA_3D_CMD_REDEFINE_GB_MOB64:
5104 {
5105 SVGA3dCmdRedefineGBMob64 *pCmd = (SVGA3dCmdRedefineGBMob64 *)pvCmd;
5106 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5107 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5108 break;
5109 }
5110
5111 case SVGA_3D_CMD_NOP_ERROR:
5112 {
5113 /* Apparently there is nothing to do. */
5114 break;
5115 }
5116
5117 case SVGA_3D_CMD_SET_VERTEX_STREAMS:
5118 {
5119 SVGA3dCmdSetVertexStreams *pCmd = (SVGA3dCmdSetVertexStreams *)pvCmd;
5120 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5121 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5122 break;
5123 }
5124
5125 case SVGA_3D_CMD_SET_VERTEX_DECLS:
5126 {
5127 SVGA3dCmdSetVertexDecls *pCmd = (SVGA3dCmdSetVertexDecls *)pvCmd;
5128 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5129 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5130 break;
5131 }
5132
5133 case SVGA_3D_CMD_SET_VERTEX_DIVISORS:
5134 {
5135 SVGA3dCmdSetVertexDivisors *pCmd = (SVGA3dCmdSetVertexDivisors *)pvCmd;
5136 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5137 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);
5138 break;
5139 }
5140
5141 case SVGA_3D_CMD_DRAW:
5142 {
5143 /* No corresponding SVGA3dCmd structure. */
5144 VMSVGA_3D_CMD_NOTIMPL();
5145 break;
5146 }
5147
5148 case SVGA_3D_CMD_DRAW_INDEXED:
5149 {
5150 /* No corresponding SVGA3dCmd structure. */
5151 VMSVGA_3D_CMD_NOTIMPL();
5152 break;
5153 }
5154
5155 case SVGA_3D_CMD_DX_DEFINE_CONTEXT:
5156 {
5157 SVGA3dCmdDXDefineContext *pCmd = (SVGA3dCmdDXDefineContext *)pvCmd;
5158 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5159 rcParse = vmsvga3dCmdDXDefineContext(pThisCC, pCmd, cbCmd);
5160 break;
5161 }
5162
5163 case SVGA_3D_CMD_DX_DESTROY_CONTEXT:
5164 {
5165 SVGA3dCmdDXDestroyContext *pCmd = (SVGA3dCmdDXDestroyContext *)pvCmd;
5166 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5167 rcParse = vmsvga3dCmdDXDestroyContext(pThisCC, pCmd, cbCmd);
5168 break;
5169 }
5170
5171 case SVGA_3D_CMD_DX_BIND_CONTEXT:
5172 {
5173 SVGA3dCmdDXBindContext *pCmd = (SVGA3dCmdDXBindContext *)pvCmd;
5174 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5175 rcParse = vmsvga3dCmdDXBindContext(pThisCC, pCmd, cbCmd);
5176 break;
5177 }
5178
5179 case SVGA_3D_CMD_DX_READBACK_CONTEXT:
5180 {
5181 SVGA3dCmdDXReadbackContext *pCmd = (SVGA3dCmdDXReadbackContext *)pvCmd;
5182 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5183 rcParse = vmsvga3dCmdDXReadbackContext(pThisCC, pCmd, cbCmd);
5184 break;
5185 }
5186
5187 case SVGA_3D_CMD_DX_INVALIDATE_CONTEXT:
5188 {
5189 SVGA3dCmdDXInvalidateContext *pCmd = (SVGA3dCmdDXInvalidateContext *)pvCmd;
5190 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5191 rcParse = vmsvga3dCmdDXInvalidateContext(pThisCC, idDXContext, pCmd, cbCmd);
5192 break;
5193 }
5194
5195 case SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER:
5196 {
5197 SVGA3dCmdDXSetSingleConstantBuffer *pCmd = (SVGA3dCmdDXSetSingleConstantBuffer *)pvCmd;
5198 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5199 rcParse = vmsvga3dCmdDXSetSingleConstantBuffer(pThisCC, idDXContext, pCmd, cbCmd);
5200 break;
5201 }
5202
5203 case SVGA_3D_CMD_DX_SET_SHADER_RESOURCES:
5204 {
5205 SVGA3dCmdDXSetShaderResources *pCmd = (SVGA3dCmdDXSetShaderResources *)pvCmd;
5206 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5207 rcParse = vmsvga3dCmdDXSetShaderResources(pThisCC, idDXContext, pCmd, cbCmd);
5208 break;
5209 }
5210
5211 case SVGA_3D_CMD_DX_SET_SHADER:
5212 {
5213 SVGA3dCmdDXSetShader *pCmd = (SVGA3dCmdDXSetShader *)pvCmd;
5214 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5215 rcParse = vmsvga3dCmdDXSetShader(pThisCC, idDXContext, pCmd, cbCmd);
5216 break;
5217 }
5218
5219 case SVGA_3D_CMD_DX_SET_SAMPLERS:
5220 {
5221 SVGA3dCmdDXSetSamplers *pCmd = (SVGA3dCmdDXSetSamplers *)pvCmd;
5222 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5223 rcParse = vmsvga3dCmdDXSetSamplers(pThisCC, idDXContext, pCmd, cbCmd);
5224 break;
5225 }
5226
5227 case SVGA_3D_CMD_DX_DRAW:
5228 {
5229 SVGA3dCmdDXDraw *pCmd = (SVGA3dCmdDXDraw *)pvCmd;
5230 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5231 rcParse = vmsvga3dCmdDXDraw(pThisCC, idDXContext, pCmd, cbCmd);
5232 break;
5233 }
5234
5235 case SVGA_3D_CMD_DX_DRAW_INDEXED:
5236 {
5237 SVGA3dCmdDXDrawIndexed *pCmd = (SVGA3dCmdDXDrawIndexed *)pvCmd;
5238 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5239 rcParse = vmsvga3dCmdDXDrawIndexed(pThisCC, idDXContext, pCmd, cbCmd);
5240 break;
5241 }
5242
5243 case SVGA_3D_CMD_DX_DRAW_INSTANCED:
5244 {
5245 SVGA3dCmdDXDrawInstanced *pCmd = (SVGA3dCmdDXDrawInstanced *)pvCmd;
5246 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5247 rcParse = vmsvga3dCmdDXDrawInstanced(pThisCC, idDXContext, pCmd, cbCmd);
5248 break;
5249 }
5250
5251 case SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED:
5252 {
5253 SVGA3dCmdDXDrawIndexedInstanced *pCmd = (SVGA3dCmdDXDrawIndexedInstanced *)pvCmd;
5254 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5255 rcParse = vmsvga3dCmdDXDrawIndexedInstanced(pThisCC, idDXContext, pCmd, cbCmd);
5256 break;
5257 }
5258
5259 case SVGA_3D_CMD_DX_DRAW_AUTO:
5260 {
5261 SVGA3dCmdDXDrawAuto *pCmd = (SVGA3dCmdDXDrawAuto *)pvCmd;
5262 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5263 rcParse = vmsvga3dCmdDXDrawAuto(pThisCC, idDXContext, pCmd, cbCmd);
5264 break;
5265 }
5266
5267 case SVGA_3D_CMD_DX_SET_INPUT_LAYOUT:
5268 {
5269 SVGA3dCmdDXSetInputLayout *pCmd = (SVGA3dCmdDXSetInputLayout *)pvCmd;
5270 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5271 rcParse = vmsvga3dCmdDXSetInputLayout(pThisCC, idDXContext, pCmd, cbCmd);
5272 break;
5273 }
5274
5275 case SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS:
5276 {
5277 SVGA3dCmdDXSetVertexBuffers *pCmd = (SVGA3dCmdDXSetVertexBuffers *)pvCmd;
5278 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5279 rcParse = vmsvga3dCmdDXSetVertexBuffers(pThisCC, idDXContext, pCmd, cbCmd);
5280 break;
5281 }
5282
5283 case SVGA_3D_CMD_DX_SET_INDEX_BUFFER:
5284 {
5285 SVGA3dCmdDXSetIndexBuffer *pCmd = (SVGA3dCmdDXSetIndexBuffer *)pvCmd;
5286 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5287 rcParse = vmsvga3dCmdDXSetIndexBuffer(pThisCC, idDXContext, pCmd, cbCmd);
5288 break;
5289 }
5290
5291 case SVGA_3D_CMD_DX_SET_TOPOLOGY:
5292 {
5293 SVGA3dCmdDXSetTopology *pCmd = (SVGA3dCmdDXSetTopology *)pvCmd;
5294 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5295 rcParse = vmsvga3dCmdDXSetTopology(pThisCC, idDXContext, pCmd, cbCmd);
5296 break;
5297 }
5298
5299 case SVGA_3D_CMD_DX_SET_RENDERTARGETS:
5300 {
5301 SVGA3dCmdDXSetRenderTargets *pCmd = (SVGA3dCmdDXSetRenderTargets *)pvCmd;
5302 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5303 rcParse = vmsvga3dCmdDXSetRenderTargets(pThisCC, idDXContext, pCmd, cbCmd);
5304 break;
5305 }
5306
5307 case SVGA_3D_CMD_DX_SET_BLEND_STATE:
5308 {
5309 SVGA3dCmdDXSetBlendState *pCmd = (SVGA3dCmdDXSetBlendState *)pvCmd;
5310 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5311 rcParse = vmsvga3dCmdDXSetBlendState(pThisCC, idDXContext, pCmd, cbCmd);
5312 break;
5313 }
5314
5315 case SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE:
5316 {
5317 SVGA3dCmdDXSetDepthStencilState *pCmd = (SVGA3dCmdDXSetDepthStencilState *)pvCmd;
5318 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5319 rcParse = vmsvga3dCmdDXSetDepthStencilState(pThisCC, idDXContext, pCmd, cbCmd);
5320 break;
5321 }
5322
5323 case SVGA_3D_CMD_DX_SET_RASTERIZER_STATE:
5324 {
5325 SVGA3dCmdDXSetRasterizerState *pCmd = (SVGA3dCmdDXSetRasterizerState *)pvCmd;
5326 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5327 rcParse = vmsvga3dCmdDXSetRasterizerState(pThisCC, idDXContext, pCmd, cbCmd);
5328 break;
5329 }
5330
5331 case SVGA_3D_CMD_DX_DEFINE_QUERY:
5332 {
5333 SVGA3dCmdDXDefineQuery *pCmd = (SVGA3dCmdDXDefineQuery *)pvCmd;
5334 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5335 rcParse = vmsvga3dCmdDXDefineQuery(pThisCC, idDXContext, pCmd, cbCmd);
5336 break;
5337 }
5338
5339 case SVGA_3D_CMD_DX_DESTROY_QUERY:
5340 {
5341 SVGA3dCmdDXDestroyQuery *pCmd = (SVGA3dCmdDXDestroyQuery *)pvCmd;
5342 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5343 rcParse = vmsvga3dCmdDXDestroyQuery(pThisCC, idDXContext, pCmd, cbCmd);
5344 break;
5345 }
5346
5347 case SVGA_3D_CMD_DX_BIND_QUERY:
5348 {
5349 SVGA3dCmdDXBindQuery *pCmd = (SVGA3dCmdDXBindQuery *)pvCmd;
5350 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5351 rcParse = vmsvga3dCmdDXBindQuery(pThisCC, idDXContext, pCmd, cbCmd);
5352 break;
5353 }
5354
5355 case SVGA_3D_CMD_DX_SET_QUERY_OFFSET:
5356 {
5357 SVGA3dCmdDXSetQueryOffset *pCmd = (SVGA3dCmdDXSetQueryOffset *)pvCmd;
5358 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5359 rcParse = vmsvga3dCmdDXSetQueryOffset(pThisCC, idDXContext, pCmd, cbCmd);
5360 break;
5361 }
5362
5363 case SVGA_3D_CMD_DX_BEGIN_QUERY:
5364 {
5365 SVGA3dCmdDXBeginQuery *pCmd = (SVGA3dCmdDXBeginQuery *)pvCmd;
5366 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5367 rcParse = vmsvga3dCmdDXBeginQuery(pThisCC, idDXContext, pCmd, cbCmd);
5368 break;
5369 }
5370
5371 case SVGA_3D_CMD_DX_END_QUERY:
5372 {
5373 SVGA3dCmdDXEndQuery *pCmd = (SVGA3dCmdDXEndQuery *)pvCmd;
5374 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5375 rcParse = vmsvga3dCmdDXEndQuery(pThisCC, idDXContext, pCmd, cbCmd);
5376 break;
5377 }
5378
5379 case SVGA_3D_CMD_DX_READBACK_QUERY:
5380 {
5381 SVGA3dCmdDXReadbackQuery *pCmd = (SVGA3dCmdDXReadbackQuery *)pvCmd;
5382 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5383 rcParse = vmsvga3dCmdDXReadbackQuery(pThisCC, idDXContext, pCmd, cbCmd);
5384 break;
5385 }
5386
5387 case SVGA_3D_CMD_DX_SET_PREDICATION:
5388 {
5389 SVGA3dCmdDXSetPredication *pCmd = (SVGA3dCmdDXSetPredication *)pvCmd;
5390 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5391 rcParse = vmsvga3dCmdDXSetPredication(pThisCC, idDXContext, pCmd, cbCmd);
5392 break;
5393 }
5394
5395 case SVGA_3D_CMD_DX_SET_SOTARGETS:
5396 {
5397 SVGA3dCmdDXSetSOTargets *pCmd = (SVGA3dCmdDXSetSOTargets *)pvCmd;
5398 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5399 rcParse = vmsvga3dCmdDXSetSOTargets(pThisCC, idDXContext, pCmd, cbCmd);
5400 break;
5401 }
5402
5403 case SVGA_3D_CMD_DX_SET_VIEWPORTS:
5404 {
5405 SVGA3dCmdDXSetViewports *pCmd = (SVGA3dCmdDXSetViewports *)pvCmd;
5406 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5407 rcParse = vmsvga3dCmdDXSetViewports(pThisCC, idDXContext, pCmd, cbCmd);
5408 break;
5409 }
5410
5411 case SVGA_3D_CMD_DX_SET_SCISSORRECTS:
5412 {
5413 SVGA3dCmdDXSetScissorRects *pCmd = (SVGA3dCmdDXSetScissorRects *)pvCmd;
5414 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5415 rcParse = vmsvga3dCmdDXSetScissorRects(pThisCC, idDXContext, pCmd, cbCmd);
5416 break;
5417 }
5418
5419 case SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW:
5420 {
5421 SVGA3dCmdDXClearRenderTargetView *pCmd = (SVGA3dCmdDXClearRenderTargetView *)pvCmd;
5422 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5423 rcParse = vmsvga3dCmdDXClearRenderTargetView(pThisCC, idDXContext, pCmd, cbCmd);
5424 break;
5425 }
5426
5427 case SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW:
5428 {
5429 SVGA3dCmdDXClearDepthStencilView *pCmd = (SVGA3dCmdDXClearDepthStencilView *)pvCmd;
5430 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5431 rcParse = vmsvga3dCmdDXClearDepthStencilView(pThisCC, idDXContext, pCmd, cbCmd);
5432 break;
5433 }
5434
5435 case SVGA_3D_CMD_DX_PRED_COPY_REGION:
5436 {
5437 SVGA3dCmdDXPredCopyRegion *pCmd = (SVGA3dCmdDXPredCopyRegion *)pvCmd;
5438 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5439 rcParse = vmsvga3dCmdDXPredCopyRegion(pThisCC, idDXContext, pCmd, cbCmd);
5440 break;
5441 }
5442
5443 case SVGA_3D_CMD_DX_PRED_COPY:
5444 {
5445 SVGA3dCmdDXPredCopy *pCmd = (SVGA3dCmdDXPredCopy *)pvCmd;
5446 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5447 rcParse = vmsvga3dCmdDXPredCopy(pThisCC, idDXContext, pCmd, cbCmd);
5448 break;
5449 }
5450
5451 case SVGA_3D_CMD_DX_PRESENTBLT:
5452 {
5453 SVGA3dCmdDXPresentBlt *pCmd = (SVGA3dCmdDXPresentBlt *)pvCmd;
5454 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5455 rcParse = vmsvga3dCmdDXPresentBlt(pThisCC, idDXContext, pCmd, cbCmd);
5456 break;
5457 }
5458
5459 case SVGA_3D_CMD_DX_GENMIPS:
5460 {
5461 SVGA3dCmdDXGenMips *pCmd = (SVGA3dCmdDXGenMips *)pvCmd;
5462 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5463 rcParse = vmsvga3dCmdDXGenMips(pThisCC, idDXContext, pCmd, cbCmd);
5464 break;
5465 }
5466
5467 case SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE:
5468 {
5469 SVGA3dCmdDXUpdateSubResource *pCmd = (SVGA3dCmdDXUpdateSubResource *)pvCmd;
5470 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5471 rcParse = vmsvga3dCmdDXUpdateSubResource(pThisCC, pCmd, cbCmd);
5472 break;
5473 }
5474
5475 case SVGA_3D_CMD_DX_READBACK_SUBRESOURCE:
5476 {
5477 SVGA3dCmdDXReadbackSubResource *pCmd = (SVGA3dCmdDXReadbackSubResource *)pvCmd;
5478 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5479 rcParse = vmsvga3dCmdDXReadbackSubResource(pThisCC, pCmd, cbCmd);
5480 break;
5481 }
5482
5483 case SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE:
5484 {
5485 SVGA3dCmdDXInvalidateSubResource *pCmd = (SVGA3dCmdDXInvalidateSubResource *)pvCmd;
5486 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5487 rcParse = vmsvga3dCmdDXInvalidateSubResource(pThisCC, pCmd, cbCmd);
5488 break;
5489 }
5490
5491 case SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW:
5492 {
5493 SVGA3dCmdDXDefineShaderResourceView *pCmd = (SVGA3dCmdDXDefineShaderResourceView *)pvCmd;
5494 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5495 rcParse = vmsvga3dCmdDXDefineShaderResourceView(pThisCC, idDXContext, pCmd, cbCmd);
5496 break;
5497 }
5498
5499 case SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW:
5500 {
5501 SVGA3dCmdDXDestroyShaderResourceView *pCmd = (SVGA3dCmdDXDestroyShaderResourceView *)pvCmd;
5502 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5503 rcParse = vmsvga3dCmdDXDestroyShaderResourceView(pThisCC, idDXContext, pCmd, cbCmd);
5504 break;
5505 }
5506
5507 case SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW:
5508 {
5509 SVGA3dCmdDXDefineRenderTargetView *pCmd = (SVGA3dCmdDXDefineRenderTargetView *)pvCmd;
5510 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5511 rcParse = vmsvga3dCmdDXDefineRenderTargetView(pThisCC, idDXContext, pCmd, cbCmd);
5512 break;
5513 }
5514
5515 case SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW:
5516 {
5517 SVGA3dCmdDXDestroyRenderTargetView *pCmd = (SVGA3dCmdDXDestroyRenderTargetView *)pvCmd;
5518 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5519 rcParse = vmsvga3dCmdDXDestroyRenderTargetView(pThisCC, idDXContext, pCmd, cbCmd);
5520 break;
5521 }
5522
5523 case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW:
5524 {
5525 SVGA3dCmdDXDefineDepthStencilView *pCmd = (SVGA3dCmdDXDefineDepthStencilView *)pvCmd;
5526 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5527 rcParse = vmsvga3dCmdDXDefineDepthStencilView(pThisCC, idDXContext, pCmd, cbCmd);
5528 break;
5529 }
5530
5531 case SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW:
5532 {
5533 SVGA3dCmdDXDestroyDepthStencilView *pCmd = (SVGA3dCmdDXDestroyDepthStencilView *)pvCmd;
5534 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5535 rcParse = vmsvga3dCmdDXDestroyDepthStencilView(pThisCC, idDXContext, pCmd, cbCmd);
5536 break;
5537 }
5538
5539 case SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT:
5540 {
5541 SVGA3dCmdDXDefineElementLayout *pCmd = (SVGA3dCmdDXDefineElementLayout *)pvCmd;
5542 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5543 rcParse = vmsvga3dCmdDXDefineElementLayout(pThisCC, idDXContext, pCmd, cbCmd);
5544 break;
5545 }
5546
5547 case SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT:
5548 {
5549 SVGA3dCmdDXDestroyElementLayout *pCmd = (SVGA3dCmdDXDestroyElementLayout *)pvCmd;
5550 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5551 rcParse = vmsvga3dCmdDXDestroyElementLayout(pThisCC, idDXContext, pCmd, cbCmd);
5552 break;
5553 }
5554
5555 case SVGA_3D_CMD_DX_DEFINE_BLEND_STATE:
5556 {
5557 SVGA3dCmdDXDefineBlendState *pCmd = (SVGA3dCmdDXDefineBlendState *)pvCmd;
5558 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5559 rcParse = vmsvga3dCmdDXDefineBlendState(pThisCC, idDXContext, pCmd, cbCmd);
5560 break;
5561 }
5562
5563 case SVGA_3D_CMD_DX_DESTROY_BLEND_STATE:
5564 {
5565 SVGA3dCmdDXDestroyBlendState *pCmd = (SVGA3dCmdDXDestroyBlendState *)pvCmd;
5566 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5567 rcParse = vmsvga3dCmdDXDestroyBlendState(pThisCC, idDXContext, pCmd, cbCmd);
5568 break;
5569 }
5570
5571 case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE:
5572 {
5573 SVGA3dCmdDXDefineDepthStencilState *pCmd = (SVGA3dCmdDXDefineDepthStencilState *)pvCmd;
5574 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5575 rcParse = vmsvga3dCmdDXDefineDepthStencilState(pThisCC, idDXContext, pCmd, cbCmd);
5576 break;
5577 }
5578
5579 case SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE:
5580 {
5581 SVGA3dCmdDXDestroyDepthStencilState *pCmd = (SVGA3dCmdDXDestroyDepthStencilState *)pvCmd;
5582 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5583 rcParse = vmsvga3dCmdDXDestroyDepthStencilState(pThisCC, idDXContext, pCmd, cbCmd);
5584 break;
5585 }
5586
5587 case SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE:
5588 {
5589 SVGA3dCmdDXDefineRasterizerState *pCmd = (SVGA3dCmdDXDefineRasterizerState *)pvCmd;
5590 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5591 rcParse = vmsvga3dCmdDXDefineRasterizerState(pThisCC, idDXContext, pCmd, cbCmd);
5592 break;
5593 }
5594
5595 case SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE:
5596 {
5597 SVGA3dCmdDXDestroyRasterizerState *pCmd = (SVGA3dCmdDXDestroyRasterizerState *)pvCmd;
5598 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5599 rcParse = vmsvga3dCmdDXDestroyRasterizerState(pThisCC, idDXContext, pCmd, cbCmd);
5600 break;
5601 }
5602
5603 case SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE:
5604 {
5605 SVGA3dCmdDXDefineSamplerState *pCmd = (SVGA3dCmdDXDefineSamplerState *)pvCmd;
5606 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5607 rcParse = vmsvga3dCmdDXDefineSamplerState(pThisCC, idDXContext, pCmd, cbCmd);
5608 break;
5609 }
5610
5611 case SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE:
5612 {
5613 SVGA3dCmdDXDestroySamplerState *pCmd = (SVGA3dCmdDXDestroySamplerState *)pvCmd;
5614 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5615 rcParse = vmsvga3dCmdDXDestroySamplerState(pThisCC, idDXContext, pCmd, cbCmd);
5616 break;
5617 }
5618
5619 case SVGA_3D_CMD_DX_DEFINE_SHADER:
5620 {
5621 SVGA3dCmdDXDefineShader *pCmd = (SVGA3dCmdDXDefineShader *)pvCmd;
5622 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5623 rcParse = vmsvga3dCmdDXDefineShader(pThisCC, idDXContext, pCmd, cbCmd);
5624 break;
5625 }
5626
5627 case SVGA_3D_CMD_DX_DESTROY_SHADER:
5628 {
5629 SVGA3dCmdDXDestroyShader *pCmd = (SVGA3dCmdDXDestroyShader *)pvCmd;
5630 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5631 rcParse = vmsvga3dCmdDXDestroyShader(pThisCC, idDXContext, pCmd, cbCmd);
5632 break;
5633 }
5634
5635 case SVGA_3D_CMD_DX_BIND_SHADER:
5636 {
5637 SVGA3dCmdDXBindShader *pCmd = (SVGA3dCmdDXBindShader *)pvCmd;
5638 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5639 rcParse = vmsvga3dCmdDXBindShader(pThisCC, idDXContext, pCmd, cbCmd);
5640 break;
5641 }
5642
5643 case SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT:
5644 {
5645 SVGA3dCmdDXDefineStreamOutput *pCmd = (SVGA3dCmdDXDefineStreamOutput *)pvCmd;
5646 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5647 rcParse = vmsvga3dCmdDXDefineStreamOutput(pThisCC, idDXContext, pCmd, cbCmd);
5648 break;
5649 }
5650
5651 case SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT:
5652 {
5653 SVGA3dCmdDXDestroyStreamOutput *pCmd = (SVGA3dCmdDXDestroyStreamOutput *)pvCmd;
5654 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5655 rcParse = vmsvga3dCmdDXDestroyStreamOutput(pThisCC, idDXContext, pCmd, cbCmd);
5656 break;
5657 }
5658
5659 case SVGA_3D_CMD_DX_SET_STREAMOUTPUT:
5660 {
5661 SVGA3dCmdDXSetStreamOutput *pCmd = (SVGA3dCmdDXSetStreamOutput *)pvCmd;
5662 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5663 rcParse = vmsvga3dCmdDXSetStreamOutput(pThisCC, idDXContext, pCmd, cbCmd);
5664 break;
5665 }
5666
5667 case SVGA_3D_CMD_DX_SET_COTABLE:
5668 {
5669 SVGA3dCmdDXSetCOTable *pCmd = (SVGA3dCmdDXSetCOTable *)pvCmd;
5670 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5671 rcParse = vmsvga3dCmdDXSetCOTable(pThisCC, pCmd, cbCmd);
5672 break;
5673 }
5674
5675 case SVGA_3D_CMD_DX_READBACK_COTABLE:
5676 {
5677 SVGA3dCmdDXReadbackCOTable *pCmd = (SVGA3dCmdDXReadbackCOTable *)pvCmd;
5678 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5679 rcParse = vmsvga3dCmdDXReadbackCOTable(pThisCC, idDXContext, pCmd, cbCmd);
5680 break;
5681 }
5682
5683 case SVGA_3D_CMD_DX_BUFFER_COPY:
5684 {
5685 SVGA3dCmdDXBufferCopy *pCmd = (SVGA3dCmdDXBufferCopy *)pvCmd;
5686 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5687 rcParse = vmsvga3dCmdDXBufferCopy(pThisCC, idDXContext, pCmd, cbCmd);
5688 break;
5689 }
5690
5691 case SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER:
5692 {
5693 SVGA3dCmdDXTransferFromBuffer *pCmd = (SVGA3dCmdDXTransferFromBuffer *)pvCmd;
5694 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5695 rcParse = vmsvga3dCmdDXTransferFromBuffer(pThisCC, pCmd, cbCmd);
5696 break;
5697 }
5698
5699 case SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK:
5700 {
5701 SVGA3dCmdDXSurfaceCopyAndReadback *pCmd = (SVGA3dCmdDXSurfaceCopyAndReadback *)pvCmd;
5702 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5703 rcParse = vmsvga3dCmdDXSurfaceCopyAndReadback(pThisCC, idDXContext, pCmd, cbCmd);
5704 break;
5705 }
5706
5707 case SVGA_3D_CMD_DX_MOVE_QUERY:
5708 {
5709 SVGA3dCmdDXMoveQuery *pCmd = (SVGA3dCmdDXMoveQuery *)pvCmd;
5710 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5711 rcParse = vmsvga3dCmdDXMoveQuery(pThisCC, idDXContext, pCmd, cbCmd);
5712 break;
5713 }
5714
5715 case SVGA_3D_CMD_DX_BIND_ALL_QUERY:
5716 {
5717 SVGA3dCmdDXBindAllQuery *pCmd = (SVGA3dCmdDXBindAllQuery *)pvCmd;
5718 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5719 rcParse = vmsvga3dCmdDXBindAllQuery(pThisCC, idDXContext, pCmd, cbCmd);
5720 break;
5721 }
5722
5723 case SVGA_3D_CMD_DX_READBACK_ALL_QUERY:
5724 {
5725 SVGA3dCmdDXReadbackAllQuery *pCmd = (SVGA3dCmdDXReadbackAllQuery *)pvCmd;
5726 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5727 rcParse = vmsvga3dCmdDXReadbackAllQuery(pThisCC, idDXContext, pCmd, cbCmd);
5728 break;
5729 }
5730
5731 case SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER:
5732 {
5733 SVGA3dCmdDXPredTransferFromBuffer *pCmd = (SVGA3dCmdDXPredTransferFromBuffer *)pvCmd;
5734 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5735 rcParse = vmsvga3dCmdDXPredTransferFromBuffer(pThisCC, idDXContext, pCmd, cbCmd);
5736 break;
5737 }
5738
5739 case SVGA_3D_CMD_DX_MOB_FENCE_64:
5740 {
5741 SVGA3dCmdDXMobFence64 *pCmd = (SVGA3dCmdDXMobFence64 *)pvCmd;
5742 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5743 rcParse = vmsvga3dCmdDXMobFence64(pThisCC, pCmd, cbCmd);
5744 break;
5745 }
5746
5747 case SVGA_3D_CMD_DX_BIND_ALL_SHADER:
5748 {
5749 SVGA3dCmdDXBindAllShader *pCmd = (SVGA3dCmdDXBindAllShader *)pvCmd;
5750 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5751 rcParse = vmsvga3dCmdDXBindAllShader(pThisCC, idDXContext, pCmd, cbCmd);
5752 break;
5753 }
5754
5755 case SVGA_3D_CMD_DX_HINT:
5756 {
5757 SVGA3dCmdDXHint *pCmd = (SVGA3dCmdDXHint *)pvCmd;
5758 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5759 rcParse = vmsvga3dCmdDXHint(pThisCC, idDXContext, pCmd, cbCmd);
5760 break;
5761 }
5762
5763 case SVGA_3D_CMD_DX_BUFFER_UPDATE:
5764 {
5765 SVGA3dCmdDXBufferUpdate *pCmd = (SVGA3dCmdDXBufferUpdate *)pvCmd;
5766 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5767 rcParse = vmsvga3dCmdDXBufferUpdate(pThisCC, idDXContext, pCmd, cbCmd);
5768 break;
5769 }
5770
5771 case SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET:
5772 {
5773 SVGA3dCmdDXSetVSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetVSConstantBufferOffset *)pvCmd;
5774 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5775 rcParse = vmsvga3dCmdDXSetVSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5776 break;
5777 }
5778
5779 case SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET:
5780 {
5781 SVGA3dCmdDXSetPSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetPSConstantBufferOffset *)pvCmd;
5782 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5783 rcParse = vmsvga3dCmdDXSetPSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5784 break;
5785 }
5786
5787 case SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET:
5788 {
5789 SVGA3dCmdDXSetGSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetGSConstantBufferOffset *)pvCmd;
5790 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5791 rcParse = vmsvga3dCmdDXSetGSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5792 break;
5793 }
5794
5795 case SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET:
5796 {
5797 SVGA3dCmdDXSetHSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetHSConstantBufferOffset *)pvCmd;
5798 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5799 rcParse = vmsvga3dCmdDXSetHSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5800 break;
5801 }
5802
5803 case SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET:
5804 {
5805 SVGA3dCmdDXSetDSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetDSConstantBufferOffset *)pvCmd;
5806 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5807 rcParse = vmsvga3dCmdDXSetDSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5808 break;
5809 }
5810
5811 case SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET:
5812 {
5813 SVGA3dCmdDXSetCSConstantBufferOffset *pCmd = (SVGA3dCmdDXSetCSConstantBufferOffset *)pvCmd;
5814 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5815 rcParse = vmsvga3dCmdDXSetCSConstantBufferOffset(pThisCC, idDXContext, pCmd, cbCmd);
5816 break;
5817 }
5818
5819 case SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER:
5820 {
5821 SVGA3dCmdDXCondBindAllShader *pCmd = (SVGA3dCmdDXCondBindAllShader *)pvCmd;
5822 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5823 rcParse = vmsvga3dCmdDXCondBindAllShader(pThisCC, idDXContext, pCmd, cbCmd);
5824 break;
5825 }
5826
5827 case SVGA_3D_CMD_SCREEN_COPY:
5828 {
5829 SVGA3dCmdScreenCopy *pCmd = (SVGA3dCmdScreenCopy *)pvCmd;
5830 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5831 rcParse = vmsvga3dCmdScreenCopy(pThisCC, idDXContext, pCmd, cbCmd);
5832 break;
5833 }
5834
5835 case SVGA_3D_CMD_RESERVED1:
5836 {
5837 VMSVGA_3D_CMD_NOTIMPL();
5838 break;
5839 }
5840
5841 case SVGA_3D_CMD_RESERVED2:
5842 {
5843 VMSVGA_3D_CMD_NOTIMPL();
5844 break;
5845 }
5846
5847 case SVGA_3D_CMD_RESERVED3:
5848 {
5849 VMSVGA_3D_CMD_NOTIMPL();
5850 break;
5851 }
5852
5853 case SVGA_3D_CMD_RESERVED4:
5854 {
5855 VMSVGA_3D_CMD_NOTIMPL();
5856 break;
5857 }
5858
5859 case SVGA_3D_CMD_RESERVED5:
5860 {
5861 VMSVGA_3D_CMD_NOTIMPL();
5862 break;
5863 }
5864
5865 case SVGA_3D_CMD_RESERVED6:
5866 {
5867 VMSVGA_3D_CMD_NOTIMPL();
5868 break;
5869 }
5870
5871 case SVGA_3D_CMD_RESERVED7:
5872 {
5873 VMSVGA_3D_CMD_NOTIMPL();
5874 break;
5875 }
5876
5877 case SVGA_3D_CMD_RESERVED8:
5878 {
5879 VMSVGA_3D_CMD_NOTIMPL();
5880 break;
5881 }
5882
5883 case SVGA_3D_CMD_GROW_OTABLE:
5884 {
5885 SVGA3dCmdGrowOTable *pCmd = (SVGA3dCmdGrowOTable *)pvCmd;
5886 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5887 rcParse = vmsvga3dCmdGrowOTable(pThisCC, pCmd, cbCmd);
5888 break;
5889 }
5890
5891 case SVGA_3D_CMD_DX_GROW_COTABLE:
5892 {
5893 SVGA3dCmdDXGrowCOTable *pCmd = (SVGA3dCmdDXGrowCOTable *)pvCmd;
5894 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5895 rcParse = vmsvga3dCmdDXGrowCOTable(pThisCC, pCmd, cbCmd);
5896 break;
5897 }
5898
5899 case SVGA_3D_CMD_INTRA_SURFACE_COPY:
5900 {
5901 SVGA3dCmdIntraSurfaceCopy *pCmd = (SVGA3dCmdIntraSurfaceCopy *)pvCmd;
5902 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5903 rcParse = vmsvga3dCmdIntraSurfaceCopy(pThisCC, idDXContext, pCmd, cbCmd);
5904 break;
5905 }
5906
5907 case SVGA_3D_CMD_DEFINE_GB_SURFACE_V3:
5908 {
5909 SVGA3dCmdDefineGBSurface_v3 *pCmd = (SVGA3dCmdDefineGBSurface_v3 *)pvCmd;
5910 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5911 rcParse = vmsvga3dCmdDefineGBSurface_v3(pThisCC, pCmd);
5912 break;
5913 }
5914
5915 case SVGA_3D_CMD_DX_RESOLVE_COPY:
5916 {
5917 SVGA3dCmdDXResolveCopy *pCmd = (SVGA3dCmdDXResolveCopy *)pvCmd;
5918 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5919 rcParse = vmsvga3dCmdDXResolveCopy(pThisCC, idDXContext, pCmd, cbCmd);
5920 break;
5921 }
5922
5923 case SVGA_3D_CMD_DX_PRED_RESOLVE_COPY:
5924 {
5925 SVGA3dCmdDXPredResolveCopy *pCmd = (SVGA3dCmdDXPredResolveCopy *)pvCmd;
5926 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5927 rcParse = vmsvga3dCmdDXPredResolveCopy(pThisCC, idDXContext, pCmd, cbCmd);
5928 break;
5929 }
5930
5931 case SVGA_3D_CMD_DX_PRED_CONVERT_REGION:
5932 {
5933 SVGA3dCmdDXPredConvertRegion *pCmd = (SVGA3dCmdDXPredConvertRegion *)pvCmd;
5934 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5935 rcParse = vmsvga3dCmdDXPredConvertRegion(pThisCC, idDXContext, pCmd, cbCmd);
5936 break;
5937 }
5938
5939 case SVGA_3D_CMD_DX_PRED_CONVERT:
5940 {
5941 SVGA3dCmdDXPredConvert *pCmd = (SVGA3dCmdDXPredConvert *)pvCmd;
5942 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5943 rcParse = vmsvga3dCmdDXPredConvert(pThisCC, idDXContext, pCmd, cbCmd);
5944 break;
5945 }
5946
5947 case SVGA_3D_CMD_WHOLE_SURFACE_COPY:
5948 {
5949 SVGA3dCmdWholeSurfaceCopy *pCmd = (SVGA3dCmdWholeSurfaceCopy *)pvCmd;
5950 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5951 rcParse = vmsvga3dCmdWholeSurfaceCopy(pThisCC, idDXContext, pCmd, cbCmd);
5952 break;
5953 }
5954
5955 case SVGA_3D_CMD_DX_DEFINE_UA_VIEW:
5956 {
5957 SVGA3dCmdDXDefineUAView *pCmd = (SVGA3dCmdDXDefineUAView *)pvCmd;
5958 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5959 rcParse = vmsvga3dCmdDXDefineUAView(pThisCC, idDXContext, pCmd, cbCmd);
5960 break;
5961 }
5962
5963 case SVGA_3D_CMD_DX_DESTROY_UA_VIEW:
5964 {
5965 SVGA3dCmdDXDestroyUAView *pCmd = (SVGA3dCmdDXDestroyUAView *)pvCmd;
5966 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5967 rcParse = vmsvga3dCmdDXDestroyUAView(pThisCC, idDXContext, pCmd, cbCmd);
5968 break;
5969 }
5970
5971 case SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT:
5972 {
5973 SVGA3dCmdDXClearUAViewUint *pCmd = (SVGA3dCmdDXClearUAViewUint *)pvCmd;
5974 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5975 rcParse = vmsvga3dCmdDXClearUAViewUint(pThisCC, idDXContext, pCmd, cbCmd);
5976 break;
5977 }
5978
5979 case SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT:
5980 {
5981 SVGA3dCmdDXClearUAViewFloat *pCmd = (SVGA3dCmdDXClearUAViewFloat *)pvCmd;
5982 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5983 rcParse = vmsvga3dCmdDXClearUAViewFloat(pThisCC, idDXContext, pCmd, cbCmd);
5984 break;
5985 }
5986
5987 case SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT:
5988 {
5989 SVGA3dCmdDXCopyStructureCount *pCmd = (SVGA3dCmdDXCopyStructureCount *)pvCmd;
5990 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5991 rcParse = vmsvga3dCmdDXCopyStructureCount(pThisCC, idDXContext, pCmd, cbCmd);
5992 break;
5993 }
5994
5995 case SVGA_3D_CMD_DX_SET_UA_VIEWS:
5996 {
5997 SVGA3dCmdDXSetUAViews *pCmd = (SVGA3dCmdDXSetUAViews *)pvCmd;
5998 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
5999 rcParse = vmsvga3dCmdDXSetUAViews(pThisCC, idDXContext, pCmd, cbCmd);
6000 break;
6001 }
6002
6003 case SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT:
6004 {
6005 SVGA3dCmdDXDrawIndexedInstancedIndirect *pCmd = (SVGA3dCmdDXDrawIndexedInstancedIndirect *)pvCmd;
6006 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6007 rcParse = vmsvga3dCmdDXDrawIndexedInstancedIndirect(pThisCC, idDXContext, pCmd, cbCmd);
6008 break;
6009 }
6010
6011 case SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT:
6012 {
6013 SVGA3dCmdDXDrawInstancedIndirect *pCmd = (SVGA3dCmdDXDrawInstancedIndirect *)pvCmd;
6014 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6015 rcParse = vmsvga3dCmdDXDrawInstancedIndirect(pThisCC, idDXContext, pCmd, cbCmd);
6016 break;
6017 }
6018
6019 case SVGA_3D_CMD_DX_DISPATCH:
6020 {
6021 SVGA3dCmdDXDispatch *pCmd = (SVGA3dCmdDXDispatch *)pvCmd;
6022 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6023 rcParse = vmsvga3dCmdDXDispatch(pThisCC, idDXContext, pCmd, cbCmd);
6024 break;
6025 }
6026
6027 case SVGA_3D_CMD_DX_DISPATCH_INDIRECT:
6028 {
6029 SVGA3dCmdDXDispatchIndirect *pCmd = (SVGA3dCmdDXDispatchIndirect *)pvCmd;
6030 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6031 rcParse = vmsvga3dCmdDXDispatchIndirect(pThisCC, idDXContext, pCmd, cbCmd);
6032 break;
6033 }
6034
6035 case SVGA_3D_CMD_WRITE_ZERO_SURFACE:
6036 {
6037 SVGA3dCmdWriteZeroSurface *pCmd = (SVGA3dCmdWriteZeroSurface *)pvCmd;
6038 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6039 rcParse = vmsvga3dCmdWriteZeroSurface(pThisCC, idDXContext, pCmd, cbCmd);
6040 break;
6041 }
6042
6043 case SVGA_3D_CMD_HINT_ZERO_SURFACE:
6044 {
6045 SVGA3dCmdHintZeroSurface *pCmd = (SVGA3dCmdHintZeroSurface *)pvCmd;
6046 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6047 rcParse = vmsvga3dCmdHintZeroSurface(pThisCC, idDXContext, pCmd, cbCmd);
6048 break;
6049 }
6050
6051 case SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER:
6052 {
6053 SVGA3dCmdDXTransferToBuffer *pCmd = (SVGA3dCmdDXTransferToBuffer *)pvCmd;
6054 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6055 rcParse = vmsvga3dCmdDXTransferToBuffer(pThisCC, idDXContext, pCmd, cbCmd);
6056 break;
6057 }
6058
6059 case SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT:
6060 {
6061 SVGA3dCmdDXSetStructureCount *pCmd = (SVGA3dCmdDXSetStructureCount *)pvCmd;
6062 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6063 rcParse = vmsvga3dCmdDXSetStructureCount(pThisCC, idDXContext, pCmd, cbCmd);
6064 break;
6065 }
6066
6067 case SVGA_3D_CMD_LOGICOPS_BITBLT:
6068 {
6069 SVGA3dCmdLogicOpsBitBlt *pCmd = (SVGA3dCmdLogicOpsBitBlt *)pvCmd;
6070 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6071 rcParse = vmsvga3dCmdLogicOpsBitBlt(pThisCC, idDXContext, pCmd, cbCmd);
6072 break;
6073 }
6074
6075 case SVGA_3D_CMD_LOGICOPS_TRANSBLT:
6076 {
6077 SVGA3dCmdLogicOpsTransBlt *pCmd = (SVGA3dCmdLogicOpsTransBlt *)pvCmd;
6078 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6079 rcParse = vmsvga3dCmdLogicOpsTransBlt(pThisCC, idDXContext, pCmd, cbCmd);
6080 break;
6081 }
6082
6083 case SVGA_3D_CMD_LOGICOPS_STRETCHBLT:
6084 {
6085 SVGA3dCmdLogicOpsStretchBlt *pCmd = (SVGA3dCmdLogicOpsStretchBlt *)pvCmd;
6086 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6087 rcParse = vmsvga3dCmdLogicOpsStretchBlt(pThisCC, idDXContext, pCmd, cbCmd);
6088 break;
6089 }
6090
6091 case SVGA_3D_CMD_LOGICOPS_COLORFILL:
6092 {
6093 SVGA3dCmdLogicOpsColorFill *pCmd = (SVGA3dCmdLogicOpsColorFill *)pvCmd;
6094 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6095 rcParse = vmsvga3dCmdLogicOpsColorFill(pThisCC, idDXContext, pCmd, cbCmd);
6096 break;
6097 }
6098
6099 case SVGA_3D_CMD_LOGICOPS_ALPHABLEND:
6100 {
6101 SVGA3dCmdLogicOpsAlphaBlend *pCmd = (SVGA3dCmdLogicOpsAlphaBlend *)pvCmd;
6102 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6103 rcParse = vmsvga3dCmdLogicOpsAlphaBlend(pThisCC, idDXContext, pCmd, cbCmd);
6104 break;
6105 }
6106
6107 case SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND:
6108 {
6109 SVGA3dCmdLogicOpsClearTypeBlend *pCmd = (SVGA3dCmdLogicOpsClearTypeBlend *)pvCmd;
6110 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6111 rcParse = vmsvga3dCmdLogicOpsClearTypeBlend(pThisCC, idDXContext, pCmd, cbCmd);
6112 break;
6113 }
6114
6115 case SVGA_3D_CMD_RESERVED2_1:
6116 {
6117 VMSVGA_3D_CMD_NOTIMPL();
6118 break;
6119 }
6120
6121 case SVGA_3D_CMD_RESERVED2_2:
6122 {
6123 VMSVGA_3D_CMD_NOTIMPL();
6124 break;
6125 }
6126
6127 case SVGA_3D_CMD_DEFINE_GB_SURFACE_V4:
6128 {
6129 SVGA3dCmdDefineGBSurface_v4 *pCmd = (SVGA3dCmdDefineGBSurface_v4 *)pvCmd;
6130 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6131 rcParse = vmsvga3dCmdDefineGBSurface_v4(pThisCC, pCmd);
6132 break;
6133 }
6134
6135 case SVGA_3D_CMD_DX_SET_CS_UA_VIEWS:
6136 {
6137 SVGA3dCmdDXSetCSUAViews *pCmd = (SVGA3dCmdDXSetCSUAViews *)pvCmd;
6138 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6139 rcParse = vmsvga3dCmdDXSetCSUAViews(pThisCC, idDXContext, pCmd, cbCmd);
6140 break;
6141 }
6142
6143 case SVGA_3D_CMD_DX_SET_MIN_LOD:
6144 {
6145 SVGA3dCmdDXSetMinLOD *pCmd = (SVGA3dCmdDXSetMinLOD *)pvCmd;
6146 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6147 rcParse = vmsvga3dCmdDXSetMinLOD(pThisCC, idDXContext, pCmd, cbCmd);
6148 break;
6149 }
6150
6151 case SVGA_3D_CMD_RESERVED2_3:
6152 {
6153 VMSVGA_3D_CMD_NOTIMPL();
6154 break;
6155 }
6156
6157 case SVGA_3D_CMD_RESERVED2_4:
6158 {
6159 VMSVGA_3D_CMD_NOTIMPL();
6160 break;
6161 }
6162
6163 case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2:
6164 {
6165 SVGA3dCmdDXDefineDepthStencilView_v2 *pCmd = (SVGA3dCmdDXDefineDepthStencilView_v2 *)pvCmd;
6166 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6167 rcParse = vmsvga3dCmdDXDefineDepthStencilView_v2(pThisCC, idDXContext, pCmd, cbCmd);
6168 break;
6169 }
6170
6171 case SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB:
6172 {
6173 SVGA3dCmdDXDefineStreamOutputWithMob *pCmd = (SVGA3dCmdDXDefineStreamOutputWithMob *)pvCmd;
6174 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6175 rcParse = vmsvga3dCmdDXDefineStreamOutputWithMob(pThisCC, idDXContext, pCmd, cbCmd);
6176 break;
6177 }
6178
6179 case SVGA_3D_CMD_DX_SET_SHADER_IFACE:
6180 {
6181 SVGA3dCmdDXSetShaderIface *pCmd = (SVGA3dCmdDXSetShaderIface *)pvCmd;
6182 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6183 rcParse = vmsvga3dCmdDXSetShaderIface(pThisCC, idDXContext, pCmd, cbCmd);
6184 break;
6185 }
6186
6187 case SVGA_3D_CMD_DX_BIND_STREAMOUTPUT:
6188 {
6189 SVGA3dCmdDXBindStreamOutput *pCmd = (SVGA3dCmdDXBindStreamOutput *)pvCmd;
6190 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6191 rcParse = vmsvga3dCmdDXBindStreamOutput(pThisCC, idDXContext, pCmd, cbCmd);
6192 break;
6193 }
6194
6195 case SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS:
6196 {
6197 SVGA3dCmdSurfaceStretchBltNonMSToMS *pCmd = (SVGA3dCmdSurfaceStretchBltNonMSToMS *)pvCmd;
6198 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6199 rcParse = vmsvga3dCmdSurfaceStretchBltNonMSToMS(pThisCC, idDXContext, pCmd, cbCmd);
6200 break;
6201 }
6202
6203 case SVGA_3D_CMD_DX_BIND_SHADER_IFACE:
6204 {
6205 SVGA3dCmdDXBindShaderIface *pCmd = (SVGA3dCmdDXBindShaderIface *)pvCmd;
6206 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6207 rcParse = vmsvga3dCmdDXBindShaderIface(pThisCC, idDXContext, pCmd, cbCmd);
6208 break;
6209 }
6210
6211 case SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION:
6212 {
6213 SVGA3dCmdVBDXClearRenderTargetViewRegion *pCmd = (SVGA3dCmdVBDXClearRenderTargetViewRegion *)pvCmd;
6214 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
6215 rcParse = vmsvga3dCmdVBDXClearRenderTargetViewRegion(pThisCC, idDXContext, pCmd, cbCmd);
6216 break;
6217 }
6218
6219 /* Unsupported commands. */
6220 case SVGA_3D_CMD_DEAD4: /* SVGA_3D_CMD_VIDEO_CREATE_DECODER */
6221 case SVGA_3D_CMD_DEAD5: /* SVGA_3D_CMD_VIDEO_DESTROY_DECODER */
6222 case SVGA_3D_CMD_DEAD6: /* SVGA_3D_CMD_VIDEO_CREATE_PROCESSOR */
6223 case SVGA_3D_CMD_DEAD7: /* SVGA_3D_CMD_VIDEO_DESTROY_PROCESSOR */
6224 case SVGA_3D_CMD_DEAD8: /* SVGA_3D_CMD_VIDEO_DECODE_START_FRAME */
6225 case SVGA_3D_CMD_DEAD9: /* SVGA_3D_CMD_VIDEO_DECODE_RENDER */
6226 case SVGA_3D_CMD_DEAD10: /* SVGA_3D_CMD_VIDEO_DECODE_END_FRAME */
6227 case SVGA_3D_CMD_DEAD11: /* SVGA_3D_CMD_VIDEO_PROCESS_FRAME */
6228 /* Prevent the compiler warning. */
6229 case SVGA_3D_CMD_LEGACY_BASE:
6230 case SVGA_3D_CMD_MAX:
6231 case SVGA_3D_CMD_FUTURE_MAX:
6232 /* No 'default' case */
6233 STAM_REL_COUNTER_INC(&pSvgaR3State->StatFifoUnkCmds);
6234 ASSERT_GUEST_MSG_FAILED(("enmCmdId=%d\n", enmCmdId));
6235 LogRelMax(16, ("VMSVGA: unsupported 3D command %d\n", enmCmdId));
6236 rcParse = VERR_NOT_IMPLEMENTED;
6237 break;
6238 }
6239
6240 return VINF_SUCCESS;
6241// return rcParse;
6242}
6243# undef VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK
6244#endif /* VBOX_WITH_VMSVGA3D */
6245
6246
6247/*
6248 *
6249 * Handlers for FIFO commands.
6250 *
6251 * Every handler takes the following parameters:
6252 *
6253 * pThis The shared VGA/VMSVGA state.
6254 * pThisCC The VGA/VMSVGA state for ring-3.
6255 * pCmd The command data.
6256 */
6257
6258
6259/* SVGA_CMD_UPDATE */
6260void vmsvgaR3CmdUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdate const *pCmd)
6261{
6262 RT_NOREF(pThis);
6263 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6264
6265 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdUpdate);
6266 Log(("SVGA_CMD_UPDATE %d,%d %dx%d\n", pCmd->x, pCmd->y, pCmd->width, pCmd->height));
6267
6268 /** @todo Multiple screens? */
6269 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, 0);
6270 if (!pScreen) /* Can happen if screen is not defined (aScreens[idScreen].fDefined == false) yet. */
6271 return;
6272
6273 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->x, pCmd->y, pCmd->width, pCmd->height);
6274}
6275
6276
6277/* SVGA_CMD_UPDATE_VERBOSE */
6278void vmsvgaR3CmdUpdateVerbose(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdateVerbose const *pCmd)
6279{
6280 RT_NOREF(pThis);
6281 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6282
6283 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdUpdateVerbose);
6284 Log(("SVGA_CMD_UPDATE_VERBOSE %d,%d %dx%d reason %#x\n", pCmd->x, pCmd->y, pCmd->width, pCmd->height, pCmd->reason));
6285
6286 /** @todo Multiple screens? */
6287 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, 0);
6288 if (!pScreen) /* Can happen if screen is not defined (aScreens[idScreen].fDefined == false) yet. */
6289 return;
6290
6291 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->x, pCmd->y, pCmd->width, pCmd->height);
6292}
6293
6294
6295/* SVGA_CMD_RECT_FILL */
6296void vmsvgaR3CmdRectFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectFill const *pCmd)
6297{
6298 RT_NOREF(pThis, pCmd);
6299 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6300
6301 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdRectFill);
6302 Log(("SVGA_CMD_RECT_FILL %08X @ %d,%d (%dx%d)\n", pCmd->pixel, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height));
6303 LogRelMax(4, ("VMSVGA: Unsupported SVGA_CMD_RECT_FILL command ignored.\n"));
6304}
6305
6306
6307/* SVGA_CMD_RECT_COPY */
6308void vmsvgaR3CmdRectCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectCopy const *pCmd)
6309{
6310 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6311
6312 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdRectCopy);
6313 Log(("SVGA_CMD_RECT_COPY %d,%d -> %d,%d %dx%d\n", pCmd->srcX, pCmd->srcY, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height));
6314
6315 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, 0);
6316 AssertPtrReturnVoid(pScreen);
6317
6318 /* Check that arguments aren't complete junk. A precise check is done in vmsvgaR3RectCopy(). */
6319 ASSERT_GUEST_RETURN_VOID(pCmd->srcX < pThis->svga.u32MaxWidth);
6320 ASSERT_GUEST_RETURN_VOID(pCmd->destX < pThis->svga.u32MaxWidth);
6321 ASSERT_GUEST_RETURN_VOID(pCmd->width < pThis->svga.u32MaxWidth);
6322 ASSERT_GUEST_RETURN_VOID(pCmd->srcY < pThis->svga.u32MaxHeight);
6323 ASSERT_GUEST_RETURN_VOID(pCmd->destY < pThis->svga.u32MaxHeight);
6324 ASSERT_GUEST_RETURN_VOID(pCmd->height < pThis->svga.u32MaxHeight);
6325
6326 vmsvgaR3RectCopy(pThisCC, pScreen, pCmd->srcX, pCmd->srcY, pCmd->destX, pCmd->destY,
6327 pCmd->width, pCmd->height, pThis->vram_size);
6328 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height);
6329}
6330
6331
6332/* SVGA_CMD_RECT_ROP_COPY */
6333void vmsvgaR3CmdRectRopCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectRopCopy const *pCmd)
6334{
6335 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6336
6337 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdRectRopCopy);
6338 Log(("SVGA_CMD_RECT_ROP_COPY %d,%d -> %d,%d %dx%d ROP %#X\n", pCmd->srcX, pCmd->srcY, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height, pCmd->rop));
6339
6340 if (pCmd->rop != SVGA_ROP_COPY)
6341 {
6342 /* We only support the plain copy ROP which makes SVGA_CMD_RECT_ROP_COPY exactly the same
6343 * as SVGA_CMD_RECT_COPY. XFree86 4.1.0 and 4.2.0 drivers (driver version 10.4.0 and 10.7.0,
6344 * respectively) issue SVGA_CMD_RECT_ROP_COPY when SVGA_CAP_RECT_COPY is present even when
6345 * SVGA_CAP_RASTER_OP is not. However, the ROP will always be SVGA_ROP_COPY.
6346 */
6347 LogRelMax(4, ("VMSVGA: SVGA_CMD_RECT_ROP_COPY %d,%d -> %d,%d (%dx%d) ROP %X unsupported\n",
6348 pCmd->srcX, pCmd->srcY, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height, pCmd->rop));
6349 return;
6350 }
6351
6352 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, 0);
6353 AssertPtrReturnVoid(pScreen);
6354
6355 /* Check that arguments aren't complete junk. A precise check is done in vmsvgaR3RectCopy(). */
6356 ASSERT_GUEST_RETURN_VOID(pCmd->srcX < pThis->svga.u32MaxWidth);
6357 ASSERT_GUEST_RETURN_VOID(pCmd->destX < pThis->svga.u32MaxWidth);
6358 ASSERT_GUEST_RETURN_VOID(pCmd->width < pThis->svga.u32MaxWidth);
6359 ASSERT_GUEST_RETURN_VOID(pCmd->srcY < pThis->svga.u32MaxHeight);
6360 ASSERT_GUEST_RETURN_VOID(pCmd->destY < pThis->svga.u32MaxHeight);
6361 ASSERT_GUEST_RETURN_VOID(pCmd->height < pThis->svga.u32MaxHeight);
6362
6363 vmsvgaR3RectCopy(pThisCC, pScreen, pCmd->srcX, pCmd->srcY, pCmd->destX, pCmd->destY,
6364 pCmd->width, pCmd->height, pThis->vram_size);
6365 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->destX, pCmd->destY, pCmd->width, pCmd->height);
6366}
6367
6368
6369/* SVGA_CMD_DISPLAY_CURSOR */
6370void vmsvgaR3CmdDisplayCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDisplayCursor const *pCmd)
6371{
6372 RT_NOREF(pThis, pCmd);
6373 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6374
6375 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDisplayCursor);
6376 Log(("SVGA_CMD_DISPLAY_CURSOR id=%d state=%d\n", pCmd->id, pCmd->state));
6377 LogRelMax(4, ("VMSVGA: Unsupported SVGA_CMD_DISPLAY_CURSOR command ignored.\n"));
6378}
6379
6380
6381/* SVGA_CMD_MOVE_CURSOR */
6382void vmsvgaR3CmdMoveCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdMoveCursor const *pCmd)
6383{
6384 RT_NOREF(pThis, pCmd);
6385 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6386
6387 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdMoveCursor);
6388 Log(("SVGA_CMD_MOVE_CURSOR to %d,%d\n", pCmd->pos.x, pCmd->pos.y));
6389 LogRelMax(4, ("VMSVGA: Unsupported SVGA_CMD_MOVE_CURSOR command ignored.\n"));
6390}
6391
6392
6393/* SVGA_CMD_DEFINE_CURSOR */
6394void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineCursor const *pCmd)
6395{
6396 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6397
6398 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineCursor);
6399 Log(("SVGA_CMD_DEFINE_CURSOR id=%d size (%dx%d) hotspot (%d,%d) andMaskDepth=%d xorMaskDepth=%d\n",
6400 pCmd->id, pCmd->width, pCmd->height, pCmd->hotspotX, pCmd->hotspotY, pCmd->andMaskDepth, pCmd->xorMaskDepth));
6401
6402 ASSERT_GUEST_RETURN_VOID(pCmd->height < 2048 && pCmd->width < 2048);
6403 ASSERT_GUEST_RETURN_VOID(pCmd->andMaskDepth <= 32);
6404 ASSERT_GUEST_RETURN_VOID(pCmd->xorMaskDepth <= 32);
6405 RT_UNTRUSTED_VALIDATED_FENCE();
6406
6407 uint32_t const cbSrcAndLine = RT_ALIGN_32(pCmd->width * (pCmd->andMaskDepth + (pCmd->andMaskDepth == 15)), 32) / 8;
6408 uint32_t const cbSrcAndMask = cbSrcAndLine * pCmd->height;
6409 uint32_t const cbSrcXorLine = RT_ALIGN_32(pCmd->width * (pCmd->xorMaskDepth + (pCmd->xorMaskDepth == 15)), 32) / 8;
6410
6411 uint8_t const *pbSrcAndMask = (uint8_t const *)(pCmd + 1);
6412 uint8_t const *pbSrcXorMask = (uint8_t const *)(pCmd + 1) + cbSrcAndMask;
6413
6414 uint32_t const cx = pCmd->width;
6415 uint32_t const cy = pCmd->height;
6416
6417 /*
6418 * Convert the input to 1-bit AND mask and a 32-bit BRGA XOR mask.
6419 * The AND data uses 8-bit aligned scanlines.
6420 * The XOR data must be starting on a 32-bit boundrary.
6421 */
6422 uint32_t cbDstAndLine = RT_ALIGN_32(cx, 8) / 8;
6423 uint32_t cbDstAndMask = cbDstAndLine * cy;
6424 uint32_t cbDstXorMask = cx * sizeof(uint32_t) * cy;
6425 uint32_t cbCopy = RT_ALIGN_32(cbDstAndMask, 4) + cbDstXorMask;
6426
6427 uint8_t *pbCopy = (uint8_t *)RTMemAlloc(cbCopy);
6428 AssertReturnVoid(pbCopy);
6429
6430 /* Convert the AND mask. */
6431 uint8_t *pbDst = pbCopy;
6432 uint8_t const *pbSrc = pbSrcAndMask;
6433 switch (pCmd->andMaskDepth)
6434 {
6435 case 1:
6436 if (cbSrcAndLine == cbDstAndLine)
6437 memcpy(pbDst, pbSrc, cbSrcAndLine * cy);
6438 else
6439 {
6440 Assert(cbSrcAndLine > cbDstAndLine); /* lines are dword alined in source, but only byte in destination. */
6441 for (uint32_t y = 0; y < cy; y++)
6442 {
6443 memcpy(pbDst, pbSrc, cbDstAndLine);
6444 pbDst += cbDstAndLine;
6445 pbSrc += cbSrcAndLine;
6446 }
6447 }
6448 break;
6449 /* Should take the XOR mask into account for the multi-bit AND mask. */
6450 case 8:
6451 for (uint32_t y = 0; y < cy; y++)
6452 {
6453 for (uint32_t x = 0; x < cx; )
6454 {
6455 uint8_t bDst = 0;
6456 uint8_t fBit = 0x80;
6457 do
6458 {
6459 uintptr_t const idxPal = pbSrc[x] * 3;
6460 if ((( pThis->last_palette[idxPal]
6461 | (pThis->last_palette[idxPal] >> 8)
6462 | (pThis->last_palette[idxPal] >> 16)) & 0xff) > 0xfc)
6463 bDst |= fBit;
6464 fBit >>= 1;
6465 x++;
6466 } while (x < cx && (x & 7));
6467 pbDst[(x - 1) / 8] = bDst;
6468 }
6469 pbDst += cbDstAndLine;
6470 pbSrc += cbSrcAndLine;
6471 }
6472 break;
6473 case 15:
6474 for (uint32_t y = 0; y < cy; y++)
6475 {
6476 for (uint32_t x = 0; x < cx; )
6477 {
6478 uint8_t bDst = 0;
6479 uint8_t fBit = 0x80;
6480 do
6481 {
6482 if ((pbSrc[x * 2] | (pbSrc[x * 2 + 1] & 0x7f)) >= 0xfc)
6483 bDst |= fBit;
6484 fBit >>= 1;
6485 x++;
6486 } while (x < cx && (x & 7));
6487 pbDst[(x - 1) / 8] = bDst;
6488 }
6489 pbDst += cbDstAndLine;
6490 pbSrc += cbSrcAndLine;
6491 }
6492 break;
6493 case 16:
6494 for (uint32_t y = 0; y < cy; y++)
6495 {
6496 for (uint32_t x = 0; x < cx; )
6497 {
6498 uint8_t bDst = 0;
6499 uint8_t fBit = 0x80;
6500 do
6501 {
6502 if ((pbSrc[x * 2] | pbSrc[x * 2 + 1]) >= 0xfc)
6503 bDst |= fBit;
6504 fBit >>= 1;
6505 x++;
6506 } while (x < cx && (x & 7));
6507 pbDst[(x - 1) / 8] = bDst;
6508 }
6509 pbDst += cbDstAndLine;
6510 pbSrc += cbSrcAndLine;
6511 }
6512 break;
6513 case 24:
6514 for (uint32_t y = 0; y < cy; y++)
6515 {
6516 for (uint32_t x = 0; x < cx; )
6517 {
6518 uint8_t bDst = 0;
6519 uint8_t fBit = 0x80;
6520 do
6521 {
6522 if ((pbSrc[x * 3] | pbSrc[x * 3 + 1] | pbSrc[x * 3 + 2]) >= 0xfc)
6523 bDst |= fBit;
6524 fBit >>= 1;
6525 x++;
6526 } while (x < cx && (x & 7));
6527 pbDst[(x - 1) / 8] = bDst;
6528 }
6529 pbDst += cbDstAndLine;
6530 pbSrc += cbSrcAndLine;
6531 }
6532 break;
6533 case 32:
6534 for (uint32_t y = 0; y < cy; y++)
6535 {
6536 for (uint32_t x = 0; x < cx; )
6537 {
6538 uint8_t bDst = 0;
6539 uint8_t fBit = 0x80;
6540 do
6541 {
6542 if ((pbSrc[x * 4] | pbSrc[x * 4 + 1] | pbSrc[x * 4 + 2] | pbSrc[x * 4 + 3]) >= 0xfc)
6543 bDst |= fBit;
6544 fBit >>= 1;
6545 x++;
6546 } while (x < cx && (x & 7));
6547 pbDst[(x - 1) / 8] = bDst;
6548 }
6549 pbDst += cbDstAndLine;
6550 pbSrc += cbSrcAndLine;
6551 }
6552 break;
6553 default:
6554 RTMemFreeZ(pbCopy, cbCopy);
6555 AssertFailedReturnVoid();
6556 }
6557
6558 /* Convert the XOR mask. */
6559 uint32_t *pu32Dst = (uint32_t *)(pbCopy + RT_ALIGN_32(cbDstAndMask, 4));
6560 pbSrc = pbSrcXorMask;
6561 switch (pCmd->xorMaskDepth)
6562 {
6563 case 1:
6564 for (uint32_t y = 0; y < cy; y++)
6565 {
6566 for (uint32_t x = 0; x < cx; )
6567 {
6568 /* most significant bit is the left most one. */
6569 uint8_t bSrc = pbSrc[x / 8];
6570 do
6571 {
6572 *pu32Dst++ = bSrc & 0x80 ? UINT32_C(0x00ffffff) : 0;
6573 bSrc <<= 1;
6574 x++;
6575 } while ((x & 7) && x < cx);
6576 }
6577 pbSrc += cbSrcXorLine;
6578 }
6579 break;
6580 case 8:
6581 for (uint32_t y = 0; y < cy; y++)
6582 {
6583 for (uint32_t x = 0; x < cx; x++)
6584 {
6585 uint32_t u = pThis->last_palette[pbSrc[x]];
6586 *pu32Dst++ = u;//RT_MAKE_U32_FROM_U8(RT_BYTE1(u), RT_BYTE2(u), RT_BYTE3(u), 0);
6587 }
6588 pbSrc += cbSrcXorLine;
6589 }
6590 break;
6591 case 15: /* Src: RGB-5-5-5 */
6592 for (uint32_t y = 0; y < cy; y++)
6593 {
6594 for (uint32_t x = 0; x < cx; x++)
6595 {
6596 uint32_t const uValue = RT_MAKE_U16(pbSrc[x * 2], pbSrc[x * 2 + 1]);
6597 *pu32Dst++ = RT_MAKE_U32_FROM_U8(( uValue & 0x1f) << 3,
6598 ((uValue >> 5) & 0x1f) << 3,
6599 ((uValue >> 10) & 0x1f) << 3, 0);
6600 }
6601 pbSrc += cbSrcXorLine;
6602 }
6603 break;
6604 case 16: /* Src: RGB-5-6-5 */
6605 for (uint32_t y = 0; y < cy; y++)
6606 {
6607 for (uint32_t x = 0; x < cx; x++)
6608 {
6609 uint32_t const uValue = RT_MAKE_U16(pbSrc[x * 2], pbSrc[x * 2 + 1]);
6610 *pu32Dst++ = RT_MAKE_U32_FROM_U8(( uValue & 0x1f) << 3,
6611 ((uValue >> 5) & 0x3f) << 2,
6612 ((uValue >> 11) & 0x1f) << 3, 0);
6613 }
6614 pbSrc += cbSrcXorLine;
6615 }
6616 break;
6617 case 24:
6618 for (uint32_t y = 0; y < cy; y++)
6619 {
6620 for (uint32_t x = 0; x < cx; x++)
6621 *pu32Dst++ = RT_MAKE_U32_FROM_U8(pbSrc[x*3], pbSrc[x*3 + 1], pbSrc[x*3 + 2], 0);
6622 pbSrc += cbSrcXorLine;
6623 }
6624 break;
6625 case 32:
6626 for (uint32_t y = 0; y < cy; y++)
6627 {
6628 for (uint32_t x = 0; x < cx; x++)
6629 *pu32Dst++ = RT_MAKE_U32_FROM_U8(pbSrc[x*4], pbSrc[x*4 + 1], pbSrc[x*4 + 2], 0);
6630 pbSrc += cbSrcXorLine;
6631 }
6632 break;
6633 default:
6634 RTMemFreeZ(pbCopy, cbCopy);
6635 AssertFailedReturnVoid();
6636 }
6637
6638 /*
6639 * Pass it to the frontend/whatever.
6640 */
6641 vmsvgaR3InstallNewCursor(pThisCC, pSvgaR3State, false /*fAlpha*/, pCmd->hotspotX, pCmd->hotspotY,
6642 cx, cy, pbCopy, cbCopy);
6643}
6644
6645
6646/* SVGA_CMD_DEFINE_ALPHA_CURSOR */
6647void vmsvgaR3CmdDefineAlphaCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineAlphaCursor const *pCmd)
6648{
6649 RT_NOREF(pThis);
6650 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6651
6652 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineAlphaCursor);
6653 Log(("VMSVGA cmd: SVGA_CMD_DEFINE_ALPHA_CURSOR id=%d size (%dx%d) hotspot (%d,%d)\n", pCmd->id, pCmd->width, pCmd->height, pCmd->hotspotX, pCmd->hotspotY));
6654
6655 /* Check against a reasonable upper limit to prevent integer overflows in the sanity checks below. */
6656 ASSERT_GUEST_RETURN_VOID(pCmd->height < 2048 && pCmd->width < 2048);
6657 RT_UNTRUSTED_VALIDATED_FENCE();
6658
6659 /* The mouse pointer interface always expects an AND mask followed by the color data (XOR mask). */
6660 uint32_t cbAndMask = (pCmd->width + 7) / 8 * pCmd->height; /* size of the AND mask */
6661 cbAndMask = ((cbAndMask + 3) & ~3); /* + gap for alignment */
6662 uint32_t cbXorMask = pCmd->width * sizeof(uint32_t) * pCmd->height; /* + size of the XOR mask (32-bit BRGA format) */
6663 uint32_t cbCursorShape = cbAndMask + cbXorMask;
6664
6665 uint8_t *pCursorCopy = (uint8_t *)RTMemAlloc(cbCursorShape);
6666 AssertPtrReturnVoid(pCursorCopy);
6667
6668 /* Transparency is defined by the alpha bytes, so make the whole bitmap visible. */
6669 memset(pCursorCopy, 0xff, cbAndMask);
6670 /* Colour data */
6671 memcpy(pCursorCopy + cbAndMask, pCmd + 1, cbXorMask);
6672
6673 vmsvgaR3InstallNewCursor(pThisCC, pSvgaR3State, true /*fAlpha*/, pCmd->hotspotX, pCmd->hotspotY,
6674 pCmd->width, pCmd->height, pCursorCopy, cbCursorShape);
6675}
6676
6677
6678/* SVGA_CMD_ESCAPE */
6679void vmsvgaR3CmdEscape(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdEscape const *pCmd)
6680{
6681 RT_NOREF(pThis);
6682 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6683
6684 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdEscape);
6685
6686 if (pCmd->nsid == SVGA_ESCAPE_NSID_VMWARE)
6687 {
6688 ASSERT_GUEST_RETURN_VOID(pCmd->size >= sizeof(uint32_t));
6689 RT_UNTRUSTED_VALIDATED_FENCE();
6690
6691 uint32_t const cmd = *(uint32_t *)(pCmd + 1);
6692 Log(("SVGA_CMD_ESCAPE (%#x %#x) VMWARE cmd=%#x\n", pCmd->nsid, pCmd->size, cmd));
6693
6694 switch (cmd)
6695 {
6696 case SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS:
6697 {
6698 SVGAEscapeVideoSetRegs *pVideoCmd = (SVGAEscapeVideoSetRegs *)(pCmd + 1);
6699 ASSERT_GUEST_RETURN_VOID(pCmd->size >= sizeof(pVideoCmd->header));
6700 RT_UNTRUSTED_VALIDATED_FENCE();
6701
6702 uint32_t const cRegs = (pCmd->size - sizeof(pVideoCmd->header)) / sizeof(pVideoCmd->items[0]);
6703
6704 Log(("SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS: stream %#x\n", pVideoCmd->header.streamId));
6705 for (uint32_t iReg = 0; iReg < cRegs; iReg++)
6706 Log(("SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS: reg %#x val %#x\n", pVideoCmd->items[iReg].registerId, pVideoCmd->items[iReg].value));
6707 RT_NOREF_PV(pVideoCmd);
6708 break;
6709 }
6710
6711 case SVGA_ESCAPE_VMWARE_VIDEO_FLUSH:
6712 {
6713 SVGAEscapeVideoFlush *pVideoCmd = (SVGAEscapeVideoFlush *)(pCmd + 1);
6714 ASSERT_GUEST_RETURN_VOID(pCmd->size >= sizeof(*pVideoCmd));
6715 Log(("SVGA_ESCAPE_VMWARE_VIDEO_FLUSH: stream %#x\n", pVideoCmd->streamId));
6716 RT_NOREF_PV(pVideoCmd);
6717 break;
6718 }
6719
6720 default:
6721 Log(("SVGA_CMD_ESCAPE: Unknown vmware escape: %#x\n", cmd));
6722 break;
6723 }
6724 }
6725 else
6726 Log(("SVGA_CMD_ESCAPE %#x %#x\n", pCmd->nsid, pCmd->size));
6727}
6728
6729
6730/* SVGA_CMD_DEFINE_SCREEN */
6731void vmsvgaR3CmdDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineScreen const *pCmd)
6732{
6733 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6734
6735 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineScreen);
6736 Log(("SVGA_CMD_DEFINE_SCREEN id=%x flags=%x size=(%d,%d) root=(%d,%d) %d:0x%x 0x%x\n",
6737 pCmd->screen.id, pCmd->screen.flags, pCmd->screen.size.width, pCmd->screen.size.height, pCmd->screen.root.x, pCmd->screen.root.y,
6738 pCmd->screen.backingStore.ptr.gmrId, pCmd->screen.backingStore.ptr.offset, pCmd->screen.backingStore.pitch));
6739
6740 uint32_t const idScreen = pCmd->screen.id;
6741 ASSERT_GUEST_RETURN_VOID(idScreen < RT_ELEMENTS(pSvgaR3State->aScreens));
6742
6743 uint32_t const uWidth = pCmd->screen.size.width;
6744 ASSERT_GUEST_RETURN_VOID(uWidth <= pThis->svga.u32MaxWidth);
6745
6746 uint32_t const uHeight = pCmd->screen.size.height;
6747 ASSERT_GUEST_RETURN_VOID(uHeight <= pThis->svga.u32MaxHeight);
6748
6749 uint32_t const cbWidth = uWidth * ((32 + 7) / 8); /** @todo 32? */
6750 uint32_t const cbPitch = pCmd->screen.backingStore.pitch ? pCmd->screen.backingStore.pitch : cbWidth;
6751 ASSERT_GUEST_RETURN_VOID(cbWidth <= cbPitch);
6752
6753 uint32_t const uScreenOffset = pCmd->screen.backingStore.ptr.offset;
6754 ASSERT_GUEST_RETURN_VOID(uScreenOffset < pThis->vram_size);
6755
6756 uint32_t const cbVram = pThis->vram_size - uScreenOffset;
6757 /* If we have a not zero pitch, then height can't exceed the available VRAM. */
6758 ASSERT_GUEST_RETURN_VOID( (uHeight == 0 && cbPitch == 0)
6759 || (cbPitch > 0 && uHeight <= cbVram / cbPitch));
6760 RT_UNTRUSTED_VALIDATED_FENCE();
6761
6762 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idScreen];
6763 pScreen->fDefined = true;
6764 pScreen->fModified = true;
6765 pScreen->fuScreen = pCmd->screen.flags;
6766 pScreen->idScreen = idScreen;
6767 if (!RT_BOOL(pCmd->screen.flags & (SVGA_SCREEN_DEACTIVATE | SVGA_SCREEN_BLANKING)))
6768 {
6769 /* Not blanked. */
6770 ASSERT_GUEST_RETURN_VOID(uWidth > 0 && uHeight > 0);
6771 RT_UNTRUSTED_VALIDATED_FENCE();
6772
6773 pScreen->xOrigin = pCmd->screen.root.x;
6774 pScreen->yOrigin = pCmd->screen.root.y;
6775 pScreen->cWidth = uWidth;
6776 pScreen->cHeight = uHeight;
6777 pScreen->offVRAM = uScreenOffset;
6778 pScreen->cbPitch = cbPitch;
6779 pScreen->cBpp = 32;
6780 }
6781 else
6782 {
6783 /* Screen blanked. Keep old values. */
6784 }
6785
6786 pThis->svga.fGFBRegisters = false;
6787 vmsvgaR3ChangeMode(pThis, pThisCC);
6788
6789#ifdef VBOX_WITH_VMSVGA3D
6790 if (RT_LIKELY(pThis->svga.f3DEnabled))
6791 vmsvga3dDefineScreen(pThis, pThisCC, pScreen);
6792#endif
6793}
6794
6795
6796/* SVGA_CMD_DESTROY_SCREEN */
6797void vmsvgaR3CmdDestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDestroyScreen const *pCmd)
6798{
6799 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6800
6801 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDestroyScreen);
6802 Log(("SVGA_CMD_DESTROY_SCREEN id=%x\n", pCmd->screenId));
6803
6804 uint32_t const idScreen = pCmd->screenId;
6805 ASSERT_GUEST_RETURN_VOID(idScreen < RT_ELEMENTS(pSvgaR3State->aScreens));
6806 RT_UNTRUSTED_VALIDATED_FENCE();
6807
6808 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idScreen];
6809 pScreen->fModified = true;
6810 pScreen->fDefined = false;
6811 pScreen->idScreen = idScreen;
6812
6813#ifdef VBOX_WITH_VMSVGA3D
6814 if (RT_LIKELY(pThis->svga.f3DEnabled))
6815 vmsvga3dDestroyScreen(pThisCC, pScreen);
6816#endif
6817 vmsvgaR3ChangeMode(pThis, pThisCC);
6818}
6819
6820
6821/* SVGA_CMD_DEFINE_GMRFB */
6822void vmsvgaR3CmdDefineGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMRFB const *pCmd)
6823{
6824 RT_NOREF(pThis);
6825 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6826
6827 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineGmrFb);
6828 Log(("SVGA_CMD_DEFINE_GMRFB gmr=%x offset=%x bytesPerLine=%x bpp=%d color depth=%d\n",
6829 pCmd->ptr.gmrId, pCmd->ptr.offset, pCmd->bytesPerLine, pCmd->format.bitsPerPixel, pCmd->format.colorDepth));
6830
6831 pSvgaR3State->GMRFB.ptr = pCmd->ptr;
6832 pSvgaR3State->GMRFB.bytesPerLine = pCmd->bytesPerLine;
6833 pSvgaR3State->GMRFB.format = pCmd->format;
6834}
6835
6836
6837/* SVGA_CMD_BLIT_GMRFB_TO_SCREEN */
6838void vmsvgaR3CmdBlitGMRFBToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitGMRFBToScreen const *pCmd)
6839{
6840 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6841
6842 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdBlitGmrFbToScreen);
6843 Log(("SVGA_CMD_BLIT_GMRFB_TO_SCREEN src=(%d,%d) dest id=%d (%d,%d)(%d,%d)\n",
6844 pCmd->srcOrigin.x, pCmd->srcOrigin.y, pCmd->destScreenId, pCmd->destRect.left, pCmd->destRect.top, pCmd->destRect.right, pCmd->destRect.bottom));
6845
6846 ASSERT_GUEST_RETURN_VOID(pCmd->destScreenId < RT_ELEMENTS(pSvgaR3State->aScreens));
6847 RT_UNTRUSTED_VALIDATED_FENCE();
6848
6849 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, pCmd->destScreenId);
6850 AssertPtrReturnVoid(pScreen);
6851
6852 /** @todo Support GMRFB.format.s.bitsPerPixel != pThis->svga.uBpp ? */
6853 AssertReturnVoid(pSvgaR3State->GMRFB.format.bitsPerPixel == pScreen->cBpp);
6854
6855 /* Clip destRect to the screen dimensions. */
6856 SVGASignedRect screenRect;
6857 screenRect.left = 0;
6858 screenRect.top = 0;
6859 screenRect.right = pScreen->cWidth;
6860 screenRect.bottom = pScreen->cHeight;
6861 SVGASignedRect clipRect = pCmd->destRect;
6862 vmsvgaR3ClipRect(&screenRect, &clipRect);
6863 RT_UNTRUSTED_VALIDATED_FENCE();
6864
6865 uint32_t const width = clipRect.right - clipRect.left;
6866 uint32_t const height = clipRect.bottom - clipRect.top;
6867
6868 if ( width == 0
6869 || height == 0)
6870 return; /* Nothing to do. */
6871
6872 int32_t const srcx = pCmd->srcOrigin.x + (clipRect.left - pCmd->destRect.left);
6873 int32_t const srcy = pCmd->srcOrigin.y + (clipRect.top - pCmd->destRect.top);
6874
6875 /* Copy the defined by GMRFB image to the screen 0 VRAM area.
6876 * Prepare parameters for vmsvgaR3GmrTransfer.
6877 */
6878 AssertReturnVoid(pScreen->offVRAM < pThis->vram_size); /* Paranoia. Ensured by SVGA_CMD_DEFINE_SCREEN. */
6879
6880 /* Destination: host buffer which describes the screen 0 VRAM.
6881 * Important are pbHstBuf and cbHstBuf. offHst and cbHstPitch are verified by vmsvgaR3GmrTransfer.
6882 */
6883 uint8_t * const pbHstBuf = (uint8_t *)pThisCC->pbVRam + pScreen->offVRAM;
6884 uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch :
6885 width * (RT_ALIGN(pScreen->cBpp, 8) / 8);
6886 uint32_t cbHstBuf = cbScanline * pScreen->cHeight;
6887 if (cbHstBuf > pThis->vram_size - pScreen->offVRAM)
6888 cbHstBuf = pThis->vram_size - pScreen->offVRAM; /* Paranoia. */
6889 uint32_t const offHst = (clipRect.left * RT_ALIGN(pScreen->cBpp, 8)) / 8
6890 + cbScanline * clipRect.top;
6891 int32_t const cbHstPitch = cbScanline;
6892
6893 /* Source: GMRFB. vmsvgaR3GmrTransfer ensures that no memory outside the GMR is read. */
6894 SVGAGuestPtr const gstPtr = pSvgaR3State->GMRFB.ptr;
6895 uint32_t const offGst = (srcx * RT_ALIGN(pSvgaR3State->GMRFB.format.bitsPerPixel, 8)) / 8
6896 + pSvgaR3State->GMRFB.bytesPerLine * srcy;
6897 int32_t const cbGstPitch = pSvgaR3State->GMRFB.bytesPerLine;
6898
6899 int rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_WRITE_HOST_VRAM,
6900 pbHstBuf, cbHstBuf, offHst, cbHstPitch,
6901 gstPtr, offGst, cbGstPitch,
6902 (width * RT_ALIGN(pScreen->cBpp, 8)) / 8, height);
6903 AssertRC(rc);
6904 vmsvgaR3UpdateScreen(pThisCC, pScreen, clipRect.left, clipRect.top, width, height);
6905}
6906
6907
6908/* SVGA_CMD_BLIT_SCREEN_TO_GMRFB */
6909void vmsvgaR3CmdBlitScreenToGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitScreenToGMRFB const *pCmd)
6910{
6911 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6912
6913 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdBlitScreentoGmrFb);
6914 /* Note! This can fetch 3d render results as well!! */
6915 Log(("SVGA_CMD_BLIT_SCREEN_TO_GMRFB dest=(%d,%d) src id=%d (%d,%d)(%d,%d)\n",
6916 pCmd->destOrigin.x, pCmd->destOrigin.y, pCmd->srcScreenId, pCmd->srcRect.left, pCmd->srcRect.top, pCmd->srcRect.right, pCmd->srcRect.bottom));
6917
6918 ASSERT_GUEST_RETURN_VOID(pCmd->srcScreenId < RT_ELEMENTS(pSvgaR3State->aScreens));
6919 RT_UNTRUSTED_VALIDATED_FENCE();
6920
6921 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, pCmd->srcScreenId);
6922 AssertPtrReturnVoid(pScreen);
6923
6924 /** @todo Support GMRFB.format.bitsPerPixel != pThis->svga.uBpp ? */
6925 AssertReturnVoid(pSvgaR3State->GMRFB.format.bitsPerPixel == pScreen->cBpp);
6926
6927 /* Clip destRect to the screen dimensions. */
6928 SVGASignedRect screenRect;
6929 screenRect.left = 0;
6930 screenRect.top = 0;
6931 screenRect.right = pScreen->cWidth;
6932 screenRect.bottom = pScreen->cHeight;
6933 SVGASignedRect clipRect = pCmd->srcRect;
6934 vmsvgaR3ClipRect(&screenRect, &clipRect);
6935 RT_UNTRUSTED_VALIDATED_FENCE();
6936
6937 uint32_t const width = clipRect.right - clipRect.left;
6938 uint32_t const height = clipRect.bottom - clipRect.top;
6939
6940 if ( width == 0
6941 || height == 0)
6942 return; /* Nothing to do. */
6943
6944 int32_t const dstx = pCmd->destOrigin.x + (clipRect.left - pCmd->srcRect.left);
6945 int32_t const dsty = pCmd->destOrigin.y + (clipRect.top - pCmd->srcRect.top);
6946
6947 /* Copy the defined by GMRFB image to the screen 0 VRAM area.
6948 * Prepare parameters for vmsvgaR3GmrTransfer.
6949 */
6950 AssertReturnVoid(pScreen->offVRAM < pThis->vram_size); /* Paranoia. Ensured by SVGA_CMD_DEFINE_SCREEN. */
6951
6952 /* Source: host buffer which describes the screen 0 VRAM.
6953 * Important are pbHstBuf and cbHstBuf. offHst and cbHstPitch are verified by vmsvgaR3GmrTransfer.
6954 */
6955 uint8_t * const pbHstBuf = (uint8_t *)pThisCC->pbVRam + pScreen->offVRAM;
6956 uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch :
6957 width * (RT_ALIGN(pScreen->cBpp, 8) / 8);
6958 uint32_t cbHstBuf = cbScanline * pScreen->cHeight;
6959 if (cbHstBuf > pThis->vram_size - pScreen->offVRAM)
6960 cbHstBuf = pThis->vram_size - pScreen->offVRAM; /* Paranoia. */
6961 uint32_t const offHst = (clipRect.left * RT_ALIGN(pScreen->cBpp, 8)) / 8
6962 + cbScanline * clipRect.top;
6963 int32_t const cbHstPitch = cbScanline;
6964
6965 /* Destination: GMRFB. vmsvgaR3GmrTransfer ensures that no memory outside the GMR is read. */
6966 SVGAGuestPtr const gstPtr = pSvgaR3State->GMRFB.ptr;
6967 uint32_t const offGst = (dstx * RT_ALIGN(pSvgaR3State->GMRFB.format.bitsPerPixel, 8)) / 8
6968 + pSvgaR3State->GMRFB.bytesPerLine * dsty;
6969 int32_t const cbGstPitch = pSvgaR3State->GMRFB.bytesPerLine;
6970
6971 int rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_READ_HOST_VRAM,
6972 pbHstBuf, cbHstBuf, offHst, cbHstPitch,
6973 gstPtr, offGst, cbGstPitch,
6974 (width * RT_ALIGN(pScreen->cBpp, 8)) / 8, height);
6975 AssertRC(rc);
6976}
6977
6978
6979/* SVGA_CMD_ANNOTATION_FILL */
6980void vmsvgaR3CmdAnnotationFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationFill const *pCmd)
6981{
6982 RT_NOREF(pThis);
6983 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6984
6985 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdAnnotationFill);
6986 Log(("SVGA_CMD_ANNOTATION_FILL red=%x green=%x blue=%x\n", pCmd->color.r, pCmd->color.g, pCmd->color.b));
6987
6988 pSvgaR3State->colorAnnotation = pCmd->color;
6989}
6990
6991
6992/* SVGA_CMD_ANNOTATION_COPY */
6993void vmsvgaR3CmdAnnotationCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationCopy const *pCmd)
6994{
6995 RT_NOREF(pThis, pCmd);
6996 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
6997
6998 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdAnnotationCopy);
6999 Log(("SVGA_CMD_ANNOTATION_COPY srcOrigin %d,%d, srcScreenId %u\n", pCmd->srcOrigin.x, pCmd->srcOrigin.y, pCmd->srcScreenId));
7000
7001 AssertFailed();
7002}
7003
7004
7005#ifdef VBOX_WITH_VMSVGA3D
7006/* SVGA_CMD_DEFINE_GMR2 */
7007void vmsvgaR3CmdDefineGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMR2 const *pCmd)
7008{
7009 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
7010
7011 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineGmr2);
7012 Log(("SVGA_CMD_DEFINE_GMR2 id=%#x %#x pages\n", pCmd->gmrId, pCmd->numPages));
7013
7014 /* Validate current GMR id. */
7015 ASSERT_GUEST_RETURN_VOID(pCmd->gmrId < pThis->svga.cGMR);
7016 ASSERT_GUEST_RETURN_VOID(pCmd->numPages <= VMSVGA_MAX_GMR_PAGES);
7017 RT_UNTRUSTED_VALIDATED_FENCE();
7018
7019 if (!pCmd->numPages)
7020 {
7021 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineGmr2Free);
7022 vmsvgaR3GmrFree(pThisCC, pCmd->gmrId);
7023 }
7024 else
7025 {
7026 PGMR pGMR = &pSvgaR3State->paGMR[pCmd->gmrId];
7027 if (pGMR->cMaxPages)
7028 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdDefineGmr2Modify);
7029
7030 /* Not sure if we should always free the descriptor, but for simplicity
7031 we do so if the new size is smaller than the current. */
7032 /** @todo always free the descriptor in SVGA_CMD_DEFINE_GMR2? */
7033 if (pGMR->cbTotal / X86_PAGE_SIZE > pCmd->numPages)
7034 vmsvgaR3GmrFree(pThisCC, pCmd->gmrId);
7035
7036 pGMR->cMaxPages = pCmd->numPages;
7037 /* The rest is done by the REMAP_GMR2 command. */
7038 }
7039}
7040
7041
7042/* SVGA_CMD_REMAP_GMR2 */
7043void vmsvgaR3CmdRemapGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRemapGMR2 const *pCmd)
7044{
7045 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
7046
7047 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdRemapGmr2);
7048 Log(("SVGA_CMD_REMAP_GMR2 id=%#x flags=%#x offset=%#x npages=%#x\n", pCmd->gmrId, pCmd->flags, pCmd->offsetPages, pCmd->numPages));
7049
7050 /* Validate current GMR id and size. */
7051 ASSERT_GUEST_RETURN_VOID(pCmd->gmrId < pThis->svga.cGMR);
7052 RT_UNTRUSTED_VALIDATED_FENCE();
7053 PGMR pGMR = &pSvgaR3State->paGMR[pCmd->gmrId];
7054 ASSERT_GUEST_RETURN_VOID( (uint64_t)pCmd->offsetPages + pCmd->numPages
7055 <= RT_MIN(pGMR->cMaxPages, RT_MIN(VMSVGA_MAX_GMR_PAGES, UINT32_MAX / X86_PAGE_SIZE)));
7056 ASSERT_GUEST_RETURN_VOID(!pCmd->offsetPages || pGMR->paDesc); /** @todo */
7057
7058 if (pCmd->numPages == 0)
7059 return;
7060 RT_UNTRUSTED_VALIDATED_FENCE();
7061
7062 /* Calc new total page count so we can use it instead of cMaxPages for allocations below. */
7063 uint32_t const cNewTotalPages = RT_MAX(pGMR->cbTotal >> X86_PAGE_SHIFT, pCmd->offsetPages + pCmd->numPages);
7064
7065 /*
7066 * We flatten the existing descriptors into a page array, overwrite the
7067 * pages specified in this command and then recompress the descriptor.
7068 */
7069 /** @todo Optimize the GMR remap algorithm! */
7070
7071 /* Save the old page descriptors as an array of page frame numbers (address >> X86_PAGE_SHIFT) */
7072 uint64_t *paNewPage64 = NULL;
7073 if (pGMR->paDesc)
7074 {
7075 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3CmdRemapGmr2Modify);
7076
7077 paNewPage64 = (uint64_t *)RTMemAllocZ(cNewTotalPages * sizeof(uint64_t));
7078 AssertPtrReturnVoid(paNewPage64);
7079
7080 uint32_t idxPage = 0;
7081 for (uint32_t i = 0; i < pGMR->numDescriptors; i++)
7082 for (uint32_t j = 0; j < pGMR->paDesc[i].numPages; j++)
7083 paNewPage64[idxPage++] = (pGMR->paDesc[i].GCPhys + j * X86_PAGE_SIZE) >> X86_PAGE_SHIFT;
7084 AssertReturnVoidStmt(idxPage == pGMR->cbTotal >> X86_PAGE_SHIFT, RTMemFree(paNewPage64));
7085 RT_UNTRUSTED_VALIDATED_FENCE();
7086 }
7087
7088 /* Free the old GMR if present. */
7089 if (pGMR->paDesc)
7090 RTMemFree(pGMR->paDesc);
7091
7092 /* Allocate the maximum amount possible (everything non-continuous) */
7093 PVMSVGAGMRDESCRIPTOR paDescs;
7094 pGMR->paDesc = paDescs = (PVMSVGAGMRDESCRIPTOR)RTMemAllocZ(cNewTotalPages * sizeof(VMSVGAGMRDESCRIPTOR));
7095 AssertReturnVoidStmt(paDescs, RTMemFree(paNewPage64));
7096
7097 if (pCmd->flags & SVGA_REMAP_GMR2_VIA_GMR)
7098 {
7099 /** @todo */
7100 AssertFailed();
7101 pGMR->numDescriptors = 0;
7102 }
7103 else
7104 {
7105 uint32_t *paPages32 = (uint32_t *)(pCmd + 1);
7106 uint64_t *paPages64 = (uint64_t *)(pCmd + 1);
7107 bool fGCPhys64 = RT_BOOL(pCmd->flags & SVGA_REMAP_GMR2_PPN64);
7108
7109 uint32_t cPages;
7110 if (paNewPage64)
7111 {
7112 /* Overwrite the old page array with the new page values. */
7113 if (fGCPhys64)
7114 for (uint32_t i = pCmd->offsetPages; i < pCmd->offsetPages + pCmd->numPages; i++)
7115 paNewPage64[i] = paPages64[i - pCmd->offsetPages];
7116 else
7117 for (uint32_t i = pCmd->offsetPages; i < pCmd->offsetPages + pCmd->numPages; i++)
7118 paNewPage64[i] = paPages32[i - pCmd->offsetPages];
7119
7120 /* Use the updated page array instead of the command data. */
7121 fGCPhys64 = true;
7122 paPages64 = paNewPage64;
7123 cPages = cNewTotalPages;
7124 }
7125 else
7126 cPages = pCmd->numPages;
7127
7128 /* The first page. */
7129 /** @todo The 0x00000FFFFFFFFFFF mask limits to 44 bits and should not be
7130 * applied to paNewPage64. */
7131 RTGCPHYS GCPhys;
7132 if (fGCPhys64)
7133 GCPhys = (paPages64[0] << X86_PAGE_SHIFT) & UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
7134 else
7135 GCPhys = (RTGCPHYS)paPages32[0] << GUEST_PAGE_SHIFT;
7136 paDescs[0].GCPhys = GCPhys;
7137 paDescs[0].numPages = 1;
7138
7139 /* Subsequent pages. */
7140 uint32_t iDescriptor = 0;
7141 for (uint32_t i = 1; i < cPages; i++)
7142 {
7143 if (pCmd->flags & SVGA_REMAP_GMR2_PPN64)
7144 GCPhys = (paPages64[i] << X86_PAGE_SHIFT) & UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
7145 else
7146 GCPhys = (RTGCPHYS)paPages32[i] << X86_PAGE_SHIFT;
7147
7148 /* Continuous physical memory? */
7149 if (GCPhys == paDescs[iDescriptor].GCPhys + paDescs[iDescriptor].numPages * X86_PAGE_SIZE)
7150 {
7151 Assert(paDescs[iDescriptor].numPages);
7152 paDescs[iDescriptor].numPages++;
7153 Log5Func(("Page %x GCPhys=%RGp successor\n", i, GCPhys));
7154 }
7155 else
7156 {
7157 iDescriptor++;
7158 paDescs[iDescriptor].GCPhys = GCPhys;
7159 paDescs[iDescriptor].numPages = 1;
7160 Log5Func(("Page %x GCPhys=%RGp\n", i, paDescs[iDescriptor].GCPhys));
7161 }
7162 }
7163
7164 pGMR->cbTotal = cNewTotalPages << X86_PAGE_SHIFT;
7165 Log5Func(("Nr of descriptors %x; cbTotal=%#x\n", iDescriptor + 1, cNewTotalPages));
7166 pGMR->numDescriptors = iDescriptor + 1;
7167 }
7168
7169 if (paNewPage64)
7170 RTMemFree(paNewPage64);
7171}
7172
7173
7174/**
7175 * Free the specified GMR
7176 *
7177 * @param pThisCC The VGA/VMSVGA state for ring-3.
7178 * @param idGMR GMR id
7179 */
7180void vmsvgaR3GmrFree(PVGASTATECC pThisCC, uint32_t idGMR)
7181{
7182 PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
7183
7184 /* Free the old descriptor if present. */
7185 PGMR pGMR = &pSVGAState->paGMR[idGMR];
7186 if ( pGMR->numDescriptors
7187 || pGMR->paDesc /* needed till we implement SVGA_REMAP_GMR2_VIA_GMR */)
7188 {
7189# ifdef DEBUG_GMR_ACCESS
7190 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pThisCC->pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3DeregisterGmr, 2, pDevIns, idGMR);
7191# endif
7192
7193 Assert(pGMR->paDesc);
7194 RTMemFree(pGMR->paDesc);
7195 pGMR->paDesc = NULL;
7196 pGMR->numDescriptors = 0;
7197 pGMR->cbTotal = 0;
7198 pGMR->cMaxPages = 0;
7199 }
7200 Assert(!pGMR->cMaxPages);
7201 Assert(!pGMR->cbTotal);
7202}
7203#endif /* VBOX_WITH_VMSVGA3D */
7204
7205
7206/**
7207 * Copy between a GMR and a host memory buffer.
7208 *
7209 * @returns VBox status code.
7210 * @param pThis The shared VGA/VMSVGA instance data.
7211 * @param pThisCC The VGA/VMSVGA state for ring-3.
7212 * @param enmTransferType Transfer type (read/write)
7213 * @param pbHstBuf Host buffer pointer (valid)
7214 * @param cbHstBuf Size of host buffer (valid)
7215 * @param offHst Host buffer offset of the first scanline
7216 * @param cbHstPitch Destination buffer pitch
7217 * @param gstPtr GMR description
7218 * @param offGst Guest buffer offset of the first scanline
7219 * @param cbGstPitch Guest buffer pitch
7220 * @param cbWidth Width in bytes to copy
7221 * @param cHeight Number of scanllines to copy
7222 */
7223int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
7224 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
7225 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
7226 uint32_t cbWidth, uint32_t cHeight)
7227{
7228 PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
7229 PPDMDEVINS pDevIns = pThisCC->pDevIns; /* simpler */
7230 int rc;
7231
7232 LogFunc(("%s host %p size=%d offset %d pitch=%d; guest gmr=%#x:%#x offset=%d pitch=%d cbWidth=%d cHeight=%d\n",
7233 enmTransferType == SVGA3D_READ_HOST_VRAM ? "WRITE" : "READ", /* GMR op: READ host VRAM means WRITE GMR */
7234 pbHstBuf, cbHstBuf, offHst, cbHstPitch,
7235 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cbWidth, cHeight));
7236 AssertReturn(cbWidth && cHeight, VERR_INVALID_PARAMETER);
7237
7238 PGMR pGMR;
7239 uint32_t cbGmr; /* The GMR size in bytes. */
7240 if (gstPtr.gmrId == SVGA_GMR_FRAMEBUFFER)
7241 {
7242 pGMR = NULL;
7243 cbGmr = pThis->vram_size;
7244 }
7245 else
7246 {
7247 AssertReturn(gstPtr.gmrId < pThis->svga.cGMR, VERR_INVALID_PARAMETER);
7248 RT_UNTRUSTED_VALIDATED_FENCE();
7249 pGMR = &pSVGAState->paGMR[gstPtr.gmrId];
7250 cbGmr = pGMR->cbTotal;
7251 }
7252
7253 /*
7254 * GMR
7255 */
7256 /* Calculate GMR offset of the data to be copied. */
7257 AssertMsgReturn(gstPtr.offset < cbGmr,
7258 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7259 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7260 VERR_INVALID_PARAMETER);
7261 RT_UNTRUSTED_VALIDATED_FENCE();
7262 AssertMsgReturn(offGst < cbGmr - gstPtr.offset,
7263 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7264 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7265 VERR_INVALID_PARAMETER);
7266 RT_UNTRUSTED_VALIDATED_FENCE();
7267 uint32_t const offGmr = offGst + gstPtr.offset; /* Offset in the GMR, where the first scanline is located. */
7268
7269 /* Verify that cbWidth is less than scanline and fits into the GMR. */
7270 uint32_t const cbGmrScanline = cbGstPitch > 0 ? cbGstPitch : -cbGstPitch;
7271 AssertMsgReturn(cbGmrScanline != 0,
7272 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7273 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7274 VERR_INVALID_PARAMETER);
7275 RT_UNTRUSTED_VALIDATED_FENCE();
7276 AssertMsgReturn(cbWidth <= cbGmrScanline,
7277 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7278 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7279 VERR_INVALID_PARAMETER);
7280 AssertMsgReturn(cbWidth <= cbGmr - offGmr,
7281 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7282 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7283 VERR_INVALID_PARAMETER);
7284 RT_UNTRUSTED_VALIDATED_FENCE();
7285
7286 /* How many bytes are available for the data in the GMR. */
7287 uint32_t const cbGmrLeft = cbGstPitch > 0 ? cbGmr - offGmr : offGmr + cbWidth;
7288
7289 /* How many scanlines would fit into the available data. */
7290 uint32_t cGmrScanlines = cbGmrLeft / cbGmrScanline;
7291 uint32_t const cbGmrLastScanline = cbGmrLeft - cGmrScanlines * cbGmrScanline; /* Slack space. */
7292 if (cbWidth <= cbGmrLastScanline)
7293 ++cGmrScanlines;
7294
7295 if (cHeight > cGmrScanlines)
7296 cHeight = cGmrScanlines;
7297
7298 AssertMsgReturn(cHeight > 0,
7299 ("gmr=%#x:%#x offGst=%#x cbGstPitch=%#x cHeight=%#x cbWidth=%#x cbGmr=%#x\n",
7300 gstPtr.gmrId, gstPtr.offset, offGst, cbGstPitch, cHeight, cbWidth, cbGmr),
7301 VERR_INVALID_PARAMETER);
7302 RT_UNTRUSTED_VALIDATED_FENCE();
7303
7304 /*
7305 * Host buffer.
7306 */
7307 AssertMsgReturn(offHst < cbHstBuf,
7308 ("buffer=%p size %d offHst=%d cbHstPitch=%d cHeight=%d cbWidth=%d\n",
7309 pbHstBuf, cbHstBuf, offHst, cbHstPitch, cHeight, cbWidth),
7310 VERR_INVALID_PARAMETER);
7311
7312 /* Verify that cbWidth is less than scanline and fits into the buffer. */
7313 uint32_t const cbHstScanline = cbHstPitch > 0 ? cbHstPitch : -cbHstPitch;
7314 AssertMsgReturn(cbHstScanline != 0,
7315 ("buffer=%p size %d offHst=%d cbHstPitch=%d cHeight=%d cbWidth=%d\n",
7316 pbHstBuf, cbHstBuf, offHst, cbHstPitch, cHeight, cbWidth),
7317 VERR_INVALID_PARAMETER);
7318 AssertMsgReturn(cbWidth <= cbHstScanline,
7319 ("buffer=%p size %d offHst=%d cbHstPitch=%d cHeight=%d cbWidth=%d\n",
7320 pbHstBuf, cbHstBuf, offHst, cbHstPitch, cHeight, cbWidth),
7321 VERR_INVALID_PARAMETER);
7322 AssertMsgReturn(cbWidth <= cbHstBuf - offHst,
7323 ("buffer=%p size %d offHst=%d cbHstPitch=%d cHeight=%d cbWidth=%d\n",
7324 pbHstBuf, cbHstBuf, offHst, cbHstPitch, cHeight, cbWidth),
7325 VERR_INVALID_PARAMETER);
7326
7327 /* How many bytes are available for the data in the buffer. */
7328 uint32_t const cbHstLeft = cbHstPitch > 0 ? cbHstBuf - offHst : offHst + cbWidth;
7329
7330 /* How many scanlines would fit into the available data. */
7331 uint32_t cHstScanlines = cbHstLeft / cbHstScanline;
7332 uint32_t const cbHstLastScanline = cbHstLeft - cHstScanlines * cbHstScanline; /* Slack space. */
7333 if (cbWidth <= cbHstLastScanline)
7334 ++cHstScanlines;
7335
7336 if (cHeight > cHstScanlines)
7337 cHeight = cHstScanlines;
7338
7339 AssertMsgReturn(cHeight > 0,
7340 ("buffer=%p size %d offHst=%d cbHstPitch=%d cHeight=%d cbWidth=%d\n",
7341 pbHstBuf, cbHstBuf, offHst, cbHstPitch, cHeight, cbWidth),
7342 VERR_INVALID_PARAMETER);
7343
7344 uint8_t *pbHst = pbHstBuf + offHst;
7345
7346 /* Shortcut for the framebuffer. */
7347 if (gstPtr.gmrId == SVGA_GMR_FRAMEBUFFER)
7348 {
7349 uint8_t *pbGst = pThisCC->pbVRam + offGmr;
7350
7351 uint8_t const *pbSrc;
7352 int32_t cbSrcPitch;
7353 uint8_t *pbDst;
7354 int32_t cbDstPitch;
7355
7356 if (enmTransferType == SVGA3D_READ_HOST_VRAM)
7357 {
7358 pbSrc = pbHst;
7359 cbSrcPitch = cbHstPitch;
7360 pbDst = pbGst;
7361 cbDstPitch = cbGstPitch;
7362 }
7363 else
7364 {
7365 pbSrc = pbGst;
7366 cbSrcPitch = cbGstPitch;
7367 pbDst = pbHst;
7368 cbDstPitch = cbHstPitch;
7369 }
7370
7371 if ( cbWidth == (uint32_t)cbGstPitch
7372 && cbGstPitch == cbHstPitch)
7373 {
7374 /* Entire scanlines, positive pitch. */
7375 memcpy(pbDst, pbSrc, cbWidth * cHeight);
7376 }
7377 else
7378 {
7379 for (uint32_t i = 0; i < cHeight; ++i)
7380 {
7381 memcpy(pbDst, pbSrc, cbWidth);
7382
7383 pbDst += cbDstPitch;
7384 pbSrc += cbSrcPitch;
7385 }
7386 }
7387 return VINF_SUCCESS;
7388 }
7389
7390 AssertPtrReturn(pGMR, VERR_INVALID_PARAMETER);
7391 AssertReturn(pGMR->numDescriptors > 0, VERR_INVALID_PARAMETER);
7392
7393 PVMSVGAGMRDESCRIPTOR const paDesc = pGMR->paDesc; /* Local copy of the pointer. */
7394 uint32_t iDesc = 0; /* Index in the descriptor array. */
7395 uint32_t offDesc = 0; /* GMR offset of the current descriptor. */
7396 uint32_t offGmrScanline = offGmr; /* GMR offset of the scanline which is being copied. */
7397 uint8_t *pbHstScanline = pbHst; /* Host address of the scanline which is being copied. */
7398 for (uint32_t i = 0; i < cHeight; ++i)
7399 {
7400 uint32_t cbCurrentWidth = cbWidth;
7401 uint32_t offGmrCurrent = offGmrScanline;
7402 uint8_t *pbCurrentHost = pbHstScanline;
7403
7404 /* Find the right descriptor */
7405 while (offDesc + paDesc[iDesc].numPages * GUEST_PAGE_SIZE <= offGmrCurrent)
7406 {
7407 offDesc += paDesc[iDesc].numPages * GUEST_PAGE_SIZE;
7408 AssertReturn(offDesc < pGMR->cbTotal, VERR_INTERNAL_ERROR); /* overflow protection */
7409 ++iDesc;
7410 AssertReturn(iDesc < pGMR->numDescriptors, VERR_INTERNAL_ERROR);
7411 }
7412
7413 while (cbCurrentWidth)
7414 {
7415 uint32_t cbToCopy;
7416
7417 if (offGmrCurrent + cbCurrentWidth <= offDesc + paDesc[iDesc].numPages * GUEST_PAGE_SIZE)
7418 cbToCopy = cbCurrentWidth;
7419 else
7420 {
7421 cbToCopy = (offDesc + paDesc[iDesc].numPages * GUEST_PAGE_SIZE - offGmrCurrent);
7422 AssertReturn(cbToCopy <= cbCurrentWidth, VERR_INVALID_PARAMETER);
7423 }
7424
7425 RTGCPHYS const GCPhys = paDesc[iDesc].GCPhys + offGmrCurrent - offDesc;
7426
7427 Log5Func(("%s phys=%RGp\n", (enmTransferType == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", GCPhys));
7428
7429 /*
7430 * We are deliberately using the non-PCI version of PDMDevHlpPCIPhys[Read|Write] as the
7431 * guest-side VMSVGA driver seems to allocate non-DMA (physical memory) addresses,
7432 * see @bugref{9654#c75}.
7433 */
7434 if (enmTransferType == SVGA3D_WRITE_HOST_VRAM)
7435 rc = PDMDevHlpPhysRead(pDevIns, GCPhys, pbCurrentHost, cbToCopy);
7436 else
7437 rc = PDMDevHlpPhysWrite(pDevIns, GCPhys, pbCurrentHost, cbToCopy);
7438 AssertRCBreak(rc);
7439
7440 cbCurrentWidth -= cbToCopy;
7441 offGmrCurrent += cbToCopy;
7442 pbCurrentHost += cbToCopy;
7443
7444 /* Go to the next descriptor if there's anything left. */
7445 if (cbCurrentWidth)
7446 {
7447 offDesc += paDesc[iDesc].numPages * GUEST_PAGE_SIZE;
7448 AssertReturn(offDesc < pGMR->cbTotal, VERR_INTERNAL_ERROR);
7449 ++iDesc;
7450 AssertReturn(iDesc < pGMR->numDescriptors, VERR_INTERNAL_ERROR);
7451 }
7452 }
7453
7454 offGmrScanline += cbGstPitch;
7455 pbHstScanline += cbHstPitch;
7456 }
7457
7458 return VINF_SUCCESS;
7459}
7460
7461
7462/**
7463 * Unsigned coordinates in pBox. Clip to [0; pSizeSrc), [0; pSizeDest).
7464 *
7465 * @param pSizeSrc Source surface dimensions.
7466 * @param pSizeDest Destination surface dimensions.
7467 * @param pBox Coordinates to be clipped.
7468 */
7469void vmsvgaR3ClipCopyBox(const SVGA3dSize *pSizeSrc, const SVGA3dSize *pSizeDest, SVGA3dCopyBox *pBox)
7470{
7471 /* Src x, w */
7472 if (pBox->srcx > pSizeSrc->width)
7473 pBox->srcx = pSizeSrc->width;
7474 if (pBox->w > pSizeSrc->width - pBox->srcx)
7475 pBox->w = pSizeSrc->width - pBox->srcx;
7476
7477 /* Src y, h */
7478 if (pBox->srcy > pSizeSrc->height)
7479 pBox->srcy = pSizeSrc->height;
7480 if (pBox->h > pSizeSrc->height - pBox->srcy)
7481 pBox->h = pSizeSrc->height - pBox->srcy;
7482
7483 /* Src z, d */
7484 if (pBox->srcz > pSizeSrc->depth)
7485 pBox->srcz = pSizeSrc->depth;
7486 if (pBox->d > pSizeSrc->depth - pBox->srcz)
7487 pBox->d = pSizeSrc->depth - pBox->srcz;
7488
7489 /* Dest x, w */
7490 if (pBox->x > pSizeDest->width)
7491 pBox->x = pSizeDest->width;
7492 if (pBox->w > pSizeDest->width - pBox->x)
7493 pBox->w = pSizeDest->width - pBox->x;
7494
7495 /* Dest y, h */
7496 if (pBox->y > pSizeDest->height)
7497 pBox->y = pSizeDest->height;
7498 if (pBox->h > pSizeDest->height - pBox->y)
7499 pBox->h = pSizeDest->height - pBox->y;
7500
7501 /* Dest z, d */
7502 if (pBox->z > pSizeDest->depth)
7503 pBox->z = pSizeDest->depth;
7504 if (pBox->d > pSizeDest->depth - pBox->z)
7505 pBox->d = pSizeDest->depth - pBox->z;
7506}
7507
7508
7509/**
7510 * Unsigned coordinates in pBox. Clip to [0; pSize).
7511 *
7512 * @param pSize Source surface dimensions.
7513 * @param pBox Coordinates to be clipped.
7514 */
7515void vmsvgaR3ClipBox(const SVGA3dSize *pSize, SVGA3dBox *pBox)
7516{
7517 /* x, w */
7518 if (pBox->x > pSize->width)
7519 pBox->x = pSize->width;
7520 if (pBox->w > pSize->width - pBox->x)
7521 pBox->w = pSize->width - pBox->x;
7522
7523 /* y, h */
7524 if (pBox->y > pSize->height)
7525 pBox->y = pSize->height;
7526 if (pBox->h > pSize->height - pBox->y)
7527 pBox->h = pSize->height - pBox->y;
7528
7529 /* z, d */
7530 if (pBox->z > pSize->depth)
7531 pBox->z = pSize->depth;
7532 if (pBox->d > pSize->depth - pBox->z)
7533 pBox->d = pSize->depth - pBox->z;
7534}
7535
7536
7537/**
7538 * Clip.
7539 *
7540 * @param pBound Bounding rectangle.
7541 * @param pRect Rectangle to be clipped.
7542 */
7543void vmsvgaR3ClipRect(SVGASignedRect const *pBound, SVGASignedRect *pRect)
7544{
7545 int32_t left;
7546 int32_t top;
7547 int32_t right;
7548 int32_t bottom;
7549
7550 /* Right order. */
7551 Assert(pBound->left <= pBound->right && pBound->top <= pBound->bottom);
7552 if (pRect->left < pRect->right)
7553 {
7554 left = pRect->left;
7555 right = pRect->right;
7556 }
7557 else
7558 {
7559 left = pRect->right;
7560 right = pRect->left;
7561 }
7562 if (pRect->top < pRect->bottom)
7563 {
7564 top = pRect->top;
7565 bottom = pRect->bottom;
7566 }
7567 else
7568 {
7569 top = pRect->bottom;
7570 bottom = pRect->top;
7571 }
7572
7573 if (left < pBound->left)
7574 left = pBound->left;
7575 if (right < pBound->left)
7576 right = pBound->left;
7577
7578 if (left > pBound->right)
7579 left = pBound->right;
7580 if (right > pBound->right)
7581 right = pBound->right;
7582
7583 if (top < pBound->top)
7584 top = pBound->top;
7585 if (bottom < pBound->top)
7586 bottom = pBound->top;
7587
7588 if (top > pBound->bottom)
7589 top = pBound->bottom;
7590 if (bottom > pBound->bottom)
7591 bottom = pBound->bottom;
7592
7593 pRect->left = left;
7594 pRect->right = right;
7595 pRect->top = top;
7596 pRect->bottom = bottom;
7597}
7598
7599
7600/**
7601 * Clip.
7602 *
7603 * @param pBound Bounding rectangle.
7604 * @param pRect Rectangle to be clipped.
7605 */
7606void vmsvgaR3Clip3dRect(SVGA3dRect const *pBound, SVGA3dRect RT_UNTRUSTED_GUEST *pRect)
7607{
7608 uint32_t const leftBound = pBound->x;
7609 uint32_t const rightBound = pBound->x + pBound->w;
7610 uint32_t const topBound = pBound->y;
7611 uint32_t const bottomBound = pBound->y + pBound->h;
7612
7613 uint32_t x = pRect->x;
7614 uint32_t y = pRect->y;
7615 uint32_t w = pRect->w;
7616 uint32_t h = pRect->h;
7617
7618 /* Make sure that right and bottom coordinates can be safely computed. */
7619 if (x > rightBound)
7620 x = rightBound;
7621 if (w > rightBound - x)
7622 w = rightBound - x;
7623 if (y > bottomBound)
7624 y = bottomBound;
7625 if (h > bottomBound - y)
7626 h = bottomBound - y;
7627
7628 /* Switch from x, y, w, h to left, top, right, bottom. */
7629 uint32_t left = x;
7630 uint32_t right = x + w;
7631 uint32_t top = y;
7632 uint32_t bottom = y + h;
7633
7634 /* A standard left, right, bottom, top clipping. */
7635 if (left < leftBound)
7636 left = leftBound;
7637 if (right < leftBound)
7638 right = leftBound;
7639
7640 if (left > rightBound)
7641 left = rightBound;
7642 if (right > rightBound)
7643 right = rightBound;
7644
7645 if (top < topBound)
7646 top = topBound;
7647 if (bottom < topBound)
7648 bottom = topBound;
7649
7650 if (top > bottomBound)
7651 top = bottomBound;
7652 if (bottom > bottomBound)
7653 bottom = bottomBound;
7654
7655 /* Back to x, y, w, h representation. */
7656 pRect->x = left;
7657 pRect->y = top;
7658 pRect->w = right - left;
7659 pRect->h = bottom - top;
7660}
7661
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