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>