This allows us to use vkr_context_alloc_object.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
A helper function that loads the id from the handle automatically.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
A helper function that asserts.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
By using the string buffer that automatically grows we avoid that
the argument string gets cut off at a certain size when we switch
to pass immediate texop args
v2: free buffers on early error return
Closes: #235
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
While crosvm gets the legit debug name from the guest kernel, it does
not pass it to virglrenderer. We prefer the instance name anyway.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Remember it as the instance name.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Ensure all ring control member variables have their own storage during
ring creation. Member address re-use would otherwise result in undefined
behavior.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Tracking offset+size together for each ring control variable makes extra
upcoming layout validation simpler.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
When VKR_RENDERER_ASYNC_FENCE_CB is not set, we destroy the VkFence at
device destruction and move the queue syncs to the ctx so that they can
get retired and freed in the next retire_fences call.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Refactored queue syncs retire on destroy into vkr_queue_retire_all_syncs
and rename vkr_queue_retire_syncs to vkr_queue_get_signaled_syncs.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
It is covered by vkr_cs_decoder_lookup_object.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
The decoder makes sure the command buffer pointer is non-NULL since
0f12c460 ("vkr: make sure the first dispatchable handle is non-NULL").
And vkr_cs_decoder_lookup_object is just fixed to validate the object
type.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
The decoder makes sure the device pointer is non-NULL since 0f12c460
("vkr: make sure the first dispatchable handle is non-NULL"). And
vkr_cs_decoder_lookup_object is just fixed to validate the object type.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
The decoder makes sure the physical device pointer is non-NULL since
0f12c460 ("vkr: make sure the first dispatchable handle is non-NULL").
And vkr_cs_decoder_lookup_object is just fixed to validate the object
type.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
They are checked by the decoder since ee9db8b0 ("vkr: validate
non-optional pointers")
This reverts 44448cf7 ("vkr: fix some null dereferences") except for the
check for args->streamCount in vkr_dispatch_vkExecuteCommandStreamsMESA,
which is unnecessary but good to have.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Use them for objects that are tracked as non-device objects. These
include VkInstance, VkPhysicalDevice, VkDevice, VkQueue,
VkDescriptorSet, and VkCommandBuffer.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Use them for objects that are tracked as device objects. This excludes
VkQueue, VkDescriptorSet, and VkCommandBuffer.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
They are wrappers to vkr_context_{add,remove}_object with added sanity
checks.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
They are wrappers to util_hash_table_{set,remove}_u64 with added sanity
checks.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Log the context id/name when a context is destroyed with an instance.
Log before vkDeviceWaitIdle when a device is destroyed with objects.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
It automatically prefixes the message with "vkr: ".
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
Rename the debug callback to virgl logger and add virgl_logv for
logging. vrend_printf becomes a wrapper of virgl_logv.
v2: use virgl_debug_callback_type (Ryan), add virgl_dummy_logger
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
For a (fooCount, pFoo) array, we encode fooCount twice. Previously, we
used one for allocation and the other for initialization. When the two
differed, we could allocate an array of N elements but initialize only
the first M elements. We only validated that M <= N.
After this commit, vn_decode_array_size validates that M == N.
The other main change is that this commit adds vn_decode_char_array to
make sure strings are null-terminated.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
vkr_queue_create returns the created queue or NULL for simplicity and we
map NULL to VK_ERROR_OUT_OF_HOST_MEMORY.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
protected and non-protected queues need separate vkr_queue objects.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Up until now sme of the info stored in sinfo was changed
based on the shader key, and since this info is used for
all shader variants when evaluating the key for shaders
to be linked, this may result in the wrong shader
variant being picked up.
Instead track the shader info that can be changed like this
in the shader variant itself.
Closes: #239
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Dave Airlie <airlied@redhat.com>
RELEASE_TRACKED_OBJECTS did not like track_list to include "obj" after
expansion. Fix the callers and fix the gotcha.
v2: replace RELEASE_TRACKED_OBJECTS by an inline function (Ryan)
Fixes: 9da6721 ("vkr: add RELEASE_TRACKED_OBJECTS for tracked vkr_object")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
dev_obj is internal to the macro. Rename it to _dev.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
The first argument is the identifier (e.g., cmd or set) of the object.
Because these macros create multiple objects, it is useless.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Fixes e5fabecbe0
vrend: pass texture levels per shader on GLES as uniform
v2: - only emit texlod uniform when textureQueryLevels is called
- initialize uniform location to -1 if the mask shows that
the texture lod levels arenot needed and ony test this when
uploading the data
(all suggested in a way by Chia-I Wu)
Closes: #237
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
While this should be the job of VVL, vkr dereferences the pointers
sometimes before calling down to the driver. It should be better for
the decoder to validate for us.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Follow up to commit a108be89e3 to clarify
acceptable length values for VIRGL_CCMD_SEND_STRING_MARKER command
buffers. This imposes no functional change.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Fixes a missed internalformat fixup when glTextureView() is used to create
vrend_surfaces for resources backed by shared EGL images without an
alpha channel (e.g. RGBX, BGRX). Such resources are registered in host
Mesa with internalformat GL_RGB8, but virglrenderer prefers to create
32bpp textures and do it's own swizzling.
fixes: commit ebb2cf3 "vrend: convert linear color to srgb for 24bpp
imported EGL resources".
Signed-off-by: Ryan Neph <ryanneph@google.com>
Break it up into vkr_{device,instance,physical_device}.c. Suggested by
Ryan Neph.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>