summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nv30_fragprog.c
diff options
context:
space:
mode:
authorBen Skeggs <darktama@iinet.net.au>2006-12-27 23:52:40 +1100
committerBen Skeggs <darktama@iinet.net.au>2006-12-27 23:53:26 +1100
commit8c180c72d5fed5f26f258759f9649fc647a764ff (patch)
treee4da9bada87cc68650b6ab709fabf885d7a28b65 /src/mesa/drivers/dri/nouveau/nv30_fragprog.c
parent9a20ae70ecda2e78ea6b52c3fd829d283434c1ad (diff)
nouveau: Use bufferobj interface for fragment program uploads
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nv30_fragprog.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nv30_fragprog.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nv30_fragprog.c b/src/mesa/drivers/dri/nouveau/nv30_fragprog.c
index b11bc1809e..cd7c955c9e 100644
--- a/src/mesa/drivers/dri/nouveau/nv30_fragprog.c
+++ b/src/mesa/drivers/dri/nouveau/nv30_fragprog.c
@@ -10,7 +10,7 @@
#include "nouveau_shader.h"
#include "nouveau_object.h"
#include "nouveau_msg.h"
-#include "nouveau_buffers.h"
+#include "nouveau_bufferobj.h"
#include "nv30_shader.h"
unsigned int NVFP_TX_AOP_COUNT = 64;
@@ -24,29 +24,28 @@ static void
NV30FPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ uint32_t offset;
- if (!nvs->program_buffer) {
- nouveau_mem *fpbuf;
+ if (!nvs->program_buffer)
+ nvs->program_buffer = ctx->Driver.NewBufferObject(ctx, 0,
+ GL_ARRAY_BUFFER_ARB);
- fpbuf = nouveau_mem_alloc(ctx, NOUVEAU_MEM_FB|NOUVEAU_MEM_MAPPED,
- nvs->program_size * sizeof(uint32_t), 0);
- if (!fpbuf) {
- fprintf(stderr, "fragprog vram alloc fail!\n");
- return;
- }
- nvs->program_buffer = fpbuf;
- }
+ /* Should use STATIC_DRAW_ARB if shader doesn't use changable params */
+ ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB,
+ nvs->program_size * sizeof(uint32_t),
+ (const GLvoid *)nvs->program,
+ GL_DYNAMIC_DRAW_ARB,
+ nvs->program_buffer);
+
+ offset = nouveau_bufferobj_gpu_ref(ctx, GL_READ_ONLY_ARB,
+ nvs->program_buffer);
- /*XXX: should do a DMA.. and not copy over a possibly in-use program.. */
- /* not using state cache here, updated programs at the same address
- * seem to not take effect unless ACTIVE_PROGRAM is called again. hw
- * caches the program somewhere? so, maybe not so bad to just clobber the
- * old program in vram..
+ /* Not using state cache here, updated programs at the same address don't
+ * seem to take effect unless the ACTIVE_PROGRAM method is called again.
+ * HW caches the program somewhere?
*/
- memcpy(nvs->program_buffer->map, nvs->program,
- nvs->program_size * sizeof(uint32_t));
BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM, 1);
- OUT_RING(nouveau_mem_gpu_offset_get(ctx, nvs->program_buffer) | 1);
+ OUT_RING (offset | 1);
}
static void