Lines Matching +full:1000 +full:base +full:- +full:x
4 * Copyright Red Hat, Inc. 2013-2014
11 * See the COPYING file in the top-level directory.
15 #include "qemu/error-report.h"
19 #include "hw/virtio/virtio-gpu.h"
20 #include "hw/virtio/virtio-gpu-bswap.h"
21 #include "hw/virtio/virtio-gpu-pixman.h"
23 #include "ui/egl-helpers.h"
28 struct virtio_gpu_simple_resource base; member
42 return container_of(res, struct virtio_gpu_virgl_resource, base); in virtio_gpu_virgl_find_resource()
81 vmr->finish_unmapping = true; in virtio_gpu_virgl_hostmem_region_free()
83 b = VIRTIO_GPU_BASE(vmr->g); in virtio_gpu_virgl_hostmem_region_free()
84 b->renderer_blocked--; in virtio_gpu_virgl_hostmem_region_free()
88 * virglrenderer works only on the main-loop thread that's holding GL in virtio_gpu_virgl_hostmem_region_free()
91 gl = VIRTIO_GPU_GL(vmr->g); in virtio_gpu_virgl_hostmem_region_free()
92 qemu_bh_schedule(gl->cmdq_resume_bh); in virtio_gpu_virgl_hostmem_region_free()
107 if (!virtio_gpu_hostmem_enabled(b->conf)) { in virtio_gpu_virgl_map_resource_blob()
109 return -EOPNOTSUPP; in virtio_gpu_virgl_map_resource_blob()
112 ret = virgl_renderer_resource_map(res->base.resource_id, &data, &size); in virtio_gpu_virgl_map_resource_blob()
115 __func__, strerror(-ret)); in virtio_gpu_virgl_map_resource_blob()
120 vmr->g = g; in virtio_gpu_virgl_map_resource_blob()
122 mr = &vmr->mr; in virtio_gpu_virgl_map_resource_blob()
124 memory_region_add_subregion(&b->hostmem, offset, mr); in virtio_gpu_virgl_map_resource_blob()
129 * virtio-gpu. In order to prevent unmapping resource while MR is alive, in virtio_gpu_virgl_map_resource_blob()
130 * and thus, making the data pointer invalid, we will block virtio-gpu in virtio_gpu_virgl_map_resource_blob()
133 OBJECT(mr)->free = virtio_gpu_virgl_hostmem_region_free; in virtio_gpu_virgl_map_resource_blob()
135 res->mr = mr; in virtio_gpu_virgl_map_resource_blob()
147 MemoryRegion *mr = res->mr; in virtio_gpu_virgl_unmap_resource_blob()
154 vmr = to_hostmem_region(res->mr); in virtio_gpu_virgl_unmap_resource_blob()
161 * 2. Wait for res->mr to be freed and cmd processing resumed in virtio_gpu_virgl_unmap_resource_blob()
165 if (vmr->finish_unmapping) { in virtio_gpu_virgl_unmap_resource_blob()
166 res->mr = NULL; in virtio_gpu_virgl_unmap_resource_blob()
169 ret = virgl_renderer_resource_unmap(res->base.resource_id); in virtio_gpu_virgl_unmap_resource_blob()
173 __func__, strerror(-ret)); in virtio_gpu_virgl_unmap_resource_blob()
180 b->renderer_blocked++; in virtio_gpu_virgl_unmap_resource_blob()
182 /* memory region owns self res->mr object and frees it by itself */ in virtio_gpu_virgl_unmap_resource_blob()
184 memory_region_del_subregion(&b->hostmem, mr); in virtio_gpu_virgl_unmap_resource_blob()
206 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_create_resource_2d()
214 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_create_resource_2d()
219 res->base.width = c2d.width; in virgl_cmd_create_resource_2d()
220 res->base.height = c2d.height; in virgl_cmd_create_resource_2d()
221 res->base.format = c2d.format; in virgl_cmd_create_resource_2d()
222 res->base.resource_id = c2d.resource_id; in virgl_cmd_create_resource_2d()
223 res->base.dmabuf_fd = -1; in virgl_cmd_create_resource_2d()
224 QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); in virgl_cmd_create_resource_2d()
254 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_create_resource_3d()
262 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_create_resource_3d()
267 res->base.width = c3d.width; in virgl_cmd_create_resource_3d()
268 res->base.height = c3d.height; in virgl_cmd_create_resource_3d()
269 res->base.format = c3d.format; in virgl_cmd_create_resource_3d()
270 res->base.resource_id = c3d.resource_id; in virgl_cmd_create_resource_3d()
271 res->base.dmabuf_fd = -1; in virgl_cmd_create_resource_3d()
272 QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); in virgl_cmd_create_resource_3d()
304 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_resource_unref()
310 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_unref()
326 QTAILQ_REMOVE(&g->reslist, &res->base, next); in virgl_cmd_resource_unref()
341 if (!virtio_gpu_context_init_enabled(g->parent_obj.conf)) { in virgl_cmd_context_create()
344 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_context_create()
371 static void virtio_gpu_rect_update(VirtIOGPU *g, int idx, int x, int y, in virtio_gpu_rect_update() argument
374 if (!g->parent_obj.scanout[idx].con) { in virtio_gpu_rect_update()
378 dpy_gl_update(g->parent_obj.scanout[idx].con, x, y, width, height); in virtio_gpu_rect_update()
389 rf.r.width, rf.r.height, rf.r.x, rf.r.y); in virgl_cmd_resource_flush()
391 for (i = 0; i < g->parent_obj.conf.max_outputs; i++) { in virgl_cmd_resource_flush()
392 if (g->parent_obj.scanout[i].resource_id != rf.resource_id) { in virgl_cmd_resource_flush()
395 virtio_gpu_rect_update(g, i, rf.r.x, rf.r.y, rf.r.width, rf.r.height); in virgl_cmd_resource_flush()
407 ss.r.width, ss.r.height, ss.r.x, ss.r.y); in virgl_cmd_set_scanout()
409 if (ss.scanout_id >= g->parent_obj.conf.max_outputs) { in virgl_cmd_set_scanout()
412 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; in virgl_cmd_set_scanout()
415 g->parent_obj.enable = 1; in virgl_cmd_set_scanout()
425 info = ext.base; in virgl_cmd_set_scanout()
435 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_set_scanout()
438 qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con, in virgl_cmd_set_scanout()
442 g->parent_obj.scanout[ss.scanout_id].con, info.tex_id, in virgl_cmd_set_scanout()
445 ss.r.x, ss.r.y, ss.r.width, ss.r.height, in virgl_cmd_set_scanout()
449 g->parent_obj.scanout[ss.scanout_id].con, NULL); in virgl_cmd_set_scanout()
450 dpy_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_id].con); in virgl_cmd_set_scanout()
452 g->parent_obj.scanout[ss.scanout_id].resource_id = ss.resource_id; in virgl_cmd_set_scanout()
466 s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, in virgl_cmd_submit_3d()
471 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_submit_3d()
475 if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { in virgl_cmd_submit_3d()
476 g->stats.req_3d++; in virgl_cmd_submit_3d()
477 g->stats.bytes_3d += cs.size; in virgl_cmd_submit_3d()
495 box.x = t2d.r.x; in virgl_cmd_transfer_to_host_2d()
561 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_resource_attach_backing()
626 if (info.capset_index < g->capset_ids->len) { in virgl_cmd_get_capset_info()
627 resp.capset_id = g_array_index(g->capset_ids, uint32_t, in virgl_cmd_get_capset_info()
648 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_get_capset()
653 resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET; in virgl_cmd_get_capset()
656 (void *)resp->capset_data); in virgl_cmd_get_capset()
657 virtio_gpu_ctrl_response(g, cmd, &resp->hdr, sizeof(*resp) + max_size); in virgl_cmd_get_capset()
671 if (!virtio_gpu_blob_enabled(g->parent_obj.conf)) { in virgl_cmd_resource_create_blob()
672 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_resource_create_blob()
683 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_resource_create_blob()
691 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_resource_create_blob()
696 res->base.resource_id = cblob.resource_id; in virgl_cmd_resource_create_blob()
697 res->base.blob_size = cblob.size; in virgl_cmd_resource_create_blob()
698 res->base.dmabuf_fd = -1; in virgl_cmd_resource_create_blob()
702 cmd, &res->base.addrs, in virgl_cmd_resource_create_blob()
703 &res->base.iov, &res->base.iov_cnt); in virgl_cmd_resource_create_blob()
705 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_create_blob()
716 virgl_args.iovecs = res->base.iov; in virgl_cmd_resource_create_blob()
717 virgl_args.num_iovs = res->base.iov_cnt; in virgl_cmd_resource_create_blob()
722 __func__, strerror(-ret)); in virgl_cmd_resource_create_blob()
723 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_create_blob()
724 virtio_gpu_cleanup_mapping(g, &res->base); in virgl_cmd_resource_create_blob()
732 __func__, cblob.resource_id, strerror(-ret)); in virgl_cmd_resource_create_blob()
733 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_create_blob()
734 virtio_gpu_cleanup_mapping(g, &res->base); in virgl_cmd_resource_create_blob()
739 res->base.dmabuf_fd = info.fd; in virgl_cmd_resource_create_blob()
741 QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); in virgl_cmd_resource_create_blob()
760 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_resource_map_blob()
766 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_map_blob()
791 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_resource_unmap_blob()
797 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_resource_unmap_blob()
812 ss.r.width, ss.r.height, ss.r.x, in virgl_cmd_set_scanout_blob()
815 if (ss.scanout_id >= g->parent_obj.conf.max_outputs) { in virgl_cmd_set_scanout_blob()
818 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; in virgl_cmd_set_scanout_blob()
829 ss.r.x + ss.r.width > ss.width || in virgl_cmd_set_scanout_blob()
834 ss.r.x, ss.r.y, ss.r.width, ss.r.height, in virgl_cmd_set_scanout_blob()
836 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_set_scanout_blob()
844 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; in virgl_cmd_set_scanout_blob()
847 if (res->base.dmabuf_fd < 0) { in virgl_cmd_set_scanout_blob()
850 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virgl_cmd_set_scanout_blob()
854 if (!virtio_gpu_scanout_blob_to_fb(&fb, &ss, res->base.blob_size)) { in virgl_cmd_set_scanout_blob()
855 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_set_scanout_blob()
859 g->parent_obj.enable = 1; in virgl_cmd_set_scanout_blob()
860 if (virtio_gpu_update_dmabuf(g, ss.scanout_id, &res->base, &fb, &ss.r)) { in virgl_cmd_set_scanout_blob()
863 cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; in virgl_cmd_set_scanout_blob()
867 virtio_gpu_update_scanout(g, ss.scanout_id, &res->base, &fb, &ss.r); in virgl_cmd_set_scanout_blob()
876 VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr); in virtio_gpu_virgl_process_cmd()
879 switch (cmd->cmd_hdr.type) { in virtio_gpu_virgl_process_cmd()
954 cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; in virtio_gpu_virgl_process_cmd()
958 if (cmd_suspended || cmd->finished) { in virtio_gpu_virgl_process_cmd()
961 if (cmd->error) { in virtio_gpu_virgl_process_cmd()
962 fprintf(stderr, "%s: ctrl 0x%x, error 0x%x\n", __func__, in virtio_gpu_virgl_process_cmd()
963 cmd->cmd_hdr.type, cmd->error); in virtio_gpu_virgl_process_cmd()
964 virtio_gpu_ctrl_response_nodata(g, cmd, cmd->error); in virtio_gpu_virgl_process_cmd()
967 if (!(cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE)) { in virtio_gpu_virgl_process_cmd()
972 trace_virtio_gpu_fence_ctrl(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type); in virtio_gpu_virgl_process_cmd()
973 virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type); in virtio_gpu_virgl_process_cmd()
981 QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) { in virgl_write_fence()
986 if (cmd->cmd_hdr.fence_id > fence) { in virgl_write_fence()
989 trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id); in virgl_write_fence()
991 QTAILQ_REMOVE(&g->fenceq, cmd, next); in virgl_write_fence()
993 g->inflight--; in virgl_write_fence()
994 if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { in virgl_write_fence()
995 trace_virtio_gpu_dec_inflight_fences(g->inflight); in virgl_write_fence()
1008 qparams.major_ver = params->major_ver; in virgl_create_context()
1009 qparams.minor_ver = params->minor_ver; in virgl_create_context()
1011 ctx = dpy_gl_ctx_create(g->parent_obj.scanout[scanout_idx].con, &qparams); in virgl_create_context()
1020 dpy_gl_ctx_destroy(g->parent_obj.scanout[0].con, qctx); in virgl_destroy_context()
1029 return dpy_gl_ctx_make_current(g->parent_obj.scanout[scanout_idx].con, in virgl_make_context_current()
1046 if (g->stats.requests) { in virtio_gpu_print_stats()
1047 fprintf(stderr, "stats: vq req %4d, %3d -- 3D %4d (%5d)\n", in virtio_gpu_print_stats()
1048 g->stats.requests, in virtio_gpu_print_stats()
1049 g->stats.max_inflight, in virtio_gpu_print_stats()
1050 g->stats.req_3d, in virtio_gpu_print_stats()
1051 g->stats.bytes_3d); in virtio_gpu_print_stats()
1052 g->stats.requests = 0; in virtio_gpu_print_stats()
1053 g->stats.max_inflight = 0; in virtio_gpu_print_stats()
1054 g->stats.req_3d = 0; in virtio_gpu_print_stats()
1055 g->stats.bytes_3d = 0; in virtio_gpu_print_stats()
1059 timer_mod(gl->print_stats, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); in virtio_gpu_print_stats()
1069 if (!QTAILQ_EMPTY(&g->cmdq) || !QTAILQ_EMPTY(&g->fenceq)) { in virtio_gpu_fence_poll()
1070 timer_mod(gl->fence_poll, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10); in virtio_gpu_fence_poll()
1083 for (i = 0; i < g->parent_obj.conf.max_outputs; i++) { in virtio_gpu_virgl_reset_scanout()
1084 dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL); in virtio_gpu_virgl_reset_scanout()
1085 dpy_gl_scanout_disable(g->parent_obj.scanout[i].con); in virtio_gpu_virgl_reset_scanout()
1112 if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { in virtio_gpu_virgl_init()
1123 gl->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, in virtio_gpu_virgl_init()
1126 if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { in virtio_gpu_virgl_init()
1127 gl->print_stats = timer_new_ms(QEMU_CLOCK_VIRTUAL, in virtio_gpu_virgl_init()
1129 timer_mod(gl->print_stats, in virtio_gpu_virgl_init()
1130 qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); in virtio_gpu_virgl_init()
1134 gl->cmdq_resume_bh = aio_bh_new(qemu_get_aio_context(), in virtio_gpu_virgl_init()
1164 if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { in virtio_gpu_virgl_get_capsets()