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>
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>
This is already handled by calling vrend_hw_switch_context with the
now-argument as true, as we do one line above.
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>
Fixes error in shader generation triggered by piglit:
arb_texture_view-rendering-layers-image
(It doesn't fix the piglit itself though)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
When the host GL version is < 4.0 then the GLSL shader language level is set
to a value below 400, but if geometry shaders, tesselation shaders, and the
gpu_shader5 are supported, then we can expect that the GLSL language level
400 is actually supported, so advertice it also on a GL host.
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This aligns the header generation code with the main body code as much
as possible. The glsl_hdr is now stored in the context to save the
passing around.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Use the buffer emitters, this makes sure we get the indents
right, but also makes it easier to cleanup this codebase later.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Fix the return checks.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
depth_clamp is actually provided also by the extensions GL_ARB_depth_clamp or
GL_NV_depth_clamp, so lets also use these to test for this functionality.
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 is a GLES only extension and the format is also only supported
on a GLES host.
Enables and passes on a host that supports it:
dEQP-GLES31.functional.texture.filtering.cube_array.formats.sr8*
dEQP-GLES31.functional.srgb_texture_decode.skip_decode.sr8.*
Closes: #49
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
GL_FRAMEBUFFER_SRGB is available on desktop GL and also when GLES exposes
the extension EXT_sRGB_write control. Add a feature to handle the use
of GL_FRAMEBUFFER_SRGB accordingly.
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 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 is *always* going to be the same, so let's drop it. Even though
it's just a few bytes, it seems silly to store the same prefix over
and over again.
Signed-off-by: Dave Airlie <airlied@redhat.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>
If more then one input variable is tagged as requiring winsys_adjust_y then
this variable would be declared more then once and consequently compiling the
shader would fail.
Keep track of whether the variable was already declared to make sure it is emitted
only once.
Closes: #72
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
There's no point in eagerly setting the blend-state, when we need to
also know the framebuffers to get it right.
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>
In the only codepath that leads here, this exact binding has already
been made, so let's avoid double-work.
This one makes sense on it's own.
Signed-off-by: Dave Airlie <airlied@redhat.com>
This is only updated from one place, and it's usually going to stay
zero. So let's cache it to prevent excessive state emission.
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 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>
This should help a bit with CPU overhead when running on top of OpenGL 4.4
(or newer).
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>
Fixes: tests/spec/arb_compute_shader/execution/basic-local-id-atomic.shader_test
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This fixes rendering in Minecraft (Java Edition), where we would
otherwise incorrectly mark a fog-inputs as flat.
While we're at it, fix a similar issue for auxprefix.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
When running tests it's easy to lose track the segfaults in the console spam,
very simply just catch the segfault and printf.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
When changing the from a one-by-one upload to an array upload the test for the
array pointer to the uniform IDs was replaced by testing the uniform array ID
against -1. However, this is not enough, because when the context is allocated
all is cleared to zero, and apparently the structure is re-used in different
invocations of shader programs. Here, one shader might have been removed but
the const field was still allocated resulting in a sigsegv. This happens e.g.
by running
dEQP-GLES31.functional.primitive_bounding_box.wide_points.
global_state.vertex_tessellation_geometry_fragment.fbo_bbox_larger
global_state.vertex_tessellation_geometry_fragment.fbo_bbox_smaller
tessellation_set_per_draw.vertex_tessellation_fragment.default_framebuffer_bbox_equal
tessellation_set_per_draw.vertex_tessellation_fragment.default_framebuffer_bbox_larger
resulting in
AddressSanitizer: SEGV on unknown address 0x00000000001c
The signal is caused by a READ memory access.
Hint: address points to the zero page.
#0 0x7f595b9eb875 in vrend_draw_bind_const_shader src/vrend_renderer.c:3677
#1 0x7f595b9ed37f in vrend_draw_bind_objects src/vrend_renderer.c:3810
Work around this by checking whether the shader type data is allocated.
Fixes: 172c9679b4
vrend/shader: handle uniforms as array
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Acked-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
It's a pkg-config 0.28 feature and Travis-CI ships with an older version.
Do the trivial task of writing it out manually ;-)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
As suggested by libtoolize
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>