This avoids a lot of fixed-size arrays, which currently leads to
warnings that are hard to prove correct or incorrect. So let's rather be
safe than sorry, and dynamically allocate these instead.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
This helper completely replace the contents of a strbuf with its
content. This is useful when building temporary strings in the shader
source generation code, and it a bit semantically cleaner (and more
efficient) than appending to an empty buffer.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
We already have an oportunistic buffer to try with here, let's use that
instead of writing to the stack first.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
There's no good reason to keep this code here; it's not like it saves us
a lot of logic, and it's unused apart from inside the glsl main.
This has the benefit of keeping struf a bit simpler; less mechanisms
needs to know about each other. Since I plan on adding more
functionality to strbuf, this will make things a lot easier.
Sadly, we don't have an easy way of doing unit-tests for the
vrend_shader internals. So for now I'm just dropping the tests here.
It's not ideal, I know, but yeah... Sorry? :P
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
These two members are written, but never read. Let's get rid of them.
This has the nice side-benefit of eliminating a warning, because of
an implicit cast.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Enable DS redaback depending on the availablility of the
corrosponding extensions.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
With 6a3cd2bd vrend: send list of readback-formats to guest
stricter format checks were introduced on GLES. This may lead to format
conversions in guest and host that can be avoided for additional
implementation specific readback formats. So when we build the format list
also check whether a bound texture format can also be read back from the
fbo and report the standard and additional formats also to the guest.
v2: Make things simpler and more correct (Erik) i.e.:
- default to false in the check for readback formats
- rename test function to indicate that we test color formats only
- don't pass the gl_version, instead use the epoxy functions
to get the platform info
v3: - check for DS readback support (Thanks to Erik for pointing out that this
is not available in unextended GLES)
- drop some superfluous braces (Erik)
v4: - move DS checks to separate commit (Erik)
v5: - split patch to move preparations that don't change
functionality to preceeding patches
- reduce the amount of error checking (Erik)
- only check readback for formats that can actually be used as
render targets
- remove some temporary variables (Erik)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Also limit the scope of some variables.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
The name for the internal texture properies flags VIRGL_BIND_NEED-SWIZZLE
and VIRGL_BIND_CAN_TEXTURE_STORAGE is misleading, and the latter flag was
even mis-using the binding member of the texture format structure.
Rename these flags to make it clear that these are not binding flags and
correctly use the 'flags' member for CAN_TEXTURE_STORAGE. In addition, drop
adding the NEED_SWIZZLE flag to the binding in the alpha texture emulation.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
To properly use compute shaders in the guest when running on a GL ES host
it is better to advertice GLSL level 430, because otherwise compute shaders
that don't explicitely add the extension ARB_compute_shaders to the shader
will not compile.
Fixes#99
v2: Add comment about why we want to advertise this feature level (Gurchetan)
v3: Don't bypass checks for level 400
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
PIPE_BIND_CUSTOM is used for query buffers and fences by the guest.
We can safely replace VREND_RESOURCE_STORAGE_SYSTEM by
VREND_RESOURCE_STORAGE_IOVEC.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This allows a resource to use the guest pages as its storage when
the iovec is attached.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Check queries from within vrend_renderer_check_fences, after
glClientWaitSync but before write_fence. This makes sure query
results are available after the fence is waited for.
In other words, given this sequence of commands
BEGIN_QUERY > DRAW_VBO > END_QUERY > GET_QUERY_RESULT > FENCE
Waiting on the fence makes sure the query result becomes available
to the guest.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Handle these two command sequences,
VIRGL_CCMD_BEGIN_QUERY
VIRGL_CCMD_END_QUERY
VIRGL_CCMD_GET_QUERY_RESULT
VIRGL_CCMD_GET_QUERY_RESULT
or
VIRGL_CCMD_BEGIN_QUERY
VIRGL_CCMD_END_QUERY
VIRGL_CCMD_GET_QUERY_RESULT
(before the query result is available)
VIRGL_CCMD_BEGIN_QUERY
VIRGL_CCMD_END_QUERY
VIRGL_CCMD_GET_QUERY_RESULT
more carefully.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This patch uses GL_EXT_framebuffer_fetch_non_coherent (preferred)
or GL_EXT_framebuffer_fetch to emulate the logiops in the fragement
shader. If neither of these extension are available then only
GL_COPY, GL_COPY_INVERTED, GL_CLEAR, and GL_SET are emulated.
Fixes piglit gl-1.0-logicop on GLES hosts.
v2: Use non_coherent access when possible
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
That helps the code checker to see whether all switch cases are used.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Pass a mask of the non-array generic inputs that the next shader expects
is passed to the shader that is currently converted. If, after emitting
all generic outputs, some are missing, then these are also generated.
Limitations: This doesn't take care of input arrays that may not be emitted
as outputs, but since this problem seems to be only related to IO variables
that are implicitely declared this is not a problem.
Fixes piglit: glsl-routing
v2: rebase and update names to new naming
v3: Declare TCS outputs as arrays as required
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Tested-by: Elie Tournier <elie.tournier@collabora.com> (v1)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
If a texture is bound in a GL context the texture object will not be
destroyed by the driver even if the program using the texture freed it.
At least with mesa Gallium drivers the effect that these texture objects
also hold references to sampler views that might have been created and
destroyed in sub-contexts. Now, when a new texture is allocated and
bound to the corresponding texture target, the old texture will finally
be destroyed at this point, and by doing so it will try to access these
already destroyed sampler views, resulting in a use after free.
Consequently, unbind the texture in context 0 after it has been allocated,
so that the driver doesn't hold an additional reference to it that inhibits
its destruction of the texture when the guest program requests this.
v2: Make sure that the texture is also unbound when the allocation function
bails out with an error (Chia-I Wu)
Closes#98
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
The formats L8A8_UNORM and L16A16_UNORM are usually not supported, but
L8A8_SRGB might, and this results in problems because the host might
ask for a texture view of a L8A8_SRGB by using L8A8_UNORM, and this will
then fail. Removing these formats lets mesa pick suitable replacements on
the guest side. This helps with "The Talos Principle".
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Multi-sample arrays are not part og GLSL 310 ES, so they need to
be explicitly enabled.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
On one hand render_condition_enable might also be set when the
cond_render_gl_mode is empty, so no conditional rendering is
actually done and the copy path can be used. On the other hand,
on GLES rectangular textures are emulated, so the texture target
needs to be corrected, and for some reason different base formats
were required which doesn't make sense.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This is not supported and will issue a warning.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The GL fallback also must be used on GLES if the target surface is
a multi-sample surface or if the region blitted from a multi-sample
surface is not equal to the target region.
This patch results in piglit reporing regressions with
multisample-blit * depth
on a GLES host. However, these piglits make bits to MS surfaces which
is not supported by glBlitFramebuffer on GLES. The old code took that
path, and mesa would actually report an error when compiled with -DDEBUG
butthe piglits still reported success. Unfortunately, resolving the MS
propperly is quite a challange for depth textures, and requires information
that is not available in the blit info (zNear and zFar), so getting these
piglits to act correcly on GLES hosts seems quite impossible.
v2: Also use fallback on GLES if the source is multi-sample and the formats
of source and dest are not equal
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This will be needed because on GLES blits to a MS surface need to
use the GL fallback path.
Signed-off-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
These resources are emulated by using normal samplers.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
With that the srgb <-> linear handling can be simplified.
v2: Don't use texture views when TextureStorage can't be used to create
the texture, because then it is not immutable.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
later we need this function in the blitter
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
v2: Don't use texture views if the texture of the format can't be
allocated by using TextureStorage, since then it is not immutable
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
On GL 4.4 (and GLES with EXT_sRGB_write_control) blits will decode and
encode sRGB when GL_FRAMEBUFFER_SRGB is supported, and they don't decode
when it isn't supported. Enabling or disabling this is signalled from
the guest by using the according surfaces.
In summary, there is no need to use the GL fallback for a blit decoding
sRGB, because this can also be handled in a normal blit.
Fixes piglits on a GL host:
blit texture srgb_to_linear downsample enabled render
blit renderbuffer srgb_to_linear msaa enabled render
blit renderbuffer srgb_to_linear msaa enabled clear
blit renderbuffer srgb_to_linear downsample enabled clear
v2: Fix typo in commit message (Erik)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The GL_EXT_color_buffer_float exptension spec defines that glReadPixels
can be done with the combination of GL_RGBA and GL_FLOAT, which matches
what OpenGL ES 3.2 allows. So let's enable the readback-format in this
case.
Thanks to Gert Wollny for pointing this out.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Fixes: 368d950e8f
shader: emulate indirect ssbo write access on GLES using a switch statement
Thanks Erik for catching this.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
This buffer was introduced, but never used. Fixes a warning.
While we're at it, fixup the lack of EOL at EOF.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 75f2191 ("shader: Don't emit gl_FragCoord layout qualifier on
GLES and emulate pixel_center_integer")
Reviewed-By: <gert.wollny@collabora.com>
On D-GL a program may contain a TE shader but no TC shader. On GLES either
both or none of TES and TCS need to be available. So if the guest sends a
shader program without a TCS, inject a passthrough shader using the
patch parameters given in the GL code.
Closes#84
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
These functions will later also be used to create a TC passthrough shader
on GLES of a GL guest doesn't send one.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
With the exception of VS inputs and FS outputs the use of components
and location layout qualifiers also requires the extension
ARB_separate_shader_objects on GL (or GLSL 4.10).
Fixes: 08b3ddded8
vrend: Signal the guest that indirect arrays are available
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Allow external users to intercept resource creation based on
scanout bind flag.
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
v2: Make use of the helper function introduced before (Gurchetan)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Fixes piglit on GLES host:
arb_shader_storage_buffer_object@execution@indirect
v2: use helper function to emit code (Gurchetan)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Resolve the indirect access by using a switch statement instead of the
indirect addressing.
Fixes: arb_arrays_of_arrays/execution/image_store/
basic-imageStore-*-const-uniform-index
Signed-off-By: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
With the new optimizations applied to the i965 driver it becomes
a requirement to specify buffers as coherent if the access is declared
as such. This fixes a regression with
dEQP-GLES31.functional.synchronization.in_invocation.ssbo_alias_overwrite
Closes#93
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Given a source and destination image, consider the following sequence
of events:
1) glTexImage with src
2) virgl_resource_copy_region copies src to dst using GL
3) mesa attempts to readback dst, which returns the correct
result with vrend_transfer_send_getteximage only
Commands that reproduce this scenario on i965/qemu:
./bin/arb_copy_image-formats -auto
./bin/fbo-generatemipmap-formats GL_ARB_texture_float -auto
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>