1 | /* $Id: DevVGA-SVGA3d-dx.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevSVGA3d - VMWare SVGA device, 3D parts - Common code for DX backend interface.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2020-2022 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 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_DEV_VMSVGA
|
---|
33 | #include <VBox/AssertGuest.h>
|
---|
34 | #include <iprt/errcore.h>
|
---|
35 | #include <VBox/log.h>
|
---|
36 | #include <VBox/vmm/pdmdev.h>
|
---|
37 |
|
---|
38 | #include <iprt/assert.h>
|
---|
39 | #include <iprt/mem.h>
|
---|
40 |
|
---|
41 | #include <VBoxVideo.h> /* required by DevVGA.h */
|
---|
42 |
|
---|
43 | /* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
|
---|
44 | #include "DevVGA.h"
|
---|
45 |
|
---|
46 | #include "DevVGA-SVGA.h"
|
---|
47 | #include "DevVGA-SVGA3d.h"
|
---|
48 | #include "DevVGA-SVGA3d-internal.h"
|
---|
49 | #include "DevVGA-SVGA-internal.h"
|
---|
50 |
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Helpers.
|
---|
54 | */
|
---|
55 |
|
---|
56 | static int dxMobWrite(PVMSVGAR3STATE pSvgaR3State, SVGAMobId mobid, uint32_t off, void const *pvData, uint32_t cbData)
|
---|
57 | {
|
---|
58 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, mobid);
|
---|
59 | ASSERT_GUEST_RETURN(pMob, VERR_INVALID_STATE);
|
---|
60 |
|
---|
61 | return vmsvgaR3MobWrite(pSvgaR3State, pMob, off, pvData, cbData);
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /*
|
---|
66 | *
|
---|
67 | * Command handlers.
|
---|
68 | *
|
---|
69 | */
|
---|
70 |
|
---|
71 | int vmsvga3dDXUnbindContext(PVGASTATECC pThisCC, uint32_t cid, SVGADXContextMobFormat *pSvgaDXContext)
|
---|
72 | {
|
---|
73 | int rc;
|
---|
74 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
75 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindContext, VERR_INVALID_STATE);
|
---|
76 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
77 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
78 |
|
---|
79 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
80 | rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
|
---|
81 | AssertRCReturn(rc, rc);
|
---|
82 |
|
---|
83 | /* Copy the host structure back to the guest memory. */
|
---|
84 | memcpy(pSvgaDXContext, &pDXContext->svgaDXContext, sizeof(*pSvgaDXContext));
|
---|
85 |
|
---|
86 | return rc;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | int vmsvga3dDXSwitchContext(PVGASTATECC pThisCC, uint32_t cid)
|
---|
91 | {
|
---|
92 | int rc;
|
---|
93 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
94 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSwitchContext, VERR_INVALID_STATE);
|
---|
95 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
96 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
97 |
|
---|
98 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
99 | rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
|
---|
100 | AssertRCReturn(rc, rc);
|
---|
101 |
|
---|
102 | /* Notify the host backend that context is about to be switched. */
|
---|
103 | rc = pSvgaR3State->pFuncsDX->pfnDXSwitchContext(pThisCC, pDXContext);
|
---|
104 | if (rc == VINF_NOT_IMPLEMENTED || RT_FAILURE(rc))
|
---|
105 | return rc;
|
---|
106 |
|
---|
107 | /** @todo Keep track of changes in the pipeline and apply only modified state. */
|
---|
108 | /* It is not necessary to restore SVGADXContextMobFormat::shaderState::shaderResources
|
---|
109 | * because they are applied by the backend before each Draw call.
|
---|
110 | */
|
---|
111 | #define DX_STATE_VS 0x00000001
|
---|
112 | #define DX_STATE_PS 0x00000002
|
---|
113 | #define DX_STATE_SAMPLERS 0x00000004
|
---|
114 | #define DX_STATE_INPUTLAYOUT 0x00000008
|
---|
115 | #define DX_STATE_TOPOLOGY 0x00000010
|
---|
116 | #define DX_STATE_BLENDSTATE 0x00000080
|
---|
117 | #define DX_STATE_DEPTHSTENCILSTATE 0x00000100
|
---|
118 | #define DX_STATE_SOTARGETS 0x00000200
|
---|
119 | #define DX_STATE_VIEWPORTS 0x00000400
|
---|
120 | #define DX_STATE_SCISSORRECTS 0x00000800
|
---|
121 | #define DX_STATE_RASTERIZERSTATE 0x00001000
|
---|
122 | #define DX_STATE_RENDERTARGETS 0x00002000
|
---|
123 | #define DX_STATE_GS 0x00004000
|
---|
124 | uint32_t u32TrackedState = 0
|
---|
125 | | DX_STATE_VS
|
---|
126 | | DX_STATE_PS
|
---|
127 | | DX_STATE_SAMPLERS
|
---|
128 | | DX_STATE_INPUTLAYOUT
|
---|
129 | | DX_STATE_TOPOLOGY
|
---|
130 | | DX_STATE_BLENDSTATE
|
---|
131 | | DX_STATE_DEPTHSTENCILSTATE
|
---|
132 | | DX_STATE_SOTARGETS
|
---|
133 | | DX_STATE_VIEWPORTS
|
---|
134 | | DX_STATE_SCISSORRECTS
|
---|
135 | | DX_STATE_RASTERIZERSTATE
|
---|
136 | | DX_STATE_RENDERTARGETS
|
---|
137 | | DX_STATE_GS
|
---|
138 | ;
|
---|
139 |
|
---|
140 | LogFunc(("cid = %d, state = 0x%08X\n", cid, u32TrackedState));
|
---|
141 |
|
---|
142 | if (u32TrackedState & DX_STATE_VS)
|
---|
143 | {
|
---|
144 | u32TrackedState &= ~DX_STATE_VS;
|
---|
145 |
|
---|
146 | SVGA3dShaderType const shaderType = SVGA3D_SHADERTYPE_VS;
|
---|
147 |
|
---|
148 | uint32_t const idxShaderState = shaderType - SVGA3D_SHADERTYPE_MIN;
|
---|
149 | SVGA3dShaderId shaderId = pDXContext->svgaDXContext.shaderState[idxShaderState].shaderId;
|
---|
150 |
|
---|
151 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShader(pThisCC, pDXContext, shaderId, shaderType);
|
---|
152 | AssertRC(rc);
|
---|
153 | }
|
---|
154 |
|
---|
155 |
|
---|
156 | if (u32TrackedState & DX_STATE_PS)
|
---|
157 | {
|
---|
158 | u32TrackedState &= ~DX_STATE_PS;
|
---|
159 |
|
---|
160 | SVGA3dShaderType const shaderType = SVGA3D_SHADERTYPE_PS;
|
---|
161 |
|
---|
162 | uint32_t const idxShaderState = shaderType - SVGA3D_SHADERTYPE_MIN;
|
---|
163 | SVGA3dShaderId shaderId = pDXContext->svgaDXContext.shaderState[idxShaderState].shaderId;
|
---|
164 |
|
---|
165 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShader(pThisCC, pDXContext, shaderId, shaderType);
|
---|
166 | AssertRC(rc);
|
---|
167 | }
|
---|
168 |
|
---|
169 |
|
---|
170 | if (u32TrackedState & DX_STATE_GS)
|
---|
171 | {
|
---|
172 | u32TrackedState &= ~DX_STATE_GS;
|
---|
173 |
|
---|
174 | SVGA3dShaderType const shaderType = SVGA3D_SHADERTYPE_GS;
|
---|
175 |
|
---|
176 | uint32_t const idxShaderState = shaderType - SVGA3D_SHADERTYPE_MIN;
|
---|
177 | SVGA3dShaderId shaderId = pDXContext->svgaDXContext.shaderState[idxShaderState].shaderId;
|
---|
178 |
|
---|
179 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShader(pThisCC, pDXContext, shaderId, shaderType);
|
---|
180 | AssertRC(rc);
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | if (u32TrackedState & DX_STATE_SAMPLERS)
|
---|
185 | {
|
---|
186 | u32TrackedState &= ~DX_STATE_SAMPLERS;
|
---|
187 |
|
---|
188 | for (int i = SVGA3D_SHADERTYPE_MIN; i < SVGA3D_SHADERTYPE_MAX; ++i)
|
---|
189 | {
|
---|
190 | SVGA3dShaderType const shaderType = (SVGA3dShaderType)i;
|
---|
191 | uint32_t const idxShaderState = shaderType - SVGA3D_SHADERTYPE_MIN;
|
---|
192 |
|
---|
193 | uint32_t startSampler = 0;
|
---|
194 | uint32_t cSamplerId = SVGA3D_DX_MAX_SAMPLERS;
|
---|
195 | SVGA3dSamplerId *paSamplerId = &pDXContext->svgaDXContext.shaderState[idxShaderState].samplers[0];
|
---|
196 |
|
---|
197 | rc = pSvgaR3State->pFuncsDX->pfnDXSetSamplers(pThisCC, pDXContext, startSampler, shaderType, cSamplerId, paSamplerId);
|
---|
198 | AssertRC(rc);
|
---|
199 | }
|
---|
200 | }
|
---|
201 |
|
---|
202 |
|
---|
203 | if (u32TrackedState & DX_STATE_INPUTLAYOUT)
|
---|
204 | {
|
---|
205 | u32TrackedState &= ~DX_STATE_INPUTLAYOUT;
|
---|
206 |
|
---|
207 | SVGA3dElementLayoutId const elementLayoutId = pDXContext->svgaDXContext.inputAssembly.layoutId;
|
---|
208 |
|
---|
209 | rc = pSvgaR3State->pFuncsDX->pfnDXSetInputLayout(pThisCC, pDXContext, elementLayoutId);
|
---|
210 | AssertRC(rc);
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | if (u32TrackedState & DX_STATE_TOPOLOGY)
|
---|
215 | {
|
---|
216 | u32TrackedState &= ~DX_STATE_TOPOLOGY;
|
---|
217 |
|
---|
218 | SVGA3dPrimitiveType const topology = (SVGA3dPrimitiveType)pDXContext->svgaDXContext.inputAssembly.topology;
|
---|
219 |
|
---|
220 | if (topology != SVGA3D_PRIMITIVE_INVALID)
|
---|
221 | rc = pSvgaR3State->pFuncsDX->pfnDXSetTopology(pThisCC, pDXContext, topology);
|
---|
222 | AssertRC(rc);
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 | if (u32TrackedState & DX_STATE_BLENDSTATE)
|
---|
227 | {
|
---|
228 | u32TrackedState &= ~DX_STATE_BLENDSTATE;
|
---|
229 |
|
---|
230 | SVGA3dBlendStateId const blendId = pDXContext->svgaDXContext.renderState.blendStateId;
|
---|
231 | /* SVGADXContextMobFormat uses uint32_t array to store the blend factors, however they are in fact 32 bit floats. */
|
---|
232 | float const *paBlendFactor = (float *)&pDXContext->svgaDXContext.renderState.blendFactor[0];
|
---|
233 | uint32_t const sampleMask = pDXContext->svgaDXContext.renderState.sampleMask;
|
---|
234 |
|
---|
235 | rc = pSvgaR3State->pFuncsDX->pfnDXSetBlendState(pThisCC, pDXContext, blendId, paBlendFactor, sampleMask);
|
---|
236 | AssertRC(rc);
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 | if (u32TrackedState & DX_STATE_DEPTHSTENCILSTATE)
|
---|
241 | {
|
---|
242 | u32TrackedState &= ~DX_STATE_DEPTHSTENCILSTATE;
|
---|
243 |
|
---|
244 | SVGA3dDepthStencilStateId const depthStencilId = pDXContext->svgaDXContext.renderState.depthStencilStateId;
|
---|
245 | uint32_t const stencilRef = pDXContext->svgaDXContext.renderState.stencilRef;
|
---|
246 |
|
---|
247 | rc = pSvgaR3State->pFuncsDX->pfnDXSetDepthStencilState(pThisCC, pDXContext, depthStencilId, stencilRef);
|
---|
248 | AssertRC(rc);
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | if (u32TrackedState & DX_STATE_SOTARGETS)
|
---|
253 | {
|
---|
254 | u32TrackedState &= ~DX_STATE_SOTARGETS;
|
---|
255 |
|
---|
256 | uint32_t cSoTarget = SVGA3D_DX_MAX_SOTARGETS;
|
---|
257 | SVGA3dSoTarget aSoTarget[SVGA3D_DX_MAX_SOTARGETS];
|
---|
258 | for (uint32_t i = 0; i < SVGA3D_DX_MAX_SOTARGETS; ++i)
|
---|
259 | {
|
---|
260 | aSoTarget[i].sid = pDXContext->svgaDXContext.streamOut.targets[i];
|
---|
261 | /** @todo Offset is not stored in svgaDXContext. Should it be stored elsewhere by the host? */
|
---|
262 | aSoTarget[i].offset = 0;
|
---|
263 | aSoTarget[i].sizeInBytes = 0;
|
---|
264 | }
|
---|
265 |
|
---|
266 | rc = pSvgaR3State->pFuncsDX->pfnDXSetSOTargets(pThisCC, pDXContext, cSoTarget, aSoTarget);
|
---|
267 | AssertRC(rc);
|
---|
268 | }
|
---|
269 |
|
---|
270 |
|
---|
271 | if (u32TrackedState & DX_STATE_VIEWPORTS)
|
---|
272 | {
|
---|
273 | u32TrackedState &= ~DX_STATE_VIEWPORTS;
|
---|
274 |
|
---|
275 | uint32_t const cViewport = pDXContext->svgaDXContext.numViewports;
|
---|
276 | SVGA3dViewport const *paViewport = &pDXContext->svgaDXContext.viewports[0];
|
---|
277 |
|
---|
278 | rc = pSvgaR3State->pFuncsDX->pfnDXSetViewports(pThisCC, pDXContext, cViewport, paViewport);
|
---|
279 | AssertRC(rc);
|
---|
280 | }
|
---|
281 |
|
---|
282 |
|
---|
283 | if (u32TrackedState & DX_STATE_SCISSORRECTS)
|
---|
284 | {
|
---|
285 | u32TrackedState &= ~DX_STATE_SCISSORRECTS;
|
---|
286 |
|
---|
287 | uint32_t const cRect = pDXContext->svgaDXContext.numScissorRects;
|
---|
288 | SVGASignedRect const *paRect = &pDXContext->svgaDXContext.scissorRects[0];
|
---|
289 |
|
---|
290 | rc = pSvgaR3State->pFuncsDX->pfnDXSetScissorRects(pThisCC, pDXContext, cRect, paRect);
|
---|
291 | AssertRC(rc);
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | if (u32TrackedState & DX_STATE_RASTERIZERSTATE)
|
---|
296 | {
|
---|
297 | u32TrackedState &= ~DX_STATE_RASTERIZERSTATE;
|
---|
298 |
|
---|
299 | SVGA3dRasterizerStateId const rasterizerId = pDXContext->svgaDXContext.renderState.rasterizerStateId;
|
---|
300 |
|
---|
301 | rc = pSvgaR3State->pFuncsDX->pfnDXSetRasterizerState(pThisCC, pDXContext, rasterizerId);
|
---|
302 | AssertRC(rc);
|
---|
303 | }
|
---|
304 |
|
---|
305 |
|
---|
306 | if (u32TrackedState & DX_STATE_RENDERTARGETS)
|
---|
307 | {
|
---|
308 | u32TrackedState &= ~DX_STATE_RENDERTARGETS;
|
---|
309 |
|
---|
310 | SVGA3dDepthStencilViewId const depthStencilViewId = (SVGA3dDepthStencilViewId)pDXContext->svgaDXContext.renderState.depthStencilViewId;
|
---|
311 | uint32_t const cRenderTargetViewId = SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS;
|
---|
312 | SVGA3dRenderTargetViewId const *paRenderTargetViewId = (SVGA3dRenderTargetViewId *)&pDXContext->svgaDXContext.renderState.renderTargetViewIds[0];
|
---|
313 |
|
---|
314 | rc = pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets(pThisCC, pDXContext, depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId);
|
---|
315 | AssertRC(rc);
|
---|
316 | }
|
---|
317 |
|
---|
318 | Assert(u32TrackedState == 0);
|
---|
319 |
|
---|
320 | return rc;
|
---|
321 | }
|
---|
322 |
|
---|
323 |
|
---|
324 | /**
|
---|
325 | * Create a new 3D DX context.
|
---|
326 | *
|
---|
327 | * @returns VBox status code.
|
---|
328 | * @param pThisCC The VGA/VMSVGA state for ring-3.
|
---|
329 | * @param cid Context id to be created.
|
---|
330 | */
|
---|
331 | int vmsvga3dDXDefineContext(PVGASTATECC pThisCC, uint32_t cid)
|
---|
332 | {
|
---|
333 | int rc;
|
---|
334 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
335 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineContext, VERR_INVALID_STATE);
|
---|
336 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
337 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
338 |
|
---|
339 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
340 |
|
---|
341 | LogFunc(("cid %d\n", cid));
|
---|
342 |
|
---|
343 | AssertReturn(cid < SVGA3D_MAX_CONTEXT_IDS, VERR_INVALID_PARAMETER);
|
---|
344 |
|
---|
345 | if (cid >= p3dState->cDXContexts)
|
---|
346 | {
|
---|
347 | /* Grow the array. */
|
---|
348 | uint32_t cNew = RT_ALIGN(cid + 15, 16);
|
---|
349 | void *pvNew = RTMemRealloc(p3dState->papDXContexts, sizeof(p3dState->papDXContexts[0]) * cNew);
|
---|
350 | AssertReturn(pvNew, VERR_NO_MEMORY);
|
---|
351 | p3dState->papDXContexts = (PVMSVGA3DDXCONTEXT *)pvNew;
|
---|
352 | while (p3dState->cDXContexts < cNew)
|
---|
353 | {
|
---|
354 | pDXContext = (PVMSVGA3DDXCONTEXT)RTMemAllocZ(sizeof(*pDXContext));
|
---|
355 | AssertReturn(pDXContext, VERR_NO_MEMORY);
|
---|
356 | pDXContext->cid = SVGA3D_INVALID_ID;
|
---|
357 | p3dState->papDXContexts[p3dState->cDXContexts++] = pDXContext;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | /* If one already exists with this id, then destroy it now. */
|
---|
361 | if (p3dState->papDXContexts[cid]->cid != SVGA3D_INVALID_ID)
|
---|
362 | vmsvga3dDXDestroyContext(pThisCC, cid);
|
---|
363 |
|
---|
364 | pDXContext = p3dState->papDXContexts[cid];
|
---|
365 | memset(pDXContext, 0, sizeof(*pDXContext));
|
---|
366 |
|
---|
367 | /* 0xFFFFFFFF (SVGA_ID_INVALID) is a better initial value than 0 for most of svgaDXContext fields. */
|
---|
368 | memset(&pDXContext->svgaDXContext, 0xFF, sizeof(pDXContext->svgaDXContext));
|
---|
369 | pDXContext->svgaDXContext.inputAssembly.topology = SVGA3D_PRIMITIVE_INVALID;
|
---|
370 | pDXContext->svgaDXContext.numViewports = 0;
|
---|
371 | pDXContext->svgaDXContext.numScissorRects = 0;
|
---|
372 | pDXContext->cid = cid;
|
---|
373 |
|
---|
374 | /* Init the backend specific data. */
|
---|
375 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineContext(pThisCC, pDXContext);
|
---|
376 |
|
---|
377 | /* Cleanup on failure. */
|
---|
378 | if (RT_FAILURE(rc))
|
---|
379 | vmsvga3dDXDestroyContext(pThisCC, cid);
|
---|
380 |
|
---|
381 | return rc;
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | int vmsvga3dDXDestroyContext(PVGASTATECC pThisCC, uint32_t cid)
|
---|
386 | {
|
---|
387 | int rc;
|
---|
388 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
389 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyContext, VERR_INVALID_STATE);
|
---|
390 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
391 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
392 |
|
---|
393 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
394 | rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
|
---|
395 | AssertRCReturn(rc, rc);
|
---|
396 |
|
---|
397 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyContext(pThisCC, pDXContext);
|
---|
398 |
|
---|
399 | RT_ZERO(*pDXContext);
|
---|
400 | pDXContext->cid = SVGA3D_INVALID_ID;
|
---|
401 |
|
---|
402 | return rc;
|
---|
403 | }
|
---|
404 |
|
---|
405 |
|
---|
406 | int vmsvga3dDXBindContext(PVGASTATECC pThisCC, uint32_t cid, SVGADXContextMobFormat *pSvgaDXContext)
|
---|
407 | {
|
---|
408 | int rc;
|
---|
409 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
410 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindContext, VERR_INVALID_STATE);
|
---|
411 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
412 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
413 |
|
---|
414 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
415 | rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
|
---|
416 | AssertRCReturn(rc, rc);
|
---|
417 |
|
---|
418 | if (pSvgaDXContext)
|
---|
419 | memcpy(&pDXContext->svgaDXContext, pSvgaDXContext, sizeof(*pSvgaDXContext));
|
---|
420 |
|
---|
421 | rc = pSvgaR3State->pFuncsDX->pfnDXBindContext(pThisCC, pDXContext);
|
---|
422 | return rc;
|
---|
423 | }
|
---|
424 |
|
---|
425 |
|
---|
426 | int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGADXContextMobFormat *pSvgaDXContext)
|
---|
427 | {
|
---|
428 | int rc;
|
---|
429 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
430 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXReadbackContext, VERR_INVALID_STATE);
|
---|
431 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
432 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
433 |
|
---|
434 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
435 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
436 | AssertRCReturn(rc, rc);
|
---|
437 |
|
---|
438 | rc = pSvgaR3State->pFuncsDX->pfnDXReadbackContext(pThisCC, pDXContext);
|
---|
439 | if (RT_SUCCESS(rc))
|
---|
440 | memcpy(pSvgaDXContext, &pDXContext->svgaDXContext, sizeof(*pSvgaDXContext));
|
---|
441 | return rc;
|
---|
442 | }
|
---|
443 |
|
---|
444 |
|
---|
445 | int vmsvga3dDXInvalidateContext(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
446 | {
|
---|
447 | int rc;
|
---|
448 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
449 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXInvalidateContext, VERR_INVALID_STATE);
|
---|
450 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
451 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
452 |
|
---|
453 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
454 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
455 | AssertRCReturn(rc, rc);
|
---|
456 |
|
---|
457 | rc = pSvgaR3State->pFuncsDX->pfnDXInvalidateContext(pThisCC, pDXContext);
|
---|
458 | return rc;
|
---|
459 | }
|
---|
460 |
|
---|
461 |
|
---|
462 | int vmsvga3dDXSetSingleConstantBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSingleConstantBuffer const *pCmd)
|
---|
463 | {
|
---|
464 | int rc;
|
---|
465 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
466 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSingleConstantBuffer, VERR_INVALID_STATE);
|
---|
467 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
468 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
469 |
|
---|
470 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
471 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
472 | AssertRCReturn(rc, rc);
|
---|
473 |
|
---|
474 | ASSERT_GUEST_RETURN(pCmd->slot < SVGA3D_DX_MAX_CONSTBUFFERS, VERR_INVALID_PARAMETER);
|
---|
475 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
476 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
477 |
|
---|
478 | uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;
|
---|
479 | SVGA3dConstantBufferBinding *pCBB = &pDXContext->svgaDXContext.shaderState[idxShaderState].constantBuffers[pCmd->slot];
|
---|
480 | pCBB->sid = pCmd->sid;
|
---|
481 | pCBB->offsetInBytes = pCmd->offsetInBytes;
|
---|
482 | pCBB->sizeInBytes = pCmd->sizeInBytes;
|
---|
483 |
|
---|
484 | rc = pSvgaR3State->pFuncsDX->pfnDXSetSingleConstantBuffer(pThisCC, pDXContext, pCmd->slot, pCmd->type, pCmd->sid, pCmd->offsetInBytes, pCmd->sizeInBytes);
|
---|
485 | return rc;
|
---|
486 | }
|
---|
487 |
|
---|
488 |
|
---|
489 | int vmsvga3dDXSetShaderResources(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderResources const *pCmd, uint32_t cShaderResourceViewId, SVGA3dShaderResourceViewId const *paShaderResourceViewId)
|
---|
490 | {
|
---|
491 | int rc;
|
---|
492 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
493 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShaderResources, VERR_INVALID_STATE);
|
---|
494 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
495 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
496 |
|
---|
497 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
498 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
499 | AssertRCReturn(rc, rc);
|
---|
500 |
|
---|
501 | ASSERT_GUEST_RETURN(pCmd->startView < SVGA3D_DX_MAX_SRVIEWS, VERR_INVALID_PARAMETER);
|
---|
502 | ASSERT_GUEST_RETURN(cShaderResourceViewId <= SVGA3D_DX_MAX_SRVIEWS - pCmd->startView, VERR_INVALID_PARAMETER);
|
---|
503 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
504 | for (uint32_t i = 0; i < cShaderResourceViewId; ++i)
|
---|
505 | ASSERT_GUEST_RETURN( paShaderResourceViewId[i] < pDXContext->cot.cSRView
|
---|
506 | || paShaderResourceViewId[i] == SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER);
|
---|
507 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
508 |
|
---|
509 | uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;
|
---|
510 | for (uint32_t i = 0; i < cShaderResourceViewId; ++i)
|
---|
511 | {
|
---|
512 | SVGA3dShaderResourceViewId const shaderResourceViewId = paShaderResourceViewId[i];
|
---|
513 | pDXContext->svgaDXContext.shaderState[idxShaderState].shaderResources[pCmd->startView + i] = shaderResourceViewId;
|
---|
514 | }
|
---|
515 |
|
---|
516 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShaderResources(pThisCC, pDXContext, pCmd->startView, pCmd->type, cShaderResourceViewId, paShaderResourceViewId);
|
---|
517 | return rc;
|
---|
518 | }
|
---|
519 |
|
---|
520 |
|
---|
521 | int vmsvga3dDXSetShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShader const *pCmd)
|
---|
522 | {
|
---|
523 | int rc;
|
---|
524 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
525 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShader, VERR_INVALID_STATE);
|
---|
526 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
527 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
528 |
|
---|
529 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
530 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
531 | AssertRCReturn(rc, rc);
|
---|
532 |
|
---|
533 | ASSERT_GUEST_RETURN( pCmd->shaderId < pDXContext->cot.cShader
|
---|
534 | || pCmd->shaderId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
|
---|
535 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
536 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
537 |
|
---|
538 | uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;
|
---|
539 | pDXContext->svgaDXContext.shaderState[idxShaderState].shaderId = pCmd->shaderId;
|
---|
540 |
|
---|
541 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShader(pThisCC, pDXContext, pCmd->shaderId, pCmd->type);
|
---|
542 | return rc;
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | int vmsvga3dDXSetSamplers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSamplers const *pCmd, uint32_t cSamplerId, SVGA3dSamplerId const *paSamplerId)
|
---|
547 | {
|
---|
548 | int rc;
|
---|
549 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
550 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSamplers, VERR_INVALID_STATE);
|
---|
551 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
552 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
553 |
|
---|
554 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
555 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
556 | AssertRCReturn(rc, rc);
|
---|
557 |
|
---|
558 | ASSERT_GUEST_RETURN(pCmd->startSampler < SVGA3D_DX_MAX_SAMPLERS, VERR_INVALID_PARAMETER);
|
---|
559 | ASSERT_GUEST_RETURN(cSamplerId <= SVGA3D_DX_MAX_SAMPLERS - pCmd->startSampler, VERR_INVALID_PARAMETER);
|
---|
560 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
561 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
562 |
|
---|
563 | uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;
|
---|
564 | for (uint32_t i = 0; i < cSamplerId; ++i)
|
---|
565 | {
|
---|
566 | SVGA3dSamplerId const samplerId = paSamplerId[i];
|
---|
567 | ASSERT_GUEST_RETURN( samplerId < pDXContext->cot.cSampler
|
---|
568 | || samplerId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
|
---|
569 | pDXContext->svgaDXContext.shaderState[idxShaderState].samplers[pCmd->startSampler + i] = samplerId;
|
---|
570 | }
|
---|
571 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
572 |
|
---|
573 | rc = pSvgaR3State->pFuncsDX->pfnDXSetSamplers(pThisCC, pDXContext, pCmd->startSampler, pCmd->type, cSamplerId, paSamplerId);
|
---|
574 | return rc;
|
---|
575 | }
|
---|
576 |
|
---|
577 |
|
---|
578 | #ifdef DUMP_BITMAPS
|
---|
579 | static void vmsvga3dDXDrawDumpRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
|
---|
580 | {
|
---|
581 | for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)
|
---|
582 | {
|
---|
583 | if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] != SVGA3D_INVALID_ID)
|
---|
584 | {
|
---|
585 | SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[i]];
|
---|
586 | Log(("Dump RT[%u] sid = %u rtvid = %u\n", i, pRTViewEntry->sid, pDXContext->svgaDXContext.renderState.renderTargetViewIds[i]));
|
---|
587 |
|
---|
588 | SVGA3dSurfaceImageId image;
|
---|
589 | image.sid = pRTViewEntry->sid;
|
---|
590 | image.face = 0;
|
---|
591 | image.mipmap = 0;
|
---|
592 | VMSVGA3D_MAPPED_SURFACE map;
|
---|
593 | int rc = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
|
---|
594 | if (RT_SUCCESS(rc))
|
---|
595 | {
|
---|
596 | vmsvga3dMapWriteBmpFile(&map, "rt-");
|
---|
597 | vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
|
---|
598 | }
|
---|
599 | else
|
---|
600 | Log(("Map failed %Rrc\n", rc));
|
---|
601 | }
|
---|
602 | }
|
---|
603 | }
|
---|
604 | #endif
|
---|
605 |
|
---|
606 | int vmsvga3dDXDraw(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDraw const *pCmd)
|
---|
607 | {
|
---|
608 | int rc;
|
---|
609 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
610 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDraw, VERR_INVALID_STATE);
|
---|
611 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
612 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
613 |
|
---|
614 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
615 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
616 | AssertRCReturn(rc, rc);
|
---|
617 |
|
---|
618 | rc = pSvgaR3State->pFuncsDX->pfnDXDraw(pThisCC, pDXContext, pCmd->vertexCount, pCmd->startVertexLocation);
|
---|
619 | #ifdef DUMP_BITMAPS
|
---|
620 | vmsvga3dDXDrawDumpRenderTargets(pThisCC, pDXContext);
|
---|
621 | #endif
|
---|
622 | return rc;
|
---|
623 | }
|
---|
624 |
|
---|
625 |
|
---|
626 | int vmsvga3dDXDrawIndexed(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexed const *pCmd)
|
---|
627 | {
|
---|
628 | int rc;
|
---|
629 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
630 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexed, VERR_INVALID_STATE);
|
---|
631 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
632 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
633 |
|
---|
634 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
635 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
636 | AssertRCReturn(rc, rc);
|
---|
637 |
|
---|
638 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexed(pThisCC, pDXContext, pCmd->indexCount, pCmd->startIndexLocation, pCmd->baseVertexLocation);
|
---|
639 | #ifdef DUMP_BITMAPS
|
---|
640 | vmsvga3dDXDrawDumpRenderTargets(pThisCC, pDXContext);
|
---|
641 | #endif
|
---|
642 | return rc;
|
---|
643 | }
|
---|
644 |
|
---|
645 |
|
---|
646 | int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd)
|
---|
647 | {
|
---|
648 | int rc;
|
---|
649 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
650 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawInstanced, VERR_INVALID_STATE);
|
---|
651 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
652 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
653 |
|
---|
654 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
655 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
656 | AssertRCReturn(rc, rc);
|
---|
657 |
|
---|
658 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstanced(pThisCC, pDXContext,
|
---|
659 | pCmd->vertexCountPerInstance, pCmd->instanceCount, pCmd->startVertexLocation, pCmd->startInstanceLocation);
|
---|
660 | #ifdef DUMP_BITMAPS
|
---|
661 | vmsvga3dDXDrawDumpRenderTargets(pThisCC, pDXContext);
|
---|
662 | #endif
|
---|
663 | return rc;
|
---|
664 | }
|
---|
665 |
|
---|
666 |
|
---|
667 | int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd)
|
---|
668 | {
|
---|
669 | int rc;
|
---|
670 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
671 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced, VERR_INVALID_STATE);
|
---|
672 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
673 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
674 |
|
---|
675 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
676 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
677 | AssertRCReturn(rc, rc);
|
---|
678 |
|
---|
679 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced(pThisCC, pDXContext,
|
---|
680 | pCmd->indexCountPerInstance, pCmd->instanceCount, pCmd->startIndexLocation, pCmd->baseVertexLocation, pCmd->startInstanceLocation);
|
---|
681 | #ifdef DUMP_BITMAPS
|
---|
682 | vmsvga3dDXDrawDumpRenderTargets(pThisCC, pDXContext);
|
---|
683 | #endif
|
---|
684 | return rc;
|
---|
685 | }
|
---|
686 |
|
---|
687 |
|
---|
688 | int vmsvga3dDXDrawAuto(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
689 | {
|
---|
690 | int rc;
|
---|
691 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
692 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawAuto, VERR_INVALID_STATE);
|
---|
693 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
694 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
695 |
|
---|
696 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
697 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
698 | AssertRCReturn(rc, rc);
|
---|
699 |
|
---|
700 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawAuto(pThisCC, pDXContext);
|
---|
701 | #ifdef DUMP_BITMAPS
|
---|
702 | vmsvga3dDXDrawDumpRenderTargets(pThisCC, pDXContext);
|
---|
703 | #endif
|
---|
704 | return rc;
|
---|
705 | }
|
---|
706 |
|
---|
707 |
|
---|
708 | int vmsvga3dDXSetInputLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dElementLayoutId elementLayoutId)
|
---|
709 | {
|
---|
710 | int rc;
|
---|
711 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
712 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetInputLayout, VERR_INVALID_STATE);
|
---|
713 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
714 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
715 |
|
---|
716 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
717 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
718 | AssertRCReturn(rc, rc);
|
---|
719 |
|
---|
720 | ASSERT_GUEST_RETURN( elementLayoutId == SVGA3D_INVALID_ID
|
---|
721 | || elementLayoutId < pDXContext->cot.cElementLayout, VERR_INVALID_PARAMETER);
|
---|
722 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
723 |
|
---|
724 | pDXContext->svgaDXContext.inputAssembly.layoutId = elementLayoutId;
|
---|
725 |
|
---|
726 | rc = pSvgaR3State->pFuncsDX->pfnDXSetInputLayout(pThisCC, pDXContext, elementLayoutId);
|
---|
727 | return rc;
|
---|
728 | }
|
---|
729 |
|
---|
730 |
|
---|
731 | int vmsvga3dDXSetVertexBuffers(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t startBuffer, uint32_t cVertexBuffer, SVGA3dVertexBuffer const *paVertexBuffer)
|
---|
732 | {
|
---|
733 | int rc;
|
---|
734 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
735 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetVertexBuffers, VERR_INVALID_STATE);
|
---|
736 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
737 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
738 |
|
---|
739 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
740 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
741 | AssertRCReturn(rc, rc);
|
---|
742 |
|
---|
743 | ASSERT_GUEST_RETURN(startBuffer < SVGA3D_DX_MAX_VERTEXBUFFERS, VERR_INVALID_PARAMETER);
|
---|
744 | ASSERT_GUEST_RETURN(cVertexBuffer <= SVGA3D_DX_MAX_VERTEXBUFFERS - startBuffer, VERR_INVALID_PARAMETER);
|
---|
745 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
746 |
|
---|
747 | for (uint32_t i = 0; i < cVertexBuffer; ++i)
|
---|
748 | {
|
---|
749 | uint32_t const idxVertexBuffer = startBuffer + i;
|
---|
750 |
|
---|
751 | pDXContext->svgaDXContext.inputAssembly.vertexBuffers[idxVertexBuffer].bufferId = paVertexBuffer[i].sid;
|
---|
752 | pDXContext->svgaDXContext.inputAssembly.vertexBuffers[idxVertexBuffer].stride = paVertexBuffer[i].stride;
|
---|
753 | pDXContext->svgaDXContext.inputAssembly.vertexBuffers[idxVertexBuffer].offset = paVertexBuffer[i].offset;
|
---|
754 | }
|
---|
755 |
|
---|
756 | rc = pSvgaR3State->pFuncsDX->pfnDXSetVertexBuffers(pThisCC, pDXContext, startBuffer, cVertexBuffer, paVertexBuffer);
|
---|
757 | return rc;
|
---|
758 | }
|
---|
759 |
|
---|
760 |
|
---|
761 | int vmsvga3dDXSetIndexBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetIndexBuffer const *pCmd)
|
---|
762 | {
|
---|
763 | int rc;
|
---|
764 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
765 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetIndexBuffer, VERR_INVALID_STATE);
|
---|
766 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
767 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
768 |
|
---|
769 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
770 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
771 | AssertRCReturn(rc, rc);
|
---|
772 |
|
---|
773 | pDXContext->svgaDXContext.inputAssembly.indexBufferSid = pCmd->sid;
|
---|
774 | pDXContext->svgaDXContext.inputAssembly.indexBufferOffset = pCmd->offset;
|
---|
775 | pDXContext->svgaDXContext.inputAssembly.indexBufferFormat = pCmd->format;
|
---|
776 |
|
---|
777 | rc = pSvgaR3State->pFuncsDX->pfnDXSetIndexBuffer(pThisCC, pDXContext, pCmd->sid, pCmd->format, pCmd->offset);
|
---|
778 | return rc;
|
---|
779 | }
|
---|
780 |
|
---|
781 |
|
---|
782 | int vmsvga3dDXSetTopology(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dPrimitiveType topology)
|
---|
783 | {
|
---|
784 | int rc;
|
---|
785 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
786 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetTopology, VERR_INVALID_STATE);
|
---|
787 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
788 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
789 |
|
---|
790 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
791 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
792 | AssertRCReturn(rc, rc);
|
---|
793 |
|
---|
794 | ASSERT_GUEST_RETURN(topology >= SVGA3D_PRIMITIVE_MIN && topology < SVGA3D_PRIMITIVE_MAX, VERR_INVALID_PARAMETER);
|
---|
795 |
|
---|
796 | pDXContext->svgaDXContext.inputAssembly.topology = topology;
|
---|
797 |
|
---|
798 | rc = pSvgaR3State->pFuncsDX->pfnDXSetTopology(pThisCC, pDXContext, topology);
|
---|
799 | return rc;
|
---|
800 | }
|
---|
801 |
|
---|
802 |
|
---|
803 | int vmsvga3dDXSetRenderTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dDepthStencilViewId depthStencilViewId, uint32_t cRenderTargetViewId, SVGA3dRenderTargetViewId const *paRenderTargetViewId)
|
---|
804 | {
|
---|
805 | int rc;
|
---|
806 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
807 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets, VERR_INVALID_STATE);
|
---|
808 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
809 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
810 |
|
---|
811 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
812 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
813 | AssertRCReturn(rc, rc);
|
---|
814 |
|
---|
815 | ASSERT_GUEST_RETURN( depthStencilViewId < pDXContext->cot.cDSView
|
---|
816 | || depthStencilViewId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
|
---|
817 | ASSERT_GUEST_RETURN(cRenderTargetViewId <= SVGA3D_MAX_RENDER_TARGETS, VERR_INVALID_PARAMETER);
|
---|
818 | for (uint32_t i = 0; i < cRenderTargetViewId; ++i)
|
---|
819 | ASSERT_GUEST_RETURN( paRenderTargetViewId[i] < pDXContext->cot.cRTView
|
---|
820 | || paRenderTargetViewId[i] == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
|
---|
821 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
822 |
|
---|
823 | pDXContext->svgaDXContext.renderState.depthStencilViewId = depthStencilViewId;
|
---|
824 | for (uint32_t i = 0; i < cRenderTargetViewId; ++i)
|
---|
825 | pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = paRenderTargetViewId[i];
|
---|
826 |
|
---|
827 | /* Remember how many render target slots must be set. */
|
---|
828 | pDXContext->cRenderTargets = RT_MAX(pDXContext->cRenderTargets, cRenderTargetViewId);
|
---|
829 |
|
---|
830 | rc = pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets(pThisCC, pDXContext, depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId);
|
---|
831 | return rc;
|
---|
832 | }
|
---|
833 |
|
---|
834 |
|
---|
835 | int vmsvga3dDXSetBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetBlendState const *pCmd)
|
---|
836 | {
|
---|
837 | int rc;
|
---|
838 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
839 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetBlendState, VERR_INVALID_STATE);
|
---|
840 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
841 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
842 |
|
---|
843 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
844 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
845 | AssertRCReturn(rc, rc);
|
---|
846 |
|
---|
847 | SVGA3dBlendStateId const blendId = pCmd->blendId;
|
---|
848 |
|
---|
849 | ASSERT_GUEST_RETURN( blendId == SVGA3D_INVALID_ID
|
---|
850 | || blendId < pDXContext->cot.cBlendState, VERR_INVALID_PARAMETER);
|
---|
851 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
852 |
|
---|
853 | pDXContext->svgaDXContext.renderState.blendStateId = blendId;
|
---|
854 | /* SVGADXContextMobFormat uses uint32_t array to store the blend factors, however they are in fact 32 bit floats. */
|
---|
855 | memcpy(pDXContext->svgaDXContext.renderState.blendFactor, pCmd->blendFactor, sizeof(pDXContext->svgaDXContext.renderState.blendFactor));
|
---|
856 | pDXContext->svgaDXContext.renderState.sampleMask = pCmd->sampleMask;
|
---|
857 |
|
---|
858 | rc = pSvgaR3State->pFuncsDX->pfnDXSetBlendState(pThisCC, pDXContext, blendId, pCmd->blendFactor, pCmd->sampleMask);
|
---|
859 | return rc;
|
---|
860 | }
|
---|
861 |
|
---|
862 |
|
---|
863 | int vmsvga3dDXSetDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDepthStencilState const *pCmd)
|
---|
864 | {
|
---|
865 | int rc;
|
---|
866 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
867 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetDepthStencilState, VERR_INVALID_STATE);
|
---|
868 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
869 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
870 |
|
---|
871 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
872 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
873 | AssertRCReturn(rc, rc);
|
---|
874 |
|
---|
875 | SVGA3dDepthStencilStateId const depthStencilId = pCmd->depthStencilId;
|
---|
876 |
|
---|
877 | ASSERT_GUEST_RETURN( depthStencilId == SVGA3D_INVALID_ID
|
---|
878 | || depthStencilId < pDXContext->cot.cDepthStencil, VERR_INVALID_PARAMETER);
|
---|
879 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
880 |
|
---|
881 | pDXContext->svgaDXContext.renderState.depthStencilStateId = depthStencilId;
|
---|
882 | pDXContext->svgaDXContext.renderState.stencilRef = pCmd->stencilRef;
|
---|
883 |
|
---|
884 | rc = pSvgaR3State->pFuncsDX->pfnDXSetDepthStencilState(pThisCC, pDXContext, depthStencilId, pCmd->stencilRef);
|
---|
885 | return rc;
|
---|
886 | }
|
---|
887 |
|
---|
888 |
|
---|
889 | int vmsvga3dDXSetRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dRasterizerStateId rasterizerId)
|
---|
890 | {
|
---|
891 | int rc;
|
---|
892 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
893 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetRasterizerState, VERR_INVALID_STATE);
|
---|
894 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
895 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
896 |
|
---|
897 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
898 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
899 | AssertRCReturn(rc, rc);
|
---|
900 |
|
---|
901 | ASSERT_GUEST_RETURN( rasterizerId == SVGA3D_INVALID_ID
|
---|
902 | || rasterizerId < pDXContext->cot.cRasterizerState, VERR_INVALID_PARAMETER);
|
---|
903 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
904 |
|
---|
905 | pDXContext->svgaDXContext.renderState.rasterizerStateId = rasterizerId;
|
---|
906 |
|
---|
907 | rc = pSvgaR3State->pFuncsDX->pfnDXSetRasterizerState(pThisCC, pDXContext, rasterizerId);
|
---|
908 | return rc;
|
---|
909 | }
|
---|
910 |
|
---|
911 |
|
---|
912 | int vmsvga3dDXDefineQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineQuery const *pCmd)
|
---|
913 | {
|
---|
914 | int rc;
|
---|
915 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
916 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineQuery, VERR_INVALID_STATE);
|
---|
917 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
918 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
919 |
|
---|
920 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
921 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
922 | AssertRCReturn(rc, rc);
|
---|
923 |
|
---|
924 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
925 |
|
---|
926 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
927 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
928 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_QUERYTYPE_MIN && pCmd->type < SVGA3D_QUERYTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
929 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
930 |
|
---|
931 | /* Cleanup the current query. */
|
---|
932 | pSvgaR3State->pFuncsDX->pfnDXDestroyQuery(pThisCC, pDXContext, queryId);
|
---|
933 |
|
---|
934 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
935 | pEntry->type = pCmd->type;
|
---|
936 | pEntry->state = SVGADX_QDSTATE_IDLE;
|
---|
937 | pEntry->flags = pCmd->flags;
|
---|
938 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
939 | pEntry->offset = 0;
|
---|
940 |
|
---|
941 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineQuery(pThisCC, pDXContext, queryId, pEntry);
|
---|
942 | return rc;
|
---|
943 | }
|
---|
944 |
|
---|
945 |
|
---|
946 | int vmsvga3dDXDestroyQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyQuery const *pCmd)
|
---|
947 | {
|
---|
948 | int rc;
|
---|
949 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
950 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyQuery, VERR_INVALID_STATE);
|
---|
951 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
952 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
953 |
|
---|
954 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
955 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
956 | AssertRCReturn(rc, rc);
|
---|
957 |
|
---|
958 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
959 |
|
---|
960 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
961 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
962 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
963 |
|
---|
964 | pSvgaR3State->pFuncsDX->pfnDXDestroyQuery(pThisCC, pDXContext, queryId);
|
---|
965 |
|
---|
966 | /* Cleanup COTable entry.*/
|
---|
967 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
968 | pEntry->type = SVGA3D_QUERYTYPE_INVALID;
|
---|
969 | pEntry->state = SVGADX_QDSTATE_INVALID;
|
---|
970 | pEntry->flags = 0;
|
---|
971 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
972 | pEntry->offset = 0;
|
---|
973 |
|
---|
974 | return rc;
|
---|
975 | }
|
---|
976 |
|
---|
977 |
|
---|
978 | int vmsvga3dDXBindQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindQuery const *pCmd, PVMSVGAMOB pMob)
|
---|
979 | {
|
---|
980 | int rc;
|
---|
981 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
982 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
983 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
984 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
985 |
|
---|
986 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
987 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
988 | AssertRCReturn(rc, rc);
|
---|
989 |
|
---|
990 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
991 |
|
---|
992 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
993 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
994 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
995 |
|
---|
996 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
997 | pEntry->mobid = vmsvgaR3MobId(pMob);
|
---|
998 |
|
---|
999 | return rc;
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 |
|
---|
1003 | int vmsvga3dDXSetQueryOffset(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetQueryOffset const *pCmd)
|
---|
1004 | {
|
---|
1005 | int rc;
|
---|
1006 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1007 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
1008 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1009 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1010 |
|
---|
1011 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1012 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1013 | AssertRCReturn(rc, rc);
|
---|
1014 |
|
---|
1015 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
1016 |
|
---|
1017 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
1018 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
1019 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1020 |
|
---|
1021 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
1022 | pEntry->offset = pCmd->mobOffset;
|
---|
1023 |
|
---|
1024 | return rc;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 |
|
---|
1028 | int vmsvga3dDXBeginQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBeginQuery const *pCmd)
|
---|
1029 | {
|
---|
1030 | int rc;
|
---|
1031 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1032 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBeginQuery, VERR_INVALID_STATE);
|
---|
1033 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1034 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1035 |
|
---|
1036 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1037 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1038 | AssertRCReturn(rc, rc);
|
---|
1039 |
|
---|
1040 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
1041 |
|
---|
1042 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
1043 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
1044 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1045 |
|
---|
1046 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
1047 | Assert(pEntry->state == SVGADX_QDSTATE_IDLE || pEntry->state == SVGADX_QDSTATE_PENDING || pEntry->state == SVGADX_QDSTATE_FINISHED);
|
---|
1048 | if (pEntry->state != SVGADX_QDSTATE_ACTIVE)
|
---|
1049 | {
|
---|
1050 | rc = pSvgaR3State->pFuncsDX->pfnDXBeginQuery(pThisCC, pDXContext, queryId);
|
---|
1051 | if (RT_SUCCESS(rc))
|
---|
1052 | {
|
---|
1053 | pEntry->state = SVGADX_QDSTATE_ACTIVE;
|
---|
1054 |
|
---|
1055 | /* Update the guest status of the query. */
|
---|
1056 | uint32_t const u32 = SVGA3D_QUERYSTATE_PENDING;
|
---|
1057 | dxMobWrite(pSvgaR3State, pEntry->mobid, pEntry->offset, &u32, sizeof(u32));
|
---|
1058 | }
|
---|
1059 | else
|
---|
1060 | {
|
---|
1061 | uint32_t const u32 = SVGA3D_QUERYSTATE_FAILED;
|
---|
1062 | dxMobWrite(pSvgaR3State, pEntry->mobid, pEntry->offset, &u32, sizeof(u32));
|
---|
1063 | }
|
---|
1064 | }
|
---|
1065 | return rc;
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | static int dxEndQuery(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dQueryId queryId, SVGACOTableDXQueryEntry *pEntry)
|
---|
1070 | {
|
---|
1071 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1072 |
|
---|
1073 | int rc;
|
---|
1074 | Assert(pEntry->state == SVGADX_QDSTATE_ACTIVE);
|
---|
1075 | if (pEntry->state == SVGADX_QDSTATE_ACTIVE)
|
---|
1076 | {
|
---|
1077 | pEntry->state = SVGADX_QDSTATE_PENDING;
|
---|
1078 |
|
---|
1079 | uint32_t u32QueryState;
|
---|
1080 | SVGADXQueryResultUnion queryResult;
|
---|
1081 | uint32_t cbQuery = 0; /* Actual size of query data returned by backend. */
|
---|
1082 | rc = pSvgaR3State->pFuncsDX->pfnDXEndQuery(pThisCC, pDXContext, queryId, &queryResult, &cbQuery);
|
---|
1083 | if (RT_SUCCESS(rc))
|
---|
1084 | {
|
---|
1085 | /* Write the result after SVGA3dQueryState. */
|
---|
1086 | dxMobWrite(pSvgaR3State, pEntry->mobid, pEntry->offset + sizeof(uint32_t), &queryResult, cbQuery);
|
---|
1087 |
|
---|
1088 | u32QueryState = SVGA3D_QUERYSTATE_SUCCEEDED;
|
---|
1089 | }
|
---|
1090 | else
|
---|
1091 | u32QueryState = SVGA3D_QUERYSTATE_FAILED;
|
---|
1092 |
|
---|
1093 | dxMobWrite(pSvgaR3State, pEntry->mobid, pEntry->offset, &u32QueryState, sizeof(u32QueryState));
|
---|
1094 |
|
---|
1095 | if (RT_SUCCESS(rc))
|
---|
1096 | pEntry->state = SVGADX_QDSTATE_FINISHED;
|
---|
1097 | }
|
---|
1098 | else
|
---|
1099 | rc = VERR_INVALID_STATE;
|
---|
1100 |
|
---|
1101 | return rc;
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 |
|
---|
1105 | int vmsvga3dDXEndQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXEndQuery const *pCmd)
|
---|
1106 | {
|
---|
1107 | int rc;
|
---|
1108 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1109 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXEndQuery, VERR_INVALID_STATE);
|
---|
1110 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1111 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1112 |
|
---|
1113 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1114 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1115 | AssertRCReturn(rc, rc);
|
---|
1116 |
|
---|
1117 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
1118 |
|
---|
1119 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
1120 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
1121 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1122 |
|
---|
1123 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[queryId];
|
---|
1124 | rc = dxEndQuery(pThisCC, pDXContext, queryId, pEntry);
|
---|
1125 | return rc;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 |
|
---|
1129 | int vmsvga3dDXReadbackQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackQuery const *pCmd)
|
---|
1130 | {
|
---|
1131 | int rc;
|
---|
1132 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1133 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
1134 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1135 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1136 |
|
---|
1137 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1138 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1139 | AssertRCReturn(rc, rc);
|
---|
1140 |
|
---|
1141 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
1142 |
|
---|
1143 | ASSERT_GUEST_RETURN(pDXContext->cot.paQuery, VERR_INVALID_STATE);
|
---|
1144 | ASSERT_GUEST_RETURN(queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
1145 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1146 |
|
---|
1147 | /* The device does not cache queries. So this is a NOP. */
|
---|
1148 |
|
---|
1149 | return rc;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 |
|
---|
1153 | int vmsvga3dDXSetPredication(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetPredication const *pCmd)
|
---|
1154 | {
|
---|
1155 | int rc;
|
---|
1156 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1157 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetPredication, VERR_INVALID_STATE);
|
---|
1158 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1159 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1160 |
|
---|
1161 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1162 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1163 | AssertRCReturn(rc, rc);
|
---|
1164 |
|
---|
1165 | SVGA3dQueryId const queryId = pCmd->queryId;
|
---|
1166 |
|
---|
1167 | ASSERT_GUEST_RETURN( queryId == SVGA3D_INVALID_ID
|
---|
1168 | || queryId < pDXContext->cot.cQuery, VERR_INVALID_PARAMETER);
|
---|
1169 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1170 |
|
---|
1171 | rc = pSvgaR3State->pFuncsDX->pfnDXSetPredication(pThisCC, pDXContext, queryId, pCmd->predicateValue);
|
---|
1172 | return rc;
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 |
|
---|
1176 | int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget)
|
---|
1177 | {
|
---|
1178 | int rc;
|
---|
1179 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1180 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSOTargets, VERR_INVALID_STATE);
|
---|
1181 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1182 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1183 |
|
---|
1184 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1185 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1186 | AssertRCReturn(rc, rc);
|
---|
1187 |
|
---|
1188 | ASSERT_GUEST_RETURN(cSoTarget <= SVGA3D_DX_MAX_SOTARGETS, VERR_INVALID_PARAMETER);
|
---|
1189 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1190 |
|
---|
1191 | /** @todo Offset is not stored in svgaDXContext. Should it be stored elsewhere? */
|
---|
1192 | for (uint32_t i = 0; i < SVGA3D_DX_MAX_SOTARGETS; ++i)
|
---|
1193 | pDXContext->svgaDXContext.streamOut.targets[i] = i < cSoTarget ? paSoTarget[i].sid : SVGA3D_INVALID_ID;
|
---|
1194 |
|
---|
1195 | rc = pSvgaR3State->pFuncsDX->pfnDXSetSOTargets(pThisCC, pDXContext, cSoTarget, paSoTarget);
|
---|
1196 | return rc;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | int vmsvga3dDXSetViewports(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cViewport, SVGA3dViewport const *paViewport)
|
---|
1201 | {
|
---|
1202 | int rc;
|
---|
1203 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1204 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetViewports, VERR_INVALID_STATE);
|
---|
1205 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1206 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1207 |
|
---|
1208 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1209 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1210 | AssertRCReturn(rc, rc);
|
---|
1211 |
|
---|
1212 | ASSERT_GUEST_RETURN(cViewport <= SVGA3D_DX_MAX_VIEWPORTS, VERR_INVALID_PARAMETER);
|
---|
1213 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1214 |
|
---|
1215 | pDXContext->svgaDXContext.numViewports = (uint8_t)cViewport;
|
---|
1216 | for (uint32_t i = 0; i < cViewport; ++i)
|
---|
1217 | pDXContext->svgaDXContext.viewports[i] = paViewport[i];
|
---|
1218 |
|
---|
1219 | rc = pSvgaR3State->pFuncsDX->pfnDXSetViewports(pThisCC, pDXContext, cViewport, paViewport);
|
---|
1220 | return rc;
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | int vmsvga3dDXSetScissorRects(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cRect, SVGASignedRect const *paRect)
|
---|
1225 | {
|
---|
1226 | int rc;
|
---|
1227 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1228 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetScissorRects, VERR_INVALID_STATE);
|
---|
1229 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1230 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1231 |
|
---|
1232 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1233 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1234 | AssertRCReturn(rc, rc);
|
---|
1235 |
|
---|
1236 | ASSERT_GUEST_RETURN(cRect <= SVGA3D_DX_MAX_SCISSORRECTS, VERR_INVALID_PARAMETER);
|
---|
1237 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1238 |
|
---|
1239 | pDXContext->svgaDXContext.numScissorRects = (uint8_t)cRect;
|
---|
1240 | for (uint32_t i = 0; i < cRect; ++i)
|
---|
1241 | pDXContext->svgaDXContext.scissorRects[i] = paRect[i];
|
---|
1242 |
|
---|
1243 | rc = pSvgaR3State->pFuncsDX->pfnDXSetScissorRects(pThisCC, pDXContext, cRect, paRect);
|
---|
1244 | return rc;
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | int vmsvga3dDXClearRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearRenderTargetView const *pCmd)
|
---|
1249 | {
|
---|
1250 | int rc;
|
---|
1251 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1252 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearRenderTargetView, VERR_INVALID_STATE);
|
---|
1253 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1254 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1255 |
|
---|
1256 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1257 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1258 | AssertRCReturn(rc, rc);
|
---|
1259 |
|
---|
1260 | SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
|
---|
1261 |
|
---|
1262 | ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
|
---|
1263 | ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
|
---|
1264 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1265 |
|
---|
1266 | rc = pSvgaR3State->pFuncsDX->pfnDXClearRenderTargetView(pThisCC, pDXContext, renderTargetViewId, &pCmd->rgba);
|
---|
1267 | return rc;
|
---|
1268 | }
|
---|
1269 |
|
---|
1270 |
|
---|
1271 | int vmsvga3dDXClearDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearDepthStencilView const *pCmd)
|
---|
1272 | {
|
---|
1273 | int rc;
|
---|
1274 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1275 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearDepthStencilView, VERR_INVALID_STATE);
|
---|
1276 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1277 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1278 |
|
---|
1279 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1280 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1281 | AssertRCReturn(rc, rc);
|
---|
1282 |
|
---|
1283 | SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
|
---|
1284 |
|
---|
1285 | ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
|
---|
1286 | ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
|
---|
1287 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1288 |
|
---|
1289 | rc = pSvgaR3State->pFuncsDX->pfnDXClearDepthStencilView(pThisCC, pDXContext, pCmd->flags, depthStencilViewId, pCmd->depth, (uint8_t)pCmd->stencil);
|
---|
1290 | return rc;
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 |
|
---|
1294 | int vmsvga3dDXPredCopyRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopyRegion const *pCmd)
|
---|
1295 | {
|
---|
1296 | int rc;
|
---|
1297 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1298 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredCopyRegion, VERR_INVALID_STATE);
|
---|
1299 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1300 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1301 |
|
---|
1302 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1303 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1304 | AssertRCReturn(rc, rc);
|
---|
1305 |
|
---|
1306 | /** @todo Memcpy if both resources do not have the hardware resource. */
|
---|
1307 |
|
---|
1308 | rc = pSvgaR3State->pFuncsDX->pfnDXPredCopyRegion(pThisCC, pDXContext, pCmd->dstSid, pCmd->dstSubResource, pCmd->srcSid, pCmd->srcSubResource, &pCmd->box);
|
---|
1309 | return rc;
|
---|
1310 | }
|
---|
1311 |
|
---|
1312 |
|
---|
1313 | int vmsvga3dDXPredCopy(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopy const *pCmd)
|
---|
1314 | {
|
---|
1315 | int rc;
|
---|
1316 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1317 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredCopy, VERR_INVALID_STATE);
|
---|
1318 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1319 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1320 |
|
---|
1321 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1322 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1323 | AssertRCReturn(rc, rc);
|
---|
1324 |
|
---|
1325 | rc = pSvgaR3State->pFuncsDX->pfnDXPredCopy(pThisCC, pDXContext, pCmd->dstSid, pCmd->srcSid);
|
---|
1326 | return rc;
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 |
|
---|
1330 | int vmsvga3dDXPresentBlt(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPresentBlt const *pCmd)
|
---|
1331 | {
|
---|
1332 | int rc;
|
---|
1333 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1334 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPresentBlt, VERR_INVALID_STATE);
|
---|
1335 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1336 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1337 |
|
---|
1338 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1339 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1340 | AssertRCReturn(rc, rc);
|
---|
1341 |
|
---|
1342 | rc = pSvgaR3State->pFuncsDX->pfnDXPresentBlt(pThisCC, pDXContext,
|
---|
1343 | pCmd->dstSid, pCmd->destSubResource, &pCmd->boxDest,
|
---|
1344 | pCmd->srcSid, pCmd->srcSubResource, &pCmd->boxSrc, pCmd->mode);
|
---|
1345 | return rc;
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 |
|
---|
1349 | int vmsvga3dDXGenMips(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXGenMips const *pCmd)
|
---|
1350 | {
|
---|
1351 | int rc;
|
---|
1352 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1353 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXGenMips, VERR_INVALID_STATE);
|
---|
1354 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1355 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1356 |
|
---|
1357 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1358 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1359 | AssertRCReturn(rc, rc);
|
---|
1360 |
|
---|
1361 | SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
|
---|
1362 |
|
---|
1363 | ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
|
---|
1364 | ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
|
---|
1365 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1366 |
|
---|
1367 | rc = pSvgaR3State->pFuncsDX->pfnDXGenMips(pThisCC, pDXContext, shaderResourceViewId);
|
---|
1368 | return rc;
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 |
|
---|
1372 | int vmsvga3dDXDefineShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShaderResourceView const *pCmd)
|
---|
1373 | {
|
---|
1374 | int rc;
|
---|
1375 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1376 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineShaderResourceView, VERR_INVALID_STATE);
|
---|
1377 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1378 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1379 |
|
---|
1380 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1381 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1382 | AssertRCReturn(rc, rc);
|
---|
1383 |
|
---|
1384 | SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
|
---|
1385 |
|
---|
1386 | ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
|
---|
1387 | ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
|
---|
1388 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1389 |
|
---|
1390 | SVGACOTableDXSRViewEntry *pEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
|
---|
1391 | pEntry->sid = pCmd->sid;
|
---|
1392 | pEntry->format = pCmd->format;
|
---|
1393 | pEntry->resourceDimension = pCmd->resourceDimension;
|
---|
1394 | pEntry->desc = pCmd->desc;
|
---|
1395 |
|
---|
1396 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineShaderResourceView(pThisCC, pDXContext, shaderResourceViewId, pEntry);
|
---|
1397 | return rc;
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 |
|
---|
1401 | int vmsvga3dDXDestroyShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShaderResourceView const *pCmd)
|
---|
1402 | {
|
---|
1403 | int rc;
|
---|
1404 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1405 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyShaderResourceView, VERR_INVALID_STATE);
|
---|
1406 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1407 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1408 |
|
---|
1409 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1410 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1411 | AssertRCReturn(rc, rc);
|
---|
1412 |
|
---|
1413 | SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
|
---|
1414 |
|
---|
1415 | ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
|
---|
1416 | ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
|
---|
1417 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1418 |
|
---|
1419 | SVGACOTableDXSRViewEntry *pEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
|
---|
1420 | RT_ZERO(*pEntry);
|
---|
1421 |
|
---|
1422 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyShaderResourceView(pThisCC, pDXContext, shaderResourceViewId);
|
---|
1423 | return rc;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 |
|
---|
1427 | int vmsvga3dDXDefineRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRenderTargetView const *pCmd)
|
---|
1428 | {
|
---|
1429 | int rc;
|
---|
1430 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1431 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineRenderTargetView, VERR_INVALID_STATE);
|
---|
1432 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1433 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1434 |
|
---|
1435 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1436 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1437 | AssertRCReturn(rc, rc);
|
---|
1438 |
|
---|
1439 | SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
|
---|
1440 |
|
---|
1441 | ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
|
---|
1442 | ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
|
---|
1443 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1444 |
|
---|
1445 | SVGACOTableDXRTViewEntry *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
|
---|
1446 | pEntry->sid = pCmd->sid;
|
---|
1447 | pEntry->format = pCmd->format;
|
---|
1448 | pEntry->resourceDimension = pCmd->resourceDimension;
|
---|
1449 | pEntry->desc = pCmd->desc;
|
---|
1450 |
|
---|
1451 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry);
|
---|
1452 | return rc;
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 |
|
---|
1456 | int vmsvga3dDXDestroyRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRenderTargetView const *pCmd)
|
---|
1457 | {
|
---|
1458 | int rc;
|
---|
1459 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1460 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyRenderTargetView, VERR_INVALID_STATE);
|
---|
1461 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1462 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1463 |
|
---|
1464 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1465 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1466 | AssertRCReturn(rc, rc);
|
---|
1467 |
|
---|
1468 | SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
|
---|
1469 |
|
---|
1470 | ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
|
---|
1471 | ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
|
---|
1472 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1473 |
|
---|
1474 | SVGACOTableDXRTViewEntry *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
|
---|
1475 | RT_ZERO(*pEntry);
|
---|
1476 |
|
---|
1477 | for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)
|
---|
1478 | {
|
---|
1479 | if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] == renderTargetViewId)
|
---|
1480 | pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = SVGA_ID_INVALID;
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyRenderTargetView(pThisCC, pDXContext, renderTargetViewId);
|
---|
1484 | return rc;
|
---|
1485 | }
|
---|
1486 |
|
---|
1487 |
|
---|
1488 | int vmsvga3dDXDefineDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView_v2 const *pCmd)
|
---|
1489 | {
|
---|
1490 | int rc;
|
---|
1491 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1492 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilView, VERR_INVALID_STATE);
|
---|
1493 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1494 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1495 |
|
---|
1496 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1497 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1498 | AssertRCReturn(rc, rc);
|
---|
1499 |
|
---|
1500 | SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
|
---|
1501 |
|
---|
1502 | ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
|
---|
1503 | ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
|
---|
1504 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1505 |
|
---|
1506 | SVGACOTableDXDSViewEntry *pEntry = &pDXContext->cot.paDSView[depthStencilViewId];
|
---|
1507 | pEntry->sid = pCmd->sid;
|
---|
1508 | pEntry->format = pCmd->format;
|
---|
1509 | pEntry->resourceDimension = pCmd->resourceDimension;
|
---|
1510 | pEntry->mipSlice = pCmd->mipSlice;
|
---|
1511 | pEntry->firstArraySlice = pCmd->firstArraySlice;
|
---|
1512 | pEntry->arraySize = pCmd->arraySize;
|
---|
1513 | pEntry->flags = pCmd->flags;
|
---|
1514 |
|
---|
1515 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry);
|
---|
1516 | return rc;
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 |
|
---|
1520 | int vmsvga3dDXDestroyDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilView const *pCmd)
|
---|
1521 | {
|
---|
1522 | int rc;
|
---|
1523 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1524 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilView, VERR_INVALID_STATE);
|
---|
1525 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1526 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1527 |
|
---|
1528 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1529 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1530 | AssertRCReturn(rc, rc);
|
---|
1531 |
|
---|
1532 | SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
|
---|
1533 |
|
---|
1534 | ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
|
---|
1535 | ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
|
---|
1536 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1537 |
|
---|
1538 | SVGACOTableDXDSViewEntry *pEntry = &pDXContext->cot.paDSView[depthStencilViewId];
|
---|
1539 | RT_ZERO(*pEntry);
|
---|
1540 |
|
---|
1541 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilView(pThisCC, pDXContext, depthStencilViewId);
|
---|
1542 | return rc;
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 |
|
---|
1546 | int vmsvga3dDXDefineElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dElementLayoutId elementLayoutId, uint32_t cDesc, SVGA3dInputElementDesc const *paDesc)
|
---|
1547 | {
|
---|
1548 | int rc;
|
---|
1549 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1550 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineElementLayout, VERR_INVALID_STATE);
|
---|
1551 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1552 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1553 |
|
---|
1554 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1555 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1556 | AssertRCReturn(rc, rc);
|
---|
1557 |
|
---|
1558 | ASSERT_GUEST_RETURN(pDXContext->cot.paElementLayout, VERR_INVALID_STATE);
|
---|
1559 | ASSERT_GUEST_RETURN(elementLayoutId < pDXContext->cot.cElementLayout, VERR_INVALID_PARAMETER);
|
---|
1560 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1561 |
|
---|
1562 | SVGACOTableDXElementLayoutEntry *pEntry = &pDXContext->cot.paElementLayout[elementLayoutId];
|
---|
1563 | pEntry->elid = elementLayoutId;
|
---|
1564 | pEntry->numDescs = RT_MIN(cDesc, RT_ELEMENTS(pEntry->descs));
|
---|
1565 | memcpy(pEntry->descs, paDesc, pEntry->numDescs * sizeof(pEntry->descs[0]));
|
---|
1566 |
|
---|
1567 | #ifdef LOG_ENABLED
|
---|
1568 | Log6(("Element layout %d: slot off fmt class step reg\n", pEntry->elid));
|
---|
1569 | for (uint32_t i = 0; i < pEntry->numDescs; ++i)
|
---|
1570 | {
|
---|
1571 | Log6((" [%u]: %u 0x%02X %d %u %u %u\n",
|
---|
1572 | i,
|
---|
1573 | pEntry->descs[i].inputSlot,
|
---|
1574 | pEntry->descs[i].alignedByteOffset,
|
---|
1575 | pEntry->descs[i].format,
|
---|
1576 | pEntry->descs[i].inputSlotClass,
|
---|
1577 | pEntry->descs[i].instanceDataStepRate,
|
---|
1578 | pEntry->descs[i].inputRegister
|
---|
1579 | ));
|
---|
1580 | }
|
---|
1581 | #endif
|
---|
1582 |
|
---|
1583 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineElementLayout(pThisCC, pDXContext, elementLayoutId, pEntry);
|
---|
1584 | return rc;
|
---|
1585 | }
|
---|
1586 |
|
---|
1587 |
|
---|
1588 | int vmsvga3dDXDestroyElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyElementLayout const *pCmd)
|
---|
1589 | {
|
---|
1590 | int rc;
|
---|
1591 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1592 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyElementLayout, VERR_INVALID_STATE);
|
---|
1593 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1594 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1595 |
|
---|
1596 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1597 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1598 | AssertRCReturn(rc, rc);
|
---|
1599 |
|
---|
1600 | SVGA3dElementLayoutId const elementLayoutId = pCmd->elementLayoutId;
|
---|
1601 |
|
---|
1602 | ASSERT_GUEST_RETURN(pDXContext->cot.paElementLayout, VERR_INVALID_STATE);
|
---|
1603 | ASSERT_GUEST_RETURN(elementLayoutId < pDXContext->cot.cElementLayout, VERR_INVALID_PARAMETER);
|
---|
1604 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1605 |
|
---|
1606 | pSvgaR3State->pFuncsDX->pfnDXDestroyElementLayout(pThisCC, pDXContext, elementLayoutId);
|
---|
1607 |
|
---|
1608 | SVGACOTableDXElementLayoutEntry *pEntry = &pDXContext->cot.paElementLayout[elementLayoutId];
|
---|
1609 | RT_ZERO(*pEntry);
|
---|
1610 | pEntry->elid = SVGA3D_INVALID_ID;
|
---|
1611 |
|
---|
1612 | return rc;
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 |
|
---|
1616 | int vmsvga3dDXDefineBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineBlendState const *pCmd)
|
---|
1617 | {
|
---|
1618 | int rc;
|
---|
1619 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1620 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineBlendState, VERR_INVALID_STATE);
|
---|
1621 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1622 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1623 |
|
---|
1624 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1625 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1626 | AssertRCReturn(rc, rc);
|
---|
1627 |
|
---|
1628 | SVGA3dBlendStateId const blendId = pCmd->blendId;
|
---|
1629 |
|
---|
1630 | ASSERT_GUEST_RETURN(pDXContext->cot.paBlendState, VERR_INVALID_STATE);
|
---|
1631 | ASSERT_GUEST_RETURN(blendId < pDXContext->cot.cBlendState, VERR_INVALID_PARAMETER);
|
---|
1632 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1633 |
|
---|
1634 | SVGACOTableDXBlendStateEntry *pEntry = &pDXContext->cot.paBlendState[blendId];
|
---|
1635 | pEntry->alphaToCoverageEnable = pCmd->alphaToCoverageEnable;
|
---|
1636 | pEntry->independentBlendEnable = pCmd->independentBlendEnable;
|
---|
1637 | memcpy(pEntry->perRT, pCmd->perRT, sizeof(pEntry->perRT));
|
---|
1638 |
|
---|
1639 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineBlendState(pThisCC, pDXContext, blendId, pEntry);
|
---|
1640 | return rc;
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 |
|
---|
1644 | int vmsvga3dDXDestroyBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyBlendState const *pCmd)
|
---|
1645 | {
|
---|
1646 | int rc;
|
---|
1647 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1648 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyBlendState, VERR_INVALID_STATE);
|
---|
1649 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1650 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1651 |
|
---|
1652 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1653 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1654 | AssertRCReturn(rc, rc);
|
---|
1655 |
|
---|
1656 | SVGA3dBlendStateId const blendId = pCmd->blendId;
|
---|
1657 |
|
---|
1658 | ASSERT_GUEST_RETURN(pDXContext->cot.paBlendState, VERR_INVALID_STATE);
|
---|
1659 | ASSERT_GUEST_RETURN(blendId < pDXContext->cot.cBlendState, VERR_INVALID_PARAMETER);
|
---|
1660 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1661 |
|
---|
1662 | pSvgaR3State->pFuncsDX->pfnDXDestroyBlendState(pThisCC, pDXContext, blendId);
|
---|
1663 |
|
---|
1664 | SVGACOTableDXBlendStateEntry *pEntry = &pDXContext->cot.paBlendState[blendId];
|
---|
1665 | RT_ZERO(*pEntry);
|
---|
1666 |
|
---|
1667 | return rc;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 |
|
---|
1671 | int vmsvga3dDXDefineDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilState const *pCmd)
|
---|
1672 | {
|
---|
1673 | int rc;
|
---|
1674 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1675 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilState, VERR_INVALID_STATE);
|
---|
1676 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1677 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1678 |
|
---|
1679 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1680 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1681 | AssertRCReturn(rc, rc);
|
---|
1682 |
|
---|
1683 | SVGA3dDepthStencilStateId const depthStencilId = pCmd->depthStencilId;
|
---|
1684 |
|
---|
1685 | ASSERT_GUEST_RETURN(pDXContext->cot.paDepthStencil, VERR_INVALID_STATE);
|
---|
1686 | ASSERT_GUEST_RETURN(depthStencilId < pDXContext->cot.cDepthStencil, VERR_INVALID_PARAMETER);
|
---|
1687 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1688 |
|
---|
1689 | SVGACOTableDXDepthStencilEntry *pEntry = &pDXContext->cot.paDepthStencil[depthStencilId];
|
---|
1690 | pEntry->depthEnable = pCmd->depthEnable;
|
---|
1691 | pEntry->depthWriteMask = pCmd->depthWriteMask;
|
---|
1692 | pEntry->depthFunc = pCmd->depthFunc;
|
---|
1693 | pEntry->stencilEnable = pCmd->stencilEnable;
|
---|
1694 | pEntry->frontEnable = pCmd->frontEnable;
|
---|
1695 | pEntry->backEnable = pCmd->backEnable;
|
---|
1696 | pEntry->stencilReadMask = pCmd->stencilReadMask;
|
---|
1697 | pEntry->stencilWriteMask = pCmd->stencilWriteMask;
|
---|
1698 |
|
---|
1699 | pEntry->frontStencilFailOp = pCmd->frontStencilFailOp;
|
---|
1700 | pEntry->frontStencilDepthFailOp = pCmd->frontStencilDepthFailOp;
|
---|
1701 | pEntry->frontStencilPassOp = pCmd->frontStencilPassOp;
|
---|
1702 | pEntry->frontStencilFunc = pCmd->frontStencilFunc;
|
---|
1703 |
|
---|
1704 | pEntry->backStencilFailOp = pCmd->backStencilFailOp;
|
---|
1705 | pEntry->backStencilDepthFailOp = pCmd->backStencilDepthFailOp;
|
---|
1706 | pEntry->backStencilPassOp = pCmd->backStencilPassOp;
|
---|
1707 | pEntry->backStencilFunc = pCmd->backStencilFunc;
|
---|
1708 |
|
---|
1709 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilState(pThisCC, pDXContext, depthStencilId, pEntry);
|
---|
1710 | return rc;
|
---|
1711 | }
|
---|
1712 |
|
---|
1713 |
|
---|
1714 | int vmsvga3dDXDestroyDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilState const *pCmd)
|
---|
1715 | {
|
---|
1716 | int rc;
|
---|
1717 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1718 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilState, VERR_INVALID_STATE);
|
---|
1719 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1720 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1721 |
|
---|
1722 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1723 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1724 | AssertRCReturn(rc, rc);
|
---|
1725 |
|
---|
1726 | SVGA3dDepthStencilStateId const depthStencilId = pCmd->depthStencilId;
|
---|
1727 |
|
---|
1728 | ASSERT_GUEST_RETURN(pDXContext->cot.paDepthStencil, VERR_INVALID_STATE);
|
---|
1729 | ASSERT_GUEST_RETURN(depthStencilId < pDXContext->cot.cDepthStencil, VERR_INVALID_PARAMETER);
|
---|
1730 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1731 |
|
---|
1732 | pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilState(pThisCC, pDXContext, depthStencilId);
|
---|
1733 |
|
---|
1734 | SVGACOTableDXDepthStencilEntry *pEntry = &pDXContext->cot.paDepthStencil[depthStencilId];
|
---|
1735 | RT_ZERO(*pEntry);
|
---|
1736 |
|
---|
1737 | return rc;
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 |
|
---|
1741 | int vmsvga3dDXDefineRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRasterizerState const *pCmd)
|
---|
1742 | {
|
---|
1743 | int rc;
|
---|
1744 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1745 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineRasterizerState, VERR_INVALID_STATE);
|
---|
1746 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1747 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1748 |
|
---|
1749 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1750 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1751 | AssertRCReturn(rc, rc);
|
---|
1752 |
|
---|
1753 | SVGA3dRasterizerStateId const rasterizerId = pCmd->rasterizerId;
|
---|
1754 |
|
---|
1755 | ASSERT_GUEST_RETURN(pDXContext->cot.paRasterizerState, VERR_INVALID_STATE);
|
---|
1756 | ASSERT_GUEST_RETURN(rasterizerId < pDXContext->cot.cRasterizerState, VERR_INVALID_PARAMETER);
|
---|
1757 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1758 |
|
---|
1759 | SVGACOTableDXRasterizerStateEntry *pEntry = &pDXContext->cot.paRasterizerState[rasterizerId];
|
---|
1760 | pEntry->fillMode = pCmd->fillMode;
|
---|
1761 | pEntry->cullMode = pCmd->cullMode;
|
---|
1762 | pEntry->frontCounterClockwise = pCmd->frontCounterClockwise;
|
---|
1763 | pEntry->provokingVertexLast = pCmd->provokingVertexLast;
|
---|
1764 | pEntry->depthBias = pCmd->depthBias;
|
---|
1765 | pEntry->depthBiasClamp = pCmd->depthBiasClamp;
|
---|
1766 | pEntry->slopeScaledDepthBias = pCmd->slopeScaledDepthBias;
|
---|
1767 | pEntry->depthClipEnable = pCmd->depthClipEnable;
|
---|
1768 | pEntry->scissorEnable = pCmd->scissorEnable;
|
---|
1769 | pEntry->multisampleEnable = pCmd->multisampleEnable;
|
---|
1770 | pEntry->antialiasedLineEnable = pCmd->antialiasedLineEnable;
|
---|
1771 | pEntry->lineWidth = pCmd->lineWidth;
|
---|
1772 | pEntry->lineStippleEnable = pCmd->lineStippleEnable;
|
---|
1773 | pEntry->lineStippleFactor = pCmd->lineStippleFactor;
|
---|
1774 | pEntry->lineStipplePattern = pCmd->lineStipplePattern;
|
---|
1775 | pEntry->forcedSampleCount = 0; /** @todo Not in pCmd. */
|
---|
1776 | RT_ZERO(pEntry->mustBeZero);
|
---|
1777 |
|
---|
1778 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineRasterizerState(pThisCC, pDXContext, rasterizerId, pEntry);
|
---|
1779 | return rc;
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 |
|
---|
1783 | int vmsvga3dDXDestroyRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRasterizerState const *pCmd)
|
---|
1784 | {
|
---|
1785 | int rc;
|
---|
1786 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1787 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyRasterizerState, VERR_INVALID_STATE);
|
---|
1788 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1789 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1790 |
|
---|
1791 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1792 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1793 | AssertRCReturn(rc, rc);
|
---|
1794 |
|
---|
1795 | SVGA3dRasterizerStateId const rasterizerId = pCmd->rasterizerId;
|
---|
1796 |
|
---|
1797 | ASSERT_GUEST_RETURN(pDXContext->cot.paRasterizerState, VERR_INVALID_STATE);
|
---|
1798 | ASSERT_GUEST_RETURN(rasterizerId < pDXContext->cot.cRasterizerState, VERR_INVALID_PARAMETER);
|
---|
1799 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1800 |
|
---|
1801 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyRasterizerState(pThisCC, pDXContext, rasterizerId);
|
---|
1802 |
|
---|
1803 | SVGACOTableDXRasterizerStateEntry *pEntry = &pDXContext->cot.paRasterizerState[rasterizerId];
|
---|
1804 | RT_ZERO(*pEntry);
|
---|
1805 |
|
---|
1806 | return rc;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 |
|
---|
1810 | int vmsvga3dDXDefineSamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineSamplerState const *pCmd)
|
---|
1811 | {
|
---|
1812 | int rc;
|
---|
1813 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1814 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineSamplerState, VERR_INVALID_STATE);
|
---|
1815 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1816 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1817 |
|
---|
1818 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1819 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1820 | AssertRCReturn(rc, rc);
|
---|
1821 |
|
---|
1822 | SVGA3dSamplerId const samplerId = pCmd->samplerId;
|
---|
1823 |
|
---|
1824 | ASSERT_GUEST_RETURN(pDXContext->cot.paSampler, VERR_INVALID_STATE);
|
---|
1825 | ASSERT_GUEST_RETURN(samplerId < pDXContext->cot.cSampler, VERR_INVALID_PARAMETER);
|
---|
1826 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1827 |
|
---|
1828 | SVGACOTableDXSamplerEntry *pEntry = &pDXContext->cot.paSampler[samplerId];
|
---|
1829 | pEntry->filter = pCmd->filter;
|
---|
1830 | pEntry->addressU = pCmd->addressU;
|
---|
1831 | pEntry->addressV = pCmd->addressV;
|
---|
1832 | pEntry->addressW = pCmd->addressW;
|
---|
1833 | pEntry->mipLODBias = pCmd->mipLODBias;
|
---|
1834 | pEntry->maxAnisotropy = pCmd->maxAnisotropy;
|
---|
1835 | pEntry->comparisonFunc = pCmd->comparisonFunc;
|
---|
1836 | pEntry->borderColor = pCmd->borderColor;
|
---|
1837 | pEntry->minLOD = pCmd->minLOD;
|
---|
1838 | pEntry->maxLOD = pCmd->maxLOD;
|
---|
1839 |
|
---|
1840 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineSamplerState(pThisCC, pDXContext, samplerId, pEntry);
|
---|
1841 | return rc;
|
---|
1842 | }
|
---|
1843 |
|
---|
1844 |
|
---|
1845 | int vmsvga3dDXDestroySamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroySamplerState const *pCmd)
|
---|
1846 | {
|
---|
1847 | int rc;
|
---|
1848 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1849 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroySamplerState, VERR_INVALID_STATE);
|
---|
1850 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1851 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1852 |
|
---|
1853 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1854 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1855 | AssertRCReturn(rc, rc);
|
---|
1856 |
|
---|
1857 | SVGA3dSamplerId const samplerId = pCmd->samplerId;
|
---|
1858 |
|
---|
1859 | ASSERT_GUEST_RETURN(pDXContext->cot.paSampler, VERR_INVALID_STATE);
|
---|
1860 | ASSERT_GUEST_RETURN(samplerId < pDXContext->cot.cSampler, VERR_INVALID_PARAMETER);
|
---|
1861 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1862 |
|
---|
1863 | pSvgaR3State->pFuncsDX->pfnDXDestroySamplerState(pThisCC, pDXContext, samplerId);
|
---|
1864 |
|
---|
1865 | SVGACOTableDXSamplerEntry *pEntry = &pDXContext->cot.paSampler[samplerId];
|
---|
1866 | RT_ZERO(*pEntry);
|
---|
1867 |
|
---|
1868 | return rc;
|
---|
1869 | }
|
---|
1870 |
|
---|
1871 |
|
---|
1872 | int vmsvga3dDXDefineShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShader const *pCmd)
|
---|
1873 | {
|
---|
1874 | int rc;
|
---|
1875 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1876 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineShader, VERR_INVALID_STATE);
|
---|
1877 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1878 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1879 |
|
---|
1880 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1881 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1882 | AssertRCReturn(rc, rc);
|
---|
1883 |
|
---|
1884 | SVGA3dShaderId const shaderId = pCmd->shaderId;
|
---|
1885 |
|
---|
1886 | ASSERT_GUEST_RETURN(pDXContext->cot.paShader, VERR_INVALID_STATE);
|
---|
1887 | ASSERT_GUEST_RETURN(shaderId < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
|
---|
1888 | ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
|
---|
1889 | ASSERT_GUEST_RETURN(pCmd->sizeInBytes >= 8, VERR_INVALID_PARAMETER); /* Version Token + Length Token. */
|
---|
1890 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1891 |
|
---|
1892 | /* Cleanup the current shader. */
|
---|
1893 | pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
|
---|
1894 |
|
---|
1895 | SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[shaderId];
|
---|
1896 | pEntry->type = pCmd->type;
|
---|
1897 | pEntry->sizeInBytes = pCmd->sizeInBytes;
|
---|
1898 | pEntry->offsetInBytes = 0;
|
---|
1899 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
1900 |
|
---|
1901 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineShader(pThisCC, pDXContext, shaderId, pEntry);
|
---|
1902 | return rc;
|
---|
1903 | }
|
---|
1904 |
|
---|
1905 |
|
---|
1906 | int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd)
|
---|
1907 | {
|
---|
1908 | int rc;
|
---|
1909 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
1910 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyShader, VERR_INVALID_STATE);
|
---|
1911 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
1912 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
1913 |
|
---|
1914 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
1915 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
1916 | AssertRCReturn(rc, rc);
|
---|
1917 |
|
---|
1918 | SVGA3dShaderId const shaderId = pCmd->shaderId;
|
---|
1919 |
|
---|
1920 | ASSERT_GUEST_RETURN(pDXContext->cot.paShader, VERR_INVALID_STATE);
|
---|
1921 | ASSERT_GUEST_RETURN(shaderId < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
|
---|
1922 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1923 |
|
---|
1924 | pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
|
---|
1925 |
|
---|
1926 | /* Cleanup COTable entries.*/
|
---|
1927 | SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[shaderId];
|
---|
1928 | pEntry->type = SVGA3D_SHADERTYPE_INVALID;
|
---|
1929 | pEntry->sizeInBytes = 0;
|
---|
1930 | pEntry->offsetInBytes = 0;
|
---|
1931 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
1932 |
|
---|
1933 | /** @todo Destroy shaders on context and backend deletion. */
|
---|
1934 | return rc;
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 |
|
---|
1938 | static int dxBindShader(DXShaderInfo *pShaderInfo, PVMSVGAMOB pMob, SVGACOTableDXShaderEntry const *pEntry, void const *pvShaderBytecode)
|
---|
1939 | {
|
---|
1940 | /* How many bytes the MOB can hold. */
|
---|
1941 | uint32_t const cbMob = vmsvgaR3MobSize(pMob) - pEntry->offsetInBytes;
|
---|
1942 | ASSERT_GUEST_RETURN(cbMob >= pEntry->sizeInBytes, VERR_INVALID_PARAMETER);
|
---|
1943 | AssertReturn(pEntry->sizeInBytes >= 8, VERR_INTERNAL_ERROR); /* Host ensures this in DefineShader. */
|
---|
1944 |
|
---|
1945 | int rc = DXShaderParse(pvShaderBytecode, pEntry->sizeInBytes, pShaderInfo);
|
---|
1946 | if (RT_SUCCESS(rc))
|
---|
1947 | {
|
---|
1948 | /* Get the length of the shader bytecode. */
|
---|
1949 | uint32_t const *pau32Token = (uint32_t *)pvShaderBytecode; /* Tokens */
|
---|
1950 | uint32_t const cToken = pau32Token[1]; /* Length of the shader in tokens. */
|
---|
1951 | ASSERT_GUEST_RETURN(cToken <= pEntry->sizeInBytes / 4, VERR_INVALID_PARAMETER);
|
---|
1952 |
|
---|
1953 | /* Check if the shader contains SVGA3dDXSignatureHeader and signature entries after the bytecode.
|
---|
1954 | * If they are not there (Linux guest driver does not provide them), then it is fine
|
---|
1955 | * and the signatures generated by DXShaderParse will be used.
|
---|
1956 | */
|
---|
1957 | uint32_t cbSignaturesAvail = pEntry->sizeInBytes - cToken * 4; /* How many bytes for signatures are available. */
|
---|
1958 | if (cbSignaturesAvail >= sizeof(SVGA3dDXSignatureHeader))
|
---|
1959 | {
|
---|
1960 | cbSignaturesAvail -= sizeof(SVGA3dDXSignatureHeader);
|
---|
1961 |
|
---|
1962 | SVGA3dDXSignatureHeader const *pSignatureHeader = (SVGA3dDXSignatureHeader *)((uint8_t *)pvShaderBytecode + cToken * 4);
|
---|
1963 | if (pSignatureHeader->headerVersion == SVGADX_SIGNATURE_HEADER_VERSION_0)
|
---|
1964 | {
|
---|
1965 | ASSERT_GUEST_RETURN( pSignatureHeader->numInputSignatures <= RT_ELEMENTS(pShaderInfo->aInputSignature)
|
---|
1966 | && pSignatureHeader->numOutputSignatures <= RT_ELEMENTS(pShaderInfo->aOutputSignature)
|
---|
1967 | && pSignatureHeader->numPatchConstantSignatures <= RT_ELEMENTS(pShaderInfo->aPatchConstantSignature),
|
---|
1968 | VERR_INVALID_PARAMETER);
|
---|
1969 |
|
---|
1970 | uint32_t const cSignature = pSignatureHeader->numInputSignatures
|
---|
1971 | + pSignatureHeader->numOutputSignatures
|
---|
1972 | + pSignatureHeader->numPatchConstantSignatures;
|
---|
1973 | uint32_t const cbSignature = cSignature * sizeof(SVGA3dDXSignatureEntry);
|
---|
1974 | ASSERT_GUEST_RETURN(cbSignaturesAvail >= cbSignature, VERR_INVALID_PARAMETER);
|
---|
1975 |
|
---|
1976 | /* The shader does not need guesswork. */
|
---|
1977 | pShaderInfo->fGuestSignatures = true;
|
---|
1978 |
|
---|
1979 | /* Copy to DXShaderInfo. */
|
---|
1980 | uint8_t const *pu8Signatures = (uint8_t *)&pSignatureHeader[1];
|
---|
1981 | pShaderInfo->cInputSignature = pSignatureHeader->numInputSignatures;
|
---|
1982 | memcpy(pShaderInfo->aInputSignature, pu8Signatures, pSignatureHeader->numInputSignatures * sizeof(SVGA3dDXSignatureEntry));
|
---|
1983 |
|
---|
1984 | pu8Signatures += pSignatureHeader->numInputSignatures * sizeof(SVGA3dDXSignatureEntry);
|
---|
1985 | pShaderInfo->cOutputSignature = pSignatureHeader->numOutputSignatures;
|
---|
1986 | memcpy(pShaderInfo->aOutputSignature, pu8Signatures, pSignatureHeader->numOutputSignatures * sizeof(SVGA3dDXSignatureEntry));
|
---|
1987 |
|
---|
1988 | pu8Signatures += pSignatureHeader->numOutputSignatures * sizeof(SVGA3dDXSignatureEntry);
|
---|
1989 | pShaderInfo->cPatchConstantSignature = pSignatureHeader->numPatchConstantSignatures;
|
---|
1990 | memcpy(pShaderInfo->aPatchConstantSignature, pu8Signatures, pSignatureHeader->numPatchConstantSignatures * sizeof(SVGA3dDXSignatureEntry));
|
---|
1991 |
|
---|
1992 | DXShaderGenerateSemantics(pShaderInfo);
|
---|
1993 | }
|
---|
1994 | }
|
---|
1995 | }
|
---|
1996 |
|
---|
1997 | return rc;
|
---|
1998 | }
|
---|
1999 |
|
---|
2000 |
|
---|
2001 | int vmsvga3dDXBindShader(PVGASTATECC pThisCC, SVGA3dCmdDXBindShader const *pCmd, PVMSVGAMOB pMob)
|
---|
2002 | {
|
---|
2003 | int rc;
|
---|
2004 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2005 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindShader, VERR_INVALID_STATE);
|
---|
2006 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2007 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2008 |
|
---|
2009 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2010 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2011 | AssertRCReturn(rc, rc);
|
---|
2012 |
|
---|
2013 | ASSERT_GUEST_RETURN(pCmd->shid < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
|
---|
2014 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2015 |
|
---|
2016 | /* 'type' and 'sizeInBytes' has been already initialized by DefineShader. */
|
---|
2017 | SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[pCmd->shid];
|
---|
2018 | //pEntry->type;
|
---|
2019 | //pEntry->sizeInBytes;
|
---|
2020 | pEntry->offsetInBytes = pCmd->offsetInBytes;
|
---|
2021 | pEntry->mobid = vmsvgaR3MobId(pMob);
|
---|
2022 |
|
---|
2023 | if (pMob)
|
---|
2024 | {
|
---|
2025 | /* Bind a mob to the shader. */
|
---|
2026 |
|
---|
2027 | /* Create a memory pointer for the MOB, which is accessible by host. */
|
---|
2028 | rc = vmsvgaR3MobBackingStoreCreate(pSvgaR3State, pMob, vmsvgaR3MobSize(pMob));
|
---|
2029 | if (RT_SUCCESS(rc))
|
---|
2030 | {
|
---|
2031 | /* Get pointer to the shader bytecode. This will also verify the offset. */
|
---|
2032 | void const *pvShaderBytecode = vmsvgaR3MobBackingStorePtr(pMob, pEntry->offsetInBytes);
|
---|
2033 | ASSERT_GUEST_RETURN(pvShaderBytecode, VERR_INVALID_PARAMETER);
|
---|
2034 |
|
---|
2035 | /* Get the shader and optional signatures from the MOB. */
|
---|
2036 | DXShaderInfo shaderInfo;
|
---|
2037 | RT_ZERO(shaderInfo);
|
---|
2038 | rc = dxBindShader(&shaderInfo, pMob, pEntry, pvShaderBytecode);
|
---|
2039 | if (RT_SUCCESS(rc))
|
---|
2040 | {
|
---|
2041 | /* pfnDXBindShader makes a copy of shaderInfo on success. */
|
---|
2042 | rc = pSvgaR3State->pFuncsDX->pfnDXBindShader(pThisCC, pDXContext, pCmd->shid, &shaderInfo);
|
---|
2043 | }
|
---|
2044 | AssertRC(rc);
|
---|
2045 |
|
---|
2046 | /** @todo Backing store is not needed anymore in any case? */
|
---|
2047 | if (RT_FAILURE(rc))
|
---|
2048 | {
|
---|
2049 | DXShaderFree(&shaderInfo);
|
---|
2050 |
|
---|
2051 | vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
|
---|
2052 | }
|
---|
2053 | }
|
---|
2054 | }
|
---|
2055 | else
|
---|
2056 | {
|
---|
2057 | /* Unbind. */
|
---|
2058 | /** @todo Nothing to do here but release the MOB? */
|
---|
2059 | vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
|
---|
2060 | }
|
---|
2061 |
|
---|
2062 | return rc;
|
---|
2063 | }
|
---|
2064 |
|
---|
2065 |
|
---|
2066 | int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd)
|
---|
2067 | {
|
---|
2068 | int rc;
|
---|
2069 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2070 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput, VERR_INVALID_STATE);
|
---|
2071 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2072 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2073 |
|
---|
2074 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2075 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2076 | AssertRCReturn(rc, rc);
|
---|
2077 |
|
---|
2078 | SVGA3dStreamOutputId const soid = pCmd->soid;
|
---|
2079 |
|
---|
2080 | ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
|
---|
2081 | ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
|
---|
2082 | ASSERT_GUEST_RETURN(pCmd->numOutputStreamEntries < SVGA3D_MAX_DX10_STREAMOUT_DECLS, VERR_INVALID_PARAMETER);
|
---|
2083 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2084 |
|
---|
2085 | SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
|
---|
2086 | pEntry->numOutputStreamEntries = pCmd->numOutputStreamEntries;
|
---|
2087 | memcpy(pEntry->decl, pCmd->decl, sizeof(pEntry->decl));
|
---|
2088 | memcpy(pEntry->streamOutputStrideInBytes, pCmd->streamOutputStrideInBytes, sizeof(pEntry->streamOutputStrideInBytes));
|
---|
2089 | pEntry->rasterizedStream = 0; // Apparently invalid in this command: pCmd->rasterizedStream;
|
---|
2090 | pEntry->numOutputStreamStrides = 0;
|
---|
2091 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
2092 | pEntry->offsetInBytes = 0;
|
---|
2093 | pEntry->usesMob = 0;
|
---|
2094 | pEntry->pad0 = 0;
|
---|
2095 | pEntry->pad1 = 0;
|
---|
2096 | RT_ZERO(pEntry->pad2);
|
---|
2097 |
|
---|
2098 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput(pThisCC, pDXContext, soid, pEntry);
|
---|
2099 | return rc;
|
---|
2100 | }
|
---|
2101 |
|
---|
2102 |
|
---|
2103 | int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd)
|
---|
2104 | {
|
---|
2105 | int rc;
|
---|
2106 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2107 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput, VERR_INVALID_STATE);
|
---|
2108 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2109 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2110 |
|
---|
2111 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2112 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2113 | AssertRCReturn(rc, rc);
|
---|
2114 |
|
---|
2115 | SVGA3dStreamOutputId const soid = pCmd->soid;
|
---|
2116 |
|
---|
2117 | ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
|
---|
2118 | ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
|
---|
2119 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2120 |
|
---|
2121 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput(pThisCC, pDXContext, soid);
|
---|
2122 |
|
---|
2123 | SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
|
---|
2124 | RT_ZERO(*pEntry);
|
---|
2125 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
2126 |
|
---|
2127 | return rc;
|
---|
2128 | }
|
---|
2129 |
|
---|
2130 |
|
---|
2131 | int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd)
|
---|
2132 | {
|
---|
2133 | int rc;
|
---|
2134 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2135 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput, VERR_INVALID_STATE);
|
---|
2136 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2137 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2138 |
|
---|
2139 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2140 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2141 | AssertRCReturn(rc, rc);
|
---|
2142 |
|
---|
2143 | SVGA3dStreamOutputId const soid = pCmd->soid;
|
---|
2144 |
|
---|
2145 | ASSERT_GUEST_RETURN( soid == SVGA_ID_INVALID
|
---|
2146 | || soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
|
---|
2147 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2148 |
|
---|
2149 | pDXContext->svgaDXContext.streamOut.soid = soid;
|
---|
2150 |
|
---|
2151 | rc = pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput(pThisCC, pDXContext, soid);
|
---|
2152 | return rc;
|
---|
2153 | }
|
---|
2154 |
|
---|
2155 |
|
---|
2156 | static int dxSetOrGrowCOTable(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGAMOB pMob,
|
---|
2157 | SVGACOTableType type, uint32_t validSizeInBytes, bool fGrow)
|
---|
2158 | {
|
---|
2159 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2160 | int rc = VINF_SUCCESS;
|
---|
2161 |
|
---|
2162 | ASSERT_GUEST_RETURN(type < RT_ELEMENTS(pDXContext->aCOTMobs), VERR_INVALID_PARAMETER);
|
---|
2163 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2164 |
|
---|
2165 | uint32_t cbCOT;
|
---|
2166 | if (pMob)
|
---|
2167 | {
|
---|
2168 | /* Bind a new mob to the COTable. */
|
---|
2169 | cbCOT = vmsvgaR3MobSize(pMob);
|
---|
2170 |
|
---|
2171 | ASSERT_GUEST_RETURN(validSizeInBytes <= cbCOT, VERR_INVALID_PARAMETER);
|
---|
2172 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2173 |
|
---|
2174 | /* Create a memory pointer, which is accessible by host. */
|
---|
2175 | rc = vmsvgaR3MobBackingStoreCreate(pSvgaR3State, pMob, validSizeInBytes);
|
---|
2176 | }
|
---|
2177 | else
|
---|
2178 | {
|
---|
2179 | /* Unbind. */
|
---|
2180 | validSizeInBytes = 0;
|
---|
2181 | cbCOT = 0;
|
---|
2182 | vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pDXContext->aCOTMobs[type]);
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 | uint32_t cEntries = 0;
|
---|
2186 | uint32_t cValidEntries = 0;
|
---|
2187 | if (RT_SUCCESS(rc))
|
---|
2188 | {
|
---|
2189 | static uint32_t const s_acbEntry[SVGA_COTABLE_MAX] =
|
---|
2190 | {
|
---|
2191 | sizeof(SVGACOTableDXRTViewEntry),
|
---|
2192 | sizeof(SVGACOTableDXDSViewEntry),
|
---|
2193 | sizeof(SVGACOTableDXSRViewEntry),
|
---|
2194 | sizeof(SVGACOTableDXElementLayoutEntry),
|
---|
2195 | sizeof(SVGACOTableDXBlendStateEntry),
|
---|
2196 | sizeof(SVGACOTableDXDepthStencilEntry),
|
---|
2197 | sizeof(SVGACOTableDXRasterizerStateEntry),
|
---|
2198 | sizeof(SVGACOTableDXSamplerEntry),
|
---|
2199 | sizeof(SVGACOTableDXStreamOutputEntry),
|
---|
2200 | sizeof(SVGACOTableDXQueryEntry),
|
---|
2201 | sizeof(SVGACOTableDXShaderEntry),
|
---|
2202 | sizeof(SVGACOTableDXUAViewEntry),
|
---|
2203 | };
|
---|
2204 |
|
---|
2205 | cEntries = cbCOT / s_acbEntry[type];
|
---|
2206 | cValidEntries = validSizeInBytes / s_acbEntry[type];
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | if (RT_SUCCESS(rc))
|
---|
2210 | {
|
---|
2211 | if ( fGrow
|
---|
2212 | && pDXContext->aCOTMobs[type]
|
---|
2213 | && cValidEntries)
|
---|
2214 | {
|
---|
2215 | /* Copy entries from the current mob to the new mob. */
|
---|
2216 | void const *pvSrc = vmsvgaR3MobBackingStorePtr(pDXContext->aCOTMobs[type], 0);
|
---|
2217 | void *pvDst = vmsvgaR3MobBackingStorePtr(pMob, 0);
|
---|
2218 | if (pvSrc && pvDst)
|
---|
2219 | memcpy(pvDst, pvSrc, validSizeInBytes);
|
---|
2220 | else
|
---|
2221 | AssertFailedStmt(rc = VERR_INVALID_STATE);
|
---|
2222 | }
|
---|
2223 | }
|
---|
2224 |
|
---|
2225 | if (RT_SUCCESS(rc))
|
---|
2226 | {
|
---|
2227 | pDXContext->aCOTMobs[type] = pMob;
|
---|
2228 |
|
---|
2229 | void *pvCOT = vmsvgaR3MobBackingStorePtr(pMob, 0);
|
---|
2230 | switch (type)
|
---|
2231 | {
|
---|
2232 | case SVGA_COTABLE_RTVIEW:
|
---|
2233 | pDXContext->cot.paRTView = (SVGACOTableDXRTViewEntry *)pvCOT;
|
---|
2234 | pDXContext->cot.cRTView = cEntries;
|
---|
2235 | break;
|
---|
2236 | case SVGA_COTABLE_DSVIEW:
|
---|
2237 | pDXContext->cot.paDSView = (SVGACOTableDXDSViewEntry *)pvCOT;
|
---|
2238 | pDXContext->cot.cDSView = cEntries;
|
---|
2239 | break;
|
---|
2240 | case SVGA_COTABLE_SRVIEW:
|
---|
2241 | pDXContext->cot.paSRView = (SVGACOTableDXSRViewEntry *)pvCOT;
|
---|
2242 | pDXContext->cot.cSRView = cEntries;
|
---|
2243 | break;
|
---|
2244 | case SVGA_COTABLE_ELEMENTLAYOUT:
|
---|
2245 | pDXContext->cot.paElementLayout = (SVGACOTableDXElementLayoutEntry *)pvCOT;
|
---|
2246 | pDXContext->cot.cElementLayout = cEntries;
|
---|
2247 | break;
|
---|
2248 | case SVGA_COTABLE_BLENDSTATE:
|
---|
2249 | pDXContext->cot.paBlendState = (SVGACOTableDXBlendStateEntry *)pvCOT;
|
---|
2250 | pDXContext->cot.cBlendState = cEntries;
|
---|
2251 | break;
|
---|
2252 | case SVGA_COTABLE_DEPTHSTENCIL:
|
---|
2253 | pDXContext->cot.paDepthStencil = (SVGACOTableDXDepthStencilEntry *)pvCOT;
|
---|
2254 | pDXContext->cot.cDepthStencil = cEntries;
|
---|
2255 | break;
|
---|
2256 | case SVGA_COTABLE_RASTERIZERSTATE:
|
---|
2257 | pDXContext->cot.paRasterizerState = (SVGACOTableDXRasterizerStateEntry *)pvCOT;
|
---|
2258 | pDXContext->cot.cRasterizerState = cEntries;
|
---|
2259 | break;
|
---|
2260 | case SVGA_COTABLE_SAMPLER:
|
---|
2261 | pDXContext->cot.paSampler = (SVGACOTableDXSamplerEntry *)pvCOT;
|
---|
2262 | pDXContext->cot.cSampler = cEntries;
|
---|
2263 | break;
|
---|
2264 | case SVGA_COTABLE_STREAMOUTPUT:
|
---|
2265 | pDXContext->cot.paStreamOutput = (SVGACOTableDXStreamOutputEntry *)pvCOT;
|
---|
2266 | pDXContext->cot.cStreamOutput = cEntries;
|
---|
2267 | break;
|
---|
2268 | case SVGA_COTABLE_DXQUERY:
|
---|
2269 | pDXContext->cot.paQuery = (SVGACOTableDXQueryEntry *)pvCOT;
|
---|
2270 | pDXContext->cot.cQuery = cEntries;
|
---|
2271 | break;
|
---|
2272 | case SVGA_COTABLE_DXSHADER:
|
---|
2273 | pDXContext->cot.paShader = (SVGACOTableDXShaderEntry *)pvCOT;
|
---|
2274 | pDXContext->cot.cShader = cEntries;
|
---|
2275 | break;
|
---|
2276 | case SVGA_COTABLE_UAVIEW:
|
---|
2277 | pDXContext->cot.paUAView = (SVGACOTableDXUAViewEntry *)pvCOT;
|
---|
2278 | pDXContext->cot.cUAView = cEntries;
|
---|
2279 | break;
|
---|
2280 | case SVGA_COTABLE_MAX: break; /* Compiler warning */
|
---|
2281 | }
|
---|
2282 | }
|
---|
2283 | else
|
---|
2284 | vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
|
---|
2285 |
|
---|
2286 | /* Notify the backend. */
|
---|
2287 | if (RT_SUCCESS(rc))
|
---|
2288 | rc = pSvgaR3State->pFuncsDX->pfnDXSetCOTable(pThisCC, pDXContext, type, cValidEntries);
|
---|
2289 |
|
---|
2290 | return rc;
|
---|
2291 | }
|
---|
2292 |
|
---|
2293 |
|
---|
2294 | int vmsvga3dDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, PVMSVGAMOB pMob)
|
---|
2295 | {
|
---|
2296 | int rc;
|
---|
2297 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2298 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCOTable, VERR_INVALID_STATE);
|
---|
2299 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2300 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2301 |
|
---|
2302 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2303 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2304 | AssertRCReturn(rc, rc);
|
---|
2305 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2306 |
|
---|
2307 | return dxSetOrGrowCOTable(pThisCC, pDXContext, pMob, pCmd->type, pCmd->validSizeInBytes, false);
|
---|
2308 | }
|
---|
2309 |
|
---|
2310 |
|
---|
2311 | int vmsvga3dDXReadbackCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackCOTable const *pCmd)
|
---|
2312 | {
|
---|
2313 | int rc;
|
---|
2314 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2315 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
2316 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2317 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2318 |
|
---|
2319 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2320 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2321 | AssertRCReturn(rc, rc);
|
---|
2322 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2323 |
|
---|
2324 | ASSERT_GUEST_RETURN(pCmd->type < RT_ELEMENTS(pDXContext->aCOTMobs), VERR_INVALID_PARAMETER);
|
---|
2325 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2326 |
|
---|
2327 | PVMSVGAMOB pMob = pDXContext->aCOTMobs[pCmd->type];
|
---|
2328 | rc = vmsvgaR3MobBackingStoreWriteToGuest(pSvgaR3State, pMob);
|
---|
2329 | return rc;
|
---|
2330 | }
|
---|
2331 |
|
---|
2332 |
|
---|
2333 | int vmsvga3dDXBufferCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2334 | {
|
---|
2335 | int rc;
|
---|
2336 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2337 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBufferCopy, VERR_INVALID_STATE);
|
---|
2338 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2339 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2340 |
|
---|
2341 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2342 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2343 | AssertRCReturn(rc, rc);
|
---|
2344 |
|
---|
2345 | rc = pSvgaR3State->pFuncsDX->pfnDXBufferCopy(pThisCC, pDXContext);
|
---|
2346 | return rc;
|
---|
2347 | }
|
---|
2348 |
|
---|
2349 |
|
---|
2350 | int vmsvga3dDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2351 | {
|
---|
2352 | int rc;
|
---|
2353 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2354 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSurfaceCopyAndReadback, VERR_INVALID_STATE);
|
---|
2355 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2356 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2357 |
|
---|
2358 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2359 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2360 | AssertRCReturn(rc, rc);
|
---|
2361 |
|
---|
2362 | rc = pSvgaR3State->pFuncsDX->pfnDXSurfaceCopyAndReadback(pThisCC, pDXContext);
|
---|
2363 | return rc;
|
---|
2364 | }
|
---|
2365 |
|
---|
2366 |
|
---|
2367 | int vmsvga3dDXMoveQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2368 | {
|
---|
2369 | int rc;
|
---|
2370 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2371 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXMoveQuery, VERR_INVALID_STATE);
|
---|
2372 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2373 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2374 |
|
---|
2375 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2376 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2377 | AssertRCReturn(rc, rc);
|
---|
2378 |
|
---|
2379 | rc = pSvgaR3State->pFuncsDX->pfnDXMoveQuery(pThisCC, pDXContext);
|
---|
2380 | return rc;
|
---|
2381 | }
|
---|
2382 |
|
---|
2383 |
|
---|
2384 | int vmsvga3dDXBindAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindAllQuery const *pCmd)
|
---|
2385 | {
|
---|
2386 | int rc;
|
---|
2387 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2388 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
2389 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2390 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2391 |
|
---|
2392 | RT_NOREF(idDXContext);
|
---|
2393 |
|
---|
2394 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2395 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2396 | AssertRCReturn(rc, rc);
|
---|
2397 |
|
---|
2398 | for (uint32_t i = 0; i < pDXContext->cot.cQuery; ++i)
|
---|
2399 | {
|
---|
2400 | SVGACOTableDXQueryEntry *pEntry = &pDXContext->cot.paQuery[i];
|
---|
2401 | if (pEntry->type != SVGA3D_QUERYTYPE_INVALID)
|
---|
2402 | pEntry->mobid = pCmd->mobid;
|
---|
2403 | }
|
---|
2404 |
|
---|
2405 | return rc;
|
---|
2406 | }
|
---|
2407 |
|
---|
2408 |
|
---|
2409 | int vmsvga3dDXReadbackAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackAllQuery const *pCmd)
|
---|
2410 | {
|
---|
2411 | int rc;
|
---|
2412 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2413 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
2414 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2415 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2416 |
|
---|
2417 | RT_NOREF(idDXContext);
|
---|
2418 |
|
---|
2419 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2420 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2421 | AssertRCReturn(rc, rc);
|
---|
2422 |
|
---|
2423 | /* "Read back cached states from the device if they exist."
|
---|
2424 | * The device does not cache queries. So this is a NOP.
|
---|
2425 | */
|
---|
2426 | RT_NOREF(pDXContext);
|
---|
2427 |
|
---|
2428 | return rc;
|
---|
2429 | }
|
---|
2430 |
|
---|
2431 |
|
---|
2432 | int vmsvga3dDXBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2433 | {
|
---|
2434 | int rc;
|
---|
2435 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2436 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindAllShader, VERR_INVALID_STATE);
|
---|
2437 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2438 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2439 |
|
---|
2440 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2441 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2442 | AssertRCReturn(rc, rc);
|
---|
2443 |
|
---|
2444 | rc = pSvgaR3State->pFuncsDX->pfnDXBindAllShader(pThisCC, pDXContext);
|
---|
2445 | return rc;
|
---|
2446 | }
|
---|
2447 |
|
---|
2448 |
|
---|
2449 | int vmsvga3dDXHint(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2450 | {
|
---|
2451 | int rc;
|
---|
2452 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2453 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXHint, VERR_INVALID_STATE);
|
---|
2454 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2455 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2456 |
|
---|
2457 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2458 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2459 | AssertRCReturn(rc, rc);
|
---|
2460 |
|
---|
2461 | rc = pSvgaR3State->pFuncsDX->pfnDXHint(pThisCC, pDXContext);
|
---|
2462 | return rc;
|
---|
2463 | }
|
---|
2464 |
|
---|
2465 |
|
---|
2466 | int vmsvga3dDXBufferUpdate(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2467 | {
|
---|
2468 | int rc;
|
---|
2469 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2470 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBufferUpdate, VERR_INVALID_STATE);
|
---|
2471 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2472 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2473 |
|
---|
2474 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2475 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2476 | AssertRCReturn(rc, rc);
|
---|
2477 |
|
---|
2478 | rc = pSvgaR3State->pFuncsDX->pfnDXBufferUpdate(pThisCC, pDXContext);
|
---|
2479 | return rc;
|
---|
2480 | }
|
---|
2481 |
|
---|
2482 |
|
---|
2483 | int vmsvga3dDXSetVSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2484 | {
|
---|
2485 | int rc;
|
---|
2486 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2487 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetVSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2488 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2489 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2490 |
|
---|
2491 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2492 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2493 | AssertRCReturn(rc, rc);
|
---|
2494 |
|
---|
2495 | rc = pSvgaR3State->pFuncsDX->pfnDXSetVSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2496 | return rc;
|
---|
2497 | }
|
---|
2498 |
|
---|
2499 |
|
---|
2500 | int vmsvga3dDXSetPSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2501 | {
|
---|
2502 | int rc;
|
---|
2503 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2504 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetPSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2505 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2506 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2507 |
|
---|
2508 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2509 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2510 | AssertRCReturn(rc, rc);
|
---|
2511 |
|
---|
2512 | rc = pSvgaR3State->pFuncsDX->pfnDXSetPSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2513 | return rc;
|
---|
2514 | }
|
---|
2515 |
|
---|
2516 |
|
---|
2517 | int vmsvga3dDXSetGSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2518 | {
|
---|
2519 | int rc;
|
---|
2520 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2521 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetGSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2522 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2523 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2524 |
|
---|
2525 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2526 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2527 | AssertRCReturn(rc, rc);
|
---|
2528 |
|
---|
2529 | rc = pSvgaR3State->pFuncsDX->pfnDXSetGSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2530 | return rc;
|
---|
2531 | }
|
---|
2532 |
|
---|
2533 |
|
---|
2534 | int vmsvga3dDXSetHSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2535 | {
|
---|
2536 | int rc;
|
---|
2537 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2538 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetHSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2539 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2540 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2541 |
|
---|
2542 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2543 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2544 | AssertRCReturn(rc, rc);
|
---|
2545 |
|
---|
2546 | rc = pSvgaR3State->pFuncsDX->pfnDXSetHSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2547 | return rc;
|
---|
2548 | }
|
---|
2549 |
|
---|
2550 |
|
---|
2551 | int vmsvga3dDXSetDSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2552 | {
|
---|
2553 | int rc;
|
---|
2554 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2555 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetDSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2556 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2557 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2558 |
|
---|
2559 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2560 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2561 | AssertRCReturn(rc, rc);
|
---|
2562 |
|
---|
2563 | rc = pSvgaR3State->pFuncsDX->pfnDXSetDSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2564 | return rc;
|
---|
2565 | }
|
---|
2566 |
|
---|
2567 |
|
---|
2568 | int vmsvga3dDXSetCSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2569 | {
|
---|
2570 | int rc;
|
---|
2571 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2572 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCSConstantBufferOffset, VERR_INVALID_STATE);
|
---|
2573 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2574 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2575 |
|
---|
2576 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2577 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2578 | AssertRCReturn(rc, rc);
|
---|
2579 |
|
---|
2580 | rc = pSvgaR3State->pFuncsDX->pfnDXSetCSConstantBufferOffset(pThisCC, pDXContext);
|
---|
2581 | return rc;
|
---|
2582 | }
|
---|
2583 |
|
---|
2584 |
|
---|
2585 | int vmsvga3dDXCondBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2586 | {
|
---|
2587 | int rc;
|
---|
2588 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2589 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXCondBindAllShader, VERR_INVALID_STATE);
|
---|
2590 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2591 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2592 |
|
---|
2593 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2594 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2595 | AssertRCReturn(rc, rc);
|
---|
2596 |
|
---|
2597 | rc = pSvgaR3State->pFuncsDX->pfnDXCondBindAllShader(pThisCC, pDXContext);
|
---|
2598 | return rc;
|
---|
2599 | }
|
---|
2600 |
|
---|
2601 |
|
---|
2602 | int vmsvga3dScreenCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2603 | {
|
---|
2604 | int rc;
|
---|
2605 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2606 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnScreenCopy, VERR_INVALID_STATE);
|
---|
2607 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2608 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2609 |
|
---|
2610 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2611 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2612 | AssertRCReturn(rc, rc);
|
---|
2613 |
|
---|
2614 | rc = pSvgaR3State->pFuncsDX->pfnScreenCopy(pThisCC, pDXContext);
|
---|
2615 | return rc;
|
---|
2616 | }
|
---|
2617 |
|
---|
2618 |
|
---|
2619 | int vmsvga3dDXGrowCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXGrowCOTable const *pCmd)
|
---|
2620 | {
|
---|
2621 | int rc;
|
---|
2622 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2623 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCOTable, VERR_INVALID_STATE);
|
---|
2624 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2625 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2626 |
|
---|
2627 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2628 | rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
|
---|
2629 | AssertRCReturn(rc, rc);
|
---|
2630 |
|
---|
2631 | PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, pCmd->mobid);
|
---|
2632 | return dxSetOrGrowCOTable(pThisCC, pDXContext, pMob, pCmd->type, pCmd->validSizeInBytes, true);
|
---|
2633 | }
|
---|
2634 |
|
---|
2635 |
|
---|
2636 | int vmsvga3dIntraSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2637 | {
|
---|
2638 | int rc;
|
---|
2639 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2640 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnIntraSurfaceCopy, VERR_INVALID_STATE);
|
---|
2641 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2642 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2643 |
|
---|
2644 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2645 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2646 | AssertRCReturn(rc, rc);
|
---|
2647 |
|
---|
2648 | rc = pSvgaR3State->pFuncsDX->pfnIntraSurfaceCopy(pThisCC, pDXContext);
|
---|
2649 | return rc;
|
---|
2650 | }
|
---|
2651 |
|
---|
2652 |
|
---|
2653 | int vmsvga3dDXResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2654 | {
|
---|
2655 | int rc;
|
---|
2656 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2657 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXResolveCopy, VERR_INVALID_STATE);
|
---|
2658 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2659 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2660 |
|
---|
2661 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2662 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2663 | AssertRCReturn(rc, rc);
|
---|
2664 |
|
---|
2665 | rc = pSvgaR3State->pFuncsDX->pfnDXResolveCopy(pThisCC, pDXContext);
|
---|
2666 | return rc;
|
---|
2667 | }
|
---|
2668 |
|
---|
2669 |
|
---|
2670 | int vmsvga3dDXPredResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2671 | {
|
---|
2672 | int rc;
|
---|
2673 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2674 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredResolveCopy, VERR_INVALID_STATE);
|
---|
2675 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2676 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2677 |
|
---|
2678 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2679 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2680 | AssertRCReturn(rc, rc);
|
---|
2681 |
|
---|
2682 | rc = pSvgaR3State->pFuncsDX->pfnDXPredResolveCopy(pThisCC, pDXContext);
|
---|
2683 | return rc;
|
---|
2684 | }
|
---|
2685 |
|
---|
2686 |
|
---|
2687 | int vmsvga3dDXPredConvertRegion(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2688 | {
|
---|
2689 | int rc;
|
---|
2690 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2691 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredConvertRegion, VERR_INVALID_STATE);
|
---|
2692 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2693 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2694 |
|
---|
2695 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2696 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2697 | AssertRCReturn(rc, rc);
|
---|
2698 |
|
---|
2699 | rc = pSvgaR3State->pFuncsDX->pfnDXPredConvertRegion(pThisCC, pDXContext);
|
---|
2700 | return rc;
|
---|
2701 | }
|
---|
2702 |
|
---|
2703 |
|
---|
2704 | int vmsvga3dDXPredConvert(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2705 | {
|
---|
2706 | int rc;
|
---|
2707 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2708 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredConvert, VERR_INVALID_STATE);
|
---|
2709 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2710 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2711 |
|
---|
2712 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2713 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2714 | AssertRCReturn(rc, rc);
|
---|
2715 |
|
---|
2716 | rc = pSvgaR3State->pFuncsDX->pfnDXPredConvert(pThisCC, pDXContext);
|
---|
2717 | return rc;
|
---|
2718 | }
|
---|
2719 |
|
---|
2720 |
|
---|
2721 | int vmsvga3dWholeSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2722 | {
|
---|
2723 | int rc;
|
---|
2724 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2725 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnWholeSurfaceCopy, VERR_INVALID_STATE);
|
---|
2726 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2727 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2728 |
|
---|
2729 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2730 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2731 | AssertRCReturn(rc, rc);
|
---|
2732 |
|
---|
2733 | rc = pSvgaR3State->pFuncsDX->pfnWholeSurfaceCopy(pThisCC, pDXContext);
|
---|
2734 | return rc;
|
---|
2735 | }
|
---|
2736 |
|
---|
2737 |
|
---|
2738 | int vmsvga3dDXDefineUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineUAView const *pCmd)
|
---|
2739 | {
|
---|
2740 | int rc;
|
---|
2741 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2742 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineUAView, VERR_INVALID_STATE);
|
---|
2743 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2744 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2745 |
|
---|
2746 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2747 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2748 | AssertRCReturn(rc, rc);
|
---|
2749 |
|
---|
2750 | SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
|
---|
2751 |
|
---|
2752 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
2753 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
2754 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2755 |
|
---|
2756 | SVGACOTableDXUAViewEntry *pEntry = &pDXContext->cot.paUAView[uaViewId];
|
---|
2757 | pEntry->sid = pCmd->sid;
|
---|
2758 | pEntry->format = pCmd->format;
|
---|
2759 | pEntry->resourceDimension = pCmd->resourceDimension;
|
---|
2760 | pEntry->desc = pCmd->desc;
|
---|
2761 | pEntry->structureCount = 0;
|
---|
2762 |
|
---|
2763 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineUAView(pThisCC, pDXContext, uaViewId, pEntry);
|
---|
2764 | return rc;
|
---|
2765 | }
|
---|
2766 |
|
---|
2767 |
|
---|
2768 | int vmsvga3dDXDestroyUAView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyUAView const *pCmd)
|
---|
2769 | {
|
---|
2770 | int rc;
|
---|
2771 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2772 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyUAView, VERR_INVALID_STATE);
|
---|
2773 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2774 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2775 |
|
---|
2776 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2777 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2778 | AssertRCReturn(rc, rc);
|
---|
2779 |
|
---|
2780 | SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
|
---|
2781 |
|
---|
2782 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
2783 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
2784 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2785 |
|
---|
2786 | SVGACOTableDXUAViewEntry *pEntry = &pDXContext->cot.paUAView[uaViewId];
|
---|
2787 | RT_ZERO(*pEntry);
|
---|
2788 |
|
---|
2789 | rc = pSvgaR3State->pFuncsDX->pfnDXDestroyUAView(pThisCC, pDXContext, uaViewId);
|
---|
2790 | return rc;
|
---|
2791 | }
|
---|
2792 |
|
---|
2793 |
|
---|
2794 | int vmsvga3dDXClearUAViewUint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewUint const *pCmd)
|
---|
2795 | {
|
---|
2796 | int rc;
|
---|
2797 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2798 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearUAViewUint, VERR_INVALID_STATE);
|
---|
2799 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2800 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2801 |
|
---|
2802 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2803 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2804 | AssertRCReturn(rc, rc);
|
---|
2805 |
|
---|
2806 | SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
|
---|
2807 |
|
---|
2808 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
2809 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
2810 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2811 |
|
---|
2812 | rc = pSvgaR3State->pFuncsDX->pfnDXClearUAViewUint(pThisCC, pDXContext, uaViewId, pCmd->value.value);
|
---|
2813 | return rc;
|
---|
2814 | }
|
---|
2815 |
|
---|
2816 |
|
---|
2817 | int vmsvga3dDXClearUAViewFloat(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewFloat const *pCmd)
|
---|
2818 | {
|
---|
2819 | int rc;
|
---|
2820 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2821 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearUAViewFloat, VERR_INVALID_STATE);
|
---|
2822 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2823 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2824 |
|
---|
2825 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2826 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2827 | AssertRCReturn(rc, rc);
|
---|
2828 |
|
---|
2829 | SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
|
---|
2830 |
|
---|
2831 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
2832 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
2833 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2834 |
|
---|
2835 | rc = pSvgaR3State->pFuncsDX->pfnDXClearUAViewFloat(pThisCC, pDXContext, uaViewId, pCmd->value.value);
|
---|
2836 | return rc;
|
---|
2837 | }
|
---|
2838 |
|
---|
2839 |
|
---|
2840 | int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCopyStructureCount const *pCmd)
|
---|
2841 | {
|
---|
2842 | int rc;
|
---|
2843 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2844 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount, VERR_INVALID_STATE);
|
---|
2845 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2846 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2847 |
|
---|
2848 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2849 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2850 | AssertRCReturn(rc, rc);
|
---|
2851 |
|
---|
2852 | SVGA3dUAViewId const uaViewId = pCmd->srcUAViewId;
|
---|
2853 |
|
---|
2854 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
2855 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
2856 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2857 |
|
---|
2858 | rc = pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount(pThisCC, pDXContext, uaViewId, pCmd->destSid, pCmd->destByteOffset);
|
---|
2859 | return rc;
|
---|
2860 | }
|
---|
2861 |
|
---|
2862 |
|
---|
2863 | int vmsvga3dDXSetUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetUAViews const *pCmd, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId)
|
---|
2864 | {
|
---|
2865 | int rc;
|
---|
2866 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2867 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetUAViews, VERR_INVALID_STATE);
|
---|
2868 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2869 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2870 |
|
---|
2871 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2872 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2873 | AssertRCReturn(rc, rc);
|
---|
2874 |
|
---|
2875 | ASSERT_GUEST_RETURN(pCmd->uavSpliceIndex <= SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS, VERR_INVALID_PARAMETER);
|
---|
2876 | ASSERT_GUEST_RETURN(cUAViewId <= SVGA3D_DX11_1_MAX_UAVIEWS, VERR_INVALID_PARAMETER);
|
---|
2877 | for (uint32_t i = 0; i < cUAViewId; ++i)
|
---|
2878 | ASSERT_GUEST_RETURN( paUAViewId[i] < pDXContext->cot.cUAView
|
---|
2879 | || paUAViewId[i] == SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER);
|
---|
2880 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
2881 |
|
---|
2882 | for (uint32_t i = 0; i < cUAViewId; ++i)
|
---|
2883 | {
|
---|
2884 | SVGA3dUAViewId const uaViewId = paUAViewId[i];
|
---|
2885 | pDXContext->svgaDXContext.uaViewIds[i] = uaViewId;
|
---|
2886 | }
|
---|
2887 | pDXContext->svgaDXContext.uavSpliceIndex = pCmd->uavSpliceIndex;
|
---|
2888 |
|
---|
2889 | rc = pSvgaR3State->pFuncsDX->pfnDXSetUAViews(pThisCC, pDXContext, pCmd->uavSpliceIndex, cUAViewId, paUAViewId);
|
---|
2890 | return rc;
|
---|
2891 | }
|
---|
2892 |
|
---|
2893 |
|
---|
2894 | int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstancedIndirect const *pCmd)
|
---|
2895 | {
|
---|
2896 | int rc;
|
---|
2897 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2898 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect, VERR_INVALID_STATE);
|
---|
2899 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2900 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2901 |
|
---|
2902 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2903 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2904 | AssertRCReturn(rc, rc);
|
---|
2905 |
|
---|
2906 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect(pThisCC, pDXContext, pCmd->argsBufferSid, pCmd->byteOffsetForArgs);
|
---|
2907 | return rc;
|
---|
2908 | }
|
---|
2909 |
|
---|
2910 |
|
---|
2911 | int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstancedIndirect const *pCmd)
|
---|
2912 | {
|
---|
2913 | int rc;
|
---|
2914 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2915 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect, VERR_INVALID_STATE);
|
---|
2916 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2917 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2918 |
|
---|
2919 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2920 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2921 | AssertRCReturn(rc, rc);
|
---|
2922 |
|
---|
2923 | rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect(pThisCC, pDXContext, pCmd->argsBufferSid, pCmd->byteOffsetForArgs);
|
---|
2924 | return rc;
|
---|
2925 | }
|
---|
2926 |
|
---|
2927 |
|
---|
2928 | int vmsvga3dDXDispatch(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatch const *pCmd)
|
---|
2929 | {
|
---|
2930 | int rc;
|
---|
2931 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2932 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDispatch, VERR_INVALID_STATE);
|
---|
2933 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2934 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2935 |
|
---|
2936 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2937 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2938 | AssertRCReturn(rc, rc);
|
---|
2939 |
|
---|
2940 | rc = pSvgaR3State->pFuncsDX->pfnDXDispatch(pThisCC, pDXContext, pCmd->threadGroupCountX, pCmd->threadGroupCountY, pCmd->threadGroupCountZ);
|
---|
2941 | return rc;
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 |
|
---|
2945 | int vmsvga3dDXDispatchIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2946 | {
|
---|
2947 | int rc;
|
---|
2948 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2949 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDispatchIndirect, VERR_INVALID_STATE);
|
---|
2950 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2951 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2952 |
|
---|
2953 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2954 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2955 | AssertRCReturn(rc, rc);
|
---|
2956 |
|
---|
2957 | rc = pSvgaR3State->pFuncsDX->pfnDXDispatchIndirect(pThisCC, pDXContext);
|
---|
2958 | return rc;
|
---|
2959 | }
|
---|
2960 |
|
---|
2961 |
|
---|
2962 | int vmsvga3dWriteZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2963 | {
|
---|
2964 | int rc;
|
---|
2965 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2966 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnWriteZeroSurface, VERR_INVALID_STATE);
|
---|
2967 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2968 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2969 |
|
---|
2970 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2971 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2972 | AssertRCReturn(rc, rc);
|
---|
2973 |
|
---|
2974 | rc = pSvgaR3State->pFuncsDX->pfnWriteZeroSurface(pThisCC, pDXContext);
|
---|
2975 | return rc;
|
---|
2976 | }
|
---|
2977 |
|
---|
2978 |
|
---|
2979 | int vmsvga3dHintZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2980 | {
|
---|
2981 | int rc;
|
---|
2982 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
2983 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnHintZeroSurface, VERR_INVALID_STATE);
|
---|
2984 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
2985 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
2986 |
|
---|
2987 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
2988 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
2989 | AssertRCReturn(rc, rc);
|
---|
2990 |
|
---|
2991 | rc = pSvgaR3State->pFuncsDX->pfnHintZeroSurface(pThisCC, pDXContext);
|
---|
2992 | return rc;
|
---|
2993 | }
|
---|
2994 |
|
---|
2995 |
|
---|
2996 | int vmsvga3dDXTransferToBuffer(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
2997 | {
|
---|
2998 | int rc;
|
---|
2999 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3000 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXTransferToBuffer, VERR_INVALID_STATE);
|
---|
3001 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3002 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3003 |
|
---|
3004 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3005 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3006 | AssertRCReturn(rc, rc);
|
---|
3007 |
|
---|
3008 | rc = pSvgaR3State->pFuncsDX->pfnDXTransferToBuffer(pThisCC, pDXContext);
|
---|
3009 | return rc;
|
---|
3010 | }
|
---|
3011 |
|
---|
3012 |
|
---|
3013 | int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStructureCount const *pCmd)
|
---|
3014 | {
|
---|
3015 | int rc;
|
---|
3016 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3017 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
3018 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3019 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3020 |
|
---|
3021 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3022 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3023 | AssertRCReturn(rc, rc);
|
---|
3024 |
|
---|
3025 | SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
|
---|
3026 |
|
---|
3027 | ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
|
---|
3028 | ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
|
---|
3029 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3030 |
|
---|
3031 | SVGACOTableDXUAViewEntry *pEntry = &pDXContext->cot.paUAView[uaViewId];
|
---|
3032 | pEntry->structureCount = pCmd->structureCount;
|
---|
3033 |
|
---|
3034 | return VINF_SUCCESS;
|
---|
3035 | }
|
---|
3036 |
|
---|
3037 |
|
---|
3038 | int vmsvga3dLogicOpsBitBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3039 | {
|
---|
3040 | int rc;
|
---|
3041 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3042 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsBitBlt, VERR_INVALID_STATE);
|
---|
3043 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3044 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3045 |
|
---|
3046 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3047 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3048 | AssertRCReturn(rc, rc);
|
---|
3049 |
|
---|
3050 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsBitBlt(pThisCC, pDXContext);
|
---|
3051 | return rc;
|
---|
3052 | }
|
---|
3053 |
|
---|
3054 |
|
---|
3055 | int vmsvga3dLogicOpsTransBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3056 | {
|
---|
3057 | int rc;
|
---|
3058 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3059 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsTransBlt, VERR_INVALID_STATE);
|
---|
3060 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3061 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3062 |
|
---|
3063 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3064 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3065 | AssertRCReturn(rc, rc);
|
---|
3066 |
|
---|
3067 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsTransBlt(pThisCC, pDXContext);
|
---|
3068 | return rc;
|
---|
3069 | }
|
---|
3070 |
|
---|
3071 |
|
---|
3072 | int vmsvga3dLogicOpsStretchBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3073 | {
|
---|
3074 | int rc;
|
---|
3075 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3076 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsStretchBlt, VERR_INVALID_STATE);
|
---|
3077 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3078 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3079 |
|
---|
3080 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3081 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3082 | AssertRCReturn(rc, rc);
|
---|
3083 |
|
---|
3084 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsStretchBlt(pThisCC, pDXContext);
|
---|
3085 | return rc;
|
---|
3086 | }
|
---|
3087 |
|
---|
3088 |
|
---|
3089 | int vmsvga3dLogicOpsColorFill(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3090 | {
|
---|
3091 | int rc;
|
---|
3092 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3093 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsColorFill, VERR_INVALID_STATE);
|
---|
3094 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3095 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3096 |
|
---|
3097 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3098 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3099 | AssertRCReturn(rc, rc);
|
---|
3100 |
|
---|
3101 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsColorFill(pThisCC, pDXContext);
|
---|
3102 | return rc;
|
---|
3103 | }
|
---|
3104 |
|
---|
3105 |
|
---|
3106 | int vmsvga3dLogicOpsAlphaBlend(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3107 | {
|
---|
3108 | int rc;
|
---|
3109 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3110 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsAlphaBlend, VERR_INVALID_STATE);
|
---|
3111 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3112 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3113 |
|
---|
3114 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3115 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3116 | AssertRCReturn(rc, rc);
|
---|
3117 |
|
---|
3118 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsAlphaBlend(pThisCC, pDXContext);
|
---|
3119 | return rc;
|
---|
3120 | }
|
---|
3121 |
|
---|
3122 |
|
---|
3123 | int vmsvga3dLogicOpsClearTypeBlend(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3124 | {
|
---|
3125 | int rc;
|
---|
3126 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3127 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsClearTypeBlend, VERR_INVALID_STATE);
|
---|
3128 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3129 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3130 |
|
---|
3131 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3132 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3133 | AssertRCReturn(rc, rc);
|
---|
3134 |
|
---|
3135 | rc = pSvgaR3State->pFuncsDX->pfnLogicOpsClearTypeBlend(pThisCC, pDXContext);
|
---|
3136 | return rc;
|
---|
3137 | }
|
---|
3138 |
|
---|
3139 |
|
---|
3140 | int vmsvga3dDXSetCSUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetCSUAViews const *pCmd, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId)
|
---|
3141 | {
|
---|
3142 | int rc;
|
---|
3143 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3144 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCSUAViews, VERR_INVALID_STATE);
|
---|
3145 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3146 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3147 |
|
---|
3148 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3149 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3150 | AssertRCReturn(rc, rc);
|
---|
3151 |
|
---|
3152 | ASSERT_GUEST_RETURN(pCmd->startIndex < SVGA3D_DX11_1_MAX_UAVIEWS, VERR_INVALID_PARAMETER);
|
---|
3153 | ASSERT_GUEST_RETURN(cUAViewId <= SVGA3D_DX11_1_MAX_UAVIEWS - pCmd->startIndex, VERR_INVALID_PARAMETER);
|
---|
3154 | for (uint32_t i = 0; i < cUAViewId; ++i)
|
---|
3155 | ASSERT_GUEST_RETURN( paUAViewId[i] < pDXContext->cot.cUAView
|
---|
3156 | || paUAViewId[i] == SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER);
|
---|
3157 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3158 |
|
---|
3159 | for (uint32_t i = 0; i < cUAViewId; ++i)
|
---|
3160 | {
|
---|
3161 | SVGA3dUAViewId const uaViewId = paUAViewId[i];
|
---|
3162 | pDXContext->svgaDXContext.csuaViewIds[pCmd->startIndex + i] = uaViewId;
|
---|
3163 | }
|
---|
3164 |
|
---|
3165 | rc = pSvgaR3State->pFuncsDX->pfnDXSetCSUAViews(pThisCC, pDXContext, pCmd->startIndex, cUAViewId, paUAViewId);
|
---|
3166 | return rc;
|
---|
3167 | }
|
---|
3168 |
|
---|
3169 |
|
---|
3170 | int vmsvga3dDXSetMinLOD(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3171 | {
|
---|
3172 | int rc;
|
---|
3173 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3174 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetMinLOD, VERR_INVALID_STATE);
|
---|
3175 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3176 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3177 |
|
---|
3178 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3179 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3180 | AssertRCReturn(rc, rc);
|
---|
3181 |
|
---|
3182 | rc = pSvgaR3State->pFuncsDX->pfnDXSetMinLOD(pThisCC, pDXContext);
|
---|
3183 | return rc;
|
---|
3184 | }
|
---|
3185 |
|
---|
3186 |
|
---|
3187 | int vmsvga3dDXDefineStreamOutputWithMob(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutputWithMob const *pCmd)
|
---|
3188 | {
|
---|
3189 | int rc;
|
---|
3190 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3191 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
3192 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3193 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3194 |
|
---|
3195 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3196 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3197 | AssertRCReturn(rc, rc);
|
---|
3198 |
|
---|
3199 | SVGA3dStreamOutputId const soid = pCmd->soid;
|
---|
3200 |
|
---|
3201 | ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
|
---|
3202 | ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
|
---|
3203 | ASSERT_GUEST_RETURN(pCmd->numOutputStreamEntries < SVGA3D_MAX_STREAMOUT_DECLS, VERR_INVALID_PARAMETER);
|
---|
3204 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3205 |
|
---|
3206 | SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
|
---|
3207 | pEntry->numOutputStreamEntries = pCmd->numOutputStreamEntries;
|
---|
3208 | RT_ZERO(pEntry->decl);
|
---|
3209 | memcpy(pEntry->streamOutputStrideInBytes, pCmd->streamOutputStrideInBytes, sizeof(pEntry->streamOutputStrideInBytes));
|
---|
3210 | pEntry->rasterizedStream = pCmd->rasterizedStream;
|
---|
3211 | pEntry->numOutputStreamStrides = pCmd->numOutputStreamStrides;
|
---|
3212 | pEntry->mobid = SVGA_ID_INVALID;
|
---|
3213 | pEntry->offsetInBytes = 0;
|
---|
3214 | pEntry->usesMob = 1;
|
---|
3215 | pEntry->pad0 = 0;
|
---|
3216 | pEntry->pad1 = 0;
|
---|
3217 | RT_ZERO(pEntry->pad2);
|
---|
3218 |
|
---|
3219 | rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput(pThisCC, pDXContext, soid, pEntry);
|
---|
3220 | return rc;
|
---|
3221 | }
|
---|
3222 |
|
---|
3223 |
|
---|
3224 | int vmsvga3dDXSetShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3225 | {
|
---|
3226 | int rc;
|
---|
3227 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3228 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShaderIface, VERR_INVALID_STATE);
|
---|
3229 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3230 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3231 |
|
---|
3232 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3233 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3234 | AssertRCReturn(rc, rc);
|
---|
3235 |
|
---|
3236 | rc = pSvgaR3State->pFuncsDX->pfnDXSetShaderIface(pThisCC, pDXContext);
|
---|
3237 | return rc;
|
---|
3238 | }
|
---|
3239 |
|
---|
3240 |
|
---|
3241 | int vmsvga3dDXBindStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXBindStreamOutput const *pCmd)
|
---|
3242 | {
|
---|
3243 | int rc;
|
---|
3244 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3245 | AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
|
---|
3246 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3247 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3248 |
|
---|
3249 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3250 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3251 | AssertRCReturn(rc, rc);
|
---|
3252 | SVGA3dStreamOutputId const soid = pCmd->soid;
|
---|
3253 |
|
---|
3254 | ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
|
---|
3255 | ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
|
---|
3256 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3257 |
|
---|
3258 | SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
|
---|
3259 |
|
---|
3260 | ASSERT_GUEST_RETURN(pCmd->sizeInBytes >= pEntry->numOutputStreamEntries * sizeof(SVGA3dStreamOutputDeclarationEntry), VERR_INVALID_PARAMETER);
|
---|
3261 | ASSERT_GUEST(pEntry->usesMob);
|
---|
3262 |
|
---|
3263 | pEntry->mobid = pCmd->mobid;
|
---|
3264 | pEntry->offsetInBytes = pCmd->offsetInBytes;
|
---|
3265 | pEntry->usesMob = 1;
|
---|
3266 |
|
---|
3267 | return VINF_SUCCESS;
|
---|
3268 | }
|
---|
3269 |
|
---|
3270 |
|
---|
3271 | int vmsvga3dSurfaceStretchBltNonMSToMS(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3272 | {
|
---|
3273 | int rc;
|
---|
3274 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3275 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnSurfaceStretchBltNonMSToMS, VERR_INVALID_STATE);
|
---|
3276 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3277 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3278 |
|
---|
3279 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3280 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3281 | AssertRCReturn(rc, rc);
|
---|
3282 |
|
---|
3283 | rc = pSvgaR3State->pFuncsDX->pfnSurfaceStretchBltNonMSToMS(pThisCC, pDXContext);
|
---|
3284 | return rc;
|
---|
3285 | }
|
---|
3286 |
|
---|
3287 |
|
---|
3288 | int vmsvga3dDXBindShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext)
|
---|
3289 | {
|
---|
3290 | int rc;
|
---|
3291 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3292 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindShaderIface, VERR_INVALID_STATE);
|
---|
3293 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3294 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3295 |
|
---|
3296 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3297 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3298 | AssertRCReturn(rc, rc);
|
---|
3299 |
|
---|
3300 | rc = pSvgaR3State->pFuncsDX->pfnDXBindShaderIface(pThisCC, pDXContext);
|
---|
3301 | return rc;
|
---|
3302 | }
|
---|
3303 |
|
---|
3304 |
|
---|
3305 | int vmsvga3dVBDXClearRenderTargetViewRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdVBDXClearRenderTargetViewRegion const *pCmd, uint32_t cRect, SVGASignedRect const *paRect)
|
---|
3306 | {
|
---|
3307 | int rc;
|
---|
3308 | PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
|
---|
3309 | AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnVBDXClearRenderTargetViewRegion, VERR_INVALID_STATE);
|
---|
3310 | PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
|
---|
3311 | AssertReturn(p3dState, VERR_INVALID_STATE);
|
---|
3312 |
|
---|
3313 | PVMSVGA3DDXCONTEXT pDXContext;
|
---|
3314 | rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
|
---|
3315 | AssertRCReturn(rc, rc);
|
---|
3316 |
|
---|
3317 | SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->viewId;
|
---|
3318 |
|
---|
3319 | ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
|
---|
3320 | ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
|
---|
3321 | ASSERT_GUEST_RETURN(cRect <= 65536, VERR_INVALID_PARAMETER); /* Arbitrary limit. */
|
---|
3322 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
3323 |
|
---|
3324 | rc = pSvgaR3State->pFuncsDX->pfnVBDXClearRenderTargetViewRegion(pThisCC, pDXContext, renderTargetViewId, &pCmd->color, cRect, paRect);
|
---|
3325 | return rc;
|
---|
3326 | }
|
---|
3327 |
|
---|