Commit Graph

413 Commits

Author SHA1 Message Date
Pavel Asyutchenko 2b3a020928 llvmpipe: protect from doing FB fetch of missing buffers
Signed-off-by: Pavel Asyutchenko <sventeam@yandex.ru>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13252>
2021-11-17 04:08:54 +00:00
Pavel Asyutchenko 3ebd6498c4 llvmpipe: fix gl_FragColor and gl_LastFragData[0] combination
Signed-off-by: Pavel Asyutchenko <sventeam@yandex.ru>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13252>
2021-11-17 04:08:54 +00:00
Pavel Asyutchenko b1de61dd38 llvmpipe: fix wrong assumption on FB fetch shader opacity
In certain cases variant->opaque could be set to true, which
reset command list for tiles fully covered by a triangle
with this shader. This is obviously wrong in presence of
framebuffer fetch.

Signed-off-by: Pavel Asyutchenko <sventeam@yandex.ru>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13252>
2021-11-17 04:08:54 +00:00
Dave Airlie 29f4931b52 llvmpipe: fix 4-bit output scaling.
This is overkill, but hey 4-bits per channel is hardly something to
care about.

(Suggestions welcome for a better version).

Fixes:
dEQP-GLES2.functional.fbo.render.*rgba4*

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12001>
2021-10-06 04:35:25 +00:00
Pavel Asyutchenko 7ffb152276 llvmpipe: fix crash when doing FB fetch + gl_FragDepth write in one shader
Reproducible by piglit test from this MR:
https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/576

Signed-off-by: Pavel Asyutchenko <sventeam@yandex.ru>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12705>
2021-10-05 20:45:38 +00:00
Dave Airlie 690cc3bb80 llvmpipe: overhaul fs/cs variant keys to be simpler.
These currently always had one sampler state embedded, but got messy
when images was 1 and samplers was 0.

This should fix some undefined reads seen

Fixes: e639e311a1 ("llvmpipe/cs: overhaul cs variant key state.")
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13012>
2021-09-30 04:55:12 +10:00
Roland Scheidegger 49337ec410 gallium: add rasterizer depth_clamp enable bit
This is required for d3d10+, which has depth_clamp always enabled
regardless of depth_clip (in contrast to OpenGL, where enabling
depth_clamp disables depth_clip). There doesn't seem to be a GL
extension for it, but it will be used for lavapipe to implement
VK_EXT_depth_clip_enable.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12260>
2021-09-09 18:29:26 +00:00
Emma Anholt a2dfb49961 llvmpipe: memcpy user_buffers at set_constant_buffer time.
The data in the user buffer is only valid for a short period of time, and
we could use-after-free it if rendering hadn't been flushed by shader
deletion time.

Fixes: #5254
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12724>
2021-09-07 19:16:32 +00:00
Dave Airlie 291d0795a3 llvmpipe/fs: fix multisample depth/stencil fs writes.
The state wasn't storing the shader depth/stencil outputs
per-sample, so only the last sample emitted was being used
for the late depth test and stencil ref.

Noticed while trying to fix some vulkan depth stencil resolve
issues

Fixes: a0195240c4 ("llvmpipe: handle multisample early depth test/late depth write")

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12504>
2021-08-31 23:26:45 +00:00
Erik Faye-Lund 6e05f68924 llvmpipe: rip out cylindrical wrap support
Acked-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12505>
2021-08-25 19:37:16 +00:00
Erik Faye-Lund 7b0bda2e55 gallium/tgsi: rip out cylindrical wrap support
We never enable this feature, so let's rip it out completely.

Acked-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12505>
2021-08-25 19:37:16 +00:00
Roland Scheidegger ba7fd5b561 llvmpipe/linear: don't try to use tgsi analysis for nir shaders
Even though it's probably harmless, we shouldn't try it, so just skip it,
eventually need to hook in nir analysis there.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11969>
2021-07-21 22:40:18 +02:00
Jose Fonseca 5a1d3bcf26 llvmpipe: Add a linear rasterizer optimized for 2D rendering.
This change adds:

- an alternative rasterizer, which rasterizes bins in a left->right &
  top->bottom linear fashion;

- triangle -> rectangle detection;

- 1:1 blit detection;

- a special TGSI -> LLVM IR code generation that uses 8-bit SSE integers
  in AoS fashion (as opposed to 32bits floats.)

Altogether these changes yield a 2x to 3x performance improvement for 2D
workloads.  It was designed to render Windows 7 Aero and other Windows
built-in 3D applications (like Windows Media Player, Internet Explorer
11, UWP applications) with minimum CPU utilization, but it should be
generally applicable to other 2D-on-3D applications, like desktop
compositors, HTML browsers, 3D based UI toolkits, etc.

This was mostly the brainchild of Keith Whitwell back in 2010.  I wrote
TGSI -> AoS translation.  And many others added bug-fixes and
enhancements over the years: Roland Scheidegger, Brian Paul, and James
Benton.

Known issues:

- piglit spec@!opengl 1.1@quad-invariance will warn that "left and right
half should match" due to rounding error difference

- These optimized paths to kick in is that depth-buffer must not be
used, so some applications which want to benefit from these improvements
might need to be modified to ensure they use painter's algorithm instead
of depth-buffers.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Keith Whitwell <keithw@vmware.com>

v2: Incorporate Dave Airlie feedback: cleanup LP_DEBUG_xx; shrink 3+
empty lines.
v3: silence unused var warning, adapt to new upstream code (point setup)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11969>
2021-07-21 22:40:18 +02:00
Dave Airlie 9cfcf3783b llvmpipe: add support for max aniso query.
This just joins the sampler code to the llvmpipe shader stages.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8804>
2021-07-21 10:19:51 +10:00
Dave Airlie a672f9ebf0 llvmpipe: add filter table shader accessor
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8804>
2021-07-21 10:19:51 +10:00
Mike Blumenkrantz 621b8788bb llvmpipe: only dump tgsi shaders if they're actually tgsi shaders
this crashes otherwise

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11016>
2021-05-26 23:44:10 +00:00
Dave Airlie 172c719baf llvmpipe: fix non-multisampled rendering to multisampled framebuffer
Don't depend moving between samples on key->multisample

Big CI wins
Reported-by: Erik Faye-Lund <kusmabite@gmail.com>

Reviewed-by: Emma Anholt <emma@anholt.net>
Fixes: 210d714f46 ("llvmpipe: handle multisample color stores.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10780>
2021-05-15 06:05:00 +10:00
Jesse Natalie b678115480 llvmpipe: Fix MSVC warning C4334 (32bit shift cast to 64bit)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Cc: mesa-stable@lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10331>
2021-04-20 00:28:35 +00:00
Dave Airlie 60bdf61d68 llvmpipe: always take depth clamping from state tracker
Don't be smarter than state tracker here, of d3d10 wants to do
something the state tracker should hard code that. Since lavapipe
wants to use clip_halfz and depth clipping independently.

This fixes some issues blitting Z that zink was seeing

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10068>
2021-04-08 05:18:16 +10:00
Dave Airlie f96f016c22 llvmpipe: when depth clamp is disable clamp to 0.0/1.0
When depth clamp is disabled the viewport values aren't meaningful,
however the value is about to be converted to a unorm so needs
to still be clamped to 0/1.

This might not be the best place for this, maybe it should be in
the write swizzled code.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10068>
2021-04-08 05:17:53 +10:00
Dave Airlie 6adbf6c86c llvmpipe: add reduction mode support
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9423>
2021-03-12 16:02:25 +10:00
Dave Airlie e81cd37363 llvmpipe: add view index support to rasterizer
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9399>
2021-03-12 05:05:51 +00:00
Vinson Lee 816d28f4a1 llvmpipe: Fix typos.
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8542>
2021-02-25 04:04:28 +00:00
Dave Airlie c10b785490 llvmpipe: fix use after free with fs variant cleanup
item->base will be freed for the NULL reference write
so just use a temporary to avoid it.

This was found with asan and lavapipe:
dEQP-VK.api.copy_and_blit.core.blit_image*

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8912>
2021-02-11 08:34:35 +10:00
Marek Olšák 72ff66c3d7 gallium: add unbind_num_trailing_slots to set_shader_images
Instead of calling this function again to unbind trailing slots,
extend it to do it when images are being set. This reduces CPU overhead.
Only st/mesa benefits.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
2021-01-27 23:53:34 +00:00
Marek Olšák a51d4b10f1 gallium: add take_ownership param into set_constant_buffer to eliminate atomics
We often do this:
    pipe->set_constant_buffer(pipe, shader, slot, &cb);
    pipe_resource_reference(&cb->buffer, NULL);

That results in atomic increment in set_constant_buffer followed by
atomic decrement after set_constant_buffer. This new interface
eliminates those atomics.

For the case above, this should be used instead:
    pipe->set_constant_buffer(pipe, shader, slot, true, &cb);
    cb->buffer = NULL; // if cb is not a local variable, else do nothing

AMD Zen benefits from this. The perf improvement is ~3% for Viewperf13/Catia.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
2021-01-27 23:53:34 +00:00
Marek Olšák 912ba743b5 gallium: inline pipe_depth_state to decrease DSA state size by 4 bytes
Depth and alpha states are now packed together, interleaved somewhat.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7940>
2020-12-22 12:01:38 +00:00
Marek Olšák d0534cea7f gallium: inline pipe_alpha_state to enable better DSA bitfield packing
pipe_alpha_state and pipe_depth_state will be packed together
because they have only a few bitfields each. This will eventually
remove 4 bytes of padding in pipe_depth_stencil_alpha_state.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7940>
2020-12-22 12:01:38 +00:00
Dave Airlie 47701d47e7 llvmpipe: respect the sample mask in non-multisample flag
This partly revert
50987644 llvmpipe: don't use sample mask with 0 samples

since Vulkan wants this behaviour.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7435>
2020-11-04 01:53:29 +00:00
Dave Airlie dc6313b098 llvmpipe/fs: multisample depth/stencil bad ir generated
Need to update the z value after updating the pos at pixel
center, and later reupdate it again, so we can avoid some
LLVM IR values not being dominant issues.

Fixes:
dEQP-VK.renderpass.suballocation.multisample.s8_uint.samples_4

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6381>
2020-08-31 13:20:11 +10:00
Dave Airlie 2d6385715d llvmpipe: blend has effects even if no colorbuffers.
ARB_framebuffer_no_attachments + multisampling means blend
can have an effect even outside of colorbufs

Fixes:
dEQP-VK.pipeline.multisample.alpha_to_coverage_no_color_attachment.samples_4.alpha_opaque

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6381>
2020-08-31 13:20:11 +10:00
Dave Airlie 99330e50c9 llvmpipe: add reference counting to fragment shaders.
Currently llvmpipe calls finish on the context when a shader
variant has to be destroyed just in case the variant is currently
in use by the setup engine.

Fix this by reference counting the shaders, and reference counting
the shader variants.

Whenever a shader is used in the rasteriser backend, it is added
to a reference list and removed when the rasterizer is finished with it.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6341>
2020-08-31 10:02:22 +10:00
Dave Airlie 41c7bb6ec0 llvmpipe: add framebuffer fetching support (v1.1)
v1.1:
Merge two if blocks (Roland)

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5914>
2020-07-20 15:14:09 +10:00
Dave Airlie 87e27543fe llvmpipe: fix stencil only formats.
Currently the test crashes with LLVM errors
Stored value type does not match pointer operand type!
  store <8 x i32> %s_dst, <8 x i8>* %261

Change the stored type for 8-bit stencil formats.

Fixes:
GTF-GL45.gtf44.GL31Tests.texture_stencil8.texture_stencil8_gl44

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5926>
2020-07-17 05:09:34 +10:00
Dave Airlie 3bb3e8940c llvmpipe: add ARB_post_depth_coverage support.
This doesn't pass thie piglits because currently they are broken
for case where GL upgrades 2 samples to 4

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5767>
2020-07-08 07:19:25 +10:00
Dave Airlie f75c1e83e2 llvmpipe: pass number of images into image soa create
Just store this for now to use later with indexing

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3778>
2020-07-02 04:12:17 +00:00
Dave Airlie 30c5cbbcd2 llvmpipe: pass number of samplers into llvm sampler code.
This is to be used later for indirect texture access

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3778>
2020-07-02 04:12:16 +00:00
Dave Airlie f0d91c9af3 llvmpipe/fs: add caching support
Serialize and check if the object is in the cache, it there is
a cached object skip compilation code once we've constructed
the function interface.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5049>
2020-06-11 06:05:40 +10:00
Dave Airlie 7b7c02d161 gallivm: add support for a cache object
This plumbs the cache object into the gallivm API, nothing uses
it yet.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5049>
2020-06-11 06:05:40 +10:00
Dave Airlie d815d74f75 llvmpipe/draw: drop variant number from function names.
When we use an object cache for the MCJIT we can have identical
cache entries from the same shader variant in different shaders,
but the JIT objcache uses the function name to relink things,
so it has to be consistent. Just drop the variants from the
function names.

Note the modules still have the variant info.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5049>
2020-06-11 06:05:40 +10:00
Dave Airlie ee90339cfb llvmpipe: add gl_SampleMaskIn support.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5050>
2020-05-19 10:26:46 +10:00
Dave Airlie 0dac24790e llvmpipe/fs: hook up the interpolation APIs.
This hooks the nir code to the interp code.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5050>
2020-05-19 10:26:46 +10:00
Dave Airlie c9690b7471 llvmpipe: use per-sample position not sample id for interp
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5050>
2020-05-19 10:26:46 +10:00
Dave Airlie 5098764483 llvmpipe: don't use sample mask with 0 samples
piglit:
spec/arb_sample_shading/builtin-gl-sample-mask 0
spec/arb_sample_shading/builtin-gl-sample-mask-simple 0
CTS:
KHR-GL45.sample_variables.mask.rgba8.samples_0.mask_zero

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5050>
2020-05-19 10:26:46 +10:00
Dave Airlie 89d4b6b5c8 llvmpipe: make sample position a global array.
I messed this up and LLVM asserts on it.

Use the gallivm struct wrappers to make it clearer.

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2913

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Tested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4933>
2020-05-07 18:38:51 +00:00
Dave Airlie dab8803af4 llvmpipe: enable ARB_sample_shading
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
2020-05-06 06:20:38 +00:00
Dave Airlie 8a83db4204 llvmpipe: add min samples support to the fragment shader.
This isn't enabled yet until the state gets hooked up

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
2020-05-06 06:20:38 +00:00
Dave Airlie c638a59fa8 llvmpipe: disable opaque variant for multisample
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
2020-05-06 06:20:38 +00:00
Dave Airlie c5021ebb15 llvmpipe: fix multisample occlusion queries.
This needs to check the per-sample mask inside the loop if
multisample is enabled.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
2020-05-06 06:20:38 +00:00
Dave Airlie 335938cffd llvmpipe: move color storing earlier in frag shader
Move the color storage before the late Z test as for sample
shading it needs to be inside a loop with the fragment shader.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
2020-05-06 06:20:38 +00:00