[PATCH] nv50: don't allocate in the param buffer
Christoph Bumiller
e0425955 at student.tuwien.ac.at
Sun Jun 21 10:01:33 PDT 2009
Since we upload all parameters on every program / constbuf change,
we don't have to reserve space and can just use the whole buffer.
Doesn't apply to the buffer holding immediates.
---
src/gallium/drivers/nv50/nv50_program.c | 39 ++++++++----------------------
src/gallium/drivers/nv50/nv50_program.h | 6 ++--
2 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 75c5cea..28a9f2a 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -2433,7 +2433,7 @@ static void
nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
{
struct pipe_screen *pscreen = nv50->pipe.screen;
- unsigned cbuf, start, count;
+ unsigned cbuf, count;
if (!p->data[0] && p->immd_nr) {
struct nouveau_resource *heap = nv50->screen->immd_heap[0];
@@ -2457,23 +2457,10 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
if (!p->param_nr)
return;
- if (!p->data[1]) {
- struct nouveau_resource *heap =
- nv50->screen->parm_heap[p->type];
-
- if (nouveau_resource_alloc(heap, p->param_nr, p, &p->data[1])) {
- while (heap->next && heap->size < p->param_nr) {
- struct nv50_program *evict = heap->next->priv;
- nouveau_resource_free(&evict->data[1]);
- }
-
- if (nouveau_resource_alloc(heap, p->param_nr, p,
- &p->data[1]))
- assert(0);
- }
- }
-
- start = p->data[1]->start;
+ /* we can use the whole buffer for parameters as we upload them
+ * all everytime anyway
+ */
+ assert(p->param_nr <= 128);
if (p->type == PIPE_SHADER_VERTEX) {
count = p->param_nr - p->cfg.vp.ucp.nr * 4;
@@ -2486,15 +2473,13 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
if (count) {
float *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type],
PIPE_BUFFER_USAGE_CPU_READ);
- nv50_program_upload_data(nv50, map, start, count, cbuf);
+ nv50_program_upload_data(nv50, map, 0, count, cbuf);
pipe_buffer_unmap(pscreen, nv50->constbuf[p->type]);
}
if (p->param_nr > count) {
- start += count;
- count = p->cfg.vp.ucp.nr * 4;
nv50_program_upload_data(nv50, &p->cfg.vp.ucp.ucp[0][0],
- start, count, cbuf);
+ count, p->cfg.vp.ucp.nr * 4, cbuf);
}
}
@@ -2526,8 +2511,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
assert(!"No more space in program VRAM buffer.");
}
- if ((p->data[0] && p->data[0]->start != p->data_start[0]) ||
- (p->data[1] && p->data[1]->start != p->data_start[1]))
+ if (p->data[0] && p->data[0]->start != p->data_start[0])
upload = TRUE;
if (upload) {
@@ -2546,7 +2530,9 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
bs = (e->inst[1] >> 22) & 0x07;
assert(bs < 2);
ei = e->param.shift >> 5;
- ci = e->param.index + p->data[bs]->start;
+ ci = e->param.index;
+ if (bs == 0)
+ ci += p->data[bs]->start;
e->inst[ei] &= ~e->param.mask;
e->inst[ei] |= (ci << e->param.shift);
@@ -2554,8 +2540,6 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
if (p->data[0])
p->data_start[0] = p->data[0]->start;
- if (p->data[1])
- p->data_start[1] = p->data[1]->start;
}
if (!upload)
@@ -2869,7 +2853,6 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
nouveau_bo_ref(NULL, &p->bo);
nouveau_resource_free(&p->data[0]);
- nouveau_resource_free(&p->data[1]);
nouveau_resource_free(&p->code);
while (p->ln)
diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h
index ac5230d..2b7cffd 100644
--- a/src/gallium/drivers/nv50/nv50_program.h
+++ b/src/gallium/drivers/nv50/nv50_program.h
@@ -32,11 +32,11 @@ struct nv50_program {
struct nv50_program_exec *exec_head;
struct nv50_program_exec *exec_tail;
unsigned exec_size;
- struct nouveau_resource *data[2];
- unsigned data_start[2];
- struct nouveau_resource *code;
struct nouveau_bo *bo;
+ struct nouveau_resource *code;
+ struct nouveau_resource *data[1];
+ unsigned data_start[1];
float *immd;
unsigned immd_nr;
--
1.6.0.6
--------------090503050107050804030002
Content-Type: text/plain;
name="0015-nv50-defer-FP-attribute-loading.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="0015-nv50-defer-FP-attribute-loading.patch"
More information about the Nouveau
mailing list