diff options
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_shader.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv30_fragprog.c | 37 |
2 files changed, 20 insertions, 21 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h index 6e934f2908..08cb7817cf 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.h @@ -2,7 +2,7 @@ #define __SHADER_COMMON_H__ #include "mtypes.h" -#include "nouveau_buffers.h" +#include "bufferobj.h" typedef struct _nvsFunc nvsFunc; @@ -41,7 +41,7 @@ typedef struct _nouveauShader { unsigned int program_alloc_size; unsigned int program_start_id; unsigned int program_current; - nouveau_mem *program_buffer; + struct gl_buffer_object *program_buffer; unsigned int inputs_read; unsigned int outputs_written; int inst_count; 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 |