};
struct r600_range {
- unsigned start_offset;
- unsigned end_offset;
struct r600_block **blocks;
};
struct r600_context {
struct radeon *radeon;
- unsigned hash_size;
- unsigned hash_shift;
- struct r600_range range[256];
+ struct r600_range *range;
unsigned nblocks;
struct r600_block **blocks;
struct list_head dirty;
ctx->radeon = radeon;
LIST_INITHEAD(&ctx->query_list);
+ ctx->range = calloc(NUM_RANGES, sizeof(struct r600_range));
+ if (!ctx->range) {
+ r = -ENOMEM;
+ goto out_err;
+ }
+
/* initialize hash */
- ctx->hash_size = 19;
- ctx->hash_shift = 11;
- for (int i = 0; i < 256; i++) {
- ctx->range[i].start_offset = i << ctx->hash_shift;
- ctx->range[i].end_offset = ((i + 1) << ctx->hash_shift) - 1;
- ctx->range[i].blocks = calloc(1 << ctx->hash_shift, sizeof(void*));
+ for (int i = 0; i < NUM_RANGES; i++) {
+ ctx->range[i].blocks = calloc(1 << HASH_SHIFT, sizeof(void*));
if (ctx->range[i].blocks == NULL) {
- return -ENOMEM;
+ r = -ENOMEM;
+ goto out_err;
}
}
/* setup block table */
ctx->blocks = calloc(ctx->nblocks, sizeof(void*));
- for (int i = 0, c = 0; i < 256; i++) {
- for (int j = 0; j < (1 << ctx->hash_shift); j++) {
+ for (int i = 0, c = 0; i < NUM_RANGES; i++) {
+ for (int j = 0; j < (1 << HASH_SHIFT); j++) {
if (ctx->range[i].blocks[j]) {
assert(c < ctx->nblocks);
ctx->blocks[c++] = ctx->range[i].blocks[j];
- j += (ctx->range[i].blocks[j]->nreg << 2) - 1;
+ j += (ctx->range[i].blocks[j]->nreg) - 1;
}
}
}
struct r600_block *block;
struct r600_range *range;
- for (int i = 0; i < 256; i++) {
- for (int j = 0; j < (1 << ctx->hash_shift); j++) {
+ for (int i = 0; i < NUM_RANGES; i++) {
+ for (int j = 0; j < (1 << HASH_SHIFT); j++) {
block = ctx->range[i].blocks[j];
if (block) {
for (int k = 0, offset = block->start_offset; k < block->nreg; k++, offset += 4) {
}
free(ctx->range[i].blocks);
}
+ free(ctx->range);
free(ctx->blocks);
free(ctx->reloc);
free(ctx->bo);
ctx->radeon = radeon;
LIST_INITHEAD(&ctx->query_list);
+ ctx->range = calloc(NUM_RANGES, sizeof(struct r600_range));
+ if (!ctx->range) {
+ r = -ENOMEM;
+ goto out_err;
+ }
+
/* initialize hash */
- ctx->hash_size = 19;
- ctx->hash_shift = 11;
- for (int i = 0; i < 256; i++) {
- ctx->range[i].start_offset = i << ctx->hash_shift;
- ctx->range[i].end_offset = ((i + 1) << ctx->hash_shift) - 1;
- ctx->range[i].blocks = calloc(1 << ctx->hash_shift, sizeof(void*));
+ for (int i = 0; i < NUM_RANGES; i++) {
+ ctx->range[i].blocks = calloc(1 << HASH_SHIFT, sizeof(void*));
if (ctx->range[i].blocks == NULL) {
r = -ENOMEM;
goto out_err;
/* setup block table */
ctx->blocks = calloc(ctx->nblocks, sizeof(void*));
- for (int i = 0, c = 0; i < 256; i++) {
- for (int j = 0, add; j < (1 << ctx->hash_shift); j++) {
+ for (int i = 0, c = 0; i < NUM_RANGES; i++) {
+ for (int j = 0, add; j < (1 << HASH_SHIFT); j++) {
if (ctx->range[i].blocks[j]) {
add = 1;
for (int k = 0; k < c; k++) {
if (add) {
assert(c < ctx->nblocks);
ctx->blocks[c++] = ctx->range[i].blocks[j];
- j += (ctx->range[i].blocks[j]->nreg << 2) - 1;
+ j += (ctx->range[i].blocks[j]->nreg) - 1;
}
}
}
/*
* helpers
*/
-#define CTX_RANGE_ID(ctx, offset) (((offset) >> (ctx)->hash_shift) & 255)
-#define CTX_BLOCK_ID(ctx, offset) ((offset) & ((1 << (ctx)->hash_shift) - 1))
+
+/* each range covers 9 bits of dword space = 512 dwords = 2k bytes */
+/* there is a block entry for each register so 512 blocks */
+/* we have no registers to read/write below 0x8000 (0x2000 in dw space) */
+/* we use some fake offsets at 0x40000 to do evergreen sampler borders so take 0x42000 as a max bound*/
+#define RANGE_OFFSET_START 0x8000
+#define HASH_SHIFT 9
+#define NUM_RANGES (0x42000 - RANGE_OFFSET_START) / (4 << HASH_SHIFT) /* 128 << 9 = 64k */
+
+#define CTX_RANGE_ID(ctx, offset) ((((offset - RANGE_OFFSET_START) >> 2) >> HASH_SHIFT) & 255)
+#define CTX_BLOCK_ID(ctx, offset) (((offset - RANGE_OFFSET_START) >> 2) & ((1 << HASH_SHIFT) - 1))
/*
* radeon_bo.c