Having this code overwrite whatever was done before is a gotcha waiting
to happen.
Signed-Off: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The range is needed to identify indirectly addresses IO values.
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>
On GLSL ES implicit conversion are not enabled by default. Since here the
evaluations are hard coded, just emit literal values according to the
types they are used with in the operations.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
On GLES *Rect textures are not supported and emulated by using a normal
2D texture. Therefore, the texture coordinates must be normalized for
these cases and the LOD must be set to 0.
Fixes: piglits
textureGather with 2DRECT texture
arb_fragment_program_shadow/tex-shadow2drect
arb_fragment_program_shadow/txp-shadow2drect
glsl-fs-texture2drect -proj3 and -proj4
Related: #81 (some non-shader tests still fail for rect textures)
v2: - Reorder some conditions to make the control flow easier to follow
- correct WS (both Gurchetan)
Remark: For some of these piglits one must currently force GL 3.3 in the
guest, otherwise they fail because of GLSL version 1.50 not being
supported.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: <Gurchetan Singh gurchetansingh@chromium.org>
GLES doesn't support 1D textures, so they are emulated by using 2D
textures and the access has to be fixed by adding the y lookup coordinate.
v2: simplify the code flow (Gurchetan)
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>
This function was added but never used. Let's get rid of it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 5d2dde4 ("strings: move to 3 strings, and patch extensions onto end of string 0 (v2)")
Reviewed-by: Gurchetan Singh <gurchetansingh@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>
Otherwise, a failure happens with gold linker:
../src/.libs/libvirglrenderer.so: error: undefined reference to 'drmPrimeHandleToFD'
https://errors.yoctoproject.org/Errors/Details/222046/
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.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 saves adding the padding and just appends the ext strings
v2: use emit_hdr for the precision strings (Gert)
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
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>
This will make things easier in a later patch.
Suggested by Gert.
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
when virgl_renderer_init is called from qemu for initializing D-GL
no context type flags are set and the context remains at NONE.
Assume in this case that gl_colorspace is true, otherwise the
feat_srgb_write_control flag will be cleared and the guest only
gets OpenGL 2.1 compatibility.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
As of 2018/11/30 EXT_texture_sRGB_R8 is also a valid extension for
desktop GL. Hence, move the format into the joined list so that
it can be picked up if the D-GL host supports it.
Signed-off-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>
vrend_debug.h is not installed but we need the typedef for the debug
callback.
Fixes: 70fefe33df
virgl: expose function to set output callback
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Fixes the mem leak:
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7f49a7733c60 in realloc (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0xdbc60)
#1 0x7f49a713100a in add_sampler_array ../../../../virgl-gitlab/src/vrend_shader.c:619
#2 0x7f49a71318cb in add_samplers ../../../../virgl-gitlab/src/vrend_shader.c:677
#3 0x7f49a713a780 in iter_declaration ../../../../virgl-gitlab/src/vrend_shader.c:1213
#4 0x7f49a7194c37 in tgsi_iterate_shader ../../../../../../virgl-gitlab/src/gallium/auxiliary/tgsi/tgsi_iterate.c:59
#5 0x7f49a7169a24 in vrend_convert_shader ../../../../virgl-gitlab/src/vrend_shader.c:5012
Closes: #85
[airlied: v2: free image arrays as well]
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
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>