egl_image always wraps gbm_bo so far so this is not a real issue. But
it will change soon.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
Make virgl_egl_image_from_dmabuf a generic helper. Add
virgl_egl_image_from_gbm_bo and virgl_egl_aux_plane_image_from_gbm_bo
that use the helper.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
Use helper variables for some pointer derefs and query the shader ID's
only once.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
v2: rename ctx to sub_ctx (inspired by comment of Chia-I)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This info is only used when creating the shader key, so it can reside in
the sub context.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
With that Unigine Heaven goes from around 56 FPS to 58
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
With that shaders that are used more frequently will remain at the
top of the list, and since the search in the shader program list is
linear, this should save some time.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This gives a 6% speed improvement with Unigine Heaven
v2: remove the unlikely for dual_src, the whole statement will
be changed later (Chia-I Wu)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
if-chains can usually not be optimized very well, switch/case might be
implemented as a jump table.
v2: Add a break in bese before default (Chia-I Wu)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This makes the code a bit easier to read and may help the complier
to avoid needless dereferencing of pointers.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
v2: add comment about that INDEX is not used (Chia-I Wu)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Comparing to virgl_renderer_context_create, it allows flags to be
specified. flags can only be used to specify the capset id in this
commit, but that may change in the future.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Unlike out_fourcc, where the default value 0 is DRM_FORMAT_INVALID, the
default value 0 for out_modifier is DRM_FORMAT_MOD_LINEAR.
This changes nothing in practice as the only user of
virgl_renderer_execute is crosvm, and crosvm takes the
ENABLE_MINIGBM_ALLOCATION path instead.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Add virgl_resource::map_info and return it in
virgl_renderer_resource_get_map_info.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
This allows the callers to modify the returned virgl_resource without
looking up.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
When a virgl_resource wraps a pipe_resource, it is said to be typed
because pipe_resource contains the type information.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
Most of the time we pass a string that can simply be forwarded to
the perfetto trace function.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This silences a warning about non-static variable not being previously
declared.
v2: make table const (Chia-I Wu)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Rename it to vrend_resource_alloc_texture to match
vrend_resource_alloc_buffer.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Add vrend_resource_fixup_emulated_bgra to fix up emulated bgra.
This is a refactor with no real change.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Add vrend_resource_alloc_buffer to allocate the storage for PIPE_BUFFER.
This is a refactor with no real change.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Add vrend_resource_create helper to allocate and initialize the
vrend_resource struct.
This is a refactor with no real change.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
This is now already checked before we decode the command.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
v2: drop decode state and use local variables to handle keeping
track of the decode buffer state (Chia-I Wo)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
With that we don't need to resolve the pointer chain in each decode
function.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Since each switch case only results is a function call we can also execute
the call directly by using a call table.
v2: Add VIRGL_CCMD_NOP and validate table when a context is
created (Chai-I Wu).
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
If GL_POINT_SPRITE mode is enabled and a texture has
GL_COORD_REPLACE enabled, the texture will apply coord_replace
to all primitive types, instead of only GL_POINTS as expected.
This change checks the prim_mode for every draw call and selects
the appropriate shader variant to enable coord_replace only when
rendering GL_POINTS primitives.
Closes: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/188
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
We don't know what internal format the GL driver uses and we have to
glFinish and do a gbm transfer unless VREND_STORAGE_GL_IMMUTABLE is set.
This is motivated by Mesa's internal format change from GL_RGB to
GL_RGB8 for VIRGL_FORMAT_B8G8R8X8_UNORM in
5e4d69ec78.
That change caused glTexSubImage2D(..., GL_BGRA_EXT, GL_UNSIGNED_BYTE)
to be rejected by _mesa_gles_error_check_format_and_type.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The bo contents may be undefined when only GBM_BO_TRANSFER_WRITE is set
(e.g., with radeonsi). When transferring to a subregion, we need to set
GBM_BO_TRANSFER_READ as well.
gbm_bo_map2 does allow us to map a subregion, but not all
implementations work correctly.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
We can now use gbm_bo_map(..) directly to match Mesa.
If minigbm doesn't define the needed use flags, we define it
internally.
This should allow us to build with minigbm allocation enabled and
use the Mesa gbm header.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Fixes the order of params passed to emit_ios() calls
(swaps winsys_adjust_y_emitted and force_color_two_side).
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-By: David Riley <davidriley@chromium.org>
EGL_ANDROID_native_fence_sync only works on gles profiles.
Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>