summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_curbe.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_curbe.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_curbe.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_curbe.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index 545dedd34b..39a8610952 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -38,6 +38,7 @@
#include "shader/prog_parameter.h"
#include "shader/prog_statevars.h"
#include "intel_batchbuffer.h"
+#include "intel_regions.h"
#include "brw_context.h"
#include "brw_defines.h"
#include "brw_state.h"
@@ -251,6 +252,7 @@ static void prepare_constant_buffer(struct brw_context *brw)
_mesa_load_state_parameters(ctx, vp->program.Base.Parameters);
+ /* XXX just use a memcpy here */
for (i = 0; i < nr; i++) {
const GLfloat *value = vp->program.Base.Parameters->ParameterValues[i];
buf[offset + i * 4 + 0] = value[0];
@@ -330,11 +332,40 @@ static void prepare_constant_buffer(struct brw_context *brw)
}
+/**
+ * Vertex/fragment shader constants are stored in a pseudo 1D texture.
+ * This function updates the constants in that buffer.
+ */
+static void
+update_texture_constant_buffer(struct brw_context *brw)
+{
+ struct intel_context *intel = &brw->intel;
+ struct brw_fragment_program *fp =
+ (struct brw_fragment_program *) brw->fragment_program;
+ const struct gl_program_parameter_list *params = fp->program.Base.Parameters;
+ const int size = params->NumParameters * 4 * sizeof(GLfloat);
+
+ assert(fp->const_buffer);
+ assert(fp->const_buffer->size >= size);
+
+ /* copy constants into the buffer */
+ if (size > 0) {
+ GLubyte *map;
+ dri_bo_map(fp->const_buffer, GL_TRUE);
+ map = fp->const_buffer->virtual;
+ memcpy(map, params->ParameterValues, size);
+ dri_bo_unmap(fp->const_buffer);
+ }
+}
+
+
static void emit_constant_buffer(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
GLuint sz = brw->curbe.total_size;
+ update_texture_constant_buffer(brw);
+
BEGIN_BATCH(2, IGNORE_CLIPRECTS);
if (sz == 0) {
OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));