VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp@ 91605

Last change on this file since 91605 was 91507, checked in by vboxsync, 3 years ago

Devices/Graphics: DUMP_BITMAPS update: bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 107.2 KB
Line 
1/* $Id: DevVGA-SVGA3d-dx.cpp 91507 2021-10-01 10:27:12Z vboxsync $ */
2/** @file
3 * DevSVGA3d - VMWare SVGA device, 3D parts - Common code for DX backend interface.
4 */
5
6/*
7 * Copyright (C) 2020-2021 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
23#include <VBox/AssertGuest.h>
24#include <iprt/errcore.h>
25#include <VBox/log.h>
26#include <VBox/vmm/pdmdev.h>
27
28#include <iprt/assert.h>
29#include <iprt/mem.h>
30
31#include <VBoxVideo.h> /* required by DevVGA.h */
32
33/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
34#include "DevVGA.h"
35
36#include "DevVGA-SVGA.h"
37#include "DevVGA-SVGA3d.h"
38#include "DevVGA-SVGA3d-internal.h"
39#include "DevVGA-SVGA-internal.h"
40
41
42int vmsvga3dDXUnbindContext(PVGASTATECC pThisCC, uint32_t cid, SVGADXContextMobFormat *pSvgaDXContext)
43{
44 int rc;
45 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
46 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindContext, VERR_INVALID_STATE);
47 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
48 AssertReturn(p3dState, VERR_INVALID_STATE);
49
50 PVMSVGA3DDXCONTEXT pDXContext;
51 rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
52 AssertRCReturn(rc, rc);
53
54 /* Copy the host structure back to the guest memory. */
55 memcpy(pSvgaDXContext, &pDXContext->svgaDXContext, sizeof(*pSvgaDXContext));
56
57 return rc;
58}
59
60
61/**
62 * Create a new 3D DX context.
63 *
64 * @returns VBox status code.
65 * @param pThisCC The VGA/VMSVGA state for ring-3.
66 * @param cid Context id to be created.
67 */
68int vmsvga3dDXDefineContext(PVGASTATECC pThisCC, uint32_t cid)
69{
70 int rc;
71 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
72 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineContext, VERR_INVALID_STATE);
73 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
74 AssertReturn(p3dState, VERR_INVALID_STATE);
75
76 PVMSVGA3DDXCONTEXT pDXContext;
77
78 LogFunc(("cid %d\n", cid));
79
80 AssertReturn(cid < SVGA3D_MAX_CONTEXT_IDS, VERR_INVALID_PARAMETER);
81
82 if (cid >= p3dState->cDXContexts)
83 {
84 /* Grow the array. */
85 uint32_t cNew = RT_ALIGN(cid + 15, 16);
86 void *pvNew = RTMemRealloc(p3dState->papDXContexts, sizeof(p3dState->papDXContexts[0]) * cNew);
87 AssertReturn(pvNew, VERR_NO_MEMORY);
88 p3dState->papDXContexts = (PVMSVGA3DDXCONTEXT *)pvNew;
89 while (p3dState->cDXContexts < cNew)
90 {
91 pDXContext = (PVMSVGA3DDXCONTEXT)RTMemAllocZ(sizeof(*pDXContext));
92 AssertReturn(pDXContext, VERR_NO_MEMORY);
93 pDXContext->cid = SVGA3D_INVALID_ID;
94 p3dState->papDXContexts[p3dState->cDXContexts++] = pDXContext;
95 }
96 }
97 /* If one already exists with this id, then destroy it now. */
98 if (p3dState->papDXContexts[cid]->cid != SVGA3D_INVALID_ID)
99 vmsvga3dDXDestroyContext(pThisCC, cid);
100
101 pDXContext = p3dState->papDXContexts[cid];
102 memset(pDXContext, 0, sizeof(*pDXContext));
103 /* 0xFFFFFFFF (SVGA_ID_INVALID) is a better initial value than 0 for most of svgaDXContext fields. */
104 memset(&pDXContext->svgaDXContext, 0xFF, sizeof(pDXContext->svgaDXContext));
105 pDXContext->cid = cid;
106
107 /* Init the backend specific data. */
108 rc = pSvgaR3State->pFuncsDX->pfnDXDefineContext(pThisCC, pDXContext);
109
110 /* Cleanup on failure. */
111 if (RT_FAILURE(rc))
112 vmsvga3dDXDestroyContext(pThisCC, cid);
113
114 return rc;
115}
116
117
118int vmsvga3dDXDestroyContext(PVGASTATECC pThisCC, uint32_t cid)
119{
120 int rc;
121 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
122 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyContext, VERR_INVALID_STATE);
123 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
124 AssertReturn(p3dState, VERR_INVALID_STATE);
125
126 PVMSVGA3DDXCONTEXT pDXContext;
127 rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
128 AssertRCReturn(rc, rc);
129
130 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyContext(pThisCC, pDXContext);
131 return rc;
132}
133
134
135int vmsvga3dDXBindContext(PVGASTATECC pThisCC, uint32_t cid, SVGADXContextMobFormat *pSvgaDXContext)
136{
137 int rc;
138 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
139 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindContext, VERR_INVALID_STATE);
140 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
141 AssertReturn(p3dState, VERR_INVALID_STATE);
142
143 PVMSVGA3DDXCONTEXT pDXContext;
144 rc = vmsvga3dDXContextFromCid(p3dState, cid, &pDXContext);
145 AssertRCReturn(rc, rc);
146
147 if (pSvgaDXContext)
148 memcpy(&pDXContext->svgaDXContext, pSvgaDXContext, sizeof(*pSvgaDXContext));
149
150 rc = pSvgaR3State->pFuncsDX->pfnDXBindContext(pThisCC, pDXContext);
151 return rc;
152}
153
154
155int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGADXContextMobFormat *pSvgaDXContext)
156{
157 int rc;
158 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
159 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXReadbackContext, VERR_INVALID_STATE);
160 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
161 AssertReturn(p3dState, VERR_INVALID_STATE);
162
163 PVMSVGA3DDXCONTEXT pDXContext;
164 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
165 AssertRCReturn(rc, rc);
166
167 rc = pSvgaR3State->pFuncsDX->pfnDXReadbackContext(pThisCC, pDXContext);
168 if (RT_SUCCESS(rc))
169 memcpy(pSvgaDXContext, &pDXContext->svgaDXContext, sizeof(*pSvgaDXContext));
170 return rc;
171}
172
173
174int vmsvga3dDXInvalidateContext(PVGASTATECC pThisCC, uint32_t idDXContext)
175{
176 int rc;
177 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
178 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXInvalidateContext, VERR_INVALID_STATE);
179 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
180 AssertReturn(p3dState, VERR_INVALID_STATE);
181
182 PVMSVGA3DDXCONTEXT pDXContext;
183 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
184 AssertRCReturn(rc, rc);
185
186 rc = pSvgaR3State->pFuncsDX->pfnDXInvalidateContext(pThisCC, pDXContext);
187 return rc;
188}
189
190
191int vmsvga3dDXSetSingleConstantBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSingleConstantBuffer const *pCmd)
192{
193 int rc;
194 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
195 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSingleConstantBuffer, VERR_INVALID_STATE);
196 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
197 AssertReturn(p3dState, VERR_INVALID_STATE);
198
199 PVMSVGA3DDXCONTEXT pDXContext;
200 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
201 AssertRCReturn(rc, rc);
202
203 ASSERT_GUEST_RETURN(pCmd->slot < SVGA3D_DX_MAX_CONSTBUFFERS, VERR_INVALID_PARAMETER);
204 ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
205 RT_UNTRUSTED_VALIDATED_FENCE();
206
207 rc = pSvgaR3State->pFuncsDX->pfnDXSetSingleConstantBuffer(pThisCC, pDXContext, pCmd->slot, pCmd->type, pCmd->sid, pCmd->offsetInBytes, pCmd->sizeInBytes);
208 if (RT_SUCCESS(rc))
209 {
210 uint32_t const idxShaderState = pCmd->type - SVGA3D_SHADERTYPE_MIN;
211 SVGA3dConstantBufferBinding *pCBB = &pDXContext->svgaDXContext.shaderState[idxShaderState].constantBuffers[pCmd->slot];
212 pCBB->sid = pCmd->sid;
213 pCBB->offsetInBytes = pCmd->offsetInBytes;
214 pCBB->sizeInBytes = pCmd->sizeInBytes;
215 }
216 return rc;
217}
218
219
220int vmsvga3dDXSetShaderResources(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShaderResources const *pCmd, uint32_t cShaderResourceViewId, SVGA3dShaderResourceViewId const *paShaderResourceViewId)
221{
222 int rc;
223 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
224 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShaderResources, VERR_INVALID_STATE);
225 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
226 AssertReturn(p3dState, VERR_INVALID_STATE);
227
228 PVMSVGA3DDXCONTEXT pDXContext;
229 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
230 AssertRCReturn(rc, rc);
231
232 ASSERT_GUEST_RETURN(pCmd->startView < SVGA3D_DX_MAX_SRVIEWS, VERR_INVALID_PARAMETER);
233 ASSERT_GUEST_RETURN(cShaderResourceViewId <= SVGA3D_DX_MAX_SRVIEWS - pCmd->startView, VERR_INVALID_PARAMETER);
234 ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
235 ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
236 for (uint32_t i = 0; i < cShaderResourceViewId; ++i)
237 ASSERT_GUEST_RETURN( paShaderResourceViewId[i] < pDXContext->cot.cSRView
238 || paShaderResourceViewId[i] == SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER);
239 RT_UNTRUSTED_VALIDATED_FENCE();
240
241 rc = pSvgaR3State->pFuncsDX->pfnDXSetShaderResources(pThisCC, pDXContext, pCmd->startView, pCmd->type, cShaderResourceViewId, paShaderResourceViewId);
242 return rc;
243}
244
245
246int vmsvga3dDXSetShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetShader const *pCmd)
247{
248 int rc;
249 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
250 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShader, VERR_INVALID_STATE);
251 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
252 AssertReturn(p3dState, VERR_INVALID_STATE);
253
254 PVMSVGA3DDXCONTEXT pDXContext;
255 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
256 AssertRCReturn(rc, rc);
257
258 ASSERT_GUEST_RETURN( pCmd->shaderId < pDXContext->cot.cShader
259 || pCmd->shaderId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
260 RT_UNTRUSTED_VALIDATED_FENCE();
261
262 PVMSVGA3DSHADER pShader;
263 if (pCmd->shaderId != SVGA_ID_INVALID)
264 {
265 SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[pCmd->shaderId];
266 ASSERT_GUEST_RETURN(pEntry->type == pCmd->type, VERR_INVALID_PARAMETER);
267 RT_UNTRUSTED_VALIDATED_FENCE();
268
269 pShader = &pDXContext->paShader[pCmd->shaderId];
270 }
271 else
272 pShader = NULL;
273
274 rc = pSvgaR3State->pFuncsDX->pfnDXSetShader(pThisCC, pDXContext, pCmd->type, pShader);
275 return rc;
276}
277
278
279int vmsvga3dDXSetSamplers(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSamplers const *pCmd, uint32_t cSamplerId, SVGA3dSamplerId const *paSamplerId)
280{
281 int rc;
282 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
283 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSamplers, VERR_INVALID_STATE);
284 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
285 AssertReturn(p3dState, VERR_INVALID_STATE);
286
287 PVMSVGA3DDXCONTEXT pDXContext;
288 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
289 AssertRCReturn(rc, rc);
290
291 ASSERT_GUEST_RETURN(pCmd->startSampler < SVGA3D_DX_MAX_SAMPLERS, VERR_INVALID_PARAMETER);
292 ASSERT_GUEST_RETURN(cSamplerId <= SVGA3D_DX_MAX_SAMPLERS - pCmd->startSampler, VERR_INVALID_PARAMETER);
293 ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
294 ASSERT_GUEST_RETURN(pDXContext->cot.paSampler, VERR_INVALID_STATE);
295 for (uint32_t i = 0; i < cSamplerId; ++i)
296 {
297 SVGA3dSamplerId const samplerId = paSamplerId[i];
298 ASSERT_GUEST_RETURN( samplerId < pDXContext->cot.cSampler
299 || samplerId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
300 }
301 RT_UNTRUSTED_VALIDATED_FENCE();
302
303 rc = pSvgaR3State->pFuncsDX->pfnDXSetSamplers(pThisCC, pDXContext, pCmd->startSampler, pCmd->type, cSamplerId, paSamplerId);
304 return rc;
305}
306
307
308int vmsvga3dDXDraw(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDraw const *pCmd)
309{
310 int rc;
311 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
312 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDraw, VERR_INVALID_STATE);
313 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
314 AssertReturn(p3dState, VERR_INVALID_STATE);
315
316 PVMSVGA3DDXCONTEXT pDXContext;
317 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
318 AssertRCReturn(rc, rc);
319
320 rc = pSvgaR3State->pFuncsDX->pfnDXDraw(pThisCC, pDXContext, pCmd->vertexCount, pCmd->startVertexLocation);
321#ifdef DUMP_BITMAPS
322 SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
323 SVGA3dSurfaceImageId image;
324 image.sid = pRTViewEntry->sid;
325 image.face = 0;
326 image.mipmap = 0;
327 VMSVGA3D_MAPPED_SURFACE map;
328 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
329 if (RT_SUCCESS(rc2))
330 {
331 vmsvga3dMapWriteBmpFile(&map, "rt-");
332 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
333 }
334#endif
335 return rc;
336}
337
338
339int vmsvga3dDXDrawIndexed(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexed const *pCmd)
340{
341 int rc;
342 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
343 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexed, VERR_INVALID_STATE);
344 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
345 AssertReturn(p3dState, VERR_INVALID_STATE);
346
347 PVMSVGA3DDXCONTEXT pDXContext;
348 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
349 AssertRCReturn(rc, rc);
350
351 rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexed(pThisCC, pDXContext, pCmd->indexCount, pCmd->startIndexLocation, pCmd->baseVertexLocation);
352#ifdef DUMP_BITMAPS
353 SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
354 SVGA3dSurfaceImageId image;
355 image.sid = pRTViewEntry->sid;
356 image.face = 0;
357 image.mipmap = 0;
358 VMSVGA3D_MAPPED_SURFACE map;
359 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
360 if (RT_SUCCESS(rc2))
361 {
362 vmsvga3dMapWriteBmpFile(&map, "rt-");
363 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
364 }
365#endif
366 return rc;
367}
368
369
370int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd)
371{
372 int rc;
373 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
374 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawInstanced, VERR_INVALID_STATE);
375 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
376 AssertReturn(p3dState, VERR_INVALID_STATE);
377
378 PVMSVGA3DDXCONTEXT pDXContext;
379 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
380 AssertRCReturn(rc, rc);
381
382 rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstanced(pThisCC, pDXContext,
383 pCmd->vertexCountPerInstance, pCmd->instanceCount, pCmd->startVertexLocation, pCmd->startInstanceLocation);
384#ifdef DUMP_BITMAPS
385 SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
386 SVGA3dSurfaceImageId image;
387 image.sid = pRTViewEntry->sid;
388 image.face = 0;
389 image.mipmap = 0;
390 VMSVGA3D_MAPPED_SURFACE map;
391 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
392 if (RT_SUCCESS(rc2))
393 {
394 vmsvga3dMapWriteBmpFile(&map, "rt-");
395 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
396 }
397#endif
398 return rc;
399}
400
401
402int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd)
403{
404 int rc;
405 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
406 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced, VERR_INVALID_STATE);
407 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
408 AssertReturn(p3dState, VERR_INVALID_STATE);
409
410 PVMSVGA3DDXCONTEXT pDXContext;
411 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
412 AssertRCReturn(rc, rc);
413
414 rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced(pThisCC, pDXContext,
415 pCmd->indexCountPerInstance, pCmd->instanceCount, pCmd->startIndexLocation, pCmd->baseVertexLocation, pCmd->startInstanceLocation);
416#ifdef DUMP_BITMAPS
417 SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
418 SVGA3dSurfaceImageId image;
419 image.sid = pRTViewEntry->sid;
420 image.face = 0;
421 image.mipmap = 0;
422 VMSVGA3D_MAPPED_SURFACE map;
423 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
424 if (RT_SUCCESS(rc2))
425 {
426 vmsvga3dMapWriteBmpFile(&map, "rt-");
427 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
428 }
429#endif
430 return rc;
431}
432
433
434int vmsvga3dDXDrawAuto(PVGASTATECC pThisCC, uint32_t idDXContext)
435{
436 int rc;
437 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
438 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawAuto, VERR_INVALID_STATE);
439 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
440 AssertReturn(p3dState, VERR_INVALID_STATE);
441
442 PVMSVGA3DDXCONTEXT pDXContext;
443 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
444 AssertRCReturn(rc, rc);
445
446 rc = pSvgaR3State->pFuncsDX->pfnDXDrawAuto(pThisCC, pDXContext);
447#ifdef DUMP_BITMAPS
448 SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
449 SVGA3dSurfaceImageId image;
450 image.sid = pRTViewEntry->sid;
451 image.face = 0;
452 image.mipmap = 0;
453 VMSVGA3D_MAPPED_SURFACE map;
454 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
455 if (RT_SUCCESS(rc2))
456 {
457 vmsvga3dMapWriteBmpFile(&map, "rt-");
458 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);
459 }
460#endif
461 return rc;
462}
463
464
465int vmsvga3dDXSetInputLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dElementLayoutId elementLayoutId)
466{
467 int rc;
468 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
469 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetInputLayout, VERR_INVALID_STATE);
470 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
471 AssertReturn(p3dState, VERR_INVALID_STATE);
472
473 PVMSVGA3DDXCONTEXT pDXContext;
474 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
475 AssertRCReturn(rc, rc);
476
477 ASSERT_GUEST_RETURN(pDXContext->cot.paElementLayout, VERR_INVALID_STATE);
478 ASSERT_GUEST_RETURN(elementLayoutId < pDXContext->cot.cElementLayout, VERR_INVALID_PARAMETER);
479 RT_UNTRUSTED_VALIDATED_FENCE();
480
481 rc = pSvgaR3State->pFuncsDX->pfnDXSetInputLayout(pThisCC, pDXContext, elementLayoutId);
482 return rc;
483}
484
485
486int vmsvga3dDXSetVertexBuffers(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t startBuffer, uint32_t cVertexBuffer, SVGA3dVertexBuffer const *paVertexBuffer)
487{
488 int rc;
489 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
490 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetVertexBuffers, VERR_INVALID_STATE);
491 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
492 AssertReturn(p3dState, VERR_INVALID_STATE);
493
494 PVMSVGA3DDXCONTEXT pDXContext;
495 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
496 AssertRCReturn(rc, rc);
497
498 ASSERT_GUEST_RETURN(startBuffer < SVGA3D_DX_MAX_VERTEXBUFFERS, VERR_INVALID_PARAMETER);
499 ASSERT_GUEST_RETURN(cVertexBuffer <= SVGA3D_DX_MAX_VERTEXBUFFERS - startBuffer, VERR_INVALID_PARAMETER);
500 RT_UNTRUSTED_VALIDATED_FENCE();
501
502 rc = pSvgaR3State->pFuncsDX->pfnDXSetVertexBuffers(pThisCC, pDXContext, startBuffer, cVertexBuffer, paVertexBuffer);
503 return rc;
504}
505
506
507int vmsvga3dDXSetIndexBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetIndexBuffer const *pCmd)
508{
509 int rc;
510 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
511 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetIndexBuffer, VERR_INVALID_STATE);
512 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
513 AssertReturn(p3dState, VERR_INVALID_STATE);
514
515 PVMSVGA3DDXCONTEXT pDXContext;
516 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
517 AssertRCReturn(rc, rc);
518
519 rc = pSvgaR3State->pFuncsDX->pfnDXSetIndexBuffer(pThisCC, pDXContext, pCmd->sid, pCmd->format, pCmd->offset);
520 if (RT_SUCCESS(rc))
521 {
522 pDXContext->svgaDXContext.inputAssembly.indexBufferSid = pCmd->sid;
523 pDXContext->svgaDXContext.inputAssembly.indexBufferOffset = pCmd->offset;
524 pDXContext->svgaDXContext.inputAssembly.indexBufferFormat = pCmd->format;
525 }
526 return rc;
527}
528
529
530int vmsvga3dDXSetTopology(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dPrimitiveType topology)
531{
532 int rc;
533 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
534 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetTopology, VERR_INVALID_STATE);
535 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
536 AssertReturn(p3dState, VERR_INVALID_STATE);
537
538 PVMSVGA3DDXCONTEXT pDXContext;
539 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
540 AssertRCReturn(rc, rc);
541
542 ASSERT_GUEST_RETURN(topology >= SVGA3D_PRIMITIVE_MIN && topology < SVGA3D_PRIMITIVE_MAX, VERR_INVALID_PARAMETER);
543
544 rc = pSvgaR3State->pFuncsDX->pfnDXSetTopology(pThisCC, pDXContext, topology);
545 if (RT_SUCCESS(rc))
546 pDXContext->svgaDXContext.inputAssembly.topology = topology;
547 return rc;
548}
549
550
551int vmsvga3dDXSetRenderTargets(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dDepthStencilViewId depthStencilViewId, uint32_t cRenderTargetViewId, SVGA3dRenderTargetViewId const *paRenderTargetViewId)
552{
553 int rc;
554 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
555 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets, VERR_INVALID_STATE);
556 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
557 AssertReturn(p3dState, VERR_INVALID_STATE);
558
559 PVMSVGA3DDXCONTEXT pDXContext;
560 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
561 AssertRCReturn(rc, rc);
562
563 ASSERT_GUEST_RETURN( depthStencilViewId < pDXContext->cot.cDSView
564 || depthStencilViewId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
565 ASSERT_GUEST_RETURN(cRenderTargetViewId < SVGA3D_MAX_RENDER_TARGETS, VERR_INVALID_PARAMETER);
566 for (uint32_t i = 0; i < cRenderTargetViewId; ++i)
567 ASSERT_GUEST_RETURN( paRenderTargetViewId[i] < pDXContext->cot.cRTView
568 || paRenderTargetViewId[i] == SVGA_ID_INVALID, VERR_INVALID_PARAMETER);
569 RT_UNTRUSTED_VALIDATED_FENCE();
570
571 rc = pSvgaR3State->pFuncsDX->pfnDXSetRenderTargets(pThisCC, pDXContext, depthStencilViewId, cRenderTargetViewId, paRenderTargetViewId);
572 if (RT_SUCCESS(rc))
573 {
574 pDXContext->svgaDXContext.renderState.depthStencilViewId = depthStencilViewId;
575 for (uint32_t i = 0; i < cRenderTargetViewId; ++i)
576 pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = paRenderTargetViewId[i];
577 }
578 return rc;
579}
580
581
582int vmsvga3dDXSetBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetBlendState const *pCmd)
583{
584 int rc;
585 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
586 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetBlendState, VERR_INVALID_STATE);
587 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
588 AssertReturn(p3dState, VERR_INVALID_STATE);
589
590 PVMSVGA3DDXCONTEXT pDXContext;
591 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
592 AssertRCReturn(rc, rc);
593
594 SVGA3dBlendStateId const blendId = pCmd->blendId;
595
596 ASSERT_GUEST_RETURN(pDXContext->cot.paBlendState, VERR_INVALID_STATE);
597 ASSERT_GUEST_RETURN(blendId < pDXContext->cot.cBlendState, VERR_INVALID_PARAMETER);
598 RT_UNTRUSTED_VALIDATED_FENCE();
599
600 rc = pSvgaR3State->pFuncsDX->pfnDXSetBlendState(pThisCC, pDXContext, blendId, pCmd->blendFactor, pCmd->sampleMask);
601 return rc;
602}
603
604
605int vmsvga3dDXSetDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetDepthStencilState const *pCmd)
606{
607 int rc;
608 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
609 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetDepthStencilState, VERR_INVALID_STATE);
610 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
611 AssertReturn(p3dState, VERR_INVALID_STATE);
612
613 PVMSVGA3DDXCONTEXT pDXContext;
614 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
615 AssertRCReturn(rc, rc);
616
617 SVGA3dDepthStencilStateId const depthStencilId = pCmd->depthStencilId;
618
619 ASSERT_GUEST_RETURN(pDXContext->cot.paDepthStencil, VERR_INVALID_STATE);
620 ASSERT_GUEST_RETURN(depthStencilId < pDXContext->cot.cDepthStencil, VERR_INVALID_PARAMETER);
621 RT_UNTRUSTED_VALIDATED_FENCE();
622
623 rc = pSvgaR3State->pFuncsDX->pfnDXSetDepthStencilState(pThisCC, pDXContext, depthStencilId, pCmd->stencilRef);
624 return rc;
625}
626
627
628int vmsvga3dDXSetRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dRasterizerStateId rasterizerId)
629{
630 int rc;
631 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
632 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetRasterizerState, VERR_INVALID_STATE);
633 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
634 AssertReturn(p3dState, VERR_INVALID_STATE);
635
636 PVMSVGA3DDXCONTEXT pDXContext;
637 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
638 AssertRCReturn(rc, rc);
639
640 ASSERT_GUEST_RETURN(rasterizerId < pDXContext->cot.cRasterizerState, VERR_INVALID_PARAMETER);
641 RT_UNTRUSTED_VALIDATED_FENCE();
642
643 rc = pSvgaR3State->pFuncsDX->pfnDXSetRasterizerState(pThisCC, pDXContext, rasterizerId);
644 return rc;
645}
646
647
648int vmsvga3dDXDefineQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
649{
650 int rc;
651 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
652 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineQuery, VERR_INVALID_STATE);
653 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
654 AssertReturn(p3dState, VERR_INVALID_STATE);
655
656 PVMSVGA3DDXCONTEXT pDXContext;
657 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
658 AssertRCReturn(rc, rc);
659
660 rc = pSvgaR3State->pFuncsDX->pfnDXDefineQuery(pThisCC, pDXContext);
661 return rc;
662}
663
664
665int vmsvga3dDXDestroyQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
666{
667 int rc;
668 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
669 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyQuery, VERR_INVALID_STATE);
670 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
671 AssertReturn(p3dState, VERR_INVALID_STATE);
672
673 PVMSVGA3DDXCONTEXT pDXContext;
674 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
675 AssertRCReturn(rc, rc);
676
677 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyQuery(pThisCC, pDXContext);
678 return rc;
679}
680
681
682int vmsvga3dDXBindQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
683{
684 int rc;
685 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
686 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindQuery, VERR_INVALID_STATE);
687 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
688 AssertReturn(p3dState, VERR_INVALID_STATE);
689
690 PVMSVGA3DDXCONTEXT pDXContext;
691 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
692 AssertRCReturn(rc, rc);
693
694 rc = pSvgaR3State->pFuncsDX->pfnDXBindQuery(pThisCC, pDXContext);
695 return rc;
696}
697
698
699int vmsvga3dDXSetQueryOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
700{
701 int rc;
702 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
703 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetQueryOffset, VERR_INVALID_STATE);
704 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
705 AssertReturn(p3dState, VERR_INVALID_STATE);
706
707 PVMSVGA3DDXCONTEXT pDXContext;
708 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
709 AssertRCReturn(rc, rc);
710
711 rc = pSvgaR3State->pFuncsDX->pfnDXSetQueryOffset(pThisCC, pDXContext);
712 return rc;
713}
714
715
716int vmsvga3dDXBeginQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
717{
718 int rc;
719 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
720 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBeginQuery, VERR_INVALID_STATE);
721 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
722 AssertReturn(p3dState, VERR_INVALID_STATE);
723
724 PVMSVGA3DDXCONTEXT pDXContext;
725 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
726 AssertRCReturn(rc, rc);
727
728 rc = pSvgaR3State->pFuncsDX->pfnDXBeginQuery(pThisCC, pDXContext);
729 return rc;
730}
731
732
733int vmsvga3dDXEndQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
734{
735 int rc;
736 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
737 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXEndQuery, VERR_INVALID_STATE);
738 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
739 AssertReturn(p3dState, VERR_INVALID_STATE);
740
741 PVMSVGA3DDXCONTEXT pDXContext;
742 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
743 AssertRCReturn(rc, rc);
744
745 rc = pSvgaR3State->pFuncsDX->pfnDXEndQuery(pThisCC, pDXContext);
746 return rc;
747}
748
749
750int vmsvga3dDXReadbackQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
751{
752 int rc;
753 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
754 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXReadbackQuery, VERR_INVALID_STATE);
755 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
756 AssertReturn(p3dState, VERR_INVALID_STATE);
757
758 PVMSVGA3DDXCONTEXT pDXContext;
759 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
760 AssertRCReturn(rc, rc);
761
762 rc = pSvgaR3State->pFuncsDX->pfnDXReadbackQuery(pThisCC, pDXContext);
763 return rc;
764}
765
766
767int vmsvga3dDXSetPredication(PVGASTATECC pThisCC, uint32_t idDXContext)
768{
769 int rc;
770 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
771 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetPredication, VERR_INVALID_STATE);
772 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
773 AssertReturn(p3dState, VERR_INVALID_STATE);
774
775 PVMSVGA3DDXCONTEXT pDXContext;
776 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
777 AssertRCReturn(rc, rc);
778
779 rc = pSvgaR3State->pFuncsDX->pfnDXSetPredication(pThisCC, pDXContext);
780 return rc;
781}
782
783
784int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget)
785{
786 int rc;
787 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
788 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetSOTargets, VERR_INVALID_STATE);
789 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
790 AssertReturn(p3dState, VERR_INVALID_STATE);
791
792 PVMSVGA3DDXCONTEXT pDXContext;
793 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
794 AssertRCReturn(rc, rc);
795
796 ASSERT_GUEST_RETURN(cSoTarget < SVGA3D_DX_MAX_SOTARGETS, VERR_INVALID_PARAMETER);
797
798 rc = pSvgaR3State->pFuncsDX->pfnDXSetSOTargets(pThisCC, pDXContext, cSoTarget, paSoTarget);
799 return rc;
800}
801
802
803int vmsvga3dDXSetViewports(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cViewport, SVGA3dViewport const *paViewport)
804{
805 int rc;
806 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
807 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetViewports, 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 rc = pSvgaR3State->pFuncsDX->pfnDXSetViewports(pThisCC, pDXContext, cViewport, paViewport);
816 return rc;
817}
818
819
820int vmsvga3dDXSetScissorRects(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cRect, SVGASignedRect const *paRect)
821{
822 int rc;
823 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
824 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetScissorRects, VERR_INVALID_STATE);
825 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
826 AssertReturn(p3dState, VERR_INVALID_STATE);
827
828 PVMSVGA3DDXCONTEXT pDXContext;
829 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
830 AssertRCReturn(rc, rc);
831
832 rc = pSvgaR3State->pFuncsDX->pfnDXSetScissorRects(pThisCC, pDXContext, cRect, paRect);
833 return rc;
834}
835
836
837int vmsvga3dDXClearRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearRenderTargetView const *pCmd)
838{
839 int rc;
840 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
841 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearRenderTargetView, VERR_INVALID_STATE);
842 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
843 AssertReturn(p3dState, VERR_INVALID_STATE);
844
845 PVMSVGA3DDXCONTEXT pDXContext;
846 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
847 AssertRCReturn(rc, rc);
848
849 SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
850
851 ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
852 ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
853 RT_UNTRUSTED_VALIDATED_FENCE();
854
855 rc = pSvgaR3State->pFuncsDX->pfnDXClearRenderTargetView(pThisCC, pDXContext, renderTargetViewId, &pCmd->rgba);
856 return rc;
857}
858
859
860int vmsvga3dDXClearDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearDepthStencilView const *pCmd)
861{
862 int rc;
863 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
864 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearDepthStencilView, VERR_INVALID_STATE);
865 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
866 AssertReturn(p3dState, VERR_INVALID_STATE);
867
868 PVMSVGA3DDXCONTEXT pDXContext;
869 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
870 AssertRCReturn(rc, rc);
871
872 SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
873
874 ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
875 ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
876 RT_UNTRUSTED_VALIDATED_FENCE();
877
878 rc = pSvgaR3State->pFuncsDX->pfnDXClearDepthStencilView(pThisCC, pDXContext, pCmd->flags, depthStencilViewId, pCmd->depth, (uint8_t)pCmd->stencil);
879 return rc;
880}
881
882
883int vmsvga3dDXPredCopyRegion(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXPredCopyRegion const *pCmd)
884{
885 int rc;
886 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
887 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredCopyRegion, VERR_INVALID_STATE);
888 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
889 AssertReturn(p3dState, VERR_INVALID_STATE);
890
891 PVMSVGA3DDXCONTEXT pDXContext;
892 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
893 AssertRCReturn(rc, rc);
894
895 /** @todo Memcpy if both resources do not have the hardware resource. */
896
897 rc = pSvgaR3State->pFuncsDX->pfnDXPredCopyRegion(pThisCC, pDXContext, pCmd->dstSid, pCmd->dstSubResource, pCmd->srcSid, pCmd->srcSubResource, &pCmd->box);
898 return rc;
899}
900
901
902int vmsvga3dDXPredCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
903{
904 int rc;
905 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
906 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredCopy, VERR_INVALID_STATE);
907 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
908 AssertReturn(p3dState, VERR_INVALID_STATE);
909
910 PVMSVGA3DDXCONTEXT pDXContext;
911 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
912 AssertRCReturn(rc, rc);
913
914 rc = pSvgaR3State->pFuncsDX->pfnDXPredCopy(pThisCC, pDXContext);
915 return rc;
916}
917
918
919int vmsvga3dDXPresentBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
920{
921 int rc;
922 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
923 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPresentBlt, VERR_INVALID_STATE);
924 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
925 AssertReturn(p3dState, VERR_INVALID_STATE);
926
927 PVMSVGA3DDXCONTEXT pDXContext;
928 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
929 AssertRCReturn(rc, rc);
930
931 rc = pSvgaR3State->pFuncsDX->pfnDXPresentBlt(pThisCC, pDXContext);
932 return rc;
933}
934
935
936int vmsvga3dDXGenMips(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXGenMips const *pCmd)
937{
938 int rc;
939 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
940 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXGenMips, VERR_INVALID_STATE);
941 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
942 AssertReturn(p3dState, VERR_INVALID_STATE);
943
944 PVMSVGA3DDXCONTEXT pDXContext;
945 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
946 AssertRCReturn(rc, rc);
947
948 SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
949
950 ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
951 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
952 RT_UNTRUSTED_VALIDATED_FENCE();
953
954 rc = pSvgaR3State->pFuncsDX->pfnDXGenMips(pThisCC, pDXContext, shaderResourceViewId);
955 return rc;
956}
957
958
959int vmsvga3dDXDefineShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShaderResourceView const *pCmd)
960{
961 int rc;
962 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
963 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineShaderResourceView, VERR_INVALID_STATE);
964 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
965 AssertReturn(p3dState, VERR_INVALID_STATE);
966
967 PVMSVGA3DDXCONTEXT pDXContext;
968 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
969 AssertRCReturn(rc, rc);
970
971 SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
972
973 ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
974 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
975 RT_UNTRUSTED_VALIDATED_FENCE();
976
977 SVGACOTableDXSRViewEntry *pEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
978 pEntry->sid = pCmd->sid;
979 pEntry->format = pCmd->format;
980 pEntry->resourceDimension = pCmd->resourceDimension;
981 pEntry->desc = pCmd->desc;
982
983 rc = pSvgaR3State->pFuncsDX->pfnDXDefineShaderResourceView(pThisCC, pDXContext, shaderResourceViewId, pEntry);
984 return rc;
985}
986
987
988int vmsvga3dDXDestroyShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShaderResourceView const *pCmd)
989{
990 int rc;
991 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
992 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyShaderResourceView, VERR_INVALID_STATE);
993 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
994 AssertReturn(p3dState, VERR_INVALID_STATE);
995
996 PVMSVGA3DDXCONTEXT pDXContext;
997 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
998 AssertRCReturn(rc, rc);
999
1000 SVGA3dShaderResourceViewId const shaderResourceViewId = pCmd->shaderResourceViewId;
1001
1002 ASSERT_GUEST_RETURN(pDXContext->cot.paSRView, VERR_INVALID_STATE);
1003 ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, VERR_INVALID_PARAMETER);
1004 RT_UNTRUSTED_VALIDATED_FENCE();
1005
1006 SVGACOTableDXSRViewEntry *pEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
1007 RT_ZERO(*pEntry);
1008
1009 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyShaderResourceView(pThisCC, pDXContext, shaderResourceViewId);
1010 return rc;
1011}
1012
1013
1014int vmsvga3dDXDefineRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRenderTargetView const *pCmd)
1015{
1016 int rc;
1017 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1018 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineRenderTargetView, VERR_INVALID_STATE);
1019 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1020 AssertReturn(p3dState, VERR_INVALID_STATE);
1021
1022 PVMSVGA3DDXCONTEXT pDXContext;
1023 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1024 AssertRCReturn(rc, rc);
1025
1026 SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
1027
1028 ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
1029 ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
1030 RT_UNTRUSTED_VALIDATED_FENCE();
1031
1032 SVGACOTableDXRTViewEntry *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
1033 pEntry->sid = pCmd->sid;
1034 pEntry->format = pCmd->format;
1035 pEntry->resourceDimension = pCmd->resourceDimension;
1036 pEntry->desc = pCmd->desc;
1037
1038 rc = pSvgaR3State->pFuncsDX->pfnDXDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry);
1039 return rc;
1040}
1041
1042
1043int vmsvga3dDXDestroyRenderTargetView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyRenderTargetView const *pCmd)
1044{
1045 int rc;
1046 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1047 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyRenderTargetView, VERR_INVALID_STATE);
1048 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1049 AssertReturn(p3dState, VERR_INVALID_STATE);
1050
1051 PVMSVGA3DDXCONTEXT pDXContext;
1052 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1053 AssertRCReturn(rc, rc);
1054
1055 SVGA3dRenderTargetViewId const renderTargetViewId = pCmd->renderTargetViewId;
1056
1057 ASSERT_GUEST_RETURN(pDXContext->cot.paRTView, VERR_INVALID_STATE);
1058 ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
1059 RT_UNTRUSTED_VALIDATED_FENCE();
1060
1061 SVGACOTableDXRTViewEntry *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
1062 RT_ZERO(*pEntry);
1063
1064 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyRenderTargetView(pThisCC, pDXContext, renderTargetViewId);
1065 /// @todo for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)
1066 //{
1067 // if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] == renderTargetViewId)
1068 // pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] = SVGA_ID_INVALID;
1069 //}
1070 return rc;
1071}
1072
1073
1074int vmsvga3dDXDefineDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilView_v2 const *pCmd)
1075{
1076 int rc;
1077 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1078 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilView, VERR_INVALID_STATE);
1079 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1080 AssertReturn(p3dState, VERR_INVALID_STATE);
1081
1082 PVMSVGA3DDXCONTEXT pDXContext;
1083 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1084 AssertRCReturn(rc, rc);
1085
1086 SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
1087
1088 ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
1089 ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
1090 RT_UNTRUSTED_VALIDATED_FENCE();
1091
1092 SVGACOTableDXDSViewEntry *pEntry = &pDXContext->cot.paDSView[depthStencilViewId];
1093 pEntry->sid = pCmd->sid;
1094 pEntry->format = pCmd->format;
1095 pEntry->resourceDimension = pCmd->resourceDimension;
1096 pEntry->mipSlice = pCmd->mipSlice;
1097 pEntry->firstArraySlice = pCmd->firstArraySlice;
1098 pEntry->arraySize = pCmd->arraySize;
1099 pEntry->flags = pCmd->flags;
1100
1101 rc = pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry);
1102 return rc;
1103}
1104
1105
1106int vmsvga3dDXDestroyDepthStencilView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyDepthStencilView const *pCmd)
1107{
1108 int rc;
1109 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1110 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilView, VERR_INVALID_STATE);
1111 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1112 AssertReturn(p3dState, VERR_INVALID_STATE);
1113
1114 PVMSVGA3DDXCONTEXT pDXContext;
1115 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1116 AssertRCReturn(rc, rc);
1117
1118 SVGA3dDepthStencilViewId const depthStencilViewId = pCmd->depthStencilViewId;
1119
1120 ASSERT_GUEST_RETURN(pDXContext->cot.paDSView, VERR_INVALID_STATE);
1121 ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
1122 RT_UNTRUSTED_VALIDATED_FENCE();
1123
1124 SVGACOTableDXDSViewEntry *pEntry = &pDXContext->cot.paDSView[depthStencilViewId];
1125 RT_ZERO(*pEntry);
1126
1127 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilView(pThisCC, pDXContext, depthStencilViewId);
1128 return rc;
1129}
1130
1131
1132int vmsvga3dDXDefineElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dElementLayoutId elementLayoutId, uint32_t cDesc, SVGA3dInputElementDesc const *paDesc)
1133{
1134 int rc;
1135 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1136 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineElementLayout, VERR_INVALID_STATE);
1137 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1138 AssertReturn(p3dState, VERR_INVALID_STATE);
1139
1140 PVMSVGA3DDXCONTEXT pDXContext;
1141 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1142 AssertRCReturn(rc, rc);
1143
1144 ASSERT_GUEST_RETURN(pDXContext->cot.paElementLayout, VERR_INVALID_STATE);
1145 ASSERT_GUEST_RETURN(elementLayoutId < pDXContext->cot.cElementLayout, VERR_INVALID_PARAMETER);
1146 RT_UNTRUSTED_VALIDATED_FENCE();
1147
1148 SVGACOTableDXElementLayoutEntry *pEntry = &pDXContext->cot.paElementLayout[elementLayoutId];
1149 pEntry->elid = elementLayoutId;
1150 pEntry->numDescs = RT_MIN(cDesc, RT_ELEMENTS(pEntry->descs));
1151 memcpy(pEntry->descs, paDesc, pEntry->numDescs * sizeof(pEntry->descs[0]));
1152
1153#ifdef LOG_ENABLED
1154 Log6(("Element layout %d: slot off fmt class step reg\n", pEntry->elid));
1155 for (uint32_t i = 0; i < pEntry->numDescs; ++i)
1156 {
1157 Log6((" [%u]: %u 0x%02X %d %u %u %u\n",
1158 i,
1159 pEntry->descs[i].inputSlot,
1160 pEntry->descs[i].alignedByteOffset,
1161 pEntry->descs[i].format,
1162 pEntry->descs[i].inputSlotClass,
1163 pEntry->descs[i].instanceDataStepRate,
1164 pEntry->descs[i].inputRegister
1165 ));
1166 }
1167#endif
1168
1169 rc = pSvgaR3State->pFuncsDX->pfnDXDefineElementLayout(pThisCC, pDXContext, elementLayoutId, pEntry);
1170 return rc;
1171}
1172
1173
1174int vmsvga3dDXDestroyElementLayout(PVGASTATECC pThisCC, uint32_t idDXContext)
1175{
1176 int rc;
1177 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1178 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyElementLayout, VERR_INVALID_STATE);
1179 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1180 AssertReturn(p3dState, VERR_INVALID_STATE);
1181
1182 PVMSVGA3DDXCONTEXT pDXContext;
1183 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1184 AssertRCReturn(rc, rc);
1185
1186 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyElementLayout(pThisCC, pDXContext);
1187 return rc;
1188}
1189
1190
1191int vmsvga3dDXDefineBlendState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineBlendState const *pCmd)
1192{
1193 int rc;
1194 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1195 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineBlendState, VERR_INVALID_STATE);
1196 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1197 AssertReturn(p3dState, VERR_INVALID_STATE);
1198
1199 PVMSVGA3DDXCONTEXT pDXContext;
1200 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1201 AssertRCReturn(rc, rc);
1202
1203 const SVGA3dBlendStateId blendId = pCmd->blendId;
1204
1205 ASSERT_GUEST_RETURN(pDXContext->cot.paBlendState, VERR_INVALID_STATE);
1206 ASSERT_GUEST_RETURN(blendId < pDXContext->cot.cBlendState, VERR_INVALID_PARAMETER);
1207 RT_UNTRUSTED_VALIDATED_FENCE();
1208
1209 SVGACOTableDXBlendStateEntry *pEntry = &pDXContext->cot.paBlendState[blendId];
1210 pEntry->alphaToCoverageEnable = pCmd->alphaToCoverageEnable;
1211 pEntry->independentBlendEnable = pCmd->independentBlendEnable;
1212 memcpy(pEntry->perRT, pCmd->perRT, sizeof(pEntry->perRT));
1213
1214 rc = pSvgaR3State->pFuncsDX->pfnDXDefineBlendState(pThisCC, pDXContext, blendId, pEntry);
1215 return rc;
1216}
1217
1218
1219int vmsvga3dDXDestroyBlendState(PVGASTATECC pThisCC, uint32_t idDXContext)
1220{
1221 int rc;
1222 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1223 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyBlendState, VERR_INVALID_STATE);
1224 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1225 AssertReturn(p3dState, VERR_INVALID_STATE);
1226
1227 PVMSVGA3DDXCONTEXT pDXContext;
1228 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1229 AssertRCReturn(rc, rc);
1230
1231 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyBlendState(pThisCC, pDXContext);
1232 return rc;
1233}
1234
1235
1236int vmsvga3dDXDefineDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineDepthStencilState const *pCmd)
1237{
1238 int rc;
1239 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1240 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilState, VERR_INVALID_STATE);
1241 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1242 AssertReturn(p3dState, VERR_INVALID_STATE);
1243
1244 PVMSVGA3DDXCONTEXT pDXContext;
1245 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1246 AssertRCReturn(rc, rc);
1247
1248 SVGA3dDepthStencilStateId const depthStencilId = pCmd->depthStencilId;
1249
1250 ASSERT_GUEST_RETURN(pDXContext->cot.paDepthStencil, VERR_INVALID_STATE);
1251 ASSERT_GUEST_RETURN(depthStencilId < pDXContext->cot.cDepthStencil, VERR_INVALID_PARAMETER);
1252 RT_UNTRUSTED_VALIDATED_FENCE();
1253
1254 SVGACOTableDXDepthStencilEntry *pEntry = &pDXContext->cot.paDepthStencil[depthStencilId];
1255 pEntry->depthEnable = pCmd->depthEnable;
1256 pEntry->depthWriteMask = pCmd->depthWriteMask;
1257 pEntry->depthFunc = pCmd->depthFunc;
1258 pEntry->stencilEnable = pCmd->stencilEnable;
1259 pEntry->frontEnable = pCmd->frontEnable;
1260 pEntry->backEnable = pCmd->backEnable;
1261 pEntry->stencilReadMask = pCmd->stencilReadMask;
1262 pEntry->stencilWriteMask = pCmd->stencilWriteMask;
1263
1264 pEntry->frontStencilFailOp = pCmd->frontStencilFailOp;
1265 pEntry->frontStencilDepthFailOp = pCmd->frontStencilDepthFailOp;
1266 pEntry->frontStencilPassOp = pCmd->frontStencilPassOp;
1267 pEntry->frontStencilFunc = pCmd->frontStencilFunc;
1268
1269 pEntry->backStencilFailOp = pCmd->backStencilFailOp;
1270 pEntry->backStencilDepthFailOp = pCmd->backStencilDepthFailOp;
1271 pEntry->backStencilPassOp = pCmd->backStencilPassOp;
1272 pEntry->backStencilFunc = pCmd->backStencilFunc;
1273
1274 rc = pSvgaR3State->pFuncsDX->pfnDXDefineDepthStencilState(pThisCC, pDXContext, depthStencilId, pEntry);
1275 return rc;
1276}
1277
1278
1279int vmsvga3dDXDestroyDepthStencilState(PVGASTATECC pThisCC, uint32_t idDXContext)
1280{
1281 int rc;
1282 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1283 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilState, VERR_INVALID_STATE);
1284 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1285 AssertReturn(p3dState, VERR_INVALID_STATE);
1286
1287 PVMSVGA3DDXCONTEXT pDXContext;
1288 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1289 AssertRCReturn(rc, rc);
1290
1291 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyDepthStencilState(pThisCC, pDXContext);
1292 return rc;
1293}
1294
1295
1296int vmsvga3dDXDefineRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineRasterizerState const *pCmd)
1297{
1298 int rc;
1299 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1300 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineRasterizerState, VERR_INVALID_STATE);
1301 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1302 AssertReturn(p3dState, VERR_INVALID_STATE);
1303
1304 PVMSVGA3DDXCONTEXT pDXContext;
1305 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1306 AssertRCReturn(rc, rc);
1307
1308 SVGA3dRasterizerStateId const rasterizerId = pCmd->rasterizerId;
1309
1310 ASSERT_GUEST_RETURN(pDXContext->cot.paRasterizerState, VERR_INVALID_STATE);
1311 ASSERT_GUEST_RETURN(rasterizerId < pDXContext->cot.cRasterizerState, VERR_INVALID_PARAMETER);
1312 RT_UNTRUSTED_VALIDATED_FENCE();
1313
1314 SVGACOTableDXRasterizerStateEntry *pEntry = &pDXContext->cot.paRasterizerState[rasterizerId];
1315 pEntry->fillMode = pCmd->fillMode;
1316 pEntry->cullMode = pCmd->cullMode;
1317 pEntry->frontCounterClockwise = pCmd->frontCounterClockwise;
1318 pEntry->provokingVertexLast = pCmd->provokingVertexLast;
1319 pEntry->depthBias = pCmd->depthBias;
1320 pEntry->depthBiasClamp = pCmd->depthBiasClamp;
1321 pEntry->slopeScaledDepthBias = pCmd->slopeScaledDepthBias;
1322 pEntry->depthClipEnable = pCmd->depthClipEnable;
1323 pEntry->scissorEnable = pCmd->scissorEnable;
1324 pEntry->multisampleEnable = pCmd->multisampleEnable;
1325 pEntry->antialiasedLineEnable = pCmd->antialiasedLineEnable;
1326 pEntry->lineWidth = pCmd->lineWidth;
1327 pEntry->lineStippleEnable = pCmd->lineStippleEnable;
1328 pEntry->lineStippleFactor = pCmd->lineStippleFactor;
1329 pEntry->lineStipplePattern = pCmd->lineStipplePattern;
1330 pEntry->forcedSampleCount = 0; /** @todo Not in pCmd. */
1331 RT_ZERO(pEntry->mustBeZero);
1332
1333 rc = pSvgaR3State->pFuncsDX->pfnDXDefineRasterizerState(pThisCC, pDXContext, rasterizerId, pEntry);
1334 return rc;
1335}
1336
1337
1338int vmsvga3dDXDestroyRasterizerState(PVGASTATECC pThisCC, uint32_t idDXContext)
1339{
1340 int rc;
1341 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1342 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyRasterizerState, VERR_INVALID_STATE);
1343 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1344 AssertReturn(p3dState, VERR_INVALID_STATE);
1345
1346 PVMSVGA3DDXCONTEXT pDXContext;
1347 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1348 AssertRCReturn(rc, rc);
1349
1350 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyRasterizerState(pThisCC, pDXContext);
1351 return rc;
1352}
1353
1354
1355int vmsvga3dDXDefineSamplerState(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineSamplerState const *pCmd)
1356{
1357 int rc;
1358 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1359 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineSamplerState, VERR_INVALID_STATE);
1360 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1361 AssertReturn(p3dState, VERR_INVALID_STATE);
1362
1363 PVMSVGA3DDXCONTEXT pDXContext;
1364 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1365 AssertRCReturn(rc, rc);
1366
1367 SVGA3dSamplerId const samplerId = pCmd->samplerId;
1368
1369 ASSERT_GUEST_RETURN(pDXContext->cot.paSampler, VERR_INVALID_STATE);
1370 ASSERT_GUEST_RETURN(samplerId < pDXContext->cot.cSampler, VERR_INVALID_PARAMETER);
1371 RT_UNTRUSTED_VALIDATED_FENCE();
1372
1373 SVGACOTableDXSamplerEntry *pEntry = &pDXContext->cot.paSampler[samplerId];
1374 pEntry->filter = pCmd->filter;
1375 pEntry->addressU = pCmd->addressU;
1376 pEntry->addressV = pCmd->addressV;
1377 pEntry->addressW = pCmd->addressW;
1378 pEntry->mipLODBias = pCmd->mipLODBias;
1379 pEntry->maxAnisotropy = pCmd->maxAnisotropy;
1380 pEntry->comparisonFunc = pCmd->comparisonFunc;
1381 pEntry->borderColor = pCmd->borderColor;
1382 pEntry->minLOD = pCmd->minLOD;
1383 pEntry->maxLOD = pCmd->maxLOD;
1384
1385 rc = pSvgaR3State->pFuncsDX->pfnDXDefineSamplerState(pThisCC, pDXContext, samplerId, pEntry);
1386 return rc;
1387}
1388
1389
1390int vmsvga3dDXDestroySamplerState(PVGASTATECC pThisCC, uint32_t idDXContext)
1391{
1392 int rc;
1393 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1394 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroySamplerState, VERR_INVALID_STATE);
1395 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1396 AssertReturn(p3dState, VERR_INVALID_STATE);
1397
1398 PVMSVGA3DDXCONTEXT pDXContext;
1399 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1400 AssertRCReturn(rc, rc);
1401
1402 rc = pSvgaR3State->pFuncsDX->pfnDXDestroySamplerState(pThisCC, pDXContext);
1403 return rc;
1404}
1405
1406
1407int vmsvga3dDXDefineShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShader const *pCmd)
1408{
1409 int rc;
1410 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1411 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineShader, VERR_INVALID_STATE);
1412 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1413 AssertReturn(p3dState, VERR_INVALID_STATE);
1414
1415 PVMSVGA3DDXCONTEXT pDXContext;
1416 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1417 AssertRCReturn(rc, rc);
1418
1419 AssertReturn(pDXContext->paShader, VERR_INVALID_STATE);
1420
1421 SVGA3dShaderId const shaderId = pCmd->shaderId;
1422
1423 ASSERT_GUEST_RETURN(pDXContext->cot.paShader, VERR_INVALID_STATE);
1424 ASSERT_GUEST_RETURN(shaderId < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
1425 ASSERT_GUEST_RETURN(pCmd->type >= SVGA3D_SHADERTYPE_MIN && pCmd->type < SVGA3D_SHADERTYPE_MAX, VERR_INVALID_PARAMETER);
1426 ASSERT_GUEST_RETURN(pCmd->sizeInBytes >= 8, VERR_INVALID_PARAMETER); /* Version Token + Length Token. */
1427 RT_UNTRUSTED_VALIDATED_FENCE();
1428
1429 SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[shaderId];
1430 pEntry->type = pCmd->type;
1431 pEntry->sizeInBytes = pCmd->sizeInBytes;
1432 pEntry->offsetInBytes = 0;
1433 pEntry->mobid = SVGA_ID_INVALID;
1434
1435 PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId];
1436 if (pShader->id != SVGA_ID_INVALID)
1437 {
1438 /* Cleanup the current shader. */
1439 pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
1440 RTMemFree(pShader->pShaderProgram);
1441 }
1442
1443 pShader->id = shaderId;
1444 pShader->cid = idDXContext;
1445 pShader->type = pEntry->type;
1446 pShader->cbData = pEntry->sizeInBytes;
1447 pShader->pShaderProgram = NULL;
1448 pShader->u.pvBackendShader = NULL;
1449
1450 rc = pSvgaR3State->pFuncsDX->pfnDXDefineShader(pThisCC, pDXContext, shaderId, pEntry);
1451 return rc;
1452}
1453
1454
1455int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd)
1456{
1457 int rc;
1458 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1459 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyShader, VERR_INVALID_STATE);
1460 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1461 AssertReturn(p3dState, VERR_INVALID_STATE);
1462
1463 PVMSVGA3DDXCONTEXT pDXContext;
1464 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1465 AssertRCReturn(rc, rc);
1466
1467 AssertReturn(pDXContext->paShader, VERR_INVALID_STATE);
1468
1469 SVGA3dShaderId const shaderId = pCmd->shaderId;
1470
1471 ASSERT_GUEST_RETURN(pDXContext->cot.paShader, VERR_INVALID_STATE);
1472 ASSERT_GUEST_RETURN(shaderId < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
1473 RT_UNTRUSTED_VALIDATED_FENCE();
1474
1475 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
1476
1477 /* Cleanup COTable entries.*/
1478 SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[shaderId];
1479 pEntry->type = SVGA3D_SHADERTYPE_INVALID;
1480 pEntry->sizeInBytes = 0;
1481 pEntry->offsetInBytes = 0;
1482 pEntry->mobid = SVGA_ID_INVALID;
1483
1484 PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId];
1485 pShader->id = SVGA_ID_INVALID;
1486 pShader->cid = SVGA_ID_INVALID;
1487 pShader->type = SVGA3D_SHADERTYPE_INVALID;
1488 pShader->cbData = 0;
1489 RTMemFree(pShader->pShaderProgram);
1490 pShader->pShaderProgram = NULL;
1491 pShader->u.pvBackendShader = NULL;
1492
1493 return rc;
1494}
1495
1496
1497static int dxBindShader(PVMSVGA3DSHADER pShader, PVMSVGAMOB pMob, SVGACOTableDXShaderEntry const *pEntry, void const *pvShaderBytecode)
1498{
1499 /* How many bytes the MOB can hold. */
1500 uint32_t const cbMob = vmsvgaR3MobSize(pMob) - pEntry->offsetInBytes;
1501 ASSERT_GUEST_RETURN(cbMob >= pEntry->sizeInBytes, VERR_INVALID_PARAMETER);
1502 AssertReturn(pEntry->sizeInBytes >= 8, VERR_INTERNAL_ERROR); /* Host ensures this in DefineShader. */
1503
1504 int rc = DXShaderParse(pvShaderBytecode, pEntry->sizeInBytes, &pShader->shaderInfo);
1505 if (RT_SUCCESS(rc))
1506 {
1507 /* Get the length of the shader bytecode. */
1508 uint32_t const *pau32Token = (uint32_t *)pvShaderBytecode; /* Tokens */
1509 uint32_t const cToken = pau32Token[1]; /* Length of the shader in tokens. */
1510 ASSERT_GUEST_RETURN(cToken <= pEntry->sizeInBytes / 4, VERR_INVALID_PARAMETER);
1511
1512 pShader->cbData = cToken * 4;
1513
1514 /* Check if the MOB contains SVGA3dDXSignatureHeader and signature entries.
1515 * If they are not there (Linux guest driver does not provide them), then it is fine
1516 * and the signatures generated by DXShaderParse will be used.
1517 */
1518 uint32_t const cbSignaturesMax = cbMob - pShader->cbData; /* How many bytes for signatures are available. */
1519 if (cbSignaturesMax > sizeof(SVGA3dDXSignatureHeader))
1520 {
1521 SVGA3dDXSignatureHeader const *pSignatureHeader = (SVGA3dDXSignatureHeader *)((uint8_t *)pvShaderBytecode + pShader->cbData);
1522 if (pSignatureHeader->headerVersion == SVGADX_SIGNATURE_HEADER_VERSION_0)
1523 {
1524 DEBUG_BREAKPOINT_TEST();
1525 ASSERT_GUEST_RETURN( pSignatureHeader->numInputSignatures <= RT_ELEMENTS(pShader->shaderInfo.aInputSignature)
1526 && pSignatureHeader->numOutputSignatures <= RT_ELEMENTS(pShader->shaderInfo.aOutputSignature)
1527 && pSignatureHeader->numPatchConstantSignatures <= RT_ELEMENTS(pShader->shaderInfo.aPatchConstantSignature),
1528 VERR_INVALID_PARAMETER);
1529
1530 uint32_t const cSignature = pSignatureHeader->numInputSignatures
1531 + pSignatureHeader->numOutputSignatures
1532 + pSignatureHeader->numPatchConstantSignatures;
1533 ASSERT_GUEST_RETURN( cbSignaturesMax - sizeof(SVGA3dDXSignatureHeader)
1534 > cSignature * sizeof(sizeof(SVGA3dDXSignatureEntry)), VERR_INVALID_PARAMETER);
1535
1536 /* Copy to DXShaderInfo. */
1537 uint8_t const *pu8Signatures = (uint8_t *)&pSignatureHeader[1];
1538 pShader->shaderInfo.cInputSignature = pSignatureHeader->numInputSignatures;
1539 memcpy(pShader->shaderInfo.aInputSignature, pu8Signatures, pSignatureHeader->numInputSignatures * sizeof(SVGA3dDXSignatureEntry));
1540
1541 pu8Signatures += pSignatureHeader->numInputSignatures * sizeof(SVGA3dDXSignatureEntry);
1542 pShader->shaderInfo.cOutputSignature = pSignatureHeader->numOutputSignatures;
1543 memcpy(pShader->shaderInfo.aOutputSignature, pu8Signatures, pSignatureHeader->numOutputSignatures * sizeof(SVGA3dDXSignatureEntry));
1544
1545 pu8Signatures += pSignatureHeader->numOutputSignatures * sizeof(SVGA3dDXSignatureEntry);
1546 pShader->shaderInfo.cPatchConstantSignature = pSignatureHeader->numPatchConstantSignatures;
1547 memcpy(pShader->shaderInfo.aPatchConstantSignature, pu8Signatures, pSignatureHeader->numPatchConstantSignatures * sizeof(SVGA3dDXSignatureEntry));
1548 }
1549 }
1550 }
1551
1552 return rc;
1553}
1554
1555
1556int vmsvga3dDXBindShader(PVGASTATECC pThisCC, SVGA3dCmdDXBindShader const *pCmd, PVMSVGAMOB pMob)
1557{
1558 int rc;
1559 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1560 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindShader, VERR_INVALID_STATE);
1561 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1562 AssertReturn(p3dState, VERR_INVALID_STATE);
1563
1564 PVMSVGA3DDXCONTEXT pDXContext;
1565 rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
1566 AssertRCReturn(rc, rc);
1567
1568 ASSERT_GUEST_RETURN(pCmd->shid < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
1569 RT_UNTRUSTED_VALIDATED_FENCE();
1570
1571 SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[pCmd->shid];
1572 //pEntry->type;
1573 //pEntry->sizeInBytes;
1574 pEntry->offsetInBytes = pCmd->offsetInBytes;
1575 pEntry->mobid = vmsvgaR3MobId(pMob);
1576
1577 if (pMob)
1578 {
1579 /* Bind a mob to the shader. */
1580
1581 /* Create a memory pointer for the MOB, which is accessible by host. */
1582 rc = vmsvgaR3MobBackingStoreCreate(pSvgaR3State, pMob, vmsvgaR3MobSize(pMob));
1583 if (RT_SUCCESS(rc))
1584 {
1585 /* Get pointer to the shader bytecode. This will also verify the offset. */
1586 void const *pvShaderBytecode = vmsvgaR3MobBackingStorePtr(pMob, pEntry->offsetInBytes);
1587 ASSERT_GUEST_RETURN(pvShaderBytecode, VERR_INVALID_PARAMETER);
1588
1589 PVMSVGA3DSHADER pShader = &pDXContext->paShader[pCmd->shid];
1590 Assert( pShader->id == pCmd->shid
1591 && pShader->type == pEntry->type); /* The host ensures this. */
1592
1593 /* Get the shader and optional signatures from the MOB. */
1594 rc = dxBindShader(pShader, pMob, pEntry, pvShaderBytecode);
1595 if (RT_SUCCESS(rc))
1596 rc = pSvgaR3State->pFuncsDX->pfnDXBindShader(pThisCC, pDXContext, pShader, pvShaderBytecode);
1597
1598 if (RT_FAILURE(rc))
1599 {
1600 /** @todo Any cleanup? */
1601 vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
1602 }
1603 }
1604 }
1605 else
1606 {
1607 /* Unbind. */
1608 /** @todo Nothing to do here but release the MOB? */
1609 vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
1610 }
1611
1612 return rc;
1613}
1614
1615
1616int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd)
1617{
1618 int rc;
1619 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1620 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput, 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 SVGA3dStreamOutputId const soid = pCmd->soid;
1629
1630 ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
1631 ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
1632 ASSERT_GUEST_RETURN(pCmd->numOutputStreamEntries < SVGA3D_MAX_DX10_STREAMOUT_DECLS, VERR_INVALID_PARAMETER);
1633 RT_UNTRUSTED_VALIDATED_FENCE();
1634
1635 SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
1636 pEntry->numOutputStreamEntries = pCmd->numOutputStreamEntries;
1637 memcpy(pEntry->decl, pCmd->decl, sizeof(pEntry->decl));
1638 memcpy(pEntry->streamOutputStrideInBytes, pCmd->streamOutputStrideInBytes, sizeof(pEntry->streamOutputStrideInBytes));
1639 pEntry->rasterizedStream = 0; // Apparently invalid in this command: pCmd->rasterizedStream;
1640 pEntry->numOutputStreamStrides = 0;
1641 pEntry->mobid = SVGA_ID_INVALID;
1642 pEntry->offsetInBytes = 0;
1643 pEntry->usesMob = 0;
1644 pEntry->pad0 = 0;
1645 pEntry->pad1 = 0;
1646 RT_ZERO(pEntry->pad2);
1647
1648 rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput(pThisCC, pDXContext, soid, pEntry);
1649 return rc;
1650}
1651
1652
1653int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd)
1654{
1655 int rc;
1656 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1657 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput, VERR_INVALID_STATE);
1658 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1659 AssertReturn(p3dState, VERR_INVALID_STATE);
1660
1661 PVMSVGA3DDXCONTEXT pDXContext;
1662 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1663 AssertRCReturn(rc, rc);
1664
1665 SVGA3dStreamOutputId const soid = pCmd->soid;
1666
1667 ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
1668 ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
1669 RT_UNTRUSTED_VALIDATED_FENCE();
1670
1671 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput(pThisCC, pDXContext, soid);
1672
1673 SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
1674 RT_ZERO(*pEntry);
1675 pEntry->mobid = SVGA_ID_INVALID;
1676
1677 return rc;
1678}
1679
1680
1681int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStreamOutput const *pCmd)
1682{
1683 int rc;
1684 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1685 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput, VERR_INVALID_STATE);
1686 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1687 AssertReturn(p3dState, VERR_INVALID_STATE);
1688
1689 PVMSVGA3DDXCONTEXT pDXContext;
1690 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1691 AssertRCReturn(rc, rc);
1692
1693 SVGA3dStreamOutputId const soid = pCmd->soid;
1694
1695 ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
1696 ASSERT_GUEST_RETURN( soid == SVGA_ID_INVALID
1697 || soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
1698 RT_UNTRUSTED_VALIDATED_FENCE();
1699
1700 rc = pSvgaR3State->pFuncsDX->pfnDXSetStreamOutput(pThisCC, pDXContext, soid);
1701 if (RT_SUCCESS(rc))
1702 pDXContext->svgaDXContext.streamOut.soid = soid;
1703
1704 return rc;
1705}
1706
1707
1708int vmsvga3dDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, PVMSVGAMOB pMob)
1709{
1710 int rc;
1711 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1712 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCOTable, VERR_INVALID_STATE);
1713 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1714 AssertReturn(p3dState, VERR_INVALID_STATE);
1715
1716 PVMSVGA3DDXCONTEXT pDXContext;
1717 rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
1718 AssertRCReturn(rc, rc);
1719 RT_UNTRUSTED_VALIDATED_FENCE();
1720
1721 ASSERT_GUEST_RETURN(pCmd->type < RT_ELEMENTS(pDXContext->aCOTMobs), VERR_INVALID_PARAMETER);
1722 RT_UNTRUSTED_VALIDATED_FENCE();
1723
1724 uint32_t validSizeInBytes;
1725 uint32_t cbCOT;
1726 if (pMob)
1727 {
1728 /* Bind a mob to the COTable. */
1729 validSizeInBytes = pCmd->validSizeInBytes;
1730 cbCOT = vmsvgaR3MobSize(pMob);
1731
1732 ASSERT_GUEST_RETURN(validSizeInBytes <= cbCOT, VERR_INVALID_PARAMETER);
1733 RT_UNTRUSTED_VALIDATED_FENCE();
1734
1735 /* Create a memory pointer, which is accessible by host. */
1736 rc = vmsvgaR3MobBackingStoreCreate(pSvgaR3State, pMob, validSizeInBytes);
1737 }
1738 else
1739 {
1740 /* Unbind. */
1741 validSizeInBytes = 0;
1742 cbCOT = 0;
1743 vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pDXContext->aCOTMobs[pCmd->type]);
1744 }
1745
1746 uint32_t cEntries = 0;
1747 uint32_t cValidEntries = 0;
1748 if (RT_SUCCESS(rc))
1749 {
1750 static uint32_t const s_acbEntry[SVGA_COTABLE_MAX] =
1751 {
1752 sizeof(SVGACOTableDXRTViewEntry),
1753 sizeof(SVGACOTableDXDSViewEntry),
1754 sizeof(SVGACOTableDXSRViewEntry),
1755 sizeof(SVGACOTableDXElementLayoutEntry),
1756 sizeof(SVGACOTableDXBlendStateEntry),
1757 sizeof(SVGACOTableDXDepthStencilEntry),
1758 sizeof(SVGACOTableDXRasterizerStateEntry),
1759 sizeof(SVGACOTableDXSamplerEntry),
1760 sizeof(SVGACOTableDXStreamOutputEntry),
1761 sizeof(SVGACOTableDXQueryEntry),
1762 sizeof(SVGACOTableDXShaderEntry),
1763 sizeof(SVGACOTableDXUAViewEntry),
1764 };
1765
1766 cEntries = cbCOT / s_acbEntry[pCmd->type];
1767 cValidEntries = validSizeInBytes / s_acbEntry[pCmd->type];
1768 }
1769
1770 if (RT_SUCCESS(rc))
1771 {
1772 pDXContext->aCOTMobs[pCmd->type] = pMob;
1773
1774 void *pvCOT = vmsvgaR3MobBackingStorePtr(pMob, 0);
1775 switch (pCmd->type)
1776 {
1777 case SVGA_COTABLE_RTVIEW:
1778 pDXContext->cot.paRTView = (SVGACOTableDXRTViewEntry *)pvCOT;
1779 pDXContext->cot.cRTView = cEntries;
1780 break;
1781 case SVGA_COTABLE_DSVIEW:
1782 pDXContext->cot.paDSView = (SVGACOTableDXDSViewEntry *)pvCOT;
1783 pDXContext->cot.cDSView = cEntries;
1784 break;
1785 case SVGA_COTABLE_SRVIEW:
1786 pDXContext->cot.paSRView = (SVGACOTableDXSRViewEntry *)pvCOT;
1787 pDXContext->cot.cSRView = cEntries;
1788 break;
1789 case SVGA_COTABLE_ELEMENTLAYOUT:
1790 pDXContext->cot.paElementLayout = (SVGACOTableDXElementLayoutEntry *)pvCOT;
1791 pDXContext->cot.cElementLayout = cEntries;
1792 break;
1793 case SVGA_COTABLE_BLENDSTATE:
1794 pDXContext->cot.paBlendState = (SVGACOTableDXBlendStateEntry *)pvCOT;
1795 pDXContext->cot.cBlendState = cEntries;
1796 break;
1797 case SVGA_COTABLE_DEPTHSTENCIL:
1798 pDXContext->cot.paDepthStencil = (SVGACOTableDXDepthStencilEntry *)pvCOT;
1799 pDXContext->cot.cDepthStencil = cEntries;
1800 break;
1801 case SVGA_COTABLE_RASTERIZERSTATE:
1802 pDXContext->cot.paRasterizerState = (SVGACOTableDXRasterizerStateEntry *)pvCOT;
1803 pDXContext->cot.cRasterizerState = cEntries;
1804 break;
1805 case SVGA_COTABLE_SAMPLER:
1806 pDXContext->cot.paSampler = (SVGACOTableDXSamplerEntry *)pvCOT;
1807 pDXContext->cot.cSampler = cEntries;
1808 break;
1809 case SVGA_COTABLE_STREAMOUTPUT:
1810 pDXContext->cot.paStreamOutput = (SVGACOTableDXStreamOutputEntry *)pvCOT;
1811 pDXContext->cot.cStreamOutput = cEntries;
1812 break;
1813 case SVGA_COTABLE_DXQUERY:
1814 pDXContext->cot.paQuery = (SVGACOTableDXQueryEntry *)pvCOT;
1815 pDXContext->cot.cQuery = cEntries;
1816 break;
1817 case SVGA_COTABLE_DXSHADER:
1818 pDXContext->cot.paShader = (SVGACOTableDXShaderEntry *)pvCOT;
1819 pDXContext->cot.cShader = cEntries;
1820
1821 /* Create host array for information about shaders. */
1822 RTMemFree(pDXContext->paShader);
1823 pDXContext->paShader = NULL;
1824
1825 if (pDXContext->cot.cShader)
1826 {
1827 pDXContext->paShader = (PVMSVGA3DSHADER)RTMemAllocZ(pDXContext->cot.cShader * sizeof(VMSVGA3DSHADER));
1828 AssertReturn(pDXContext->paShader, VERR_NO_MEMORY);
1829 for (uint32_t i = 0; i < pDXContext->cot.cShader; ++i)
1830 pDXContext->paShader[i].id = SVGA_ID_INVALID;
1831 }
1832 break;
1833 case SVGA_COTABLE_UAVIEW:
1834 pDXContext->cot.paUAView = (SVGACOTableDXUAViewEntry *)pvCOT;
1835 pDXContext->cot.cUAView = cEntries;
1836 break;
1837 case SVGA_COTABLE_MAX: break; /* Compiler warning */
1838 }
1839 }
1840 else
1841 vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob);
1842
1843 /* Notify the backend. */
1844 if (RT_SUCCESS(rc))
1845 rc = pSvgaR3State->pFuncsDX->pfnDXSetCOTable(pThisCC, pDXContext, pCmd->type, cValidEntries);
1846
1847 return rc;
1848}
1849
1850
1851int vmsvga3dDXReadbackCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackCOTable const *pCmd)
1852{
1853 int rc;
1854 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1855 AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
1856 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1857 AssertReturn(p3dState, VERR_INVALID_STATE);
1858
1859 PVMSVGA3DDXCONTEXT pDXContext;
1860 rc = vmsvga3dDXContextFromCid(p3dState, pCmd->cid, &pDXContext);
1861 AssertRCReturn(rc, rc);
1862 RT_UNTRUSTED_VALIDATED_FENCE();
1863
1864 ASSERT_GUEST_RETURN(pCmd->type < RT_ELEMENTS(pDXContext->aCOTMobs), VERR_INVALID_PARAMETER);
1865 RT_UNTRUSTED_VALIDATED_FENCE();
1866
1867 PVMSVGAMOB pMob = pDXContext->aCOTMobs[pCmd->type];
1868 rc = vmsvgaR3MobBackingStoreWriteToGuest(pSvgaR3State, pMob);
1869 return rc;
1870}
1871
1872
1873int vmsvga3dDXBufferCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
1874{
1875 int rc;
1876 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1877 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBufferCopy, VERR_INVALID_STATE);
1878 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1879 AssertReturn(p3dState, VERR_INVALID_STATE);
1880
1881 PVMSVGA3DDXCONTEXT pDXContext;
1882 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1883 AssertRCReturn(rc, rc);
1884
1885 rc = pSvgaR3State->pFuncsDX->pfnDXBufferCopy(pThisCC, pDXContext);
1886 return rc;
1887}
1888
1889
1890int vmsvga3dDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext)
1891{
1892 int rc;
1893 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1894 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSurfaceCopyAndReadback, VERR_INVALID_STATE);
1895 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1896 AssertReturn(p3dState, VERR_INVALID_STATE);
1897
1898 PVMSVGA3DDXCONTEXT pDXContext;
1899 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1900 AssertRCReturn(rc, rc);
1901
1902 rc = pSvgaR3State->pFuncsDX->pfnDXSurfaceCopyAndReadback(pThisCC, pDXContext);
1903 return rc;
1904}
1905
1906
1907int vmsvga3dDXMoveQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
1908{
1909 int rc;
1910 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1911 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXMoveQuery, VERR_INVALID_STATE);
1912 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1913 AssertReturn(p3dState, VERR_INVALID_STATE);
1914
1915 PVMSVGA3DDXCONTEXT pDXContext;
1916 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1917 AssertRCReturn(rc, rc);
1918
1919 rc = pSvgaR3State->pFuncsDX->pfnDXMoveQuery(pThisCC, pDXContext);
1920 return rc;
1921}
1922
1923
1924int vmsvga3dDXBindAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
1925{
1926 int rc;
1927 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1928 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindAllQuery, VERR_INVALID_STATE);
1929 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1930 AssertReturn(p3dState, VERR_INVALID_STATE);
1931
1932 PVMSVGA3DDXCONTEXT pDXContext;
1933 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1934 AssertRCReturn(rc, rc);
1935
1936 rc = pSvgaR3State->pFuncsDX->pfnDXBindAllQuery(pThisCC, pDXContext);
1937 return rc;
1938}
1939
1940
1941int vmsvga3dDXReadbackAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext)
1942{
1943 int rc;
1944 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1945 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXReadbackAllQuery, VERR_INVALID_STATE);
1946 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1947 AssertReturn(p3dState, VERR_INVALID_STATE);
1948
1949 PVMSVGA3DDXCONTEXT pDXContext;
1950 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1951 AssertRCReturn(rc, rc);
1952
1953 rc = pSvgaR3State->pFuncsDX->pfnDXReadbackAllQuery(pThisCC, pDXContext);
1954 return rc;
1955}
1956
1957
1958int vmsvga3dDXMobFence64(PVGASTATECC pThisCC, uint32_t idDXContext)
1959{
1960 int rc;
1961 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1962 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXMobFence64, VERR_INVALID_STATE);
1963 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1964 AssertReturn(p3dState, VERR_INVALID_STATE);
1965
1966 PVMSVGA3DDXCONTEXT pDXContext;
1967 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1968 AssertRCReturn(rc, rc);
1969
1970 rc = pSvgaR3State->pFuncsDX->pfnDXMobFence64(pThisCC, pDXContext);
1971 return rc;
1972}
1973
1974
1975int vmsvga3dDXBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext)
1976{
1977 int rc;
1978 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1979 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindAllShader, VERR_INVALID_STATE);
1980 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1981 AssertReturn(p3dState, VERR_INVALID_STATE);
1982
1983 PVMSVGA3DDXCONTEXT pDXContext;
1984 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
1985 AssertRCReturn(rc, rc);
1986
1987 rc = pSvgaR3State->pFuncsDX->pfnDXBindAllShader(pThisCC, pDXContext);
1988 return rc;
1989}
1990
1991
1992int vmsvga3dDXHint(PVGASTATECC pThisCC, uint32_t idDXContext)
1993{
1994 int rc;
1995 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
1996 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXHint, VERR_INVALID_STATE);
1997 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
1998 AssertReturn(p3dState, VERR_INVALID_STATE);
1999
2000 PVMSVGA3DDXCONTEXT pDXContext;
2001 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2002 AssertRCReturn(rc, rc);
2003
2004 rc = pSvgaR3State->pFuncsDX->pfnDXHint(pThisCC, pDXContext);
2005 return rc;
2006}
2007
2008
2009int vmsvga3dDXBufferUpdate(PVGASTATECC pThisCC, uint32_t idDXContext)
2010{
2011 int rc;
2012 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2013 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBufferUpdate, VERR_INVALID_STATE);
2014 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2015 AssertReturn(p3dState, VERR_INVALID_STATE);
2016
2017 PVMSVGA3DDXCONTEXT pDXContext;
2018 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2019 AssertRCReturn(rc, rc);
2020
2021 rc = pSvgaR3State->pFuncsDX->pfnDXBufferUpdate(pThisCC, pDXContext);
2022 return rc;
2023}
2024
2025
2026int vmsvga3dDXSetVSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2027{
2028 int rc;
2029 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2030 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetVSConstantBufferOffset, VERR_INVALID_STATE);
2031 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2032 AssertReturn(p3dState, VERR_INVALID_STATE);
2033
2034 PVMSVGA3DDXCONTEXT pDXContext;
2035 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2036 AssertRCReturn(rc, rc);
2037
2038 rc = pSvgaR3State->pFuncsDX->pfnDXSetVSConstantBufferOffset(pThisCC, pDXContext);
2039 return rc;
2040}
2041
2042
2043int vmsvga3dDXSetPSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2044{
2045 int rc;
2046 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2047 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetPSConstantBufferOffset, VERR_INVALID_STATE);
2048 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2049 AssertReturn(p3dState, VERR_INVALID_STATE);
2050
2051 PVMSVGA3DDXCONTEXT pDXContext;
2052 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2053 AssertRCReturn(rc, rc);
2054
2055 rc = pSvgaR3State->pFuncsDX->pfnDXSetPSConstantBufferOffset(pThisCC, pDXContext);
2056 return rc;
2057}
2058
2059
2060int vmsvga3dDXSetGSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2061{
2062 int rc;
2063 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2064 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetGSConstantBufferOffset, VERR_INVALID_STATE);
2065 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2066 AssertReturn(p3dState, VERR_INVALID_STATE);
2067
2068 PVMSVGA3DDXCONTEXT pDXContext;
2069 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2070 AssertRCReturn(rc, rc);
2071
2072 rc = pSvgaR3State->pFuncsDX->pfnDXSetGSConstantBufferOffset(pThisCC, pDXContext);
2073 return rc;
2074}
2075
2076
2077int vmsvga3dDXSetHSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2078{
2079 int rc;
2080 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2081 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetHSConstantBufferOffset, VERR_INVALID_STATE);
2082 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2083 AssertReturn(p3dState, VERR_INVALID_STATE);
2084
2085 PVMSVGA3DDXCONTEXT pDXContext;
2086 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2087 AssertRCReturn(rc, rc);
2088
2089 rc = pSvgaR3State->pFuncsDX->pfnDXSetHSConstantBufferOffset(pThisCC, pDXContext);
2090 return rc;
2091}
2092
2093
2094int vmsvga3dDXSetDSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2095{
2096 int rc;
2097 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2098 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetDSConstantBufferOffset, VERR_INVALID_STATE);
2099 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2100 AssertReturn(p3dState, VERR_INVALID_STATE);
2101
2102 PVMSVGA3DDXCONTEXT pDXContext;
2103 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2104 AssertRCReturn(rc, rc);
2105
2106 rc = pSvgaR3State->pFuncsDX->pfnDXSetDSConstantBufferOffset(pThisCC, pDXContext);
2107 return rc;
2108}
2109
2110
2111int vmsvga3dDXSetCSConstantBufferOffset(PVGASTATECC pThisCC, uint32_t idDXContext)
2112{
2113 int rc;
2114 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2115 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCSConstantBufferOffset, VERR_INVALID_STATE);
2116 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2117 AssertReturn(p3dState, VERR_INVALID_STATE);
2118
2119 PVMSVGA3DDXCONTEXT pDXContext;
2120 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2121 AssertRCReturn(rc, rc);
2122
2123 rc = pSvgaR3State->pFuncsDX->pfnDXSetCSConstantBufferOffset(pThisCC, pDXContext);
2124 return rc;
2125}
2126
2127
2128int vmsvga3dDXCondBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext)
2129{
2130 int rc;
2131 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2132 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXCondBindAllShader, VERR_INVALID_STATE);
2133 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2134 AssertReturn(p3dState, VERR_INVALID_STATE);
2135
2136 PVMSVGA3DDXCONTEXT pDXContext;
2137 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2138 AssertRCReturn(rc, rc);
2139
2140 rc = pSvgaR3State->pFuncsDX->pfnDXCondBindAllShader(pThisCC, pDXContext);
2141 return rc;
2142}
2143
2144
2145int vmsvga3dScreenCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
2146{
2147 int rc;
2148 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2149 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnScreenCopy, VERR_INVALID_STATE);
2150 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2151 AssertReturn(p3dState, VERR_INVALID_STATE);
2152
2153 PVMSVGA3DDXCONTEXT pDXContext;
2154 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2155 AssertRCReturn(rc, rc);
2156
2157 rc = pSvgaR3State->pFuncsDX->pfnScreenCopy(pThisCC, pDXContext);
2158 return rc;
2159}
2160
2161
2162int vmsvga3dGrowOTable(PVGASTATECC pThisCC, uint32_t idDXContext)
2163{
2164 int rc;
2165 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2166 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnGrowOTable, VERR_INVALID_STATE);
2167 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2168 AssertReturn(p3dState, VERR_INVALID_STATE);
2169
2170 PVMSVGA3DDXCONTEXT pDXContext;
2171 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2172 AssertRCReturn(rc, rc);
2173
2174 rc = pSvgaR3State->pFuncsDX->pfnGrowOTable(pThisCC, pDXContext);
2175 return rc;
2176}
2177
2178
2179int vmsvga3dDXGrowCOTable(PVGASTATECC pThisCC, uint32_t idDXContext)
2180{
2181 int rc;
2182 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2183 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXGrowCOTable, VERR_INVALID_STATE);
2184 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2185 AssertReturn(p3dState, VERR_INVALID_STATE);
2186
2187 PVMSVGA3DDXCONTEXT pDXContext;
2188 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2189 AssertRCReturn(rc, rc);
2190
2191 rc = pSvgaR3State->pFuncsDX->pfnDXGrowCOTable(pThisCC, pDXContext);
2192 return rc;
2193}
2194
2195
2196int vmsvga3dIntraSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
2197{
2198 int rc;
2199 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2200 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnIntraSurfaceCopy, VERR_INVALID_STATE);
2201 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2202 AssertReturn(p3dState, VERR_INVALID_STATE);
2203
2204 PVMSVGA3DDXCONTEXT pDXContext;
2205 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2206 AssertRCReturn(rc, rc);
2207
2208 rc = pSvgaR3State->pFuncsDX->pfnIntraSurfaceCopy(pThisCC, pDXContext);
2209 return rc;
2210}
2211
2212
2213int vmsvga3dDefineGBSurface_v3(PVGASTATECC pThisCC, uint32_t idDXContext)
2214{
2215 int rc;
2216 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2217 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDefineGBSurface_v3, VERR_INVALID_STATE);
2218 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2219 AssertReturn(p3dState, VERR_INVALID_STATE);
2220
2221 PVMSVGA3DDXCONTEXT pDXContext;
2222 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2223 AssertRCReturn(rc, rc);
2224
2225 rc = pSvgaR3State->pFuncsDX->pfnDefineGBSurface_v3(pThisCC, pDXContext);
2226 return rc;
2227}
2228
2229
2230int vmsvga3dDXResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
2231{
2232 int rc;
2233 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2234 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXResolveCopy, VERR_INVALID_STATE);
2235 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2236 AssertReturn(p3dState, VERR_INVALID_STATE);
2237
2238 PVMSVGA3DDXCONTEXT pDXContext;
2239 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2240 AssertRCReturn(rc, rc);
2241
2242 rc = pSvgaR3State->pFuncsDX->pfnDXResolveCopy(pThisCC, pDXContext);
2243 return rc;
2244}
2245
2246
2247int vmsvga3dDXPredResolveCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
2248{
2249 int rc;
2250 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2251 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredResolveCopy, VERR_INVALID_STATE);
2252 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2253 AssertReturn(p3dState, VERR_INVALID_STATE);
2254
2255 PVMSVGA3DDXCONTEXT pDXContext;
2256 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2257 AssertRCReturn(rc, rc);
2258
2259 rc = pSvgaR3State->pFuncsDX->pfnDXPredResolveCopy(pThisCC, pDXContext);
2260 return rc;
2261}
2262
2263
2264int vmsvga3dDXPredConvertRegion(PVGASTATECC pThisCC, uint32_t idDXContext)
2265{
2266 int rc;
2267 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2268 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredConvertRegion, VERR_INVALID_STATE);
2269 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2270 AssertReturn(p3dState, VERR_INVALID_STATE);
2271
2272 PVMSVGA3DDXCONTEXT pDXContext;
2273 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2274 AssertRCReturn(rc, rc);
2275
2276 rc = pSvgaR3State->pFuncsDX->pfnDXPredConvertRegion(pThisCC, pDXContext);
2277 return rc;
2278}
2279
2280
2281int vmsvga3dDXPredConvert(PVGASTATECC pThisCC, uint32_t idDXContext)
2282{
2283 int rc;
2284 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2285 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredConvert, VERR_INVALID_STATE);
2286 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2287 AssertReturn(p3dState, VERR_INVALID_STATE);
2288
2289 PVMSVGA3DDXCONTEXT pDXContext;
2290 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2291 AssertRCReturn(rc, rc);
2292
2293 rc = pSvgaR3State->pFuncsDX->pfnDXPredConvert(pThisCC, pDXContext);
2294 return rc;
2295}
2296
2297
2298int vmsvga3dWholeSurfaceCopy(PVGASTATECC pThisCC, uint32_t idDXContext)
2299{
2300 int rc;
2301 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2302 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnWholeSurfaceCopy, VERR_INVALID_STATE);
2303 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2304 AssertReturn(p3dState, VERR_INVALID_STATE);
2305
2306 PVMSVGA3DDXCONTEXT pDXContext;
2307 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2308 AssertRCReturn(rc, rc);
2309
2310 rc = pSvgaR3State->pFuncsDX->pfnWholeSurfaceCopy(pThisCC, pDXContext);
2311 return rc;
2312}
2313
2314
2315int vmsvga3dDXDefineUAView(PVGASTATECC pThisCC, uint32_t idDXContext)
2316{
2317 int rc;
2318 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2319 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineUAView, VERR_INVALID_STATE);
2320 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2321 AssertReturn(p3dState, VERR_INVALID_STATE);
2322
2323 PVMSVGA3DDXCONTEXT pDXContext;
2324 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2325 AssertRCReturn(rc, rc);
2326
2327 rc = pSvgaR3State->pFuncsDX->pfnDXDefineUAView(pThisCC, pDXContext);
2328 return rc;
2329}
2330
2331
2332int vmsvga3dDXDestroyUAView(PVGASTATECC pThisCC, uint32_t idDXContext)
2333{
2334 int rc;
2335 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2336 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDestroyUAView, VERR_INVALID_STATE);
2337 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2338 AssertReturn(p3dState, VERR_INVALID_STATE);
2339
2340 PVMSVGA3DDXCONTEXT pDXContext;
2341 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2342 AssertRCReturn(rc, rc);
2343
2344 rc = pSvgaR3State->pFuncsDX->pfnDXDestroyUAView(pThisCC, pDXContext);
2345 return rc;
2346}
2347
2348
2349int vmsvga3dDXClearUAViewUint(PVGASTATECC pThisCC, uint32_t idDXContext)
2350{
2351 int rc;
2352 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2353 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearUAViewUint, VERR_INVALID_STATE);
2354 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2355 AssertReturn(p3dState, VERR_INVALID_STATE);
2356
2357 PVMSVGA3DDXCONTEXT pDXContext;
2358 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2359 AssertRCReturn(rc, rc);
2360
2361 rc = pSvgaR3State->pFuncsDX->pfnDXClearUAViewUint(pThisCC, pDXContext);
2362 return rc;
2363}
2364
2365
2366int vmsvga3dDXClearUAViewFloat(PVGASTATECC pThisCC, uint32_t idDXContext)
2367{
2368 int rc;
2369 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2370 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXClearUAViewFloat, VERR_INVALID_STATE);
2371 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2372 AssertReturn(p3dState, VERR_INVALID_STATE);
2373
2374 PVMSVGA3DDXCONTEXT pDXContext;
2375 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2376 AssertRCReturn(rc, rc);
2377
2378 rc = pSvgaR3State->pFuncsDX->pfnDXClearUAViewFloat(pThisCC, pDXContext);
2379 return rc;
2380}
2381
2382
2383int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext)
2384{
2385 int rc;
2386 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2387 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount, VERR_INVALID_STATE);
2388 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2389 AssertReturn(p3dState, VERR_INVALID_STATE);
2390
2391 PVMSVGA3DDXCONTEXT pDXContext;
2392 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2393 AssertRCReturn(rc, rc);
2394
2395 rc = pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount(pThisCC, pDXContext);
2396 return rc;
2397}
2398
2399
2400int vmsvga3dDXSetUAViews(PVGASTATECC pThisCC, uint32_t idDXContext)
2401{
2402 int rc;
2403 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2404 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetUAViews, VERR_INVALID_STATE);
2405 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2406 AssertReturn(p3dState, VERR_INVALID_STATE);
2407
2408 PVMSVGA3DDXCONTEXT pDXContext;
2409 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2410 AssertRCReturn(rc, rc);
2411
2412 rc = pSvgaR3State->pFuncsDX->pfnDXSetUAViews(pThisCC, pDXContext);
2413 return rc;
2414}
2415
2416
2417int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
2418{
2419 int rc;
2420 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2421 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect, VERR_INVALID_STATE);
2422 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2423 AssertReturn(p3dState, VERR_INVALID_STATE);
2424
2425 PVMSVGA3DDXCONTEXT pDXContext;
2426 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2427 AssertRCReturn(rc, rc);
2428
2429 rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect(pThisCC, pDXContext);
2430 return rc;
2431}
2432
2433
2434int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
2435{
2436 int rc;
2437 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2438 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect, VERR_INVALID_STATE);
2439 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2440 AssertReturn(p3dState, VERR_INVALID_STATE);
2441
2442 PVMSVGA3DDXCONTEXT pDXContext;
2443 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2444 AssertRCReturn(rc, rc);
2445
2446 rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect(pThisCC, pDXContext);
2447 return rc;
2448}
2449
2450
2451int vmsvga3dDXDispatch(PVGASTATECC pThisCC, uint32_t idDXContext)
2452{
2453 int rc;
2454 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2455 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDispatch, VERR_INVALID_STATE);
2456 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2457 AssertReturn(p3dState, VERR_INVALID_STATE);
2458
2459 PVMSVGA3DDXCONTEXT pDXContext;
2460 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2461 AssertRCReturn(rc, rc);
2462
2463 rc = pSvgaR3State->pFuncsDX->pfnDXDispatch(pThisCC, pDXContext);
2464 return rc;
2465}
2466
2467
2468int vmsvga3dDXDispatchIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
2469{
2470 int rc;
2471 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2472 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDispatchIndirect, VERR_INVALID_STATE);
2473 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2474 AssertReturn(p3dState, VERR_INVALID_STATE);
2475
2476 PVMSVGA3DDXCONTEXT pDXContext;
2477 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2478 AssertRCReturn(rc, rc);
2479
2480 rc = pSvgaR3State->pFuncsDX->pfnDXDispatchIndirect(pThisCC, pDXContext);
2481 return rc;
2482}
2483
2484
2485int vmsvga3dWriteZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext)
2486{
2487 int rc;
2488 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2489 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnWriteZeroSurface, VERR_INVALID_STATE);
2490 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2491 AssertReturn(p3dState, VERR_INVALID_STATE);
2492
2493 PVMSVGA3DDXCONTEXT pDXContext;
2494 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2495 AssertRCReturn(rc, rc);
2496
2497 rc = pSvgaR3State->pFuncsDX->pfnWriteZeroSurface(pThisCC, pDXContext);
2498 return rc;
2499}
2500
2501
2502int vmsvga3dHintZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext)
2503{
2504 int rc;
2505 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2506 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnHintZeroSurface, VERR_INVALID_STATE);
2507 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2508 AssertReturn(p3dState, VERR_INVALID_STATE);
2509
2510 PVMSVGA3DDXCONTEXT pDXContext;
2511 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2512 AssertRCReturn(rc, rc);
2513
2514 rc = pSvgaR3State->pFuncsDX->pfnHintZeroSurface(pThisCC, pDXContext);
2515 return rc;
2516}
2517
2518
2519int vmsvga3dDXTransferToBuffer(PVGASTATECC pThisCC, uint32_t idDXContext)
2520{
2521 int rc;
2522 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2523 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXTransferToBuffer, VERR_INVALID_STATE);
2524 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2525 AssertReturn(p3dState, VERR_INVALID_STATE);
2526
2527 PVMSVGA3DDXCONTEXT pDXContext;
2528 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2529 AssertRCReturn(rc, rc);
2530
2531 rc = pSvgaR3State->pFuncsDX->pfnDXTransferToBuffer(pThisCC, pDXContext);
2532 return rc;
2533}
2534
2535
2536int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext)
2537{
2538 int rc;
2539 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2540 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetStructureCount, VERR_INVALID_STATE);
2541 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2542 AssertReturn(p3dState, VERR_INVALID_STATE);
2543
2544 PVMSVGA3DDXCONTEXT pDXContext;
2545 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2546 AssertRCReturn(rc, rc);
2547
2548 rc = pSvgaR3State->pFuncsDX->pfnDXSetStructureCount(pThisCC, pDXContext);
2549 return rc;
2550}
2551
2552
2553int vmsvga3dLogicOpsBitBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
2554{
2555 int rc;
2556 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2557 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsBitBlt, VERR_INVALID_STATE);
2558 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2559 AssertReturn(p3dState, VERR_INVALID_STATE);
2560
2561 PVMSVGA3DDXCONTEXT pDXContext;
2562 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2563 AssertRCReturn(rc, rc);
2564
2565 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsBitBlt(pThisCC, pDXContext);
2566 return rc;
2567}
2568
2569
2570int vmsvga3dLogicOpsTransBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
2571{
2572 int rc;
2573 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2574 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsTransBlt, VERR_INVALID_STATE);
2575 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2576 AssertReturn(p3dState, VERR_INVALID_STATE);
2577
2578 PVMSVGA3DDXCONTEXT pDXContext;
2579 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2580 AssertRCReturn(rc, rc);
2581
2582 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsTransBlt(pThisCC, pDXContext);
2583 return rc;
2584}
2585
2586
2587int vmsvga3dLogicOpsStretchBlt(PVGASTATECC pThisCC, uint32_t idDXContext)
2588{
2589 int rc;
2590 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2591 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsStretchBlt, VERR_INVALID_STATE);
2592 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2593 AssertReturn(p3dState, VERR_INVALID_STATE);
2594
2595 PVMSVGA3DDXCONTEXT pDXContext;
2596 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2597 AssertRCReturn(rc, rc);
2598
2599 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsStretchBlt(pThisCC, pDXContext);
2600 return rc;
2601}
2602
2603
2604int vmsvga3dLogicOpsColorFill(PVGASTATECC pThisCC, uint32_t idDXContext)
2605{
2606 int rc;
2607 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2608 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsColorFill, VERR_INVALID_STATE);
2609 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2610 AssertReturn(p3dState, VERR_INVALID_STATE);
2611
2612 PVMSVGA3DDXCONTEXT pDXContext;
2613 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2614 AssertRCReturn(rc, rc);
2615
2616 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsColorFill(pThisCC, pDXContext);
2617 return rc;
2618}
2619
2620
2621int vmsvga3dLogicOpsAlphaBlend(PVGASTATECC pThisCC, uint32_t idDXContext)
2622{
2623 int rc;
2624 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2625 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsAlphaBlend, VERR_INVALID_STATE);
2626 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2627 AssertReturn(p3dState, VERR_INVALID_STATE);
2628
2629 PVMSVGA3DDXCONTEXT pDXContext;
2630 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2631 AssertRCReturn(rc, rc);
2632
2633 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsAlphaBlend(pThisCC, pDXContext);
2634 return rc;
2635}
2636
2637
2638int vmsvga3dLogicOpsClearTypeBlend(PVGASTATECC pThisCC, uint32_t idDXContext)
2639{
2640 int rc;
2641 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2642 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnLogicOpsClearTypeBlend, VERR_INVALID_STATE);
2643 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2644 AssertReturn(p3dState, VERR_INVALID_STATE);
2645
2646 PVMSVGA3DDXCONTEXT pDXContext;
2647 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2648 AssertRCReturn(rc, rc);
2649
2650 rc = pSvgaR3State->pFuncsDX->pfnLogicOpsClearTypeBlend(pThisCC, pDXContext);
2651 return rc;
2652}
2653
2654
2655int vmsvga3dDefineGBSurface_v4(PVGASTATECC pThisCC, uint32_t idDXContext)
2656{
2657 int rc;
2658 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2659 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDefineGBSurface_v4, VERR_INVALID_STATE);
2660 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2661 AssertReturn(p3dState, VERR_INVALID_STATE);
2662
2663 PVMSVGA3DDXCONTEXT pDXContext;
2664 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2665 AssertRCReturn(rc, rc);
2666
2667 rc = pSvgaR3State->pFuncsDX->pfnDefineGBSurface_v4(pThisCC, pDXContext);
2668 return rc;
2669}
2670
2671
2672int vmsvga3dDXSetCSUAViews(PVGASTATECC pThisCC, uint32_t idDXContext)
2673{
2674 int rc;
2675 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2676 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetCSUAViews, VERR_INVALID_STATE);
2677 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2678 AssertReturn(p3dState, VERR_INVALID_STATE);
2679
2680 PVMSVGA3DDXCONTEXT pDXContext;
2681 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2682 AssertRCReturn(rc, rc);
2683
2684 rc = pSvgaR3State->pFuncsDX->pfnDXSetCSUAViews(pThisCC, pDXContext);
2685 return rc;
2686}
2687
2688
2689int vmsvga3dDXSetMinLOD(PVGASTATECC pThisCC, uint32_t idDXContext)
2690{
2691 int rc;
2692 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2693 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetMinLOD, VERR_INVALID_STATE);
2694 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2695 AssertReturn(p3dState, VERR_INVALID_STATE);
2696
2697 PVMSVGA3DDXCONTEXT pDXContext;
2698 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2699 AssertRCReturn(rc, rc);
2700
2701 rc = pSvgaR3State->pFuncsDX->pfnDXSetMinLOD(pThisCC, pDXContext);
2702 return rc;
2703}
2704
2705
2706int vmsvga3dDXDefineStreamOutputWithMob(PVGASTATECC pThisCC, uint32_t idDXContext)
2707{
2708 int rc;
2709 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2710 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutputWithMob, VERR_INVALID_STATE);
2711 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2712 AssertReturn(p3dState, VERR_INVALID_STATE);
2713
2714 PVMSVGA3DDXCONTEXT pDXContext;
2715 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2716 AssertRCReturn(rc, rc);
2717
2718 rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutputWithMob(pThisCC, pDXContext);
2719 return rc;
2720}
2721
2722
2723int vmsvga3dDXSetShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext)
2724{
2725 int rc;
2726 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2727 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetShaderIface, VERR_INVALID_STATE);
2728 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2729 AssertReturn(p3dState, VERR_INVALID_STATE);
2730
2731 PVMSVGA3DDXCONTEXT pDXContext;
2732 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2733 AssertRCReturn(rc, rc);
2734
2735 rc = pSvgaR3State->pFuncsDX->pfnDXSetShaderIface(pThisCC, pDXContext);
2736 return rc;
2737}
2738
2739
2740int vmsvga3dDXBindStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext)
2741{
2742 int rc;
2743 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2744 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindStreamOutput, VERR_INVALID_STATE);
2745 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2746 AssertReturn(p3dState, VERR_INVALID_STATE);
2747
2748 PVMSVGA3DDXCONTEXT pDXContext;
2749 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2750 AssertRCReturn(rc, rc);
2751
2752 rc = pSvgaR3State->pFuncsDX->pfnDXBindStreamOutput(pThisCC, pDXContext);
2753 return rc;
2754}
2755
2756
2757int vmsvga3dSurfaceStretchBltNonMSToMS(PVGASTATECC pThisCC, uint32_t idDXContext)
2758{
2759 int rc;
2760 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2761 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnSurfaceStretchBltNonMSToMS, VERR_INVALID_STATE);
2762 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2763 AssertReturn(p3dState, VERR_INVALID_STATE);
2764
2765 PVMSVGA3DDXCONTEXT pDXContext;
2766 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2767 AssertRCReturn(rc, rc);
2768
2769 rc = pSvgaR3State->pFuncsDX->pfnSurfaceStretchBltNonMSToMS(pThisCC, pDXContext);
2770 return rc;
2771}
2772
2773
2774int vmsvga3dDXBindShaderIface(PVGASTATECC pThisCC, uint32_t idDXContext)
2775{
2776 int rc;
2777 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
2778 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXBindShaderIface, VERR_INVALID_STATE);
2779 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
2780 AssertReturn(p3dState, VERR_INVALID_STATE);
2781
2782 PVMSVGA3DDXCONTEXT pDXContext;
2783 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
2784 AssertRCReturn(rc, rc);
2785
2786 rc = pSvgaR3State->pFuncsDX->pfnDXBindShaderIface(pThisCC, pDXContext);
2787 return rc;
2788}
2789
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette