This crashed for me all the time with nir_to_tgsi triggering compile
failures. The glsl_strings get freed at shader destroy time, no need
to do so here.
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Refactor only. There are a lot of variables named like *_id/*_index
already.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Refactor only. There are a lot of variables named like *_id/*_index
already.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Let the value found in the properties takes preference.
This fixes all compilation and link errors with
KHR-GL43.cull_distance.functional
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
To make the TGSI-GLSL conversion easier to track, keep the original TGSI
text in place when it is to be logged, and print it right before the shader
conversion.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Commit 603699f1 ("vrend: Cleanup and fix bug in next_sampler_id
tracking") fixed a rendering issue in Factorio but inadvertently changed
the indexing behavior for shadow samplers in some related code cleaning.
shadow_samp_*_locs arrays are currently indexed according to the bit
position of a sampler in samplers_used_mask and shadow_samp_mask, so
sampler_index must be incremented for each sampler, not just for each
shadow sampler.
Fixes: 603699f1 ("vrend: Cleanup and fix bug in next_sampler_id tracking")
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
A debug message is emitted whenever sampler states are applied and a
NULL state pointer is encountered. NULL pointers indicate that the
default state should be used instead, so there's no need to spam with
error messages approx. 1+ times per draw-call.
commit 405a50d ("vrend: cleanup vrend_bind_sampler_states") adds a more
useful debug message at sampler state bind-time when handle is non-zero
and corresponding state object cannot be located.
Fixes: 32c733f ("src/: replace all instances of "fprintf to stderr" with "vrend_printf"")
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Discovered while investigating broken floor tile rendering in Factorio
(game). Skipping increment of next_sampler_id, regardless of dirty
status, results in collision with caller's use of next_sampler_id for
additional samplers.
Closes: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/227
Fixes: c08c8419 ("vrend: use helper pointers in draw_bind_samplers_shader")
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Cleaner to modify ctx->sub->sampler_views_dirty directly.
Added error message for failed sampler state binds.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
refactor vrend_shader_info use to constant and reduce some variable
scope.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Up until now sme of the info stored in sinfo was changed
based on the shader key, and since this info is used for
all shader variants when evaluating the key for shaders
to be linked, this may result in the wrong shader
variant being picked up.
Instead track the shader info that can be changed like this
in the shader variant itself.
Closes: #239
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Dave Airlie <airlied@redhat.com>
Fixes e5fabecbe0
vrend: pass texture levels per shader on GLES as uniform
v2: - only emit texlod uniform when textureQueryLevels is called
- initialize uniform location to -1 if the mask shows that
the texture lod levels arenot needed and ony test this when
uploading the data
(all suggested in a way by Chia-I Wu)
Closes: #237
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Fixes a missed internalformat fixup when glTextureView() is used to create
vrend_surfaces for resources backed by shared EGL images without an
alpha channel (e.g. RGBX, BGRX). Such resources are registered in host
Mesa with internalformat GL_RGB8, but virglrenderer prefers to create
32bpp textures and do it's own swizzling.
fixes: commit ebb2cf3 "vrend: convert linear color to srgb for 24bpp
imported EGL resources".
Signed-off-by: Ryan Neph <ryanneph@google.com>
Although anisotropic filtering uses a float value, most hw doesn't
care below integer levels, so just transmit 1-16 for the sampler value
not the full float.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Resources imported from dma-bufs as EGL images are given internal format
GL_RGB8 (24bpp) by host mesa. When placing srgb texture views on such
resources, the appropriate view format would be GL_SRGB8, but this is
not color-renderable for GL or GLES and results in an incomplete
framebuffer. Instead, GL_RGB8 must be used as the attachment format and
linear->srgb colorspace conversions must be applied manually in the frag
shader and for calls to glClearColor() involving these surfaces.
This resolves a
dEQP-EGL.functional.wide_color.window_888_colorspace_srgb test failure
for GBM-enabled hosts with newer host mesa, which imports
B8G8R8X8_UNORM and R8G8B8X8_UNORM as 24bpp instead of the more
compatible 32bpp.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: John Bates <jbates@chromium.org>
For fragment ARB programs, the fog co-ordinate input
can be requested independently of any other part of the
graphics pipeline. Through the use of an OPTION declaration.
This can lead to a case where a fragment shader expects
a fog co-ordinate input, but it is not being supplied
by the preceding shader stage.
This patch will fix it by forcing it to 0 when it detects
the case, which should neutralize the fog color.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Compute shader don't have in- or outputs, so don't try to
sync the interfaces with the shaders that are still bound.
This fixes a state leak where non-compute shaders are still
bound when a compute shader is compiled.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Lepton Wu <lepton@chromium.org>
As suggested by Lepton
Fixes 57a4e9498a
vrend: get rid of glShaderStorageBlockBinding
Closes: #229
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Lepton Wu <lepton@chromium.org>
It indicates that fences should be retired directly from the
sync thread when enabled.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Once we retire fences directly in the sync thread, we will also need
to check queries in the same loop as virgl_renderer_poll() will no
longer be called.
In order to do that safely, we need to lock around operations on
the query waiting list. We also need to keep track of the current
context for the sync thread given we need to update it before
checking query status.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Since GLES doesn't support QueryTextureLevels in shaders we have
to collect this info and pass it as uniform to the shader.
v2: use pipe_shader_to_prefix
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Seperate more elements into the shader stages that they are used in
and evaluate them only for the stage they are relevant for.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
There is no reason why this value should be obtained using a return
parameter. Also fix the version to return zero when the version string
doesn't follow the standard.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Mesa clamps the number of cbufs to eight, so we can use uint8_t bitmask for
cbufs states. Be save for the future by only reporting support for
at most eight cbufs.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Compress the structure so that it fits into a 64 bit value.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
In addition combine values into a bitfield so that the compiler can use a
64 bit move instead of individual moves.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Keeping all the information in one place might come in handy when we
want to further refactor this. On the way also compress the structure.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Use a bitfield to declare vrend_interp_info and make it a fixed size array.
One one hand this avoids all the hassles with allocating and freeing memory,
and it will make it possible to shrink the size of the data that is passed
from the sinfo to the shader key.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
- don't write zeros, the memory is initialized to zero anyway
- reorder evaluation to check whether it is a FS only once.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
The property doesn't change. so it doesn't make sense to set it in the
shader key.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Caught by fuzzer. surf[0]->texture cannot be assumed to be a valid
pointer.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
On GLES it is not supported, and on GL it seems to be irrelevant,
because the guest already handles this.
Update the test expectation accordingly.
Fixes#201
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
We use GL_RGBA internal format for RGBX texture while an imported RGBX
texture uses GL_RGB8 as internal format since
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5034
On GLES host, glBlitFramebuffer doesn't work in such case because the
internal format doesn't match. Fall back to GL to fix it.
Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Lepton Wu <lepton@chromium.org>
These warnings were detected with clang version 12.0.0.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
On GLES hosts, BGR* resources are manually swizzled to RGB* internal
format on creation and swizzled back to BGR* format on readback.
For small transfers, iovec data is directly passed to the host driver
without staging in a temp buffer first. When swizzling for BGR*
resources, this modifies the persistend iovec buffer when it should
remain in the user-provided format. So we force temp buffers for all
iovec transfers on BGR* resources on GLES hosts to fix this.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Lepton Wu <lepton@chromium.org>
This fixes the regression introduced with commit
45eb512a43e257427617699e3849ca93434c1717c and
62cc6ed6e5.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
vrend_renderer_pipe_resource_set_type() called for
VIRGL_RESOURCE_FD_DMABUF resources fail during virgl to GBM format
conversion due to an uninitialized variable.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
BGRX resources backed by EGL images are given GL_RGB8 internal format
on creation outside of virglrenderer, so we must accomodate when
creating a texture view.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>