mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 15:40:11 +01:00
freedreno/ir3: convert over to ralloc
The home-grown heap scheme (which is ultra-simple but probably not good to always allocate and memset such a chunk of memory up front) was a remnant of fdre (where the ir originally came from). But since we have ralloc in mesa, lets just use that instead. Signed-off-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
parent
27cf3b0052
commit
8fe2076243
2 changed files with 6 additions and 40 deletions
|
|
@ -30,48 +30,23 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "util/ralloc.h"
|
||||||
|
|
||||||
#include "freedreno_util.h"
|
#include "freedreno_util.h"
|
||||||
#include "instr-a3xx.h"
|
#include "instr-a3xx.h"
|
||||||
|
|
||||||
#define CHUNK_SZ 1020
|
|
||||||
|
|
||||||
struct ir3_heap_chunk {
|
|
||||||
struct ir3_heap_chunk *next;
|
|
||||||
uint32_t heap[CHUNK_SZ];
|
|
||||||
};
|
|
||||||
|
|
||||||
static void grow_heap(struct ir3 *shader)
|
|
||||||
{
|
|
||||||
struct ir3_heap_chunk *chunk = calloc(1, sizeof(*chunk));
|
|
||||||
chunk->next = shader->chunk;
|
|
||||||
shader->chunk = chunk;
|
|
||||||
shader->heap_idx = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* simple allocator to carve allocations out of an up-front allocated heap,
|
/* simple allocator to carve allocations out of an up-front allocated heap,
|
||||||
* so that we can free everything easily in one shot.
|
* so that we can free everything easily in one shot.
|
||||||
*/
|
*/
|
||||||
void * ir3_alloc(struct ir3 *shader, int sz)
|
void * ir3_alloc(struct ir3 *shader, int sz)
|
||||||
{
|
{
|
||||||
void *ptr;
|
return ralloc_size(shader, sz);
|
||||||
|
|
||||||
sz = align(sz, 4) / 4;
|
|
||||||
|
|
||||||
if ((shader->heap_idx + sz) > CHUNK_SZ)
|
|
||||||
grow_heap(shader);
|
|
||||||
|
|
||||||
ptr = &shader->chunk->heap[shader->heap_idx];
|
|
||||||
shader->heap_idx += sz;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ir3 * ir3_create(struct ir3_compiler *compiler,
|
struct ir3 * ir3_create(struct ir3_compiler *compiler,
|
||||||
unsigned nin, unsigned nout)
|
unsigned nin, unsigned nout)
|
||||||
{
|
{
|
||||||
struct ir3 *shader = calloc(1, sizeof(struct ir3));
|
struct ir3 *shader = ralloc(compiler, struct ir3);
|
||||||
|
|
||||||
grow_heap(shader);
|
|
||||||
|
|
||||||
shader->compiler = compiler;
|
shader->compiler = compiler;
|
||||||
shader->ninputs = nin;
|
shader->ninputs = nin;
|
||||||
|
|
@ -88,17 +63,13 @@ struct ir3 * ir3_create(struct ir3_compiler *compiler,
|
||||||
|
|
||||||
void ir3_destroy(struct ir3 *shader)
|
void ir3_destroy(struct ir3 *shader)
|
||||||
{
|
{
|
||||||
while (shader->chunk) {
|
/* TODO convert the dynamic array to ralloc too: */
|
||||||
struct ir3_heap_chunk *chunk = shader->chunk;
|
|
||||||
shader->chunk = chunk->next;
|
|
||||||
free(chunk);
|
|
||||||
}
|
|
||||||
free(shader->indirects);
|
free(shader->indirects);
|
||||||
free(shader->predicates);
|
free(shader->predicates);
|
||||||
free(shader->baryfs);
|
free(shader->baryfs);
|
||||||
free(shader->keeps);
|
free(shader->keeps);
|
||||||
free(shader->astc_srgb);
|
free(shader->astc_srgb);
|
||||||
free(shader);
|
ralloc_free(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define iassert(cond) do { \
|
#define iassert(cond) do { \
|
||||||
|
|
|
||||||
|
|
@ -337,8 +337,6 @@ static inline int ir3_neighbor_count(struct ir3_instruction *instr)
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ir3_heap_chunk;
|
|
||||||
|
|
||||||
struct ir3 {
|
struct ir3 {
|
||||||
struct ir3_compiler *compiler;
|
struct ir3_compiler *compiler;
|
||||||
|
|
||||||
|
|
@ -388,9 +386,6 @@ struct ir3 {
|
||||||
|
|
||||||
/* List of ir3_array's: */
|
/* List of ir3_array's: */
|
||||||
struct list_head array_list;
|
struct list_head array_list;
|
||||||
|
|
||||||
unsigned heap_idx;
|
|
||||||
struct ir3_heap_chunk *chunk;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct nir_variable nir_variable;
|
typedef struct nir_variable nir_variable;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue