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>
We will need it to allocate a mmapable fd.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
COPY_TRANSFER3D was designed to handle transfers
to host. This patch is making it possible to use
this CCMD in both directions.
If guest would like to have this data available
immediately, then it should encode, flush and wait on
the guest side.
The data is copied from host to iovec attached to resource.
In most cases resource is a staging buffer.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Only non-import path is affected by this fallback:
- drop the export info since the fd type can only be dma_buf here
- allocate gbm bo and export a fd for import as external memory
- track the gbm bo in vkr_device_memory
- vkr_context_get_blob exports fd from the bo and we destroy bo here
- vkr_device_memory_release ensures the gbm bo gets destroyed
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Currently we do the below:
1. Open one render node fd per renderer process
2. Track gbm_device pointer per vkr_physical_device
The main reason is that the fallback path requiring the gbm_device
does not use drm render node for physical device.
Later we might:
1. Figure out render nodes for different physical devices
2. Open render node and create gbm_device per vkr_physical_device
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
1. the workaround is only required for host visible mem type
2. remove the def FORCE_ENABLE_DMABUF from common
3. update the docs to reflect the current assumptions
4. sanity check memory export before forcing export, which requires
extensions to be initialized before memory properties init for a
physical device
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Add a new command associated to glLinkProgram. With this we should be
able to compile and link shaders when requested by the user.
Together with the command we expect an array of shader handles attached
to the program, where each position of the array corresponds to a pipe
shader type.
Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Simplify info parameter by replacing it with vertices_per_patch.
Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
If resource created from egl image we don't need to attach iov to it.
Therefore we don't need to do transfer iov to/from host for those
resources.
Signed-off-by: Yurii Danilovskyi <glyd@opensynergy.com>
Reviewed-by: maksym.wezdecki@collabora.com
Add a helper to return the previous struct of the found struct with
input sType. This is useful for swapping a struct with something else.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Since we use GLES or the GL core profile on the host, the
alpha formats will not be available anyway, so just emulate
them right away, this helps to fix more piglits from
bin/arb_texture_buffer_object-formats fs arb
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: maksym.wezdecki@collabora.com
The swizzling didn't take into account that the destination might
actually only read a few components or just one, so that the
applied swizzling could even become invalid because code like
dest.z = vec4(dest.z.x, dest.z.y.dest.z.z. dest.z.w)
could be created. The check for when to apply the swizzling was also
not correct because the two values compared came from different
name-spaces.
To fix this, just check whether the TEXTURE_NEEDS_SWIZZLE is set,
and when loweing in the shader, take only the components into account
that are actually written.
This also needs a fix for the alpha-format override to add the
TEXTURE_NEEDS_SWIZZLE flag.
Finally take the shader type into account when checking the number
of sampler views.
v2: Correct the shader code to apply the swizzling (Maksym)
v3: Fix formatting (Maksym)
Fixes: 29c6b9177541f189ebed5158a432b21d0d82211
vrend: apply format swizzling during GLSL generation
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: maksym.wezdecki@collabora.com
This is needed for modern games that require more than 16 samplers.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
To query the size and number of levels we have to obtain the
sampler as source for the size query, but also the index for
the emulated level lookup, so default to always obtaining the
right sampler, and add a special case for obtaining the sampler
index.
v2: - Fix possible endless loop (John)
- Use the sampler source index to find find the real index
v3: Make loop easier to read, and rename variables (John)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
On OpenGL all textures can be read back using glGetTexture. On GLES
we have to be able to bind the texture to an FBO to use glReadPixels,
and only a few formats are supported as destination formats.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
Note that it is also possible to draw just one instance with
start_intance larger than zero, and one must call
glDrawElementsInstancedBaseVertexBaseInstance
or
glDrawArraysInstancedBaseInstance
in this case.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
Sometimes we receive FS shaders where some output was optimized away.
In this case we have to set the output locations explicitly, but it is
no problem if we always do this. On GL this can always be done by using
glBindFragDataLocationIndexed, it is supported since at least GL 3.3,
and the alternative, setting the layouts in the shader, requires the same
OpenGL. On GLES we have to emit explict locations if EXT_blend_func_extended
is not supported. This fises rendering of "The Long Dark".
v2: - Emit EXT_blend_func_extended in FS if extension is available
since this is required when not emitting the explicit locations
(Robert Wenzel)
- call glBindFragDataLocationIndexedEXT on GLES because that's what the
extension requires
v3: use sizoef(buf) instead of hard-coding size (John)
Related: #223
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: maksym.wezdecki@collabora.com (v2)
Reviewed-by: John Bates <jbates@chromium.org>
A shader that writes only depth will have num_outputs > 0, but since
there are no color outputs, we must not add the swizzling.
This fixes silicon city on GLES/crosvm
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
This should help debugging shader compilation errors.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
Fixes: f50c878d61
vrend: factor out preparing the blit info
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Corentin Noël <corentin.noel@collabora.com>
Since we can't properly resolve the depth buffer, we have to use one
samole, so use the sample 0 and not a random value from tc.z.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Corentin Noël <corentin.noel@collabora.com>.
The extension declaration must come before the precision definition, and
in GLES we have to emit the OES extension instead of the ARB extension.
Fixes pihlit :
spec/arb_get_texture_sub_image/arb_get_texture_sub_image-cubemap
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Corentin Noël <corentin.noel@collabora.com>.
Instead of just caching the fragment shaders and use some tables
cache all shaders and use a hash table.
Related: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/125
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Corentin Noël <corentin.noel@collabora.com>.