Rename VREND_RESOURCE_STORAGE_IOVEC to
VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM and introduce
VREND_RESOURCE_STORAGE_GUEST. The former is used as storage for query
buffers, and the latter will be used in upcoming commits for staging
buffers.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
With 6a3cd2bd vrend: send list of readback-formats to guest
stricter format checks were introduced on GLES. This may lead to format
conversions in guest and host that can be avoided for additional
implementation specific readback formats. So when we build the format list
also check whether a bound texture format can also be read back from the
fbo and report the standard and additional formats also to the guest.
v2: Make things simpler and more correct (Erik) i.e.:
- default to false in the check for readback formats
- rename test function to indicate that we test color formats only
- don't pass the gl_version, instead use the epoxy functions
to get the platform info
v3: - check for DS readback support (Thanks to Erik for pointing out that this
is not available in unextended GLES)
- drop some superfluous braces (Erik)
v4: - move DS checks to separate commit (Erik)
v5: - split patch to move preparations that don't change
functionality to preceeding patches
- reduce the amount of error checking (Erik)
- only check readback for formats that can actually be used as
render targets
- remove some temporary variables (Erik)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Also limit the scope of some variables.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
The name for the internal texture properies flags VIRGL_BIND_NEED-SWIZZLE
and VIRGL_BIND_CAN_TEXTURE_STORAGE is misleading, and the latter flag was
even mis-using the binding member of the texture format structure.
Rename these flags to make it clear that these are not binding flags and
correctly use the 'flags' member for CAN_TEXTURE_STORAGE. In addition, drop
adding the NEED_SWIZZLE flag to the binding in the alpha texture emulation.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
This allows a resource to use the guest pages as its storage when
the iovec is attached.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Check queries from within vrend_renderer_check_fences, after
glClientWaitSync but before write_fence. This makes sure query
results are available after the fence is waited for.
In other words, given this sequence of commands
BEGIN_QUERY > DRAW_VBO > END_QUERY > GET_QUERY_RESULT > FENCE
Waiting on the fence makes sure the query result becomes available
to the guest.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
With that the srgb <-> linear handling can be simplified.
v2: Don't use texture views when TextureStorage can't be used to create
the texture, because then it is not immutable.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
later we need this function in the blitter
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Check args of the following function:
- vrend_decode_set_vertex_buffers
- vrend_decode_set_shader_buffers
- vrend_decode_set_atomic_buffers
- vrend_decode_set_shader_images
And change variable type to uint as the protocol should never send negative number.
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
These already have to be the same as VIRGL_TRANSFER_{TO,FROM}_HOST, as
defined by the protocol. There's no point in having a separate set of
internal names for them.
While we're at it, rewrite tan if as a switch for clarity. This allows
us to detect internal usage of invalid values.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Virglrenderer sometimes tries to remove resources from the hash table
twice. Which will mess up the ressource hash table and reference counts
and therefore and leads to qemu/virglrenderer crashes.
Reproducer:
(a) guest creates resource foo, id 42.
(b) guest creates an object bar referencing resource foo.
(c) guest unreferences resource foo.
-> resource id 42 is removed from hash.
(d) guest creates a new resource baz, re-using id 42.
(e) guest destroys object bar.
-> resource foo refcount goes down to zero.
-> resource id 42 gets removed from hash the second time,
but id 42 entry points to resource baz not foo now.
Oops.
Note that most linux kernel drivers will never ever re-use resource ids
due to a bug in the virtio-gpu kms driver, in which case this bug
doesn't cause any harm.
Root cause is that vrend_renderer_resource_destroy() may call
vrend_resource_remove(), depending on the call chain. This is wrong.
Only vrend_renderer_resource_unref() which is called when the guest
unreferences a resource should remove the id from the hash table by
calling vrend_resource_remove().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: <Gurchetan Singh gurchetansingh@chromium.org>
To avoid that the guest sends mixed color attachments when this is not
supported test this and add an according caps flag.
Related: #88 (a full fix needs a mesa side patch to make use of the
flag sent)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
A transfer won't occur in context zero if the transfer command
comes from submit_cmd. We need to restore prior state.
With the recent framebuffer binding cleanups, we really only need
to worry about the framebuffer.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
This is needed to properly support EXT_sRGB_write_control
v2: Make return value of virgl_has_egl_khr_gl_colorspace
a bool (Gurchetan)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This adds a new api to set/get a private pointer.
v2: add private ptr test
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This is always passed as zero, so let's make the code a bit easier to
grok by removing this unused argument. We still need to pass zero to the
externally passed callback, though.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Add flags tgsi,glsl,stream, and shader and change the corresponding
logging code.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
No real flags are defined, only the macros and functions.
VREND_DEBUG(flag, ctx, ...) translates to fprintf(stderr, ...)
that is enabled based on whether logging is enabled for flag
in context ctx
VREND_DEBUG_EXT(flag, ctx, X) can be used to add code sequenses
as X, e.g. specific logging calls like for streams.
v2: Make use of variadic macros to make the VREND_DEBUG macro more
like a call to *printf (Following a suggestion by Gurchetan)
v3: Already include debug header in vrend_renderer.c
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Add support for TGSI's HW atomic counters, implemented here with
atomic_uint.
v2: - Fix calculation of atomic count in cmd
v3: - Add feature-checks (Dave Airlie)
v4: - Pass max-values for all stages and combined (Erik)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Gallium copy_image redirects calls to resource_copy_region for equal src
and dst formats or if at least one of the two is compressed. Handle the
condition for selecting blit vs. glCopyImageSubRegion accordingly.
Fixes piglit: bptc-float-modes
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This adds the texture barrier support for the texture barriers,
a separate patch would be needed to implement the framebuffer fetch
barriers.
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
glTexStorage*D is more restrictive in supporting texture formats, especially
on GLES. Specifically, it doesn't support BGRA textures that are needed to get
any useful display, but it is needed to get immutable textures that are required
for glTextureView.
Check which formats are supported and use glTexStorage*D for these, otherwise
fall back to use glTexImage*D.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
On an GL host set the sRGB blit framebuffer state explicitly to make virgl
behave like on a GLES host.
This does not correct the handing of sRGB completely, because the state
GL_FRAMEBUFFER_SRGB is not properly transmitted to the host. As a result
the piglits "blit texture linear_to_srgb * * *" flip.
Tests thatset "enable" failed before and pass now, and tests that set "disable"
now fail.
v2: - Move setting the fbo state out of the loop (Robert Tarasov)
- Use the blitter context to set and store the state, since it is only,
and currently we don't pass the state from the guest
relevant when the dst texture is SRGB, there is no need to disable it
- Just enforce that a source SRGB texture is always decoded when this could
be disabled
Fixes on GL host:
dEQP-GLES3.functional.fbo.blit.conversion.rgb8_to_srgb8_alpha8
dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8
Reviewed-by: Robert Tarasov <tutankhamen@chromium.org>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This requires adding new protocol to pass the width/height/layers/sample
default values from the host.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
For compute shaders we put the req local memory into the streamout
places in the protocol, and we create compute shaders in a separate
lookup function
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
GL4.2/GLES3.1 adds glMemoryBarrier so make sure we can handle it.
v2: add a cap bit for this for guest
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
This adds support for tracking images, and binding them
to the GL context.
includes:
vrend_renderer: create texture when TBO is used as image
vrend_renderer: specify correct access to glBindImageTexture
v2:
vrend_renderer: invert glBindImageTexture layered logic
v3: fix decode macros (Gert pointed out for ssbo)
v4: add max image samples to the caps.
add image arrays.
use mask var outside loop (Gert)
change img_locs type to GLint and printf on fail (Gert)
Co-authors: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
These VREND_BIND_*-flags here are basically a subset of the
VIRGL_BIND_*-flags, with one custom flag added. So let's just use
those, and use an unused big from the others for the swizzle-flag.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
These are identical to the corresponding VIRGL_BIND-flags,
so let's get rid of this duplicate definition.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
This pulls the code out from the gles31 development,
and modifies the caps to support two different limits
(so far I've only found fs/cs vs everyone else limits differ)
v2: fix buffer creation paths, limit maximums, handle indirect
(don't pass -1 into gl funcs when we don't need to).
v3: free ssbo locs
v4: use two caps fields
Co-authors: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
When the host is gles >= 3.2, gl >= 4.3, or when the extension
GL_(ARB|EXT|OES)_copy_image is available, memcopy like blitting and region
copying can be done for many color format combinations by using
glCopyImageSubData.
This fixes a number of tests from the subset
dEQP-GLES31.functional.copy_image.non_compressed.viewclass_*
v2: - Clean list of canonical formats (Gurchetan Singh)
- Use size of canonical formats to decide whether they can be copied via
gCopyImageSubData
- Also honour the render state when deciding whether glCopyImageSubData
will do, or whether we need to do a blit.
v3: - replace format size check by compatibility check (Gurchetan Singh) but
keep the check seperate because we need to add logic for compressed
texture later
Reviewed-by: Gurchetan Singh <gurchetansingh at chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
The protocol will never send negative numbers, so use uints
to avoid having to compare to 0 and other warnings.
Reviewed-by: Po-Hsien Wang <pwang@chromium.org>
This is required to implement glMinSampleShading().
Sadly, we've been setting has_sample_shading for a while, even
though this is needed. So we need to set a capability so mesa will
know that it's safe to emit this command.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Query the number of supported samples and the sample position and
store these to the caps.v2 structure. We support only up to 16 samples.
This implementation requires a GL host backend.
v2: - glTexImage2Dmultisample is not available on a gles 3.1 host
and trying to call it crashed qemu (Jakob Bornecrantz)
Use glTexStorage2DMultisample instead and delete texture each
round because the texture becomes immutable.
- move call to get sample positions only when caps v2 needs to be
filled.
v3: - rebase against master
- take care of nits (Dave)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
In the copy fallback, when a texture can not be rendered, the data that resides
in the backing iovec needs to be used. For the non-zero levels of mip-map textures
the data is located at an offset. This patch adds storing this offset and using it
when data is read from the backing iovec and updating the dst iov. We limit the
mip-map levels for which this is done to 1-17, which is enough to cover
32kx32k textures. The patch also fixes the stride when accessing mip-map levels.
Fixes:
dEQP-GLES3.functional.texture.specification.teximage3d_depth.depth_component24_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component32f_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component24_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component16_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth32f_stencil8_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth24_stencil8_2d_array
v2: * rebase and remove unused variables
* also correct offset when writing to the destination backing iovec
v3: * follow mesa/virgl notation and range for storing the mip-map offsets
Suggested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
v2: With epoxy GL/gl.h is not directly included (Dave Airlie).
Instead move the include of epoxy/gl.h from vrend_renderer.c to
vrend_renderer.h
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Allow resources created externally (eg gbm created buffers as
dma bufs) to be used. As an example, crosvm
(https://chromium.googlesource.com/chromiumos/platform/crosvm/)
will intercept resource creation to use minigbm to allocate
buffers that its compositor is able to properly handle since it
only supports compositing with buffers allocated via minigbm.
This patch allows direct rendering to those buffers without
requiring an extra copy.
v2: Handle missing extension better.
v3: Update commit message with more details on usage.
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
This passes the default tessellation factors from the guest to
the host.
v2: fix warnings
Tested-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
and make sure that on GLES it it chosen for GL_RGBA4 over
VIRGL_FORMAT_B4G4R4A4_UNORM, by removing support for the latter.
This is needed because on GLES3 GL_BGRA isn't a supported format to pass
to glTexImage3D.
Fixes the test dEQP-GLES3.functional.texture.format.sized.3d.rgba4_pot
on GLES hosts.
v2: * Make more explicit the GL/GLES split (Gert Wollny)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Suggested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
This allows the tbo code to properly detect if we are using a buffer
as a texture or not, instead of relying on GL_TEXTURE_BUFFER being used.
We also don't need to special case generate the tbo texture id until
sampler bind time.
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>