This helps a lot locating errors in the shaders.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
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>
Left shift int 1 by 31 bit is undefined behavior, which causes fuzzer
failure. Change 1 to 1u to avoid the runtime error.
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
There's little reason to confuse lod-bias and cubemap seamlessness. So
let's give lod-bias its own warning string.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This flag is *always* passed as zero, so it carries no information.
Let's just get rid of it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This flag is *always* passed as zero, so it carries no information.
Let's just get rid of it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.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>
mesa optimizes away the information about input layouts for generics and
patches for TCS, TES, and GEOM shaders (all that pass these inputs as
arrays), but when input arrays are allowed, then these varyings may
actually have overlapping layouts (at least some piglits do, even though
they don't specifically require ARB_enhanced_layouts).
To be able to link shaders like these with enables arrays pass this info
to the next stage.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Arrays of arrays are way easier to handle and they are available on GLES
3.1, D-GL 4.3, and all hardware that is supported by mesa. The old code
path is still able to use blocks for passing parameters to and from
tesselation and geometry stages, but for the new code path they are
required.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
Set the pre stage correctly when the TCS shader is missing on OpenGL and
warn about it when on OpenGL ES.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
We already have a helper for this, let's use it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
When calling vrend_renderer_transfer_write_iov through
vrend_renderer_transfer_iov, we sometimes come down these
code-paths with the context 0 active, but the non-zero context being
passed as the context-pointer. Trying to do any caching based on this
will only lead to incorrect behavior.
There's little point in trying to fixup the caching in the ctx0 for
this call-site, as there's no other code-path using ctx0 that tries
to play ball with the cache.
So let's get rid ot the context-argument when possible, and pass a
NULL-pointer when it can come either from ctx0 or a rendering-context.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Without this, the next patch gets trickier, because we try to
*avoid* passing down the wrong data rather than trying to react to it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This argument is unused, and the function is not a part of the external
API, so there's little point in passing it just to discard it again.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Context name length was being ignored and strncpy does not enforce
null termination but the destination was being used as a null terminated
string.
Change-Id: I715394b364130578a1a6a319dc16927261523d71
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
EXT_texture_query_lod on GLES is proposed as extension providing for
GLES what ARB_texture_query_lod provides for D-GL.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
GL_TEXTURE_LOD_BIAS is supported in GLES at least since 3.0,
This also fixes a number of piglits when run on a GLES host.
GL_TEXTURE_SEAMLESS_CUBE_MAP is not supported on the other hand.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This GLES extension has been merged into the OpenGL registry, so it may
now become available.
Signed-off-by: Gert Wollny <gert.wollny@collabora.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>
This tracks more accurately what exactly needs to be updated.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
We're going to have to do this anyway, so let's just do it cleanly
right away.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
These settings can't change in the lifetime of the texture-view,
so let's set them up front instead of re-setting them on every re-emit.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
There's no point in changing the texture-binding unless we're going to
do something with the texture-stage.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
This means less needless work per frame, as this binding will never
change.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
The result is the same, we just skip a bit quicker over unused entries.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
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>
d9a4be4d0a broke a number of tests
when running on a GLES host because tgsitargettogltarget may
return PIPE_BUFFER which is 0. So, instead of simply reverting the commit
make it more explicit that we check for PIPE_BUFFER to make it clearer
that this condition may actually trigger.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Instead of enumerating all the GL buffer types, just use the
is_buffer flag.
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This uses the string array helpers to pass around the glsl strings
for the program.
This could be expanded on to provide more than 2 strings easily
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
We can't cache the current states on the texture-view, as multiple views
can point to the same texture. Instead, we need to cache the state on
the texture.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 8d288c4 ("vrend: update texture state on a per view base")
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
tgsitargettogltarget never returns a value that evaluates to zero, so
this condition can't trigger. Let's drop the code.
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>
Texture views with emulated alpha also needs to get their border-color
swizzled. So let's check the texture-view instead of the resource.
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>
This is going to make a difference for the next patch.
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>
Using GLenum here makes it sound like this is used for OpenGL formats,
and not for pipe_format, which it really is. So let's change the type to
reflect what it really is.
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>
This toggle only affect fixed-function fragment-shading, which we don't
use at all. So let's not waste time setting unused state.
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>
We shouldn't call glTexBuffer unless we know the feature is enabled,
otherwise a rouge client might be able to crash the host.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
[airlied: fix whitespace]
Signed-off-by: Dave Airlie <airlied@redhat.com>
v2: Instead of releasing the UBO's at the end don't reference count them.
The guest keeps track of these resources and their reference counts,
so it will not release the UBO's without re-setting the binding during
the live time of a client progra, However, at final clean up the UBO's
are not rebound before the resourse is released in the guest side resulting
in the memory leak. When we skip the ref-counting on the host side the
resourses are cleaned up correctly without breaking the program otherwise.
Fixes resource leaks:
Direct leak of 2448 byte(s) in 9 object(s) allocated from:
#0 0x7fe3151aba68 in __interceptor_calloc (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0xdba68)
#1 0x7fe314b89ea6 in vrend_renderer_resource_create ../../../../virgl-gitlab/src/vrend_renderer.c:5834
#2 0x7fe314b52b44 in virgl_renderer_resource_create ../../../../virgl-gitlab/src/virglrenderer.c:63
#3 0x560533f27852 in vtest_create_resource2 ../../../../virgl-gitlab/vtest/vtest_renderer.c:432
#4 0x560533f254fa in vtest_main_run_renderer ../../../../virgl-gitlab/vtest/vtest_server.c:359
#5 0x560533f244df in main ../../../../virgl-gitlab/vtest/vtest_server.c:105
#6 0x7fe313919ac9 in __libc_start_main (/lib64/libc.so.6+0x21ac9)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This is helpful to get the name of the guest program that may trigger a
memory leak. One can also pass a custom string as program name by setting
the environment variable GALLIUM_PROCESS_NAME in the guest accordingly.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This way all output originating from virglrenderer will be redirected.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This patch adds the infrastructure and replaces the debug calls to fprintf
by calls to vrend_printf that internally may be redirected.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
We need to dirty the compute shader if we bind a new non-compute program,
this fixes a bug in the qbo tests when qbo is merged.
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>