Mesa (main): zink: handle PIPE_BUFFER sparse texture queries
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed May 18 02:42:34 UTC 2022
Module: Mesa
Branch: main
Commit: ca1d98df995a8fe3948a5bf7b1316d0184ffeb99
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca1d98df995a8fe3948a5bf7b1316d0184ffeb99
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Apr 21 13:10:37 2022 -0400
zink: handle PIPE_BUFFER sparse texture queries
this is legal but was never handled
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16563>
---
src/gallium/drivers/zink/zink_screen.c | 55 +++++++++++++++++++---------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index c78f1971f07..864fd10a7b1 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1884,6 +1884,20 @@ zink_get_sparse_texture_virtual_page_size(struct pipe_screen *pscreen,
int *x, int *y, int *z)
{
struct zink_screen *screen = zink_screen(pscreen);
+ static const int page_size_2d[][3] = {
+ { 256, 256, 1 }, /* 8bpp */
+ { 256, 128, 1 }, /* 16bpp */
+ { 128, 128, 1 }, /* 32bpp */
+ { 128, 64, 1 }, /* 64bpp */
+ { 64, 64, 1 }, /* 128bpp */
+ };
+ static const int page_size_3d[][3] = {
+ { 64, 32, 32 }, /* 8bpp */
+ { 32, 32, 32 }, /* 16bpp */
+ { 32, 32, 16 }, /* 32bpp */
+ { 32, 16, 16 }, /* 64bpp */
+ { 16, 16, 16 }, /* 128bpp */
+ };
/* Only support one type of page size. */
if (offset != 0)
return 0;
@@ -1913,6 +1927,9 @@ zink_get_sparse_texture_virtual_page_size(struct pipe_screen *pscreen,
type = VK_IMAGE_TYPE_3D;
break;
+ case PIPE_BUFFER:
+ goto hack_it_up;
+
default:
return 0;
}
@@ -1929,30 +1946,7 @@ zink_get_sparse_texture_virtual_page_size(struct pipe_screen *pscreen,
if (!prop_count) {
if (pformat == PIPE_FORMAT_R9G9B9E5_FLOAT) {
screen->faked_e5sparse = true;
- static const int page_size_2d[][3] = {
- { 256, 256, 1 }, /* 8bpp */
- { 256, 128, 1 }, /* 16bpp */
- { 128, 128, 1 }, /* 32bpp */
- { 128, 64, 1 }, /* 64bpp */
- { 64, 64, 1 }, /* 128bpp */
- };
- static const int page_size_3d[][3] = {
- { 64, 32, 32 }, /* 8bpp */
- { 32, 32, 32 }, /* 16bpp */
- { 32, 32, 16 }, /* 32bpp */
- { 32, 16, 16 }, /* 64bpp */
- { 16, 16, 16 }, /* 128bpp */
- };
- const int (*page_sizes)[3] = target == PIPE_TEXTURE_3D ? page_size_3d : page_size_2d;
- int blk_size = util_format_get_blocksize(pformat);
-
- if (size) {
- unsigned index = util_logbase2(blk_size);
- if (x) *x = page_sizes[index][0];
- if (y) *y = page_sizes[index][1];
- if (z) *z = page_sizes[index][2];
- }
- return 1;
+ goto hack_it_up;
}
return 0;
}
@@ -1966,6 +1960,19 @@ zink_get_sparse_texture_virtual_page_size(struct pipe_screen *pscreen,
*z = props[0].imageGranularity.depth;
}
+ return 1;
+hack_it_up:
+ {
+ const int (*page_sizes)[3] = target == PIPE_TEXTURE_3D ? page_size_3d : page_size_2d;
+ int blk_size = util_format_get_blocksize(pformat);
+
+ if (size) {
+ unsigned index = util_logbase2(blk_size);
+ if (x) *x = page_sizes[index][0];
+ if (y) *y = page_sizes[index][1];
+ if (z) *z = page_sizes[index][2];
+ }
+ }
return 1;
}
More information about the mesa-commit
mailing list