Commit Graph

47108 Commits

Author SHA1 Message Date
Yonggang Luo
2b00ba23c2 st: Fixes warning [-Wimplicit-fallthrough] in st_texture.c
Warning message:
../src/mesa/state_tracker/st_texture.c:190:4: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18204>
2022-09-01 03:00:36 +00:00
Emma Anholt
5f66a927ec gallium,glsl: Delete PIPE_CAP_VERTEXID_NOBASE and lower_vertex_id.
Every driver uses the nir_lower_system_values path now.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18327>
2022-08-31 22:57:03 +00:00
Erik Faye-Lund
8abb5c8b41 mesa/st: force nearest-filtering for fp32 textures
OpenGL 3.0 requires ARB_texture_float, which technically speaking
requires linear-filtering support for FP32 textures. However, because a
lot of early implementations just ignore this and does nearest filtering
instead due to lack of hardware features for this, this functionality
was never added to the OpenGL CTS.

The result is that FP32 is a feature that is required on paper, but
is unreliable to be used by applications in practice. This is mostly
fine; for most filterable use-cases (e.g colors), FP16 is fine and saves
a bunch of bandwidth, and for cases where you really need the extra bits
(depth-reads etc), filtering is usually not what's wanted.

To save drivers that doesn't support filtering of FP32 filtering from
having to manually whack the state, and get needless CSOs in the CSO
caches, let's force this in early, where we already do the same for
integer textures.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18292>
2022-08-31 07:02:51 +00:00
Erik Faye-Lund
ec222a20da mesa/st: always force integer filtering to nearest
There's no need to re-check the DRI-config setting here; we either
already got nearest filtering already, or the we applied a work-around
to avoid incomplete textures. In either case, these should be nearest,
no need to check for it again.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18292>
2022-08-31 07:02:51 +00:00
Erik Faye-Lund
70c71c4200 mesa/st: also override mip filter for integer textures
If not, drivers may attempt interpolating these values, which isn't
going to do anything good.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18292>
2022-08-31 07:02:51 +00:00
Nanley Chery
5c2c8652d1 mesa/st: Drop st_texture_image_transfer::map
It's only used in the scope of a single function, st_UnmapTextureImage. Use
a local variable instead.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Nanley Chery
21038d1540 mesa/st: Fix indentation in st_MapTextureImage
Dedent an if-else block and setup the else braces according to the coding
style.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Nanley Chery
dab19642ee mesa/st: Don't map compressed texture fallbacks for reads
We don't need to map the compressed texture's fallback resource for operations
which will only read from the texture (e.g., glGetCompressedTexImage2D and
glCopyImageSubData).

For compressed textures using a fallback, delay the map until
st_UnmapTextureImage and only do the map if it's being written to.

To help identify what's being changed, the expected indentation changes are
split out into the next patch.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Nanley Chery
81094981b6 mesa/st: Add and use st_texture_image_transfer::box
Use this field to determine which parts of the compressed texture fallback
resource needs updating. Drops a dependency on the
st_texture_image_transfer::transfer pointer.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Nanley Chery
5f1967e92b mesa/st: Add and use st_texture_image_insert_transfer
Split out the transfer array reallocation and insertion functionality from
st_texture_image_map.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Nanley Chery
9fe525e37b mesa/st: Set PIPE_MAP_DISCARD_RANGE in fallback_copy_image
Enables some drivers to avoid reading from the destination when mapping it.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18257>
2022-08-30 22:11:34 +00:00
Erik Faye-Lund
7f7c8e83df mesa: fall-back to fp16 for bptc-textures
FP16 is way more commonly supported than FP32, and requires half the
memory bandwidth. Because the internal format of BPTC is really FP16,
let's fall back to that instead.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
72ad3787a3 mesa/main: add fp16-versions of bptc decompression functions
These are essential copies of the float-versions, with minor
adjustments.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
253b521b6e mesa/main: remove always-true define
We don't include this header anwhere where BPTC_BLOCK_DECODE isn't
already true, so let's remove it.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
e4ff42684b mesa/st: enable bptc extension with fallback
This implements emulation of BPTC for all drivers that don't natively
support it in HW, similar to what we have for ETC and ASTC already. The
only significant difference is that we don't implement any transcoding
DRI-conf for it.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
4f4e28face mesa/st: implement fallback for bptc
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
2b7dfd8de1 mesa: add _mesa_unpack_bptc-function
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
529e70271f mesa: add format-helper for bptc
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
403b9bf870 mesa/st: add context-flag for bptc-support
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
8f446322e1 mesa/st: do not use memcpy when using compressed fallback
If we're using the memcpy-path, we don't update the compressed image,
which will be needed if an application try to download the texture-image
again afterwards.

This isn't a problem yet, because none of the current compressed formats
with fallback are copyable as per the OpenGL 4.6 Core spec, table 8.14.
However, this is about to change, when we introduce fallback for BPTC
formats.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
673d241f36 mesa/st: avoid double-mapping if both images are the same
If both src_image and dst_image are pointing to the same image, we'll
end up double mapping the image, which throws an assert in
st_texture_image_map.

So let's check if these images are the same, and avoid the extra mapping
in that case.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
985fde28a2 mesa/st: simplify st_compressed_format_fallback
By looking at the format-layout, we can do switch-cases here instead of
serial calls to _mesa_is_format_foo(). This isn't a huge deal yet, but
this function is going to learn about a lot more formats soon...

Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
bf6e70965d mesa/main: simplify implementation of _mesa_is_format_astc_2d
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:47 +00:00
Erik Faye-Lund
207798c557 mesa/main: simplify implmementation of _mesa_is_format_etc2
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Soroush Kashani <soroush.kashani@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>
2022-08-30 08:36:46 +00:00
Brian Paul
1d915cd702 st_pbo/compute: fix memset() warning
Using memset() to zero a few sequential fields in gl_pixelstore_attrib
is a bit dodgy (what if someone were to add/reorder fields?).  And gcc
emits a warning in optimized builds:

In function ‘memset’,
    inlined from ‘copy_converted_buffer’ at ../src/mesa/state_tracker/st_pbo_compute.c:1038:7,
    inlined from ‘st_GetTexSubImage_shader’ at ../src/mesa/state_tracker/st_pbo_compute.c:1146:7:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:10: warning: ‘__builtin_memset’ offset [9, 24] from the object at ‘packing’ is out of the bounds of referenced subobject ‘RowLength’ with type ‘int’ at offset 4 [-Warray-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Just replace the memset with ordinary assignments.

Signed-off-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18261>
2022-08-26 14:37:44 +00:00
Jesse Natalie
d0a1c1a37d mesa: Expose GL_NV_ES1_1_compatibility
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18217>
2022-08-25 10:17:10 -07:00
Marek Olšák
cbad4adc13 st/mesa: fix potential use-after-free in draw_bitmap_quad
This is super unlikely to be freed before use, but let's fix it anyway.

setup_render_state calls set_sampler_views(take_ownership=true), which
means it takes ownership of the sampler view reference and is free to
unreference it, so we can't use sv after setup_render_state.

Fixes: feda6e9c5d - st/mesa: set take_ownership = true in set_sampler_views

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17780>
2022-08-24 18:13:02 +00:00
Marek Olšák
bb860f63f6 mesa: create glBitmap textures while creating display lists
This makes glCallList just a textured draw, which is blazingly fast.

Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17780>
2022-08-24 18:13:02 +00:00
Marek Olšák
6da2fb81a7 Revert "mesa: implement a display list / glBitmap texture atlas"
This reverts commit b26ddda12f and
commit 06d3b0a006.

Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17780>
2022-08-24 18:13:02 +00:00
Ian Romanick
1aacd9492d radeonsi: r600: d3d12: st: Use NIR lowering for tg4 offset arrays instead of GLSL lowering
I think I got all the drivers that need updating.  This is only
necessary in drivers that support GLSL 4.00 / GL_ARB_gpu_shader5 and
have PIPE_CAP_TEXTURE_GATHER_OFFSETS = 0.

v2: Don't (accidentally) condition tg4 offsets lowering on tex rect
lowering.  Noticed by Qiang.

v3: Add missing bool() cast.

v4: don't use designated initializers

Fixes: 640f909862 ("glsl: add _texture related sparse texture builtin functions")
Closes: #6365
Tested-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16547>
2022-08-23 01:10:23 +00:00
Yonggang Luo
a5972eb7ac mapi: Remove usage of _glapi_check_multithread and _glapi_destroy_multithread
They are empty stub functions now so have no need call to them

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17814>
2022-08-22 21:32:09 +00:00
Mike Blumenkrantz
7b81dbe591 st_pbo/compute: pre-clamp loaded geometry based on coord components
if only some of these components will be used, clamp the rest to enable
better shader optimizing

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>
2022-08-22 02:00:55 +00:00
Mike Blumenkrantz
613348766c st_pbo/compute: pre-clamp shader geometry to 16bit
no point doing this in the shader

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>
2022-08-22 02:00:55 +00:00
Mike Blumenkrantz
2fa5afd639 st_pbo/compute: fix 1D coord dimension by pre-trimming vectors
cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>
2022-08-22 02:00:55 +00:00
Mike Blumenkrantz
cd07a0002f st_pbo/compute: fix 1D_ARRAY offsets
these come in as yoffset, but the constant data must use 0 since the sampler
view is created with the offset

cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>
2022-08-22 02:00:55 +00:00
Mike Blumenkrantz
bd3b03939b st_pbo/compute: handle download failures with fallback
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18118>
2022-08-22 02:00:55 +00:00
Mike Blumenkrantz
c68c36f890 mesa/st: simplify sampler border color swizzling
this reuses the pre-calculated swizzle value to resolve a TODO item and
improve perf

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
e00bb6cb98 mesa/st: use tracked samplerview swizzle values
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
0ccc0f7b50 mesa: track gl_texture_object swizzle internally
this moves updating of swizzles to the points at which it could possibly change

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
383b39f313 mesa/st: use pre-calculated format swizzle for samplerviews
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
e713a9a982 mesa: track format swizzles on teximage objects
this will only very rarely change, so stop calculating it during sampler update

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
55ef65d4f4 gallium: add PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_ALPHA_NOT_W
mesa/gallium and util_format have different handling of alpha channels:
* mesa/gallium always uses w for the alpha swizzle
* util_format uses the actual component

for drivers which need to use the latter handling, this quirk will use the right
border color

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
1341d7aa84 mesa/st: use plumbed value for srgb_skip_decode in sampler conversion
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
1c172cdbcc mesa/st: plumb glsl130_or_later through sampler creation
no functional changes

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
d1e33fa345 mesa/st: add ignore_srgb_decode param to st_convert_sampler
same as st_get_texture_sampler_view_from_stobj, no functional changes

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
28d033b34f mesa: require render target bind for A/L/I in format selection
these are required framebuffer formats in certain versions of GL,
so don't create a texture that can't later be bound to a framebuffer

see also spec@!opengl 3.0@required-texture-attachment-formats

cc: mesa-stable

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Mike Blumenkrantz
4f28e2827c mesa: fix blending when using luminance/intensity emulation
neither of these have a real alpha channel, so reuse the xrgb blend
clamping here to ensure the "right" alpha value is used

cc: mesa-stable

fixes:
spec@arb_texture_float@fbo-blending-formats

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687>
2022-08-12 14:24:52 +00:00
Marek Olšák
7361b67f92 glthread: add missing code for GL_ARB_sparse_texture
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17976>
2022-08-12 06:06:48 +00:00
Marek Olšák
f9b0dc9377 glthread: track GL_READ_FRAMEBUFFER bindings too
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17976>
2022-08-12 06:06:48 +00:00
Marek Olšák
eb4036ea5b glthread: unbind framebuffers in glDeleteFramebuffers
Tests:
    dEQP-GLES2.functional.lifetime.delete_bound.framebuffer
    dEQP-GLES2.functional.state_query.integers.framebuffer_binding_getinteger

Fixes: e48f676835 - glthread: don't sync for more glGetIntegerv enums for glretrace

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17976>
2022-08-12 06:06:48 +00:00