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>
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>