Commit Graph

57 Commits

Author SHA1 Message Date
Yonggang Luo a9e2c699aa util/c11: Update function u_thread_create to be c11 conformance
Do not assume thrd_t to be a pointer or integer, as the C11 standard tells us:
  thrd_t: implementation-defined complete object type identifying a thread
At https://en.cppreference.com/w/c/thread
So we always return the thread creation return code instead of thrd_t value, and judge the return
code properly.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
2022-06-15 17:37:17 +00:00
Marek Olšák 69e3f35435 gallium/ddebug: implement pipe_vertex_state callbacks
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15964>
2022-04-20 22:15:43 +00:00
Dave Airlie 127bcbed18 gallivm/st/lvp: add flags arg to get_query_result_resource api.
Currently this just has wait, but in order to get the right answer
for vulkan partial, lavapipe/llvmpipe need to pass a partial flag
through here in the future.

This just changes the API so that's possible.

v2: use an enum (zmike)

Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15009>
2022-02-15 10:12:01 +10:00
Qiang Yu 485ceb5c51 gallium: add multi_sample parameter to get_sparse_texture_virtual_page_size
Instead of using actual sample count as parameter, we only use a bool
to indicate if the target is multi sample. This is because we don't
know the sample count when glGetInternalformativ() case.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14362>
2022-01-18 16:10:36 +08:00
Qiang Yu 5dd9cb1069 gallium/dd_debug: add get_sparse_texture_virtual_page_size
Otherwise GALLIUM_DDEBUG=always crash when sparse texture is used.

Fixes: eed8421bba ("gallium: add screen get_sparse_texture_virtual_page_size callback")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Sigend-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14362>
2022-01-18 16:10:35 +08:00
Emma Anholt 17332ceb0f mesa/st: Add an optional GLSL link fail msg to finalize_nir.
GLES2 drivers are allowed to reject some GLSL constructs, like dynamic
loop bounds (which neither i915g nor vc4 can fully support), but gallium
hasn't had any way to trigger a link failure.  Add a return msg to the
finalize_nir hook, which is called at the end of GLSL linking, and use
that.  This means that some other callers of finalize need to do something
with the msg, and we (for now) just throw it away.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12218>
2021-09-06 18:09:25 +00:00
Marek Olšák 10a46226b1 gallium: remove vertices_per_patch, add pipe_context::set_patch_vertices
We would like draw-only display lists to have immutable draw info and
this is the only GL non-draw state in pipe_draw_info (not counting
view_mask).

It also allows removing some code from draw_vbo for tessellation.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12351>
2021-08-21 00:08:11 +00:00
Marek Olšák bb89cf4bf3 gallium: add take_ownership into set_sampler_views to skip reference counting
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12334>
2021-08-20 15:04:20 +00:00
Ian Romanick 5f2dbd45f2 gallium: Remove "optimize" parameter from pipe_screen::finalize_nir
As part of adding support for inline uniforms in Iris, I was going to
add a finalize_nir hook.  I went looking to see how other drivers use
the "optimize" parameter, and I discovered that *nobody* uses it at all.

v2: Fix typo in commit message.  Noticed by Mike.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12317>
2021-08-13 15:45:29 -07:00
Marek Olšák eb74f97769 gallium: split transfer_(un)map into buffer_(un)map and texture_(un)map
The u_resource_vtbl indirection is going to be removed.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10659>
2021-05-21 17:38:04 +00:00
Mike Blumenkrantz dae3113c3d gallium: split drawid out of pipe_draw_info and as a separate draw_vbo param
the only case in which this is nonzero is if a multidraw gets split by the frontend,
i.e., mesa core, and in all other cases it can be ignored. the value can also be ignored
for all indirect draws, though it seems many (most?) gallium drivers are not aware of this

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Mike Blumenkrantz 4566383ae4 gallium: move pipe_draw_info::index_bias to pipe_draw_start_count_bias
this moves index_bias into the multidraw struct, enabling draws where the value
changes to be merged; the draw_info struct member is renamed and moved to the end
of the struct for tc use

u_vbuf still has some checks to split draws if index_bias changes, maybe
this can be removed at some point?

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Mike Blumenkrantz 4fe6c85526 gallium: rename pipe_draw_start_count -> pipe_draw_start_count_bias
and add an index_bias member

no functional changes yet, just the rename and unused struct member

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10166>
2021-04-30 03:59:19 +00:00
Marek Olšák 27dcb46629 gallium: add take_ownership param into set_vertex_buffers to eliminate atomics
There are a few places (mainly u_threaded_context) that do:
   set_vertex_buffers(...);
   for (i = 0; i < count; i++)
      pipe_resource_reference(&buffers[i].resource.buffer, NULL);

set_vertex_buffers increments the reference counts while the loop
decrements them.

This commit eliminates those reference count changes by adding a parameter
into set_vertex_buffers that tells the callee to accept all buffers
without incrementing the reference counts.

AMD Zen benefits from this because it has slow atomics if they come from
different CCXs.

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:35 +00:00
Marek Olšák b688ea31fc gallium: add unbind_num_trailing_slots to set_sampler_views
Instead of calling this functions again to unbind trailing slots,
extend it to do it when binding. This reduces CPU overhead.

A lot of drivers ignore "start" and always unbind all slots after "count".
Such drivers don't need any changes here.

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:35 +00: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 0278d1fa32 gallium: add unbind_num_trailing_slots to set_vertex_buffers
Instead of calling this functions again to unbind trailing slots,
extend it to do it as part of the call that sets vertex buffers.
This reduces CPU overhead. Only st/mesa benefits from this.

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
X512 a534cd2827 aux/driver_ddebug: Normalize pid type from Haiku
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8323>
2021-01-09 20:51:27 -06:00
Marek Olšák b7f12a0452 gallium: pass pipe_stencil_ref by value (it has only 2 bytes)
This changes pipe_context::set_stencil_ref to pass the parameter by value.

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
Jesse Natalie 9ac8f8f490 gallium: Add optional pipe_context to flush_frontbuffer
It's hooked up in all the pipe wrapper drivers, and all the
frontends except a couple places in glx/xlib.

This enables a more efficient path for drivers which use
swrast's Present, but hardware rendering (e.g. d3d12, zink).

Reviewed-by: Dave Airlie <airlied@redhat.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8045>
2020-12-14 23:31:37 +00:00
Marek Olšák 1cd455b17b gallium: extend draw_vbo to support multi draws
Essentially rename multi_draw to draw_vbo and remove start and count
from pipe_draw_info.

This is only an interface change. It doesn't add multi draw support
anywhere.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
2020-11-18 01:41:25 +00:00
Marek Olšák abe8ef862f gallium: make pipe_draw_indirect_info * a draw_vbo parameter
This removes 8 bytes from pipe_draw_info (think u_threaded_context)
and a lot of info->indirect pointer indirections.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
2020-11-18 01:41:24 +00:00
Marek Olšák 1a717dca04 gallium: move count_from_stream_output into pipe_draw_indirect_info
This removes some overhead from tc_draw_vbo and increases the maximum number
of draws per batch from 153 to 192 in u_threaded_context.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
2020-11-18 01:41:24 +00:00
Dave Airlie e9724722a3 gallium: add a level parameter to resource parameter get
For lavapipe interface to llvmpipe there is a need to retrieve per-level
info, so this seems like the best interface to use for it.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6639>
2020-11-02 22:27:14 +00:00
Mike Blumenkrantz 1c8bcad81a gallium: add pipe cap for scissored clears and pass scissor state to clear() hook
this adds a new pipe cap that drivers can support which enables passing buffer
clears with scissor test enabled through to be handled by the driver instead
of having mesa draw a quad

also adjust all existing clear() hooks to have the new parameter

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4310>
2020-04-29 18:05:06 +00:00
Pierre-Eric Pelloux-Prayer 7f52bbb7c0 ddebug: add missing forward declaration
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4319>
2020-03-30 11:05:52 +00:00
Karol Herbst 6e035c01fb Revert "gallium: make handles of set_global_binding 64 bit"
This reverts commit e1ffb72a05
2020-03-10 22:41:26 +00:00
Karol Herbst e1ffb72a05 gallium: make handles of set_global_binding 64 bit
needed by CL

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4072>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4072>
2020-03-10 22:06:19 +00:00
Eric Anholt 882ca6dfb0 util: Move gallium's PIPE_FORMAT utils to /util/format/
To make PIPE_FORMATs usable from non-gallium parts of Mesa, I want to
move their helpers out of gallium.  Since u_format used
util_copy_rect(), I moved that in there, too.

I've put it in a separate directory in util/ because it's a big chunk
of related code, and it's not clear to me whether we might want it as
a separate library from libmesa_util at some point.

Closes: #1905
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
2019-11-14 10:47:20 -08:00
Timothy Arceri 7f106a2b5d util: rename list_empty() to list_is_empty()
This makes it clear that it's a boolean test and not an action
(eg. "empty the list").

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2019-10-28 11:24:38 +00:00
Marek Olšák fb04e5da97 gallium: add pipe_screen::finalize_nir
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2019-10-23 21:12:52 -04:00
Marek Olšák d307aa56f9 gallium: extend resource_get_param to be as capable as resource_get_handle
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2019-09-18 14:41:30 -04:00
Kenneth Graunke 0e6b573ae5 gallium/ddebug: Wrap resource_get_param if available
Fixes: 0346b70083 ("gallium/screen: Add pipe_screen::resource_get_param")
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-08-21 22:18:22 +00:00
Erik Faye-Lund 0091f62978 mesa: avoid warning on Windows
On Windows, p_atomic_inc_return returns an unsigned long long rather
than the type the pointer refers to, so let's make sure we cast the
result to the right type. Otherwise, we'll trigger a warning about
the wrong format-string for the type.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-08-15 20:23:49 +02:00
Ilia Mirkin 0e30c6b8a7 gallium: switch boolean -> bool at the interface definitions
This is a relatively minimal change to adjust all the gallium interfaces
to use bool instead of boolean. I tried to avoid making unrelated
changes inside of drivers to flip boolean -> bool to reduce the risk of
regressions (the compiler will much more easily allow "dirty" values
inside a char-based boolean than a C99 _Bool).

This has been build-tested on amd64 with:

Gallium drivers: nouveau r300 r600 radeonsi freedreno swrast etnaviv v3d
                 vc4 i915 svga virgl swr panfrost iris lima kmsro
Gallium st:      mesa xa xvmc xvmc vdpau va

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
2019-07-22 22:13:51 -04:00
Eric Engestrom dffeaa55dd util: use standard name for snprintf()
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-07-19 22:39:38 +01:00
Brian Paul bc517dbbf7 ddebug: fix a few MSVC compiler warnings
Don't return an expression in void functions.
Replace an unsigned int with proper enum.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2019-05-08 10:05:41 -06:00
Julien Isorce a3c202de0a gallium: add resource_get_info to pipe_screen
Generic plumbing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443
Signed-off-by: Julien Isorce <jisorce@oblong.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-30 17:53:12 +00:00
Nicolai Hähnle fea3dcb844 ddebug: expose some helper functions as non-inline
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-25 12:35:24 +02:00
Nicolai Hähnle ac0b60fa47 ddebug: dump driver state into a separate file
Due to asynchronous execution, it's not clear which of the draws the state
may refer to.

This also works around an issue encountered with radeonsi where dumping
the driver state itself caused a hang.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-25 12:35:21 +02:00
Nicolai Hähnle b7fab7b02d ddebug: log calls to pipe->flush
This can be useful when internal draws lead to a hang.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-25 12:35:19 +02:00
Nicolai Hähnle fe0d2b3d37 ddebug: set thread name
For better debuggability.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-25 12:35:16 +02:00
Dave Airlie 738921afd9 ddebug: add compute functions to help hang detection
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-04-05 10:01:08 +10:00
Marek Olšák 66a82ec6f0 gallium: add writable_bitmask parameter into set_shader_buffers
to indicate write usage per buffer.
This is just a hint (it will be used by radeonsi).

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2019-04-04 19:28:52 -04:00
Guido Günther a5e24dc416 gallium: ddebug: Add missing fence related wrappers
Without that `GALLIUM_DDEBUG=always kmscube -A` would segfault like

  #0  0x0000000000000000 in  ()
  #1  0x0000ffffa72a3c54 in dri2_get_fence_fd (_screen=0xaaaaed4f2090, _fence=0xaaaaed9ef880) at ../src/gallium/state_trackers/dri/dri_helpers.c:140
  #2  0x0000ffffa8744824 in dri2_dup_native_fence_fd (drv=0xaaaaed5010c0, disp=0xaaaaed5029a0, sync=0xaaaaed9ef7c0) at ../src/egl/drivers/dri2/egl_dri2.c:3050
  #3  0x0000ffffa87339b8 in eglDupNativeFenceFDANDROID (dpy=0xaaaaed5029a0, sync=0xaaaaed9ef7c0) at ../src/egl/main/eglapi.c:2107
  #4  0x0000aaaabd29ca90 in  ()
  #5  0x0000aaaabd401000 in  ()

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
2019-04-04 17:30:15 +02:00
Nicolai Hähnle 7230cb8f2b ddebug: always flush when requested, even when hang detection is disabled
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-12-19 11:59:18 +01:00
Nicolai Hähnle 539fdc49f1 ddebug: simplify watchdog loop and fix crash in the no-timeout case
The following race condition could occur in the no-timeout case:

  API thread               Gallium thread            Watchdog
  ----------               --------------            --------
  dd_before_draw
  u_threaded_context draw
  dd_after_draw
    add to dctx->records
    signal watchdog
                                                     dump & destroy record
                           execute draw
                           dd_after_draw_async
                             use-after-free!

Alternatively, the same scenario would assert in a debug build when
destroying the record because record->driver_finished has not signaled.

Fix this and simplify the logic at the same time by
- handing the record pointers off to the watchdog thread *before* each
  draw call and
- waiting on the driver_finished fence in the watchdog thread

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-12-19 11:59:10 +01:00
Marek Olšák e5e3b5cdcc gallium: add pipe_context::set_context_param for tuning perf on AMD Zen (v2)
State trackers will not use the new param directly, but will instead use
a helper in MakeCurrent that does the right thing.

v2: rework the interface

Reviewed-by: Brian Paul <brianp@vmware.com>
2018-09-07 15:48:31 -04:00
Marek Olšák 7c8716e4fb ddebug: implement set_window_rectangles
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2018-08-14 21:18:51 -04:00