crocus: inline group_index<->bti
this is on a fastpath for ubo emission Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11707>
This commit is contained in:
@@ -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 */
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user