summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_program.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-03-31 17:06:22 -0600
committerBrian Paul <brianp@vmware.com>2009-04-03 09:07:04 -0600
commit597cd5b94e4818679af1134d053541f3d2cfb80e (patch)
treeb2bb0c1c7cb1e98962f33cc773e982f311be25ce /src/mesa/drivers/dri/i965/brw_program.c
parentba8b25a46cdd52e7b9116cc7d76dc4db4d667464 (diff)
i965: check-point commit of new constant buffer support
Currently, shader constants are stored in the GRF (loaded from the CURBE prior to shader execution). This severly limits the number of constants and temps that we can support. This new code will support (practically) unlimited size constant buffers and free up registers in the GRF. We allocate a new buffer object for the constants and read them with "Read" messages/instructions. When only a small number of constants are used, we can still use the old method. The code works for fragment shaders only (and is actually disabled) for now. Need to do the same thing for vertex shaders and need to add the necessary code-gen to fetch the constants which are referenced by the shader instructions.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_program.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index d90bd82038..457bc2fc7f 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -111,6 +111,8 @@ static void brwProgramStringNotify( GLcontext *ctx,
struct gl_program *prog )
{
struct brw_context *brw = brw_context(ctx);
+ struct intel_context *intel = &brw->intel;
+
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
struct brw_fragment_program *newFP = brw_fragment_program(fprog);
@@ -126,6 +128,24 @@ static void brwProgramStringNotify( GLcontext *ctx,
brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
newFP->id = brw->program_id++;
newFP->isGLSL = brw_wm_is_glsl(fprog);
+
+ /* alloc constant buffer/surface */
+ {
+ const struct gl_program_parameter_list *params = prog->Parameters;
+ const int size = params->NumParameters * 4 * sizeof(GLfloat);
+
+ /* free old const buffer if too small */
+ if (newFP->const_buffer && newFP->const_buffer->size < size) {
+ dri_bo_unreference(newFP->const_buffer);
+ newFP->const_buffer = NULL;
+ }
+
+ if (!newFP->const_buffer) {
+ newFP->const_buffer = drm_intel_bo_alloc(intel->bufmgr,
+ "fp_const_buffer",
+ size, 64);
+ }
+ }
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog;