summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_blitter.c
AgeCommit message (Collapse)AuthorFilesLines
22 hoursu_blitter: stop leaking saved blitter states on no-op blitsMike Blumenkrantz1-4/+4
drivers expect blitter to clean up after itself cc: mesa-stable Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29122>
2024-03-27gallium: remove always-false parameterErik Faye-Lund1-2/+1
We always pass false to util_map_texcoords2d_onto_cubemap function, which allows us to avoid the dodgy case of using a close-to-one scaling factor in an attempt to avoid sampling on the edges. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> 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/27759>
2024-03-07util/blitter: iterate samples in stencil_fallbackMike Blumenkrantz1-27/+30
this matches handling in do_blits and fixes multisampled stencil blits fixes (nv): GTF-GL45.gtf44.GL31Tests.texture_stencil8.texture_stencil8_gl44 cc: mesa-stable Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27988>
2024-02-07gallium: remove take_ownership from set_vertex_buffers, assume it's trueMarek Olšák1-3/+3
This removes the take_ownership parameter and defines the behavior as if take_ownership was always true, which is the fast path. This way, we don't have to have 2 codepaths in set_vertex_buffers of every driver. The old behavior is optionally available through util_set_vertex_buffers. It also documents a new constraint that count in set_vertex_buffers must be equal to the number of vertex buffers referenced by vertex elements or 0. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27492>
2024-02-07gallium/u_blitter: set take_ownership=true for set_vertex_buffersMarek Olšák1-4/+2
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27492>
2024-02-07gallium: always set vertex elements before setting vertex buffersMarek Olšák1-8/+9
Drivers can use this constraint to merge vertex elements and vertex buffers in set_vertex_buffers instead of in draw_vbo. Suggested by: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8142 Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27492>
2024-02-01gallium/u_blitter: Fix a few uninitialized fb_stateLuc Ma1-5/+5
An uninitialized pipe_framebuffer_state maybe causes some issues if someone is about to use its members such as `fb_state.layers`. Signed-off-by: Luc Ma <luc@sietium.com> Reported-by: Mark Zhou <mark@sietium.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27332>
2024-01-14gallium: remove unbind_trailing_count from set_vertex_buffersMarek Olšák1-6/+8
It should implicitly unbind all bound buffers after "count". This also slightly simplies u_vbuf. This is a cleanup suggested by: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8142 Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> (asahi & panfrost) Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26309>
2023-08-14gallium: move vertex stride to CSOMike Blumenkrantz1-4/+2
this simplifies code in most place and enables some optimizations in frontends Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>
2023-08-11gallium: remove start_slot parameter from pipe_context::set_vertex_buffersYogesh Mohan Marimuthu1-6/+5
This patch removes start_slot from set_vertex_buffers() as suggested in https://gitlab.freedesktop.org/mesa/mesa/-/issues/8142 compilation testing: all gallium drivers, nine frontend compilation has been tested. d3d10umd compilation has not been tested driver, frontend testing: only llvmpipe and radeonsi driver was tested running game only the nine frontend changes are complex. All other changes are easy. nine front end was using start slot and also using multi context. nine frontend code changes: In update_vertex_elements() and update_vertex_buffers(), the vertex buffers or streams are ordered removing the holes. In update_vertex_elements() the vertex_buffer_index is updated for pipe driver to match the ordered list. v2: remove start_slot usage code from Marek (Marek Olšák) v3: nine stream number holes mask code from Axel (Axel Davy) Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> (except nine, which is Ab) Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22436>
2023-07-10gallium: cleanup util_blitter_clear_render_targetItalo Nicola1-9/+10
Signed-off-by: Italo Nicola <italonicola@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23735>
2023-07-06aux/util: use unsigned instead of uintErik Faye-Lund1-3/+3
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24002>
2023-06-29util/blitter: revert util_blitter_clear_buffer()Patrick Lerda1-4/+1
The previous change was creating a regression. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9252 Fixes: 23c003b88c54 ("util/blitter: fix util_blitter_clear_buffer() refcnt imbalance") Signed-off-by: Patrick Lerda <patrick9876@free.fr> Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23923>
2023-06-27treewide: Replace the usage of ubyte/ushort with uint8_t/uint16_tYonggang Luo1-1/+1
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: David Heidelberg <david.heidelberg@collabora.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23577>
2023-06-21util/blitter: fix util_blitter_clear_buffer() refcnt imbalancePatrick Lerda1-1/+4
Indeed, the vertex state was restored using a specific condition at the util_blitter_restore_vertex_states() level. This change ensures that the condition is the same when the vertex state is saved. The function util_blitter_clear_buffer() is only called by the r600 driver on pre-evergreen gpus. This issue is triggered on a rv770 gpu with "piglit/bin/fbo-1d -auto -fbo" or "piglit/bin/draw_buffers_gles2 -auto -fbo" while setting GALLIUM_REFCNT_LOG=refcnt.log. Fixes: 5f566faa4607 ("radeonsi: don't save and restore vertex buffers and elements for u_blitter") Signed-off-by: Patrick Lerda <patrick9876@free.fr> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23721>
2023-06-03compiler: Rename shader_prim to mesa_prim and replace all usage of ↵Yonggang Luo1-3/+3
pipe_prim_type with mesa_prim This is a prepare step to remove depends on p_defines.h in src/util/* This is done by: replace pipe_prim_type with mesa_prim replace shader_prim with mesa_prim replace PIPE_PRIM_MAX with MESA_PRIM_COUNT replace SHADER_PRIM_ with MESA_PRIM_ replace PIPE_PRIM_ with MESA_PRIM_ This patch only replace code only Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23369>
2023-04-19util/blitter: fix line wrapping on error to avoid giving wrong line numberMike Blumenkrantz1-2/+1
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22581>
2023-02-15gallium: plumb resolve attachments through from frontends -> ↵Mike Blumenkrantz1-0/+7
pipe_framebuffer_state some drivers may find this useful Reviewed-by: Adam Jackson <ajax@redhat.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18695>
2022-10-10gallium: normalized_coords -> unnormalized_coordsErik Faye-Lund1-4/+4
A lot of code zero-initializes pipe_sampler_state, and sets the states the non-zero fields manually. This means that normalized_coords is the "default" setting. However, setting normalized_coords to true isn't allways allowed, and we'd need to check PIPE_CAP_TEXRECT first. So it's not really the ideal default here. There's recently been found quite a bit of bugs in this area, where the state-tracker didn't properly lower texrects. Let's switch this around to avoid more bugs like this in the future. Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18971>
2022-08-22gallium: Inline away util_make_fragment_tex_shader interp_modeAlyssa Rosenzweig1-1/+0
Everything sets it to linear. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17918>
2022-08-09gallium/u_blitter: make the bilinear filter for MSAA resolving conformantMarek Olšák1-1/+1
This implements the bilinear filter exactly like OpenGL. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17692>
2022-08-09gallium/u_blitter: make nearest filtering emulation using TXF conformantMarek Olšák1-11/+15
This is required by glBlitFramebuffer. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Acked-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17692>
2022-08-09gallium/u_blitter: treat Z scaling as scaled blitsMarek Olšák1-1/+2
Hopefully this didn't break anything. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17692>
2022-08-09gallium/u_blitter: fix the has_txf support conditionMarek Olšák1-1/+1
GLSL 1.30 has it too. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17692>
2022-08-09gallium/u_blitter: remove unused code for integer MSAA resolveMarek Olšák1-4/+2
GL doesn't have it. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17692>
2022-07-26util/blitter: respect PIPE_TEXTURE_RECTMike Blumenkrantz1-8/+19
if this isn't supported, don't use rect-related sampling cc: mesa-stable Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17714>
2022-07-23gallium: add pipe_blit_info::dst_sample, update u_blitter to write that sampleMarek Olšák1-8/+13
A new radeonsi blit test will use it to upload different sample values into MSAA textures. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17694>
2022-06-23u_blitter: Remove util_blitter_copy_bufferAlyssa Rosenzweig1-69/+1
It is now unused. We cannot yet remove the streamout functionality in u_blitter as r600g still uses it for clear_buffer on GPUs older than Evergreen. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17142>
2022-06-21gallium/u_blitter: Fix depth.Timur Kristóf1-2/+5
Fix the transform to make sure it doesn't disturb the depth range of the blitted image. Set the Z coordinates of the vertices by hand instead of relying on the transform to do it. This is a pre-requisite to Zink always enabling depth clamping. Fixes: 26c6640835936a77d87030ce8e90f9b9f5be783e Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16929>
2022-05-19gallium/u_blitter: clear color buffers using color from a constant bufferIndrajit Kumar Das1-22/+22
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15318>
2022-05-06util/blitter: fix sampler restore with 0 saved samplersMike Blumenkrantz1-10/+31
in a sequence where a driver saves 0 sampler/views before calling u_blitter, the previous state of having 0 sampler/views bound would not be restored as expected, resulting in stale sampler/views which could affect behavior before new sampler/views were bound cc: mesa-stable Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16178>
2022-04-21u_blitter/stencil: take dstbox x/y into accounts for dst fb widthDave Airlie1-2/+2
When setting the dst framebuffer width height, it might be silly to constrain this beyond the dst resource, but at least constrain it correctly to take account of x/y offsets. This fixes some uses of this as a fallback for zink with GTF-GL46.gtf30.GL3Tests.framebuffer_blit.framebuffer_blit_functionality_stencil_blit Fixes: b4c07a8a87d0 ("gallium/util: allow scaling blits for stencil-fallback") Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16069>
2022-03-17gallium: rename layer-viewport capsErik Faye-Lund1-1/+1
Similar to the previous commits, these aren't TGSI specific, so let's drop TGSI from their name. Reviewed-by: Adam Jackson <ajax@redhat.com> Acked-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15316>
2022-03-17gallium: rename vs instance id capErik Faye-Lund1-1/+1
This cap is no longer specific to TGSI, so let's rename it and update the documentation to reflect that. Reviewed-by: Adam Jackson <ajax@redhat.com> Acked-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Juan A. Suarez <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15316>
2022-01-10replace 0 with NULL for NULL pointersThomas H.P. Andersen1-3/+3
This updates many places where 0 is used as NULL pointer. There are a few warnings left when I build the default configuration but they either relate to code outside of mesa or where "None" is used instead. Found with static analysis (smatch) Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12174>
2021-11-16gallium/u_blitter: clean up texcoords ZW when filling up just XYAlejandro Piñeiro1-1/+9
To avoid a scenario like this: * One blit needed the four components => XYZW filled up with 4 values * Following blit needing two components => ZW uses the previous values We detected this using the v3d driver with the arb_framebuffer_srgb-blit test, specifically: ./bin/arb_framebuffer_srgb-blit texture linear_to_srgb msaa enabled render -auto -fbo The main linear to srgb with msaa (not doing the resolve yet) blit requires the four components. At the end (after a resolve copy), the test uses glReadPixels, and internally it uses the blitter with two components, but the shader still uses lod on the texel fetch, so it gets the one used for the main blit, when it should be zero. Right now v3d works fine even with that wrong value, and I assume that any other driver too. But we can't ensure that would keep happening on the future, so let's use correct values. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13753>
2021-11-05Revert "gallium/u_blitter: work around broken sample shading in llvmpipe and ↵Mike Blumenkrantz1-7/+0
zink" This reverts commit 8b287c3f925121d9389df9846024d9c350cbb235. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13679>
2021-11-04gallium/u_blitter: work around broken sample shading in llvmpipe and zinkMarek Olšák1-0/+7
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13602>
2021-11-04gallium/u_blitter: do MSAA copies in 1 pass using sample shadingMarek Olšák1-44/+83
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13602>
2021-11-04gallium/u_blitter: disable sample shading for all blitsMarek Olšák1-0/+27
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13602>
2021-08-31u_blitter: add support for sample0 only resolves.Dave Airlie1-8/+8
This adds support for sample0 only resolves to support lavapipe Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12504>
2021-08-20gallium: add take_ownership into set_sampler_views to skip reference countingMarek Olšák1-7/+8
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12334>
2021-06-10util/blitter: remove duplicated set_sample_mask callsMike Blumenkrantz1-2/+0
it doesn't make sense to have both, so just keep the simpler one no functional changes because this was redundant Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11294>
2021-06-10u_blitter: fix fs used when no color emittedDave Airlie1-2/+5
Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11280>
2021-03-21gallium,st: add missing viewport swizzlesIlia Mirkin1-0/+4
Viewports must be initialized with the appropriate swizzles (for hardware that supports this feature). Fixes: 90fcb3fef28 (st/mesa: add NV_viewport_swizzle support) Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9732>
2021-01-27gallium: add take_ownership param into set_vertex_buffers to eliminate atomicsMarek Olšák1-5/+5
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-27gallium: add unbind_num_trailing_slots to set_sampler_viewsMarek Olšák1-6/+6
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-27gallium: add unbind_num_trailing_slots to set_vertex_buffersMarek Olšák1-4/+4
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-27gallium: add take_ownership param into set_constant_buffer to eliminate atomicsMarek Olšák1-3/+3
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-06gallium/util: do not perform n^2 stencil blitsErik Faye-Lund1-1/+1
We already loop n times here, no point in doing n instances as well. Fixes: e8a40715a8b ("gallium/util: add blitter-support for stencil-fallback") Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8301>