Mesa (main): crocus: inline group_index<->bti
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 5 05:14:01 UTC 2021
Module: Mesa
Branch: main
Commit: 063d7bfa1c1e995658377c7e4c713286de1a975d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=063d7bfa1c1e995658377c7e4c713286de1a975d
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Jul 5 06:35:50 2021 +1000
crocus: inline group_index<->bti
this is on a fastpath for ubo emission
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11707>
---
src/gallium/drivers/crocus/crocus_context.h | 48 +++++++++++++++++++++++++----
src/gallium/drivers/crocus/crocus_program.c | 42 -------------------------
2 files changed, 42 insertions(+), 48 deletions(-)
diff --git a/src/gallium/drivers/crocus/crocus_context.h b/src/gallium/drivers/crocus/crocus_context.h
index 0e4fc2e7bc3..fc2cea03d7f 100644
--- a/src/gallium/drivers/crocus/crocus_context.h
+++ b/src/gallium/drivers/crocus/crocus_context.h
@@ -832,12 +832,48 @@ const struct shader_info *crocus_get_shader_info(const struct crocus_context *ic
struct crocus_bo *crocus_get_scratch_space(struct crocus_context *ice,
unsigned per_thread_scratch,
gl_shader_stage stage);
-uint32_t crocus_group_index_to_bti(const struct crocus_binding_table *bt,
- enum crocus_surface_group group,
- uint32_t index);
-uint32_t crocus_bti_to_group_index(const struct crocus_binding_table *bt,
- enum crocus_surface_group group,
- uint32_t bti);
+/**
+ * Map a <group, index> pair to a binding table index.
+ *
+ * For example: <UBO, 5> => binding table index 12
+ */
+static inline uint32_t crocus_group_index_to_bti(const struct crocus_binding_table *bt,
+ enum crocus_surface_group group,
+ uint32_t index)
+{
+ assert(index < bt->sizes[group]);
+ uint64_t mask = bt->used_mask[group];
+ uint64_t bit = 1ull << index;
+ if (bit & mask) {
+ return bt->offsets[group] + util_bitcount64((bit - 1) & mask);
+ } else {
+ return CROCUS_SURFACE_NOT_USED;
+ }
+}
+
+/**
+ * Map a binding table index back to a <group, index> pair.
+ *
+ * For example: binding table index 12 => <UBO, 5>
+ */
+static inline uint32_t
+crocus_bti_to_group_index(const struct crocus_binding_table *bt,
+ enum crocus_surface_group group, uint32_t bti)
+{
+ uint64_t used_mask = bt->used_mask[group];
+ assert(bti >= bt->offsets[group]);
+
+ uint32_t c = bti - bt->offsets[group];
+ while (used_mask) {
+ int i = u_bit_scan64(&used_mask);
+ if (c == 0)
+ return i;
+ c--;
+ }
+
+ return CROCUS_SURFACE_NOT_USED;
+}
+
/* crocus_disk_cache.c */
diff --git a/src/gallium/drivers/crocus/crocus_program.c b/src/gallium/drivers/crocus/crocus_program.c
index b236a267a61..b0865b87943 100644
--- a/src/gallium/drivers/crocus/crocus_program.c
+++ b/src/gallium/drivers/crocus/crocus_program.c
@@ -740,48 +740,6 @@ enum {
SURFACE_GROUP_MAX_ELEMENTS = 64,
};
-/**
- * Map a <group, index> pair to a binding table index.
- *
- * For example: <UBO, 5> => binding table index 12
- */
-uint32_t
-crocus_group_index_to_bti(const struct crocus_binding_table *bt,
- enum crocus_surface_group group, uint32_t index)
-{
- assert(index < bt->sizes[group]);
- uint64_t mask = bt->used_mask[group];
- uint64_t bit = 1ull << index;
- if (bit & mask) {
- return bt->offsets[group] + util_bitcount64((bit - 1) & mask);
- } else {
- return CROCUS_SURFACE_NOT_USED;
- }
-}
-
-/**
- * Map a binding table index back to a <group, index> pair.
- *
- * For example: binding table index 12 => <UBO, 5>
- */
-uint32_t
-crocus_bti_to_group_index(const struct crocus_binding_table *bt,
- enum crocus_surface_group group, uint32_t bti)
-{
- uint64_t used_mask = bt->used_mask[group];
- assert(bti >= bt->offsets[group]);
-
- uint32_t c = bti - bt->offsets[group];
- while (used_mask) {
- int i = u_bit_scan64(&used_mask);
- if (c == 0)
- return i;
- c--;
- }
-
- return CROCUS_SURFACE_NOT_USED;
-}
-
static void
rewrite_src_with_bti(nir_builder *b, struct crocus_binding_table *bt,
nir_instr *instr, nir_src *src,
More information about the mesa-commit
mailing list