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>
Since this adds a new function to the library interface this also needs
a bump in the library version number.
Closes: #80
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 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>
This is needed for guest GL >= 3.0 on GLES.
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 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>
emit_ios handles all the shader types so that it is difficult to
follow what is emitted for which shader type. Start refactoring by
moving the common initialization into a separate function.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
There's no point in keeping updating all the constant buffers for every
draw; we only need to update those who has changed since last draw.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This allows us to allocate UBO ids based on the linked result, rather
than the currently bound UBOs. This gives us a per-program stable
result, which means we don't need to keep updating them.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
We already track samplers, images and ssbos using bitmasks, so this is a
bit more familiar to the rest of the code.
Also, this is going to enable some other nifty optimizations later on.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This just makes the code a bit more semantically strong, and reduce the
chance of typos in the future.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
We have call-sites where we already know the length of the string,
so calling strlen is entirely needless. So let's introduce a variant
called strbuf_append_buffer that takes an explicit length, and make
strbug_append call that instead.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
TGSI_OPCODE_BFI and TGSI_OPCODE_ATOMCAS takes four source arguments,
so we actually need to support up to four members here. Luckily, the
storage passed to this function was large enough, so no actual harm
happened, just a small semantic issue when reading the source code.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
It's not legal to reuse the varargs list without taking a copy, so
let's do that before we use it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
This moves the body generation code to the same scheme as the
header, and fixes a lot of the printf related warnings.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This moves to using the strbuf variadic append.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This avoids all the return checks in favour of setting
the error state in the string buffer, and cleans up the
result.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This should avoid all the unnecessary return overheads, at the
expense of some extra runtime overheads in the unwanted error case.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
We definitely want to check for errors after each instruction
and after iteration and header generation.
This should allow the explicit checks to be removed now.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This converts the current string tracking code to using strbuf.
The indent code and tracking for the main + header strings is moved
over.
Now we know the string lengths this also optimises the concatentation.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This adds a string buffer implementation + unit tests with
the following features:
- growing reallocation on append
- variadic printf-like append function
- indenting
- error state tracking (stop appending on errors)
This will be used in the GLSL shader construction to clean up
the bad string length issues we have now.
The variadic append is based on one Erik Faye-Lund wrote.
v1.1: improve indenting
v1.2: fix includes + use memcpy
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
We shouldn't clobber this state any more, so this assumption should be
safe.
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Both of these functions clobber the framebuffer-binding on
general-purpose GL contexts, which is bad for performance.
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>