VirtualBox

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

Last change on this file since 106655 was 106263, checked in by vboxsync, 3 months ago

3D: Remove the excessive LogRels for Src and Dst buffers validation. bugref:10580

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