├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── src ├── cover.yaml └── virtio-gpu.md └── templates ├── cover.j2 ├── pandoc.css └── template.tex /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | cover.tex 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009-2017 Red Hat, Inc. and/or its affiliates. 2 | Copyright 2016 Google, Inc. 3 | Copyright 2007 IBM Corporation 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | NAME=virtio-gpu.pdf 4 | 5 | FILES=src/virtio-gpu.md 6 | COVER=src/cover.yaml 7 | 8 | EXTS=+footnotes+implicit_figures+backtick_code_blocks 9 | 10 | $(NAME): $(FILES) templates/template.tex cover.tex 11 | pandoc \ 12 | --from markdown$(EXTS) \ 13 | --to latex \ 14 | --template templates/template.tex \ 15 | --out $@ \ 16 | --latex-engine xelatex \ 17 | --css templates/pandoc.css \ 18 | $(FILES) 19 | 20 | cover.tex: templates/cover.j2 $(COVER) 21 | cp $< $@ 22 | @echo generating $@ from $< and $(COVER) 23 | 24 | clean: 25 | rm -f $(NAME) 26 | rm -f cover.tex 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This documentation is out-of-date. Since January 2019, an official documentation is available. 2 | 3 | https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-3200007 4 | 5 | # virtio-gpu-documentation 6 | 7 | Documentation for 3D commands on Virgl3D. Not an official documentation. THIS DOCUMENTATION IS OUTDATED. 8 | -------------------------------------------------------------------------------- /src/cover.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keenuts/virtio-gpu-documentation/948ddd6504d0c859af13e3d1a0fa1a88050d73a9/src/cover.yaml -------------------------------------------------------------------------------- /src/virtio-gpu.md: -------------------------------------------------------------------------------- 1 | # Virtio-GPU | Virgl3D commands 2 | 3 | This document won't explain how to send a basic virtio-gpu command. 4 | Virtio-gpu documentation can be found [HERE](https://www.kraxel.org/virtio/virtio-v1.0-cs03-virtio-gpu.pdf) 5 | However, I will try to document Virgl3D related commands and every aspect virtio-gpu documentation does not cover today (June, 8th 2017). 6 | 7 | \pagebreak 8 | 9 | ## Reminders 10 | 11 | ```C 12 | struct iovec { 13 | void *iov_base; 14 | size_t iov_len; 15 | }; 16 | 17 | typedef struct VirtQueueElement 18 | { 19 | unsigned int index; 20 | unsigned int out_num; 21 | unsigned int in_num; 22 | hwaddr *in_addr; 23 | hwaddr *out_addr; 24 | struct iovec *in_sg; 25 | struct iovec *out_sg; 26 | } VirtQueueElement; 27 | 28 | struct virtio_gpu_ctrl_hdr { 29 | uint32_t type; 30 | uint32_t flags; 31 | uint64_t fence_id; 32 | uint32_t ctx_id; 33 | uint32_t padding; 34 | }; 35 | 36 | struct virtio_gpu_ctrl_command { 37 | VirtQueueElement elem; 38 | VirtQueue *vq; 39 | struct virtio_gpu_ctrl_hdr cmd_hdr; 40 | uint32_t error; 41 | bool waiting; //OUT 42 | bool finished; //OUT 43 | QTAILQ_ENTRY(virtio_gpu_ctrl_command) next; next cmd 44 | }; 45 | ``` 46 | 47 | \pagebreak 48 | 49 | ## VIRTIO_GPU_CMD_CTX_CREATE 50 | 51 | ```C 52 | uint32_t nlen 53 | uint32_t padding 54 | char[64] debug_name 55 | ``` 56 | 57 | This is a Virgl context. To split resources between process, etc. 58 | This is NOT an OpenGL context. 59 | 60 | - Context number must be != 0. 0 is a special context value. 61 | - Max context number is defined by **VREND_MAX_CTX** (16) 62 | - id nlen is != 0, 64 chars from debug_name len will copied to ctx name. 63 | 64 | \pagebreak 65 | 66 | ## VIRTIO_GPU_CMD_CTX_DESTROY: 67 | No specific parameters 68 | 69 | \pagebreak 70 | 71 | ## VIRTIO_GPU_CMD_RESOURCE_CREATE_2D 72 | 73 | 3D and 2D resource creation are the same under the hood. 74 | The main difference are default values. Thus a lightweight command for 2D. 75 | 76 | ```C 77 | struct { 78 | uint32_t handle; 79 | //target is set to 2 80 | uint32_t format; 81 | //bind is set to 2 82 | uint32_t width; 83 | uint32_t height; 84 | //depth = 1 85 | //array_size = 1 86 | //last_level = 0 87 | //nr_samples = 0 88 | //flags = VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP 89 | }; 90 | ``` 91 | 92 | \pagebreak 93 | 94 | ## VIRTIO_GPU_CMD_RESOURCE_CREATE_3D 95 | 96 | This time, no default values, we need to setup all the fields 97 | 98 | ```C 99 | struct { 100 | uint32_t handle; 101 | uint32_t target; 102 | uint32_t format; 103 | uint32_t bind; 104 | uint32_t width; 105 | uint32_t height; 106 | uint32_t depth; 107 | uint32_t array_size; 108 | uint32_t last_level; 109 | uint32_t nr_samples; 110 | uint32_t flags; 111 | uint32_t padding; 112 | }; 113 | ``` 114 | 115 | \pagebreak 116 | 117 | ## VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE 118 | 119 | Once a resource has been created, we need to attach it to a VGL context. 120 | Once attached, we will be able to use it. 121 | 122 | Remember: virgl context is already given in the command header. 123 | 124 | ```C 125 | struct { 126 | uint32_t handle; 127 | uint32_t padding; 128 | }; 129 | ``` 130 | 131 | \pagebreak 132 | 133 | ## VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING 134 | 135 | Once the resource created and attached, we may want modyfy/set it. 136 | There is two methods: INLINE_WRITE, or backing attachment. 137 | 138 | backing attachment is a way to share memory pages. 139 | Guest will send physical pages addresses, and host will link these pages to the resource. 140 | 141 | First, we find the header, describing how many entries we want to register, and a handle. 142 | Then, we will one field per entries, describing the size and start of the entry. 143 | 144 | ```C 145 | //Command head 146 | struct { 147 | uint32_t resource_id; 148 | uint32_t nr_entries; 149 | }; 150 | 151 | //One entry description 152 | struct { 153 | uint64_t address; 154 | uint32_t length; 155 | uint32_t padding; //struct padding, non related to our entry 156 | }; 157 | ``` 158 | 159 | \pagebreak 160 | 161 | ## VIRTIO_GPU_CMD_SUBMIT_3D: 162 | 163 | 3D command decoder is called from QEMU with a buffer, a context ID, and a word count. 164 | After the usual header, you will put the actual 3D commands. 165 | 166 | - Context must be valid 167 | - Context must be lower than **VREND_MAX_CTX** (16) 168 | 169 | Like every commands, cmd.header.ctx_id must be set to the virgl context id. 170 | cmd.header.type will be VIRTIO_GPU_CMD_SUBMIT_3D. 171 | cmd.len is the length of your commandbuffer in bytes. 172 | 173 | This command buffer can contain several 3D commands. 174 | Each command is composed of a header, and a payload. 175 | 176 | | uint32_t (MSB)| uint32_t (LSB)| 177 | |------|-------| 178 | |Length|Command| 179 | 180 | 181 | By example, to create a context (**with ctx id=5**)and then set it as current, I could issue the following command buffer: 182 | 183 | | 32 bits | 184 | |:------:| 185 | | 4 (Payload length = 4 bytes) | 186 | | VIRTIO_CCMD_CREATE_SUB_CTX (command) | 187 | | 5 (payload[0]) | 188 | | 4 (payload length = 4 bytes) | 189 | | VIRTIO_CCMD_SET_SUB_CTX (command)| 190 | |5 (payload[0] | 191 | 192 | cell[0] = command + length of the payload (1 uint32_t --> payload = 4) 193 | cell[1] = context ID 194 | ... 195 | 196 | \pagebreak 197 | 198 | These are the type allowed 199 | 200 | ```C 201 | enum { 202 | VIRGL_CCMD_NOP = 0, 203 | VIRGL_CCMD_CREATE_OBJECT = 1, 204 | VIRGL_CCMD_BIND_OBJECT, 205 | VIRGL_CCMD_DESTROY_OBJECT, 206 | VIRGL_CCMD_SET_VIEWPORT_STATE, 207 | VIRGL_CCMD_SET_FRAMEBUFFER_STATE, 208 | VIRGL_CCMD_SET_VERTEX_BUFFERS, 209 | VIRGL_CCMD_CLEAR, 210 | VIRGL_CCMD_DRAW_VBO, 211 | VIRGL_CCMD_RESOURCE_INLINE_WRITE, 212 | VIRGL_CCMD_SET_SAMPLER_VIEWS, 213 | VIRGL_CCMD_SET_INDEX_BUFFER, 214 | VIRGL_CCMD_SET_CONSTANT_BUFFER, 215 | VIRGL_CCMD_SET_STENCIL_REF, 216 | VIRGL_CCMD_SET_BLEND_COLOR, 217 | VIRGL_CCMD_SET_SCISSOR_STATE, 218 | VIRGL_CCMD_BLIT, 219 | VIRGL_CCMD_RESOURCE_COPY_REGION, 220 | VIRGL_CCMD_BIND_SAMPLER_STATES, 221 | VIRGL_CCMD_BEGIN_QUERY, 222 | VIRGL_CCMD_END_QUERY, 223 | VIRGL_CCMD_GET_QUERY_RESULT, 224 | VIRGL_CCMD_SET_POLYGON_STIPPLE, 225 | VIRGL_CCMD_SET_CLIP_STATE, 226 | VIRGL_CCMD_SET_SAMPLE_MASK, 227 | VIRGL_CCMD_SET_STREAMOUT_TARGETS, 228 | VIRGL_CCMD_SET_RENDER_CONDITION, 229 | VIRGL_CCMD_SET_UNIFORM_BUFFER, 230 | 231 | VIRGL_CCMD_SET_SUB_CTX, 232 | VIRGL_CCMD_CREATE_SUB_CTX, 233 | VIRGL_CCMD_DESTROY_SUB_CTX, 234 | VIRGL_CCMD_BIND_SHADER 235 | } 236 | ``` 237 | 238 | \pagebreak 239 | 240 | ## VIRGL_CCMD_CLEAR 241 | 242 | parameters = 6 243 | ```C 244 | [0] (uint32_t) clear_type 245 | [1] (uint32_t) R 246 | [2] (uint32_t) G 247 | [3] (uint32_t) B 248 | [4] (uint32_t) A 249 | [5] (double (64 bits)) Depth 250 | [6] (uint32_t) stencil 251 | ``` 252 | Note: On Windows, float are disabled in the kernel (DKM). 253 | 254 | ```C 255 | //LSB FIRST 256 | struct clear_type { 257 | uint8_t depth : 1; 258 | uint8_t stencil : 1; 259 | uint8_t color0 : 1; 260 | uint8_t color1 : 1; 261 | uint8_t color2 : 1; 262 | uint8_t color3 : 1; 263 | uint8_t color4 : 1; 264 | uint8_t color5 : 1; 265 | uint8_t color6 : 1; 266 | uint8_t color7 : 1; 267 | }; 268 | ``` 269 | 270 | \pagebreak 271 | 272 | ## VIRGL_CCMD_DRAW_VBO 273 | 274 | parameters = 12 275 | ```C 276 | 277 | [0] (uint32_t) start 278 | [1] (uint32_t) count 279 | 280 | [2] (uint32_t) mode //GLEnum GL_TRIANGLE/GL_LINE/etc... 281 | [3] (uint32_t) indexed //is rendering indexed ? 282 | 283 | [4] (uint32_t) instance_count 284 | [5] (uint32_t) index_bias //Only if indexed rendering is set 285 | 286 | [6] (uint32_t) start_instance // Only if instance rendering is enabled 287 | [7] (uint32_t) primitive_restart 288 | [9] (uint32_t) restart_index 289 | 290 | [9] (uint32_t) min_index 291 | [10] (uint32_t) max_index 292 | 293 | [11] (uint32_t) cso // If != 0, will be used as count, and start will be 0. 294 | ``` 295 | 296 | \pagebreak 297 | 298 | ## VIRGL_CCMD_CREATE_OBJECT 299 | 300 | Object creation parameters are higly dependent of the type of objects you create. 301 | However, the first parameter is always the handle. 302 | 303 | To specify the object type, you need to define the '**opt**' field of the header to the desired type. 304 | 305 | \pagebreak 306 | 307 | ### Creating VIRGL_OBJECT_BLEND 308 | 309 | ```C 310 | [0] (uint32_t) Handle (as always) 311 | [1] bitfield_1 312 | [2] bitfield_2 313 | [3] bitfield_3 314 | ... 315 | [10] bitfield_3 316 | ``` 317 | 318 | #### bitfield 1 319 | ```C 320 | // LSB on top 321 | struct { 322 | uint8_t independant_blend_enable : 1; 323 | uint8_t logicop_enable : 1; 324 | uint8_t dither : 1; 325 | uint8_t alpha_to_coverage : 1; 326 | uint8_t alpha_to_one : 1; 327 | }; 328 | ``` 329 | 330 | #### bitfield 2 331 | ```C 332 | // LSB on top 333 | struct { 334 | uint8_t logicop_func : 4; 335 | }; 336 | ``` 337 | 338 | #### bitfield 3 339 | ```C 340 | // LSB on top 341 | struct { 342 | uint8_t blend_enable : 1; 343 | uint8_t rgb_func : 3; 344 | uint8_t rgb_src_factor : 5; 345 | uint8_t rgb_dst_factor : 5; 346 | uint8_t alpha_func : 3; 347 | uint8_t alpha_src_factor : 5; 348 | uint8_t alpha_dst_factor : 5; 349 | uint8_t colormask : 4; 350 | }; 351 | ``` 352 | 353 | \pagebreak 354 | 355 | ### Creating VIRGL_OBJECT_RASTERIZER 356 | 357 | There is 9 parameters 358 | 359 | ```C 360 | [0] (uint32_t) Handle (as always) 361 | [1] (uint32_t) bitfield 1 362 | [2] (float) Point size 363 | [3] (uint32_t) Sprit coord enabled ? 364 | [4] (uint32_t) bitfield 2 365 | [5] (float) Line width 366 | [6] (float) offset units 367 | [7] (float) offset scale 368 | [8] (float) offset clamp 369 | ``` 370 | 371 | #### Bitfield 1 372 | ```C 373 | //LSB on top 374 | // All are 1 bit width except when specified otherwise 375 | struct { 376 | uint8_t flatshade; 377 | uint8_t depth_clip; 378 | uint8_t clip_halfz; 379 | uint8_t rasterizer_discard; 380 | uint8_t flatshade_first; 381 | uint8_t light_twoside; 382 | uint8_t sprit_coord_mode; 383 | uint8_t point_quad_rasterization; 384 | uint8_t cull_face : 2; 385 | uint8_t fill_front : 2; 386 | uint8_t fill_back : 2; 387 | uint8_t scissor; 388 | uint8_t front_ccw; 389 | uint8_t clamp_vertex_color; 390 | uint8_t clamp_fragment_color; 391 | uint8_t offset_line; 392 | uint8_t offset_point; 393 | uint8_t offset_tri; 394 | uint8_t poly_smooth; 395 | uint8_t poly_stipple_enable; 396 | uint8_t point_smooth; 397 | uint8_t point_size_per_vertex; 398 | uint8_t multisample; 399 | uint8_t line_smooth; 400 | uint8_t line_stipple:enable; 401 | uint8_t line_last_pixel; 402 | uint8_t half_pixel_center; 403 | uint8_t bottom_edge_rule; 404 | }; 405 | ``` 406 | 407 | #### bitfield 2 408 | ```C 409 | #define PIPE_MAX_CLIP_PLANES 8 410 | 411 | //LSB on top 412 | struct { 413 | uint16_t line_stipple_pattern : 16 414 | uint16_t line_stipple_factor : 8 415 | uint16_t clip_plane_enable : PIPE_MAX_CLIP_PLANES 416 | }; 417 | ``` 418 | 419 | \pagebreak 420 | 421 | ### Creating VIRGL_OBJECT_SHADER 422 | 423 | To create a shader, parameters are the following: 424 | 425 | parameters = 5 + nb_tokens / 4 426 | ```C 427 | [0] Handle (as always) 428 | [1] Shader type (0 = vertex, 1 = fragment) 429 | [2] number of tokens (aka how many letters in the ASCII representation) 430 | [3] offlen seam to be the offset to the 1st instruction (roughly) 431 | [4] num_so_output : stream output count 432 | [5] -> [END] Your shader, in TGSI-ASCII stored in a UINT32[] 433 | ``` 434 | 435 | \pagebreak 436 | 437 | ### Creating VIRGL_OBJECT_VERTEX_ELEMENTS 438 | 439 | To create a vertex elements object, parameters are the following: 440 | You can specify several sources. 441 | 442 | parameters = 1 + n * 4 443 | ```C 444 | [0] Handle (as always) 445 | 446 | [1] src_offset 447 | [2] instance_divisor 448 | [3] vertex_buffer_index 449 | [4] src_format 450 | ... 451 | [n * 4 + 0] src_offset 452 | [n * 4 + 1] instance_divisor 453 | [n * 4 + 2] vertex_buffer_index 454 | [n * 4 + 3] src_format 455 | ``` 456 | 457 | \pagebreak 458 | 459 | ### Creating VIRGL_OBJECT_SURFACE 460 | 461 | To create a surface, parameters are the following: 462 | 463 | parameters = 5 464 | ```C 465 | [0] Handle (as always) 466 | [1] resource handle 467 | [2] format 468 | [3] val0 //dependent of the surface type 469 | [4] val1 //dependent of the surface type 470 | ``` 471 | 472 | \pagebreak 473 | 474 | ### Creating VIRGL_OBJECT_DSA 475 | 476 | To create a DSA, parameters are the following (parameters = 5): 477 | ```C 478 | [0] Handle (as always) 479 | [1] bitfield 1 480 | [2] bitfield 2 481 | [3] bitfield 2 482 | [4] alpha ref 483 | ``` 484 | 485 | #### bitfield 1 486 | ```C 487 | //LSB on top 488 | struct { 489 | uint16_t depth_enabled : 1 490 | uint16_t depth_writemask : 1 491 | uint16_t depth_func : 3 492 | uint16_t unused : 3 493 | uint16_t alpha_enabled : 1 494 | uint16_t alpha_func : 3 495 | }; 496 | ``` 497 | 498 | #### bitfield 2 499 | ```C 500 | //LSB on top 501 | struct { 502 | uint16_t stencil_enabled : 1 503 | uint16_t stencil_func : 3 504 | uint16_t stencil_fail_op : 3 505 | uint16_t stencil_zpass_op : 3 506 | uint16_t stencil_zfail_op : 3 507 | uint16_t stencil_valuemask_op : 8 508 | uint16_t stencil_writemask_op : 8 509 | }; 510 | ``` 511 | 512 | 513 | \pagebreak 514 | 515 | ## VIRGL_CCMD_BIND_OBJECT, 516 | 517 | This command is used to bind a created 3D object to the current sub context. 518 | The **Opt** field of the header is used to define the type of the object. 519 | 520 | parameters = 1 521 | ```C 522 | [0] (uint32_t) handle = 0 523 | ``` 524 | 525 | \pagebreak 526 | 527 | ## VIRGL_CCMD_SET_FRAMEBUFFER_STATE, 528 | 529 | 2 + n parameters to setup framebuffer state. 530 | 531 | ```C 532 | [0] (uint32_t) nbr_surfaces = 0 533 | [1] (uint32_t) zsurf_handle = 0 534 | [2] (uint32_t) surface_handle_1 = 0 535 | ... 536 | [.] (uint32_t) surface_handle_n = 0 537 | ``` 538 | 539 | \pagebreak 540 | 541 | ## VIRGL_CCMD_SET_VIEWPORT_STATE 542 | 543 | This command takes an array and a starting offset. 544 | If the offset 'n', with n > 0, first n values are skipped. 545 | 546 | Each viewport is defined using 6 32-bit floats. 3 for the scale, 3 for the translation 547 | Here is an example with 1 viewport, and offset 0. 548 | 549 | parameters = 7; 550 | ```C 551 | [0] (uint32_t) offset = 0 552 | [1] (float (32 bits)) scale_A = 1.0f 553 | [2] (float (32 bits)) scale_B = 1.0f 554 | [3] (float (32 bits)) scale_C = 1.0f 555 | [4] (float (32 bits)) translation_A = 0.0f 556 | [5] (float (32 bits)) translation_B = 0.0f 557 | [6] (float (32 bits)) translation_C = 0.0f 558 | ``` 559 | 560 | \pagebreak 561 | 562 | ## VIRGL_CCMD_SET_SCISSOR_STATE 563 | 564 | This command takes an array and a starting offset. 565 | If the offset 'n', with n > 0, first n values are skipped. 566 | \ 567 | Each scissor is defined using 4 16-bit uint packed by 2: \ 568 | 2 for the min X and Y, and 2 for max X and Y. \ 569 | These values are stored using 2 uint32_t. 570 | 571 | First uint32_t: \ 572 | minX = 2 lsb bytes \ 573 | minY = 2 msb bytes \ 574 | 575 | 576 | Second uint32_t: \ 577 | maxX = 2 lsb bytes \ 578 | maxY = 2 msb bytes \ 579 | 580 | Here is an example with 1 scissor, and offset 0. 581 | 582 | parameters = 3; 583 | ```C 584 | [0] (uint32_t) offset = 0 585 | [1] (uint32_t) minXY = (0xffff) | (0xffff << 16) 586 | [2] (uint32_t) maxXY = (0x0f0f) | (0xf00f << 16) 587 | ``` 588 | 589 | \pagebreak 590 | 591 | ## VIRGL_CCMD_SET_POLYGON_STIPPLE 592 | 593 | This command takes an array of 32 uint32_t, and set the polygon stipple (As described on the OpenGL documentation) 594 | 595 | parameters = 32; 596 | ```C 597 | [0] (uint32_t) stipple_0 = 0 598 | ... 599 | [31] (uint32_t) stipple_1 = 0 600 | ``` 601 | 602 | \pagebreak 603 | 604 | ## VIRGL_CCMD_SET_SUB_CTX 605 | 606 | Create a sub context -> OpenGL context 607 | The created sub-context will be set as active. 608 | 609 | parameters = 1 610 | ```C 611 | [0] (uint32_t) context_id 612 | ``` 613 | 614 | \pagebreak 615 | 616 | ## VIRGL_CCMD_CREATE_SUB_CTX 617 | 618 | Set a sub-context as active 619 | 620 | parameters = 1 621 | ```C 622 | [0] (uint32_t) context_id 623 | ``` 624 | 625 | \pagebreak 626 | 627 | ## VIRGL_CCMD_DESTROY_SUB_CTX 628 | 629 | Destroy a sub-context 630 | 631 | parameters = 1 632 | ```C 633 | [0] (uint32_t) context_id 634 | ``` 635 | 636 | ## VIRGL_CCMD_BIND_SHADER 637 | 638 | Bind a shader to the pipeline (vtx, frag, etc) 639 | 640 | parameters = 2 641 | ```C 642 | [0] (uint32_t) handle 643 | [1] (uint32_t) shader_type (0 = vertex, 1 = fragment) 644 | 1`` 645 | -------------------------------------------------------------------------------- /templates/cover.j2: -------------------------------------------------------------------------------- 1 | \begin{titlepage} 2 | \begin{center} 3 | 4 | \textsc{\LARGE Virgl3D}\\ 5 | \textsc{Virtio-GPU | 3D commands}\\ 6 | \textsc{https ://virgil3d.github.io}\\[3cm] 7 | 8 | 9 | \textsc{\Large 3D commands reference}\\ 10 | \textsc{Virgl3D version: 0.2.0}\\ 11 | \textsc{Document version: 0.1}\\ 12 | \textsc{Date: \today}\\[2cm] 13 | 14 | \emph{Authors}\\[0.1cm] 15 | \noindent\makebox[\textwidth]{% 16 | \begin{tabular}{lr}% 17 | Nathan Gauër & \texttt{nathan.gauer@lse.epita.fr}\\ 18 | \end{tabular}}\\ 19 | 20 | 21 | \vfill 22 | \end{center} 23 | \end{titlepage} 24 | -------------------------------------------------------------------------------- /templates/pandoc.css: -------------------------------------------------------------------------------- 1 | /* 2 | * I add this to html files generated with pandoc. 3 | */ 4 | 5 | html { 6 | font-size: 100%; 7 | overflow-y: scroll; 8 | -webkit-text-size-adjust: 100%; 9 | -ms-text-size-adjust: 100%; 10 | } 11 | 12 | body { 13 | color: #444; 14 | font-family: Verdana, Arial, serif; 15 | font-size: 12px; 16 | line-height: 1.7; 17 | padding: 1em; 18 | margin: auto; 19 | max-width: 42em; 20 | background: #fefefe; 21 | } 22 | 23 | a { 24 | color: #0645ad; 25 | text-decoration: none; 26 | } 27 | 28 | a:visited { 29 | color: #0b0080; 30 | } 31 | 32 | a:hover { 33 | color: #06e; 34 | } 35 | 36 | a:active { 37 | color: #faa700; 38 | } 39 | 40 | a:focus { 41 | outline: thin dotted; 42 | } 43 | 44 | *::-moz-selection { 45 | background: rgba(255, 255, 0, 0.3); 46 | color: #000; 47 | } 48 | 49 | *::selection { 50 | background: rgba(255, 255, 0, 0.3); 51 | color: #000; 52 | } 53 | 54 | a::-moz-selection { 55 | background: rgba(255, 255, 0, 0.3); 56 | color: #0645ad; 57 | } 58 | 59 | a::selection { 60 | background: rgba(255, 255, 0, 0.3); 61 | color: #0645ad; 62 | } 63 | 64 | p { 65 | margin: 1em 0; 66 | } 67 | 68 | img { 69 | max-width: 100%; 70 | } 71 | 72 | h1, h2, h3, h4, h5, h6 { 73 | color: #111; 74 | line-height: 125%; 75 | margin-top: 2em; 76 | font-weight: normal; 77 | } 78 | 79 | h4, h5, h6 { 80 | font-weight: bold; 81 | } 82 | 83 | h1 { 84 | font-size: 2.5em; 85 | } 86 | 87 | h2 { 88 | font-size: 2em; 89 | } 90 | 91 | h3 { 92 | font-size: 1.5em; 93 | } 94 | 95 | h4 { 96 | font-size: 1.2em; 97 | } 98 | 99 | h5 { 100 | font-size: 1em; 101 | } 102 | 103 | h6 { 104 | font-size: 0.9em; 105 | } 106 | 107 | blockquote { 108 | color: #666666; 109 | margin: 0; 110 | padding-left: 3em; 111 | border-left: 0.5em #EEE solid; 112 | } 113 | 114 | hr { 115 | display: block; 116 | height: 2px; 117 | border: 0; 118 | border-top: 1px solid #aaa; 119 | border-bottom: 1px solid #eee; 120 | margin: 1em 0; 121 | padding: 0; 122 | } 123 | 124 | pre, code, kbd, samp { 125 | color: #000; 126 | font-family: monospace, monospace; 127 | _font-family: 'courier new', monospace; 128 | font-size: 0.98em; 129 | } 130 | 131 | pre { 132 | white-space: pre; 133 | white-space: pre-wrap; 134 | word-wrap: break-word; 135 | } 136 | 137 | b, strong { 138 | font-weight: bold; 139 | } 140 | 141 | dfn { 142 | font-style: italic; 143 | } 144 | 145 | ins { 146 | background: #ff9; 147 | color: #000; 148 | text-decoration: none; 149 | } 150 | 151 | mark { 152 | background: #ff0; 153 | color: #000; 154 | font-style: italic; 155 | font-weight: bold; 156 | } 157 | 158 | sub, sup { 159 | font-size: 75%; 160 | line-height: 0; 161 | position: relative; 162 | vertical-align: baseline; 163 | } 164 | 165 | sup { 166 | top: -0.5em; 167 | } 168 | 169 | sub { 170 | bottom: -0.25em; 171 | } 172 | 173 | ul, ol { 174 | margin: 1em 0; 175 | padding: 0 0 0 2em; 176 | } 177 | 178 | li p:last-child { 179 | margin-bottom: 0; 180 | } 181 | 182 | ul ul, ol ol { 183 | margin: .3em 0; 184 | } 185 | 186 | dl { 187 | margin-bottom: 1em; 188 | } 189 | 190 | dt { 191 | font-weight: bold; 192 | margin-bottom: .8em; 193 | } 194 | 195 | dd { 196 | margin: 0 0 .8em 2em; 197 | } 198 | 199 | dd:last-child { 200 | margin-bottom: 0; 201 | } 202 | 203 | img { 204 | border: 0; 205 | -ms-interpolation-mode: bicubic; 206 | vertical-align: middle; 207 | } 208 | 209 | figure { 210 | display: block; 211 | text-align: center; 212 | margin: 1em 0; 213 | } 214 | 215 | figure img { 216 | border: none; 217 | margin: 0 auto; 218 | } 219 | 220 | figcaption { 221 | font-size: 0.8em; 222 | font-style: italic; 223 | margin: 0 0 .8em; 224 | } 225 | 226 | table { 227 | margin-bottom: 2em; 228 | border-bottom: 1px solid #ddd; 229 | border-right: 1px solid #ddd; 230 | border-spacing: 0; 231 | border-collapse: collapse; 232 | } 233 | 234 | table th { 235 | padding: .2em 1em; 236 | background-color: #eee; 237 | border-top: 1px solid #ddd; 238 | border-left: 1px solid #ddd; 239 | } 240 | 241 | table td { 242 | padding: .2em 1em; 243 | border-top: 1px solid #ddd; 244 | border-left: 1px solid #ddd; 245 | vertical-align: top; 246 | } 247 | 248 | .author { 249 | font-size: 1.2em; 250 | text-align: center; 251 | } 252 | 253 | @media only screen and (min-width: 480px) { 254 | body { 255 | font-size: 14px; 256 | } 257 | } 258 | @media only screen and (min-width: 768px) { 259 | body { 260 | font-size: 16px; 261 | } 262 | } 263 | @media print { 264 | * { 265 | background: transparent !important; 266 | color: black !important; 267 | filter: none !important; 268 | -ms-filter: none !important; 269 | } 270 | 271 | body { 272 | font-size: 12pt; 273 | max-width: 100%; 274 | } 275 | 276 | a, a:visited { 277 | text-decoration: underline; 278 | } 279 | 280 | hr { 281 | height: 1px; 282 | border: 0; 283 | border-bottom: 1px solid black; 284 | } 285 | 286 | a[href]:after { 287 | content: " (" attr(href) ")"; 288 | } 289 | 290 | abbr[title]:after { 291 | content: " (" attr(title) ")"; 292 | } 293 | 294 | .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { 295 | content: ""; 296 | } 297 | 298 | pre, blockquote { 299 | border: 1px solid #999; 300 | padding-right: 1em; 301 | page-break-inside: avoid; 302 | } 303 | 304 | tr, img { 305 | page-break-inside: avoid; 306 | } 307 | 308 | img { 309 | max-width: 100% !important; 310 | } 311 | 312 | @page :left { 313 | margin: 15mm 20mm 15mm 10mm; 314 | } 315 | 316 | @page :right { 317 | margin: 15mm 10mm 15mm 20mm; 318 | } 319 | 320 | p, h2, h3 { 321 | orphans: 3; 322 | widows: 3; 323 | } 324 | 325 | h2, h3 { 326 | page-break-after: avoid; 327 | } 328 | } 329 | -------------------------------------------------------------------------------- /templates/template.tex: -------------------------------------------------------------------------------- 1 | % !TEX TS-program = xelatex 2 | % !TEX encoding = UTF-8 Unicode 3 | 4 | % ----------------- 5 | % START OF PREAMBLE 6 | % ----------------- 7 | \documentclass[12pt,a4paper]{scrreprt} 8 | 9 | 10 | % Commands 11 | \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} 12 | 13 | 14 | % Packages 15 | \usepackage{fontspec} 16 | \usepackage{eurosym} 17 | \usepackage{amssymb} 18 | \usepackage{mathtools} 19 | \usepackage{upquote} 20 | \usepackage{microtype} 21 | \usepackage{polyglossia} 22 | \usepackage{longtable,booktabs} 23 | \usepackage{graphicx} 24 | \usepackage{grffile} 25 | \usepackage[normalem]{ulem} 26 | \usepackage[setpagesize=false, 27 | unicode=false, 28 | colorlinks=true, 29 | urlcolor=blue, 30 | linkcolor=black]{hyperref} 31 | \usepackage{float} 32 | \usepackage{setspace} 33 | \onehalfspace 34 | 35 | 36 | % Polyglossia settings 37 | \setmainlanguage{french} % or danish 38 | \addto\captionsenglish{% 39 | \renewcommand{\contentsname}{Table of Contents} 40 | } 41 | \addto\captionsdanish{% 42 | \renewcommand{\contentsname}{Indholdsfortegnelse} 43 | } 44 | 45 | 46 | % Required for syntax highlighting 47 | $highlighting-macros$ 48 | 49 | 50 | % Don't let images overflow the page 51 | % Can still explicit set width/height/options for an image 52 | \makeatletter 53 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 54 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 55 | \makeatother 56 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 57 | 58 | 59 | % Make links footnotes instead of hotlinks 60 | \renewcommand{\href}[2]{#2\footnote{\url{#1}}} 61 | 62 | 63 | % Avoid problems with \sout in headers with hyperref: 64 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 65 | 66 | 67 | % No paragraph indentation 68 | % and set space between paragraphs 69 | %\setlength{\parindent}{3pt} 70 | \setlength{\parskip}{1em plus 2pt minus 1pt} 71 | \setlength{\emergencystretch}{3em} % prevent overfull lines 72 | 73 | \providecommand{\tightlist}{% 74 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 75 | 76 | % ----------------- 77 | % END OF PREAMBLE 78 | % ----------------- 79 | \begin{document} 80 | 81 | \input{cover} 82 | 83 | % chapter: 0, section: 1, subsection: 2 etc 84 | \setcounter{secnumdepth}{1} 85 | \setcounter{tocdepth}{1} 86 | \tableofcontents 87 | 88 | $body$ 89 | 90 | \end{document} 91 | --------------------------------------------------------------------------------