summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-09-15 22:46:39 -0400
committerMarge Bot <eric+marge@anholt.net>2021-10-01 14:51:23 +0000
commit1c66de323904a529bc03ca0be79feffd963e6d60 (patch)
treeb6356bc7d6ce2e2051eb1e824bc4ce7fa424cbb7 /src/gallium/auxiliary/util
parentd5218f08891650dd638c0484d237dfa4675f8d74 (diff)
gallium: add pipe_vertex_state and draw_vertex_state for display lists
The main motivation is to improve the score of viewperf13/snx. This new interface is designed to be optimal for display lists as implemented by the vbo module. It has much lower CPU overhead in the frontend, threaded context, and the driver. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13050>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_helpers.c22
-rw-r--r--src/gallium/auxiliary/util/u_helpers.h9
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h12
-rw-r--r--src/gallium/auxiliary/util/u_prim.c3
-rw-r--r--src/gallium/auxiliary/util/u_screen.c1
5 files changed, 47 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c
index 0c358a06b21..dd415b9909f 100644
--- a/src/gallium/auxiliary/util/u_helpers.c
+++ b/src/gallium/auxiliary/util/u_helpers.c
@@ -496,3 +496,25 @@ util_lower_clearsize_to_dword(const void *clearValue, int *clearValueSize, uint3
}
return false;
}
+
+void
+util_init_pipe_vertex_state(struct pipe_screen *screen,
+ struct pipe_vertex_buffer *buffer,
+ const struct pipe_vertex_element *elements,
+ unsigned num_elements,
+ struct pipe_resource *indexbuf,
+ uint32_t full_velem_mask,
+ struct pipe_vertex_state *state)
+{
+ assert(num_elements == util_bitcount(full_velem_mask));
+
+ pipe_reference_init(&state->reference, 1);
+ state->screen = screen;
+
+ pipe_vertex_buffer_reference(&state->input.vbuffer, buffer);
+ pipe_resource_reference(&state->input.indexbuf, indexbuf);
+ state->input.num_elements = num_elements;
+ for (unsigned i = 0; i < num_elements; i++)
+ state->input.elements[i] = elements[i];
+ state->input.full_velem_mask = full_velem_mask;
+}
diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h
index f08f44dad99..9246d306ed8 100644
--- a/src/gallium/auxiliary/util/u_helpers.h
+++ b/src/gallium/auxiliary/util/u_helpers.h
@@ -121,6 +121,15 @@ void util_throttle_memory_usage(struct pipe_context *pipe,
bool
util_lower_clearsize_to_dword(const void *clearValue, int *clearValueSize, uint32_t *clamped);
+void
+util_init_pipe_vertex_state(struct pipe_screen *screen,
+ struct pipe_vertex_buffer *buffer,
+ const struct pipe_vertex_element *elements,
+ unsigned num_elements,
+ struct pipe_resource *indexbuf,
+ uint32_t full_velem_mask,
+ struct pipe_vertex_state *state);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 7e040138ec2..1f1215c7ff0 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -231,6 +231,18 @@ pipe_so_target_reference(struct pipe_stream_output_target **dst,
}
static inline void
+pipe_vertex_state_reference(struct pipe_vertex_state **dst,
+ struct pipe_vertex_state *src)
+{
+ struct pipe_vertex_state *old_dst = *dst;
+
+ if (pipe_reference(old_dst ? &old_dst->reference : NULL,
+ src ? &src->reference : NULL))
+ old_dst->screen->vertex_state_destroy(old_dst->screen, old_dst);
+ *dst = src;
+}
+
+static inline void
pipe_vertex_buffer_unreference(struct pipe_vertex_buffer *dst)
{
if (dst->is_user_buffer)
diff --git a/src/gallium/auxiliary/util/u_prim.c b/src/gallium/auxiliary/util/u_prim.c
index 9646a639ea7..a84d0e71e7c 100644
--- a/src/gallium/auxiliary/util/u_prim.c
+++ b/src/gallium/auxiliary/util/u_prim.c
@@ -37,6 +37,9 @@ u_prim_name(enum pipe_prim_type prim)
struct pipe_draw_info info;
STATIC_ASSERT(sizeof(info.mode) == 1);
+ struct pipe_draw_vertex_state_info dvs_info;
+ STATIC_ASSERT(sizeof(dvs_info.mode) == 1);
+
static const struct debug_named_value names[] = {
DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index eb6be76b228..eba554600fd 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -472,6 +472,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
return 1;
case PIPE_CAP_EMULATE_NONFIXED_PRIMITIVE_RESTART:
+ case PIPE_CAP_DRAW_VERTEX_STATE:
return 0;
default: