uniform_size->map->put(hidden_uniform_start + hidden_id, name);
}
-/**
- * Search through the list of empty blocks to find one that fits the current
- * uniform.
- */
-static int
-find_empty_block(struct gl_shader_program *prog,
- struct gl_uniform_storage *uniform)
-{
- const unsigned entries = MAX2(1, uniform->array_elements);
-
- foreach_list_typed(struct empty_uniform_block, block, link,
- &prog->EmptyUniformLocations) {
- /* Found a block with enough slots to fit the uniform */
- if (block->slots == entries) {
- unsigned start = block->start;
- exec_node_remove(&block->link);
- ralloc_free(block);
-
- return start;
- /* Found a block with more slots than needed. It can still be used. */
- } else if (block->slots > entries) {
- unsigned start = block->start;
- block->start += entries;
- block->slots -= entries;
-
- return start;
- }
- }
-
- return -1;
-}
-
static void
link_setup_uniform_remap_tables(struct gl_context *ctx,
struct gl_shader_program *prog)
int chosen_location = -1;
if (empty_locs)
- chosen_location = find_empty_block(prog, &prog->data->UniformStorage[i]);
+ chosen_location = link_util_find_empty_block(prog, &prog->data->UniformStorage[i]);
/* Add new entries to the total amount of entries. */
total_entries += entries;
#include "util/set.h"
#include "string_to_uint_map.h"
#include "linker.h"
+#include "linker_util.h"
#include "link_varyings.h"
#include "ir_optimization.h"
#include "ir_rvalue_visitor.h"
}
}
- struct empty_uniform_block *current_block = NULL;
-
- for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
- /* We found empty space in UniformRemapTable. */
- if (prog->UniformRemapTable[i] == NULL) {
- /* We've found the beginning of a new continous block of empty slots */
- if (!current_block || current_block->start + current_block->slots != i) {
- current_block = rzalloc(prog, struct empty_uniform_block);
- current_block->start = i;
- exec_list_push_tail(&prog->EmptyUniformLocations,
- ¤t_block->link);
- }
-
- /* The current block continues, so we simply increment its slots */
- current_block->slots++;
- }
- }
+ link_util_update_empty_uniform_locations(prog);
delete uniform_map;
prog->NumExplicitUniformLocations = entries_total;
const glsl_struct_field *named_ifc_member);
};
-/**
- * Sometimes there are empty slots left over in UniformRemapTable after we
- * allocate slots to explicit locations. This struct represents a single
- * continouous block of empty slots in UniformRemapTable.
- */
-struct empty_uniform_block {
- struct exec_node link;
- /* The start location of the block */
- unsigned start;
- /* The number of slots in the block */
- unsigned slots;
-};
-
#endif /* GLSL_LINKER_H */
#include "main/mtypes.h"
#include "linker_util.h"
#include "util/set.h"
+#include "ir_uniform.h" /* for gl_uniform_storage */
/* Utility methods shared between the GLSL IR and the NIR */
return true;
}
+
+/**
+ * Search through the list of empty blocks to find one that fits the current
+ * uniform.
+ */
+int
+link_util_find_empty_block(struct gl_shader_program *prog,
+ struct gl_uniform_storage *uniform)
+{
+ const unsigned entries = MAX2(1, uniform->array_elements);
+
+ foreach_list_typed(struct empty_uniform_block, block, link,
+ &prog->EmptyUniformLocations) {
+ /* Found a block with enough slots to fit the uniform */
+ if (block->slots == entries) {
+ unsigned start = block->start;
+ exec_node_remove(&block->link);
+ ralloc_free(block);
+
+ return start;
+ /* Found a block with more slots than needed. It can still be used. */
+ } else if (block->slots > entries) {
+ unsigned start = block->start;
+ block->start += entries;
+ block->slots -= entries;
+
+ return start;
+ }
+ }
+
+ return -1;
+}
+
+void
+link_util_update_empty_uniform_locations(struct gl_shader_program *prog)
+{
+ struct empty_uniform_block *current_block = NULL;
+
+ for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
+ /* We found empty space in UniformRemapTable. */
+ if (prog->UniformRemapTable[i] == NULL) {
+ /* We've found the beginning of a new continous block of empty slots */
+ if (!current_block || current_block->start + current_block->slots != i) {
+ current_block = rzalloc(prog, struct empty_uniform_block);
+ current_block->start = i;
+ exec_list_push_tail(&prog->EmptyUniformLocations,
+ ¤t_block->link);
+ }
+
+ /* The current block continues, so we simply increment its slots */
+ current_block->slots++;
+ }
+ }
+}
#define GLSL_LINKER_UTIL_H
struct gl_shader_program;
+struct gl_uniform_storage;
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * Sometimes there are empty slots left over in UniformRemapTable after we
+ * allocate slots to explicit locations. This struct represents a single
+ * continouous block of empty slots in UniformRemapTable.
+ */
+struct empty_uniform_block {
+ struct exec_node link;
+ /* The start location of the block */
+ unsigned start;
+ /* The number of slots in the block */
+ unsigned slots;
+};
+
void
linker_error(struct gl_shader_program *prog, const char *fmt, ...);
struct set *resource_set,
GLenum type, const void *data, uint8_t stages);
+int
+link_util_find_empty_block(struct gl_shader_program *prog,
+ struct gl_uniform_storage *uniform);
+
+void
+link_util_update_empty_uniform_locations(struct gl_shader_program *prog);
+
#ifdef __cplusplus
}
#endif