Skip to content
Snippets Groups Projects

introduce virgl_resource as the type of global cross-api resources

Merged Chia-I Wu requested to merge olv/virglrenderer:virgl-res into master

This MR introduces virgl_resource as the type of global cross-api resources.

It is possible to create a virgl_resource from a vrend_resource (export), or to create a vrend_resource from a virgl_resource (attach and import).

@gurchetansingh

Edited by Chia-I Wu

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Owner

    In other words, virgl_res_lookup(res_id) returns the cross-api virgl_res. vrend_renderer_ctx_res_lookup(ctx, res_id) returns the Gallium vrend_resource.

    vrend_renderer will work with vrend_resource exclusively. Because a virgl_res is created from a vrend_resource, a virgl_res can always be converted to a vrend_resource directly.

    Edited by Chia-I Wu
  • Overall approach seems fine, though don't quite see bigger picture yet.

  • Author Owner

    The plan is to introduce a cross-api global resource, virgl_res (better name needed), in a backward compatible way.

    This commit shows the relation between the existing vrend_resource and the new virgl_res. Semantically, virgl_res is in global res_hash and vrend_resource is in vrend_context::res_hash. vrend_context only works with vrend_resource. A virgl_res must be attached to a vrend_context and becomes a vrend_resource to be usable (for 3D part of virtio-gpu; 2D has no vrend_context semantically).

    There will be virv_resource, something similar to vrend_resource but only usable by virv_context. The relation between virv_context/virv_resource/virgl_res will be similar to the relation of vrend_context/vrend_resource/virgl_res. virgl_res provides a bridge to convert between virv_resource <-> vrend_resource.

    It might seem that virgl_res introduces another level of indirection and some overhead. But if you look at the changes careful, there is zero overhead while it paves the path to cross-api support.

    Edited by Chia-I Wu
  • Chia-I Wu mentioned in merge request !369 (merged)

    mentioned in merge request !369 (merged)

  • Chia-I Wu added 46 commits

    added 46 commits

    • 5d1dc2d6...6c44b4a7 - 19 commits from branch virgl:master
    • fc5fc27e - virgl: rename vrend_util.h
    • 5f33c661 - virgl: move hash and compare functions to util
    • 8cad250b - virgl: add virgl_context
    • d74bcfb4 - vrend: inherit from virgl_context
    • 50a30eff - virgl: make virgl_renderer_context_destroy generic
    • cd16791a - virgl: make virgl_renderer_ctx_{attach,detach}_resource generic
    • 9086005e - vrend: constify vrend_decoder_state::buf
    • a558efab - vrend: reject cmd submission for ctx 0
    • d759e0f9 - virgl: make virgl_renderer_submit_cmd generic
    • f1708d34 - virgl: make virgl_renderer_context_create generic
    • ff55cbf0 - vrend: remove unnecessary switch_0 logic
    • b88b2df4 - vrend: ctx0 does not need to be a vrend_decode_ctx
    • 759a5579 - vrend: store context pointer in vrend_query
    • ead0788b - virgl: make virgl_renderer_transfer_*_iov mroe generic
    • 88fec3fe - vrend: remove vrend_transfer_info::ctx_id
    • 91b0a9b6 - vrend: remove vrend_lookup_renderer_ctx
    • 7d3adcd9 - virgl: add virgl_resource
    • d3152efd - vrend: rework global resource management
    • 94741a96 - vrend: rework context resource management
    • 94704f3d - vrend: simplify vrend_object_insert
    • aeb84976 - virgl: move private data to virgl_resource
    • 84e74156 - virgl: pass virgl_resource to {attach,detach}_resource
    • eddeb0f5 - virgl: add virgl_context_foreach
    • 84f00dfe - virgl: make virgl_renderer_resource_unref generic
    • f7fc1b7b - vrend: constify iovec
    • d74d67c1 - virgl: make virgl_renderer_resource_{attach,detach}_iov generic
    • a1cc9e67 - virgl: move resource lookup up for some functions

    Compare with previous version

  • Author Owner

    Rebased on top of !369 (merged) and made more complete. virgl_res is renamed to virgl_resource.

20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 **************************************************************************/
24
25 #ifndef VIRGL_RESOURCE_H
26 #define VIRGL_RESOURCE_H
27
28 #include <stdint.h>
29
30 struct iovec;
31 struct pipe_resource;
32
33 /**
34 * A global cross-context resource. It is not directly usable by renderer
35 * contexts, but must be imported to create a context object first. For
  • Overall, general approach makes sense. I like vrend_resource being the context obj for GL.

  • Chia-I Wu added 36 commits

    added 36 commits

    • a1cc9e67...33cfd723 - 6 commits from branch virgl:master
    • 77a020a5 - virgl: rename vrend_util.h
    • 89cf9270 - virgl: move hash and compare functions to util
    • 6a43d7d6 - virgl: add virgl_context
    • f1930702 - vrend: inherit from virgl_context
    • 09253672 - virgl: make virgl_renderer_context_destroy generic
    • 594bdce0 - virgl: make virgl_renderer_ctx_{attach,detach}_resource generic
    • 19a9b8e1 - vrend: constify vrend_decoder_state::buf
    • 37763941 - vrend: reject cmd submission for ctx 0
    • 708018c3 - virgl: make virgl_renderer_submit_cmd generic
    • fb43225f - virgl: make virgl_renderer_context_create generic
    • 78dcebe8 - vrend: remove unnecessary switch_0 logic
    • 6f05c13b - vrend: ctx0 does not need to be a vrend_decode_ctx
    • 54925c36 - virgl: add virgl_resource
    • fd7dbd90 - vrend: rework global resource management
    • 3135165d - vrend: rework context resource management
    • 8b8b54e5 - vrend: simplify vrend_object_insert
    • c7520852 - virgl: move private data to virgl_resource
    • f0dcc479 - virgl: pass virgl_resource to virgl_context callbacks
    • d4703d8a - virgl: add virgl_context_foreach
    • 38dca2b6 - virgl: make virgl_renderer_resource_unref generic
    • cc1eb3f5 - vrend: constify iovec
    • 9077a811 - virgl: make virgl_renderer_resource_{attach,detach}_iov generic
    • 54e7da6a - virgl: move resource lookup up for some functions
    • 64d1d480 - vrend: remove vrend_transfer_info::handle
    • 3341f654 - virgl: make virgl_renderer_transfer_*_iov more generic
    • 7294c063 - vrend: remove vrend_transfer_info::ctx_id
    • d36a0012 - virgl: move vrend_renderer_execute to virglrenderer
    • 0d57d46a - vrend: store context pointer in vrend_query
    • 05797c4d - vrend: remove vrend_lookup_renderer_ctx
    • a391a443 - vrend: remove vrend_renderer_res_lookup

    Compare with previous version

  • Author Owner

    Thanks. I will drop the RFC tag. I need to do more testing before I drop the WIP tag.

    This MR has also been updated to include everything I want for now. The last two commits are my goal for this MR: remove context lookup and global resource lookup from vrend.

  • Chia-I Wu changed title from WIP: RFC: introduce virgl_res as the type of global cross-api resources to WIP: introduce virgl_resource as the type of global cross-api resources

    changed title from WIP: RFC: introduce virgl_res as the type of global cross-api resources to WIP: introduce virgl_resource as the type of global cross-api resources

  • Chia-I Wu changed the description

    changed the description

    • Maybe we can rename virgl_res by global_resource or cross_api_resource. Like this, we get ride of the gl part that can be confusing.

    • Author Owner

      I am open to naming.

      My current plan is to treat vrend as the prefix of the GL renderer and virgl as the prefix for everything else. When the VK renderer is added, it will also get its own prefix.

    • May be something like, vrend as prefix for GL renderer, vkrend as prefix for VK renderer and glbl as prefix for everything else.

    • Author Owner

      glbl? Other options are gpu or gfx.

      Or we can go with prefix-less but be verbose. virgl_context becomes renderer_context, and virgl_resource becomes global_resource for example.

      As for the VK renderer, I current use vkr as the prefix.

      The name of the command protocol is also open to suggestions. I call it Venus (wife of Vulcan) right now.

    • Agree, gfx as prefix seems better choice for everything global(context/resources).

    • Please register or sign in to reply
  • Small nit: 37763941 and 708018c3 can be merged

  • Chia-I Wu added 31 commits

    added 31 commits

    • a391a443...660eaa21 - 13 commits from branch virgl:master
    • e9d5ed1b - virgl: add virgl_resource
    • e642e413 - vrend: rework global resource management
    • 1f5699f5 - vrend: rework context resource management
    • 3f9dd13a - vrend: simplify vrend_object_insert
    • 67585382 - virgl: move private data to virgl_resource
    • 3970058f - virgl: pass virgl_resource to virgl_context callbacks
    • 49c0537a - virgl: add virgl_context_foreach
    • 40286234 - virgl: make virgl_renderer_resource_unref generic
    • 524bb38e - vrend: constify iovec
    • ea0ee69a - virgl: make virgl_renderer_resource_{attach,detach}_iov generic
    • 9bea31e8 - virgl: move resource lookup up for some functions
    • 6771968b - vrend: remove vrend_transfer_info::handle
    • c3d9177d - virgl: make virgl_renderer_transfer_*_iov more generic
    • f8acaeb2 - vrend: remove vrend_transfer_info::ctx_id
    • 304660a3 - virgl: move vrend_renderer_execute to virglrenderer
    • 4998c7fd - vrend: store context pointer in vrend_query
    • c3ad05f1 - vrend: remove vrend_lookup_renderer_ctx
    • 004647d3 - vrend: remove vrend_renderer_res_lookup

    Compare with previous version

  • Chia-I Wu added 20 commits

    added 20 commits

    • 466f32dd - 1 commit from branch virgl:master
    • d879df89 - virgl: add virgl_resource
    • 5b6d42f1 - vrend: rework global resource management
    • 20808fc4 - vrend: rework context resource management
    • 2b708107 - vrend: simplify vrend_object_insert
    • 28edc658 - virgl: move private data to virgl_resource
    • 3218c609 - virgl: pass virgl_resource to virgl_context callbacks
    • 9f4a97ec - virgl: add virgl_context_foreach
    • f3d953b8 - virgl: make virgl_renderer_resource_unref generic
    • d065862d - virgl: move resource lookup up for some functions
    • b7f41ef4 - vrend: remove iov from vrend_renderer_resource_create
    • 8594b530 - vrend: constify iovec
    • cd3b3e2a - virgl: make virgl_renderer_resource_{attach,detach}_iov generic
    • 582814a1 - vrend: move handle out of vrend_transfer_info
    • 1787350b - virgl: make virgl_renderer_transfer_*_iov more generic
    • 495d498c - vrend: remove vrend_transfer_info::ctx_id
    • d3335c8e - virgl: move vrend_renderer_execute to virglrenderer
    • 7c984184 - vrend: remove vrend_renderer_res_lookup
    • 1ffd2b95 - vrend: store context pointer in vrend_query
    • 962925a7 - vrend: remove vrend_lookup_renderer_ctx

    Compare with previous version

  • Chia-I Wu unmarked as a Work In Progress

    unmarked as a Work In Progress

  • Chia-I Wu changed the description

    changed the description

  • Author Owner

    I tested some games and they ran fine. PTAL!

  • The changes look good to me, though I'd wait a few days for landing this in case anybody has additional ideas on naming (I have no strong opinions on the subject)

    Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>

    Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>

    Edited by Gurchetan Singh
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading