Changeset 86203 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 21, 2020 3:10:26 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r86197 r86203 3175 3175 * header. Will break out of the switch if it doesn't. 3176 3176 */ 3177 # define VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(a_cbMin) \3177 # define VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(a_cbMin) \ 3178 3178 if (1) { \ 3179 3179 AssertMsgBreak(cbCmd >= (a_cbMin), ("size=%#x a_cbMin=%#zx\n", cbCmd, (size_t)(a_cbMin))); \ … … 3188 3188 * @param cbCmd Size of the command in bytes. 3189 3189 * @param pvCmd Pointer to the command. 3190 * @returns VBox status code if an error was detected parsing a command. 3190 3191 */ 3191 3192 static int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cmdId, uint32_t cbCmd, void const *pvCmd) 3192 3193 { 3193 int rc = VINF_SUCCESS; 3194 PVMSVGAR3STATE pSVGAState = pThisCC->svga.pSvgaR3State; 3195 3196 switch (cmdId) 3197 { 3198 case SVGA_3D_CMD_SURFACE_DEFINE: 3199 { 3200 uint32_t cMipLevels; 3201 SVGA3dCmdDefineSurface *pCmd = (SVGA3dCmdDefineSurface *)pvCmd; 3202 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3203 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceDefine); 3204 3205 cMipLevels = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize); 3206 rc = vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, (uint32_t)pCmd->surfaceFlags, pCmd->format, pCmd->face, 0, 3207 SVGA3D_TEX_FILTER_NONE, cMipLevels, (SVGA3dSize *)(pCmd + 1)); 3208 # ifdef DEBUG_GMR_ACCESS 3209 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis); 3210 # endif 3211 break; 3212 } 3213 3214 case SVGA_3D_CMD_SURFACE_DEFINE_V2: 3215 { 3216 uint32_t cMipLevels; 3217 SVGA3dCmdDefineSurface_v2 *pCmd = (SVGA3dCmdDefineSurface_v2 *)pvCmd; 3218 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3219 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceDefineV2); 3220 3221 cMipLevels = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize); 3222 rc = vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, pCmd->face, 3223 pCmd->multisampleCount, pCmd->autogenFilter, 3224 cMipLevels, (SVGA3dSize *)(pCmd + 1)); 3225 break; 3226 } 3227 3228 case SVGA_3D_CMD_SURFACE_DESTROY: 3229 { 3230 SVGA3dCmdDestroySurface *pCmd = (SVGA3dCmdDestroySurface *)pvCmd; 3231 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3232 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceDestroy); 3233 rc = vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid); 3234 break; 3235 } 3236 3237 case SVGA_3D_CMD_SURFACE_COPY: 3238 { 3239 uint32_t cCopyBoxes; 3240 SVGA3dCmdSurfaceCopy *pCmd = (SVGA3dCmdSurfaceCopy *)pvCmd; 3241 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3242 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceCopy); 3243 3244 cCopyBoxes = (cbCmd - sizeof(pCmd)) / sizeof(SVGA3dCopyBox); 3245 rc = vmsvga3dSurfaceCopy(pThisCC, pCmd->dest, pCmd->src, cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1)); 3246 break; 3247 } 3248 3249 case SVGA_3D_CMD_SURFACE_STRETCHBLT: 3250 { 3251 SVGA3dCmdSurfaceStretchBlt *pCmd = (SVGA3dCmdSurfaceStretchBlt *)pvCmd; 3252 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3253 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceStretchBlt); 3254 3255 rc = vmsvga3dSurfaceStretchBlt(pThis, pThisCC, &pCmd->dest, &pCmd->boxDest, 3256 &pCmd->src, &pCmd->boxSrc, pCmd->mode); 3257 break; 3258 } 3259 3260 case SVGA_3D_CMD_SURFACE_DMA: 3261 { 3262 uint32_t cCopyBoxes; 3263 SVGA3dCmdSurfaceDMA *pCmd = (SVGA3dCmdSurfaceDMA *)pvCmd; 3264 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3265 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceDma); 3266 3267 uint64_t u64NanoTS = 0; 3268 if (LogRelIs3Enabled()) 3269 u64NanoTS = RTTimeNanoTS(); 3270 cCopyBoxes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyBox); 3271 STAM_PROFILE_START(&pSVGAState->StatR3Cmd3dSurfaceDmaProf, a); 3272 rc = vmsvga3dSurfaceDMA(pThis, pThisCC, pCmd->guest, pCmd->host, pCmd->transfer, 3273 cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1)); 3274 STAM_PROFILE_STOP(&pSVGAState->StatR3Cmd3dSurfaceDmaProf, a); 3275 if (LogRelIs3Enabled()) 3276 { 3277 if (cCopyBoxes) 3278 { 3279 SVGA3dCopyBox *pFirstBox = (SVGA3dCopyBox *)(pCmd + 1); 3280 LogRel3(("VMSVGA: SURFACE_DMA: %d us %d boxes %d,%d %dx%d%s\n", 3281 (RTTimeNanoTS() - u64NanoTS) / 1000ULL, cCopyBoxes, 3282 pFirstBox->x, pFirstBox->y, pFirstBox->w, pFirstBox->h, 3283 pCmd->transfer == SVGA3D_READ_HOST_VRAM ? " readback!!!" : "")); 3284 } 3285 } 3286 break; 3287 } 3288 3289 case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN: 3290 { 3291 uint32_t cRects; 3292 SVGA3dCmdBlitSurfaceToScreen *pCmd = (SVGA3dCmdBlitSurfaceToScreen *)pvCmd; 3293 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3294 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSurfaceScreen); 3295 3296 static uint64_t u64FrameStartNanoTS = 0; 3297 static uint64_t u64ElapsedPerSecNano = 0; 3298 static int cFrames = 0; 3299 uint64_t u64NanoTS = 0; 3300 if (LogRelIs3Enabled()) 3301 u64NanoTS = RTTimeNanoTS(); 3302 cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect); 3303 STAM_REL_PROFILE_START(&pSVGAState->StatR3Cmd3dBlitSurfaceToScreenProf, a); 3304 rc = vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage, 3305 pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1)); 3306 STAM_REL_PROFILE_STOP(&pSVGAState->StatR3Cmd3dBlitSurfaceToScreenProf, a); 3307 if (LogRelIs3Enabled()) 3308 { 3309 uint64_t u64ElapsedNano = RTTimeNanoTS() - u64NanoTS; 3310 u64ElapsedPerSecNano += u64ElapsedNano; 3311 3312 SVGASignedRect *pFirstRect = cRects ? (SVGASignedRect *)(pCmd + 1) : &pCmd->destRect; 3313 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: %d us %d rects %d,%d %dx%d\n", 3314 (u64ElapsedNano) / 1000ULL, cRects, 3315 pFirstRect->left, pFirstRect->top, 3316 pFirstRect->right - pFirstRect->left, pFirstRect->bottom - pFirstRect->top)); 3317 3318 ++cFrames; 3319 if (u64NanoTS - u64FrameStartNanoTS >= UINT64_C(1000000000)) 3320 { 3321 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: FPS %d, elapsed %llu us\n", 3322 cFrames, u64ElapsedPerSecNano / 1000ULL)); 3323 u64FrameStartNanoTS = u64NanoTS; 3324 cFrames = 0; 3325 u64ElapsedPerSecNano = 0; 3326 } 3327 } 3328 break; 3329 } 3330 3331 case SVGA_3D_CMD_CONTEXT_DEFINE: 3332 { 3333 SVGA3dCmdDefineContext *pCmd = (SVGA3dCmdDefineContext *)pvCmd; 3334 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3335 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dContextDefine); 3336 3337 rc = vmsvga3dContextDefine(pThisCC, pCmd->cid); 3338 break; 3339 } 3340 3341 case SVGA_3D_CMD_CONTEXT_DESTROY: 3342 { 3343 SVGA3dCmdDestroyContext *pCmd = (SVGA3dCmdDestroyContext *)pvCmd; 3344 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3345 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dContextDestroy); 3346 3347 rc = vmsvga3dContextDestroy(pThisCC, pCmd->cid); 3348 break; 3349 } 3350 3351 case SVGA_3D_CMD_SETTRANSFORM: 3352 { 3353 SVGA3dCmdSetTransform *pCmd = (SVGA3dCmdSetTransform *)pvCmd; 3354 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3355 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetTransform); 3356 3357 rc = vmsvga3dSetTransform(pThisCC, pCmd->cid, pCmd->type, pCmd->matrix); 3358 break; 3359 } 3360 3361 case SVGA_3D_CMD_SETZRANGE: 3362 { 3363 SVGA3dCmdSetZRange *pCmd = (SVGA3dCmdSetZRange *)pvCmd; 3364 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3365 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetZRange); 3366 3367 rc = vmsvga3dSetZRange(pThisCC, pCmd->cid, pCmd->zRange); 3368 break; 3369 } 3370 3371 case SVGA_3D_CMD_SETRENDERSTATE: 3372 { 3373 uint32_t cRenderStates; 3374 SVGA3dCmdSetRenderState *pCmd = (SVGA3dCmdSetRenderState *)pvCmd; 3375 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3376 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetRenderState); 3377 3378 cRenderStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderState); 3379 rc = vmsvga3dSetRenderState(pThisCC, pCmd->cid, cRenderStates, (SVGA3dRenderState *)(pCmd + 1)); 3380 break; 3381 } 3382 3383 case SVGA_3D_CMD_SETRENDERTARGET: 3384 { 3385 SVGA3dCmdSetRenderTarget *pCmd = (SVGA3dCmdSetRenderTarget *)pvCmd; 3386 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3387 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetRenderTarget); 3388 3389 rc = vmsvga3dSetRenderTarget(pThisCC, pCmd->cid, pCmd->type, pCmd->target); 3390 break; 3391 } 3392 3393 case SVGA_3D_CMD_SETTEXTURESTATE: 3394 { 3395 uint32_t cTextureStates; 3396 SVGA3dCmdSetTextureState *pCmd = (SVGA3dCmdSetTextureState *)pvCmd; 3397 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3398 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetTextureState); 3399 3400 cTextureStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dTextureState); 3401 rc = vmsvga3dSetTextureState(pThisCC, pCmd->cid, cTextureStates, (SVGA3dTextureState *)(pCmd + 1)); 3402 break; 3403 } 3404 3405 case SVGA_3D_CMD_SETMATERIAL: 3406 { 3407 SVGA3dCmdSetMaterial *pCmd = (SVGA3dCmdSetMaterial *)pvCmd; 3408 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3409 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetMaterial); 3410 3411 rc = vmsvga3dSetMaterial(pThisCC, pCmd->cid, pCmd->face, &pCmd->material); 3412 break; 3413 } 3414 3415 case SVGA_3D_CMD_SETLIGHTDATA: 3416 { 3417 SVGA3dCmdSetLightData *pCmd = (SVGA3dCmdSetLightData *)pvCmd; 3418 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3419 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetLightData); 3420 3421 rc = vmsvga3dSetLightData(pThisCC, pCmd->cid, pCmd->index, &pCmd->data); 3422 break; 3423 } 3424 3425 case SVGA_3D_CMD_SETLIGHTENABLED: 3426 { 3427 SVGA3dCmdSetLightEnabled *pCmd = (SVGA3dCmdSetLightEnabled *)pvCmd; 3428 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3429 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetLightEnable); 3430 3431 rc = vmsvga3dSetLightEnabled(pThisCC, pCmd->cid, pCmd->index, pCmd->enabled); 3432 break; 3433 } 3434 3435 case SVGA_3D_CMD_SETVIEWPORT: 3436 { 3437 SVGA3dCmdSetViewport *pCmd = (SVGA3dCmdSetViewport *)pvCmd; 3438 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3439 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetViewPort); 3440 3441 rc = vmsvga3dSetViewPort(pThisCC, pCmd->cid, &pCmd->rect); 3442 break; 3443 } 3444 3445 case SVGA_3D_CMD_SETCLIPPLANE: 3446 { 3447 SVGA3dCmdSetClipPlane *pCmd = (SVGA3dCmdSetClipPlane *)pvCmd; 3448 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3449 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetClipPlane); 3450 3451 rc = vmsvga3dSetClipPlane(pThisCC, pCmd->cid, pCmd->index, pCmd->plane); 3452 break; 3453 } 3454 3455 case SVGA_3D_CMD_CLEAR: 3456 { 3457 SVGA3dCmdClear *pCmd = (SVGA3dCmdClear *)pvCmd; 3458 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3459 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dClear); 3460 3461 uint32_t cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRect); 3462 rc = vmsvga3dCommandClear(pThisCC, pCmd->cid, pCmd->clearFlag, pCmd->color, pCmd->depth, pCmd->stencil, cRects, (SVGA3dRect *)(pCmd + 1)); 3463 break; 3464 } 3465 3466 case SVGA_3D_CMD_PRESENT: 3467 case SVGA_3D_CMD_PRESENT_READBACK: /** @todo SVGA_3D_CMD_PRESENT_READBACK isn't quite the same as present... */ 3468 { 3469 SVGA3dCmdPresent *pCmd = (SVGA3dCmdPresent *)pvCmd; 3470 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3471 if (cmdId == SVGA_3D_CMD_PRESENT) 3472 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dPresent); 3473 else 3474 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dPresentReadBack); 3475 3476 uint32_t cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyRect); 3477 3478 STAM_PROFILE_START(&pSVGAState->StatR3Cmd3dPresentProf, a); 3479 rc = vmsvga3dCommandPresent(pThis, pThisCC, pCmd->sid, cRects, (SVGA3dCopyRect *)(pCmd + 1)); 3480 STAM_PROFILE_STOP(&pSVGAState->StatR3Cmd3dPresentProf, a); 3481 break; 3482 } 3483 3484 case SVGA_3D_CMD_SHADER_DEFINE: 3485 { 3486 SVGA3dCmdDefineShader *pCmd = (SVGA3dCmdDefineShader *)pvCmd; 3487 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3488 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dShaderDefine); 3489 3490 uint32_t cbData = (cbCmd - sizeof(*pCmd)); 3491 rc = vmsvga3dShaderDefine(pThisCC, pCmd->cid, pCmd->shid, pCmd->type, cbData, (uint32_t *)(pCmd + 1)); 3492 break; 3493 } 3494 3495 case SVGA_3D_CMD_SHADER_DESTROY: 3496 { 3497 SVGA3dCmdDestroyShader *pCmd = (SVGA3dCmdDestroyShader *)pvCmd; 3498 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3499 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dShaderDestroy); 3500 3501 rc = vmsvga3dShaderDestroy(pThisCC, pCmd->cid, pCmd->shid, pCmd->type); 3502 break; 3503 } 3504 3505 case SVGA_3D_CMD_SET_SHADER: 3506 { 3507 SVGA3dCmdSetShader *pCmd = (SVGA3dCmdSetShader *)pvCmd; 3508 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3509 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetShader); 3510 3511 rc = vmsvga3dShaderSet(pThisCC, NULL, pCmd->cid, pCmd->type, pCmd->shid); 3512 break; 3513 } 3514 3515 case SVGA_3D_CMD_SET_SHADER_CONST: 3516 { 3517 SVGA3dCmdSetShaderConst *pCmd = (SVGA3dCmdSetShaderConst *)pvCmd; 3518 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3519 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetShaderConst); 3520 3521 uint32_t cRegisters = (cbCmd - sizeof(*pCmd)) / sizeof(pCmd->values) + 1; 3522 rc = vmsvga3dShaderSetConst(pThisCC, pCmd->cid, pCmd->reg, pCmd->type, pCmd->ctype, cRegisters, pCmd->values); 3523 break; 3524 } 3525 3526 case SVGA_3D_CMD_DRAW_PRIMITIVES: 3527 { 3528 SVGA3dCmdDrawPrimitives *pCmd = (SVGA3dCmdDrawPrimitives *)pvCmd; 3529 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3530 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dDrawPrimitives); 3531 3532 AssertBreak(pCmd->numRanges <= SVGA3D_MAX_DRAW_PRIMITIVE_RANGES); 3533 AssertBreak(pCmd->numVertexDecls <= SVGA3D_MAX_VERTEX_ARRAYS); 3534 uint32_t const cbRangesAndVertexDecls = pCmd->numVertexDecls * sizeof(SVGA3dVertexDecl) 3535 + pCmd->numRanges * sizeof(SVGA3dPrimitiveRange); 3536 ASSERT_GUEST_BREAK(cbRangesAndVertexDecls <= cbCmd - sizeof(*pCmd)); 3537 3538 uint32_t cVertexDivisor = (cbCmd - sizeof(*pCmd) - cbRangesAndVertexDecls) / sizeof(uint32_t); 3539 AssertBreak(!cVertexDivisor || cVertexDivisor == pCmd->numVertexDecls); 3540 3541 RT_UNTRUSTED_VALIDATED_FENCE(); 3542 3543 SVGA3dVertexDecl *pVertexDecl = (SVGA3dVertexDecl *)(pCmd + 1); 3544 SVGA3dPrimitiveRange *pNumRange = (SVGA3dPrimitiveRange *)&pVertexDecl[pCmd->numVertexDecls]; 3545 SVGA3dVertexDivisor *pVertexDivisor = cVertexDivisor ? (SVGA3dVertexDivisor *)&pNumRange[pCmd->numRanges] : NULL; 3546 3547 STAM_PROFILE_START(&pSVGAState->StatR3Cmd3dDrawPrimitivesProf, a); 3548 rc = vmsvga3dDrawPrimitives(pThisCC, pCmd->cid, pCmd->numVertexDecls, pVertexDecl, pCmd->numRanges, 3549 pNumRange, cVertexDivisor, pVertexDivisor); 3550 STAM_PROFILE_STOP(&pSVGAState->StatR3Cmd3dDrawPrimitivesProf, a); 3551 break; 3552 } 3553 3554 case SVGA_3D_CMD_SETSCISSORRECT: 3555 { 3556 SVGA3dCmdSetScissorRect *pCmd = (SVGA3dCmdSetScissorRect *)pvCmd; 3557 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3558 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dSetScissorRect); 3559 3560 rc = vmsvga3dSetScissorRect(pThisCC, pCmd->cid, &pCmd->rect); 3561 break; 3562 } 3563 3564 case SVGA_3D_CMD_BEGIN_QUERY: 3565 { 3566 SVGA3dCmdBeginQuery *pCmd = (SVGA3dCmdBeginQuery *)pvCmd; 3567 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3568 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dBeginQuery); 3569 3570 rc = vmsvga3dQueryBegin(pThisCC, pCmd->cid, pCmd->type); 3571 break; 3572 } 3573 3574 case SVGA_3D_CMD_END_QUERY: 3575 { 3576 SVGA3dCmdEndQuery *pCmd = (SVGA3dCmdEndQuery *)pvCmd; 3577 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3578 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dEndQuery); 3579 3580 rc = vmsvga3dQueryEnd(pThisCC, pCmd->cid, pCmd->type, pCmd->guestResult); 3581 break; 3582 } 3583 3584 case SVGA_3D_CMD_WAIT_FOR_QUERY: 3585 { 3586 SVGA3dCmdWaitForQuery *pCmd = (SVGA3dCmdWaitForQuery *)pvCmd; 3587 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3588 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dWaitForQuery); 3589 3590 rc = vmsvga3dQueryWait(pThis, pThisCC, pCmd->cid, pCmd->type, pCmd->guestResult); 3591 break; 3592 } 3593 3594 case SVGA_3D_CMD_GENERATE_MIPMAPS: 3595 { 3596 SVGA3dCmdGenerateMipmaps *pCmd = (SVGA3dCmdGenerateMipmaps *)pvCmd; 3597 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3598 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dGenerateMipmaps); 3599 3600 rc = vmsvga3dGenerateMipmaps(pThisCC, pCmd->sid, pCmd->filter); 3601 break; 3602 } 3603 3604 case SVGA_3D_CMD_ACTIVATE_SURFACE: 3605 /* context id + surface id? */ 3606 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dActivateSurface); 3607 break; 3608 case SVGA_3D_CMD_DEACTIVATE_SURFACE: 3609 /* context id + surface id? */ 3610 STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dDeactivateSurface); 3611 break; 3612 3613 default: 3614 STAM_REL_COUNTER_INC(&pSVGAState->StatFifoUnkCmds); 3615 AssertMsgFailed(("cmdId=%d\n", cmdId)); 3616 break; 3617 } 3618 3619 return rc; 3620 } 3621 # undef VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK 3194 int rcParse = VINF_SUCCESS; 3195 PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State; 3196 3197 switch (cmdId) 3198 { 3199 case SVGA_3D_CMD_SURFACE_DEFINE: 3200 { 3201 SVGA3dCmdDefineSurface *pCmd = (SVGA3dCmdDefineSurface *)pvCmd; 3202 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3203 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefine); 3204 3205 uint32_t const cMipLevels = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize); 3206 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, (uint32_t)pCmd->surfaceFlags, pCmd->format, pCmd->face, 0, 3207 SVGA3D_TEX_FILTER_NONE, cMipLevels, (SVGA3dSize *)(pCmd + 1)); 3208 # ifdef DEBUG_GMR_ACCESS 3209 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis); 3210 # endif 3211 break; 3212 } 3213 3214 case SVGA_3D_CMD_SURFACE_DEFINE_V2: 3215 { 3216 SVGA3dCmdDefineSurface_v2 *pCmd = (SVGA3dCmdDefineSurface_v2 *)pvCmd; 3217 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3218 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDefineV2); 3219 3220 uint32_t const cMipLevels = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSize); 3221 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, pCmd->face, 3222 pCmd->multisampleCount, pCmd->autogenFilter, 3223 cMipLevels, (SVGA3dSize *)(pCmd + 1)); 3224 break; 3225 } 3226 3227 case SVGA_3D_CMD_SURFACE_DESTROY: 3228 { 3229 SVGA3dCmdDestroySurface *pCmd = (SVGA3dCmdDestroySurface *)pvCmd; 3230 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3231 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDestroy); 3232 3233 vmsvga3dSurfaceDestroy(pThisCC, pCmd->sid); 3234 break; 3235 } 3236 3237 case SVGA_3D_CMD_SURFACE_COPY: 3238 { 3239 SVGA3dCmdSurfaceCopy *pCmd = (SVGA3dCmdSurfaceCopy *)pvCmd; 3240 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3241 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceCopy); 3242 3243 uint32_t const cCopyBoxes = (cbCmd - sizeof(pCmd)) / sizeof(SVGA3dCopyBox); 3244 vmsvga3dSurfaceCopy(pThisCC, pCmd->dest, pCmd->src, cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1)); 3245 break; 3246 } 3247 3248 case SVGA_3D_CMD_SURFACE_STRETCHBLT: 3249 { 3250 SVGA3dCmdSurfaceStretchBlt *pCmd = (SVGA3dCmdSurfaceStretchBlt *)pvCmd; 3251 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3252 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceStretchBlt); 3253 3254 vmsvga3dSurfaceStretchBlt(pThis, pThisCC, &pCmd->dest, &pCmd->boxDest, 3255 &pCmd->src, &pCmd->boxSrc, pCmd->mode); 3256 break; 3257 } 3258 3259 case SVGA_3D_CMD_SURFACE_DMA: 3260 { 3261 SVGA3dCmdSurfaceDMA *pCmd = (SVGA3dCmdSurfaceDMA *)pvCmd; 3262 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3263 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceDma); 3264 3265 uint64_t u64NanoTS = 0; 3266 if (LogRelIs3Enabled()) 3267 u64NanoTS = RTTimeNanoTS(); 3268 uint32_t const cCopyBoxes = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyBox); 3269 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a); 3270 vmsvga3dSurfaceDMA(pThis, pThisCC, pCmd->guest, pCmd->host, pCmd->transfer, 3271 cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1)); 3272 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dSurfaceDmaProf, a); 3273 if (LogRelIs3Enabled()) 3274 { 3275 if (cCopyBoxes) 3276 { 3277 SVGA3dCopyBox *pFirstBox = (SVGA3dCopyBox *)(pCmd + 1); 3278 LogRel3(("VMSVGA: SURFACE_DMA: %d us %d boxes %d,%d %dx%d%s\n", 3279 (RTTimeNanoTS() - u64NanoTS) / 1000ULL, cCopyBoxes, 3280 pFirstBox->x, pFirstBox->y, pFirstBox->w, pFirstBox->h, 3281 pCmd->transfer == SVGA3D_READ_HOST_VRAM ? " readback!!!" : "")); 3282 } 3283 } 3284 break; 3285 } 3286 3287 case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN: 3288 { 3289 SVGA3dCmdBlitSurfaceToScreen *pCmd = (SVGA3dCmdBlitSurfaceToScreen *)pvCmd; 3290 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3291 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSurfaceScreen); 3292 3293 static uint64_t u64FrameStartNanoTS = 0; 3294 static uint64_t u64ElapsedPerSecNano = 0; 3295 static int cFrames = 0; 3296 uint64_t u64NanoTS = 0; 3297 if (LogRelIs3Enabled()) 3298 u64NanoTS = RTTimeNanoTS(); 3299 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGASignedRect); 3300 STAM_REL_PROFILE_START(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a); 3301 vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage, 3302 pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1)); 3303 STAM_REL_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dBlitSurfaceToScreenProf, a); 3304 if (LogRelIs3Enabled()) 3305 { 3306 uint64_t u64ElapsedNano = RTTimeNanoTS() - u64NanoTS; 3307 u64ElapsedPerSecNano += u64ElapsedNano; 3308 3309 SVGASignedRect *pFirstRect = cRects ? (SVGASignedRect *)(pCmd + 1) : &pCmd->destRect; 3310 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: %d us %d rects %d,%d %dx%d\n", 3311 (u64ElapsedNano) / 1000ULL, cRects, 3312 pFirstRect->left, pFirstRect->top, 3313 pFirstRect->right - pFirstRect->left, pFirstRect->bottom - pFirstRect->top)); 3314 3315 ++cFrames; 3316 if (u64NanoTS - u64FrameStartNanoTS >= UINT64_C(1000000000)) 3317 { 3318 LogRel3(("VMSVGA: SURFACE_TO_SCREEN: FPS %d, elapsed %llu us\n", 3319 cFrames, u64ElapsedPerSecNano / 1000ULL)); 3320 u64FrameStartNanoTS = u64NanoTS; 3321 cFrames = 0; 3322 u64ElapsedPerSecNano = 0; 3323 } 3324 } 3325 break; 3326 } 3327 3328 case SVGA_3D_CMD_CONTEXT_DEFINE: 3329 { 3330 SVGA3dCmdDefineContext *pCmd = (SVGA3dCmdDefineContext *)pvCmd; 3331 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3332 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDefine); 3333 3334 vmsvga3dContextDefine(pThisCC, pCmd->cid); 3335 break; 3336 } 3337 3338 case SVGA_3D_CMD_CONTEXT_DESTROY: 3339 { 3340 SVGA3dCmdDestroyContext *pCmd = (SVGA3dCmdDestroyContext *)pvCmd; 3341 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3342 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dContextDestroy); 3343 3344 vmsvga3dContextDestroy(pThisCC, pCmd->cid); 3345 break; 3346 } 3347 3348 case SVGA_3D_CMD_SETTRANSFORM: 3349 { 3350 SVGA3dCmdSetTransform *pCmd = (SVGA3dCmdSetTransform *)pvCmd; 3351 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3352 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTransform); 3353 3354 vmsvga3dSetTransform(pThisCC, pCmd->cid, pCmd->type, pCmd->matrix); 3355 break; 3356 } 3357 3358 case SVGA_3D_CMD_SETZRANGE: 3359 { 3360 SVGA3dCmdSetZRange *pCmd = (SVGA3dCmdSetZRange *)pvCmd; 3361 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3362 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetZRange); 3363 3364 vmsvga3dSetZRange(pThisCC, pCmd->cid, pCmd->zRange); 3365 break; 3366 } 3367 3368 case SVGA_3D_CMD_SETRENDERSTATE: 3369 { 3370 SVGA3dCmdSetRenderState *pCmd = (SVGA3dCmdSetRenderState *)pvCmd; 3371 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3372 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderState); 3373 3374 uint32_t const cRenderStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRenderState); 3375 vmsvga3dSetRenderState(pThisCC, pCmd->cid, cRenderStates, (SVGA3dRenderState *)(pCmd + 1)); 3376 break; 3377 } 3378 3379 case SVGA_3D_CMD_SETRENDERTARGET: 3380 { 3381 SVGA3dCmdSetRenderTarget *pCmd = (SVGA3dCmdSetRenderTarget *)pvCmd; 3382 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3383 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetRenderTarget); 3384 3385 vmsvga3dSetRenderTarget(pThisCC, pCmd->cid, pCmd->type, pCmd->target); 3386 break; 3387 } 3388 3389 case SVGA_3D_CMD_SETTEXTURESTATE: 3390 { 3391 SVGA3dCmdSetTextureState *pCmd = (SVGA3dCmdSetTextureState *)pvCmd; 3392 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3393 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetTextureState); 3394 3395 uint32_t const cTextureStates = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dTextureState); 3396 vmsvga3dSetTextureState(pThisCC, pCmd->cid, cTextureStates, (SVGA3dTextureState *)(pCmd + 1)); 3397 break; 3398 } 3399 3400 case SVGA_3D_CMD_SETMATERIAL: 3401 { 3402 SVGA3dCmdSetMaterial *pCmd = (SVGA3dCmdSetMaterial *)pvCmd; 3403 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3404 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetMaterial); 3405 3406 vmsvga3dSetMaterial(pThisCC, pCmd->cid, pCmd->face, &pCmd->material); 3407 break; 3408 } 3409 3410 case SVGA_3D_CMD_SETLIGHTDATA: 3411 { 3412 SVGA3dCmdSetLightData *pCmd = (SVGA3dCmdSetLightData *)pvCmd; 3413 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3414 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetLightData); 3415 3416 vmsvga3dSetLightData(pThisCC, pCmd->cid, pCmd->index, &pCmd->data); 3417 break; 3418 } 3419 3420 case SVGA_3D_CMD_SETLIGHTENABLED: 3421 { 3422 SVGA3dCmdSetLightEnabled *pCmd = (SVGA3dCmdSetLightEnabled *)pvCmd; 3423 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3424 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetLightEnable); 3425 3426 vmsvga3dSetLightEnabled(pThisCC, pCmd->cid, pCmd->index, pCmd->enabled); 3427 break; 3428 } 3429 3430 case SVGA_3D_CMD_SETVIEWPORT: 3431 { 3432 SVGA3dCmdSetViewport *pCmd = (SVGA3dCmdSetViewport *)pvCmd; 3433 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3434 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetViewPort); 3435 3436 vmsvga3dSetViewPort(pThisCC, pCmd->cid, &pCmd->rect); 3437 break; 3438 } 3439 3440 case SVGA_3D_CMD_SETCLIPPLANE: 3441 { 3442 SVGA3dCmdSetClipPlane *pCmd = (SVGA3dCmdSetClipPlane *)pvCmd; 3443 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3444 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetClipPlane); 3445 3446 vmsvga3dSetClipPlane(pThisCC, pCmd->cid, pCmd->index, pCmd->plane); 3447 break; 3448 } 3449 3450 case SVGA_3D_CMD_CLEAR: 3451 { 3452 SVGA3dCmdClear *pCmd = (SVGA3dCmdClear *)pvCmd; 3453 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3454 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dClear); 3455 3456 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dRect); 3457 vmsvga3dCommandClear(pThisCC, pCmd->cid, pCmd->clearFlag, pCmd->color, pCmd->depth, pCmd->stencil, cRects, (SVGA3dRect *)(pCmd + 1)); 3458 break; 3459 } 3460 3461 case SVGA_3D_CMD_PRESENT: 3462 case SVGA_3D_CMD_PRESENT_READBACK: /** @todo SVGA_3D_CMD_PRESENT_READBACK isn't quite the same as present... */ 3463 { 3464 SVGA3dCmdPresent *pCmd = (SVGA3dCmdPresent *)pvCmd; 3465 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3466 if (cmdId == SVGA_3D_CMD_PRESENT) 3467 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dPresent); 3468 else 3469 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dPresentReadBack); 3470 3471 uint32_t const cRects = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dCopyRect); 3472 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dPresentProf, a); 3473 vmsvga3dCommandPresent(pThis, pThisCC, pCmd->sid, cRects, (SVGA3dCopyRect *)(pCmd + 1)); 3474 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dPresentProf, a); 3475 break; 3476 } 3477 3478 case SVGA_3D_CMD_SHADER_DEFINE: 3479 { 3480 SVGA3dCmdDefineShader *pCmd = (SVGA3dCmdDefineShader *)pvCmd; 3481 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3482 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dShaderDefine); 3483 3484 uint32_t const cbData = (cbCmd - sizeof(*pCmd)); 3485 vmsvga3dShaderDefine(pThisCC, pCmd->cid, pCmd->shid, pCmd->type, cbData, (uint32_t *)(pCmd + 1)); 3486 break; 3487 } 3488 3489 case SVGA_3D_CMD_SHADER_DESTROY: 3490 { 3491 SVGA3dCmdDestroyShader *pCmd = (SVGA3dCmdDestroyShader *)pvCmd; 3492 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3493 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dShaderDestroy); 3494 3495 vmsvga3dShaderDestroy(pThisCC, pCmd->cid, pCmd->shid, pCmd->type); 3496 break; 3497 } 3498 3499 case SVGA_3D_CMD_SET_SHADER: 3500 { 3501 SVGA3dCmdSetShader *pCmd = (SVGA3dCmdSetShader *)pvCmd; 3502 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3503 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetShader); 3504 3505 vmsvga3dShaderSet(pThisCC, NULL, pCmd->cid, pCmd->type, pCmd->shid); 3506 break; 3507 } 3508 3509 case SVGA_3D_CMD_SET_SHADER_CONST: 3510 { 3511 SVGA3dCmdSetShaderConst *pCmd = (SVGA3dCmdSetShaderConst *)pvCmd; 3512 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3513 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetShaderConst); 3514 3515 uint32_t const cRegisters = (cbCmd - sizeof(*pCmd)) / sizeof(pCmd->values) + 1; 3516 vmsvga3dShaderSetConst(pThisCC, pCmd->cid, pCmd->reg, pCmd->type, pCmd->ctype, cRegisters, pCmd->values); 3517 break; 3518 } 3519 3520 case SVGA_3D_CMD_DRAW_PRIMITIVES: 3521 { 3522 SVGA3dCmdDrawPrimitives *pCmd = (SVGA3dCmdDrawPrimitives *)pvCmd; 3523 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3524 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dDrawPrimitives); 3525 3526 ASSERT_GUEST_STMT_BREAK(pCmd->numRanges <= SVGA3D_MAX_DRAW_PRIMITIVE_RANGES, rcParse = VERR_INVALID_PARAMETER); 3527 ASSERT_GUEST_STMT_BREAK(pCmd->numVertexDecls <= SVGA3D_MAX_VERTEX_ARRAYS, rcParse = VERR_INVALID_PARAMETER); 3528 uint32_t const cbRangesAndVertexDecls = pCmd->numVertexDecls * sizeof(SVGA3dVertexDecl) 3529 + pCmd->numRanges * sizeof(SVGA3dPrimitiveRange); 3530 ASSERT_GUEST_STMT_BREAK(cbRangesAndVertexDecls <= cbCmd - sizeof(*pCmd), rcParse = VERR_INVALID_PARAMETER); 3531 3532 uint32_t const cVertexDivisor = (cbCmd - sizeof(*pCmd) - cbRangesAndVertexDecls) / sizeof(uint32_t); 3533 ASSERT_GUEST_STMT_BREAK(!cVertexDivisor || cVertexDivisor == pCmd->numVertexDecls, rcParse = VERR_INVALID_PARAMETER); 3534 RT_UNTRUSTED_VALIDATED_FENCE(); 3535 3536 SVGA3dVertexDecl *pVertexDecl = (SVGA3dVertexDecl *)(pCmd + 1); 3537 SVGA3dPrimitiveRange *pNumRange = (SVGA3dPrimitiveRange *)&pVertexDecl[pCmd->numVertexDecls]; 3538 SVGA3dVertexDivisor *pVertexDivisor = cVertexDivisor ? (SVGA3dVertexDivisor *)&pNumRange[pCmd->numRanges] : NULL; 3539 3540 STAM_PROFILE_START(&pSvgaR3State->StatR3Cmd3dDrawPrimitivesProf, a); 3541 vmsvga3dDrawPrimitives(pThisCC, pCmd->cid, pCmd->numVertexDecls, pVertexDecl, pCmd->numRanges, 3542 pNumRange, cVertexDivisor, pVertexDivisor); 3543 STAM_PROFILE_STOP(&pSvgaR3State->StatR3Cmd3dDrawPrimitivesProf, a); 3544 break; 3545 } 3546 3547 case SVGA_3D_CMD_SETSCISSORRECT: 3548 { 3549 SVGA3dCmdSetScissorRect *pCmd = (SVGA3dCmdSetScissorRect *)pvCmd; 3550 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3551 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dSetScissorRect); 3552 3553 vmsvga3dSetScissorRect(pThisCC, pCmd->cid, &pCmd->rect); 3554 break; 3555 } 3556 3557 case SVGA_3D_CMD_BEGIN_QUERY: 3558 { 3559 SVGA3dCmdBeginQuery *pCmd = (SVGA3dCmdBeginQuery *)pvCmd; 3560 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3561 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dBeginQuery); 3562 3563 vmsvga3dQueryBegin(pThisCC, pCmd->cid, pCmd->type); 3564 break; 3565 } 3566 3567 case SVGA_3D_CMD_END_QUERY: 3568 { 3569 SVGA3dCmdEndQuery *pCmd = (SVGA3dCmdEndQuery *)pvCmd; 3570 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3571 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dEndQuery); 3572 3573 vmsvga3dQueryEnd(pThisCC, pCmd->cid, pCmd->type, pCmd->guestResult); 3574 break; 3575 } 3576 3577 case SVGA_3D_CMD_WAIT_FOR_QUERY: 3578 { 3579 SVGA3dCmdWaitForQuery *pCmd = (SVGA3dCmdWaitForQuery *)pvCmd; 3580 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3581 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dWaitForQuery); 3582 3583 vmsvga3dQueryWait(pThis, pThisCC, pCmd->cid, pCmd->type, pCmd->guestResult); 3584 break; 3585 } 3586 3587 case SVGA_3D_CMD_GENERATE_MIPMAPS: 3588 { 3589 SVGA3dCmdGenerateMipmaps *pCmd = (SVGA3dCmdGenerateMipmaps *)pvCmd; 3590 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 3591 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dGenerateMipmaps); 3592 3593 vmsvga3dGenerateMipmaps(pThisCC, pCmd->sid, pCmd->filter); 3594 break; 3595 } 3596 3597 case SVGA_3D_CMD_ACTIVATE_SURFACE: 3598 /* context id + surface id? */ 3599 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dActivateSurface); 3600 break; 3601 3602 case SVGA_3D_CMD_DEACTIVATE_SURFACE: 3603 /* context id + surface id? */ 3604 STAM_REL_COUNTER_INC(&pSvgaR3State->StatR3Cmd3dDeactivateSurface); 3605 break; 3606 3607 default: 3608 STAM_REL_COUNTER_INC(&pSvgaR3State->StatFifoUnkCmds); 3609 ASSERT_GUEST_MSG_FAILED(("cmdId=%d\n", cmdId)); 3610 rcParse = VERR_NOT_IMPLEMENTED; 3611 break; 3612 } 3613 3614 return rcParse; 3615 } 3616 # undef VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK 3622 3617 # endif // VBOX_WITH_VMSVGA3D 3623 3618 … … 5119 5114 && pFIFO[SVGA_FIFO_FENCE_GOAL] == pCmd->fence) 5120 5115 { 5121 Log(("fence goal reached irq (fence=% x)\n", pCmd->fence));5116 Log(("fence goal reached irq (fence=%#x)\n", pCmd->fence)); 5122 5117 u32IrqStatus |= SVGA_IRQFLAG_FENCE_GOAL; 5123 5118 } … … 5371 5366 5372 5367 /* Command data begins after the 32 bit command length. */ 5373 vmsvgaR3Process3dCmd(pThis, pThisCC, cmdId, *pcbMore, pcbMore + 1); 5368 int rc = vmsvgaR3Process3dCmd(pThis, pThisCC, cmdId, *pcbMore, pcbMore + 1); 5369 if (RT_SUCCESS(rc)) 5370 { /* likely */ } 5371 else 5372 { 5373 CBstatus = SVGA_CB_STATUS_COMMAND_ERROR; 5374 break; 5375 } 5374 5376 } 5375 5377 else
Note:
See TracChangeset
for help on using the changeset viewer.