Mesa (main): panfrost: Don't make get_index_buffer_bounded per-gen
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 23 20:28:03 UTC 2021
Module: Mesa
Branch: main
Commit: fd298985c80eb2e71bbd17a9e62527b580993ba4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd298985c80eb2e71bbd17a9e62527b580993ba4
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Mon Jul 12 19:20:16 2021 -0400
panfrost: Don't make get_index_buffer_bounded per-gen
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11851>
---
src/gallium/drivers/panfrost/pan_cmdstream.c | 61 --------------------------
src/gallium/drivers/panfrost/pan_context.h | 6 +++
src/gallium/drivers/panfrost/pan_helpers.c | 64 ++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 61 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index c7505df66b4..a7b3e6cf375 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -81,67 +81,6 @@ panfrost_sample_pattern(unsigned samples)
}
}
-/* Gets a GPU address for the associated index buffer. Only gauranteed to be
- * good for the duration of the draw (transient), could last longer. Also get
- * the bounds on the index buffer for the range accessed by the draw. We do
- * these operations together because there are natural optimizations which
- * require them to be together. */
-
-static mali_ptr
-panfrost_get_index_buffer_bounded(struct panfrost_batch *batch,
- const struct pipe_draw_info *info,
- const struct pipe_draw_start_count_bias *draw,
- unsigned *min_index, unsigned *max_index)
-{
- struct panfrost_resource *rsrc = pan_resource(info->index.resource);
- struct panfrost_context *ctx = batch->ctx;
- off_t offset = draw->start * info->index_size;
- bool needs_indices = true;
- mali_ptr out = 0;
-
- if (info->index_bounds_valid) {
- *min_index = info->min_index;
- *max_index = info->max_index;
- needs_indices = false;
- }
-
- if (!info->has_user_indices) {
- /* Only resources can be directly mapped */
- panfrost_batch_read_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
- out = rsrc->image.data.bo->ptr.gpu + offset;
-
- /* Check the cache */
- needs_indices = !panfrost_minmax_cache_get(rsrc->index_cache,
- draw->start,
- draw->count,
- min_index,
- max_index);
- } else {
- /* Otherwise, we need to upload to transient memory */
- const uint8_t *ibuf8 = (const uint8_t *) info->index.user;
- struct panfrost_ptr T =
- pan_pool_alloc_aligned(&batch->pool.base,
- draw->count *
- info->index_size,
- info->index_size);
-
- memcpy(T.cpu, ibuf8 + offset, draw->count * info->index_size);
- out = T.gpu;
- }
-
- if (needs_indices) {
- /* Fallback */
- u_vbuf_get_minmax_index(&ctx->base, info, draw, min_index, max_index);
-
- if (!info->has_user_indices)
- panfrost_minmax_cache_add(rsrc->index_cache,
- draw->start, draw->count,
- *min_index, *max_index);
- }
-
- return out;
-}
-
static unsigned
translate_tex_wrap(enum pipe_tex_wrap w, bool using_nearest)
{
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index a9f79639ce7..8ed66966b9c 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -401,6 +401,12 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
void
panfrost_analyze_sysvals(struct panfrost_shader_state *ss);
+mali_ptr
+panfrost_get_index_buffer_bounded(struct panfrost_batch *batch,
+ const struct pipe_draw_info *info,
+ const struct pipe_draw_start_count_bias *draw,
+ unsigned *min_index, unsigned *max_index);
+
/* Instancing */
mali_ptr
diff --git a/src/gallium/drivers/panfrost/pan_helpers.c b/src/gallium/drivers/panfrost/pan_helpers.c
index ddd0b485529..418f29de66e 100644
--- a/src/gallium/drivers/panfrost/pan_helpers.c
+++ b/src/gallium/drivers/panfrost/pan_helpers.c
@@ -22,6 +22,7 @@
*/
#include "pan_context.h"
+#include "util/u_vbuf.h"
void
panfrost_analyze_sysvals(struct panfrost_shader_state *ss)
@@ -77,3 +78,66 @@ panfrost_analyze_sysvals(struct panfrost_shader_state *ss)
ss->dirty_3d = dirty;
ss->dirty_shader = dirty_shader;
}
+
+/* Gets a GPU address for the associated index buffer. Only gauranteed to be
+ * good for the duration of the draw (transient), could last longer. Also get
+ * the bounds on the index buffer for the range accessed by the draw. We do
+ * these operations together because there are natural optimizations which
+ * require them to be together. */
+
+mali_ptr
+panfrost_get_index_buffer_bounded(struct panfrost_batch *batch,
+ const struct pipe_draw_info *info,
+ const struct pipe_draw_start_count_bias *draw,
+ unsigned *min_index, unsigned *max_index)
+{
+ struct panfrost_resource *rsrc = pan_resource(info->index.resource);
+ struct panfrost_context *ctx = batch->ctx;
+ off_t offset = draw->start * info->index_size;
+ bool needs_indices = true;
+ mali_ptr out = 0;
+
+ if (info->index_bounds_valid) {
+ *min_index = info->min_index;
+ *max_index = info->max_index;
+ needs_indices = false;
+ }
+
+ if (!info->has_user_indices) {
+ /* Only resources can be directly mapped */
+ panfrost_batch_read_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
+ out = rsrc->image.data.bo->ptr.gpu + offset;
+
+ /* Check the cache */
+ needs_indices = !panfrost_minmax_cache_get(rsrc->index_cache,
+ draw->start,
+ draw->count,
+ min_index,
+ max_index);
+ } else {
+ /* Otherwise, we need to upload to transient memory */
+ const uint8_t *ibuf8 = (const uint8_t *) info->index.user;
+ struct panfrost_ptr T =
+ pan_pool_alloc_aligned(&batch->pool.base,
+ draw->count *
+ info->index_size,
+ info->index_size);
+
+ memcpy(T.cpu, ibuf8 + offset, draw->count * info->index_size);
+ out = T.gpu;
+ }
+
+ if (needs_indices) {
+ /* Fallback */
+ u_vbuf_get_minmax_index(&ctx->base, info, draw, min_index, max_index);
+
+ if (!info->has_user_indices)
+ panfrost_minmax_cache_add(rsrc->index_cache,
+ draw->start, draw->count,
+ *min_index, *max_index);
+ }
+
+ return out;
+}
+
+
More information about the mesa-commit
mailing list