diff options
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c index d7ed33e732a0..62d6377b8ee8 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | |||
@@ -505,3 +505,60 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno) | |||
505 | out_err: | 505 | out_err: |
506 | return ret; | 506 | return ret; |
507 | } | 507 | } |
508 | |||
509 | /** | ||
510 | * vmw_fifo_emit_dummy_query - emits a dummy query to the fifo. | ||
511 | * | ||
512 | * @dev_priv: The device private structure. | ||
513 | * @cid: The hardware context id used for the query. | ||
514 | * | ||
515 | * This function is used to emit a dummy occlusion query with | ||
516 | * no primitives rendered between query begin and query end. | ||
517 | * It's used to provide a query barrier, in order to know that when | ||
518 | * this query is finished, all preceding queries are also finished. | ||
519 | * | ||
520 | * A Query results structure should have been initialized at the start | ||
521 | * of the dev_priv->dummy_query_bo buffer object. And that buffer object | ||
522 | * must also be either reserved or pinned when this function is called. | ||
523 | * | ||
524 | * Returns -ENOMEM on failure to reserve fifo space. | ||
525 | */ | ||
526 | int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, | ||
527 | uint32_t cid) | ||
528 | { | ||
529 | /* | ||
530 | * A query wait without a preceding query end will | ||
531 | * actually finish all queries for this cid | ||
532 | * without writing to the query result structure. | ||
533 | */ | ||
534 | |||
535 | struct ttm_buffer_object *bo = dev_priv->dummy_query_bo; | ||
536 | struct { | ||
537 | SVGA3dCmdHeader header; | ||
538 | SVGA3dCmdWaitForQuery body; | ||
539 | } *cmd; | ||
540 | |||
541 | cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd)); | ||
542 | |||
543 | if (unlikely(cmd == NULL)) { | ||
544 | DRM_ERROR("Out of fifo space for dummy query.\n"); | ||
545 | return -ENOMEM; | ||
546 | } | ||
547 | |||
548 | cmd->header.id = SVGA_3D_CMD_WAIT_FOR_QUERY; | ||
549 | cmd->header.size = sizeof(cmd->body); | ||
550 | cmd->body.cid = cid; | ||
551 | cmd->body.type = SVGA3D_QUERYTYPE_OCCLUSION; | ||
552 | |||
553 | if (bo->mem.mem_type == TTM_PL_VRAM) { | ||
554 | cmd->body.guestResult.gmrId = SVGA_GMR_FRAMEBUFFER; | ||
555 | cmd->body.guestResult.offset = bo->offset; | ||
556 | } else { | ||
557 | cmd->body.guestResult.gmrId = bo->mem.start; | ||
558 | cmd->body.guestResult.offset = 0; | ||
559 | } | ||
560 | |||
561 | vmw_fifo_commit(dev_priv, sizeof(*cmd)); | ||
562 | |||
563 | return 0; | ||
564 | } | ||