This allows a blob resource to be backed by a mmap()-able fd.
Internally, it is a memfd or a shm.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Elements is replaced by ARRAY_SIZE.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
These warnings were detected with clang version 12.0.0.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Make it clear that they are implicit between submit_cmd and
resource_busy_wait.
implicit_fence_submitted is (fence_id - 1) so this change is slightly
more than renaming.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
There is never a need to wait for the GPU works (if any) involved in
resource creation. A client commonly does
VCMD_SUBMIT_CMD
VCMD_RESOURCE_CREATE2(dummy)
...
VCMD_RESOURCE_BUSY_WAIT(dummy)
only because VCMD_RESOURCE_BUSY_WAIT needs a resource. We don't need a
fence for resource creation.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Let VTEST_FUZZER_FENCES control whether VCMD_RESOURCE_BUSY_WAIT waits or
not. Fences are always created.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
It gives clients access to virgl_renderer_resource_create_blob and
virgl_renderer_resource_export_blob.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Protocol version 3 uses server-generated, rather than client-generated,
resource ids. Without that, clients could pick conflicting resource
ids.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
VCMD_RESOURCE_CREATE and VCMD_RESOURCE_CREATE2 use and return
server-generated ids since version 3. The client id must be 0.
This makes the commands work more like linux's
DRM_IOCTL_VIRTGPU_RESOURCE_CREATE.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
This paves the way for a protcol change where the server will
generate resource ids. This also improves our error handling by
switching from FREE to vtest_unref_resource.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
It gives clients access to virgl_renderer_context_create_with_flags.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Comparing to VCMD_GET_{CAPS,CAPS2}, it allows any capset id/version
to be queried.
This is similar to linux's DRM_IOCTL_VIRTGPU_GET_CAPS.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
There is no parameter defined yet, but the command can be used to query
optional features. It also allows new features to be introduced without
bumping up the protocol version.
This is similar to linux's DRM_IOCTL_VIRTGPU_GETPARAM.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
The goal is to allow clients to negoticate protocol versions, capsets,
and in the future, parameters and context types before
virgl_renderer_context_create is called.
Specifically, these commands should not trigger
virgl_renderer_context_create
VCMD_PING_PROTOCOL_VERSION
VCMD_PROTOCOL_VERSION
VCMD_GET_CAPS
VCMD_GET_CAPS2
VCMD_RESOURCE_BUSY_WAIT when res_id==0 (for legacy reasons)
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Move virgl_renderer_context_create call from vtest_create_context to
the new vtest_lazy_init_context. This defers context initialization
until the first command after VCMD_CREATE_RENDERER.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
struct vtest_context is about to get more complex. Use
vtest_destroy_context so that we have a single point that does context
destruction.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Passing NULL for args to indicate nop is too tricky to get right.
Add a bool for that.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: David Riley <davidriley@chromium.org>
We want to destroy all resources owned by a context after a client
dies unexpectedly. This is needed for --multi-clients. See commit
6c44b4a79 (vtest: add experimental multi-client support) for more
details.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Call virgl_renderer_resource_unref from resource_destroy_func. Do
not rely on virgl_renderer_cleanup to clean up for us. This is
needed for proper multiple client support, where we need to clean up
client resources when a client dies.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Move the common code of vtest_create_{resource,resource2} to the new
function.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Manage both v1 and v2 resources the same way.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Add vtest_resource and embed iovec in it.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Move the common code of vtest_transfer_{put,put_nop,put2,put2_nop}
to the new function.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Move the common code of vtest_transfer_{get,get_nop,get2,get2_nop}
to the new function.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Replace DECODE_TRANSFER2 macro by the new helper.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Replace DECODE_TRANSFER macro by the new helper.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Autotools is deprecated since debb6e6ac4
It's now time to drop it definitively.
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Previously, Mesa would remain forever blocked in read() after an error
such as failing to compile a shader.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
To keep Valgrind happy:
==3628== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==3628== at 0x48DB431: sendmsg (sendmsg.c:28)
==3628== by 0x10C00E: vtest_create_resource2 (in /virglrenderer/build/vtest/virgl_test_server)
==3628== by 0x10AC2B: vtest_server_run (in /virglrenderer/build/vtest/virgl_test_server)
==3628== by 0x10A5B3: main (in /virglrenderer/build/vtest/virgl_test_server)
==3628== Address 0x1fff0004ef is on thread 1's stack
==3628== in frame #1, created by vtest_create_resource2 (???:)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Add --multi-clients to enable experimental multi-client support.
Note that multi-client should be enabled only when the clients know
and trust each other. This is because resources are global among
the clients. Two clients trying to create two resources with the
same id will result in an id conflict for example.
Proper multi-client support requires changes to the protocol. The
main change will be for the server to generate globally unique
resource ids and enforce access controls.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Add vtest_server_run to replace vtest_server_run_renderer. The new
function is the main loop of the server, which
- accepts new client connections
- dispatches client commands
- removes inactive clients
- lazily initi/cleanup the renderer
- optionally forks for each connection
in a single loop.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Get rid of gotos so that it will be easier when we turn
vtest_server_run_renderer into the main loop.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
We want to make vtest_server_run_renderer the main loop when we add
multi-client support. Forking for new clients will be done in the
main loop.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Call vtest_init_renderer when the client connects, instead of before
the first command. We want to make vtest_server_run_renderer the
main loop when we add multi-client support, and this makes things
simpler.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Refactor command dispatching to a separate function,
vtest_client_dispatch_commands.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>