On GLES B8G8R8A8_SRGB is not available and B8G8R8A8_UNORM can not be
created as immutable. In order to have versions of these formats that
can be created immutable on GLES provide the formats R8G8B8A8_SRGB and
_UNORM with swizzling to BGRA that can then be used instead of the BGRA
formats. Since this may break things these swizzled versions will later
be only enabled when the guest requests them.
v2: Check the base swizzled BGRA format only on GL
v3: Correct type in method name (Gurchetan)
v4: Add PREFER_EMULATED_BRGA to according format binding flags (Gurchetan)
v5: Add comment about formats nou to be used in the guest (Gurchetan)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This is useful for logging a continuation on the same line.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Function handles a single instance - drop the S from the name.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
The top level emit_ios() already zeros it, so we can remove the
duplicate (and misleading) one in emit_ios_vs().
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Use the helper instead of open-coding it.
v2: use callback (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Use the helper instead of open-coding it.
v2: use callback (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Factor out the 'generic' output handling out of emit_ios_geom() into a
helper. We'll use that across the board with later commits.
v2: use callback (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Move the GS stream output handling in a separate loop.
Will allow us to de-duplicate the generic output handling across the
board.
v2: Drop prog_type check (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Bundle all the front/back color handling to a single block. It makes
the code slightly easier to follow.
Plus it will allow us to factor out some code with a later commit.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
v2: keep prefix/auxprefix declarations on separate lines (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
v2: use "" to initialize the fixed size char array (Gert)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
When there is no change to UBOs of a shader stage, we still need to
increment next_ubo_id to match bind_ubo_locs. This was regressed by
commit 2192c92 (renderer: only update dirty constbufs).
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Do not use in/out parameters for sampler_id and ubo_id. They are
easier to get wrong.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
ubo_used_mask is similar to samplers_used_mask but for UBOs.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Allow external users to intercept resource creation based on
shared bind flag.
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Introduce a SHADER_REQ_SAMPLER_BUF bit and use it with shader_req_bits.
v2: use bitwise or for the SHADER_REQ_* fields, use next bit in the list
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> (v1)
We do that across the board, plus it makes the code slightly more
comprehensible.
v2: update the is_shad hunk as well.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> (v1)
The function emit_sampler_decl() considers that GLES does not have 1D
textures, but it ignores the fact that we can have a range passed into
the function.
This workaround predates the correct fix in vrend_shader_samplertypeconv()
which returns a "2D" literal as needed.
Drop this partial workaround.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Analogous to previous commit there's a single user that cares about it.
Let that one use amplertype_is_shadow() and drop the function argument.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Only a single user cared about the is_shadow information.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
As pointed out by Erik, this is a rogue-client behaviour which we
generally just ignore.
Suggested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
GL 4.2 supports depth layouts that make it possible to optimize by
enabling early depth tests and still being able to write a new
z value in the fragment shader under specific circumstances.
Fixes#106
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The fuzzer series added a few warnings that need to be silenced.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: David Riley <davidriley@chromium.org>
Destroy resources even if there is a pipe_reference.
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Transfer strides are either set internally or coming from
virgl_renderer_transfer_{write,read}_iov. As far as I can tell,
Mesa always passes sane values. We also expect sane values in
places like vrend_renderer_transfer_write_iov,
vrend_transfer_send_readpixels, and vrend_transfer_send_getteximage
already. Let's reject bad strides.
This fixes, for example, transfers to 1D array (thus box->height is
1) with non-default stride.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
The origin change is already handled within Gallium, so it is only
necessary to deal with the Z range property.
v2: don't mark viewport as dirty when halfz is changed, this is already
handled by Gallium (Gurchetan)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
sed -i "s/[[:space:]]*$//g" */*.[ch]
Note: there's a handful more in src/gallium, although that's left as-is
to minimise merge conflicts as we have to port things from Mesa.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
We're overall pretty consistent, with a couple of exceptions addressed
in this patch.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Results in overall less code, making it easier to read.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Use the symbolic macros instead of the actual value.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Just like all the other non-static vrend_shader functions.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Ensure we can't create a texture resource with zero width, to
guarantee that we get a non-zero stride, since either:
1. A non-zero stride was specified in the transfer request, or
2. We will calculate a stride based on texture width which we guarantee
is not zero
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This is required to be able to properly handle transfers with
data layouts that are different from the resource layout.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This commit improves bound checking by more accurately calculating
the expected transfer size. This improvement is achieved in two ways:
1. Using the image level (layer_)stride when the (layer_)stride is 0,
which matches the interpretation we use for performing the actual
read/write.
2. Calculating the transfer size by using the exact end offset in
the image, instead of using multiples of whole image rows.
The increased accuracy increases safety, and also allows us to support
some transfers with explicit strides that were previously rejected (see
added test).
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
There is no need to fail such transfers, in the same way we don't fail
when we are given a stride for targets without height, especially since
both stride and layer_stride have a valid (albeit possibly not very
useful) interpretation for all targets types.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
We no longer fall back here, as we've already tried glGetTexImage and
failed in the case where that's possible.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
These two snippets do the same, let's just place them in a helper and
call that instead.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Looks like this was never really used for anything useful. Let's just
get rid of it.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
For instance the GALLIUM_HUD requires this, also when the host doesn't
advertise support for input arrays.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>