summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/virgl
AgeCommit message (Collapse)AuthorFilesLines
2021-03-19virgl: Use atomic operation directly.Lepton Wu1-2/+7
This make sure we don't trigger assert in pipe_reference Signed-off-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: John Bates <jbates@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9722>
2021-03-19virgl: Don't destroy resource while it's in use.Lepton Wu1-0/+10
This is the race condition: thread 1 check reference count of resource and then find out out it's zero and then it begin to destroy it. Around the same time, thread 2 gets the lock and get the resource from the hash table and plan to use it. Then this resource gets destroyed while it's still in use. Signed-off-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9701>
2021-02-05virgl: Convert errno to string.Vinson Lee1-1/+1
Fix defect reported by Coverity Scan. Invalid type in argument to printf format specifier (PRINTF_ARGS) invalid_type: Argument *__errno_location() to format specifier %s was expected to have type char * but has type int. Fixes: d37124b065c ("virgl: add support for VIRGL_CAP_V2_UNTYPED_RESOURCE") Signed-off-by: Vinson Lee <vlee@freedesktop.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8874>
2021-01-22virgl: add support for VIRGL_CAP_V2_UNTYPED_RESOURCEChia-I Wu2-0/+63
An untyped resource is a blob resource that contains only raw bytes without type information (e.g., width, height, format, etc.). virgl supports only typed resources, and when it encounters untyped resources, it fails silently in the host. This cap enables virgl to assign type information to untyped resources. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-By: Isaac Bosompem <mrisaacb@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8584>
2021-01-20virgl: Cache depth and stencil buffersRohan Garg1-1/+2
Expand the list of bind flags to cache depth and stencil buffers. Extensive testing shows the following performance improvements: Game | % difference in FPS Plague Inc | 7 Portal 2 | 21 Overcooked 2 | 1.2 Hollow Knight | -1.1 Civilization V | 3.8 Signed-off-by: Rohan Garg <rohan.garg@collabora.com> Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8560>
2020-11-24meson: add idep_mesautil to components using simple_mtx.hMark Janes2-2/+2
If valgrind is installed, these components need to find valgrind.h. Fixes: 53f7d539cd9 ("util: Add helgrind support for simple_mtx") Closes: #3876 Acked-by: Rob Clark <robclark@freedesktop.org>
2020-10-29virgl: Correctly align size of blobsTomeu Vizoso1-1/+1
Probably a copy-paste error. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Fixes: cd31f46f08a7 ("virgl/drm: add resource create blob function") Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7332>
2020-10-01virgl: fix stride + layer_stride inconsistencyGurchetan Singh2-4/+31
With blob resources, stride doesn't necesarily have to equal width * bpp. The use case for this a minigbm blob resource with blob mem BLOB_MEM_HOST3D_GUEST imported into guest Mesa. In addition, for BLOB_MEM_HOST we can repurpose the transfer ioctls to also flush caches if need be, so this seems a good time to fix this issue. Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-10-01virgl: query blob memGurchetan Singh2-1/+5
Resource blob also modifies resource info. Let's use this functionality. Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-10-01virgl: support PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENTGurchetan Singh1-3/+11
We should have GL4.5 with this. Piglit tests should now pass. In terms of performance, we're between 70% to 80% of host performance on Iris, based on a apitrace of a 2013 GL4.5 game: 11.204 FPS (guest) 15.947 FPS (host) This is still better than the status quo, when said game was unplayable with Virgl due to an inefficient GL4.3 fallback. TEST=piglit -t arb_buffer_storage all results/ passes Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-10-01virgl/drm: add resource create blob functionGurchetan Singh2-0/+76
A blob resource is a container for: - VIRTGPU_BLOB_MEM_GUEST: a guest memory allocation (referred to as a "guest-only blob resource") - VIRTGPU_BLOB_MEM_HOST3D: a host3d memory allocation (referred to as a "host-only blob resource") - VIRTGPU_BLOB_MEM_HOST3D_GUEST: a guest + host3d memory allocation (referred to as a "default blob resource"). Blob resources can be used to implement new features and fix shortcomings with the current resource create path. The subsequent patches how blob resources may be leveraged to implement GL_ARB_buffer_storage and get GL4.5. Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-10-01virgl/drm: query for resource blob and host visible memory regionGurchetan Singh2-19/+38
Check for these features. v2: refactor querying params in general (@shadeslayer) Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-10-01virgl: add flags to (*resource_create) callbackGurchetan Singh5-12/+20
We never seemed to use these. But for ARB_buffer_storage we'll need it. Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821>
2020-08-28virgl: Fix unused var warnings in release build from assertions.Eric Anholt1-2/+2
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6462>
2020-08-21virgl: move protocol headers to a common placeChia-I Wu7-134/+8
Tested with meson. Android.mk changes are not tested. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6235>
2020-06-18virgl: replace all dup() with os_dupfd_cloexec()Eric Engestrom1-2/+2
Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369>
2020-06-18replace all F_DUPFD_CLOEXEC with os_dupfd_cloexec()Eric Engestrom1-1/+2
All squashed into a single commit because it shouldn't have any behaviour change, except that it might work now on platforms where it was broken because F_DUPFD_CLOEXEC is not supported but FD_CLOEXEC is. Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369>
2020-06-01meson: use gnu_symbol_visibility argumentDylan Baker3-3/+3
This uses a meson builtin to handle -fvisibility=hidden. This is nice because we don't need to track which languages are used, if C++ is suddenly added meson just does the right thing. Acked-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4740>
2020-05-13gallium: rename 'state tracker' to 'frontend'Marek Olšák2-2/+2
Acked-by: Eric Anholt <eric@anholt.net> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4902>
2020-03-28meson: inline `inc_common`Eric Engestrom3-3/+3
Let's make it clear what includes are being added everywhere, so that they can be cleaned up. Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4360>
2020-03-27util: don't include p_defines.h and u_pointer.h from galliumMarek Olšák1-0/+1
It's a mess, but this is what I arrived at. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4324>
2020-02-26gallium/hash_table: remove some function wrappersMarek Olšák1-10/+10
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3722> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3722>
2020-02-26gallium/hash_table: turn it into a wrapper around util/hash_tableMarek Olšák2-4/+4
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3722>
2020-02-26gallium/hash_table: consolidate hash tables with FD keysMarek Olšák1-23/+1
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3722>
2020-02-26gallium/hash_table: consolidate hash tables with pointer keysMarek Olšák1-14/+2
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3722>
2020-02-01virgl: Use align_free for align_malloc allocated bufferSzymon Andrzejuk1-1/+1
Signed-off-by: Szymon Andrzejuk <s.andrzejuk@samsung.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-01-10virgl/drm: update UAPIGurchetan Singh2-175/+1
This seems to compile. Header copied over from drm-misc-next 7da5492739db. Acked-by: Eric Engestrom <eric@engestrom.ch>
2019-11-14util: Move gallium's PIPE_FORMAT utils to /util/format/Eric Anholt3-3/+3
To make PIPE_FORMATs usable from non-gallium parts of Mesa, I want to move their helpers out of gallium. Since u_format used util_copy_rect(), I moved that in there, too. I've put it in a separate directory in util/ because it's a big chunk of related code, and it's not clear to me whether we might want it as a separate library from libmesa_util at some point. Closes: #1905 Acked-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
2019-10-28util: remove LIST_DEL macroTimothy Arceri1-2/+2
Just use the inlined function directly. The macro was replaced with the function in ebe304fa540f. Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-28util: remove LIST_ADDTAIL macroTimothy Arceri1-1/+1
Just use the inlined function directly. The macro was replaced with the function in ebe304fa540f. Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-28util: remove LIST_INITHEAD macroTimothy Arceri1-1/+1
Just use the inlined function directly. The macro was replaced with the function in ebe304fa540f. Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-02virgl: honor winsys supplied metadataGurchetan Singh1-1/+6
To truly to do this correctly, we'll have to fix the discrepancy between drm_virtgpu_3d_transfer_to_host and virtio_gpu_transfer_host_3d. However, this is a good starting point. Since virtio-gpu only supports self-import and export, this should be fine. Let's only do WINSYS_HANDLE_TYPE_FD for this currently. Reviewed by: Robert Tarasov <tutankhamen@chromium.org>
2019-10-02virgl: modify resource_create_from_handle(..) callbackGurchetan Singh1-1/+5
This commit makes no functional changes, just adds the revelant plumbing. Reviewed by: Robert Tarasov <tutankhamen@chromium.org>
2019-10-02virgl: remove stride from virgl_hw_resGurchetan Singh2-3/+0
It's not used anywhere, and stride isn't really an intrinsic property of a GEM buffer. Reviewed by: Robert Tarasov <tutankhamen@chromium.org>
2019-09-18virgl: Remove wrong EAGAIN handling for drmIoctlLepton Wu1-3/+3
drmIoctl handles EAGAIN itself and actually it always return -1 on errors. Remove the wrong handling of its return value. Also, print a warning when it fails. v2: - use _debug_printf instead of fprintf (Gurchetan Singh) Signed-off-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Eric Anholt <eric@anholt.net> (v1)
2019-09-14virgl: replace fprintf with _debug_printfLepton Wu1-5/+5
Signed-off-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-08-26virgl: fix format conversion for recent gallium changes.Dave Airlie2-2/+2
The virgl formats are fixed in time snapshots of the gallium ones, we just need to provide a translation table between them when we enter the hardware. This fixes a regression since Eric renumbered the gallium table. Fixes: c45c33a5a2 (gallium: Remove manual defining of PIPE_FORMAT enum values.) Bugzilla: https://bugs.freedesktop.org/111454 v1 by Dave Airlie <airlied@redhat.com> v2: virgl: Add a number of formats to the table that are used, e.g. for vertex attributes v3: cover some more missing formats from a piglit run Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
2019-08-26virgl: drop unused format fieldDave Airlie2-2/+0
2019-07-30meson: Test for program_invocation_nameMatt Turner1-1/+1
program_invocation_name and program_invocation_short_name are both GNU extensions. I don't believe one can exist without the other, so only check for program_invocation_name. Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2019-07-10android: virgl: remove unnecessary LOCAL_C_INCLUDESChih-Wei Huang2-4/+0
The path could be imported automatically. Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw> Reviewed-by: Mauro Rossi <issor.oruam@gmail.com>
2019-06-29android: fix typo LOCAL_EXPORT_C_INCLUDESChih-Wei Huang1-1/+1
Should be LOCAL_EXPORT_C_INCLUDE_DIRS. Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw> Tested-by: Mauro Rossi <issor.oruam@gmail.com>
2019-06-21android: virgl: fix libmesa_winsys_virgil_common build and dependenciesMauro Rossi2-0/+4
Fixes the following building errors and resolves Bug 110922 Fixes gallium_dri target missing symbols at linking. external/mesa/src/gallium/winsys/virgl/drm/Android.mk: error: libmesa_winsys_virgl (STATIC_LIBRARIES android-x86_64) missing libmesa_winsys_virgl_common (STATIC_LIBRARIES android-x86_64) ... external/mesa/src/gallium/winsys/virgl/vtest/Android.mk: error: libmesa_winsys_virgl_vtest (STATIC_LIBRARIES android-x86_64) missing libmesa_winsys_virgl_common (STATIC_LIBRARIES android-x86_64) ... build/core/main.mk:728: error: exiting from previous errors. In file included from external/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c:34: external/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h:35:10: fatal error: 'virgl_resource_cache.h' file not found ^~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. In file included from external/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c:32: external/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h:35:10: fatal error: 'virgl_resource_cache.h' file not found #include "virgl_resource_cache.h" ^~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Fixes: b18f09a ("virgl: Introduce virgl_resource_cache") Signed-off-by: Mauro Rossi <issor.oruam@gmail.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Tested-by: Clayton Craft <clayton.a.craft@intel.com>
2019-06-20gallium/virgl: Add code path for virgl to read driconfGert Wollny2-3/+3
This works only for the drm variant of virgl and not for the vtest variant. v2: Rebase, replace the configuration query function by a pointer to the configuration data. Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v1) Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-06-17virgl: add resource_reference to virgl_winsysChia-I Wu2-30/+17
It works similar to pipe_resource_reference but is for virgl_hw_res. It can also replace resource_unref. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2019-06-14virgl: Return immediately when finding a compatible resource in the cacheAlexandros Frantzis1-25/+14
When searching for resources in the cache, we previously released all expired resources even after having found a compatible resource. This commit changes this behavior to return immediately when finding a compatible resource, so that the operation finishes more quickly. This moves more of the burden of releasing expired resources to cache addition, which, since it happens at resource destruction time, it's less time critical. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
2019-06-14virgl: Use virgl_resource_cache in the vtest winsysAlexandros Frantzis4-122/+44
Replace the cache implementation in the vtest winsys with virgl_resource_cache. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
2019-06-14virgl: Use virgl_resource_cache in the drm winsysAlexandros Frantzis4-123/+44
Replace the cache implementation in the drm winsys with virgl_resource_cache. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
2019-06-14virgl: Introduce virgl_resource_cacheAlexandros Frantzis5-0/+330
Introduce a resource cache implementation that can be used by any virgl winsys backend. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
2019-06-11virgl: consider newly created resources idleChia-I Wu1-6/+8
A newly created resource can be regarded as idle. We don't care if the RESOURCE_CREATE command has been retired, unless it is used for fencing. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2019-06-11virgl: make resource_wait/resource_is_busy cheaperChia-I Wu2-0/+27
The round trip to the kernel is expensive. Add a local cache to avoid it when possible. There is a race condition when two contexts access the same resource at the same time (e.g., ctx1 submits a cmdbuf that accesses a resource while ctx2 maps the resource). But that is probably an app bug in the first place. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>