summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorPatrice Mandin <pmandin@caramail.com>2008-07-11 23:17:47 +0200
committerPatrice Mandin <pmandin@caramail.com>2008-07-11 23:17:47 +0200
commitc7086277546d065eb94ba8dbeca1620605f167ea (patch)
treec268d20322bf8989df4797ffece8349b5eaaf496 /src/gallium/drivers
parent5acbd0b0961089f9553adbe9b3d1341997ccb220 (diff)
nv30: Move constant buffers out of vert/frag prog structures
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h6
-rw-r--r--src/gallium/drivers/nv30/nv30_fragprog.c12
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c5
-rw-r--r--src/gallium/drivers/nv30/nv30_vertprog.c18
4 files changed, 19 insertions, 22 deletions
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index 72f803c80a..c3c8b73309 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -124,6 +124,8 @@ struct nv30_context {
unsigned dirty;
struct pipe_scissor_state scissor;
unsigned stipple[32];
+ struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
+ unsigned constbuf_nr[PIPE_SHADER_TYPES];
struct nv30_rasterizer_state *rasterizer;
struct nv30_zsa_state *zsa;
struct nv30_blend_state *blend;
@@ -150,16 +152,12 @@ struct nv30_context {
struct {
struct nv30_vertex_program *active;
-
struct nv30_vertex_program *current;
- struct pipe_buffer *constant_buf;
} vertprog;
struct {
struct nv30_fragment_program *active;
-
struct nv30_fragment_program *current;
- struct pipe_buffer *constant_buf;
} fragprog;
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
index 6af86e4f4f..b560455a02 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -820,6 +820,8 @@ nv30_fragprog_upload(struct nv30_context *nv30,
void
nv30_fragprog_bind(struct nv30_context *nv30, struct nv30_fragment_program *fp)
{
+ struct pipe_buffer *constbuf =
+ nv30->constbuf[PIPE_SHADER_FRAGMENT];
struct pipe_winsys *ws = nv30->pipe.winsys;
int i;
@@ -830,8 +832,9 @@ nv30_fragprog_bind(struct nv30_context *nv30, struct nv30_fragment_program *fp)
}
if (fp->nr_consts) {
- float *map = ws->buffer_map(ws, nv30->fragprog.constant_buf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ float *map;
+
+ map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ);
for (i = 0; i < fp->nr_consts; i++) {
struct nv30_fragment_program_data *fpd = &fp->consts[i];
uint32_t *p = &fp->insn[fpd->offset];
@@ -842,13 +845,10 @@ nv30_fragprog_bind(struct nv30_context *nv30, struct nv30_fragment_program *fp)
memcpy(p, cb, 4 * sizeof(float));
fp->on_hw = 0;
}
- ws->buffer_unmap(ws, nv30->fragprog.constant_buf);
+ ws->buffer_unmap(ws, constbuf);
}
if (!fp->on_hw) {
- const uint32_t le = 1;
- uint32_t *map;
-
if (!fp->buffer)
fp->buffer = ws->buffer_create(ws, 0x100, 0,
fp->insn_len * 4);
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 72b9515eb1..aec6fa2b15 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -589,12 +589,13 @@ nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
{
struct nv30_context *nv30 = nv30_context(pipe);
+ nv30->constbuf[shader] = buf->buffer;
+ nv30->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
+
if (shader == PIPE_SHADER_VERTEX) {
- nv30->vertprog.constant_buf = buf->buffer;
nv30->dirty |= NV30_NEW_VERTPROG;
} else
if (shader == PIPE_SHADER_FRAGMENT) {
- nv30->fragprog.constant_buf = buf->buffer;
nv30->dirty |= NV30_NEW_FRAGPROG;
}
}
diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
index 1b34d2e4b2..90756febd2 100644
--- a/src/gallium/drivers/nv30/nv30_vertprog.c
+++ b/src/gallium/drivers/nv30/nv30_vertprog.c
@@ -135,7 +135,7 @@ emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nv30_sreg src)
/*
* |VVV|
- * d°.°b
+ * d�.�b
* \u/
*
*/
@@ -641,9 +641,12 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
{
struct nouveau_winsys *nvws = nv30->nvws;
struct pipe_winsys *ws = nv30->pipe.winsys;
+ struct pipe_buffer *constbuf;
boolean upload_code = FALSE, upload_data = FALSE;
int i;
+ constbuf = nv30->constbuf[PIPE_SHADER_VERTEX];
+
/* Translate TGSI shader into hw bytecode */
if (!vp->translated) {
nv30_vertprog_translate(nv30, vp);
@@ -730,8 +733,8 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
if (vp->nr_consts) {
float *map = NULL;
- if (nv30->vertprog.constant_buf) {
- map = ws->buffer_map(ws, nv30->vertprog.constant_buf,
+ if (constbuf) {
+ map = ws->buffer_map(ws, constbuf,
PIPE_BUFFER_USAGE_CPU_READ);
}
@@ -750,15 +753,10 @@ nv30_vertprog_bind(struct nv30_context *nv30, struct nv30_vertex_program *vp)
BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5);
OUT_RING (i + vp->data->start);
OUT_RINGp ((uint32_t *)vpd->value, 4);
-#if 0
- NOUVEAU_MSG("VP const %d: %f %f %f %f\n",
- i, vpd->value[0], vpd->value[1],
- vpd->value[2], vpd->value[3]);
-#endif
}
- if (map) {
- ws->buffer_unmap(ws, nv30->vertprog.constant_buf);
+ if (constbuf) {
+ ws->buffer_unmap(ws, constbuf);
}
}