1 | /* $Id: DevVGA-SVGA-cmd.cpp 103469 2024-02-20 08:15:41Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMware SVGA device - implementation of VMSVGA commands.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2023 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 <VBox/AssertGuest.h>
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <VBox/vmm/pdmdev.h>
|
---|
38 | #include <VBoxVideo.h>
|
---|
39 |
|
---|
40 | /* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
|
---|
41 | #include "DevVGA.h"
|
---|
42 |
|
---|
43 | /* Should be included after DevVGA.h/DevVGA-SVGA.h to pick all defines. */
|
---|
44 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
45 | # include "DevVGA-SVGA3d.h"
|
---|
46 | #endif
|
---|
47 | #include "DevVGA-SVGA-internal.h"
|
---|
48 |
|
---|
49 | #include <iprt/formats/bmp.h>
|
---|
50 | #include <stdio.h>
|
---|
51 |
|
---|
52 | #if defined(LOG_ENABLED) || defined(VBOX_STRICT)
|
---|
53 | # define SVGA_CASE_ID2STR(idx) case idx: return #idx
|
---|
54 |
|
---|
55 | static const char *vmsvgaFifo3dCmdToString(SVGAFifo3dCmdId enmCmdId)
|
---|
56 | {
|
---|
57 | switch (enmCmdId)
|
---|
58 | {
|
---|
59 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LEGACY_BASE);
|
---|
60 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DEFINE);
|
---|
61 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DESTROY);
|
---|
62 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_COPY);
|
---|
63 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_STRETCHBLT);
|
---|
64 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DMA);
|
---|
65 | SVGA_CASE_ID2STR(SVGA_3D_CMD_CONTEXT_DEFINE);
|
---|
66 | SVGA_CASE_ID2STR(SVGA_3D_CMD_CONTEXT_DESTROY);
|
---|
67 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETTRANSFORM);
|
---|
68 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETZRANGE);
|
---|
69 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETRENDERSTATE);
|
---|
70 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETRENDERTARGET);
|
---|
71 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETTEXTURESTATE);
|
---|
72 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETMATERIAL);
|
---|
73 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETLIGHTDATA);
|
---|
74 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETLIGHTENABLED);
|
---|
75 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETVIEWPORT);
|
---|
76 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETCLIPPLANE);
|
---|
77 | SVGA_CASE_ID2STR(SVGA_3D_CMD_CLEAR);
|
---|
78 | SVGA_CASE_ID2STR(SVGA_3D_CMD_PRESENT);
|
---|
79 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SHADER_DEFINE);
|
---|
80 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SHADER_DESTROY);
|
---|
81 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_SHADER);
|
---|
82 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_SHADER_CONST);
|
---|
83 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW_PRIMITIVES);
|
---|
84 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SETSCISSORRECT);
|
---|
85 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BEGIN_QUERY);
|
---|
86 | SVGA_CASE_ID2STR(SVGA_3D_CMD_END_QUERY);
|
---|
87 | SVGA_CASE_ID2STR(SVGA_3D_CMD_WAIT_FOR_QUERY);
|
---|
88 | SVGA_CASE_ID2STR(SVGA_3D_CMD_PRESENT_READBACK);
|
---|
89 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN);
|
---|
90 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_DEFINE_V2);
|
---|
91 | SVGA_CASE_ID2STR(SVGA_3D_CMD_GENERATE_MIPMAPS);
|
---|
92 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD4); /* SVGA_3D_CMD_VIDEO_CREATE_DECODER */
|
---|
93 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD5); /* SVGA_3D_CMD_VIDEO_DESTROY_DECODER */
|
---|
94 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD6); /* SVGA_3D_CMD_VIDEO_CREATE_PROCESSOR */
|
---|
95 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD7); /* SVGA_3D_CMD_VIDEO_DESTROY_PROCESSOR */
|
---|
96 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD8); /* SVGA_3D_CMD_VIDEO_DECODE_START_FRAME */
|
---|
97 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD9); /* SVGA_3D_CMD_VIDEO_DECODE_RENDER */
|
---|
98 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD10); /* SVGA_3D_CMD_VIDEO_DECODE_END_FRAME */
|
---|
99 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD11); /* SVGA_3D_CMD_VIDEO_PROCESS_FRAME */
|
---|
100 | SVGA_CASE_ID2STR(SVGA_3D_CMD_ACTIVATE_SURFACE);
|
---|
101 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEACTIVATE_SURFACE);
|
---|
102 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SCREEN_DMA);
|
---|
103 | SVGA_CASE_ID2STR(SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION); /* SVGA_3D_CMD_DEAD1 */
|
---|
104 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD2);
|
---|
105 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD12); /* Old SVGA_3D_CMD_LOGICOPS_BITBLT */
|
---|
106 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD13); /* Old SVGA_3D_CMD_LOGICOPS_TRANSBLT */
|
---|
107 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD14); /* Old SVGA_3D_CMD_LOGICOPS_STRETCHBLT */
|
---|
108 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD15); /* Old SVGA_3D_CMD_LOGICOPS_COLORFILL */
|
---|
109 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD16); /* Old SVGA_3D_CMD_LOGICOPS_ALPHABLEND */
|
---|
110 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD17); /* Old SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND */
|
---|
111 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_OTABLE_BASE);
|
---|
112 | SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_OTABLE);
|
---|
113 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_MOB);
|
---|
114 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_MOB);
|
---|
115 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEAD3);
|
---|
116 | SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING);
|
---|
117 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE);
|
---|
118 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SURFACE);
|
---|
119 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SURFACE);
|
---|
120 | SVGA_CASE_ID2STR(SVGA_3D_CMD_COND_BIND_GB_SURFACE);
|
---|
121 | SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_IMAGE);
|
---|
122 | SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_SURFACE);
|
---|
123 | SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_IMAGE);
|
---|
124 | SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_SURFACE);
|
---|
125 | SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_IMAGE);
|
---|
126 | SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_SURFACE);
|
---|
127 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_CONTEXT);
|
---|
128 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_CONTEXT);
|
---|
129 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_CONTEXT);
|
---|
130 | SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_CONTEXT);
|
---|
131 | SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_CONTEXT);
|
---|
132 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SHADER);
|
---|
133 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SHADER);
|
---|
134 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SHADER);
|
---|
135 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_OTABLE_BASE64);
|
---|
136 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BEGIN_GB_QUERY);
|
---|
137 | SVGA_CASE_ID2STR(SVGA_3D_CMD_END_GB_QUERY);
|
---|
138 | SVGA_CASE_ID2STR(SVGA_3D_CMD_WAIT_FOR_GB_QUERY);
|
---|
139 | SVGA_CASE_ID2STR(SVGA_3D_CMD_NOP);
|
---|
140 | SVGA_CASE_ID2STR(SVGA_3D_CMD_ENABLE_GART);
|
---|
141 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DISABLE_GART);
|
---|
142 | SVGA_CASE_ID2STR(SVGA_3D_CMD_MAP_MOB_INTO_GART);
|
---|
143 | SVGA_CASE_ID2STR(SVGA_3D_CMD_UNMAP_GART_RANGE);
|
---|
144 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SCREENTARGET);
|
---|
145 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DESTROY_GB_SCREENTARGET);
|
---|
146 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SCREENTARGET);
|
---|
147 | SVGA_CASE_ID2STR(SVGA_3D_CMD_UPDATE_GB_SCREENTARGET);
|
---|
148 | SVGA_CASE_ID2STR(SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL);
|
---|
149 | SVGA_CASE_ID2STR(SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL);
|
---|
150 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE);
|
---|
151 | SVGA_CASE_ID2STR(SVGA_3D_CMD_GB_SCREEN_DMA);
|
---|
152 | SVGA_CASE_ID2STR(SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH);
|
---|
153 | SVGA_CASE_ID2STR(SVGA_3D_CMD_GB_MOB_FENCE);
|
---|
154 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V2);
|
---|
155 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_MOB64);
|
---|
156 | SVGA_CASE_ID2STR(SVGA_3D_CMD_REDEFINE_GB_MOB64);
|
---|
157 | SVGA_CASE_ID2STR(SVGA_3D_CMD_NOP_ERROR);
|
---|
158 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_STREAMS);
|
---|
159 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_DECLS);
|
---|
160 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SET_VERTEX_DIVISORS);
|
---|
161 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW);
|
---|
162 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DRAW_INDEXED);
|
---|
163 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_CONTEXT);
|
---|
164 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_CONTEXT);
|
---|
165 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_CONTEXT);
|
---|
166 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_CONTEXT);
|
---|
167 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_INVALIDATE_CONTEXT);
|
---|
168 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER);
|
---|
169 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER_RESOURCES);
|
---|
170 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER);
|
---|
171 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SAMPLERS);
|
---|
172 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW);
|
---|
173 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED);
|
---|
174 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INSTANCED);
|
---|
175 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED);
|
---|
176 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_AUTO);
|
---|
177 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_INPUT_LAYOUT);
|
---|
178 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS);
|
---|
179 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_INDEX_BUFFER);
|
---|
180 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_TOPOLOGY);
|
---|
181 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_RENDERTARGETS);
|
---|
182 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_BLEND_STATE);
|
---|
183 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE);
|
---|
184 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_RASTERIZER_STATE);
|
---|
185 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_QUERY);
|
---|
186 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_QUERY);
|
---|
187 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_QUERY);
|
---|
188 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_QUERY_OFFSET);
|
---|
189 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BEGIN_QUERY);
|
---|
190 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_END_QUERY);
|
---|
191 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_QUERY);
|
---|
192 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_PREDICATION);
|
---|
193 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SOTARGETS);
|
---|
194 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VIEWPORTS);
|
---|
195 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SCISSORRECTS);
|
---|
196 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW);
|
---|
197 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW);
|
---|
198 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_COPY_REGION);
|
---|
199 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_COPY);
|
---|
200 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRESENTBLT);
|
---|
201 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_GENMIPS);
|
---|
202 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE);
|
---|
203 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_SUBRESOURCE);
|
---|
204 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE);
|
---|
205 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW);
|
---|
206 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW);
|
---|
207 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW);
|
---|
208 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW);
|
---|
209 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW);
|
---|
210 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW);
|
---|
211 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT);
|
---|
212 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT);
|
---|
213 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_BLEND_STATE);
|
---|
214 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_BLEND_STATE);
|
---|
215 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE);
|
---|
216 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE);
|
---|
217 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE);
|
---|
218 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE);
|
---|
219 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE);
|
---|
220 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE);
|
---|
221 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_SHADER);
|
---|
222 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_SHADER);
|
---|
223 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_SHADER);
|
---|
224 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT);
|
---|
225 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT);
|
---|
226 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_STREAMOUTPUT);
|
---|
227 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_COTABLE);
|
---|
228 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_COTABLE);
|
---|
229 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BUFFER_COPY);
|
---|
230 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER);
|
---|
231 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK);
|
---|
232 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_MOVE_QUERY);
|
---|
233 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_ALL_QUERY);
|
---|
234 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_READBACK_ALL_QUERY);
|
---|
235 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER);
|
---|
236 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_MOB_FENCE_64);
|
---|
237 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_ALL_SHADER);
|
---|
238 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_HINT);
|
---|
239 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BUFFER_UPDATE);
|
---|
240 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET);
|
---|
241 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET);
|
---|
242 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET);
|
---|
243 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET);
|
---|
244 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET);
|
---|
245 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET);
|
---|
246 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER);
|
---|
247 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SCREEN_COPY);
|
---|
248 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED1);
|
---|
249 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2);
|
---|
250 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED3);
|
---|
251 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED4);
|
---|
252 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED5);
|
---|
253 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED6);
|
---|
254 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED7);
|
---|
255 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED8);
|
---|
256 | SVGA_CASE_ID2STR(SVGA_3D_CMD_GROW_OTABLE);
|
---|
257 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_GROW_COTABLE);
|
---|
258 | SVGA_CASE_ID2STR(SVGA_3D_CMD_INTRA_SURFACE_COPY);
|
---|
259 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V3);
|
---|
260 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_RESOLVE_COPY);
|
---|
261 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_RESOLVE_COPY);
|
---|
262 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_CONVERT_REGION);
|
---|
263 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_PRED_CONVERT);
|
---|
264 | SVGA_CASE_ID2STR(SVGA_3D_CMD_WHOLE_SURFACE_COPY);
|
---|
265 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_UA_VIEW);
|
---|
266 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DESTROY_UA_VIEW);
|
---|
267 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT);
|
---|
268 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT);
|
---|
269 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT);
|
---|
270 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_UA_VIEWS);
|
---|
271 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT);
|
---|
272 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT);
|
---|
273 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DISPATCH);
|
---|
274 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DISPATCH_INDIRECT);
|
---|
275 | SVGA_CASE_ID2STR(SVGA_3D_CMD_WRITE_ZERO_SURFACE);
|
---|
276 | SVGA_CASE_ID2STR(SVGA_3D_CMD_HINT_ZERO_SURFACE);
|
---|
277 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER);
|
---|
278 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT);
|
---|
279 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_BITBLT);
|
---|
280 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_TRANSBLT);
|
---|
281 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_STRETCHBLT);
|
---|
282 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_COLORFILL);
|
---|
283 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_ALPHABLEND);
|
---|
284 | SVGA_CASE_ID2STR(SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND);
|
---|
285 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_1);
|
---|
286 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_2);
|
---|
287 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DEFINE_GB_SURFACE_V4);
|
---|
288 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_CS_UA_VIEWS);
|
---|
289 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_MIN_LOD);
|
---|
290 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_3);
|
---|
291 | SVGA_CASE_ID2STR(SVGA_3D_CMD_RESERVED2_4);
|
---|
292 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2);
|
---|
293 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB);
|
---|
294 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_SET_SHADER_IFACE);
|
---|
295 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_STREAMOUTPUT);
|
---|
296 | SVGA_CASE_ID2STR(SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS);
|
---|
297 | SVGA_CASE_ID2STR(SVGA_3D_CMD_DX_BIND_SHADER_IFACE);
|
---|
298 | SVGA_CASE_ID2STR(SVGA_3D_CMD_MAX);
|
---|
299 | SVGA_CASE_ID2STR(SVGA_3D_CMD_FUTURE_MAX);
|
---|
300 |
|
---|
301 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR);
|
---|
302 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER_OUTPUT_VIEW);
|
---|
303 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER);
|
---|
304 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_DECODER_BEGIN_FRAME);
|
---|
305 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_DECODER_SUBMIT_BUFFERS);
|
---|
306 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_DECODER_END_FRAME);
|
---|
307 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_INPUT_VIEW);
|
---|
308 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_OUTPUT_VIEW);
|
---|
309 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_BLT);
|
---|
310 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER);
|
---|
311 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER_OUTPUT_VIEW);
|
---|
312 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR);
|
---|
313 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_INPUT_VIEW);
|
---|
314 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_OUTPUT_VIEW);
|
---|
315 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_TARGET_RECT);
|
---|
316 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_BACKGROUND_COLOR);
|
---|
317 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_COLOR_SPACE);
|
---|
318 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_ALPHA_FILL_MODE);
|
---|
319 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_CONSTRICTION);
|
---|
320 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_STEREO_MODE);
|
---|
321 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FRAME_FORMAT);
|
---|
322 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_COLOR_SPACE);
|
---|
323 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_OUTPUT_RATE);
|
---|
324 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_SOURCE_RECT);
|
---|
325 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_DEST_RECT);
|
---|
326 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ALPHA);
|
---|
327 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PALETTE);
|
---|
328 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PIXEL_ASPECT_RATIO);
|
---|
329 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_LUMA_KEY);
|
---|
330 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_STEREO_FORMAT);
|
---|
331 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_AUTO_PROCESSING_MODE);
|
---|
332 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FILTER);
|
---|
333 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ROTATION);
|
---|
334 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_GET_VIDEO_CAPABILITY);
|
---|
335 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_CLEAR_RTV);
|
---|
336 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_CLEAR_UAV);
|
---|
337 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_CLEAR_VDOV);
|
---|
338 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_CLEAR_VPIV);
|
---|
339 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_DX_CLEAR_VPOV);
|
---|
340 | SVGA_CASE_ID2STR(VBSVGA_3D_CMD_MAX);
|
---|
341 | #ifndef DEBUG_sunlover
|
---|
342 | default: break; /* Compiler warning. */
|
---|
343 | #endif
|
---|
344 | }
|
---|
345 | return "UNKNOWN_3D";
|
---|
346 | }
|
---|
347 |
|
---|
348 | /**
|
---|
349 | * FIFO command name lookup
|
---|
350 | *
|
---|
351 | * @returns FIFO command string or "UNKNOWN"
|
---|
352 | * @param u32Cmd FIFO command
|
---|
353 | */
|
---|
354 | const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd)
|
---|
355 | {
|
---|
356 | switch (u32Cmd)
|
---|
357 | {
|
---|
358 | SVGA_CASE_ID2STR(SVGA_CMD_INVALID_CMD);
|
---|
359 | SVGA_CASE_ID2STR(SVGA_CMD_UPDATE);
|
---|
360 | SVGA_CASE_ID2STR(SVGA_CMD_RECT_FILL);
|
---|
361 | SVGA_CASE_ID2STR(SVGA_CMD_RECT_COPY);
|
---|
362 | SVGA_CASE_ID2STR(SVGA_CMD_RECT_ROP_COPY);
|
---|
363 | SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_CURSOR);
|
---|
364 | SVGA_CASE_ID2STR(SVGA_CMD_DISPLAY_CURSOR);
|
---|
365 | SVGA_CASE_ID2STR(SVGA_CMD_MOVE_CURSOR);
|
---|
366 | SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_ALPHA_CURSOR);
|
---|
367 | SVGA_CASE_ID2STR(SVGA_CMD_UPDATE_VERBOSE);
|
---|
368 | SVGA_CASE_ID2STR(SVGA_CMD_FRONT_ROP_FILL);
|
---|
369 | SVGA_CASE_ID2STR(SVGA_CMD_FENCE);
|
---|
370 | SVGA_CASE_ID2STR(SVGA_CMD_ESCAPE);
|
---|
371 | SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_SCREEN);
|
---|
372 | SVGA_CASE_ID2STR(SVGA_CMD_DESTROY_SCREEN);
|
---|
373 | SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_GMRFB);
|
---|
374 | SVGA_CASE_ID2STR(SVGA_CMD_BLIT_GMRFB_TO_SCREEN);
|
---|
375 | SVGA_CASE_ID2STR(SVGA_CMD_BLIT_SCREEN_TO_GMRFB);
|
---|
376 | SVGA_CASE_ID2STR(SVGA_CMD_ANNOTATION_FILL);
|
---|
377 | SVGA_CASE_ID2STR(SVGA_CMD_ANNOTATION_COPY);
|
---|
378 | SVGA_CASE_ID2STR(SVGA_CMD_DEFINE_GMR2);
|
---|
379 | SVGA_CASE_ID2STR(SVGA_CMD_REMAP_GMR2);
|
---|
380 | SVGA_CASE_ID2STR(SVGA_CMD_DEAD);
|
---|
381 | SVGA_CASE_ID2STR(SVGA_CMD_DEAD_2);
|
---|
382 | SVGA_CASE_ID2STR(SVGA_CMD_NOP);
|
---|
383 | SVGA_CASE_ID2STR(SVGA_CMD_NOP_ERROR);
|
---|
384 | SVGA_CASE_ID2STR(SVGA_CMD_MAX);
|
---|
385 | default:
|
---|
386 | if ( (u32Cmd >= SVGA_3D_CMD_BASE && u32Cmd < SVGA_3D_CMD_MAX)
|
---|
387 | || (u32Cmd >= VBSVGA_3D_CMD_BASE && u32Cmd < VBSVGA_3D_CMD_MAX))
|
---|
388 | return vmsvgaFifo3dCmdToString((SVGAFifo3dCmdId)u32Cmd);
|
---|
389 | }
|
---|
390 | return "UNKNOWN";
|
---|
391 | }
|
---|
392 | # undef SVGA_CASE_ID2STR
|
---|
393 | #endif /* LOG_ENABLED || VBOX_STRICT */
|
---|
394 |
|
---|
395 |
|
---|
396 | /*
|
---|
397 | *
|
---|
398 | * Guest-Backed Objects (GBO).
|
---|
399 | *
|
---|
400 | */
|
---|
401 |
|
---|
402 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
403 |
|
---|
404 | static int vmsvgaR3GboCreate(PVMSVGAR3STATE pSvgaR3State, SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, PVMSVGAGBO pGbo)
|
---|
405 | {
|
---|
406 | ASSERT_GUEST_RETURN(sizeInBytes <= _128M, VERR_INVALID_PARAMETER); /** @todo Less than SVGA_REG_MOB_MAX_SIZE */
|
---|
407 |
|
---|
408 | /*
|
---|
409 | * The 'baseAddress' is a page number and points to the 'root page' of the GBO.
|
---|
410 | * Content of the root page depends on the ptDepth value:
|
---|
411 | * SVGA3D_MOBFMT_PTDEPTH[64]_0 - the only data page;
|
---|
412 | * SVGA3D_MOBFMT_PTDEPTH[64]_1 - array of page numbers for data pages;
|
---|
413 | * SVGA3D_MOBFMT_PTDEPTH[64]_2 - array of page numbers for SVGA3D_MOBFMT_PTDEPTH[64]_1 pages.
|
---|
414 | * The code below extracts the page addresses of the GBO.
|
---|
415 | */
|
---|
416 |
|
---|
417 | /* Verify and normalize the ptDepth value. */
|
---|
418 | bool fGCPhys64; /* Whether the page table contains 64 bit page numbers. */
|
---|
419 | if (RT_LIKELY( ptDepth == SVGA3D_MOBFMT_PTDEPTH64_0
|
---|
420 | || ptDepth == SVGA3D_MOBFMT_PTDEPTH64_1
|
---|
421 | || ptDepth == SVGA3D_MOBFMT_PTDEPTH64_2))
|
---|
422 | fGCPhys64 = true;
|
---|
423 | else if ( ptDepth == SVGA3D_MOBFMT_PTDEPTH_0
|
---|
424 | || ptDepth == SVGA3D_MOBFMT_PTDEPTH_1
|
---|
425 | || ptDepth == SVGA3D_MOBFMT_PTDEPTH_2)
|
---|
426 | {
|
---|
427 | fGCPhys64 = false;
|
---|
428 | /* Shift ptDepth to the SVGA3D_MOBFMT_PTDEPTH64_x range. */
|
---|
429 | ptDepth = (SVGAMobFormat)(ptDepth + SVGA3D_MOBFMT_PTDEPTH64_0 - SVGA3D_MOBFMT_PTDEPTH_0);
|
---|
430 | }
|
---|
431 | else if (ptDepth == SVGA3D_MOBFMT_RANGE)
|
---|
432 | fGCPhys64 = false; /* Does not matter, there is no page table. */
|
---|
433 | else
|
---|
434 | ASSERT_GUEST_FAILED_RETURN(VERR_INVALID_PARAMETER);
|
---|
435 |
|
---|
436 | uint32_t const cPPNsPerPage = X86_PAGE_SIZE / (fGCPhys64 ? sizeof(PPN64) : sizeof(PPN));
|
---|
437 |
|
---|
438 | pGbo->cbTotal = sizeInBytes;
|
---|
439 | pGbo->cTotalPages = (sizeInBytes + X86_PAGE_SIZE - 1) >> X86_PAGE_SHIFT;
|
---|
440 |
|
---|
441 | /* Allocate the maximum amount possible (everything non-continuous) */
|
---|
442 | PVMSVGAGBODESCRIPTOR paDescriptors = (PVMSVGAGBODESCRIPTOR)RTMemAlloc(pGbo->cTotalPages * sizeof(VMSVGAGBODESCRIPTOR));
|
---|
443 | AssertReturn(paDescriptors, VERR_NO_MEMORY);
|
---|
444 |
|
---|
445 | int rc = VINF_SUCCESS;
|
---|
446 | if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_0)
|
---|
447 | {
|
---|
448 | ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages == 1,
|
---|
449 | RTMemFree(paDescriptors),
|
---|
450 | VERR_INVALID_PARAMETER);
|
---|
451 |
|
---|
452 | RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
|
---|
453 | GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
|
---|
454 | paDescriptors[0].GCPhys = GCPhys;
|
---|
455 | paDescriptors[0].cPages = 1;
|
---|
456 | }
|
---|
457 | else if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_1)
|
---|
458 | {
|
---|
459 | ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages <= cPPNsPerPage,
|
---|
460 | RTMemFree(paDescriptors),
|
---|
461 | VERR_INVALID_PARAMETER);
|
---|
462 |
|
---|
463 | /* Read the root page. */
|
---|
464 | uint8_t au8RootPage[X86_PAGE_SIZE];
|
---|
465 | RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
|
---|
466 | rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhys, &au8RootPage, sizeof(au8RootPage));
|
---|
467 | if (RT_SUCCESS(rc))
|
---|
468 | {
|
---|
469 | PPN64 *paPPN64 = (PPN64 *)&au8RootPage[0];
|
---|
470 | PPN *paPPN32 = (PPN *)&au8RootPage[0];
|
---|
471 | for (uint32_t iPPN = 0; iPPN < pGbo->cTotalPages; ++iPPN)
|
---|
472 | {
|
---|
473 | GCPhys = (RTGCPHYS)(fGCPhys64 ? paPPN64[iPPN] : paPPN32[iPPN]) << X86_PAGE_SHIFT;
|
---|
474 | GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
|
---|
475 | paDescriptors[iPPN].GCPhys = GCPhys;
|
---|
476 | paDescriptors[iPPN].cPages = 1;
|
---|
477 | }
|
---|
478 | }
|
---|
479 | }
|
---|
480 | else if (ptDepth == SVGA3D_MOBFMT_PTDEPTH64_2)
|
---|
481 | {
|
---|
482 | ASSERT_GUEST_STMT_RETURN(pGbo->cTotalPages <= cPPNsPerPage * cPPNsPerPage,
|
---|
483 | RTMemFree(paDescriptors),
|
---|
484 | VERR_INVALID_PARAMETER);
|
---|
485 |
|
---|
486 | /* Read the Level2 root page. */
|
---|
487 | uint8_t au8RootPageLevel2[X86_PAGE_SIZE];
|
---|
488 | RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
|
---|
489 | rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhys, &au8RootPageLevel2, sizeof(au8RootPageLevel2));
|
---|
490 | if (RT_SUCCESS(rc))
|
---|
491 | {
|
---|
492 | uint32_t cPagesLeft = pGbo->cTotalPages;
|
---|
493 |
|
---|
494 | PPN64 *paPPN64Level2 = (PPN64 *)&au8RootPageLevel2[0];
|
---|
495 | PPN *paPPN32Level2 = (PPN *)&au8RootPageLevel2[0];
|
---|
496 |
|
---|
497 | uint32_t const cPPNsLevel2 = (pGbo->cTotalPages + cPPNsPerPage - 1) / cPPNsPerPage;
|
---|
498 | for (uint32_t iPPNLevel2 = 0; iPPNLevel2 < cPPNsLevel2; ++iPPNLevel2)
|
---|
499 | {
|
---|
500 | /* Read the Level1 root page. */
|
---|
501 | uint8_t au8RootPage[X86_PAGE_SIZE];
|
---|
502 | RTGCPHYS GCPhysLevel1 = (RTGCPHYS)(fGCPhys64 ? paPPN64Level2[iPPNLevel2] : paPPN32Level2[iPPNLevel2]) << X86_PAGE_SHIFT;
|
---|
503 | GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
|
---|
504 | rc = PDMDevHlpPCIPhysRead(pSvgaR3State->pDevIns, GCPhysLevel1, &au8RootPage, sizeof(au8RootPage));
|
---|
505 | if (RT_SUCCESS(rc))
|
---|
506 | {
|
---|
507 | PPN64 *paPPN64 = (PPN64 *)&au8RootPage[0];
|
---|
508 | PPN *paPPN32 = (PPN *)&au8RootPage[0];
|
---|
509 |
|
---|
510 | uint32_t const cPPNs = RT_MIN(cPagesLeft, cPPNsPerPage);
|
---|
511 | for (uint32_t iPPN = 0; iPPN < cPPNs; ++iPPN)
|
---|
512 | {
|
---|
513 | GCPhys = (RTGCPHYS)(fGCPhys64 ? paPPN64[iPPN] : paPPN32[iPPN]) << X86_PAGE_SHIFT;
|
---|
514 | GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
|
---|
515 | paDescriptors[iPPN + iPPNLevel2 * cPPNsPerPage].GCPhys = GCPhys;
|
---|
516 | paDescriptors[iPPN + iPPNLevel2 * cPPNsPerPage].cPages = 1;
|
---|
517 | }
|
---|
518 | cPagesLeft -= cPPNs;
|
---|
519 | }
|
---|
520 | }
|
---|
521 | }
|
---|
522 | }
|
---|
523 | else if (ptDepth == SVGA3D_MOBFMT_RANGE)
|
---|
524 | {
|
---|
525 | RTGCPHYS GCPhys = (RTGCPHYS)baseAddress << X86_PAGE_SHIFT;
|
---|
526 | GCPhys &= UINT64_C(0x00000FFFFFFFFFFF); /* Seeing rubbish in the top bits with certain linux guests. */
|
---|
527 | paDescriptors[0].GCPhys = GCPhys;
|
---|
528 | paDescriptors[0].cPages = pGbo->cTotalPages;
|
---|
529 | }
|
---|
530 | else
|
---|
531 | {
|
---|
532 | AssertFailed();
|
---|
533 | return VERR_INTERNAL_ERROR; /* ptDepth should be already verified. */
|
---|
534 | }
|
---|
535 |
|
---|
536 | /* Compress the descriptors. */
|
---|
537 | if (ptDepth != SVGA3D_MOBFMT_RANGE)
|
---|
538 | {
|
---|
539 | uint32_t iDescriptor = 0;
|
---|
540 | for (uint32_t i = 1; i < pGbo->cTotalPages; ++i)
|
---|
541 | {
|
---|
542 | /* Continuous physical memory? */
|
---|
543 | if (paDescriptors[i].GCPhys == paDescriptors[iDescriptor].GCPhys + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE)
|
---|
544 | {
|
---|
545 | Assert(paDescriptors[iDescriptor].cPages);
|
---|
546 | paDescriptors[iDescriptor].cPages++;
|
---|
547 | Log5Func(("Page %x GCPhys=%RGp successor\n", i, paDescriptors[i].GCPhys));
|
---|
548 | }
|
---|
549 | else
|
---|
550 | {
|
---|
551 | iDescriptor++;
|
---|
552 | paDescriptors[iDescriptor].GCPhys = paDescriptors[i].GCPhys;
|
---|
553 | paDescriptors[iDescriptor].cPages = 1;
|
---|
554 | Log5Func(("Page %x GCPhys=%RGp\n", i, paDescriptors[iDescriptor].GCPhys));
|
---|
555 | }
|
---|
556 | }
|
---|
557 |
|
---|
558 | pGbo->cDescriptors = iDescriptor + 1;
|
---|
559 | Log5Func(("Nr of descriptors %d\n", pGbo->cDescriptors));
|
---|
560 | }
|
---|
561 | else
|
---|
562 | pGbo->cDescriptors = 1;
|
---|
563 |
|
---|
564 | if (RT_LIKELY(pGbo->cDescriptors < pGbo->cTotalPages))
|
---|
565 | {
|
---|
566 | pGbo->paDescriptors = (PVMSVGAGBODESCRIPTOR)RTMemRealloc(paDescriptors, pGbo->cDescriptors * sizeof(VMSVGAGBODESCRIPTOR));
|
---|
567 | AssertReturn(pGbo->paDescriptors, VERR_NO_MEMORY);
|
---|
568 | }
|
---|
569 | else
|
---|
570 | pGbo->paDescriptors = paDescriptors;
|
---|
571 |
|
---|
572 | pGbo->fGboFlags = 0;
|
---|
573 | pGbo->pvHost = NULL;
|
---|
574 |
|
---|
575 | return VINF_SUCCESS;
|
---|
576 | }
|
---|
577 |
|
---|
578 |
|
---|
579 | static void vmsvgaR3GboDestroy(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
|
---|
580 | {
|
---|
581 | RT_NOREF(pSvgaR3State);
|
---|
582 |
|
---|
583 | if (RT_LIKELY(VMSVGA_IS_GBO_CREATED(pGbo)))
|
---|
584 | {
|
---|
585 | RTMemFree(pGbo->pvHost);
|
---|
586 | RTMemFree(pGbo->paDescriptors);
|
---|
587 | RT_ZERO(*pGbo);
|
---|
588 | }
|
---|
589 | }
|
---|
590 |
|
---|
591 | /** @todo static void vmsvgaR3GboWriteProtect(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo, bool fWriteProtect) */
|
---|
592 |
|
---|
593 | typedef enum VMSVGAGboTransferDirection
|
---|
594 | {
|
---|
595 | VMSVGAGboTransferDirection_Read,
|
---|
596 | VMSVGAGboTransferDirection_Write,
|
---|
597 | } VMSVGAGboTransferDirection;
|
---|
598 |
|
---|
599 | static int vmsvgaR3GboTransfer(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
|
---|
600 | uint32_t off, void *pvData, uint32_t cbData,
|
---|
601 | VMSVGAGboTransferDirection enmDirection)
|
---|
602 | {
|
---|
603 | //DEBUG_BREAKPOINT_TEST();
|
---|
604 | int rc = VINF_SUCCESS;
|
---|
605 | uint8_t *pu8CurrentHost = (uint8_t *)pvData;
|
---|
606 |
|
---|
607 | /* Find the right descriptor */
|
---|
608 | PCVMSVGAGBODESCRIPTOR const paDescriptors = pGbo->paDescriptors;
|
---|
609 | uint32_t iDescriptor = 0; /* Index in the descriptor array. */
|
---|
610 | uint32_t offDescriptor = 0; /* GMR offset of the current descriptor. */
|
---|
611 | while (offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE <= off)
|
---|
612 | {
|
---|
613 | offDescriptor += paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE;
|
---|
614 | AssertReturn(offDescriptor < pGbo->cbTotal, VERR_INTERNAL_ERROR); /* overflow protection */
|
---|
615 | ++iDescriptor;
|
---|
616 | AssertReturn(iDescriptor < pGbo->cDescriptors, VERR_INTERNAL_ERROR);
|
---|
617 | }
|
---|
618 |
|
---|
619 | while (cbData)
|
---|
620 | {
|
---|
621 | uint32_t cbToCopy;
|
---|
622 | if (off + cbData <= offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE)
|
---|
623 | cbToCopy = cbData;
|
---|
624 | else
|
---|
625 | {
|
---|
626 | cbToCopy = (offDescriptor + paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE - off);
|
---|
627 | AssertReturn(cbToCopy <= cbData, VERR_INVALID_PARAMETER);
|
---|
628 | }
|
---|
629 |
|
---|
630 | RTGCPHYS const GCPhys = paDescriptors[iDescriptor].GCPhys + off - offDescriptor;
|
---|
631 | Log5Func(("%s phys=%RGp\n", (enmDirection == VMSVGAGboTransferDirection_Read) ? "READ" : "WRITE", GCPhys));
|
---|
632 |
|
---|
633 | /*
|
---|
634 | * We are deliberately using the non-PCI version of PDMDevHlpPCIPhys[Read|Write] as the
|
---|
635 | * guest-side VMSVGA driver seems to allocate non-DMA (regular physical) addresses,
|
---|
636 | * see @bugref{9654#c75}.
|
---|
637 | */
|
---|
638 | if (enmDirection == VMSVGAGboTransferDirection_Read)
|
---|
639 | rc = PDMDevHlpPhysRead(pSvgaR3State->pDevIns, GCPhys, pu8CurrentHost, cbToCopy);
|
---|
640 | else
|
---|
641 | rc = PDMDevHlpPhysWrite(pSvgaR3State->pDevIns, GCPhys, pu8CurrentHost, cbToCopy);
|
---|
642 | AssertRCBreak(rc);
|
---|
643 |
|
---|
644 | cbData -= cbToCopy;
|
---|
645 | off += cbToCopy;
|
---|
646 | pu8CurrentHost += cbToCopy;
|
---|
647 |
|
---|
648 | /* Go to the next descriptor if there's anything left. */
|
---|
649 | if (cbData)
|
---|
650 | {
|
---|
651 | offDescriptor += paDescriptors[iDescriptor].cPages * X86_PAGE_SIZE;
|
---|
652 | AssertReturn(offDescriptor < pGbo->cbTotal, VERR_INTERNAL_ERROR);
|
---|
653 | ++iDescriptor;
|
---|
654 | AssertReturn(iDescriptor < pGbo->cDescriptors, VERR_INTERNAL_ERROR);
|
---|
655 | }
|
---|
656 | }
|
---|
657 | return rc;
|
---|
658 | }
|
---|
659 |
|
---|
660 |
|
---|
661 | static int vmsvgaR3GboWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
|
---|
662 | uint32_t off, void const *pvData, uint32_t cbData)
|
---|
663 | {
|
---|
664 | return vmsvgaR3GboTransfer(pSvgaR3State, pGbo,
|
---|
665 | off, (void *)pvData, cbData,
|
---|
666 | VMSVGAGboTransferDirection_Write);
|
---|
667 | }
|
---|
668 |
|
---|
669 |
|
---|
670 | static int vmsvgaR3GboRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo,
|
---|
671 | uint32_t off, void *pvData, uint32_t cbData)
|
---|
672 | {
|
---|
673 | return vmsvgaR3GboTransfer(pSvgaR3State, pGbo,
|
---|
674 | off, pvData, cbData,
|
---|
675 | VMSVGAGboTransferDirection_Read);
|
---|
676 | }
|
---|
677 |
|
---|
678 |
|
---|
679 | static int vmsvgaR3GboBackingStoreCreate(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo, uint32_t cbValid)
|
---|
680 | {
|
---|
681 | int rc;
|
---|
682 |
|
---|
683 | /* Just reread the data if pvHost has been allocated already. */
|
---|
684 | if (!(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED))
|
---|
685 | pGbo->pvHost = RTMemAllocZ(pGbo->cbTotal);
|
---|
686 |
|
---|
687 | if (pGbo->pvHost)
|
---|
688 | {
|
---|
689 | cbValid = RT_MIN(cbValid, pGbo->cbTotal);
|
---|
690 | rc = vmsvgaR3GboRead(pSvgaR3State, pGbo, 0, pGbo->pvHost, cbValid);
|
---|
691 | }
|
---|
692 | else
|
---|
693 | rc = VERR_NO_MEMORY;
|
---|
694 |
|
---|
695 | if (RT_SUCCESS(rc))
|
---|
696 | pGbo->fGboFlags |= VMSVGAGBO_F_HOST_BACKED;
|
---|
697 | else
|
---|
698 | {
|
---|
699 | RTMemFree(pGbo->pvHost);
|
---|
700 | pGbo->pvHost = NULL;
|
---|
701 | }
|
---|
702 | return rc;
|
---|
703 | }
|
---|
704 |
|
---|
705 |
|
---|
706 | static void vmsvgaR3GboBackingStoreDelete(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
|
---|
707 | {
|
---|
708 | RT_NOREF(pSvgaR3State);
|
---|
709 | AssertReturnVoid(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED);
|
---|
710 | RTMemFree(pGbo->pvHost);
|
---|
711 | pGbo->pvHost = NULL;
|
---|
712 | pGbo->fGboFlags &= ~VMSVGAGBO_F_HOST_BACKED;
|
---|
713 | }
|
---|
714 |
|
---|
715 |
|
---|
716 | static int vmsvgaR3GboBackingStoreWriteToGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
|
---|
717 | {
|
---|
718 | AssertReturn(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED, VERR_INVALID_STATE);
|
---|
719 | return vmsvgaR3GboWrite(pSvgaR3State, pGbo, 0, pGbo->pvHost, pGbo->cbTotal);
|
---|
720 | }
|
---|
721 |
|
---|
722 |
|
---|
723 | static int vmsvgaR3GboBackingStoreReadFromGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo)
|
---|
724 | {
|
---|
725 | AssertReturn(pGbo->fGboFlags & VMSVGAGBO_F_HOST_BACKED, VERR_INVALID_STATE);
|
---|
726 | return vmsvgaR3GboRead(pSvgaR3State, pGbo, 0, pGbo->pvHost, pGbo->cbTotal);
|
---|
727 | }
|
---|
728 |
|
---|
729 | static int vmsvgaR3GboCopy(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboDst, uint32_t offDst,
|
---|
730 | PVMSVGAGBO pGboSrc, uint32_t offSrc, uint32_t cbCopy)
|
---|
731 | {
|
---|
732 | uint32_t const cbTmpBuf = GUEST_PAGE_SIZE;
|
---|
733 | void *pvTmpBuf = RTMemTmpAlloc(cbTmpBuf);
|
---|
734 | AssertPtrReturn(pvTmpBuf, VERR_NO_MEMORY);
|
---|
735 |
|
---|
736 | int rc = VINF_SUCCESS;
|
---|
737 | while (cbCopy > 0)
|
---|
738 | {
|
---|
739 | uint32_t const cbToCopy = RT_MIN(cbTmpBuf, cbCopy);
|
---|
740 |
|
---|
741 | rc = vmsvgaR3GboRead(pSvgaR3State, pGboSrc, offSrc, pvTmpBuf, cbToCopy);
|
---|
742 | AssertRCBreak(rc);
|
---|
743 |
|
---|
744 | rc = vmsvgaR3GboWrite(pSvgaR3State, pGboDst, offDst, pvTmpBuf, cbToCopy);
|
---|
745 | AssertRCBreak(rc);
|
---|
746 |
|
---|
747 | offSrc += cbToCopy;
|
---|
748 | offDst += cbToCopy;
|
---|
749 | cbCopy -= cbToCopy;
|
---|
750 | }
|
---|
751 |
|
---|
752 | RTMemTmpFree(pvTmpBuf);
|
---|
753 | return rc;
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | /*
|
---|
758 | *
|
---|
759 | * Object Tables.
|
---|
760 | *
|
---|
761 | */
|
---|
762 |
|
---|
763 | static int vmsvgaR3OTableSetOrGrow(PVMSVGAR3STATE pSvgaR3State, SVGAOTableType type, PPN64 baseAddress,
|
---|
764 | uint32_t sizeInBytes, uint32 validSizeInBytes, SVGAMobFormat ptDepth, bool fGrow)
|
---|
765 | {
|
---|
766 | ASSERT_GUEST_RETURN(type < RT_ELEMENTS(pSvgaR3State->aGboOTables), VERR_INVALID_PARAMETER);
|
---|
767 | ASSERT_GUEST_RETURN(sizeInBytes >= validSizeInBytes, VERR_INVALID_PARAMETER);
|
---|
768 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
769 |
|
---|
770 | ASSERT_GUEST_RETURN(pSvgaR3State->aGboOTables[type].cbTotal >= validSizeInBytes, VERR_INVALID_PARAMETER);
|
---|
771 |
|
---|
772 | if (sizeInBytes > 0)
|
---|
773 | {
|
---|
774 | /* Create a new guest backed object for the object table. */
|
---|
775 | VMSVGAGBO gbo;
|
---|
776 | int rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, &gbo);
|
---|
777 | AssertRCReturn(rc, rc);
|
---|
778 |
|
---|
779 | /* If the guest sets a new OTable (fGrow == false), then it has already copied the valid data to the new GBO. */
|
---|
780 | if (fGrow && validSizeInBytes)
|
---|
781 | {
|
---|
782 | /* Copy data from old gbo to the new one. */
|
---|
783 | rc = vmsvgaR3GboCopy(pSvgaR3State, &gbo, 0, &pSvgaR3State->aGboOTables[type], 0, validSizeInBytes);
|
---|
784 | AssertRCReturnStmt(rc, vmsvgaR3GboDestroy(pSvgaR3State, &gbo), rc);
|
---|
785 | }
|
---|
786 |
|
---|
787 | vmsvgaR3GboDestroy(pSvgaR3State, &pSvgaR3State->aGboOTables[type]);
|
---|
788 | pSvgaR3State->aGboOTables[type] = gbo;
|
---|
789 |
|
---|
790 | }
|
---|
791 | else
|
---|
792 | vmsvgaR3GboDestroy(pSvgaR3State, &pSvgaR3State->aGboOTables[type]);
|
---|
793 |
|
---|
794 | return VINF_SUCCESS;
|
---|
795 | }
|
---|
796 |
|
---|
797 |
|
---|
798 | static int vmsvgaR3OTableVerifyIndex(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
|
---|
799 | uint32_t idx, uint32_t cbEntry)
|
---|
800 | {
|
---|
801 | RT_NOREF(pSvgaR3State);
|
---|
802 |
|
---|
803 | /* The table must exist and the index must be within the table. */
|
---|
804 | ASSERT_GUEST_RETURN(VMSVGA_IS_GBO_CREATED(pGboOTable), VERR_INVALID_PARAMETER);
|
---|
805 | ASSERT_GUEST_RETURN(idx < pGboOTable->cbTotal / cbEntry, VERR_INVALID_PARAMETER);
|
---|
806 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
807 | return VINF_SUCCESS;
|
---|
808 | }
|
---|
809 |
|
---|
810 |
|
---|
811 | static int vmsvgaR3OTableRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
|
---|
812 | uint32_t idx, uint32_t cbEntry,
|
---|
813 | void *pvData, uint32_t cbData)
|
---|
814 | {
|
---|
815 | AssertReturn(cbData <= cbEntry, VERR_INVALID_PARAMETER);
|
---|
816 |
|
---|
817 | int rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, pGboOTable, idx, cbEntry);
|
---|
818 | if (RT_SUCCESS(rc))
|
---|
819 | {
|
---|
820 | uint32_t const off = idx * cbEntry;
|
---|
821 | rc = vmsvgaR3GboRead(pSvgaR3State, pGboOTable, off, pvData, cbData);
|
---|
822 | }
|
---|
823 | return rc;
|
---|
824 | }
|
---|
825 |
|
---|
826 | static int vmsvgaR3OTableWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGboOTable,
|
---|
827 | uint32_t idx, uint32_t cbEntry,
|
---|
828 | void const *pvData, uint32_t cbData)
|
---|
829 | {
|
---|
830 | AssertReturn(cbData <= cbEntry, VERR_INVALID_PARAMETER);
|
---|
831 |
|
---|
832 | int rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, pGboOTable, idx, cbEntry);
|
---|
833 | if (RT_SUCCESS(rc))
|
---|
834 | {
|
---|
835 | uint32_t const off = idx * cbEntry;
|
---|
836 | rc = vmsvgaR3GboWrite(pSvgaR3State, pGboOTable, off, pvData, cbData);
|
---|
837 | }
|
---|
838 | return rc;
|
---|
839 | }
|
---|
840 |
|
---|
841 |
|
---|
842 | int vmsvgaR3OTableReadSurface(PVMSVGAR3STATE pSvgaR3State, uint32_t sid, SVGAOTableSurfaceEntry *pEntrySurface)
|
---|
843 | {
|
---|
844 | return vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
845 | sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, pEntrySurface, sizeof(SVGAOTableSurfaceEntry));
|
---|
846 | }
|
---|
847 |
|
---|
848 |
|
---|
849 | /*
|
---|
850 | *
|
---|
851 | * The guest's Memory OBjects (MOB).
|
---|
852 | *
|
---|
853 | */
|
---|
854 |
|
---|
855 | static int vmsvgaR3MobCreate(PVMSVGAR3STATE pSvgaR3State,
|
---|
856 | SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, SVGAMobId mobid,
|
---|
857 | PVMSVGAMOB pMob)
|
---|
858 | {
|
---|
859 | RT_ZERO(*pMob);
|
---|
860 |
|
---|
861 | /* Update the entry in the pSvgaR3State->pGboOTableMob. */
|
---|
862 | SVGAOTableMobEntry entry;
|
---|
863 | entry.ptDepth = ptDepth;
|
---|
864 | entry.sizeInBytes = sizeInBytes;
|
---|
865 | entry.base = baseAddress;
|
---|
866 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
|
---|
867 | mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
868 | if (RT_SUCCESS(rc))
|
---|
869 | {
|
---|
870 | /* Create the corresponding GBO. */
|
---|
871 | rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, &pMob->Gbo);
|
---|
872 | if (RT_SUCCESS(rc))
|
---|
873 | {
|
---|
874 | /* If a mob with this id already exists, then delete it. */
|
---|
875 | PVMSVGAMOB pOldMob = (PVMSVGAMOB)RTAvlU32Remove(&pSvgaR3State->MOBTree, mobid);
|
---|
876 | if (pOldMob)
|
---|
877 | {
|
---|
878 | /* This should not happen. */
|
---|
879 | ASSERT_GUEST_FAILED();
|
---|
880 | RTListNodeRemove(&pOldMob->nodeLRU);
|
---|
881 | vmsvgaR3GboDestroy(pSvgaR3State, &pOldMob->Gbo);
|
---|
882 | RTMemFree(pOldMob);
|
---|
883 | }
|
---|
884 |
|
---|
885 | /* Add to the tree of known MOBs and the LRU list. */
|
---|
886 | pMob->Core.Key = mobid;
|
---|
887 | if (RTAvlU32Insert(&pSvgaR3State->MOBTree, &pMob->Core))
|
---|
888 | {
|
---|
889 | RTListPrepend(&pSvgaR3State->MOBLRUList, &pMob->nodeLRU);
|
---|
890 | return VINF_SUCCESS;
|
---|
891 | }
|
---|
892 |
|
---|
893 | AssertFailedStmt(rc = VERR_INVALID_STATE);
|
---|
894 | vmsvgaR3GboDestroy(pSvgaR3State, &pMob->Gbo);
|
---|
895 | }
|
---|
896 | }
|
---|
897 |
|
---|
898 | return rc;
|
---|
899 | }
|
---|
900 |
|
---|
901 |
|
---|
902 | static void vmsvgaR3MobFree(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
|
---|
903 | {
|
---|
904 | vmsvgaR3GboDestroy(pSvgaR3State, &pMob->Gbo);
|
---|
905 | RTMemFree(pMob);
|
---|
906 | }
|
---|
907 |
|
---|
908 |
|
---|
909 | static int vmsvgaR3MobDestroy(PVMSVGAR3STATE pSvgaR3State, SVGAMobId mobid)
|
---|
910 | {
|
---|
911 | /* Update the entry in the pSvgaR3State->pGboOTableMob. */
|
---|
912 | SVGAOTableMobEntry entry;
|
---|
913 | RT_ZERO(entry);
|
---|
914 | vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
|
---|
915 | mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
916 |
|
---|
917 | PVMSVGAMOB pMob = (PVMSVGAMOB)RTAvlU32Remove(&pSvgaR3State->MOBTree, mobid);
|
---|
918 | if (pMob)
|
---|
919 | {
|
---|
920 | RTListNodeRemove(&pMob->nodeLRU);
|
---|
921 | vmsvgaR3MobFree(pSvgaR3State, pMob);
|
---|
922 | return VINF_SUCCESS;
|
---|
923 | }
|
---|
924 |
|
---|
925 | return VERR_INVALID_PARAMETER;
|
---|
926 | }
|
---|
927 |
|
---|
928 |
|
---|
929 | PVMSVGAMOB vmsvgaR3MobGet(PVMSVGAR3STATE pSvgaR3State, SVGAMobId RT_UNTRUSTED_GUEST mobid)
|
---|
930 | {
|
---|
931 | if (mobid == SVGA_ID_INVALID)
|
---|
932 | return NULL;
|
---|
933 |
|
---|
934 | PVMSVGAMOB pMob = (PVMSVGAMOB)RTAvlU32Get(&pSvgaR3State->MOBTree, mobid);
|
---|
935 | if (pMob)
|
---|
936 | {
|
---|
937 | /* Move to the head of the LRU list. */
|
---|
938 | RTListNodeRemove(&pMob->nodeLRU);
|
---|
939 | RTListPrepend(&pSvgaR3State->MOBLRUList, &pMob->nodeLRU);
|
---|
940 | }
|
---|
941 | else
|
---|
942 | ASSERT_GUEST_FAILED();
|
---|
943 |
|
---|
944 | return pMob;
|
---|
945 | }
|
---|
946 |
|
---|
947 |
|
---|
948 | int vmsvgaR3MobWrite(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob,
|
---|
949 | uint32_t off, void const *pvData, uint32_t cbData)
|
---|
950 | {
|
---|
951 | return vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, off, pvData, cbData);
|
---|
952 | }
|
---|
953 |
|
---|
954 |
|
---|
955 | int vmsvgaR3MobRead(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob,
|
---|
956 | uint32_t off, void *pvData, uint32_t cbData)
|
---|
957 | {
|
---|
958 | return vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, off, pvData, cbData);
|
---|
959 | }
|
---|
960 |
|
---|
961 |
|
---|
962 | /** Create a host ring-3 pointer to the MOB data.
|
---|
963 | * Current approach is to allocate a host memory buffer and copy the guest MOB data if necessary.
|
---|
964 | * @param pSvgaR3State R3 device state.
|
---|
965 | * @param pMob The MOB.
|
---|
966 | * @param cbValid How many bytes of the guest backing memory contain valid data.
|
---|
967 | * @return VBox status.
|
---|
968 | */
|
---|
969 | /** @todo uint32_t cbValid -> uint32_t offStart, uint32_t cbData */
|
---|
970 | int vmsvgaR3MobBackingStoreCreate(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob, uint32_t cbValid)
|
---|
971 | {
|
---|
972 | AssertReturn(pMob, VERR_INVALID_PARAMETER);
|
---|
973 | return vmsvgaR3GboBackingStoreCreate(pSvgaR3State, &pMob->Gbo, cbValid);
|
---|
974 | }
|
---|
975 |
|
---|
976 |
|
---|
977 | void vmsvgaR3MobBackingStoreDelete(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
|
---|
978 | {
|
---|
979 | if (pMob)
|
---|
980 | vmsvgaR3GboBackingStoreDelete(pSvgaR3State, &pMob->Gbo);
|
---|
981 | }
|
---|
982 |
|
---|
983 |
|
---|
984 | int vmsvgaR3MobBackingStoreWriteToGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
|
---|
985 | {
|
---|
986 | if (pMob)
|
---|
987 | return vmsvgaR3GboBackingStoreWriteToGuest(pSvgaR3State, &pMob->Gbo);
|
---|
988 | return VERR_INVALID_PARAMETER;
|
---|
989 | }
|
---|
990 |
|
---|
991 |
|
---|
992 | int vmsvgaR3MobBackingStoreReadFromGuest(PVMSVGAR3STATE pSvgaR3State, PVMSVGAMOB pMob)
|
---|
993 | {
|
---|
994 | if (pMob)
|
---|
995 | return vmsvgaR3GboBackingStoreReadFromGuest(pSvgaR3State, &pMob->Gbo);
|
---|
996 | return VERR_INVALID_PARAMETER;
|
---|
997 | }
|
---|
998 |
|
---|
999 |
|
---|
1000 | void *vmsvgaR3MobBackingStorePtr(PVMSVGAMOB pMob, uint32_t off)
|
---|
1001 | {
|
---|
1002 | if (pMob && (pMob->Gbo.fGboFlags & VMSVGAGBO_F_HOST_BACKED))
|
---|
1003 | {
|
---|
1004 | if (off <= pMob->Gbo.cbTotal)
|
---|
1005 | return (uint8_t *)pMob->Gbo.pvHost + off;
|
---|
1006 | }
|
---|
1007 | return NULL;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 |
|
---|
1011 | static DECLCALLBACK(int) vmsvgaR3MobFreeCb(PAVLU32NODECORE pNode, void *pvUser)
|
---|
1012 | {
|
---|
1013 | PVMSVGAMOB pMob = (PVMSVGAMOB)pNode;
|
---|
1014 | PVMSVGAR3STATE pSvgaR3State = (PVMSVGAR3STATE)pvUser;
|
---|
1015 | vmsvgaR3MobFree(pSvgaR3State, pMob);
|
---|
1016 | return 0;
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 |
|
---|
1020 | #endif /* VBOX_WITH_VMSVGA3D */
|
---|
1021 |
|
---|
1022 |
|
---|
1023 |
|
---|
1024 | void vmsvgaR3ResetSvgaState(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
1025 | {
|
---|
1026 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
1027 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1028 | RT_NOREF(pThis);
|
---|
1029 |
|
---|
1030 | RTAvlU32Destroy(&pSvgaR3State->MOBTree, vmsvgaR3MobFreeCb, pSvgaR3State);
|
---|
1031 | RTListInit(&pSvgaR3State->MOBLRUList);
|
---|
1032 |
|
---|
1033 | for (unsigned i = 0; i < RT_ELEMENTS(pSvgaR3State->aGboOTables); ++i)
|
---|
1034 | vmsvgaR3GboDestroy(pSvgaR3State, &pSvgaR3State->aGboOTables[i]);
|
---|
1035 | #else
|
---|
1036 | RT_NOREF(pThis, pThisCC);
|
---|
1037 | #endif
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 |
|
---|
1041 | void vmsvgaR3TerminateSvgaState(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
1042 | {
|
---|
1043 | vmsvgaR3ResetSvgaState(pThis, pThisCC);
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | /*
|
---|
1048 | * Screen objects.
|
---|
1049 | */
|
---|
1050 | VMSVGASCREENOBJECT *vmsvgaR3GetScreenObject(PVGASTATECC pThisCC, uint32_t idScreen)
|
---|
1051 | {
|
---|
1052 | PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State;
|
---|
1053 | if ( idScreen < (uint32_t)RT_ELEMENTS(pSVGAState->aScreens)
|
---|
1054 | && pSVGAState
|
---|
1055 | && pSVGAState->aScreens[idScreen].fDefined)
|
---|
1056 | {
|
---|
1057 | Assert(pSVGAState->aScreens[idScreen].idScreen == idScreen);
|
---|
1058 | return &pSVGAState->aScreens[idScreen];
|
---|
1059 | }
|
---|
1060 | return NULL;
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 |
|
---|
1064 | int vmsvgaR3DestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen)
|
---|
1065 | {
|
---|
1066 | pScreen->fModified = true;
|
---|
1067 | pScreen->fDefined = false;
|
---|
1068 |
|
---|
1069 | /* Notify frontend that the screen is about to be deleted. */
|
---|
1070 | vmsvgaR3ChangeMode(pThis, pThisCC);
|
---|
1071 |
|
---|
1072 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
1073 | if (RT_LIKELY(pThis->svga.f3DEnabled))
|
---|
1074 | vmsvga3dDestroyScreen(pThisCC, pScreen);
|
---|
1075 | #endif
|
---|
1076 |
|
---|
1077 | RTMemFree(pScreen->pvScreenBitmap);
|
---|
1078 | pScreen->pvScreenBitmap = NULL;
|
---|
1079 |
|
---|
1080 | return VINF_SUCCESS;
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 |
|
---|
1084 | void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC)
|
---|
1085 | {
|
---|
1086 | for (uint32_t idScreen = 0; idScreen < (uint32_t)RT_ELEMENTS(pThisCC->svga.pSvgaR3State->aScreens); ++idScreen)
|
---|
1087 | {
|
---|
1088 | VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, idScreen);
|
---|
1089 | if (pScreen)
|
---|
1090 | vmsvgaR3DestroyScreen(pThis, pThisCC, pScreen);
|
---|
1091 | }
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 |
|
---|
1095 | /**
|
---|
1096 | * Copy a rectangle of pixels within guest VRAM.
|
---|
1097 | */
|
---|
1098 | static void vmsvgaR3RectCopy(PVGASTATECC pThisCC, VMSVGASCREENOBJECT const *pScreen, uint32_t srcX, uint32_t srcY,
|
---|
1099 | uint32_t dstX, uint32_t dstY, uint32_t width, uint32_t height, unsigned cbFrameBuffer)
|
---|
1100 | {
|
---|
1101 | if (!width || !height)
|
---|
1102 | return; /* Nothing to do, don't even bother. */
|
---|
1103 |
|
---|
1104 | /*
|
---|
1105 | * The guest VRAM (aka GFB) is considered to be a bitmap in the format
|
---|
1106 | * corresponding to the current display mode.
|
---|
1107 | */
|
---|
1108 | uint32_t const cbPixel = RT_ALIGN(pScreen->cBpp, 8) / 8;
|
---|
1109 | uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch : width * cbPixel;
|
---|
1110 | uint8_t const *pSrc;
|
---|
1111 | uint8_t *pDst;
|
---|
1112 | unsigned const cbRectWidth = width * cbPixel;
|
---|
1113 | unsigned uMaxOffset;
|
---|
1114 |
|
---|
1115 | uMaxOffset = (RT_MAX(srcY, dstY) + height) * cbScanline + (RT_MAX(srcX, dstX) + width) * cbPixel;
|
---|
1116 | if (uMaxOffset >= cbFrameBuffer)
|
---|
1117 | {
|
---|
1118 | Log(("Max offset (%u) too big for framebuffer (%u bytes), ignoring!\n", uMaxOffset, cbFrameBuffer));
|
---|
1119 | return; /* Just don't listen to a bad guest. */
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | pSrc = pDst = pThisCC->pbVRam;
|
---|
1123 | pSrc += srcY * cbScanline + srcX * cbPixel;
|
---|
1124 | pDst += dstY * cbScanline + dstX * cbPixel;
|
---|
1125 |
|
---|
1126 | if (srcY >= dstY)
|
---|
1127 | {
|
---|
1128 | /* Source below destination, copy top to bottom. */
|
---|
1129 | for (; height > 0; height--)
|
---|
1130 | {
|
---|
1131 | memmove(pDst, pSrc, cbRectWidth);
|
---|
1132 | pSrc += cbScanline;
|
---|
1133 | pDst += cbScanline;
|
---|
1134 | }
|
---|
1135 | }
|
---|
1136 | else
|
---|
1137 | {
|
---|
1138 | /* Source above destination, copy bottom to top. */
|
---|
1139 | pSrc += cbScanline * (height - 1);
|
---|
1140 | pDst += cbScanline * (height - 1);
|
---|
1141 | for (; height > 0; height--)
|
---|
1142 | {
|
---|
1143 | memmove(pDst, pSrc, cbRectWidth);
|
---|
1144 | pSrc -= cbScanline;
|
---|
1145 | pDst -= cbScanline;
|
---|
1146 | }
|
---|
1147 | }
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 |
|
---|
1151 | /**
|
---|
1152 | * Common worker for changing the pointer shape.
|
---|
1153 | *
|
---|
1154 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
1155 | * @param pSVGAState The VMSVGA ring-3 instance data.
|
---|
1156 | * @param fAlpha Whether there is alpha or not.
|
---|
1157 | * @param xHot Hotspot x coordinate.
|
---|
1158 | * @param yHot Hotspot y coordinate.
|
---|
1159 | * @param cx Width.
|
---|
1160 | * @param cy Height.
|
---|
1161 | * @param pbData Heap copy of the cursor data. Consumed.
|
---|
1162 | * @param cbData The size of the data.
|
---|
1163 | */
|
---|
1164 | static void vmsvgaR3InstallNewCursor(PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState, bool fAlpha,
|
---|
1165 | uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, uint8_t *pbData, uint32_t cbData)
|
---|
1166 | {
|
---|
1167 | LogRel2(("vmsvgaR3InstallNewCursor: cx=%d cy=%d xHot=%d yHot=%d fAlpha=%d cbData=%#x\n", cx, cy, xHot, yHot, fAlpha, cbData));
|
---|
1168 | #ifdef LOG_ENABLED
|
---|
1169 | if (LogIs2Enabled())
|
---|
1170 | {
|
---|
1171 | uint32_t cbAndLine = RT_ALIGN(cx, 8) / 8;
|
---|
1172 | if (!fAlpha)
|
---|
1173 | {
|
---|
1174 | Log2(("VMSVGA Cursor AND mask (%d,%d):\n", cx, cy));
|
---|
1175 | for (uint32_t y = 0; y < cy; y++)
|
---|
1176 | {
|
---|
1177 | Log2(("%3u:", y));
|
---|
1178 | uint8_t const *pbLine = &pbData[y * cbAndLine];
|
---|
1179 | for (uint32_t x = 0; x < cx; x += 8)
|
---|
1180 | {
|
---|
1181 | uint8_t b = pbLine[x / 8];
|
---|
1182 | char szByte[12];
|
---|
1183 | szByte[0] = b & 0x80 ? '*' : ' '; /* most significant bit first */
|
---|
1184 | szByte[1] = b & 0x40 ? '*' : ' ';
|
---|
1185 | szByte[2] = b & 0x20 ? '*' : ' ';
|
---|
1186 | szByte[3] = b & 0x10 ? '*' : ' ';
|
---|
1187 | szByte[4] = b & 0x08 ? '*' : ' ';
|
---|
1188 | szByte[5] = b & 0x04 ? '*' : ' ';
|
---|
1189 | szByte[6] = b & 0x02 ? '*' : ' ';
|
---|
1190 | szByte[7] = b & 0x01 ? '*' : ' ';
|
---|
1191 | szByte[8] = '\0';
|
---|
1192 | Log2(("%s", szByte));
|
---|
1193 | }
|
---|
1194 | Log2(("\n"));
|
---|
1195 | }
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 | Log2(("VMSVGA Cursor XOR mask (%d,%d):\n", cx, cy));
|
---|
1199 | uint32_t const *pu32Xor = (uint32_t const *)&pbData[RT_ALIGN_32(cbAndLine * cy, 4)];
|
---|
1200 | for (uint32_t y = 0; y < cy; y++)
|
---|
1201 | {
|
---|
1202 | Log2(("%3u:", y));
|
---|
1203 | uint32_t const *pu32Line = &pu32Xor[y * cx];
|
---|
1204 | for (uint32_t x = 0; x < cx; x++)
|
---|
1205 | Log2((" %08x", pu32Line[x]));
|
---|
1206 | Log2(("\n"));
|
---|
1207 | }
|
---|
1208 | }
|
---|
1209 | #endif
|
---|
1210 |
|
---|
1211 | int rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, true /*fVisible*/, fAlpha, xHot, yHot, cx, cy, pbData);
|
---|
1212 | AssertRC(rc);
|
---|
1213 |
|
---|
1214 | if (pSVGAState->Cursor.fActive)
|
---|
1215 | RTMemFreeZ(pSVGAState->Cursor.pData, pSVGAState->Cursor.cbData);
|
---|
1216 |
|
---|
1217 | pSVGAState->Cursor.fActive = true;
|
---|
1218 | pSVGAState->Cursor.xHotspot = xHot;
|
---|
1219 | pSVGAState->Cursor.yHotspot = yHot;
|
---|
1220 | pSVGAState->Cursor.width = cx;
|
---|
1221 | pSVGAState->Cursor.height = cy;
|
---|
1222 | pSVGAState->Cursor.cbData = cbData;
|
---|
1223 | pSVGAState->Cursor.pData = pbData;
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 |
|
---|
1227 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
1228 |
|
---|
1229 | /*
|
---|
1230 | * SVGA_3D_CMD_* handlers.
|
---|
1231 | */
|
---|
1232 |
|
---|
1233 |
|
---|
1234 | /** SVGA_3D_CMD_SURFACE_DEFINE 1040, SVGA_3D_CMD_SURFACE_DEFINE_V2 1070
|
---|
1235 | *
|
---|
1236 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
1237 | * @param pCmd The VMSVGA command.
|
---|
1238 | * @param cMipLevelSizes Number of elements in the paMipLevelSizes array.
|
---|
1239 | * @param paMipLevelSizes Arrays of surface sizes for each face and miplevel.
|
---|
1240 | */
|
---|
1241 | static void vmsvga3dCmdDefineSurface(PVGASTATECC pThisCC, SVGA3dCmdDefineSurface_v2 const *pCmd,
|
---|
1242 | uint32_t cMipLevelSizes, SVGA3dSize *paMipLevelSizes)
|
---|
1243 | {
|
---|
1244 | ASSERT_GUEST_RETURN_VOID(pCmd->sid < SVGA3D_MAX_SURFACE_IDS);
|
---|
1245 | ASSERT_GUEST_RETURN_VOID(cMipLevelSizes >= 1);
|
---|
1246 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1247 |
|
---|
1248 | /* Number of faces (cFaces) is specified as the number of the first non-zero elements in the 'face' array.
|
---|
1249 | * Since only plain surfaces (cFaces == 1) and cubemaps (cFaces == 6) are supported
|
---|
1250 | * (see also SVGA3dCmdDefineSurface definition in svga3d_reg.h), we ignore anything else.
|
---|
1251 | */
|
---|
1252 | uint32_t cRemainingMipLevels = cMipLevelSizes;
|
---|
1253 | uint32_t cFaces = 0;
|
---|
1254 | for (uint32_t i = 0; i < SVGA3D_MAX_SURFACE_FACES; ++i)
|
---|
1255 | {
|
---|
1256 | if (pCmd->face[i].numMipLevels == 0)
|
---|
1257 | break;
|
---|
1258 |
|
---|
1259 | /* All SVGA3dSurfaceFace structures must have the same value of numMipLevels field */
|
---|
1260 | ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels == pCmd->face[0].numMipLevels);
|
---|
1261 |
|
---|
1262 | /* numMipLevels value can't be greater than the number of remaining elements in the paMipLevelSizes array. */
|
---|
1263 | ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels <= cRemainingMipLevels);
|
---|
1264 | cRemainingMipLevels -= pCmd->face[i].numMipLevels;
|
---|
1265 |
|
---|
1266 | ++cFaces;
|
---|
1267 | }
|
---|
1268 | for (uint32_t i = cFaces; i < SVGA3D_MAX_SURFACE_FACES; ++i)
|
---|
1269 | ASSERT_GUEST_RETURN_VOID(pCmd->face[i].numMipLevels == 0);
|
---|
1270 |
|
---|
1271 | /* cFaces must be 6 for a cubemap and 1 otherwise. */
|
---|
1272 | ASSERT_GUEST_RETURN_VOID(cFaces == (uint32_t)((pCmd->surfaceFlags & SVGA3D_SURFACE_CUBEMAP) ? 6 : 1));
|
---|
1273 |
|
---|
1274 | /* Sum of face[i].numMipLevels must be equal to cMipLevels. */
|
---|
1275 | ASSERT_GUEST_RETURN_VOID(cRemainingMipLevels == 0);
|
---|
1276 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1277 |
|
---|
1278 | /* Verify paMipLevelSizes */
|
---|
1279 | uint32_t cWidth = paMipLevelSizes[0].width;
|
---|
1280 | uint32_t cHeight = paMipLevelSizes[0].height;
|
---|
1281 | uint32_t cDepth = paMipLevelSizes[0].depth;
|
---|
1282 | for (uint32_t i = 1; i < pCmd->face[0].numMipLevels; ++i)
|
---|
1283 | {
|
---|
1284 | cWidth >>= 1;
|
---|
1285 | if (cWidth == 0) cWidth = 1;
|
---|
1286 | cHeight >>= 1;
|
---|
1287 | if (cHeight == 0) cHeight = 1;
|
---|
1288 | cDepth >>= 1;
|
---|
1289 | if (cDepth == 0) cDepth = 1;
|
---|
1290 | for (uint32_t iFace = 0; iFace < cFaces; ++iFace)
|
---|
1291 | {
|
---|
1292 | uint32_t const iMipLevelSize = iFace * pCmd->face[0].numMipLevels + i;
|
---|
1293 | ASSERT_GUEST_RETURN_VOID( cWidth == paMipLevelSizes[iMipLevelSize].width
|
---|
1294 | && cHeight == paMipLevelSizes[iMipLevelSize].height
|
---|
1295 | && cDepth == paMipLevelSizes[iMipLevelSize].depth);
|
---|
1296 | }
|
---|
1297 | }
|
---|
1298 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1299 |
|
---|
1300 | /* Create the surface. */
|
---|
1301 | SVGA3dMSPattern const multisamplePattern = pCmd->multisampleCount > 1 ? SVGA3D_MS_PATTERN_STANDARD : SVGA3D_MS_PATTERN_NONE;
|
---|
1302 | SVGA3dMSQualityLevel const qualityLevel = pCmd->multisampleCount > 1 ? SVGA3D_MS_QUALITY_FULL : SVGA3D_MS_QUALITY_NONE;
|
---|
1303 | vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
|
---|
1304 | pCmd->multisampleCount, multisamplePattern, qualityLevel, pCmd->autogenFilter,
|
---|
1305 | pCmd->face[0].numMipLevels, &paMipLevelSizes[0], /* arraySize = */ 0, /* bufferByteStride = */ 0, /* fAllocMipLevels = */ true);
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 |
|
---|
1309 | /* SVGA_3D_CMD_SET_OTABLE_BASE 1091 */
|
---|
1310 | static void vmsvga3dCmdSetOTableBase(PVGASTATECC pThisCC, SVGA3dCmdSetOTableBase const *pCmd)
|
---|
1311 | {
|
---|
1312 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1313 | vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
|
---|
1314 | pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ false);
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 |
|
---|
1318 | /* SVGA_3D_CMD_DEFINE_GB_MOB 1093 */
|
---|
1319 | static void vmsvga3dCmdDefineGBMob(PVGASTATECC pThisCC, SVGA3dCmdDefineGBMob const *pCmd)
|
---|
1320 | {
|
---|
1321 | DEBUG_BREAKPOINT_TEST();
|
---|
1322 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1323 |
|
---|
1324 | ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
|
---|
1325 |
|
---|
1326 | /* Maybe just update the OTable and create Gbo when the MOB is actually accessed? */
|
---|
1327 | /* Allocate a structure for the MOB. */
|
---|
1328 | PVMSVGAMOB pMob = (PVMSVGAMOB)RTMemAllocZ(sizeof(*pMob));
|
---|
1329 | AssertPtrReturnVoid(pMob);
|
---|
1330 |
|
---|
1331 | int rc = vmsvgaR3MobCreate(pSvgaR3State, pCmd->ptDepth, pCmd->base, pCmd->sizeInBytes, pCmd->mobid, pMob);
|
---|
1332 | if (RT_SUCCESS(rc))
|
---|
1333 | {
|
---|
1334 | return;
|
---|
1335 | }
|
---|
1336 |
|
---|
1337 | AssertFailed();
|
---|
1338 |
|
---|
1339 | RTMemFree(pMob);
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 |
|
---|
1343 | /* SVGA_3D_CMD_DESTROY_GB_MOB 1094 */
|
---|
1344 | static void vmsvga3dCmdDestroyGBMob(PVGASTATECC pThisCC, SVGA3dCmdDestroyGBMob const *pCmd)
|
---|
1345 | {
|
---|
1346 | //DEBUG_BREAKPOINT_TEST();
|
---|
1347 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1348 |
|
---|
1349 | ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
|
---|
1350 |
|
---|
1351 | int rc = vmsvgaR3MobDestroy(pSvgaR3State, pCmd->mobid);
|
---|
1352 | if (RT_SUCCESS(rc))
|
---|
1353 | {
|
---|
1354 | return;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | AssertFailed();
|
---|
1358 | }
|
---|
1359 |
|
---|
1360 |
|
---|
1361 | /* SVGA_3D_CMD_DEFINE_GB_SURFACE 1097 */
|
---|
1362 | static void vmsvga3dCmdDefineGBSurface(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface const *pCmd)
|
---|
1363 | {
|
---|
1364 | //DEBUG_BREAKPOINT_TEST();
|
---|
1365 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1366 |
|
---|
1367 | /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
|
---|
1368 | SVGAOTableSurfaceEntry entry;
|
---|
1369 | RT_ZERO(entry);
|
---|
1370 | entry.format = pCmd->format;
|
---|
1371 | entry.surface1Flags = pCmd->surfaceFlags;
|
---|
1372 | entry.numMipLevels = pCmd->numMipLevels;
|
---|
1373 | entry.multisampleCount = pCmd->multisampleCount;
|
---|
1374 | entry.autogenFilter = pCmd->autogenFilter;
|
---|
1375 | entry.size = pCmd->size;
|
---|
1376 | entry.mobid = SVGA_ID_INVALID;
|
---|
1377 | // entry.arraySize = 0;
|
---|
1378 | // entry.mobPitch = 0;
|
---|
1379 | // entry.surface2Flags = 0;
|
---|
1380 | // entry.multisamplePattern = 0;
|
---|
1381 | // entry.qualityLevel = 0;
|
---|
1382 | // entry.bufferByteStride = 0;
|
---|
1383 | // entry.minLOD = 0;
|
---|
1384 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1385 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1386 | if (RT_SUCCESS(rc))
|
---|
1387 | {
|
---|
1388 | /* Create the host surface. */
|
---|
1389 | SVGA3dMSPattern const multisamplePattern = pCmd->multisampleCount > 1 ? SVGA3D_MS_PATTERN_STANDARD : SVGA3D_MS_PATTERN_NONE;
|
---|
1390 | SVGA3dMSQualityLevel const qualityLevel = pCmd->multisampleCount > 1 ? SVGA3D_MS_QUALITY_FULL : SVGA3D_MS_QUALITY_NONE;
|
---|
1391 | vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
|
---|
1392 | pCmd->multisampleCount, multisamplePattern, qualityLevel, pCmd->autogenFilter,
|
---|
1393 | pCmd->numMipLevels, &pCmd->size, /* arraySize = */ 0, /* bufferByteStride = */ 0, /* fAllocMipLevels = */ false);
|
---|
1394 | }
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 |
|
---|
1398 | /* SVGA_3D_CMD_DESTROY_GB_SURFACE 1098 */
|
---|
1399 | static void vmsvga3dCmdDestroyGBSurface(PVGASTATECC pThisCC, SVGA3dCmdDestroyGBSurface const *pCmd)
|
---|
1400 | {
|
---|
1401 | //DEBUG_BREAKPOINT_TEST();
|
---|
1402 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1403 |
|
---|
1404 | /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
|
---|
1405 | SVGAOTableSurfaceEntry entry;
|
---|
1406 | RT_ZERO(entry);
|
---|
1407 | entry.mobid = SVGA_ID_INVALID;
|
---|
1408 | vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1409 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1410 |
|
---|
1411 | vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid);
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 |
|
---|
1415 | /* SVGA_3D_CMD_BIND_GB_SURFACE 1099 */
|
---|
1416 | static void vmsvga3dCmdBindGBSurface(PVGASTATECC pThisCC, SVGA3dCmdBindGBSurface const *pCmd)
|
---|
1417 | {
|
---|
1418 | //DEBUG_BREAKPOINT_TEST();
|
---|
1419 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1420 |
|
---|
1421 | /* Assign the mobid to the surface. */
|
---|
1422 | int rc = VINF_SUCCESS;
|
---|
1423 | if (pCmd->mobid != SVGA_ID_INVALID)
|
---|
1424 | rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
|
---|
1425 | pCmd->mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE);
|
---|
1426 | if (RT_SUCCESS(rc))
|
---|
1427 | {
|
---|
1428 | SVGAOTableSurfaceEntry entry;
|
---|
1429 | rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1430 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1431 | if (RT_SUCCESS(rc))
|
---|
1432 | {
|
---|
1433 | entry.mobid = pCmd->mobid;
|
---|
1434 | rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1435 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1436 | if (RT_SUCCESS(rc))
|
---|
1437 | {
|
---|
1438 | /* */
|
---|
1439 | }
|
---|
1440 | }
|
---|
1441 | }
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 |
|
---|
1445 | typedef union
|
---|
1446 | {
|
---|
1447 | float f;
|
---|
1448 | uint32_t u;
|
---|
1449 | } Unsigned2Float;
|
---|
1450 |
|
---|
1451 | float float16ToFloat(uint16_t f16)
|
---|
1452 | {
|
---|
1453 | /* Format specs from Wiki: [15] = sign, [14:10] = exponent, [9:0] = fraction */
|
---|
1454 | uint16_t const f = f16 & 0x3FF;
|
---|
1455 | uint16_t const e = (f16 >> 10) & 0x1F;
|
---|
1456 | uint16_t const s = (f16 >> 15) & 0x1;
|
---|
1457 | Unsigned2Float u2f;
|
---|
1458 |
|
---|
1459 | if (e == 0)
|
---|
1460 | {
|
---|
1461 | if (f == 0)
|
---|
1462 | {
|
---|
1463 | /* zero, -0 */
|
---|
1464 | u2f.u = (s << 31) | (0 << 23) | 0;
|
---|
1465 | return u2f.f;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | /* subnormal numbers: (-1)^signbit * 2^-14 * 0.significantbits */
|
---|
1469 | float const k = 1.0f / 16384.0f; /* 2^-14 */
|
---|
1470 | return (s ? -1.0f : 1.0f) * k * (float)f / 1024.0f;
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | if (e == 31)
|
---|
1474 | {
|
---|
1475 | if (f == 0)
|
---|
1476 | {
|
---|
1477 | /* +-infinity */
|
---|
1478 | u2f.u = (s << 31) | (0xFF << 23) | 0;
|
---|
1479 | return u2f.f;
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | /* NaN */
|
---|
1483 | u2f.u = (s << 31) | (0xFF << 23) | 1;
|
---|
1484 | return u2f.f;
|
---|
1485 | }
|
---|
1486 |
|
---|
1487 | /* normalized value: (-1)^signbit * 2^(exponent - 15) * 1.significantbits */
|
---|
1488 | /* Build the float, adjusting for exponent bias (float32 bias is 127, float16 is 15)
|
---|
1489 | * and number of bits in the fraction (float32 has 23, float16 has 10). */
|
---|
1490 | u2f.u = (s << 31) | ((e + 127 - 15) << 23) | (f << (23 - 10));
|
---|
1491 | return u2f.f;
|
---|
1492 | }
|
---|
1493 |
|
---|
1494 |
|
---|
1495 | static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap)
|
---|
1496 | {
|
---|
1497 | if ( pMap->cbBlock != 4 && pMap->cbBlock != 2 && pMap->cbBlock != 1
|
---|
1498 | && pMap->format != SVGA3D_R16G16B16A16_FLOAT
|
---|
1499 | && pMap->format != SVGA3D_R32G32B32A32_FLOAT)
|
---|
1500 | return VERR_NOT_SUPPORTED;
|
---|
1501 |
|
---|
1502 | int const w = pMap->cbRow / pMap->cbBlock;
|
---|
1503 | int const h = pMap->cRows;
|
---|
1504 |
|
---|
1505 | const int cbBitmap = pMap->cbRow * pMap->cRows * 4;
|
---|
1506 |
|
---|
1507 | FILE *f = fopen(pszFilename, "wb");
|
---|
1508 | if (!f)
|
---|
1509 | return VERR_FILE_NOT_FOUND;
|
---|
1510 |
|
---|
1511 | #ifdef RT_OS_WINDOWS
|
---|
1512 | if (pMap->cbBlock == 4)
|
---|
1513 | {
|
---|
1514 | BMPFILEHDR fileHdr;
|
---|
1515 | RT_ZERO(fileHdr);
|
---|
1516 | fileHdr.uType = BMP_HDR_MAGIC;
|
---|
1517 | fileHdr.cbFileSize = sizeof(fileHdr) + sizeof(BITMAPV4HEADER) + cbBitmap;
|
---|
1518 | fileHdr.offBits = sizeof(fileHdr) + sizeof(BITMAPV4HEADER);
|
---|
1519 |
|
---|
1520 | BITMAPV4HEADER hdrV4;
|
---|
1521 | RT_ZERO(hdrV4);
|
---|
1522 | hdrV4.bV4Size = sizeof(hdrV4);
|
---|
1523 | hdrV4.bV4Width = w;
|
---|
1524 | hdrV4.bV4Height = -h;
|
---|
1525 | hdrV4.bV4Planes = 1;
|
---|
1526 | hdrV4.bV4BitCount = 32;
|
---|
1527 | hdrV4.bV4V4Compression = BI_BITFIELDS;
|
---|
1528 | hdrV4.bV4SizeImage = cbBitmap;
|
---|
1529 | hdrV4.bV4XPelsPerMeter = 2835;
|
---|
1530 | hdrV4.bV4YPelsPerMeter = 2835;
|
---|
1531 | // hdrV4.bV4ClrUsed = 0;
|
---|
1532 | // hdrV4.bV4ClrImportant = 0;
|
---|
1533 | hdrV4.bV4RedMask = 0x00ff0000;
|
---|
1534 | hdrV4.bV4GreenMask = 0x0000ff00;
|
---|
1535 | hdrV4.bV4BlueMask = 0x000000ff;
|
---|
1536 | hdrV4.bV4AlphaMask = 0xff000000;
|
---|
1537 | hdrV4.bV4CSType = LCS_WINDOWS_COLOR_SPACE;
|
---|
1538 | // hdrV4.bV4Endpoints = {0};
|
---|
1539 | // hdrV4.bV4GammaRed = 0;
|
---|
1540 | // hdrV4.bV4GammaGreen = 0;
|
---|
1541 | // hdrV4.bV4GammaBlue = 0;
|
---|
1542 |
|
---|
1543 | fwrite(&fileHdr, 1, sizeof(fileHdr), f);
|
---|
1544 | fwrite(&hdrV4, 1, sizeof(hdrV4), f);
|
---|
1545 | }
|
---|
1546 | else
|
---|
1547 | #endif
|
---|
1548 | {
|
---|
1549 | BMPFILEHDR fileHdr;
|
---|
1550 | RT_ZERO(fileHdr);
|
---|
1551 | fileHdr.uType = BMP_HDR_MAGIC;
|
---|
1552 | fileHdr.cbFileSize = sizeof(BMPFILEHDR) + sizeof(BMPWIN3XINFOHDR) + cbBitmap;
|
---|
1553 | fileHdr.offBits = sizeof(BMPFILEHDR) + sizeof(BMPWIN3XINFOHDR);
|
---|
1554 |
|
---|
1555 | BMPWIN3XINFOHDR coreHdr;
|
---|
1556 | RT_ZERO(coreHdr);
|
---|
1557 | coreHdr.cbSize = sizeof(coreHdr);
|
---|
1558 | coreHdr.uWidth = w;
|
---|
1559 | coreHdr.uHeight = -h;
|
---|
1560 | coreHdr.cPlanes = 1;
|
---|
1561 | coreHdr.cBits = 32;
|
---|
1562 | coreHdr.cbSizeImage = cbBitmap;
|
---|
1563 |
|
---|
1564 | fwrite(&fileHdr, 1, sizeof(fileHdr), f);
|
---|
1565 | fwrite(&coreHdr, 1, sizeof(coreHdr), f);
|
---|
1566 | }
|
---|
1567 |
|
---|
1568 | if (pMap->format == SVGA3D_R16G16B16A16_FLOAT)
|
---|
1569 | {
|
---|
1570 | const uint8_t *s = (uint8_t *)pMap->pvData;
|
---|
1571 | for (int32_t y = 0; y < h; ++y)
|
---|
1572 | {
|
---|
1573 | for (int32_t x = 0; x < w; ++x)
|
---|
1574 | {
|
---|
1575 | uint16_t const *pu16Pixel = (uint16_t *)(s + x * 8);
|
---|
1576 | uint8_t r = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[0]));
|
---|
1577 | uint8_t g = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[1]));
|
---|
1578 | uint8_t b = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[2]));
|
---|
1579 | uint8_t a = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[3]));
|
---|
1580 | uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24);
|
---|
1581 | fwrite(&u32Pixel, 1, 4, f);
|
---|
1582 | }
|
---|
1583 |
|
---|
1584 | s += pMap->cbRowPitch;
|
---|
1585 | }
|
---|
1586 | }
|
---|
1587 | else if (pMap->format == SVGA3D_R32G32B32A32_FLOAT)
|
---|
1588 | {
|
---|
1589 | const uint8_t *s = (uint8_t *)pMap->pvData;
|
---|
1590 | for (int32_t y = 0; y < h; ++y)
|
---|
1591 | {
|
---|
1592 | for (int32_t x = 0; x < w; ++x)
|
---|
1593 | {
|
---|
1594 | float const *pPixel = (float *)(s + x * 8);
|
---|
1595 | uint8_t r = (uint8_t)(255.0 * pPixel[0]);
|
---|
1596 | uint8_t g = (uint8_t)(255.0 * pPixel[1]);
|
---|
1597 | uint8_t b = (uint8_t)(255.0 * pPixel[2]);
|
---|
1598 | uint8_t a = (uint8_t)(255.0 * pPixel[3]);
|
---|
1599 | uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24);
|
---|
1600 | fwrite(&u32Pixel, 1, 4, f);
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | s += pMap->cbRowPitch;
|
---|
1604 | }
|
---|
1605 | }
|
---|
1606 | else if (pMap->cbBlock == 4)
|
---|
1607 | {
|
---|
1608 | const uint8_t *s = (uint8_t *)pMap->pvData;
|
---|
1609 | for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow)
|
---|
1610 | {
|
---|
1611 | fwrite(s, 1, pMap->cbRow, f);
|
---|
1612 |
|
---|
1613 | s += pMap->cbRowPitch;
|
---|
1614 | }
|
---|
1615 | }
|
---|
1616 | else if (pMap->cbBlock == 2)
|
---|
1617 | {
|
---|
1618 | const uint8_t *s = (uint8_t *)pMap->pvData;
|
---|
1619 | for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow)
|
---|
1620 | {
|
---|
1621 | for (int32_t x = 0; x < w; ++x)
|
---|
1622 | {
|
---|
1623 | uint16_t const *pPixel = (uint16_t *)(s + x * sizeof(uint16_t));
|
---|
1624 | uint32_t u32Pixel = *pPixel;
|
---|
1625 | fwrite(&u32Pixel, 1, 4, f);
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 | s += pMap->cbRowPitch;
|
---|
1629 | }
|
---|
1630 | }
|
---|
1631 | else if (pMap->cbBlock == 1)
|
---|
1632 | {
|
---|
1633 | const uint8_t *s = (uint8_t *)pMap->pvData;
|
---|
1634 | for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow)
|
---|
1635 | {
|
---|
1636 | for (int32_t x = 0; x < w; ++x)
|
---|
1637 | {
|
---|
1638 | uint32_t u32Pixel = s[x];
|
---|
1639 | fwrite(&u32Pixel, 1, 4, f);
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | s += pMap->cbRowPitch;
|
---|
1643 | }
|
---|
1644 | }
|
---|
1645 |
|
---|
1646 | fclose(f);
|
---|
1647 |
|
---|
1648 | return VINF_SUCCESS;
|
---|
1649 | }
|
---|
1650 |
|
---|
1651 |
|
---|
1652 | void vmsvga3dMapWriteBmpFile(VMSVGA3D_MAPPED_SURFACE const *pMap, char const *pszPrefix)
|
---|
1653 | {
|
---|
1654 | static int idxBitmap = 0;
|
---|
1655 | char *pszFilename = RTStrAPrintf2("bmp\\%s%d.bmp", pszPrefix, idxBitmap++);
|
---|
1656 | int rc = vmsvga3dBmpWrite(pszFilename, pMap);
|
---|
1657 | Log(("WriteBmpFile %s format %d %Rrc\n", pszFilename, pMap->format, rc)); RT_NOREF(rc);
|
---|
1658 | RTStrFree(pszFilename);
|
---|
1659 | }
|
---|
1660 |
|
---|
1661 |
|
---|
1662 | static int vmsvgaR3TransferSurfaceLevel(PVGASTATECC pThisCC,
|
---|
1663 | PVMSVGAMOB pMob,
|
---|
1664 | SVGA3dSurfaceImageId const *pImage,
|
---|
1665 | SVGA3dBox const *pBox,
|
---|
1666 | SVGA3dTransferType enmTransfer)
|
---|
1667 | {
|
---|
1668 | if (vmsvga3dIsMultisampleSurface(pThisCC, pImage->sid))
|
---|
1669 | {
|
---|
1670 | /* Multisample surfaces can't be accessed. Skip. */
|
---|
1671 | return VINF_SUCCESS;
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1675 |
|
---|
1676 | VMSVGA3D_SURFACE_MAP enmMapType;
|
---|
1677 | if (enmTransfer == SVGA3D_WRITE_HOST_VRAM)
|
---|
1678 | enmMapType = pBox
|
---|
1679 | ? VMSVGA3D_SURFACE_MAP_WRITE
|
---|
1680 | : VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;
|
---|
1681 | else if (enmTransfer == SVGA3D_READ_HOST_VRAM)
|
---|
1682 | enmMapType = VMSVGA3D_SURFACE_MAP_READ;
|
---|
1683 | else
|
---|
1684 | AssertFailedReturn(VERR_INVALID_PARAMETER);
|
---|
1685 |
|
---|
1686 | VMSVGA3D_MAPPED_SURFACE map;
|
---|
1687 | int rc = vmsvga3dSurfaceMap(pThisCC, pImage, pBox, enmMapType, &map);
|
---|
1688 | if (RT_SUCCESS(rc))
|
---|
1689 | {
|
---|
1690 | /* Copy mapped surface <-> MOB. */
|
---|
1691 | VMSGA3D_BOX_DIMENSIONS dims;
|
---|
1692 | rc = vmsvga3dGetBoxDimensions(pThisCC, pImage, pBox, &dims);
|
---|
1693 | if (RT_SUCCESS(rc))
|
---|
1694 | {
|
---|
1695 | for (uint32_t z = 0; z < map.box.d; ++z)
|
---|
1696 | {
|
---|
1697 | uint8_t *pu8Map = (uint8_t *)map.pvData + z * map.cbDepthPitch;
|
---|
1698 | uint32_t offMob = dims.offSubresource + dims.offBox + z * dims.cbDepthPitch;
|
---|
1699 |
|
---|
1700 | for (uint32_t iRow = 0; iRow < map.cRows; ++iRow)
|
---|
1701 | {
|
---|
1702 | if (enmTransfer == SVGA3D_READ_HOST_VRAM)
|
---|
1703 | rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow);
|
---|
1704 | else
|
---|
1705 | rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow);
|
---|
1706 | AssertRCBreak(rc);
|
---|
1707 |
|
---|
1708 | pu8Map += map.cbRowPitch;
|
---|
1709 | offMob += dims.cbPitch;
|
---|
1710 | }
|
---|
1711 | }
|
---|
1712 | }
|
---|
1713 |
|
---|
1714 | // vmsvga3dMapWriteBmpFile(&map, "Dynamic");
|
---|
1715 |
|
---|
1716 | bool const fWritten = (enmTransfer == SVGA3D_WRITE_HOST_VRAM);
|
---|
1717 | vmsvga3dSurfaceUnmap(pThisCC, pImage, &map, fWritten);
|
---|
1718 | }
|
---|
1719 |
|
---|
1720 | return rc;
|
---|
1721 | }
|
---|
1722 |
|
---|
1723 |
|
---|
1724 | /* SVGA_3D_CMD_UPDATE_GB_IMAGE 1101 */
|
---|
1725 | static void vmsvga3dCmdUpdateGBImage(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBImage const *pCmd)
|
---|
1726 | {
|
---|
1727 | //DEBUG_BREAKPOINT_TEST();
|
---|
1728 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1729 |
|
---|
1730 | LogFlowFunc(("sid=%u @%u,%u,%u %ux%ux%u\n",
|
---|
1731 | pCmd->image.sid, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.d));
|
---|
1732 |
|
---|
1733 | /*
|
---|
1734 | SVGA3dSurfaceFormat format;
|
---|
1735 | SVGA3dSurface1Flags surface1Flags;
|
---|
1736 | uint32 numMipLevels;
|
---|
1737 | uint32 multisampleCount;
|
---|
1738 | SVGA3dTextureFilter autogenFilter;
|
---|
1739 | SVGA3dSize size;
|
---|
1740 | SVGAMobId mobid;
|
---|
1741 | uint32 arraySize;
|
---|
1742 | uint32 mobPitch;
|
---|
1743 | SVGA3dSurface2Flags surface2Flags;
|
---|
1744 | uint8 multisamplePattern;
|
---|
1745 | uint8 qualityLevel;
|
---|
1746 | uint16 bufferByteStride;
|
---|
1747 | float minLOD;
|
---|
1748 | */
|
---|
1749 |
|
---|
1750 | /* "update a surface from its backing MOB." */
|
---|
1751 | SVGAOTableSurfaceEntry entrySurface;
|
---|
1752 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1753 | pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
1754 | if (RT_SUCCESS(rc))
|
---|
1755 | {
|
---|
1756 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
1757 | if (pMob)
|
---|
1758 | {
|
---|
1759 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM);
|
---|
1760 | AssertRC(rc);
|
---|
1761 | }
|
---|
1762 | }
|
---|
1763 | }
|
---|
1764 |
|
---|
1765 |
|
---|
1766 | /* SVGA_3D_CMD_UPDATE_GB_SURFACE 1102 */
|
---|
1767 | static void vmsvga3dCmdUpdateGBSurface(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBSurface const *pCmd)
|
---|
1768 | {
|
---|
1769 | //DEBUG_BREAKPOINT_TEST();
|
---|
1770 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1771 |
|
---|
1772 | LogFlowFunc(("sid=%u\n",
|
---|
1773 | pCmd->sid));
|
---|
1774 |
|
---|
1775 | /* "update a surface from its backing MOB." */
|
---|
1776 | SVGAOTableSurfaceEntry entrySurface;
|
---|
1777 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1778 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
1779 | if (RT_SUCCESS(rc))
|
---|
1780 | {
|
---|
1781 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
1782 | if (pMob)
|
---|
1783 | {
|
---|
1784 | uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid);
|
---|
1785 | for (uint32_t iArray = 0; iArray < arraySize; ++iArray)
|
---|
1786 | {
|
---|
1787 | for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap)
|
---|
1788 | {
|
---|
1789 | SVGA3dSurfaceImageId image;
|
---|
1790 | image.sid = pCmd->sid;
|
---|
1791 | image.face = iArray;
|
---|
1792 | image.mipmap = iMipmap;
|
---|
1793 |
|
---|
1794 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_WRITE_HOST_VRAM);
|
---|
1795 | AssertRCBreak(rc);
|
---|
1796 | }
|
---|
1797 | }
|
---|
1798 | }
|
---|
1799 | }
|
---|
1800 | }
|
---|
1801 |
|
---|
1802 |
|
---|
1803 | /* SVGA_3D_CMD_READBACK_GB_IMAGE 1103 */
|
---|
1804 | static void vmsvga3dCmdReadbackGBImage(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBImage const *pCmd)
|
---|
1805 | {
|
---|
1806 | //DEBUG_BREAKPOINT_TEST();
|
---|
1807 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1808 |
|
---|
1809 | LogFlowFunc(("sid=%u, face=%u, mipmap=%u\n",
|
---|
1810 | pCmd->image.sid, pCmd->image.face, pCmd->image.mipmap));
|
---|
1811 |
|
---|
1812 | /* Read a surface to its backing MOB. */
|
---|
1813 | SVGAOTableSurfaceEntry entrySurface;
|
---|
1814 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1815 | pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
1816 | if (RT_SUCCESS(rc))
|
---|
1817 | {
|
---|
1818 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
1819 | if (pMob)
|
---|
1820 | {
|
---|
1821 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
|
---|
1822 | AssertRC(rc);
|
---|
1823 | }
|
---|
1824 | }
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 |
|
---|
1828 | /* SVGA_3D_CMD_READBACK_GB_SURFACE 1104 */
|
---|
1829 | static void vmsvga3dCmdReadbackGBSurface(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBSurface const *pCmd)
|
---|
1830 | {
|
---|
1831 | //DEBUG_BREAKPOINT_TEST();
|
---|
1832 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1833 |
|
---|
1834 | LogFlowFunc(("sid=%u\n",
|
---|
1835 | pCmd->sid));
|
---|
1836 |
|
---|
1837 | /* Read a surface to its backing MOB. */
|
---|
1838 | SVGAOTableSurfaceEntry entrySurface;
|
---|
1839 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1840 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
1841 | if (RT_SUCCESS(rc))
|
---|
1842 | {
|
---|
1843 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
1844 | if (pMob)
|
---|
1845 | {
|
---|
1846 | uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid);
|
---|
1847 | for (uint32_t iArray = 0; iArray < arraySize; ++iArray)
|
---|
1848 | {
|
---|
1849 | for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap)
|
---|
1850 | {
|
---|
1851 | SVGA3dSurfaceImageId image;
|
---|
1852 | image.sid = pCmd->sid;
|
---|
1853 | image.face = iArray;
|
---|
1854 | image.mipmap = iMipmap;
|
---|
1855 |
|
---|
1856 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
|
---|
1857 | AssertRCBreak(rc);
|
---|
1858 | }
|
---|
1859 | }
|
---|
1860 | }
|
---|
1861 | }
|
---|
1862 | }
|
---|
1863 |
|
---|
1864 |
|
---|
1865 | /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE 1105 */
|
---|
1866 | static void vmsvga3dCmdInvalidateGBImage(PVGASTATECC pThisCC, SVGA3dCmdInvalidateGBImage const *pCmd)
|
---|
1867 | {
|
---|
1868 | //DEBUG_BREAKPOINT_TEST();
|
---|
1869 | vmsvga3dSurfaceInvalidate(pThisCC, pCmd->image.sid, pCmd->image.face, pCmd->image.mipmap);
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 |
|
---|
1873 | /* SVGA_3D_CMD_INVALIDATE_GB_SURFACE 1106 */
|
---|
1874 | static void vmsvga3dCmdInvalidateGBSurface(PVGASTATECC pThisCC, SVGA3dCmdInvalidateGBSurface const *pCmd)
|
---|
1875 | {
|
---|
1876 | //DEBUG_BREAKPOINT_TEST();
|
---|
1877 | vmsvga3dSurfaceInvalidate(pThisCC, pCmd->sid, SVGA_ID_INVALID, SVGA_ID_INVALID);
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 |
|
---|
1881 | /* SVGA_3D_CMD_SET_OTABLE_BASE64 1115 */
|
---|
1882 | static void vmsvga3dCmdSetOTableBase64(PVGASTATECC pThisCC, SVGA3dCmdSetOTableBase64 const *pCmd)
|
---|
1883 | {
|
---|
1884 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1885 | vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
|
---|
1886 | pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ false);
|
---|
1887 | }
|
---|
1888 |
|
---|
1889 |
|
---|
1890 | /* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET 1124 */
|
---|
1891 | static void vmsvga3dCmdDefineGBScreenTarget(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dCmdDefineGBScreenTarget const *pCmd)
|
---|
1892 | {
|
---|
1893 | //DEBUG_BREAKPOINT_TEST();
|
---|
1894 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1895 |
|
---|
1896 | ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
|
---|
1897 | ASSERT_GUEST_RETURN_VOID(pCmd->width > 0 && pCmd->width <= pThis->svga.u32MaxWidth); /* SVGA_REG_SCREENTARGET_MAX_WIDTH */
|
---|
1898 | ASSERT_GUEST_RETURN_VOID(pCmd->height > 0 && pCmd->height <= pThis->svga.u32MaxHeight); /* SVGA_REG_SCREENTARGET_MAX_HEIGHT */
|
---|
1899 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1900 |
|
---|
1901 | /* Update the entry in the pSvgaR3State->pGboOTableScreenTarget. */
|
---|
1902 | SVGAOTableScreenTargetEntry entry;
|
---|
1903 | RT_ZERO(entry);
|
---|
1904 | entry.image.sid = SVGA_ID_INVALID;
|
---|
1905 | // entry.image.face = 0;
|
---|
1906 | // entry.image.mipmap = 0;
|
---|
1907 | entry.width = pCmd->width;
|
---|
1908 | entry.height = pCmd->height;
|
---|
1909 | entry.xRoot = pCmd->xRoot;
|
---|
1910 | entry.yRoot = pCmd->yRoot;
|
---|
1911 | entry.flags = pCmd->flags;
|
---|
1912 | entry.dpi = pCmd->dpi;
|
---|
1913 |
|
---|
1914 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
|
---|
1915 | pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1916 | if (RT_SUCCESS(rc))
|
---|
1917 | {
|
---|
1918 | /* Screen objects and screen targets are similar, therefore we will use the same for both. */
|
---|
1919 | /** @todo Generic screen object/target interface. */
|
---|
1920 | VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
|
---|
1921 | Assert(pScreen->idScreen == pCmd->stid);
|
---|
1922 | pScreen->fDefined = true;
|
---|
1923 | pScreen->fModified = true;
|
---|
1924 | pScreen->fuScreen = SVGA_SCREEN_MUST_BE_SET
|
---|
1925 | | (RT_BOOL(pCmd->flags & SVGA_STFLAG_PRIMARY) ? SVGA_SCREEN_IS_PRIMARY : 0);
|
---|
1926 |
|
---|
1927 | pScreen->xOrigin = pCmd->xRoot;
|
---|
1928 | pScreen->yOrigin = pCmd->yRoot;
|
---|
1929 | pScreen->cWidth = pCmd->width;
|
---|
1930 | pScreen->cHeight = pCmd->height;
|
---|
1931 | pScreen->offVRAM = 0; /* Not applicable for screen targets, they use either a separate memory buffer or a host window. */
|
---|
1932 | pScreen->cbPitch = pCmd->width * 4;
|
---|
1933 | pScreen->cBpp = 32;
|
---|
1934 |
|
---|
1935 | if (RT_LIKELY(pThis->svga.f3DEnabled))
|
---|
1936 | vmsvga3dDefineScreen(pThis, pThisCC, pScreen);
|
---|
1937 |
|
---|
1938 | if (!pScreen->pHwScreen)
|
---|
1939 | {
|
---|
1940 | /* System memory buffer. */
|
---|
1941 | pScreen->pvScreenBitmap = RTMemAllocZ(pScreen->cHeight * pScreen->cbPitch);
|
---|
1942 | }
|
---|
1943 |
|
---|
1944 | pThis->svga.fGFBRegisters = false;
|
---|
1945 | vmsvgaR3ChangeMode(pThis, pThisCC);
|
---|
1946 | }
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 |
|
---|
1950 | /* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET 1125 */
|
---|
1951 | static void vmsvga3dCmdDestroyGBScreenTarget(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dCmdDestroyGBScreenTarget const *pCmd)
|
---|
1952 | {
|
---|
1953 | //DEBUG_BREAKPOINT_TEST();
|
---|
1954 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1955 |
|
---|
1956 | ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
|
---|
1957 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1958 |
|
---|
1959 | /* Update the entry in the pSvgaR3State->pGboOTableScreenTarget. */
|
---|
1960 | SVGAOTableScreenTargetEntry entry;
|
---|
1961 | RT_ZERO(entry);
|
---|
1962 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
|
---|
1963 | pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1964 | if (RT_SUCCESS(rc))
|
---|
1965 | {
|
---|
1966 | /* Screen objects and screen targets are similar, therefore we will use the same for both. */
|
---|
1967 | /** @todo Generic screen object/target interface. */
|
---|
1968 | VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
|
---|
1969 | vmsvgaR3DestroyScreen(pThis, pThisCC, pScreen);
|
---|
1970 | }
|
---|
1971 | }
|
---|
1972 |
|
---|
1973 |
|
---|
1974 | /* SVGA_3D_CMD_BIND_GB_SCREENTARGET 1126 */
|
---|
1975 | static void vmsvga3dCmdBindGBScreenTarget(PVGASTATECC pThisCC, SVGA3dCmdBindGBScreenTarget const *pCmd)
|
---|
1976 | {
|
---|
1977 | //DEBUG_BREAKPOINT_TEST();
|
---|
1978 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1979 |
|
---|
1980 | /* "Binding a surface to a Screen Target the same as flipping" */
|
---|
1981 |
|
---|
1982 | ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
|
---|
1983 | ASSERT_GUEST_RETURN_VOID(pCmd->image.face == 0 && pCmd->image.mipmap == 0);
|
---|
1984 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1985 |
|
---|
1986 | /* Assign the surface to the screen target. */
|
---|
1987 | int rc = VINF_SUCCESS;
|
---|
1988 | if (pCmd->image.sid != SVGA_ID_INVALID)
|
---|
1989 | rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
1990 | pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE);
|
---|
1991 | if (RT_SUCCESS(rc))
|
---|
1992 | {
|
---|
1993 | SVGAOTableScreenTargetEntry entry;
|
---|
1994 | rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
|
---|
1995 | pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
1996 | if (RT_SUCCESS(rc))
|
---|
1997 | {
|
---|
1998 | entry.image = pCmd->image;
|
---|
1999 | rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
|
---|
2000 | pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
2001 | if (RT_SUCCESS(rc))
|
---|
2002 | {
|
---|
2003 | VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
|
---|
2004 | rc = pSvgaR3State->pFuncsGBO->pfnScreenTargetBind(pThisCC, pScreen, pCmd->image.sid);
|
---|
2005 | AssertRC(rc);
|
---|
2006 | }
|
---|
2007 | }
|
---|
2008 | }
|
---|
2009 | }
|
---|
2010 |
|
---|
2011 |
|
---|
2012 | /* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET 1127 */
|
---|
2013 | static void vmsvga3dCmdUpdateGBScreenTarget(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBScreenTarget const *pCmd)
|
---|
2014 | {
|
---|
2015 | //DEBUG_BREAKPOINT_TEST();
|
---|
2016 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2017 |
|
---|
2018 | /* Update the screen target from its backing surface. */
|
---|
2019 | ASSERT_GUEST_RETURN_VOID(pCmd->stid < RT_ELEMENTS(pSvgaR3State->aScreens));
|
---|
2020 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2021 |
|
---|
2022 | /* Get the screen target info. */
|
---|
2023 | SVGAOTableScreenTargetEntry entryScreenTarget;
|
---|
2024 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SCREENTARGET],
|
---|
2025 | pCmd->stid, SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE, &entryScreenTarget, sizeof(entryScreenTarget));
|
---|
2026 | if (RT_SUCCESS(rc))
|
---|
2027 | {
|
---|
2028 | ASSERT_GUEST_RETURN_VOID(entryScreenTarget.image.face == 0 && entryScreenTarget.image.mipmap == 0);
|
---|
2029 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2030 |
|
---|
2031 | if (entryScreenTarget.image.sid != SVGA_ID_INVALID)
|
---|
2032 | {
|
---|
2033 | SVGAOTableSurfaceEntry entrySurface;
|
---|
2034 | rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
2035 | entryScreenTarget.image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
2036 | if (RT_SUCCESS(rc))
|
---|
2037 | {
|
---|
2038 | /* Copy entrySurface.mobid content to the screen target. */
|
---|
2039 | if (entrySurface.mobid != SVGA_ID_INVALID)
|
---|
2040 | {
|
---|
2041 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2042 | SVGA3dRect targetRect = pCmd->rect;
|
---|
2043 |
|
---|
2044 | VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[pCmd->stid];
|
---|
2045 | if (pScreen->pHwScreen)
|
---|
2046 | {
|
---|
2047 | /* Copy the screen target surface to the backend's screen. */
|
---|
2048 | pSvgaR3State->pFuncsGBO->pfnScreenTargetUpdate(pThisCC, pScreen, &targetRect);
|
---|
2049 | }
|
---|
2050 | else
|
---|
2051 | {
|
---|
2052 | SVGASignedRect r;
|
---|
2053 | r.left = pCmd->rect.x;
|
---|
2054 | r.top = pCmd->rect.y;
|
---|
2055 | r.right = pCmd->rect.x + pCmd->rect.w;
|
---|
2056 | r.bottom = pCmd->rect.y + pCmd->rect.h;
|
---|
2057 | vmsvga3dScreenUpdate(pThisCC, pCmd->stid, r, entryScreenTarget.image, r, 0, NULL);
|
---|
2058 | }
|
---|
2059 | }
|
---|
2060 | }
|
---|
2061 | }
|
---|
2062 | }
|
---|
2063 | }
|
---|
2064 |
|
---|
2065 |
|
---|
2066 | /* SVGA_3D_CMD_DEFINE_GB_SURFACE_V2 1134 */
|
---|
2067 | static void vmsvga3dCmdDefineGBSurface_v2(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v2 const *pCmd)
|
---|
2068 | {
|
---|
2069 | //DEBUG_BREAKPOINT_TEST();
|
---|
2070 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2071 |
|
---|
2072 | /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
|
---|
2073 | SVGAOTableSurfaceEntry entry;
|
---|
2074 | RT_ZERO(entry);
|
---|
2075 | entry.format = pCmd->format;
|
---|
2076 | entry.surface1Flags = pCmd->surfaceFlags;
|
---|
2077 | entry.numMipLevels = pCmd->numMipLevels;
|
---|
2078 | entry.multisampleCount = pCmd->multisampleCount;
|
---|
2079 | entry.autogenFilter = pCmd->autogenFilter;
|
---|
2080 | entry.size = pCmd->size;
|
---|
2081 | entry.mobid = SVGA_ID_INVALID;
|
---|
2082 | entry.arraySize = pCmd->arraySize;
|
---|
2083 | // entry.mobPitch = 0;
|
---|
2084 | // entry.surface2Flags = 0;
|
---|
2085 | // entry.multisamplePattern = 0;
|
---|
2086 | // entry.qualityLevel = 0;
|
---|
2087 | // entry.bufferByteStride = 0;
|
---|
2088 | // entry.minLOD = 0;
|
---|
2089 |
|
---|
2090 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
2091 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
2092 | if (RT_SUCCESS(rc))
|
---|
2093 | {
|
---|
2094 | /* Create the host surface. */
|
---|
2095 | SVGA3dMSPattern const multisamplePattern = pCmd->multisampleCount > 1 ? SVGA3D_MS_PATTERN_STANDARD : SVGA3D_MS_PATTERN_NONE;
|
---|
2096 | SVGA3dMSQualityLevel const qualityLevel = pCmd->multisampleCount > 1 ? SVGA3D_MS_QUALITY_FULL : SVGA3D_MS_QUALITY_NONE;
|
---|
2097 | vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
|
---|
2098 | pCmd->multisampleCount, multisamplePattern, qualityLevel, pCmd->autogenFilter,
|
---|
2099 | pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* bufferByteStride = */ 0, /* fAllocMipLevels = */ false);
|
---|
2100 | }
|
---|
2101 | }
|
---|
2102 |
|
---|
2103 |
|
---|
2104 | /* SVGA_3D_CMD_DEFINE_GB_MOB64 1135 */
|
---|
2105 | static void vmsvga3dCmdDefineGBMob64(PVGASTATECC pThisCC, SVGA3dCmdDefineGBMob64 const *pCmd)
|
---|
2106 | {
|
---|
2107 | //DEBUG_BREAKPOINT_TEST();
|
---|
2108 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2109 |
|
---|
2110 | ASSERT_GUEST_RETURN_VOID(pCmd->mobid != SVGA_ID_INVALID); /* The guest should not use this id. */
|
---|
2111 |
|
---|
2112 | /* Maybe just update the OTable and create Gbo when the MOB is actually accessed? */
|
---|
2113 | /* Allocate a structure for the MOB. */
|
---|
2114 | PVMSVGAMOB pMob = (PVMSVGAMOB)RTMemAllocZ(sizeof(*pMob));
|
---|
2115 | AssertPtrReturnVoid(pMob);
|
---|
2116 |
|
---|
2117 | int rc = vmsvgaR3MobCreate(pSvgaR3State, pCmd->ptDepth, pCmd->base, pCmd->sizeInBytes, pCmd->mobid, pMob);
|
---|
2118 | if (RT_SUCCESS(rc))
|
---|
2119 | {
|
---|
2120 | return;
|
---|
2121 | }
|
---|
2122 |
|
---|
2123 | RTMemFree(pMob);
|
---|
2124 | }
|
---|
2125 |
|
---|
2126 |
|
---|
2127 | /* SVGA_3D_CMD_DX_DEFINE_CONTEXT 1143 */
|
---|
2128 | static int vmsvga3dCmdDXDefineContext(PVGASTATECC pThisCC, SVGA3dCmdDXDefineContext const *pCmd, uint32_t cbCmd)
|
---|
2129 | {
|
---|
2130 | #ifdef VMSVGA3D_DX
|
---|
2131 | //DEBUG_BREAKPOINT_TEST();
|
---|
2132 | RT_NOREF(cbCmd);
|
---|
2133 |
|
---|
2134 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2135 |
|
---|
2136 | /* Update the entry in the pSvgaR3State->pGboOTable[SVGA_OTABLE_DXCONTEXT]. */
|
---|
2137 | SVGAOTableDXContextEntry entry;
|
---|
2138 | RT_ZERO(entry);
|
---|
2139 | entry.cid = pCmd->cid;
|
---|
2140 | entry.mobid = SVGA_ID_INVALID;
|
---|
2141 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
|
---|
2142 | pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
|
---|
2143 | if (RT_SUCCESS(rc))
|
---|
2144 | {
|
---|
2145 | /* Create the host context. */
|
---|
2146 | rc = vmsvga3dDXDefineContext(pThisCC, pCmd->cid);
|
---|
2147 | }
|
---|
2148 |
|
---|
2149 | return rc;
|
---|
2150 | #else
|
---|
2151 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2152 | return VERR_NOT_SUPPORTED;
|
---|
2153 | #endif
|
---|
2154 | }
|
---|
2155 |
|
---|
2156 |
|
---|
2157 | /* SVGA_3D_CMD_DX_DESTROY_CONTEXT 1144 */
|
---|
2158 | static int vmsvga3dCmdDXDestroyContext(PVGASTATECC pThisCC, SVGA3dCmdDXDestroyContext const *pCmd, uint32_t cbCmd)
|
---|
2159 | {
|
---|
2160 | #ifdef VMSVGA3D_DX
|
---|
2161 | //DEBUG_BREAKPOINT_TEST();
|
---|
2162 | RT_NOREF(cbCmd);
|
---|
2163 |
|
---|
2164 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2165 |
|
---|
2166 | /* Update the entry in the pSvgaR3State->pGboOTable[SVGA_OTABLE_DXCONTEXT]. */
|
---|
2167 | SVGAOTableDXContextEntry entry;
|
---|
2168 | RT_ZERO(entry);
|
---|
2169 | vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
|
---|
2170 | pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
|
---|
2171 |
|
---|
2172 | return vmsvga3dDXDestroyContext(pThisCC, pCmd->cid);
|
---|
2173 | #else
|
---|
2174 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2175 | return VERR_NOT_SUPPORTED;
|
---|
2176 | #endif
|
---|
2177 | }
|
---|
2178 |
|
---|
2179 |
|
---|
2180 | /* SVGA_3D_CMD_DX_BIND_CONTEXT 1145 */
|
---|
2181 | static int vmsvga3dCmdDXBindContext(PVGASTATECC pThisCC, SVGA3dCmdDXBindContext const *pCmd, uint32_t cbCmd)
|
---|
2182 | {
|
---|
2183 | #ifdef VMSVGA3D_DX
|
---|
2184 | //DEBUG_BREAKPOINT_TEST();
|
---|
2185 | RT_NOREF(cbCmd);
|
---|
2186 |
|
---|
2187 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2188 |
|
---|
2189 | /* Assign a mobid to a cid. */
|
---|
2190 | int rc = VINF_SUCCESS;
|
---|
2191 | if (pCmd->mobid != SVGA_ID_INVALID)
|
---|
2192 | rc = vmsvgaR3OTableVerifyIndex(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_MOB],
|
---|
2193 | pCmd->mobid, SVGA3D_OTABLE_MOB_ENTRY_SIZE);
|
---|
2194 | if (RT_SUCCESS(rc))
|
---|
2195 | {
|
---|
2196 | SVGAOTableDXContextEntry entry;
|
---|
2197 | rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
|
---|
2198 | pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
|
---|
2199 | if (RT_SUCCESS(rc))
|
---|
2200 | {
|
---|
2201 | SVGADXContextMobFormat *pSvgaDXContext = NULL;
|
---|
2202 | if (pCmd->mobid != entry.mobid && entry.mobid != SVGA_ID_INVALID)
|
---|
2203 | {
|
---|
2204 | /* Unbind notification to the DX backend. Copy the context data to the guest backing memory. */
|
---|
2205 | pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
|
---|
2206 | if (pSvgaDXContext)
|
---|
2207 | {
|
---|
2208 | rc = vmsvga3dDXUnbindContext(pThisCC, pCmd->cid, pSvgaDXContext);
|
---|
2209 | if (RT_SUCCESS(rc))
|
---|
2210 | {
|
---|
2211 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entry.mobid);
|
---|
2212 | if (pMob)
|
---|
2213 | {
|
---|
2214 | rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
|
---|
2215 | }
|
---|
2216 | }
|
---|
2217 |
|
---|
2218 | RTMemFree(pSvgaDXContext);
|
---|
2219 | pSvgaDXContext = NULL;
|
---|
2220 | }
|
---|
2221 | }
|
---|
2222 |
|
---|
2223 | if (pCmd->mobid != SVGA_ID_INVALID)
|
---|
2224 | {
|
---|
2225 | /* Bind a new context. Copy existing data from the guest backing memory. */
|
---|
2226 | if (pCmd->validContents)
|
---|
2227 | {
|
---|
2228 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
|
---|
2229 | if (pMob)
|
---|
2230 | {
|
---|
2231 | pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
|
---|
2232 | if (pSvgaDXContext)
|
---|
2233 | {
|
---|
2234 | rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
|
---|
2235 | if (RT_FAILURE(rc))
|
---|
2236 | {
|
---|
2237 | RTMemFree(pSvgaDXContext);
|
---|
2238 | pSvgaDXContext = NULL;
|
---|
2239 | }
|
---|
2240 | }
|
---|
2241 | }
|
---|
2242 | }
|
---|
2243 |
|
---|
2244 | rc = vmsvga3dDXBindContext(pThisCC, pCmd->cid, pSvgaDXContext);
|
---|
2245 |
|
---|
2246 | RTMemFree(pSvgaDXContext);
|
---|
2247 | }
|
---|
2248 |
|
---|
2249 | /* Update the object table. */
|
---|
2250 | entry.mobid = pCmd->mobid;
|
---|
2251 | rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
|
---|
2252 | pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
|
---|
2253 | }
|
---|
2254 | }
|
---|
2255 |
|
---|
2256 | return rc;
|
---|
2257 | #else
|
---|
2258 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2259 | return VERR_NOT_SUPPORTED;
|
---|
2260 | #endif
|
---|
2261 | }
|
---|
2262 |
|
---|
2263 |
|
---|
2264 | /* SVGA_3D_CMD_DX_READBACK_CONTEXT 1146 */
|
---|
2265 | static int vmsvga3dCmdDXReadbackContext(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackContext const *pCmd, uint32_t cbCmd)
|
---|
2266 | {
|
---|
2267 | #ifdef VMSVGA3D_DX
|
---|
2268 | //DEBUG_BREAKPOINT_TEST();
|
---|
2269 | RT_NOREF(cbCmd);
|
---|
2270 |
|
---|
2271 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2272 |
|
---|
2273 | /* "Request that the device flush the contents back into guest memory." */
|
---|
2274 | SVGAOTableDXContextEntry entry;
|
---|
2275 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT],
|
---|
2276 | pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry));
|
---|
2277 | if (RT_SUCCESS(rc))
|
---|
2278 | {
|
---|
2279 | if (entry.mobid != SVGA_ID_INVALID)
|
---|
2280 | {
|
---|
2281 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entry.mobid);
|
---|
2282 | if (pMob)
|
---|
2283 | {
|
---|
2284 | /* Get the content. */
|
---|
2285 | SVGADXContextMobFormat *pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat));
|
---|
2286 | if (pSvgaDXContext)
|
---|
2287 | {
|
---|
2288 | rc = vmsvga3dDXReadbackContext(pThisCC, pCmd->cid, pSvgaDXContext);
|
---|
2289 | if (RT_SUCCESS(rc))
|
---|
2290 | rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat));
|
---|
2291 |
|
---|
2292 | RTMemFree(pSvgaDXContext);
|
---|
2293 | }
|
---|
2294 | else
|
---|
2295 | rc = VERR_NO_MEMORY;
|
---|
2296 | }
|
---|
2297 | }
|
---|
2298 | }
|
---|
2299 |
|
---|
2300 | return rc;
|
---|
2301 | #else
|
---|
2302 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2303 | return VERR_NOT_SUPPORTED;
|
---|
2304 | #endif
|
---|
2305 | }
|
---|
2306 |
|
---|
2307 |
|
---|
2308 | /* SVGA_3D_CMD_DX_INVALIDATE_CONTEXT 1147 */
|
---|
2309 | static int vmsvga3dCmdDXInvalidateContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXInvalidateContext const *pCmd, uint32_t cbCmd)
|
---|
2310 | {
|
---|
2311 | #ifdef VMSVGA3D_DX
|
---|
2312 | DEBUG_BREAKPOINT_TEST();
|
---|
2313 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2314 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
2315 | return vmsvga3dDXInvalidateContext(pThisCC, idDXContext);
|
---|
2316 | #else
|
---|
2317 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2318 | return VERR_NOT_SUPPORTED;
|
---|
2319 | #endif
|
---|
2320 | }
|
---|
2321 |
|
---|
2322 |
|
---|
2323 | /* SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER 1148 */
|
---|
2324 | static int vmsvga3dCmdDXSetSingleConstantBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSingleConstantBuffer const *pCmd, uint32_t cbCmd)
|
---|
2325 | {
|
---|
2326 | #ifdef VMSVGA3D_DX
|
---|
2327 | //DEBUG_BREAKPOINT_TEST();
|
---|
2328 | RT_NOREF(cbCmd);
|
---|
2329 | return vmsvga3dDXSetSingleConstantBuffer(pThisCC, idDXContext, pCmd);
|
---|
2330 | #else
|
---|
2331 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2332 | return VERR_NOT_SUPPORTED;
|
---|
2333 | #endif
|
---|
2334 | }
|
---|
2335 |
|
---|
2336 |
|
---|
2337 | /* SVGA_3D_CMD_DX_SET_SHADER_RESOURCES 1149 */
|
---|
2338 | static int vmsvga3dCmdDXSetShaderResources(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderResources const *pCmd, uint32_t cbCmd)
|
---|
2339 | {
|
---|
2340 | #ifdef VMSVGA3D_DX
|
---|
2341 | //DEBUG_BREAKPOINT_TEST();
|
---|
2342 | SVGA3dShaderResourceViewId const *paShaderResourceViewId = (SVGA3dShaderResourceViewId *)&pCmd[1];
|
---|
2343 | uint32_t const cShaderResourceViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dShaderResourceViewId);
|
---|
2344 | return vmsvga3dDXSetShaderResources(pThisCC, idDXContext, pCmd, cShaderResourceViewId, paShaderResourceViewId);
|
---|
2345 | #else
|
---|
2346 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2347 | return VERR_NOT_SUPPORTED;
|
---|
2348 | #endif
|
---|
2349 | }
|
---|
2350 |
|
---|
2351 |
|
---|
2352 | /* SVGA_3D_CMD_DX_SET_SHADER 1150 */
|
---|
2353 | static int vmsvga3dCmdDXSetShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShader const *pCmd, uint32_t cbCmd)
|
---|
2354 | {
|
---|
2355 | #ifdef VMSVGA3D_DX
|
---|
2356 | //DEBUG_BREAKPOINT_TEST();
|
---|
2357 | RT_NOREF(cbCmd);
|
---|
2358 | return vmsvga3dDXSetShader(pThisCC, idDXContext, pCmd);
|
---|
2359 | #else
|
---|
2360 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2361 | return VERR_NOT_SUPPORTED;
|
---|
2362 | #endif
|
---|
2363 | }
|
---|
2364 |
|
---|
2365 |
|
---|
2366 | /* SVGA_3D_CMD_DX_SET_SAMPLERS 1151 */
|
---|
2367 | static int vmsvga3dCmdDXSetSamplers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSamplers const *pCmd, uint32_t cbCmd)
|
---|
2368 | {
|
---|
2369 | #ifdef VMSVGA3D_DX
|
---|
2370 | //DEBUG_BREAKPOINT_TEST();
|
---|
2371 | SVGA3dSamplerId const *paSamplerId = (SVGA3dSamplerId *)&pCmd[1];
|
---|
2372 | uint32_t const cSamplerId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSamplerId);
|
---|
2373 | return vmsvga3dDXSetSamplers(pThisCC, idDXContext, pCmd, cSamplerId, paSamplerId);
|
---|
2374 | #else
|
---|
2375 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2376 | return VERR_NOT_SUPPORTED;
|
---|
2377 | #endif
|
---|
2378 | }
|
---|
2379 |
|
---|
2380 |
|
---|
2381 | /* SVGA_3D_CMD_DX_DRAW 1152 */
|
---|
2382 | static int vmsvga3dCmdDXDraw(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDraw const *pCmd, uint32_t cbCmd)
|
---|
2383 | {
|
---|
2384 | #ifdef VMSVGA3D_DX
|
---|
2385 | //DEBUG_BREAKPOINT_TEST();
|
---|
2386 | RT_NOREF(cbCmd);
|
---|
2387 | return vmsvga3dDXDraw(pThisCC, idDXContext, pCmd);
|
---|
2388 | #else
|
---|
2389 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2390 | return VERR_NOT_SUPPORTED;
|
---|
2391 | #endif
|
---|
2392 | }
|
---|
2393 |
|
---|
2394 |
|
---|
2395 | /* SVGA_3D_CMD_DX_DRAW_INDEXED 1153 */
|
---|
2396 | static int vmsvga3dCmdDXDrawIndexed(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexed const *pCmd, uint32_t cbCmd)
|
---|
2397 | {
|
---|
2398 | #ifdef VMSVGA3D_DX
|
---|
2399 | //DEBUG_BREAKPOINT_TEST();
|
---|
2400 | RT_NOREF(cbCmd);
|
---|
2401 | return vmsvga3dDXDrawIndexed(pThisCC, idDXContext, pCmd);
|
---|
2402 | #else
|
---|
2403 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2404 | return VERR_NOT_SUPPORTED;
|
---|
2405 | #endif
|
---|
2406 | }
|
---|
2407 |
|
---|
2408 |
|
---|
2409 | /* SVGA_3D_CMD_DX_DRAW_INSTANCED 1154 */
|
---|
2410 | static int vmsvga3dCmdDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd, uint32_t cbCmd)
|
---|
2411 | {
|
---|
2412 | #ifdef VMSVGA3D_DX
|
---|
2413 | //DEBUG_BREAKPOINT_TEST();
|
---|
2414 | RT_NOREF(cbCmd);
|
---|
2415 | return vmsvga3dDXDrawInstanced(pThisCC, idDXContext, pCmd);
|
---|
2416 | #else
|
---|
2417 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2418 | return VERR_NOT_SUPPORTED;
|
---|
2419 | #endif
|
---|
2420 | }
|
---|
2421 |
|
---|
2422 |
|
---|
2423 | /* SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED 1155 */
|
---|
2424 | static int vmsvga3dCmdDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd, uint32_t cbCmd)
|
---|
2425 | {
|
---|
2426 | #ifdef VMSVGA3D_DX
|
---|
2427 | //DEBUG_BREAKPOINT_TEST();
|
---|
2428 | RT_NOREF(cbCmd);
|
---|
2429 | return vmsvga3dDXDrawIndexedInstanced(pThisCC, idDXContext, pCmd);
|
---|
2430 | #else
|
---|
2431 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2432 | return VERR_NOT_SUPPORTED;
|
---|
2433 | #endif
|
---|
2434 | }
|
---|
2435 |
|
---|
2436 |
|
---|
2437 | /* SVGA_3D_CMD_DX_DRAW_AUTO 1156 */
|
---|
2438 | static int vmsvga3dCmdDXDrawAuto(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawAuto const *pCmd, uint32_t cbCmd)
|
---|
2439 | {
|
---|
2440 | #ifdef VMSVGA3D_DX
|
---|
2441 | //DEBUG_BREAKPOINT_TEST();
|
---|
2442 | RT_NOREF(pCmd, cbCmd);
|
---|
2443 | return vmsvga3dDXDrawAuto(pThisCC, idDXContext);
|
---|
2444 | #else
|
---|
2445 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2446 | return VERR_NOT_SUPPORTED;
|
---|
2447 | #endif
|
---|
2448 | }
|
---|
2449 |
|
---|
2450 |
|
---|
2451 | /* SVGA_3D_CMD_DX_SET_INPUT_LAYOUT 1157 */
|
---|
2452 | static int vmsvga3dCmdDXSetInputLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetInputLayout const *pCmd, uint32_t cbCmd)
|
---|
2453 | {
|
---|
2454 | #ifdef VMSVGA3D_DX
|
---|
2455 | //DEBUG_BREAKPOINT_TEST();
|
---|
2456 | RT_NOREF(cbCmd);
|
---|
2457 | return vmsvga3dDXSetInputLayout(pThisCC, idDXContext, pCmd->elementLayoutId);
|
---|
2458 | #else
|
---|
2459 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2460 | return VERR_NOT_SUPPORTED;
|
---|
2461 | #endif
|
---|
2462 | }
|
---|
2463 |
|
---|
2464 |
|
---|
2465 | /* SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS 1158 */
|
---|
2466 | static int vmsvga3dCmdDXSetVertexBuffers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetVertexBuffers const *pCmd, uint32_t cbCmd)
|
---|
2467 | {
|
---|
2468 | #ifdef VMSVGA3D_DX
|
---|
2469 | //DEBUG_BREAKPOINT_TEST();
|
---|
2470 | SVGA3dVertexBuffer const *paVertexBuffer = (SVGA3dVertexBuffer *)&pCmd[1];
|
---|
2471 | uint32_t const cVertexBuffer = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dVertexBuffer);
|
---|
2472 | return vmsvga3dDXSetVertexBuffers(pThisCC, idDXContext, pCmd->startBuffer, cVertexBuffer, paVertexBuffer);
|
---|
2473 | #else
|
---|
2474 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2475 | return VERR_NOT_SUPPORTED;
|
---|
2476 | #endif
|
---|
2477 | }
|
---|
2478 |
|
---|
2479 |
|
---|
2480 | /* SVGA_3D_CMD_DX_SET_INDEX_BUFFER 1159 */
|
---|
2481 | static int vmsvga3dCmdDXSetIndexBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetIndexBuffer const *pCmd, uint32_t cbCmd)
|
---|
2482 | {
|
---|
2483 | #ifdef VMSVGA3D_DX
|
---|
2484 | //DEBUG_BREAKPOINT_TEST();
|
---|
2485 | RT_NOREF(cbCmd);
|
---|
2486 | return vmsvga3dDXSetIndexBuffer(pThisCC, idDXContext, pCmd);
|
---|
2487 | #else
|
---|
2488 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2489 | return VERR_NOT_SUPPORTED;
|
---|
2490 | #endif
|
---|
2491 | }
|
---|
2492 |
|
---|
2493 |
|
---|
2494 | /* SVGA_3D_CMD_DX_SET_TOPOLOGY 1160 */
|
---|
2495 | static int vmsvga3dCmdDXSetTopology(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetTopology const *pCmd, uint32_t cbCmd)
|
---|
2496 | {
|
---|
2497 | #ifdef VMSVGA3D_DX
|
---|
2498 | //DEBUG_BREAKPOINT_TEST();
|
---|
2499 | RT_NOREF(cbCmd);
|
---|
2500 | return vmsvga3dDXSetTopology(pThisCC, idDXContext, pCmd->topology);
|
---|
2501 | #else
|
---|
2502 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2503 | return VERR_NOT_SUPPORTED;
|
---|
2504 | #endif
|
---|
2505 | }
|
---|
2506 |
|
---|
2507 |
|
---|
2508 | /* SVGA_3D_CMD_DX_SET_RENDERTARGETS 1161 */
|
---|
2509 | static int vmsvga3dCmdDXSetRenderTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetRenderTargets const *pCmd, uint32_t cbCmd)
|
---|
2510 | {
|
---|
2511 | #ifdef VMSVGA3D_DX
|
---|
2512 | //DEBUG_BREAKPOINT_TEST();
|
---|
2513 | SVGA3dRenderTargetViewId const *paRenderTargetViewId = (SVGA3dRenderTargetViewId *)&pCmd[1];
|
---|
2514 | uint32_t const cRenderTargetViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderTargetViewId);
|
---|
2515 | return vmsvga3dDXSetRenderTargets(pThisCC, idDXContext, pCmd->depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId);
|
---|
2516 | #else
|
---|
2517 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2518 | return VERR_NOT_SUPPORTED;
|
---|
2519 | #endif
|
---|
2520 | }
|
---|
2521 |
|
---|
2522 |
|
---|
2523 | /* SVGA_3D_CMD_DX_SET_BLEND_STATE 1162 */
|
---|
2524 | static int vmsvga3dCmdDXSetBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetBlendState const *pCmd, uint32_t cbCmd)
|
---|
2525 | {
|
---|
2526 | #ifdef VMSVGA3D_DX
|
---|
2527 | //DEBUG_BREAKPOINT_TEST();
|
---|
2528 | RT_NOREF(cbCmd);
|
---|
2529 | return vmsvga3dDXSetBlendState(pThisCC, idDXContext, pCmd);
|
---|
2530 | #else
|
---|
2531 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2532 | return VERR_NOT_SUPPORTED;
|
---|
2533 | #endif
|
---|
2534 | }
|
---|
2535 |
|
---|
2536 |
|
---|
2537 | /* SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE 1163 */
|
---|
2538 | static int vmsvga3dCmdDXSetDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDepthStencilState const *pCmd, uint32_t cbCmd)
|
---|
2539 | {
|
---|
2540 | #ifdef VMSVGA3D_DX
|
---|
2541 | //DEBUG_BREAKPOINT_TEST();
|
---|
2542 | RT_NOREF(cbCmd);
|
---|
2543 | return vmsvga3dDXSetDepthStencilState(pThisCC, idDXContext, pCmd);
|
---|
2544 | #else
|
---|
2545 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2546 | return VERR_NOT_SUPPORTED;
|
---|
2547 | #endif
|
---|
2548 | }
|
---|
2549 |
|
---|
2550 |
|
---|
2551 | /* SVGA_3D_CMD_DX_SET_RASTERIZER_STATE 1164 */
|
---|
2552 | static int vmsvga3dCmdDXSetRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetRasterizerState const *pCmd, uint32_t cbCmd)
|
---|
2553 | {
|
---|
2554 | #ifdef VMSVGA3D_DX
|
---|
2555 | //DEBUG_BREAKPOINT_TEST();
|
---|
2556 | RT_NOREF(cbCmd);
|
---|
2557 | return vmsvga3dDXSetRasterizerState(pThisCC, idDXContext, pCmd->rasterizerId);
|
---|
2558 | #else
|
---|
2559 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2560 | return VERR_NOT_SUPPORTED;
|
---|
2561 | #endif
|
---|
2562 | }
|
---|
2563 |
|
---|
2564 |
|
---|
2565 | /* SVGA_3D_CMD_DX_DEFINE_QUERY 1165 */
|
---|
2566 | static int vmsvga3dCmdDXDefineQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineQuery const *pCmd, uint32_t cbCmd)
|
---|
2567 | {
|
---|
2568 | #ifdef VMSVGA3D_DX
|
---|
2569 | //DEBUG_BREAKPOINT_TEST();
|
---|
2570 | RT_NOREF(cbCmd);
|
---|
2571 | return vmsvga3dDXDefineQuery(pThisCC, idDXContext, pCmd);
|
---|
2572 | #else
|
---|
2573 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2574 | return VERR_NOT_SUPPORTED;
|
---|
2575 | #endif
|
---|
2576 | }
|
---|
2577 |
|
---|
2578 |
|
---|
2579 | /* SVGA_3D_CMD_DX_DESTROY_QUERY 1166 */
|
---|
2580 | static int vmsvga3dCmdDXDestroyQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyQuery const *pCmd, uint32_t cbCmd)
|
---|
2581 | {
|
---|
2582 | #ifdef VMSVGA3D_DX
|
---|
2583 | //DEBUG_BREAKPOINT_TEST();
|
---|
2584 | RT_NOREF(cbCmd);
|
---|
2585 | return vmsvga3dDXDestroyQuery(pThisCC, idDXContext, pCmd);
|
---|
2586 | #else
|
---|
2587 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2588 | return VERR_NOT_SUPPORTED;
|
---|
2589 | #endif
|
---|
2590 | }
|
---|
2591 |
|
---|
2592 |
|
---|
2593 | /* SVGA_3D_CMD_DX_BIND_QUERY 1167 */
|
---|
2594 | static int vmsvga3dCmdDXBindQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindQuery const *pCmd, uint32_t cbCmd)
|
---|
2595 | {
|
---|
2596 | #ifdef VMSVGA3D_DX
|
---|
2597 | //DEBUG_BREAKPOINT_TEST();
|
---|
2598 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2599 | RT_NOREF(cbCmd);
|
---|
2600 | /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
|
---|
2601 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
|
---|
2602 | return vmsvga3dDXBindQuery(pThisCC, idDXContext, pCmd, pMob);
|
---|
2603 | #else
|
---|
2604 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2605 | return VERR_NOT_SUPPORTED;
|
---|
2606 | #endif
|
---|
2607 | }
|
---|
2608 |
|
---|
2609 |
|
---|
2610 | /* SVGA_3D_CMD_DX_SET_QUERY_OFFSET 1168 */
|
---|
2611 | static int vmsvga3dCmdDXSetQueryOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetQueryOffset const *pCmd, uint32_t cbCmd)
|
---|
2612 | {
|
---|
2613 | #ifdef VMSVGA3D_DX
|
---|
2614 | //DEBUG_BREAKPOINT_TEST();
|
---|
2615 | RT_NOREF(cbCmd);
|
---|
2616 | return vmsvga3dDXSetQueryOffset(pThisCC, idDXContext, pCmd);
|
---|
2617 | #else
|
---|
2618 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2619 | return VERR_NOT_SUPPORTED;
|
---|
2620 | #endif
|
---|
2621 | }
|
---|
2622 |
|
---|
2623 |
|
---|
2624 | /* SVGA_3D_CMD_DX_BEGIN_QUERY 1169 */
|
---|
2625 | static int vmsvga3dCmdDXBeginQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBeginQuery const *pCmd, uint32_t cbCmd)
|
---|
2626 | {
|
---|
2627 | #ifdef VMSVGA3D_DX
|
---|
2628 | //DEBUG_BREAKPOINT_TEST();
|
---|
2629 | RT_NOREF(cbCmd);
|
---|
2630 | return vmsvga3dDXBeginQuery(pThisCC, idDXContext, pCmd);
|
---|
2631 | #else
|
---|
2632 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2633 | return VERR_NOT_SUPPORTED;
|
---|
2634 | #endif
|
---|
2635 | }
|
---|
2636 |
|
---|
2637 |
|
---|
2638 | /* SVGA_3D_CMD_DX_END_QUERY 1170 */
|
---|
2639 | static int vmsvga3dCmdDXEndQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXEndQuery const *pCmd, uint32_t cbCmd)
|
---|
2640 | {
|
---|
2641 | #ifdef VMSVGA3D_DX
|
---|
2642 | //DEBUG_BREAKPOINT_TEST();
|
---|
2643 | RT_NOREF(cbCmd);
|
---|
2644 | return vmsvga3dDXEndQuery(pThisCC, idDXContext, pCmd);
|
---|
2645 | #else
|
---|
2646 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2647 | return VERR_NOT_SUPPORTED;
|
---|
2648 | #endif
|
---|
2649 | }
|
---|
2650 |
|
---|
2651 |
|
---|
2652 | /* SVGA_3D_CMD_DX_READBACK_QUERY 1171 */
|
---|
2653 | static int vmsvga3dCmdDXReadbackQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackQuery const *pCmd, uint32_t cbCmd)
|
---|
2654 | {
|
---|
2655 | #ifdef VMSVGA3D_DX
|
---|
2656 | //DEBUG_BREAKPOINT_TEST();
|
---|
2657 | RT_NOREF(cbCmd);
|
---|
2658 | return vmsvga3dDXReadbackQuery(pThisCC, idDXContext, pCmd);
|
---|
2659 | #else
|
---|
2660 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2661 | return VERR_NOT_SUPPORTED;
|
---|
2662 | #endif
|
---|
2663 | }
|
---|
2664 |
|
---|
2665 |
|
---|
2666 | /* SVGA_3D_CMD_DX_SET_PREDICATION 1172 */
|
---|
2667 | static int vmsvga3dCmdDXSetPredication(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetPredication const *pCmd, uint32_t cbCmd)
|
---|
2668 | {
|
---|
2669 | #ifdef VMSVGA3D_DX
|
---|
2670 | //DEBUG_BREAKPOINT_TEST();
|
---|
2671 | RT_NOREF(cbCmd);
|
---|
2672 | return vmsvga3dDXSetPredication(pThisCC, idDXContext, pCmd);
|
---|
2673 | #else
|
---|
2674 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2675 | return VERR_NOT_SUPPORTED;
|
---|
2676 | #endif
|
---|
2677 | }
|
---|
2678 |
|
---|
2679 |
|
---|
2680 | /* SVGA_3D_CMD_DX_SET_SOTARGETS 1173 */
|
---|
2681 | static int vmsvga3dCmdDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSOTargets const *pCmd, uint32_t cbCmd)
|
---|
2682 | {
|
---|
2683 | #ifdef VMSVGA3D_DX
|
---|
2684 | //DEBUG_BREAKPOINT_TEST();
|
---|
2685 | SVGA3dSoTarget const *paSoTarget = (SVGA3dSoTarget *)&pCmd[1];
|
---|
2686 | uint32_t const cSoTarget = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSoTarget);
|
---|
2687 | return vmsvga3dDXSetSOTargets(pThisCC, idDXContext, cSoTarget, paSoTarget);
|
---|
2688 | #else
|
---|
2689 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2690 | return VERR_NOT_SUPPORTED;
|
---|
2691 | #endif
|
---|
2692 | }
|
---|
2693 |
|
---|
2694 |
|
---|
2695 | /* SVGA_3D_CMD_DX_SET_VIEWPORTS 1174 */
|
---|
2696 | static int vmsvga3dCmdDXSetViewports(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetViewports const *pCmd, uint32_t cbCmd)
|
---|
2697 | {
|
---|
2698 | #ifdef VMSVGA3D_DX
|
---|
2699 | //DEBUG_BREAKPOINT_TEST();
|
---|
2700 | SVGA3dViewport const *paViewport = (SVGA3dViewport *)&pCmd[1];
|
---|
2701 | uint32_t const cViewport = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dViewport);
|
---|
2702 | return vmsvga3dDXSetViewports(pThisCC, idDXContext, cViewport, paViewport);
|
---|
2703 | #else
|
---|
2704 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2705 | return VERR_NOT_SUPPORTED;
|
---|
2706 | #endif
|
---|
2707 | }
|
---|
2708 |
|
---|
2709 |
|
---|
2710 | /* SVGA_3D_CMD_DX_SET_SCISSORRECTS 1175 */
|
---|
2711 | static int vmsvga3dCmdDXSetScissorRects(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetScissorRects const *pCmd, uint32_t cbCmd)
|
---|
2712 | {
|
---|
2713 | #ifdef VMSVGA3D_DX
|
---|
2714 | //DEBUG_BREAKPOINT_TEST();
|
---|
2715 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
2716 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
2717 | return vmsvga3dDXSetScissorRects(pThisCC, idDXContext, cRect, paRect);
|
---|
2718 | #else
|
---|
2719 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2720 | return VERR_NOT_SUPPORTED;
|
---|
2721 | #endif
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 |
|
---|
2725 | /* SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW 1176 */
|
---|
2726 | static int vmsvga3dCmdDXClearRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearRenderTargetView const *pCmd, uint32_t cbCmd)
|
---|
2727 | {
|
---|
2728 | #ifdef VMSVGA3D_DX
|
---|
2729 | //DEBUG_BREAKPOINT_TEST();
|
---|
2730 | RT_NOREF(cbCmd);
|
---|
2731 | return vmsvga3dDXClearRenderTargetView(pThisCC, idDXContext, pCmd);
|
---|
2732 | #else
|
---|
2733 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2734 | return VERR_NOT_SUPPORTED;
|
---|
2735 | #endif
|
---|
2736 | }
|
---|
2737 |
|
---|
2738 |
|
---|
2739 | /* SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW 1177 */
|
---|
2740 | static int vmsvga3dCmdDXClearDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearDepthStencilView const *pCmd, uint32_t cbCmd)
|
---|
2741 | {
|
---|
2742 | #ifdef VMSVGA3D_DX
|
---|
2743 | //DEBUG_BREAKPOINT_TEST();
|
---|
2744 | RT_NOREF(cbCmd);
|
---|
2745 | return vmsvga3dDXClearDepthStencilView(pThisCC, idDXContext, pCmd);
|
---|
2746 | #else
|
---|
2747 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2748 | return VERR_NOT_SUPPORTED;
|
---|
2749 | #endif
|
---|
2750 | }
|
---|
2751 |
|
---|
2752 |
|
---|
2753 | /* SVGA_3D_CMD_DX_PRED_COPY_REGION 1178 */
|
---|
2754 | static int vmsvga3dCmdDXPredCopyRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopyRegion const *pCmd, uint32_t cbCmd)
|
---|
2755 | {
|
---|
2756 | #ifdef VMSVGA3D_DX
|
---|
2757 | //DEBUG_BREAKPOINT_TEST();
|
---|
2758 | RT_NOREF(cbCmd);
|
---|
2759 | return vmsvga3dDXPredCopyRegion(pThisCC, idDXContext, pCmd);
|
---|
2760 | #else
|
---|
2761 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2762 | return VERR_NOT_SUPPORTED;
|
---|
2763 | #endif
|
---|
2764 | }
|
---|
2765 |
|
---|
2766 |
|
---|
2767 | /* SVGA_3D_CMD_DX_PRED_COPY 1179 */
|
---|
2768 | static int vmsvga3dCmdDXPredCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopy const *pCmd, uint32_t cbCmd)
|
---|
2769 | {
|
---|
2770 | #ifdef VMSVGA3D_DX
|
---|
2771 | //DEBUG_BREAKPOINT_TEST();
|
---|
2772 | RT_NOREF(cbCmd);
|
---|
2773 | return vmsvga3dDXPredCopy(pThisCC, idDXContext, pCmd);
|
---|
2774 | #else
|
---|
2775 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2776 | return VERR_NOT_SUPPORTED;
|
---|
2777 | #endif
|
---|
2778 | }
|
---|
2779 |
|
---|
2780 |
|
---|
2781 | /* SVGA_3D_CMD_DX_PRESENTBLT 1180 */
|
---|
2782 | static int vmsvga3dCmdDXPresentBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPresentBlt const *pCmd, uint32_t cbCmd)
|
---|
2783 | {
|
---|
2784 | #ifdef VMSVGA3D_DX
|
---|
2785 | //DEBUG_BREAKPOINT_TEST();
|
---|
2786 | RT_NOREF(cbCmd);
|
---|
2787 | return vmsvga3dDXPresentBlt(pThisCC, idDXContext, pCmd);
|
---|
2788 | #else
|
---|
2789 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2790 | return VERR_NOT_SUPPORTED;
|
---|
2791 | #endif
|
---|
2792 | }
|
---|
2793 |
|
---|
2794 |
|
---|
2795 | /* SVGA_3D_CMD_DX_GENMIPS 1181 */
|
---|
2796 | static int vmsvga3dCmdDXGenMips(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXGenMips const *pCmd, uint32_t cbCmd)
|
---|
2797 | {
|
---|
2798 | #ifdef VMSVGA3D_DX
|
---|
2799 | //DEBUG_BREAKPOINT_TEST();
|
---|
2800 | RT_NOREF(cbCmd);
|
---|
2801 | return vmsvga3dDXGenMips(pThisCC, idDXContext, pCmd);
|
---|
2802 | #else
|
---|
2803 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2804 | return VERR_NOT_SUPPORTED;
|
---|
2805 | #endif
|
---|
2806 | }
|
---|
2807 |
|
---|
2808 |
|
---|
2809 | /* SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE 1182 */
|
---|
2810 | static int vmsvga3dCmdDXUpdateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXUpdateSubResource const *pCmd, uint32_t cbCmd)
|
---|
2811 | {
|
---|
2812 | #ifdef VMSVGA3D_DX
|
---|
2813 | //DEBUG_BREAKPOINT_TEST();
|
---|
2814 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2815 | RT_NOREF(cbCmd);
|
---|
2816 |
|
---|
2817 | LogFlowFunc(("sid=%u, subResource=%u, box=%d,%d,%d %ux%ux%u\n",
|
---|
2818 | pCmd->sid, pCmd->subResource, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.d));
|
---|
2819 |
|
---|
2820 | /* "Inform the device that the guest-contents have been updated." */
|
---|
2821 | SVGAOTableSurfaceEntry entrySurface;
|
---|
2822 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
2823 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
2824 | if (RT_SUCCESS(rc))
|
---|
2825 | {
|
---|
2826 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
2827 | if (pMob)
|
---|
2828 | {
|
---|
2829 | uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid);
|
---|
2830 | ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER);
|
---|
2831 | /* pCmd->box will be verified by the mapping function. */
|
---|
2832 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2833 |
|
---|
2834 | /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */
|
---|
2835 | SVGA3dSurfaceImageId image;
|
---|
2836 | image.sid = pCmd->sid;
|
---|
2837 | vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face);
|
---|
2838 |
|
---|
2839 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM);
|
---|
2840 | AssertRC(rc);
|
---|
2841 | }
|
---|
2842 | }
|
---|
2843 |
|
---|
2844 | return rc;
|
---|
2845 | #else
|
---|
2846 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2847 | return VERR_NOT_SUPPORTED;
|
---|
2848 | #endif
|
---|
2849 | }
|
---|
2850 |
|
---|
2851 |
|
---|
2852 | /* SVGA_3D_CMD_DX_READBACK_SUBRESOURCE 1183 */
|
---|
2853 | static int vmsvga3dCmdDXReadbackSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackSubResource const *pCmd, uint32_t cbCmd)
|
---|
2854 | {
|
---|
2855 | #ifdef VMSVGA3D_DX
|
---|
2856 | //DEBUG_BREAKPOINT_TEST();
|
---|
2857 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2858 | RT_NOREF(cbCmd);
|
---|
2859 |
|
---|
2860 | LogFlowFunc(("sid=%u, subResource=%u\n",
|
---|
2861 | pCmd->sid, pCmd->subResource));
|
---|
2862 |
|
---|
2863 | /* "Request the device to flush the dirty contents into the guest." */
|
---|
2864 | SVGAOTableSurfaceEntry entrySurface;
|
---|
2865 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
2866 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
2867 | if (RT_SUCCESS(rc))
|
---|
2868 | {
|
---|
2869 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);
|
---|
2870 | if (pMob)
|
---|
2871 | {
|
---|
2872 | uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid);
|
---|
2873 | ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER);
|
---|
2874 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2875 |
|
---|
2876 | /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */
|
---|
2877 | SVGA3dSurfaceImageId image;
|
---|
2878 | image.sid = pCmd->sid;
|
---|
2879 | vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face);
|
---|
2880 |
|
---|
2881 | rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM);
|
---|
2882 | AssertRC(rc);
|
---|
2883 | }
|
---|
2884 | }
|
---|
2885 |
|
---|
2886 | return rc;
|
---|
2887 | #else
|
---|
2888 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2889 | return VERR_NOT_SUPPORTED;
|
---|
2890 | #endif
|
---|
2891 | }
|
---|
2892 |
|
---|
2893 |
|
---|
2894 | /* SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE 1184 */
|
---|
2895 | static int vmsvga3dCmdDXInvalidateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXInvalidateSubResource const *pCmd, uint32_t cbCmd)
|
---|
2896 | {
|
---|
2897 | #ifdef VMSVGA3D_DX
|
---|
2898 | DEBUG_BREAKPOINT_TEST();
|
---|
2899 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2900 | RT_NOREF(cbCmd);
|
---|
2901 |
|
---|
2902 | LogFlowFunc(("sid=%u, subResource=%u\n",
|
---|
2903 | pCmd->sid, pCmd->subResource));
|
---|
2904 |
|
---|
2905 | /* "Notify the device that the contents can be lost." */
|
---|
2906 | SVGAOTableSurfaceEntry entrySurface;
|
---|
2907 | int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
2908 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));
|
---|
2909 | if (RT_SUCCESS(rc))
|
---|
2910 | {
|
---|
2911 | uint32_t iFace;
|
---|
2912 | uint32_t iMipmap;
|
---|
2913 | vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &iMipmap, &iFace);
|
---|
2914 | vmsvga3dSurfaceInvalidate(pThisCC, pCmd->sid, iFace, iMipmap);
|
---|
2915 | }
|
---|
2916 |
|
---|
2917 | return rc;
|
---|
2918 | #else
|
---|
2919 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
2920 | return VERR_NOT_SUPPORTED;
|
---|
2921 | #endif
|
---|
2922 | }
|
---|
2923 |
|
---|
2924 |
|
---|
2925 | /* SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW 1185 */
|
---|
2926 | static int vmsvga3dCmdDXDefineShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShaderResourceView const *pCmd, uint32_t cbCmd)
|
---|
2927 | {
|
---|
2928 | #ifdef VMSVGA3D_DX
|
---|
2929 | //DEBUG_BREAKPOINT_TEST();
|
---|
2930 | RT_NOREF(cbCmd);
|
---|
2931 | return vmsvga3dDXDefineShaderResourceView(pThisCC, idDXContext, pCmd);
|
---|
2932 | #else
|
---|
2933 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2934 | return VERR_NOT_SUPPORTED;
|
---|
2935 | #endif
|
---|
2936 | }
|
---|
2937 |
|
---|
2938 |
|
---|
2939 | /* SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW 1186 */
|
---|
2940 | static int vmsvga3dCmdDXDestroyShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShaderResourceView const *pCmd, uint32_t cbCmd)
|
---|
2941 | {
|
---|
2942 | #ifdef VMSVGA3D_DX
|
---|
2943 | //DEBUG_BREAKPOINT_TEST();
|
---|
2944 | RT_NOREF(cbCmd);
|
---|
2945 | return vmsvga3dDXDestroyShaderResourceView(pThisCC, idDXContext, pCmd);
|
---|
2946 | #else
|
---|
2947 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2948 | return VERR_NOT_SUPPORTED;
|
---|
2949 | #endif
|
---|
2950 | }
|
---|
2951 |
|
---|
2952 |
|
---|
2953 | /* SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW 1187 */
|
---|
2954 | static int vmsvga3dCmdDXDefineRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRenderTargetView const *pCmd, uint32_t cbCmd)
|
---|
2955 | {
|
---|
2956 | #ifdef VMSVGA3D_DX
|
---|
2957 | //DEBUG_BREAKPOINT_TEST();
|
---|
2958 | RT_NOREF(cbCmd);
|
---|
2959 | return vmsvga3dDXDefineRenderTargetView(pThisCC, idDXContext, pCmd);
|
---|
2960 | #else
|
---|
2961 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2962 | return VERR_NOT_SUPPORTED;
|
---|
2963 | #endif
|
---|
2964 | }
|
---|
2965 |
|
---|
2966 |
|
---|
2967 | /* SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW 1188 */
|
---|
2968 | static int vmsvga3dCmdDXDestroyRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRenderTargetView const *pCmd, uint32_t cbCmd)
|
---|
2969 | {
|
---|
2970 | #ifdef VMSVGA3D_DX
|
---|
2971 | //DEBUG_BREAKPOINT_TEST();
|
---|
2972 | RT_NOREF(cbCmd);
|
---|
2973 | return vmsvga3dDXDestroyRenderTargetView(pThisCC, idDXContext, pCmd);
|
---|
2974 | #else
|
---|
2975 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2976 | return VERR_NOT_SUPPORTED;
|
---|
2977 | #endif
|
---|
2978 | }
|
---|
2979 |
|
---|
2980 |
|
---|
2981 | /* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW 1189 */
|
---|
2982 | static int vmsvga3dCmdDXDefineDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView const *pCmd, uint32_t cbCmd)
|
---|
2983 | {
|
---|
2984 | #ifdef VMSVGA3D_DX
|
---|
2985 | //DEBUG_BREAKPOINT_TEST();
|
---|
2986 | RT_NOREF(cbCmd);
|
---|
2987 | SVGA3dCmdDXDefineDepthStencilView_v2 cmd;
|
---|
2988 | cmd.depthStencilViewId = pCmd->depthStencilViewId;
|
---|
2989 | cmd.sid = pCmd->sid;
|
---|
2990 | cmd.format = pCmd->format;
|
---|
2991 | cmd.resourceDimension = pCmd->resourceDimension;
|
---|
2992 | cmd.mipSlice = pCmd->mipSlice;
|
---|
2993 | cmd.firstArraySlice = pCmd->firstArraySlice;
|
---|
2994 | cmd.arraySize = pCmd->arraySize;
|
---|
2995 | cmd.flags = 0;
|
---|
2996 | return vmsvga3dDXDefineDepthStencilView(pThisCC, idDXContext, &cmd);
|
---|
2997 | #else
|
---|
2998 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
2999 | return VERR_NOT_SUPPORTED;
|
---|
3000 | #endif
|
---|
3001 | }
|
---|
3002 |
|
---|
3003 |
|
---|
3004 | /* SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW 1190 */
|
---|
3005 | static int vmsvga3dCmdDXDestroyDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilView const *pCmd, uint32_t cbCmd)
|
---|
3006 | {
|
---|
3007 | #ifdef VMSVGA3D_DX
|
---|
3008 | //DEBUG_BREAKPOINT_TEST();
|
---|
3009 | RT_NOREF(cbCmd);
|
---|
3010 | return vmsvga3dDXDestroyDepthStencilView(pThisCC, idDXContext, pCmd);
|
---|
3011 | #else
|
---|
3012 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3013 | return VERR_NOT_SUPPORTED;
|
---|
3014 | #endif
|
---|
3015 | }
|
---|
3016 |
|
---|
3017 |
|
---|
3018 | /* SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT 1191 */
|
---|
3019 | static int vmsvga3dCmdDXDefineElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineElementLayout const *pCmd, uint32_t cbCmd)
|
---|
3020 | {
|
---|
3021 | #ifdef VMSVGA3D_DX
|
---|
3022 | //DEBUG_BREAKPOINT_TEST();
|
---|
3023 | SVGA3dInputElementDesc const *paDesc = (SVGA3dInputElementDesc *)&pCmd[1];
|
---|
3024 | uint32_t const cDesc = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dInputElementDesc);
|
---|
3025 | return vmsvga3dDXDefineElementLayout(pThisCC, idDXContext, pCmd->elementLayoutId, cDesc, paDesc);
|
---|
3026 | #else
|
---|
3027 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3028 | return VERR_NOT_SUPPORTED;
|
---|
3029 | #endif
|
---|
3030 | }
|
---|
3031 |
|
---|
3032 |
|
---|
3033 | /* SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT 1192 */
|
---|
3034 | static int vmsvga3dCmdDXDestroyElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyElementLayout const *pCmd, uint32_t cbCmd)
|
---|
3035 | {
|
---|
3036 | #ifdef VMSVGA3D_DX
|
---|
3037 | //DEBUG_BREAKPOINT_TEST();
|
---|
3038 | RT_NOREF(cbCmd);
|
---|
3039 | return vmsvga3dDXDestroyElementLayout(pThisCC, idDXContext, pCmd);
|
---|
3040 | #else
|
---|
3041 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3042 | return VERR_NOT_SUPPORTED;
|
---|
3043 | #endif
|
---|
3044 | }
|
---|
3045 |
|
---|
3046 |
|
---|
3047 | /* SVGA_3D_CMD_DX_DEFINE_BLEND_STATE 1193 */
|
---|
3048 | static int vmsvga3dCmdDXDefineBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineBlendState const *pCmd, uint32_t cbCmd)
|
---|
3049 | {
|
---|
3050 | #ifdef VMSVGA3D_DX
|
---|
3051 | //DEBUG_BREAKPOINT_TEST();
|
---|
3052 | RT_NOREF(cbCmd);
|
---|
3053 | return vmsvga3dDXDefineBlendState(pThisCC, idDXContext, pCmd);
|
---|
3054 | #else
|
---|
3055 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3056 | return VERR_NOT_SUPPORTED;
|
---|
3057 | #endif
|
---|
3058 | }
|
---|
3059 |
|
---|
3060 |
|
---|
3061 | /* SVGA_3D_CMD_DX_DESTROY_BLEND_STATE 1194 */
|
---|
3062 | static int vmsvga3dCmdDXDestroyBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyBlendState const *pCmd, uint32_t cbCmd)
|
---|
3063 | {
|
---|
3064 | #ifdef VMSVGA3D_DX
|
---|
3065 | //DEBUG_BREAKPOINT_TEST();
|
---|
3066 | RT_NOREF(cbCmd);
|
---|
3067 | return vmsvga3dDXDestroyBlendState(pThisCC, idDXContext, pCmd);
|
---|
3068 | #else
|
---|
3069 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3070 | return VERR_NOT_SUPPORTED;
|
---|
3071 | #endif
|
---|
3072 | }
|
---|
3073 |
|
---|
3074 |
|
---|
3075 | /* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE 1195 */
|
---|
3076 | static int vmsvga3dCmdDXDefineDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilState const *pCmd, uint32_t cbCmd)
|
---|
3077 | {
|
---|
3078 | #ifdef VMSVGA3D_DX
|
---|
3079 | //DEBUG_BREAKPOINT_TEST();
|
---|
3080 | RT_NOREF(cbCmd);
|
---|
3081 | return vmsvga3dDXDefineDepthStencilState(pThisCC, idDXContext, pCmd);
|
---|
3082 | #else
|
---|
3083 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3084 | return VERR_NOT_SUPPORTED;
|
---|
3085 | #endif
|
---|
3086 | }
|
---|
3087 |
|
---|
3088 |
|
---|
3089 | /* SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE 1196 */
|
---|
3090 | static int vmsvga3dCmdDXDestroyDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilState const *pCmd, uint32_t cbCmd)
|
---|
3091 | {
|
---|
3092 | #ifdef VMSVGA3D_DX
|
---|
3093 | //DEBUG_BREAKPOINT_TEST();
|
---|
3094 | RT_NOREF(cbCmd);
|
---|
3095 | return vmsvga3dDXDestroyDepthStencilState(pThisCC, idDXContext, pCmd);
|
---|
3096 | #else
|
---|
3097 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3098 | return VERR_NOT_SUPPORTED;
|
---|
3099 | #endif
|
---|
3100 | }
|
---|
3101 |
|
---|
3102 |
|
---|
3103 | /* SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE 1197 */
|
---|
3104 | static int vmsvga3dCmdDXDefineRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRasterizerState const *pCmd, uint32_t cbCmd)
|
---|
3105 | {
|
---|
3106 | #ifdef VMSVGA3D_DX
|
---|
3107 | //DEBUG_BREAKPOINT_TEST();
|
---|
3108 | RT_NOREF(cbCmd);
|
---|
3109 | return vmsvga3dDXDefineRasterizerState(pThisCC, idDXContext, pCmd);
|
---|
3110 | #else
|
---|
3111 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3112 | return VERR_NOT_SUPPORTED;
|
---|
3113 | #endif
|
---|
3114 | }
|
---|
3115 |
|
---|
3116 |
|
---|
3117 | /* SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE 1198 */
|
---|
3118 | static int vmsvga3dCmdDXDestroyRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRasterizerState const *pCmd, uint32_t cbCmd)
|
---|
3119 | {
|
---|
3120 | #ifdef VMSVGA3D_DX
|
---|
3121 | //DEBUG_BREAKPOINT_TEST();
|
---|
3122 | RT_NOREF(cbCmd);
|
---|
3123 | return vmsvga3dDXDestroyRasterizerState(pThisCC, idDXContext, pCmd);
|
---|
3124 | #else
|
---|
3125 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3126 | return VERR_NOT_SUPPORTED;
|
---|
3127 | #endif
|
---|
3128 | }
|
---|
3129 |
|
---|
3130 |
|
---|
3131 | /* SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE 1199 */
|
---|
3132 | static int vmsvga3dCmdDXDefineSamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineSamplerState const *pCmd, uint32_t cbCmd)
|
---|
3133 | {
|
---|
3134 | #ifdef VMSVGA3D_DX
|
---|
3135 | //DEBUG_BREAKPOINT_TEST();
|
---|
3136 | RT_NOREF(cbCmd);
|
---|
3137 | return vmsvga3dDXDefineSamplerState(pThisCC, idDXContext, pCmd);
|
---|
3138 | #else
|
---|
3139 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3140 | return VERR_NOT_SUPPORTED;
|
---|
3141 | #endif
|
---|
3142 | }
|
---|
3143 |
|
---|
3144 |
|
---|
3145 | /* SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE 1200 */
|
---|
3146 | static int vmsvga3dCmdDXDestroySamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroySamplerState const *pCmd, uint32_t cbCmd)
|
---|
3147 | {
|
---|
3148 | #ifdef VMSVGA3D_DX
|
---|
3149 | //DEBUG_BREAKPOINT_TEST();
|
---|
3150 | RT_NOREF(cbCmd);
|
---|
3151 | return vmsvga3dDXDestroySamplerState(pThisCC, idDXContext, pCmd);
|
---|
3152 | #else
|
---|
3153 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3154 | return VERR_NOT_SUPPORTED;
|
---|
3155 | #endif
|
---|
3156 | }
|
---|
3157 |
|
---|
3158 |
|
---|
3159 | /* SVGA_3D_CMD_DX_DEFINE_SHADER 1201 */
|
---|
3160 | static int vmsvga3dCmdDXDefineShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShader const *pCmd, uint32_t cbCmd)
|
---|
3161 | {
|
---|
3162 | #ifdef VMSVGA3D_DX
|
---|
3163 | //DEBUG_BREAKPOINT_TEST();
|
---|
3164 | RT_NOREF(cbCmd);
|
---|
3165 | return vmsvga3dDXDefineShader(pThisCC, idDXContext, pCmd);
|
---|
3166 | #else
|
---|
3167 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3168 | return VERR_NOT_SUPPORTED;
|
---|
3169 | #endif
|
---|
3170 | }
|
---|
3171 |
|
---|
3172 |
|
---|
3173 | /* SVGA_3D_CMD_DX_DESTROY_SHADER 1202 */
|
---|
3174 | static int vmsvga3dCmdDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd, uint32_t cbCmd)
|
---|
3175 | {
|
---|
3176 | #ifdef VMSVGA3D_DX
|
---|
3177 | //DEBUG_BREAKPOINT_TEST();
|
---|
3178 | RT_NOREF(cbCmd);
|
---|
3179 | return vmsvga3dDXDestroyShader(pThisCC, idDXContext, pCmd);
|
---|
3180 | #else
|
---|
3181 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3182 | return VERR_NOT_SUPPORTED;
|
---|
3183 | #endif
|
---|
3184 | }
|
---|
3185 |
|
---|
3186 |
|
---|
3187 | /* SVGA_3D_CMD_DX_BIND_SHADER 1203 */
|
---|
3188 | static int vmsvga3dCmdDXBindShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindShader const *pCmd, uint32_t cbCmd)
|
---|
3189 | {
|
---|
3190 | #ifdef VMSVGA3D_DX
|
---|
3191 | //DEBUG_BREAKPOINT_TEST();
|
---|
3192 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3193 | RT_NOREF(idDXContext, cbCmd);
|
---|
3194 | /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
|
---|
3195 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
|
---|
3196 | return vmsvga3dDXBindShader(pThisCC, pCmd, pMob);
|
---|
3197 | #else
|
---|
3198 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3199 | return VERR_NOT_SUPPORTED;
|
---|
3200 | #endif
|
---|
3201 | }
|
---|
3202 |
|
---|
3203 |
|
---|
3204 | /* SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT 1204 */
|
---|
3205 | static int vmsvga3dCmdDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd, uint32_t cbCmd)
|
---|
3206 | {
|
---|
3207 | #ifdef VMSVGA3D_DX
|
---|
3208 | //DEBUG_BREAKPOINT_TEST();
|
---|
3209 | RT_NOREF(cbCmd);
|
---|
3210 | return vmsvga3dDXDefineStreamOutput(pThisCC, idDXContext, pCmd);
|
---|
3211 | #else
|
---|
3212 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3213 | return VERR_NOT_SUPPORTED;
|
---|
3214 | #endif
|
---|
3215 | }
|
---|
3216 |
|
---|
3217 |
|
---|
3218 | /* SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT 1205 */
|
---|
3219 | static int vmsvga3dCmdDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd, uint32_t cbCmd)
|
---|
3220 | {
|
---|
3221 | #ifdef VMSVGA3D_DX
|
---|
3222 | //DEBUG_BREAKPOINT_TEST();
|
---|
3223 | RT_NOREF(cbCmd);
|
---|
3224 | return vmsvga3dDXDestroyStreamOutput(pThisCC, idDXContext, pCmd);
|
---|
3225 | #else
|
---|
3226 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3227 | return VERR_NOT_SUPPORTED;
|
---|
3228 | #endif
|
---|
3229 | }
|
---|
3230 |
|
---|
3231 |
|
---|
3232 | /* SVGA_3D_CMD_DX_SET_STREAMOUTPUT 1206 */
|
---|
3233 | static int vmsvga3dCmdDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd, uint32_t cbCmd)
|
---|
3234 | {
|
---|
3235 | #ifdef VMSVGA3D_DX
|
---|
3236 | //DEBUG_BREAKPOINT_TEST();
|
---|
3237 | RT_NOREF(cbCmd);
|
---|
3238 | return vmsvga3dDXSetStreamOutput(pThisCC, idDXContext, pCmd);
|
---|
3239 | #else
|
---|
3240 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3241 | return VERR_NOT_SUPPORTED;
|
---|
3242 | #endif
|
---|
3243 | }
|
---|
3244 |
|
---|
3245 |
|
---|
3246 | /* SVGA_3D_CMD_DX_SET_COTABLE 1207 */
|
---|
3247 | static int vmsvga3dCmdDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, uint32_t cbCmd)
|
---|
3248 | {
|
---|
3249 | #ifdef VMSVGA3D_DX
|
---|
3250 | //DEBUG_BREAKPOINT_TEST();
|
---|
3251 | RT_NOREF(cbCmd);
|
---|
3252 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3253 | /* This returns NULL if mob does not exist. If the guest sends a wrong mob id, the current mob will be unbound. */
|
---|
3254 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
|
---|
3255 | return vmsvga3dDXSetCOTable(pThisCC, pCmd, pMob);
|
---|
3256 | #else
|
---|
3257 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
3258 | return VERR_NOT_SUPPORTED;
|
---|
3259 | #endif
|
---|
3260 | }
|
---|
3261 |
|
---|
3262 |
|
---|
3263 | /* SVGA_3D_CMD_DX_READBACK_COTABLE 1208 */
|
---|
3264 | static int vmsvga3dCmdDXReadbackCOTable(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackCOTable const *pCmd, uint32_t cbCmd)
|
---|
3265 | {
|
---|
3266 | #ifdef VMSVGA3D_DX
|
---|
3267 | //DEBUG_BREAKPOINT_TEST();
|
---|
3268 | RT_NOREF(idDXContext, cbCmd);
|
---|
3269 | return vmsvga3dDXReadbackCOTable(pThisCC, pCmd);
|
---|
3270 | #else
|
---|
3271 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3272 | return VERR_NOT_SUPPORTED;
|
---|
3273 | #endif
|
---|
3274 | }
|
---|
3275 |
|
---|
3276 |
|
---|
3277 | /* SVGA_3D_CMD_DX_BUFFER_COPY 1209 */
|
---|
3278 | static int vmsvga3dCmdDXBufferCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBufferCopy const *pCmd, uint32_t cbCmd)
|
---|
3279 | {
|
---|
3280 | #ifdef VMSVGA3D_DX
|
---|
3281 | //DEBUG_BREAKPOINT_TEST();
|
---|
3282 | RT_NOREF(idDXContext, cbCmd);
|
---|
3283 |
|
---|
3284 | int rc;
|
---|
3285 |
|
---|
3286 | /** @todo Backend should o the copy is both buffers have a hardware resource. */
|
---|
3287 | SVGA3dSurfaceImageId imageBufferSrc;
|
---|
3288 | imageBufferSrc.sid = pCmd->src;
|
---|
3289 | imageBufferSrc.face = 0;
|
---|
3290 | imageBufferSrc.mipmap = 0;
|
---|
3291 |
|
---|
3292 | SVGA3dSurfaceImageId imageBufferDest;
|
---|
3293 | imageBufferDest.sid = pCmd->dest;
|
---|
3294 | imageBufferDest.face = 0;
|
---|
3295 | imageBufferDest.mipmap = 0;
|
---|
3296 |
|
---|
3297 | /*
|
---|
3298 | * Map the source buffer.
|
---|
3299 | */
|
---|
3300 | VMSVGA3D_MAPPED_SURFACE mapBufferSrc;
|
---|
3301 | rc = vmsvga3dSurfaceMap(pThisCC, &imageBufferSrc, NULL, VMSVGA3D_SURFACE_MAP_READ, &mapBufferSrc);
|
---|
3302 | if (RT_SUCCESS(rc))
|
---|
3303 | {
|
---|
3304 | /*
|
---|
3305 | * Map the destination buffer.
|
---|
3306 | */
|
---|
3307 | VMSVGA3D_MAPPED_SURFACE mapBufferDest;
|
---|
3308 | rc = vmsvga3dSurfaceMap(pThisCC, &imageBufferDest, NULL, VMSVGA3D_SURFACE_MAP_WRITE, &mapBufferDest);
|
---|
3309 | if (RT_SUCCESS(rc))
|
---|
3310 | {
|
---|
3311 | /*
|
---|
3312 | * Copy the source buffer to the destination.
|
---|
3313 | */
|
---|
3314 | uint8_t const *pu8BufferSrc = (uint8_t *)mapBufferSrc.pvData;
|
---|
3315 | uint32_t const cbBufferSrc = mapBufferSrc.cbRow;
|
---|
3316 |
|
---|
3317 | uint8_t *pu8BufferDest = (uint8_t *)mapBufferDest.pvData;
|
---|
3318 | uint32_t const cbBufferDest = mapBufferDest.cbRow;
|
---|
3319 |
|
---|
3320 | if ( pCmd->srcX < cbBufferSrc
|
---|
3321 | && pCmd->width <= cbBufferSrc- pCmd->srcX
|
---|
3322 | && pCmd->destX < cbBufferDest
|
---|
3323 | && pCmd->width <= cbBufferDest - pCmd->destX)
|
---|
3324 | {
|
---|
3325 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3326 |
|
---|
3327 | memcpy(&pu8BufferDest[pCmd->destX], &pu8BufferSrc[pCmd->srcX], pCmd->width);
|
---|
3328 | }
|
---|
3329 | else
|
---|
3330 | ASSERT_GUEST_FAILED_STMT(rc = VERR_INVALID_PARAMETER);
|
---|
3331 |
|
---|
3332 | vmsvga3dSurfaceUnmap(pThisCC, &imageBufferDest, &mapBufferDest, true);
|
---|
3333 | }
|
---|
3334 |
|
---|
3335 | vmsvga3dSurfaceUnmap(pThisCC, &imageBufferSrc, &mapBufferSrc, false);
|
---|
3336 | }
|
---|
3337 |
|
---|
3338 | return rc;
|
---|
3339 | #else
|
---|
3340 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3341 | return VERR_NOT_SUPPORTED;
|
---|
3342 | #endif
|
---|
3343 | }
|
---|
3344 |
|
---|
3345 |
|
---|
3346 | /* SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER 1210 */
|
---|
3347 | static int vmsvga3dCmdDXTransferFromBuffer(PVGASTATECC pThisCC, SVGA3dCmdDXTransferFromBuffer const *pCmd, uint32_t cbCmd)
|
---|
3348 | {
|
---|
3349 | #ifdef VMSVGA3D_DX
|
---|
3350 | //DEBUG_BREAKPOINT_TEST();
|
---|
3351 | RT_NOREF(cbCmd);
|
---|
3352 |
|
---|
3353 | /* Plan:
|
---|
3354 | * - map the buffer;
|
---|
3355 | * - map the surface;
|
---|
3356 | * - copy from buffer map to the surface map.
|
---|
3357 | */
|
---|
3358 |
|
---|
3359 | int rc;
|
---|
3360 |
|
---|
3361 | SVGA3dSurfaceImageId imageBuffer;
|
---|
3362 | imageBuffer.sid = pCmd->srcSid;
|
---|
3363 | imageBuffer.face = 0;
|
---|
3364 | imageBuffer.mipmap = 0;
|
---|
3365 |
|
---|
3366 | SVGA3dSurfaceImageId imageSurface;
|
---|
3367 | imageSurface.sid = pCmd->destSid;
|
---|
3368 | rc = vmsvga3dCalcSurfaceMipmapAndFace(pThisCC, pCmd->destSid, pCmd->destSubResource, &imageSurface.mipmap, &imageSurface.face);
|
---|
3369 | AssertRCReturn(rc, rc);
|
---|
3370 |
|
---|
3371 | /*
|
---|
3372 | * Map the buffer.
|
---|
3373 | */
|
---|
3374 | VMSVGA3D_MAPPED_SURFACE mapBuffer;
|
---|
3375 | rc = vmsvga3dSurfaceMap(pThisCC, &imageBuffer, NULL, VMSVGA3D_SURFACE_MAP_READ, &mapBuffer);
|
---|
3376 | if (RT_SUCCESS(rc))
|
---|
3377 | {
|
---|
3378 | /*
|
---|
3379 | * Map the surface.
|
---|
3380 | */
|
---|
3381 | VMSVGA3D_MAPPED_SURFACE mapSurface;
|
---|
3382 | rc = vmsvga3dSurfaceMap(pThisCC, &imageSurface, &pCmd->destBox, VMSVGA3D_SURFACE_MAP_WRITE, &mapSurface);
|
---|
3383 | if (RT_SUCCESS(rc))
|
---|
3384 | {
|
---|
3385 | /*
|
---|
3386 | * Copy the mapped buffer to the surface. "Raw byte wise transfer"
|
---|
3387 | */
|
---|
3388 | uint8_t const *pu8Buffer = (uint8_t *)mapBuffer.pvData;
|
---|
3389 | uint32_t const cbBuffer = mapBuffer.cbRow;
|
---|
3390 |
|
---|
3391 | if (pCmd->srcOffset <= cbBuffer)
|
---|
3392 | {
|
---|
3393 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3394 | uint8_t const *pu8BufferBegin = pu8Buffer;
|
---|
3395 | uint8_t const *pu8BufferEnd = pu8Buffer + cbBuffer;
|
---|
3396 |
|
---|
3397 | pu8Buffer += pCmd->srcOffset;
|
---|
3398 |
|
---|
3399 | uint8_t *pu8Surface = (uint8_t *)mapSurface.pvData;
|
---|
3400 |
|
---|
3401 | uint32_t const cbRowCopy = RT_MIN(pCmd->srcPitch, mapSurface.cbRow);
|
---|
3402 | for (uint32_t z = 0; z < mapSurface.box.d && RT_SUCCESS(rc); ++z)
|
---|
3403 | {
|
---|
3404 | uint8_t const *pu8BufferRow = pu8Buffer;
|
---|
3405 | uint8_t *pu8SurfaceRow = pu8Surface;
|
---|
3406 | for (uint32_t iRow = 0; iRow < mapSurface.cRows; ++iRow)
|
---|
3407 | {
|
---|
3408 | ASSERT_GUEST_STMT_BREAK( (uintptr_t)pu8BufferRow >= (uintptr_t)pu8BufferBegin
|
---|
3409 | && (uintptr_t)pu8BufferRow < (uintptr_t)pu8BufferEnd
|
---|
3410 | && (uintptr_t)pu8BufferRow < (uintptr_t)(pu8BufferRow + cbRowCopy)
|
---|
3411 | && (uintptr_t)(pu8BufferRow + cbRowCopy) > (uintptr_t)pu8BufferBegin
|
---|
3412 | && (uintptr_t)(pu8BufferRow + cbRowCopy) <= (uintptr_t)pu8BufferEnd,
|
---|
3413 | rc = VERR_INVALID_PARAMETER);
|
---|
3414 |
|
---|
3415 | memcpy(pu8SurfaceRow, pu8BufferRow, cbRowCopy);
|
---|
3416 |
|
---|
3417 | pu8SurfaceRow += mapSurface.cbRowPitch;
|
---|
3418 | pu8BufferRow += pCmd->srcPitch;
|
---|
3419 | }
|
---|
3420 |
|
---|
3421 | pu8Buffer += pCmd->srcSlicePitch;
|
---|
3422 | pu8Surface += mapSurface.cbDepthPitch;
|
---|
3423 | }
|
---|
3424 | }
|
---|
3425 | else
|
---|
3426 | ASSERT_GUEST_FAILED_STMT(rc = VERR_INVALID_PARAMETER);
|
---|
3427 |
|
---|
3428 | vmsvga3dSurfaceUnmap(pThisCC, &imageSurface, &mapSurface, true);
|
---|
3429 | }
|
---|
3430 |
|
---|
3431 | vmsvga3dSurfaceUnmap(pThisCC, &imageBuffer, &mapBuffer, false);
|
---|
3432 | }
|
---|
3433 |
|
---|
3434 | return rc;
|
---|
3435 | #else
|
---|
3436 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
3437 | return VERR_NOT_SUPPORTED;
|
---|
3438 | #endif
|
---|
3439 | }
|
---|
3440 |
|
---|
3441 |
|
---|
3442 | /* SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK 1211 */
|
---|
3443 | static int vmsvga3dCmdDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSurfaceCopyAndReadback const *pCmd, uint32_t cbCmd)
|
---|
3444 | {
|
---|
3445 | #ifdef VMSVGA3D_DX
|
---|
3446 | DEBUG_BREAKPOINT_TEST();
|
---|
3447 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3448 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3449 | return vmsvga3dDXSurfaceCopyAndReadback(pThisCC, idDXContext);
|
---|
3450 | #else
|
---|
3451 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3452 | return VERR_NOT_SUPPORTED;
|
---|
3453 | #endif
|
---|
3454 | }
|
---|
3455 |
|
---|
3456 |
|
---|
3457 | /* SVGA_3D_CMD_DX_MOVE_QUERY 1212 */
|
---|
3458 | static int vmsvga3dCmdDXMoveQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXMoveQuery const *pCmd, uint32_t cbCmd)
|
---|
3459 | {
|
---|
3460 | #ifdef VMSVGA3D_DX
|
---|
3461 | DEBUG_BREAKPOINT_TEST();
|
---|
3462 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3463 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3464 | return vmsvga3dDXMoveQuery(pThisCC, idDXContext);
|
---|
3465 | #else
|
---|
3466 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3467 | return VERR_NOT_SUPPORTED;
|
---|
3468 | #endif
|
---|
3469 | }
|
---|
3470 |
|
---|
3471 |
|
---|
3472 | /* SVGA_3D_CMD_DX_BIND_ALL_QUERY 1213 */
|
---|
3473 | static int vmsvga3dCmdDXBindAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindAllQuery const *pCmd, uint32_t cbCmd)
|
---|
3474 | {
|
---|
3475 | #ifdef VMSVGA3D_DX
|
---|
3476 | //DEBUG_BREAKPOINT_TEST();
|
---|
3477 | RT_NOREF(cbCmd);
|
---|
3478 | return vmsvga3dDXBindAllQuery(pThisCC, idDXContext, pCmd);
|
---|
3479 | #else
|
---|
3480 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3481 | return VERR_NOT_SUPPORTED;
|
---|
3482 | #endif
|
---|
3483 | }
|
---|
3484 |
|
---|
3485 |
|
---|
3486 | /* SVGA_3D_CMD_DX_READBACK_ALL_QUERY 1214 */
|
---|
3487 | static int vmsvga3dCmdDXReadbackAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackAllQuery const *pCmd, uint32_t cbCmd)
|
---|
3488 | {
|
---|
3489 | #ifdef VMSVGA3D_DX
|
---|
3490 | //DEBUG_BREAKPOINT_TEST();
|
---|
3491 | RT_NOREF(cbCmd);
|
---|
3492 | return vmsvga3dDXReadbackAllQuery(pThisCC, idDXContext, pCmd);
|
---|
3493 | #else
|
---|
3494 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3495 | return VERR_NOT_SUPPORTED;
|
---|
3496 | #endif
|
---|
3497 | }
|
---|
3498 |
|
---|
3499 |
|
---|
3500 | /* SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER 1215 */
|
---|
3501 | static int vmsvga3dCmdDXPredTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredTransferFromBuffer const *pCmd, uint32_t cbCmd)
|
---|
3502 | {
|
---|
3503 | #ifdef VMSVGA3D_DX
|
---|
3504 | //DEBUG_BREAKPOINT_TEST();
|
---|
3505 | RT_NOREF(idDXContext, cbCmd);
|
---|
3506 |
|
---|
3507 | /* This command is executed in a context: "The context is implied from the command buffer header."
|
---|
3508 | * However the device design allows to do the transfer without a context, so re-use context-less command handler.
|
---|
3509 | */
|
---|
3510 | SVGA3dCmdDXTransferFromBuffer cmd;
|
---|
3511 | cmd.srcSid = pCmd->srcSid;
|
---|
3512 | cmd.srcOffset = pCmd->srcOffset;
|
---|
3513 | cmd.srcPitch = pCmd->srcPitch;
|
---|
3514 | cmd.srcSlicePitch = pCmd->srcSlicePitch;
|
---|
3515 | cmd.destSid = pCmd->destSid;
|
---|
3516 | cmd.destSubResource = pCmd->destSubResource;
|
---|
3517 | cmd.destBox = pCmd->destBox;
|
---|
3518 | return vmsvga3dCmdDXTransferFromBuffer(pThisCC, &cmd, sizeof(cmd));
|
---|
3519 | #else
|
---|
3520 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3521 | return VERR_NOT_SUPPORTED;
|
---|
3522 | #endif
|
---|
3523 | }
|
---|
3524 |
|
---|
3525 |
|
---|
3526 | /* SVGA_3D_CMD_DX_MOB_FENCE_64 1216 */
|
---|
3527 | static int vmsvga3dCmdDXMobFence64(PVGASTATECC pThisCC, SVGA3dCmdDXMobFence64 const *pCmd, uint32_t cbCmd)
|
---|
3528 | {
|
---|
3529 | #ifdef VMSVGA3D_DX
|
---|
3530 | //DEBUG_BREAKPOINT_TEST();
|
---|
3531 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3532 | RT_NOREF(cbCmd);
|
---|
3533 |
|
---|
3534 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobId);
|
---|
3535 | ASSERT_GUEST_RETURN(pMob, VERR_INVALID_PARAMETER);
|
---|
3536 |
|
---|
3537 | int rc = vmsvgaR3MobWrite(pSvgaR3State, pMob, pCmd->mobOffset, &pCmd->value, sizeof(pCmd->value));
|
---|
3538 | ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
|
---|
3539 |
|
---|
3540 | return VINF_SUCCESS;
|
---|
3541 | #else
|
---|
3542 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
3543 | return VERR_NOT_SUPPORTED;
|
---|
3544 | #endif
|
---|
3545 | }
|
---|
3546 |
|
---|
3547 |
|
---|
3548 | /* SVGA_3D_CMD_DX_BIND_ALL_SHADER 1217 */
|
---|
3549 | static int vmsvga3dCmdDXBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindAllShader const *pCmd, uint32_t cbCmd)
|
---|
3550 | {
|
---|
3551 | #ifdef VMSVGA3D_DX
|
---|
3552 | DEBUG_BREAKPOINT_TEST();
|
---|
3553 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3554 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3555 | return vmsvga3dDXBindAllShader(pThisCC, idDXContext);
|
---|
3556 | #else
|
---|
3557 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3558 | return VERR_NOT_SUPPORTED;
|
---|
3559 | #endif
|
---|
3560 | }
|
---|
3561 |
|
---|
3562 |
|
---|
3563 | /* SVGA_3D_CMD_DX_HINT 1218 */
|
---|
3564 | static int vmsvga3dCmdDXHint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXHint const *pCmd, uint32_t cbCmd)
|
---|
3565 | {
|
---|
3566 | #ifdef VMSVGA3D_DX
|
---|
3567 | DEBUG_BREAKPOINT_TEST();
|
---|
3568 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3569 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3570 | return vmsvga3dDXHint(pThisCC, idDXContext);
|
---|
3571 | #else
|
---|
3572 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3573 | return VERR_NOT_SUPPORTED;
|
---|
3574 | #endif
|
---|
3575 | }
|
---|
3576 |
|
---|
3577 |
|
---|
3578 | /* SVGA_3D_CMD_DX_BUFFER_UPDATE 1219 */
|
---|
3579 | static int vmsvga3dCmdDXBufferUpdate(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBufferUpdate const *pCmd, uint32_t cbCmd)
|
---|
3580 | {
|
---|
3581 | #ifdef VMSVGA3D_DX
|
---|
3582 | DEBUG_BREAKPOINT_TEST();
|
---|
3583 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3584 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3585 | return vmsvga3dDXBufferUpdate(pThisCC, idDXContext);
|
---|
3586 | #else
|
---|
3587 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3588 | return VERR_NOT_SUPPORTED;
|
---|
3589 | #endif
|
---|
3590 | }
|
---|
3591 |
|
---|
3592 |
|
---|
3593 | /* SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET 1220 */
|
---|
3594 | static int vmsvga3dCmdDXSetVSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetVSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3595 | {
|
---|
3596 | #ifdef VMSVGA3D_DX
|
---|
3597 | //DEBUG_BREAKPOINT_TEST();
|
---|
3598 | RT_NOREF(cbCmd);
|
---|
3599 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_VS);
|
---|
3600 | #else
|
---|
3601 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3602 | return VERR_NOT_SUPPORTED;
|
---|
3603 | #endif
|
---|
3604 | }
|
---|
3605 |
|
---|
3606 |
|
---|
3607 | /* SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET 1221 */
|
---|
3608 | static int vmsvga3dCmdDXSetPSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetPSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3609 | {
|
---|
3610 | #ifdef VMSVGA3D_DX
|
---|
3611 | //DEBUG_BREAKPOINT_TEST();
|
---|
3612 | RT_NOREF(cbCmd);
|
---|
3613 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_PS);
|
---|
3614 | #else
|
---|
3615 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3616 | return VERR_NOT_SUPPORTED;
|
---|
3617 | #endif
|
---|
3618 | }
|
---|
3619 |
|
---|
3620 |
|
---|
3621 | /* SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET 1222 */
|
---|
3622 | static int vmsvga3dCmdDXSetGSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetGSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3623 | {
|
---|
3624 | #ifdef VMSVGA3D_DX
|
---|
3625 | //DEBUG_BREAKPOINT_TEST();
|
---|
3626 | RT_NOREF(cbCmd);
|
---|
3627 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_GS);
|
---|
3628 | #else
|
---|
3629 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3630 | return VERR_NOT_SUPPORTED;
|
---|
3631 | #endif
|
---|
3632 | }
|
---|
3633 |
|
---|
3634 |
|
---|
3635 | /* SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET 1223 */
|
---|
3636 | static int vmsvga3dCmdDXSetHSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetHSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3637 | {
|
---|
3638 | #ifdef VMSVGA3D_DX
|
---|
3639 | //DEBUG_BREAKPOINT_TEST();
|
---|
3640 | RT_NOREF(cbCmd);
|
---|
3641 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_HS);
|
---|
3642 | #else
|
---|
3643 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3644 | return VERR_NOT_SUPPORTED;
|
---|
3645 | #endif
|
---|
3646 | }
|
---|
3647 |
|
---|
3648 |
|
---|
3649 | /* SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET 1224 */
|
---|
3650 | static int vmsvga3dCmdDXSetDSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3651 | {
|
---|
3652 | #ifdef VMSVGA3D_DX
|
---|
3653 | //DEBUG_BREAKPOINT_TEST();
|
---|
3654 | RT_NOREF(cbCmd);
|
---|
3655 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_DS);
|
---|
3656 | #else
|
---|
3657 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3658 | return VERR_NOT_SUPPORTED;
|
---|
3659 | #endif
|
---|
3660 | }
|
---|
3661 |
|
---|
3662 |
|
---|
3663 | /* SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET 1225 */
|
---|
3664 | static int vmsvga3dCmdDXSetCSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetCSConstantBufferOffset const *pCmd, uint32_t cbCmd)
|
---|
3665 | {
|
---|
3666 | #ifdef VMSVGA3D_DX
|
---|
3667 | //DEBUG_BREAKPOINT_TEST();
|
---|
3668 | RT_NOREF(cbCmd);
|
---|
3669 | return vmsvga3dDXSetConstantBufferOffset(pThisCC, idDXContext, pCmd, SVGA3D_SHADERTYPE_CS);
|
---|
3670 | #else
|
---|
3671 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3672 | return VERR_NOT_SUPPORTED;
|
---|
3673 | #endif
|
---|
3674 | }
|
---|
3675 |
|
---|
3676 |
|
---|
3677 | /* SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER 1226 */
|
---|
3678 | static int vmsvga3dCmdDXCondBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCondBindAllShader const *pCmd, uint32_t cbCmd)
|
---|
3679 | {
|
---|
3680 | #ifdef VMSVGA3D_DX
|
---|
3681 | DEBUG_BREAKPOINT_TEST();
|
---|
3682 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3683 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3684 | return vmsvga3dDXCondBindAllShader(pThisCC, idDXContext);
|
---|
3685 | #else
|
---|
3686 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3687 | return VERR_NOT_SUPPORTED;
|
---|
3688 | #endif
|
---|
3689 | }
|
---|
3690 |
|
---|
3691 |
|
---|
3692 | /* SVGA_3D_CMD_SCREEN_COPY 1227 */
|
---|
3693 | static int vmsvga3dCmdScreenCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdScreenCopy const *pCmd, uint32_t cbCmd)
|
---|
3694 | {
|
---|
3695 | #ifdef VMSVGA3D_DX
|
---|
3696 | DEBUG_BREAKPOINT_TEST();
|
---|
3697 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3698 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3699 | return vmsvga3dScreenCopy(pThisCC, idDXContext);
|
---|
3700 | #else
|
---|
3701 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3702 | return VERR_NOT_SUPPORTED;
|
---|
3703 | #endif
|
---|
3704 | }
|
---|
3705 |
|
---|
3706 |
|
---|
3707 | /* SVGA_3D_CMD_GROW_OTABLE 1236 */
|
---|
3708 | static int vmsvga3dCmdGrowOTable(PVGASTATECC pThisCC, SVGA3dCmdGrowOTable const *pCmd, uint32_t cbCmd)
|
---|
3709 | {
|
---|
3710 | #ifdef VMSVGA3D_DX
|
---|
3711 | //DEBUG_BREAKPOINT_TEST();
|
---|
3712 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3713 | RT_NOREF(cbCmd);
|
---|
3714 | return vmsvgaR3OTableSetOrGrow(pSvgaR3State, pCmd->type, pCmd->baseAddress,
|
---|
3715 | pCmd->sizeInBytes, pCmd->validSizeInBytes, pCmd->ptDepth, /*fGrow*/ true);
|
---|
3716 | #else
|
---|
3717 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
3718 | return VERR_NOT_SUPPORTED;
|
---|
3719 | #endif
|
---|
3720 | }
|
---|
3721 |
|
---|
3722 |
|
---|
3723 | /* SVGA_3D_CMD_DX_GROW_COTABLE 1237 */
|
---|
3724 | static int vmsvga3dCmdDXGrowCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXGrowCOTable const *pCmd, uint32_t cbCmd)
|
---|
3725 | {
|
---|
3726 | #ifdef VMSVGA3D_DX
|
---|
3727 | //DEBUG_BREAKPOINT_TEST();
|
---|
3728 | RT_NOREF(cbCmd);
|
---|
3729 | return vmsvga3dDXGrowCOTable(pThisCC, pCmd);
|
---|
3730 | #else
|
---|
3731 | RT_NOREF(pThisCC, pCmd, cbCmd);
|
---|
3732 | return VERR_NOT_SUPPORTED;
|
---|
3733 | #endif
|
---|
3734 | }
|
---|
3735 |
|
---|
3736 |
|
---|
3737 | /* SVGA_3D_CMD_INTRA_SURFACE_COPY 1238 */
|
---|
3738 | static int vmsvga3dCmdIntraSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdIntraSurfaceCopy const *pCmd, uint32_t cbCmd)
|
---|
3739 | {
|
---|
3740 | #ifdef VMSVGA3D_DX
|
---|
3741 | //DEBUG_BREAKPOINT_TEST();
|
---|
3742 | RT_NOREF(cbCmd);
|
---|
3743 | return vmsvga3dIntraSurfaceCopy(pThisCC, idDXContext, pCmd);
|
---|
3744 | #else
|
---|
3745 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3746 | return VERR_NOT_SUPPORTED;
|
---|
3747 | #endif
|
---|
3748 | }
|
---|
3749 |
|
---|
3750 |
|
---|
3751 | /* SVGA_3D_CMD_DEFINE_GB_SURFACE_V3 1239 */
|
---|
3752 | static int vmsvga3dCmdDefineGBSurface_v3(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v3 const *pCmd)
|
---|
3753 | {
|
---|
3754 | #ifdef VMSVGA3D_DX
|
---|
3755 | //DEBUG_BREAKPOINT_TEST();
|
---|
3756 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3757 |
|
---|
3758 | /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
|
---|
3759 | SVGAOTableSurfaceEntry entry;
|
---|
3760 | RT_ZERO(entry);
|
---|
3761 | entry.format = pCmd->format;
|
---|
3762 | entry.surface1Flags = (uint32_t)(pCmd->surfaceFlags);
|
---|
3763 | entry.numMipLevels = pCmd->numMipLevels;
|
---|
3764 | entry.multisampleCount = pCmd->multisampleCount;
|
---|
3765 | entry.autogenFilter = pCmd->autogenFilter;
|
---|
3766 | entry.size = pCmd->size;
|
---|
3767 | entry.mobid = SVGA_ID_INVALID;
|
---|
3768 | entry.arraySize = pCmd->arraySize;
|
---|
3769 | // entry.mobPitch = 0;
|
---|
3770 | entry.surface2Flags = (uint32_t)(pCmd->surfaceFlags >> UINT64_C(32));
|
---|
3771 | entry.multisamplePattern = pCmd->multisamplePattern;
|
---|
3772 | entry.qualityLevel = pCmd->qualityLevel;
|
---|
3773 | // entry.bufferByteStride = 0;
|
---|
3774 | // entry.minLOD = 0;
|
---|
3775 |
|
---|
3776 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
3777 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
3778 | if (RT_SUCCESS(rc))
|
---|
3779 | {
|
---|
3780 | /* Create the host surface. */
|
---|
3781 | vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
|
---|
3782 | pCmd->multisampleCount, pCmd->multisamplePattern, pCmd->qualityLevel, pCmd->autogenFilter,
|
---|
3783 | pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* bufferByteStride = */ 0, /* fAllocMipLevels = */ false);
|
---|
3784 | }
|
---|
3785 | return rc;
|
---|
3786 | #else
|
---|
3787 | RT_NOREF(pThisCC, pCmd);
|
---|
3788 | return VERR_NOT_SUPPORTED;
|
---|
3789 | #endif
|
---|
3790 | }
|
---|
3791 |
|
---|
3792 |
|
---|
3793 | /* SVGA_3D_CMD_DX_RESOLVE_COPY 1240 */
|
---|
3794 | static int vmsvga3dCmdDXResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXResolveCopy const *pCmd, uint32_t cbCmd)
|
---|
3795 | {
|
---|
3796 | #ifdef VMSVGA3D_DX
|
---|
3797 | //DEBUG_BREAKPOINT_TEST();
|
---|
3798 | RT_NOREF(cbCmd);
|
---|
3799 | return vmsvga3dDXResolveCopy(pThisCC, idDXContext, pCmd);
|
---|
3800 | #else
|
---|
3801 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3802 | return VERR_NOT_SUPPORTED;
|
---|
3803 | #endif
|
---|
3804 | }
|
---|
3805 |
|
---|
3806 |
|
---|
3807 | /* SVGA_3D_CMD_DX_PRED_RESOLVE_COPY 1241 */
|
---|
3808 | static int vmsvga3dCmdDXPredResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredResolveCopy const *pCmd, uint32_t cbCmd)
|
---|
3809 | {
|
---|
3810 | #ifdef VMSVGA3D_DX
|
---|
3811 | DEBUG_BREAKPOINT_TEST();
|
---|
3812 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3813 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3814 | return vmsvga3dDXPredResolveCopy(pThisCC, idDXContext);
|
---|
3815 | #else
|
---|
3816 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3817 | return VERR_NOT_SUPPORTED;
|
---|
3818 | #endif
|
---|
3819 | }
|
---|
3820 |
|
---|
3821 |
|
---|
3822 | /* SVGA_3D_CMD_DX_PRED_CONVERT_REGION 1242 */
|
---|
3823 | static int vmsvga3dCmdDXPredConvertRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredConvertRegion const *pCmd, uint32_t cbCmd)
|
---|
3824 | {
|
---|
3825 | #ifdef VMSVGA3D_DX
|
---|
3826 | DEBUG_BREAKPOINT_TEST();
|
---|
3827 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3828 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3829 | return vmsvga3dDXPredConvertRegion(pThisCC, idDXContext);
|
---|
3830 | #else
|
---|
3831 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3832 | return VERR_NOT_SUPPORTED;
|
---|
3833 | #endif
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 |
|
---|
3837 | /* SVGA_3D_CMD_DX_PRED_CONVERT 1243 */
|
---|
3838 | static int vmsvga3dCmdDXPredConvert(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredConvert const *pCmd, uint32_t cbCmd)
|
---|
3839 | {
|
---|
3840 | #ifdef VMSVGA3D_DX
|
---|
3841 | DEBUG_BREAKPOINT_TEST();
|
---|
3842 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3843 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3844 | return vmsvga3dDXPredConvert(pThisCC, idDXContext);
|
---|
3845 | #else
|
---|
3846 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3847 | return VERR_NOT_SUPPORTED;
|
---|
3848 | #endif
|
---|
3849 | }
|
---|
3850 |
|
---|
3851 |
|
---|
3852 | /* SVGA_3D_CMD_WHOLE_SURFACE_COPY 1244 */
|
---|
3853 | static int vmsvga3dCmdWholeSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdWholeSurfaceCopy const *pCmd, uint32_t cbCmd)
|
---|
3854 | {
|
---|
3855 | #ifdef VMSVGA3D_DX
|
---|
3856 | DEBUG_BREAKPOINT_TEST();
|
---|
3857 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3858 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
3859 | return vmsvga3dWholeSurfaceCopy(pThisCC, idDXContext);
|
---|
3860 | #else
|
---|
3861 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3862 | return VERR_NOT_SUPPORTED;
|
---|
3863 | #endif
|
---|
3864 | }
|
---|
3865 |
|
---|
3866 |
|
---|
3867 | /* SVGA_3D_CMD_DX_DEFINE_UA_VIEW 1245 */
|
---|
3868 | static int vmsvga3dCmdDXDefineUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineUAView const *pCmd, uint32_t cbCmd)
|
---|
3869 | {
|
---|
3870 | #ifdef VMSVGA3D_DX
|
---|
3871 | //DEBUG_BREAKPOINT_TEST();
|
---|
3872 | RT_NOREF(cbCmd);
|
---|
3873 | return vmsvga3dDXDefineUAView(pThisCC, idDXContext, pCmd);
|
---|
3874 | #else
|
---|
3875 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3876 | return VERR_NOT_SUPPORTED;
|
---|
3877 | #endif
|
---|
3878 | }
|
---|
3879 |
|
---|
3880 |
|
---|
3881 | /* SVGA_3D_CMD_DX_DESTROY_UA_VIEW 1246 */
|
---|
3882 | static int vmsvga3dCmdDXDestroyUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyUAView const *pCmd, uint32_t cbCmd)
|
---|
3883 | {
|
---|
3884 | #ifdef VMSVGA3D_DX
|
---|
3885 | //DEBUG_BREAKPOINT_TEST();
|
---|
3886 | RT_NOREF(cbCmd);
|
---|
3887 | return vmsvga3dDXDestroyUAView(pThisCC, idDXContext, pCmd);
|
---|
3888 | #else
|
---|
3889 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3890 | return VERR_NOT_SUPPORTED;
|
---|
3891 | #endif
|
---|
3892 | }
|
---|
3893 |
|
---|
3894 |
|
---|
3895 | /* SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT 1247 */
|
---|
3896 | static int vmsvga3dCmdDXClearUAViewUint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewUint const *pCmd, uint32_t cbCmd)
|
---|
3897 | {
|
---|
3898 | #ifdef VMSVGA3D_DX
|
---|
3899 | DEBUG_BREAKPOINT_TEST();
|
---|
3900 | RT_NOREF(cbCmd);
|
---|
3901 | return vmsvga3dDXClearUAViewUint(pThisCC, idDXContext, pCmd);
|
---|
3902 | #else
|
---|
3903 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3904 | return VERR_NOT_SUPPORTED;
|
---|
3905 | #endif
|
---|
3906 | }
|
---|
3907 |
|
---|
3908 |
|
---|
3909 | /* SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT 1248 */
|
---|
3910 | static int vmsvga3dCmdDXClearUAViewFloat(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewFloat const *pCmd, uint32_t cbCmd)
|
---|
3911 | {
|
---|
3912 | #ifdef VMSVGA3D_DX
|
---|
3913 | DEBUG_BREAKPOINT_TEST();
|
---|
3914 | RT_NOREF(cbCmd);
|
---|
3915 | return vmsvga3dDXClearUAViewFloat(pThisCC, idDXContext, pCmd);
|
---|
3916 | #else
|
---|
3917 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3918 | return VERR_NOT_SUPPORTED;
|
---|
3919 | #endif
|
---|
3920 | }
|
---|
3921 |
|
---|
3922 |
|
---|
3923 | /* SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT 1249 */
|
---|
3924 | static int vmsvga3dCmdDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCopyStructureCount const *pCmd, uint32_t cbCmd)
|
---|
3925 | {
|
---|
3926 | #ifdef VMSVGA3D_DX
|
---|
3927 | //DEBUG_BREAKPOINT_TEST();
|
---|
3928 | RT_NOREF(cbCmd);
|
---|
3929 | return vmsvga3dDXCopyStructureCount(pThisCC, idDXContext, pCmd);
|
---|
3930 | #else
|
---|
3931 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3932 | return VERR_NOT_SUPPORTED;
|
---|
3933 | #endif
|
---|
3934 | }
|
---|
3935 |
|
---|
3936 |
|
---|
3937 | /* SVGA_3D_CMD_DX_SET_UA_VIEWS 1250 */
|
---|
3938 | static int vmsvga3dCmdDXSetUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetUAViews const *pCmd, uint32_t cbCmd)
|
---|
3939 | {
|
---|
3940 | #ifdef VMSVGA3D_DX
|
---|
3941 | //DEBUG_BREAKPOINT_TEST();
|
---|
3942 | SVGA3dUAViewId const *paUAViewId = (SVGA3dUAViewId *)&pCmd[1];
|
---|
3943 | uint32_t const cUAViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dUAViewId);
|
---|
3944 | return vmsvga3dDXSetUAViews(pThisCC, idDXContext, pCmd, cUAViewId, paUAViewId);
|
---|
3945 | #else
|
---|
3946 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3947 | return VERR_NOT_SUPPORTED;
|
---|
3948 | #endif
|
---|
3949 | }
|
---|
3950 |
|
---|
3951 |
|
---|
3952 | /* SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT 1251 */
|
---|
3953 | static int vmsvga3dCmdDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstancedIndirect const *pCmd, uint32_t cbCmd)
|
---|
3954 | {
|
---|
3955 | #ifdef VMSVGA3D_DX
|
---|
3956 | //DEBUG_BREAKPOINT_TEST();
|
---|
3957 | RT_NOREF(cbCmd);
|
---|
3958 | return vmsvga3dDXDrawIndexedInstancedIndirect(pThisCC, idDXContext, pCmd);
|
---|
3959 | #else
|
---|
3960 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3961 | return VERR_NOT_SUPPORTED;
|
---|
3962 | #endif
|
---|
3963 | }
|
---|
3964 |
|
---|
3965 |
|
---|
3966 | /* SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT 1252 */
|
---|
3967 | static int vmsvga3dCmdDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstancedIndirect const *pCmd, uint32_t cbCmd)
|
---|
3968 | {
|
---|
3969 | #ifdef VMSVGA3D_DX
|
---|
3970 | //DEBUG_BREAKPOINT_TEST();
|
---|
3971 | RT_NOREF(cbCmd);
|
---|
3972 | return vmsvga3dDXDrawInstancedIndirect(pThisCC, idDXContext, pCmd);
|
---|
3973 | #else
|
---|
3974 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3975 | return VERR_NOT_SUPPORTED;
|
---|
3976 | #endif
|
---|
3977 | }
|
---|
3978 |
|
---|
3979 |
|
---|
3980 | /* SVGA_3D_CMD_DX_DISPATCH 1253 */
|
---|
3981 | static int vmsvga3dCmdDXDispatch(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatch const *pCmd, uint32_t cbCmd)
|
---|
3982 | {
|
---|
3983 | #ifdef VMSVGA3D_DX
|
---|
3984 | //DEBUG_BREAKPOINT_TEST();
|
---|
3985 | RT_NOREF(cbCmd);
|
---|
3986 | return vmsvga3dDXDispatch(pThisCC, idDXContext, pCmd);
|
---|
3987 | #else
|
---|
3988 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
3989 | return VERR_NOT_SUPPORTED;
|
---|
3990 | #endif
|
---|
3991 | }
|
---|
3992 |
|
---|
3993 |
|
---|
3994 | /* SVGA_3D_CMD_DX_DISPATCH_INDIRECT 1254 */
|
---|
3995 | static int vmsvga3dCmdDXDispatchIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatchIndirect const *pCmd, uint32_t cbCmd)
|
---|
3996 | {
|
---|
3997 | #ifdef VMSVGA3D_DX
|
---|
3998 | DEBUG_BREAKPOINT_TEST();
|
---|
3999 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4000 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4001 | return vmsvga3dDXDispatchIndirect(pThisCC, idDXContext);
|
---|
4002 | #else
|
---|
4003 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4004 | return VERR_NOT_SUPPORTED;
|
---|
4005 | #endif
|
---|
4006 | }
|
---|
4007 |
|
---|
4008 |
|
---|
4009 | /* SVGA_3D_CMD_WRITE_ZERO_SURFACE 1255 */
|
---|
4010 | static int vmsvga3dCmdWriteZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdWriteZeroSurface const *pCmd, uint32_t cbCmd)
|
---|
4011 | {
|
---|
4012 | #ifdef VMSVGA3D_DX
|
---|
4013 | DEBUG_BREAKPOINT_TEST();
|
---|
4014 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4015 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4016 | return vmsvga3dWriteZeroSurface(pThisCC, idDXContext);
|
---|
4017 | #else
|
---|
4018 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4019 | return VERR_NOT_SUPPORTED;
|
---|
4020 | #endif
|
---|
4021 | }
|
---|
4022 |
|
---|
4023 |
|
---|
4024 | /* SVGA_3D_CMD_HINT_ZERO_SURFACE 1256 */
|
---|
4025 | static int vmsvga3dCmdHintZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdHintZeroSurface const *pCmd, uint32_t cbCmd)
|
---|
4026 | {
|
---|
4027 | #ifdef VMSVGA3D_DX
|
---|
4028 | DEBUG_BREAKPOINT_TEST();
|
---|
4029 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4030 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4031 | return vmsvga3dHintZeroSurface(pThisCC, idDXContext);
|
---|
4032 | #else
|
---|
4033 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4034 | return VERR_NOT_SUPPORTED;
|
---|
4035 | #endif
|
---|
4036 | }
|
---|
4037 |
|
---|
4038 |
|
---|
4039 | /* SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER 1257 */
|
---|
4040 | static int vmsvga3dCmdDXTransferToBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXTransferToBuffer const *pCmd, uint32_t cbCmd)
|
---|
4041 | {
|
---|
4042 | #ifdef VMSVGA3D_DX
|
---|
4043 | DEBUG_BREAKPOINT_TEST();
|
---|
4044 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4045 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4046 | return vmsvga3dDXTransferToBuffer(pThisCC, idDXContext);
|
---|
4047 | #else
|
---|
4048 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4049 | return VERR_NOT_SUPPORTED;
|
---|
4050 | #endif
|
---|
4051 | }
|
---|
4052 |
|
---|
4053 |
|
---|
4054 | /* SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT 1258 */
|
---|
4055 | static int vmsvga3dCmdDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStructureCount const *pCmd, uint32_t cbCmd)
|
---|
4056 | {
|
---|
4057 | #ifdef VMSVGA3D_DX
|
---|
4058 | //DEBUG_BREAKPOINT_TEST();
|
---|
4059 | RT_NOREF(cbCmd);
|
---|
4060 | return vmsvga3dDXSetStructureCount(pThisCC, idDXContext, pCmd);
|
---|
4061 | #else
|
---|
4062 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4063 | return VERR_NOT_SUPPORTED;
|
---|
4064 | #endif
|
---|
4065 | }
|
---|
4066 |
|
---|
4067 |
|
---|
4068 | /* SVGA_3D_CMD_LOGICOPS_BITBLT 1259 */
|
---|
4069 | static int vmsvga3dCmdLogicOpsBitBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsBitBlt const *pCmd, uint32_t cbCmd)
|
---|
4070 | {
|
---|
4071 | #ifdef VMSVGA3D_DX
|
---|
4072 | DEBUG_BREAKPOINT_TEST();
|
---|
4073 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4074 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4075 | return vmsvga3dLogicOpsBitBlt(pThisCC, idDXContext);
|
---|
4076 | #else
|
---|
4077 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4078 | return VERR_NOT_SUPPORTED;
|
---|
4079 | #endif
|
---|
4080 | }
|
---|
4081 |
|
---|
4082 |
|
---|
4083 | /* SVGA_3D_CMD_LOGICOPS_TRANSBLT 1260 */
|
---|
4084 | static int vmsvga3dCmdLogicOpsTransBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsTransBlt const *pCmd, uint32_t cbCmd)
|
---|
4085 | {
|
---|
4086 | #ifdef VMSVGA3D_DX
|
---|
4087 | DEBUG_BREAKPOINT_TEST();
|
---|
4088 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4089 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4090 | return vmsvga3dLogicOpsTransBlt(pThisCC, idDXContext);
|
---|
4091 | #else
|
---|
4092 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4093 | return VERR_NOT_SUPPORTED;
|
---|
4094 | #endif
|
---|
4095 | }
|
---|
4096 |
|
---|
4097 |
|
---|
4098 | /* SVGA_3D_CMD_LOGICOPS_STRETCHBLT 1261 */
|
---|
4099 | static int vmsvga3dCmdLogicOpsStretchBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsStretchBlt const *pCmd, uint32_t cbCmd)
|
---|
4100 | {
|
---|
4101 | #ifdef VMSVGA3D_DX
|
---|
4102 | DEBUG_BREAKPOINT_TEST();
|
---|
4103 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4104 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4105 | return vmsvga3dLogicOpsStretchBlt(pThisCC, idDXContext);
|
---|
4106 | #else
|
---|
4107 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4108 | return VERR_NOT_SUPPORTED;
|
---|
4109 | #endif
|
---|
4110 | }
|
---|
4111 |
|
---|
4112 |
|
---|
4113 | /* SVGA_3D_CMD_LOGICOPS_COLORFILL 1262 */
|
---|
4114 | static int vmsvga3dCmdLogicOpsColorFill(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsColorFill const *pCmd, uint32_t cbCmd)
|
---|
4115 | {
|
---|
4116 | #ifdef VMSVGA3D_DX
|
---|
4117 | DEBUG_BREAKPOINT_TEST();
|
---|
4118 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4119 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4120 | return vmsvga3dLogicOpsColorFill(pThisCC, idDXContext);
|
---|
4121 | #else
|
---|
4122 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4123 | return VERR_NOT_SUPPORTED;
|
---|
4124 | #endif
|
---|
4125 | }
|
---|
4126 |
|
---|
4127 |
|
---|
4128 | /* SVGA_3D_CMD_LOGICOPS_ALPHABLEND 1263 */
|
---|
4129 | static int vmsvga3dCmdLogicOpsAlphaBlend(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsAlphaBlend const *pCmd, uint32_t cbCmd)
|
---|
4130 | {
|
---|
4131 | #ifdef VMSVGA3D_DX
|
---|
4132 | DEBUG_BREAKPOINT_TEST();
|
---|
4133 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4134 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4135 | return vmsvga3dLogicOpsAlphaBlend(pThisCC, idDXContext);
|
---|
4136 | #else
|
---|
4137 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4138 | return VERR_NOT_SUPPORTED;
|
---|
4139 | #endif
|
---|
4140 | }
|
---|
4141 |
|
---|
4142 |
|
---|
4143 | /* SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND 1264 */
|
---|
4144 | static int vmsvga3dCmdLogicOpsClearTypeBlend(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdLogicOpsClearTypeBlend const *pCmd, uint32_t cbCmd)
|
---|
4145 | {
|
---|
4146 | #ifdef VMSVGA3D_DX
|
---|
4147 | DEBUG_BREAKPOINT_TEST();
|
---|
4148 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4149 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4150 | return vmsvga3dLogicOpsClearTypeBlend(pThisCC, idDXContext);
|
---|
4151 | #else
|
---|
4152 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4153 | return VERR_NOT_SUPPORTED;
|
---|
4154 | #endif
|
---|
4155 | }
|
---|
4156 |
|
---|
4157 |
|
---|
4158 | /* SVGA_3D_CMD_DEFINE_GB_SURFACE_V4 1267 */
|
---|
4159 | static int vmsvga3dCmdDefineGBSurface_v4(PVGASTATECC pThisCC, SVGA3dCmdDefineGBSurface_v4 const *pCmd)
|
---|
4160 | {
|
---|
4161 | #ifdef VMSVGA3D_DX
|
---|
4162 | //DEBUG_BREAKPOINT_TEST();
|
---|
4163 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4164 |
|
---|
4165 | /* Update the entry in the pSvgaR3State->pGboOTableSurface. */
|
---|
4166 | SVGAOTableSurfaceEntry entry;
|
---|
4167 | RT_ZERO(entry);
|
---|
4168 | entry.format = pCmd->format;
|
---|
4169 | entry.surface1Flags = (uint32_t)(pCmd->surfaceFlags);
|
---|
4170 | entry.numMipLevels = pCmd->numMipLevels;
|
---|
4171 | entry.multisampleCount = pCmd->multisampleCount;
|
---|
4172 | entry.autogenFilter = pCmd->autogenFilter;
|
---|
4173 | entry.size = pCmd->size;
|
---|
4174 | entry.mobid = SVGA_ID_INVALID;
|
---|
4175 | entry.arraySize = pCmd->arraySize;
|
---|
4176 | // entry.mobPitch = 0;
|
---|
4177 | entry.surface2Flags = (uint32_t)(pCmd->surfaceFlags >> UINT64_C(32));
|
---|
4178 | entry.multisamplePattern = pCmd->multisamplePattern;
|
---|
4179 | entry.qualityLevel = pCmd->qualityLevel;
|
---|
4180 | entry.bufferByteStride = pCmd->bufferByteStride;
|
---|
4181 | // entry.minLOD = 0;
|
---|
4182 |
|
---|
4183 | int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
|
---|
4184 | pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
|
---|
4185 | if (RT_SUCCESS(rc))
|
---|
4186 | {
|
---|
4187 | /* Create the host surface. */
|
---|
4188 | vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format,
|
---|
4189 | pCmd->multisampleCount, pCmd->multisamplePattern, pCmd->qualityLevel, pCmd->autogenFilter,
|
---|
4190 | pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, pCmd->bufferByteStride, /* fAllocMipLevels = */ false);
|
---|
4191 | }
|
---|
4192 | return rc;
|
---|
4193 | #else
|
---|
4194 | RT_NOREF(pThisCC, pCmd);
|
---|
4195 | return VERR_NOT_SUPPORTED;
|
---|
4196 | #endif
|
---|
4197 | }
|
---|
4198 |
|
---|
4199 |
|
---|
4200 | /* SVGA_3D_CMD_DX_SET_CS_UA_VIEWS 1268 */
|
---|
4201 | static int vmsvga3dCmdDXSetCSUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetCSUAViews const *pCmd, uint32_t cbCmd)
|
---|
4202 | {
|
---|
4203 | #ifdef VMSVGA3D_DX
|
---|
4204 | //DEBUG_BREAKPOINT_TEST();
|
---|
4205 | SVGA3dUAViewId const *paUAViewId = (SVGA3dUAViewId *)&pCmd[1];
|
---|
4206 | uint32_t const cUAViewId = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dUAViewId);
|
---|
4207 | return vmsvga3dDXSetCSUAViews(pThisCC, idDXContext, pCmd, cUAViewId, paUAViewId);
|
---|
4208 | #else
|
---|
4209 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4210 | return VERR_NOT_SUPPORTED;
|
---|
4211 | #endif
|
---|
4212 | }
|
---|
4213 |
|
---|
4214 |
|
---|
4215 | /* SVGA_3D_CMD_DX_SET_MIN_LOD 1269 */
|
---|
4216 | static int vmsvga3dCmdDXSetMinLOD(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetMinLOD const *pCmd, uint32_t cbCmd)
|
---|
4217 | {
|
---|
4218 | #ifdef VMSVGA3D_DX
|
---|
4219 | DEBUG_BREAKPOINT_TEST();
|
---|
4220 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4221 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4222 | return vmsvga3dDXSetMinLOD(pThisCC, idDXContext);
|
---|
4223 | #else
|
---|
4224 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4225 | return VERR_NOT_SUPPORTED;
|
---|
4226 | #endif
|
---|
4227 | }
|
---|
4228 |
|
---|
4229 |
|
---|
4230 | /* SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2 1272 */
|
---|
4231 | static int vmsvga3dCmdDXDefineDepthStencilView_v2(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView_v2 const *pCmd, uint32_t cbCmd)
|
---|
4232 | {
|
---|
4233 | #ifdef VMSVGA3D_DX
|
---|
4234 | //DEBUG_BREAKPOINT_TEST();
|
---|
4235 | RT_NOREF(cbCmd);
|
---|
4236 | return vmsvga3dDXDefineDepthStencilView(pThisCC, idDXContext, pCmd);
|
---|
4237 | #else
|
---|
4238 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4239 | return VERR_NOT_SUPPORTED;
|
---|
4240 | #endif
|
---|
4241 | }
|
---|
4242 |
|
---|
4243 |
|
---|
4244 | /* SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB 1273 */
|
---|
4245 | static int vmsvga3dCmdDXDefineStreamOutputWithMob(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutputWithMob const *pCmd, uint32_t cbCmd)
|
---|
4246 | {
|
---|
4247 | #ifdef VMSVGA3D_DX
|
---|
4248 | //DEBUG_BREAKPOINT_TEST();
|
---|
4249 | RT_NOREF(cbCmd);
|
---|
4250 | return vmsvga3dDXDefineStreamOutputWithMob(pThisCC, idDXContext, pCmd);
|
---|
4251 | #else
|
---|
4252 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4253 | return VERR_NOT_SUPPORTED;
|
---|
4254 | #endif
|
---|
4255 | }
|
---|
4256 |
|
---|
4257 |
|
---|
4258 | /* SVGA_3D_CMD_DX_SET_SHADER_IFACE 1274 */
|
---|
4259 | static int vmsvga3dCmdDXSetShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderIface const *pCmd, uint32_t cbCmd)
|
---|
4260 | {
|
---|
4261 | #ifdef VMSVGA3D_DX
|
---|
4262 | DEBUG_BREAKPOINT_TEST();
|
---|
4263 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4264 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4265 | return vmsvga3dDXSetShaderIface(pThisCC, idDXContext);
|
---|
4266 | #else
|
---|
4267 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4268 | return VERR_NOT_SUPPORTED;
|
---|
4269 | #endif
|
---|
4270 | }
|
---|
4271 |
|
---|
4272 |
|
---|
4273 | /* SVGA_3D_CMD_DX_BIND_STREAMOUTPUT 1275 */
|
---|
4274 | static int vmsvga3dCmdDXBindStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindStreamOutput const *pCmd, uint32_t cbCmd)
|
---|
4275 | {
|
---|
4276 | #ifdef VMSVGA3D_DX
|
---|
4277 | //DEBUG_BREAKPOINT_TEST();
|
---|
4278 | RT_NOREF(cbCmd);
|
---|
4279 | return vmsvga3dDXBindStreamOutput(pThisCC, idDXContext, pCmd);
|
---|
4280 | #else
|
---|
4281 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4282 | return VERR_NOT_SUPPORTED;
|
---|
4283 | #endif
|
---|
4284 | }
|
---|
4285 |
|
---|
4286 |
|
---|
4287 | /* SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS 1276 */
|
---|
4288 | static int vmsvga3dCmdSurfaceStretchBltNonMSToMS(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdSurfaceStretchBltNonMSToMS const *pCmd, uint32_t cbCmd)
|
---|
4289 | {
|
---|
4290 | #ifdef VMSVGA3D_DX
|
---|
4291 | DEBUG_BREAKPOINT_TEST();
|
---|
4292 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4293 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4294 | return vmsvga3dSurfaceStretchBltNonMSToMS(pThisCC, idDXContext);
|
---|
4295 | #else
|
---|
4296 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4297 | return VERR_NOT_SUPPORTED;
|
---|
4298 | #endif
|
---|
4299 | }
|
---|
4300 |
|
---|
4301 |
|
---|
4302 | /* SVGA_3D_CMD_DX_BIND_SHADER_IFACE 1277 */
|
---|
4303 | static int vmsvga3dCmdDXBindShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindShaderIface const *pCmd, uint32_t cbCmd)
|
---|
4304 | {
|
---|
4305 | #ifdef VMSVGA3D_DX
|
---|
4306 | DEBUG_BREAKPOINT_TEST();
|
---|
4307 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4308 | RT_NOREF(pSvgaR3State, pCmd, cbCmd);
|
---|
4309 | return vmsvga3dDXBindShaderIface(pThisCC, idDXContext);
|
---|
4310 | #else
|
---|
4311 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4312 | return VERR_NOT_SUPPORTED;
|
---|
4313 | #endif
|
---|
4314 | }
|
---|
4315 |
|
---|
4316 |
|
---|
4317 | /* SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION 1083 */
|
---|
4318 | static int vmsvga3dCmdVBDXClearRenderTargetViewRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdVBDXClearRenderTargetViewRegion *pCmd, uint32_t cbCmd)
|
---|
4319 | {
|
---|
4320 | #ifdef VMSVGA3D_DX
|
---|
4321 | //DEBUG_BREAKPOINT_TEST();
|
---|
4322 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4323 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4324 | return vmsvga3dVBDXClearRenderTargetViewRegion(pThisCC, idDXContext, pCmd, cRect, paRect);
|
---|
4325 | #else
|
---|
4326 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4327 | return VERR_NOT_SUPPORTED;
|
---|
4328 | #endif
|
---|
4329 | }
|
---|
4330 |
|
---|
4331 |
|
---|
4332 | /* VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR VBSVGA_3D_CMD_BASE + 0 */
|
---|
4333 | static int vmsvga3dVBCmdDXDefineVideoProcessor(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDefineVideoProcessor *pCmd, uint32_t cbCmd)
|
---|
4334 | {
|
---|
4335 | #ifdef VMSVGA3D_DX
|
---|
4336 | //DEBUG_BREAKPOINT_TEST();
|
---|
4337 | RT_NOREF(cbCmd);
|
---|
4338 | return vmsvga3dVBDXDefineVideoProcessor(pThisCC, idDXContext, pCmd);
|
---|
4339 | #else
|
---|
4340 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4341 | return VERR_NOT_SUPPORTED;
|
---|
4342 | #endif
|
---|
4343 | }
|
---|
4344 |
|
---|
4345 |
|
---|
4346 | /* VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER_OUTPUT_VIEW VBSVGA_3D_CMD_BASE + 1 */
|
---|
4347 | static int vmsvga3dVBCmdDXDefineVideoDecoderOutputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDefineVideoDecoderOutputView *pCmd, uint32_t cbCmd)
|
---|
4348 | {
|
---|
4349 | #ifdef VMSVGA3D_DX
|
---|
4350 | //DEBUG_BREAKPOINT_TEST();
|
---|
4351 | RT_NOREF(cbCmd);
|
---|
4352 | return vmsvga3dVBDXDefineVideoDecoderOutputView(pThisCC, idDXContext, pCmd);
|
---|
4353 | #else
|
---|
4354 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4355 | return VERR_NOT_SUPPORTED;
|
---|
4356 | #endif
|
---|
4357 | }
|
---|
4358 |
|
---|
4359 |
|
---|
4360 | /* VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER VBSVGA_3D_CMD_BASE + 2 */
|
---|
4361 | static int vmsvga3dVBCmdDXDefineVideoDecoder(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDefineVideoDecoder *pCmd, uint32_t cbCmd)
|
---|
4362 | {
|
---|
4363 | #ifdef VMSVGA3D_DX
|
---|
4364 | //DEBUG_BREAKPOINT_TEST();
|
---|
4365 | RT_NOREF(cbCmd);
|
---|
4366 | return vmsvga3dVBDXDefineVideoDecoder(pThisCC, idDXContext, pCmd);
|
---|
4367 | #else
|
---|
4368 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4369 | return VERR_NOT_SUPPORTED;
|
---|
4370 | #endif
|
---|
4371 | }
|
---|
4372 |
|
---|
4373 |
|
---|
4374 | /* VBSVGA_3D_CMD_DX_VIDEO_DECODER_BEGIN_FRAME VBSVGA_3D_CMD_BASE + 3 */
|
---|
4375 | static int vmsvga3dVBCmdDXVideoDecoderBeginFrame(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoDecoderBeginFrame *pCmd, uint32_t cbCmd)
|
---|
4376 | {
|
---|
4377 | #ifdef VMSVGA3D_DX
|
---|
4378 | //DEBUG_BREAKPOINT_TEST();
|
---|
4379 | RT_NOREF(cbCmd);
|
---|
4380 | return vmsvga3dVBDXVideoDecoderBeginFrame(pThisCC, idDXContext, pCmd);
|
---|
4381 | #else
|
---|
4382 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4383 | return VERR_NOT_SUPPORTED;
|
---|
4384 | #endif
|
---|
4385 | }
|
---|
4386 |
|
---|
4387 |
|
---|
4388 | /* VBSVGA_3D_CMD_DX_VIDEO_DECODER_SUBMIT_BUFFERS VBSVGA_3D_CMD_BASE + 4 */
|
---|
4389 | static int vmsvga3dVBCmdDXVideoDecoderSubmitBuffers(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoDecoderSubmitBuffers *pCmd, uint32_t cbCmd)
|
---|
4390 | {
|
---|
4391 | #ifdef VMSVGA3D_DX
|
---|
4392 | //DEBUG_BREAKPOINT_TEST();
|
---|
4393 | VBSVGA3dVideoDecoderBufferDesc const *paBufferDesc = (VBSVGA3dVideoDecoderBufferDesc *)&pCmd[1];
|
---|
4394 | uint32_t const cBuffer = (cbCmd - sizeof(*pCmd)) / sizeof(VBSVGA3dVideoDecoderBufferDesc);
|
---|
4395 | return vmsvga3dVBDXVideoDecoderSubmitBuffers(pThisCC, idDXContext, pCmd, cBuffer, paBufferDesc);
|
---|
4396 | #else
|
---|
4397 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4398 | return VERR_NOT_SUPPORTED;
|
---|
4399 | #endif
|
---|
4400 | }
|
---|
4401 |
|
---|
4402 |
|
---|
4403 | /* VBSVGA_3D_CMD_DX_VIDEO_DECODER_END_FRAME VBSVGA_3D_CMD_BASE + 5 */
|
---|
4404 | static int vmsvga3dVBCmdDXVideoDecoderEndFrame(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoDecoderEndFrame *pCmd, uint32_t cbCmd)
|
---|
4405 | {
|
---|
4406 | #ifdef VMSVGA3D_DX
|
---|
4407 | //DEBUG_BREAKPOINT_TEST();
|
---|
4408 | RT_NOREF(cbCmd);
|
---|
4409 | return vmsvga3dVBDXVideoDecoderEndFrame(pThisCC, idDXContext, pCmd);
|
---|
4410 | #else
|
---|
4411 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4412 | return VERR_NOT_SUPPORTED;
|
---|
4413 | #endif
|
---|
4414 | }
|
---|
4415 |
|
---|
4416 |
|
---|
4417 | /* VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_INPUT_VIEW VBSVGA_3D_CMD_BASE + 6 */
|
---|
4418 | static int vmsvga3dVBCmdDXDefineVideoProcessorInputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDefineVideoProcessorInputView *pCmd, uint32_t cbCmd)
|
---|
4419 | {
|
---|
4420 | #ifdef VMSVGA3D_DX
|
---|
4421 | //DEBUG_BREAKPOINT_TEST();
|
---|
4422 | RT_NOREF(cbCmd);
|
---|
4423 | return vmsvga3dVBDXDefineVideoProcessorInputView(pThisCC, idDXContext, pCmd);
|
---|
4424 | #else
|
---|
4425 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4426 | return VERR_NOT_SUPPORTED;
|
---|
4427 | #endif
|
---|
4428 | }
|
---|
4429 |
|
---|
4430 |
|
---|
4431 | /* VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_OUTPUT_VIEW VBSVGA_3D_CMD_BASE + 7 */
|
---|
4432 | static int vmsvga3dVBCmdDXDefineVideoProcessorOutputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDefineVideoProcessorOutputView *pCmd, uint32_t cbCmd)
|
---|
4433 | {
|
---|
4434 | #ifdef VMSVGA3D_DX
|
---|
4435 | //DEBUG_BREAKPOINT_TEST();
|
---|
4436 | RT_NOREF(cbCmd);
|
---|
4437 | return vmsvga3dVBDXDefineVideoProcessorOutputView(pThisCC, idDXContext, pCmd);
|
---|
4438 | #else
|
---|
4439 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4440 | return VERR_NOT_SUPPORTED;
|
---|
4441 | #endif
|
---|
4442 | }
|
---|
4443 |
|
---|
4444 |
|
---|
4445 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_BLT VBSVGA_3D_CMD_BASE + 8 */
|
---|
4446 | static int vmsvga3dVBCmdDXVideoProcessorBlt(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorBlt *pCmd, uint32_t cbCmd)
|
---|
4447 | {
|
---|
4448 | #ifdef VMSVGA3D_DX
|
---|
4449 | //DEBUG_BREAKPOINT_TEST();
|
---|
4450 | return vmsvga3dVBDXVideoProcessorBlt(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4451 | #else
|
---|
4452 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4453 | return VERR_NOT_SUPPORTED;
|
---|
4454 | #endif
|
---|
4455 | }
|
---|
4456 |
|
---|
4457 |
|
---|
4458 | /* VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER VBSVGA_3D_CMD_BASE + 9 */
|
---|
4459 | static int vmsvga3dVBCmdDXDestroyVideoDecoder(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDestroyVideoDecoder *pCmd, uint32_t cbCmd)
|
---|
4460 | {
|
---|
4461 | #ifdef VMSVGA3D_DX
|
---|
4462 | //DEBUG_BREAKPOINT_TEST();
|
---|
4463 | RT_NOREF(cbCmd);
|
---|
4464 | return vmsvga3dVBDXDestroyVideoDecoder(pThisCC, idDXContext, pCmd);
|
---|
4465 | #else
|
---|
4466 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4467 | return VERR_NOT_SUPPORTED;
|
---|
4468 | #endif
|
---|
4469 | }
|
---|
4470 |
|
---|
4471 |
|
---|
4472 | /* VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER_OUTPUT_VIEW VBSVGA_3D_CMD_BASE + 10 */
|
---|
4473 | static int vmsvga3dVBCmdDXDestroyVideoDecoderOutputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDestroyVideoDecoderOutputView *pCmd, uint32_t cbCmd)
|
---|
4474 | {
|
---|
4475 | #ifdef VMSVGA3D_DX
|
---|
4476 | //DEBUG_BREAKPOINT_TEST();
|
---|
4477 | RT_NOREF(cbCmd);
|
---|
4478 | return vmsvga3dVBDXDestroyVideoDecoderOutputView(pThisCC, idDXContext, pCmd);
|
---|
4479 | #else
|
---|
4480 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4481 | return VERR_NOT_SUPPORTED;
|
---|
4482 | #endif
|
---|
4483 | }
|
---|
4484 |
|
---|
4485 |
|
---|
4486 | /* VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR VBSVGA_3D_CMD_BASE + 11 */
|
---|
4487 | static int vmsvga3dVBCmdDXDestroyVideoProcessor(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDestroyVideoProcessor *pCmd, uint32_t cbCmd)
|
---|
4488 | {
|
---|
4489 | #ifdef VMSVGA3D_DX
|
---|
4490 | //DEBUG_BREAKPOINT_TEST();
|
---|
4491 | RT_NOREF(cbCmd);
|
---|
4492 | return vmsvga3dVBDXDestroyVideoProcessor(pThisCC, idDXContext, pCmd);
|
---|
4493 | #else
|
---|
4494 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4495 | return VERR_NOT_SUPPORTED;
|
---|
4496 | #endif
|
---|
4497 | }
|
---|
4498 |
|
---|
4499 |
|
---|
4500 | /* VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_INPUT_VIEW VBSVGA_3D_CMD_BASE + 12 */
|
---|
4501 | static int vmsvga3dVBCmdDXDestroyVideoProcessorInputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDestroyVideoProcessorInputView *pCmd, uint32_t cbCmd)
|
---|
4502 | {
|
---|
4503 | #ifdef VMSVGA3D_DX
|
---|
4504 | //DEBUG_BREAKPOINT_TEST();
|
---|
4505 | RT_NOREF(cbCmd);
|
---|
4506 | return vmsvga3dVBDXDestroyVideoProcessorInputView(pThisCC, idDXContext, pCmd);
|
---|
4507 | #else
|
---|
4508 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4509 | return VERR_NOT_SUPPORTED;
|
---|
4510 | #endif
|
---|
4511 | }
|
---|
4512 |
|
---|
4513 |
|
---|
4514 | /* VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_OUTPUT_VIEW VBSVGA_3D_CMD_BASE + 13 */
|
---|
4515 | static int vmsvga3dVBCmdDXDestroyVideoProcessorOutputView(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXDestroyVideoProcessorOutputView *pCmd, uint32_t cbCmd)
|
---|
4516 | {
|
---|
4517 | #ifdef VMSVGA3D_DX
|
---|
4518 | //DEBUG_BREAKPOINT_TEST();
|
---|
4519 | RT_NOREF(cbCmd);
|
---|
4520 | return vmsvga3dVBDXDestroyVideoProcessorOutputView(pThisCC, idDXContext, pCmd);
|
---|
4521 | #else
|
---|
4522 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4523 | return VERR_NOT_SUPPORTED;
|
---|
4524 | #endif
|
---|
4525 | }
|
---|
4526 |
|
---|
4527 |
|
---|
4528 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_TARGET_RECT VBSVGA_3D_CMD_BASE + 14 */
|
---|
4529 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputTargetRect(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputTargetRect const *pCmd, uint32_t cbCmd)
|
---|
4530 | {
|
---|
4531 | #ifdef VMSVGA3D_DX
|
---|
4532 | //DEBUG_BREAKPOINT_TEST();
|
---|
4533 | RT_NOREF(cbCmd);
|
---|
4534 | return vmsvga3dVBDXVideoProcessorSetOutputTargetRect(pThisCC, idDXContext, pCmd);
|
---|
4535 | #else
|
---|
4536 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4537 | return VERR_NOT_SUPPORTED;
|
---|
4538 | #endif
|
---|
4539 | }
|
---|
4540 |
|
---|
4541 |
|
---|
4542 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_BACKGROUND_COLOR VBSVGA_3D_CMD_BASE + 15 */
|
---|
4543 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputBackgroundColor(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputBackgroundColor const *pCmd, uint32_t cbCmd)
|
---|
4544 | {
|
---|
4545 | #ifdef VMSVGA3D_DX
|
---|
4546 | //DEBUG_BREAKPOINT_TEST();
|
---|
4547 | RT_NOREF(cbCmd);
|
---|
4548 | return vmsvga3dVBDXVideoProcessorSetOutputBackgroundColor(pThisCC, idDXContext, pCmd);
|
---|
4549 | #else
|
---|
4550 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4551 | return VERR_NOT_SUPPORTED;
|
---|
4552 | #endif
|
---|
4553 | }
|
---|
4554 |
|
---|
4555 |
|
---|
4556 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_COLOR_SPACE VBSVGA_3D_CMD_BASE + 16 */
|
---|
4557 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputColorSpace(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputColorSpace const *pCmd, uint32_t cbCmd)
|
---|
4558 | {
|
---|
4559 | #ifdef VMSVGA3D_DX
|
---|
4560 | //DEBUG_BREAKPOINT_TEST();
|
---|
4561 | RT_NOREF(cbCmd);
|
---|
4562 | return vmsvga3dVBDXVideoProcessorSetOutputColorSpace(pThisCC, idDXContext, pCmd);
|
---|
4563 | #else
|
---|
4564 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4565 | return VERR_NOT_SUPPORTED;
|
---|
4566 | #endif
|
---|
4567 | }
|
---|
4568 |
|
---|
4569 |
|
---|
4570 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_ALPHA_FILL_MODE VBSVGA_3D_CMD_BASE + 17 */
|
---|
4571 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputAlphaFillMode(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputAlphaFillMode const *pCmd, uint32_t cbCmd)
|
---|
4572 | {
|
---|
4573 | #ifdef VMSVGA3D_DX
|
---|
4574 | //DEBUG_BREAKPOINT_TEST();
|
---|
4575 | RT_NOREF(cbCmd);
|
---|
4576 | return vmsvga3dVBDXVideoProcessorSetOutputAlphaFillMode(pThisCC, idDXContext, pCmd);
|
---|
4577 | #else
|
---|
4578 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4579 | return VERR_NOT_SUPPORTED;
|
---|
4580 | #endif
|
---|
4581 | }
|
---|
4582 |
|
---|
4583 |
|
---|
4584 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_CONSTRICTION VBSVGA_3D_CMD_BASE + 18 */
|
---|
4585 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputConstriction(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputConstriction const *pCmd, uint32_t cbCmd)
|
---|
4586 | {
|
---|
4587 | #ifdef VMSVGA3D_DX
|
---|
4588 | //DEBUG_BREAKPOINT_TEST();
|
---|
4589 | RT_NOREF(cbCmd);
|
---|
4590 | return vmsvga3dVBDXVideoProcessorSetOutputConstriction(pThisCC, idDXContext, pCmd);
|
---|
4591 | #else
|
---|
4592 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4593 | return VERR_NOT_SUPPORTED;
|
---|
4594 | #endif
|
---|
4595 | }
|
---|
4596 |
|
---|
4597 |
|
---|
4598 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_STEREO_MODE VBSVGA_3D_CMD_BASE + 19 */
|
---|
4599 | static int vmsvga3dVBCmdDXVideoProcessorSetOutputStereoMode(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetOutputStereoMode const *pCmd, uint32_t cbCmd)
|
---|
4600 | {
|
---|
4601 | #ifdef VMSVGA3D_DX
|
---|
4602 | //DEBUG_BREAKPOINT_TEST();
|
---|
4603 | RT_NOREF(cbCmd);
|
---|
4604 | return vmsvga3dVBDXVideoProcessorSetOutputStereoMode(pThisCC, idDXContext, pCmd);
|
---|
4605 | #else
|
---|
4606 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4607 | return VERR_NOT_SUPPORTED;
|
---|
4608 | #endif
|
---|
4609 | }
|
---|
4610 |
|
---|
4611 |
|
---|
4612 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FRAME_FORMAT VBSVGA_3D_CMD_BASE + 20 */
|
---|
4613 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamFrameFormat(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamFrameFormat const *pCmd, uint32_t cbCmd)
|
---|
4614 | {
|
---|
4615 | #ifdef VMSVGA3D_DX
|
---|
4616 | //DEBUG_BREAKPOINT_TEST();
|
---|
4617 | RT_NOREF(cbCmd);
|
---|
4618 | return vmsvga3dVBDXVideoProcessorSetStreamFrameFormat(pThisCC, idDXContext, pCmd);
|
---|
4619 | #else
|
---|
4620 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4621 | return VERR_NOT_SUPPORTED;
|
---|
4622 | #endif
|
---|
4623 | }
|
---|
4624 |
|
---|
4625 |
|
---|
4626 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_COLOR_SPACE VBSVGA_3D_CMD_BASE + 21 */
|
---|
4627 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamColorSpace(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamColorSpace const *pCmd, uint32_t cbCmd)
|
---|
4628 | {
|
---|
4629 | #ifdef VMSVGA3D_DX
|
---|
4630 | //DEBUG_BREAKPOINT_TEST();
|
---|
4631 | RT_NOREF(cbCmd);
|
---|
4632 | return vmsvga3dVBDXVideoProcessorSetStreamColorSpace(pThisCC, idDXContext, pCmd);
|
---|
4633 | #else
|
---|
4634 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4635 | return VERR_NOT_SUPPORTED;
|
---|
4636 | #endif
|
---|
4637 | }
|
---|
4638 |
|
---|
4639 |
|
---|
4640 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_OUTPUT_RATE VBSVGA_3D_CMD_BASE + 22 */
|
---|
4641 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamOutputRate(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamOutputRate const *pCmd, uint32_t cbCmd)
|
---|
4642 | {
|
---|
4643 | #ifdef VMSVGA3D_DX
|
---|
4644 | //DEBUG_BREAKPOINT_TEST();
|
---|
4645 | RT_NOREF(cbCmd);
|
---|
4646 | return vmsvga3dVBDXVideoProcessorSetStreamOutputRate(pThisCC, idDXContext, pCmd);
|
---|
4647 | #else
|
---|
4648 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4649 | return VERR_NOT_SUPPORTED;
|
---|
4650 | #endif
|
---|
4651 | }
|
---|
4652 |
|
---|
4653 |
|
---|
4654 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_SOURCE_RECT VBSVGA_3D_CMD_BASE + 23 */
|
---|
4655 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamSourceRect(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamSourceRect const *pCmd, uint32_t cbCmd)
|
---|
4656 | {
|
---|
4657 | #ifdef VMSVGA3D_DX
|
---|
4658 | //DEBUG_BREAKPOINT_TEST();
|
---|
4659 | RT_NOREF(cbCmd);
|
---|
4660 | return vmsvga3dVBDXVideoProcessorSetStreamSourceRect(pThisCC, idDXContext, pCmd);
|
---|
4661 | #else
|
---|
4662 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4663 | return VERR_NOT_SUPPORTED;
|
---|
4664 | #endif
|
---|
4665 | }
|
---|
4666 |
|
---|
4667 |
|
---|
4668 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_DEST_RECT VBSVGA_3D_CMD_BASE + 24 */
|
---|
4669 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamDestRect(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamDestRect const *pCmd, uint32_t cbCmd)
|
---|
4670 | {
|
---|
4671 | #ifdef VMSVGA3D_DX
|
---|
4672 | //DEBUG_BREAKPOINT_TEST();
|
---|
4673 | RT_NOREF(cbCmd);
|
---|
4674 | return vmsvga3dVBDXVideoProcessorSetStreamDestRect(pThisCC, idDXContext, pCmd);
|
---|
4675 | #else
|
---|
4676 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4677 | return VERR_NOT_SUPPORTED;
|
---|
4678 | #endif
|
---|
4679 | }
|
---|
4680 |
|
---|
4681 |
|
---|
4682 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ALPHA VBSVGA_3D_CMD_BASE + 25 */
|
---|
4683 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamAlpha(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamAlpha const *pCmd, uint32_t cbCmd)
|
---|
4684 | {
|
---|
4685 | #ifdef VMSVGA3D_DX
|
---|
4686 | //DEBUG_BREAKPOINT_TEST();
|
---|
4687 | RT_NOREF(cbCmd);
|
---|
4688 | return vmsvga3dVBDXVideoProcessorSetStreamAlpha(pThisCC, idDXContext, pCmd);
|
---|
4689 | #else
|
---|
4690 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4691 | return VERR_NOT_SUPPORTED;
|
---|
4692 | #endif
|
---|
4693 | }
|
---|
4694 |
|
---|
4695 |
|
---|
4696 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PALETTE VBSVGA_3D_CMD_BASE + 26, */
|
---|
4697 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamPalette(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamPalette const *pCmd, uint32_t cbCmd)
|
---|
4698 | {
|
---|
4699 | #ifdef VMSVGA3D_DX
|
---|
4700 | //DEBUG_BREAKPOINT_TEST();
|
---|
4701 | uint32_t const *paEntries = (uint32_t *)&pCmd[1];
|
---|
4702 | uint32_t const cEntries = (cbCmd - sizeof(*pCmd)) / sizeof(uint32_t);
|
---|
4703 | return vmsvga3dVBDXVideoProcessorSetStreamPalette(pThisCC, idDXContext, pCmd, cEntries, paEntries);
|
---|
4704 | #else
|
---|
4705 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4706 | return VERR_NOT_SUPPORTED;
|
---|
4707 | #endif
|
---|
4708 | }
|
---|
4709 |
|
---|
4710 |
|
---|
4711 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PIXEL_ASPECT_RATIO VBSVGA_3D_CMD_BASE + 27 */
|
---|
4712 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamPixelAspectRatio(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamPixelAspectRatio const *pCmd, uint32_t cbCmd)
|
---|
4713 | {
|
---|
4714 | #ifdef VMSVGA3D_DX
|
---|
4715 | //DEBUG_BREAKPOINT_TEST();
|
---|
4716 | RT_NOREF(cbCmd);
|
---|
4717 | return vmsvga3dVBDXVideoProcessorSetStreamPixelAspectRatio(pThisCC, idDXContext, pCmd);
|
---|
4718 | #else
|
---|
4719 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4720 | return VERR_NOT_SUPPORTED;
|
---|
4721 | #endif
|
---|
4722 | }
|
---|
4723 |
|
---|
4724 |
|
---|
4725 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_LUMA_KEY VBSVGA_3D_CMD_BASE + 28 */
|
---|
4726 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamLumaKey(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamLumaKey const *pCmd, uint32_t cbCmd)
|
---|
4727 | {
|
---|
4728 | #ifdef VMSVGA3D_DX
|
---|
4729 | //DEBUG_BREAKPOINT_TEST();
|
---|
4730 | RT_NOREF(cbCmd);
|
---|
4731 | return vmsvga3dVBDXVideoProcessorSetStreamLumaKey(pThisCC, idDXContext, pCmd);
|
---|
4732 | #else
|
---|
4733 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4734 | return VERR_NOT_SUPPORTED;
|
---|
4735 | #endif
|
---|
4736 | }
|
---|
4737 |
|
---|
4738 |
|
---|
4739 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_STEREO_FORMAT VBSVGA_3D_CMD_BASE + 29 */
|
---|
4740 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamStereoFormat(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamStereoFormat const *pCmd, uint32_t cbCmd)
|
---|
4741 | {
|
---|
4742 | #ifdef VMSVGA3D_DX
|
---|
4743 | //DEBUG_BREAKPOINT_TEST();
|
---|
4744 | RT_NOREF(cbCmd);
|
---|
4745 | return vmsvga3dVBDXVideoProcessorSetStreamStereoFormat(pThisCC, idDXContext, pCmd);
|
---|
4746 | #else
|
---|
4747 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4748 | return VERR_NOT_SUPPORTED;
|
---|
4749 | #endif
|
---|
4750 | }
|
---|
4751 |
|
---|
4752 |
|
---|
4753 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_AUTO_PROCESSING_MODE VBSVGA_3D_CMD_BASE + 30 */
|
---|
4754 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamAutoProcessingMode(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamAutoProcessingMode const *pCmd, uint32_t cbCmd)
|
---|
4755 | {
|
---|
4756 | #ifdef VMSVGA3D_DX
|
---|
4757 | //DEBUG_BREAKPOINT_TEST();
|
---|
4758 | RT_NOREF(cbCmd);
|
---|
4759 | return vmsvga3dVBDXVideoProcessorSetStreamAutoProcessingMode(pThisCC, idDXContext, pCmd);
|
---|
4760 | #else
|
---|
4761 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4762 | return VERR_NOT_SUPPORTED;
|
---|
4763 | #endif
|
---|
4764 | }
|
---|
4765 |
|
---|
4766 |
|
---|
4767 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FILTER VBSVGA_3D_CMD_BASE + 31 */
|
---|
4768 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamFilter(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamFilter const *pCmd, uint32_t cbCmd)
|
---|
4769 | {
|
---|
4770 | #ifdef VMSVGA3D_DX
|
---|
4771 | //DEBUG_BREAKPOINT_TEST();
|
---|
4772 | RT_NOREF(cbCmd);
|
---|
4773 | return vmsvga3dVBDXVideoProcessorSetStreamFilter(pThisCC, idDXContext, pCmd);
|
---|
4774 | #else
|
---|
4775 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4776 | return VERR_NOT_SUPPORTED;
|
---|
4777 | #endif
|
---|
4778 | }
|
---|
4779 |
|
---|
4780 |
|
---|
4781 | /* VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ROTATION VBSVGA_3D_CMD_BASE + 32 */
|
---|
4782 | static int vmsvga3dVBCmdDXVideoProcessorSetStreamRotation(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXVideoProcessorSetStreamRotation const *pCmd, uint32_t cbCmd)
|
---|
4783 | {
|
---|
4784 | #ifdef VMSVGA3D_DX
|
---|
4785 | //DEBUG_BREAKPOINT_TEST();
|
---|
4786 | RT_NOREF(cbCmd);
|
---|
4787 | return vmsvga3dVBDXVideoProcessorSetStreamRotation(pThisCC, idDXContext, pCmd);
|
---|
4788 | #else
|
---|
4789 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4790 | return VERR_NOT_SUPPORTED;
|
---|
4791 | #endif
|
---|
4792 | }
|
---|
4793 |
|
---|
4794 |
|
---|
4795 | /* VBSVGA_3D_CMD_DX_GET_VIDEO_CAPABILITY VBSVGA_3D_CMD_BASE + 33 */
|
---|
4796 | static int vmsvga3dVBCmdDXGetVideoCapability(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXGetVideoCapability const *pCmd, uint32_t cbCmd)
|
---|
4797 | {
|
---|
4798 | #ifdef VMSVGA3D_DX
|
---|
4799 | //DEBUG_BREAKPOINT_TEST();
|
---|
4800 | RT_NOREF(cbCmd);
|
---|
4801 | return vmsvga3dVBDXGetVideoCapability(pThisCC, idDXContext, pCmd);
|
---|
4802 | #else
|
---|
4803 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4804 | return VERR_NOT_SUPPORTED;
|
---|
4805 | #endif
|
---|
4806 | }
|
---|
4807 |
|
---|
4808 |
|
---|
4809 | /* VBSVGA_3D_CMD_DX_CLEAR_RTV VBSVGA_3D_CMD_BASE + 34 */
|
---|
4810 | static int vmsvga3dVBCmdDXClearRTV(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXClearView *pCmd, uint32_t cbCmd)
|
---|
4811 | {
|
---|
4812 | #ifdef VMSVGA3D_DX
|
---|
4813 | //DEBUG_BREAKPOINT_TEST();
|
---|
4814 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4815 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4816 | return vmsvga3dVBDXClearRTV(pThisCC, idDXContext, pCmd, cRect, cRect ? paRect : NULL);
|
---|
4817 | #else
|
---|
4818 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4819 | return VERR_NOT_SUPPORTED;
|
---|
4820 | #endif
|
---|
4821 | }
|
---|
4822 |
|
---|
4823 |
|
---|
4824 | /* VBSVGA_3D_CMD_DX_CLEAR_UAV VBSVGA_3D_CMD_BASE + 35 */
|
---|
4825 | static int vmsvga3dVBCmdDXClearUAV(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXClearView *pCmd, uint32_t cbCmd)
|
---|
4826 | {
|
---|
4827 | #ifdef VMSVGA3D_DX
|
---|
4828 | //DEBUG_BREAKPOINT_TEST();
|
---|
4829 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4830 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4831 | return vmsvga3dVBDXClearUAV(pThisCC, idDXContext, pCmd, cRect, cRect ? paRect : NULL);
|
---|
4832 | #else
|
---|
4833 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4834 | return VERR_NOT_SUPPORTED;
|
---|
4835 | #endif
|
---|
4836 | }
|
---|
4837 |
|
---|
4838 |
|
---|
4839 | /* VBSVGA_3D_CMD_DX_CLEAR_VDOV VBSVGA_3D_CMD_BASE + 36 */
|
---|
4840 | static int vmsvga3dVBCmdDXClearVDOV(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXClearView *pCmd, uint32_t cbCmd)
|
---|
4841 | {
|
---|
4842 | #ifdef VMSVGA3D_DX
|
---|
4843 | //DEBUG_BREAKPOINT_TEST();
|
---|
4844 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4845 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4846 | return vmsvga3dVBDXClearVDOV(pThisCC, idDXContext, pCmd, cRect, cRect ? paRect : NULL);
|
---|
4847 | #else
|
---|
4848 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4849 | return VERR_NOT_SUPPORTED;
|
---|
4850 | #endif
|
---|
4851 | }
|
---|
4852 |
|
---|
4853 |
|
---|
4854 | /* VBSVGA_3D_CMD_DX_CLEAR_VPIV VBSVGA_3D_CMD_BASE + 37 */
|
---|
4855 | static int vmsvga3dVBCmdDXClearVPIV(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXClearView *pCmd, uint32_t cbCmd)
|
---|
4856 | {
|
---|
4857 | #ifdef VMSVGA3D_DX
|
---|
4858 | //DEBUG_BREAKPOINT_TEST();
|
---|
4859 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4860 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4861 | return vmsvga3dVBDXClearVPIV(pThisCC, idDXContext, pCmd, cRect, cRect ? paRect : NULL);
|
---|
4862 | #else
|
---|
4863 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4864 | return VERR_NOT_SUPPORTED;
|
---|
4865 | #endif
|
---|
4866 | }
|
---|
4867 |
|
---|
4868 |
|
---|
4869 | /* VBSVGA_3D_CMD_DX_CLEAR_VPOV VBSVGA_3D_CMD_BASE + 38 */
|
---|
4870 | static int vmsvga3dVBCmdDXClearVPOV(PVGASTATECC pThisCC, uint32_t idDXContext, VBSVGA3dCmdDXClearView *pCmd, uint32_t cbCmd)
|
---|
4871 | {
|
---|
4872 | #ifdef VMSVGA3D_DX
|
---|
4873 | //DEBUG_BREAKPOINT_TEST();
|
---|
4874 | SVGASignedRect const *paRect = (SVGASignedRect *)&pCmd[1];
|
---|
4875 | uint32_t const cRect = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
4876 | return vmsvga3dVBDXClearVPOV(pThisCC, idDXContext, pCmd, cRect, cRect ? paRect : NULL);
|
---|
4877 | #else
|
---|
4878 | RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
|
---|
4879 | return VERR_NOT_SUPPORTED;
|
---|
4880 | #endif
|
---|
4881 | }
|
---|
4882 |
|
---|
4883 |
|
---|
4884 | /** @def VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK
|
---|
4885 | * Check that the 3D command has at least a_cbMin of payload bytes after the
|
---|
4886 | * header. Will break out of the switch if it doesn't.
|
---|
4887 | */
|
---|
4888 | # define VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(a_cbMin) \
|
---|
4889 | if (1) { \
|
---|
4890 | AssertMsgBreak(cbCmd >= (a_cbMin), ("size=%#x a_cbMin=%#zx\n", cbCmd, (size_t)(a_cbMin))); \
|
---|
4891 | RT_UNTRUSTED_VALIDATED_FENCE(); \
|
---|
4892 | } else do {} while (0)
|
---|
4893 |
|
---|
4894 | # define VMSVGA_3D_CMD_NOTIMPL() \
|
---|
4895 | if (1) { \
|
---|
4896 | AssertMsgFailed(("Not implemented %d %s\n", enmCmdId, vmsvgaR3FifoCmdToString(enmCmdId))); \
|
---|
4897 | } else do {} while (0)
|
---|
4898 |
|
---|
4899 | /** SVGA_3D_CMD_* handler.
|
---|
4900 | * This function parses the command and calls the corresponding command handler.
|
---|
4901 | *
|
---|
4902 | * @param pThis The shared VGA/VMSVGA state.
|
---|
4903 | * @param pThisCC The VGA/VMSVGA state for the current context.
|
---|
4904 | * @param idDXContext VGPU10 DX context of the commands or SVGA3D_INVALID_ID if they are not for a specific context.
|
---|
4905 | * @param enmCmdId SVGA_3D_CMD_* command identifier.
|
---|
4906 | * @param cbCmd Size of the command in bytes.
|
---|
4907 | * @param pvCmd Pointer to the command.
|
---|
4908 | * @returns VBox status code if an error was detected parsing a command.
|
---|
4909 | */
|
---|
4910 | int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDXContext, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd)
|
---|
4911 | {
|
---|
4912 | int rcParse = VINF_SUCCESS;
|
---|
4913 | PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
4914 |
|
---|
4915 | switch (enmCmdId)
|
---|
4916 | {
|
---|
4917 | case SVGA_3D_CMD_SURFACE_DEFINE:
|
---|
4918 | {
|
---|
4919 | SVGA3dCmdDefineSurface *pCmd = (SVGA3dCmdDefineSurface *)pvCmd;
|
---|
4920 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4921 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefine);
|
---|
4922 |
|
---|
4923 | SVGA3dCmdDefineSurface_v2 cmd;
|
---|
4924 | cmd.sid = pCmd->sid;
|
---|
4925 | cmd.surfaceFlags = pCmd->surfaceFlags;
|
---|
4926 | cmd.format = pCmd->format;
|
---|
4927 | memcpy(cmd.face, pCmd->face, sizeof(cmd.face));
|
---|
4928 | cmd.multisampleCount = 0;
|
---|
4929 | cmd.autogenFilter = SVGA3D_TEX_FILTER_NONE;
|
---|
4930 |
|
---|
4931 | uint32_t const cMipLevelSizes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize);
|
---|
4932 | vmsvga3dCmdDefineSurface(pThisCC, &cmd, cMipLevelSizes, (SVGA3dSize *)(pCmd + 1));
|
---|
4933 | # ifdef DEBUG_GMR_ACCESS
|
---|
4934 | VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
|
---|
4935 | # endif
|
---|
4936 | break;
|
---|
4937 | }
|
---|
4938 |
|
---|
4939 | case SVGA_3D_CMD_SURFACE_DEFINE_V2:
|
---|
4940 | {
|
---|
4941 | SVGA3dCmdDefineSurface_v2 *pCmd = (SVGA3dCmdDefineSurface_v2 *)pvCmd;
|
---|
4942 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4943 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefineV2);
|
---|
4944 |
|
---|
4945 | uint32_t const cMipLevelSizes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize);
|
---|
4946 | vmsvga3dCmdDefineSurface(pThisCC, pCmd, cMipLevelSizes, (SVGA3dSize *)(pCmd + 1));
|
---|
4947 | # ifdef DEBUG_GMR_ACCESS
|
---|
4948 | VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
|
---|
4949 | # endif
|
---|
4950 | break;
|
---|
4951 | }
|
---|
4952 |
|
---|
4953 | case SVGA_3D_CMD_SURFACE_DESTROY:
|
---|
4954 | {
|
---|
4955 | SVGA3dCmdDestroySurface *pCmd = (SVGA3dCmdDestroySurface *)pvCmd;
|
---|
4956 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4957 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDestroy);
|
---|
4958 |
|
---|
4959 | vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid);
|
---|
4960 | break;
|
---|
4961 | }
|
---|
4962 |
|
---|
4963 | case SVGA_3D_CMD_SURFACE_COPY:
|
---|
4964 | {
|
---|
4965 | SVGA3dCmdSurfaceCopy *pCmd = (SVGA3dCmdSurfaceCopy *)pvCmd;
|
---|
4966 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4967 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceCopy);
|
---|
4968 |
|
---|
4969 | uint32_t const cCopyBoxes = (cbCmd - sizeof(pCmd)) / sizeof(SVGA3dCopyBox);
|
---|
4970 | vmsvga3dSurfaceCopy(pThisCC, pCmd->dest, pCmd->src, cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
|
---|
4971 | break;
|
---|
4972 | }
|
---|
4973 |
|
---|
4974 | case SVGA_3D_CMD_SURFACE_STRETCHBLT:
|
---|
4975 | {
|
---|
4976 | SVGA3dCmdSurfaceStretchBlt *pCmd = (SVGA3dCmdSurfaceStretchBlt *)pvCmd;
|
---|
4977 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4978 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceStretchBlt);
|
---|
4979 |
|
---|
4980 | vmsvga3dSurfaceStretchBlt(pThis, pThisCC, &pCmd->dest, &pCmd->boxDest,
|
---|
4981 | &pCmd->src, &pCmd->boxSrc, pCmd->mode);
|
---|
4982 | break;
|
---|
4983 | }
|
---|
4984 |
|
---|
4985 | case SVGA_3D_CMD_SURFACE_DMA:
|
---|
4986 | {
|
---|
4987 | SVGA3dCmdSurfaceDMA *pCmd = (SVGA3dCmdSurfaceDMA *)pvCmd;
|
---|
4988 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
4989 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDma);
|
---|
4990 |
|
---|
4991 | uint64_t u64NanoTS = 0;
|
---|
4992 | if (LogRelIs3Enabled())
|
---|
4993 | u64NanoTS = RTTimeNanoTS();
|
---|
4994 | uint32_t const cCopyBoxes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyBox);
|
---|
4995 | STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a);
|
---|
4996 | vmsvga3dSurfaceDMA(pThis, pThisCC, pCmd->guest, pCmd->host, pCmd->transfer,
|
---|
4997 | cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
|
---|
4998 | STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a);
|
---|
4999 | if (LogRelIs3Enabled())
|
---|
5000 | {
|
---|
5001 | if (cCopyBoxes)
|
---|
5002 | {
|
---|
5003 | SVGA3dCopyBox *pFirstBox = (SVGA3dCopyBox *)(pCmd + 1);
|
---|
5004 | LogRel3(("VMSVGA: SURFACE_DMA: %d us %d boxes %d,%d %dx%d%s\n",
|
---|
5005 | (RTTimeNanoTS() - u64NanoTS) / 1000ULL, cCopyBoxes,
|
---|
5006 | pFirstBox->x, pFirstBox->y, pFirstBox->w, pFirstBox->h,
|
---|
5007 | pCmd->transfer == SVGA3D_READ_HOST_VRAM ? " readback!!!" : ""));
|
---|
5008 | }
|
---|
5009 | }
|
---|
5010 | break;
|
---|
5011 | }
|
---|
5012 |
|
---|
5013 | case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN:
|
---|
5014 | {
|
---|
5015 | SVGA3dCmdBlitSurfaceToScreen *pCmd = (SVGA3dCmdBlitSurfaceToScreen *)pvCmd;
|
---|
5016 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5017 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceScreen);
|
---|
5018 |
|
---|
5019 | static uint64_t u64FrameStartNanoTS = 0;
|
---|
5020 | static uint64_t u64ElapsedPerSecNano = 0;
|
---|
5021 | static int cFrames = 0;
|
---|
5022 | uint64_t u64NanoTS = 0;
|
---|
5023 | if (LogRelIs3Enabled())
|
---|
5024 | u64NanoTS = RTTimeNanoTS();
|
---|
5025 | uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect);
|
---|
5026 | STAM_REL_PROFILE_START(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a);
|
---|
5027 | vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage,
|
---|
5028 | pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1));
|
---|
5029 | STAM_REL_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a);
|
---|
5030 | if (LogRelIs3Enabled())
|
---|
5031 | {
|
---|
5032 | uint64_t u64ElapsedNano = RTTimeNanoTS() - u64NanoTS;
|
---|
5033 | u64ElapsedPerSecNano += u64ElapsedNano;
|
---|
5034 |
|
---|
5035 | SVGASignedRect *pFirstRect = cRects ? (SVGASignedRect *)(pCmd + 1) : &pCmd->destRect;
|
---|
5036 | LogRel3(("VMSVGA: SURFACE_TO_SCREEN: %d us %d rects %d,%d %dx%d\n",
|
---|
5037 | (u64ElapsedNano) / 1000ULL, cRects,
|
---|
5038 | pFirstRect->left, pFirstRect->top,
|
---|
5039 | pFirstRect->right - pFirstRect->left, pFirstRect->bottom - pFirstRect->top));
|
---|
5040 |
|
---|
5041 | ++cFrames;
|
---|
5042 | if (u64NanoTS - u64FrameStartNanoTS >= UINT64_C(1000000000))
|
---|
5043 | {
|
---|
5044 | LogRel3(("VMSVGA: SURFACE_TO_SCREEN: FPS %d, elapsed %llu us\n",
|
---|
5045 | cFrames, u64ElapsedPerSecNano / 1000ULL));
|
---|
5046 | u64FrameStartNanoTS = u64NanoTS;
|
---|
5047 | cFrames = 0;
|
---|
5048 | u64ElapsedPerSecNano = 0;
|
---|
5049 | }
|
---|
5050 | }
|
---|
5051 | break;
|
---|
5052 | }
|
---|
5053 |
|
---|
5054 | case SVGA_3D_CMD_CONTEXT_DEFINE:
|
---|
5055 | {
|
---|
5056 | SVGA3dCmdDefineContext *pCmd = (SVGA3dCmdDefineContext *)pvCmd;
|
---|
5057 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5058 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDefine);
|
---|
5059 |
|
---|
5060 | vmsvga3dContextDefine(pThisCC, pCmd->cid);
|
---|
5061 | break;
|
---|
5062 | }
|
---|
5063 |
|
---|
5064 | case SVGA_3D_CMD_CONTEXT_DESTROY:
|
---|
5065 | {
|
---|
5066 | SVGA3dCmdDestroyContext *pCmd = (SVGA3dCmdDestroyContext *)pvCmd;
|
---|
5067 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5068 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDestroy);
|
---|
5069 |
|
---|
5070 | vmsvga3dContextDestroy(pThisCC, pCmd->cid);
|
---|
5071 | break;
|
---|
5072 | }
|
---|
5073 |
|
---|
5074 | case SVGA_3D_CMD_SETTRANSFORM:
|
---|
5075 | {
|
---|
5076 | SVGA3dCmdSetTransform *pCmd = (SVGA3dCmdSetTransform *)pvCmd;
|
---|
5077 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5078 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTransform);
|
---|
5079 |
|
---|
5080 | vmsvga3dSetTransform(pThisCC, pCmd->cid, pCmd->type, pCmd->matrix);
|
---|
5081 | break;
|
---|
5082 | }
|
---|
5083 |
|
---|
5084 | case SVGA_3D_CMD_SETZRANGE:
|
---|
5085 | {
|
---|
5086 | SVGA3dCmdSetZRange *pCmd = (SVGA3dCmdSetZRange *)pvCmd;
|
---|
5087 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5088 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetZRange);
|
---|
5089 |
|
---|
5090 | vmsvga3dSetZRange(pThisCC, pCmd->cid, pCmd->zRange);
|
---|
5091 | break;
|
---|
5092 | }
|
---|
5093 |
|
---|
5094 | case SVGA_3D_CMD_SETRENDERSTATE:
|
---|
5095 | {
|
---|
5096 | SVGA3dCmdSetRenderState *pCmd = (SVGA3dCmdSetRenderState *)pvCmd;
|
---|
5097 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5098 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderState);
|
---|
5099 |
|
---|
5100 | uint32_t const cRenderStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderState);
|
---|
5101 | vmsvga3dSetRenderState(pThisCC, pCmd->cid, cRenderStates, (SVGA3dRenderState *)(pCmd + 1));
|
---|
5102 | break;
|
---|
5103 | }
|
---|
5104 |
|
---|
5105 | case SVGA_3D_CMD_SETRENDERTARGET:
|
---|
5106 | {
|
---|
5107 | SVGA3dCmdSetRenderTarget *pCmd = (SVGA3dCmdSetRenderTarget *)pvCmd;
|
---|
5108 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5109 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderTarget);
|
---|
5110 |
|
---|
5111 | vmsvga3dSetRenderTarget(pThisCC, pCmd->cid, pCmd->type, pCmd->target);
|
---|
5112 | break;
|
---|
5113 | }
|
---|
5114 |
|
---|
5115 | case SVGA_3D_CMD_SETTEXTURESTATE:
|
---|
5116 | {
|
---|
5117 | SVGA3dCmdSetTextureState *pCmd = (SVGA3dCmdSetTextureState *)pvCmd;
|
---|
5118 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5119 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTextureState);
|
---|
5120 |
|
---|
5121 | uint32_t const cTextureStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dTextureState);
|
---|
5122 | vmsvga3dSetTextureState(pThisCC, pCmd->cid, cTextureStates, (SVGA3dTextureState *)(pCmd + 1));
|
---|
5123 | break;
|
---|
5124 | }
|
---|
5125 |
|
---|
5126 | case SVGA_3D_CMD_SETMATERIAL:
|
---|
5127 | {
|
---|
5128 | SVGA3dCmdSetMaterial *pCmd = (SVGA3dCmdSetMaterial *)pvCmd;
|
---|
5129 | VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd));
|
---|
5130 | STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetMaterial);
|
---|
5131 |
|
---|
5132 | vmsvga3dSetMaterial(pThisCC, pCmd->cid, pCmd->face, &pCmd->material);
|
---|
5133 | break;
|
---|
5134 | }
|
---|
5135 |
|
---|