summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/i965/brw_curbe.c30
-rw-r--r--src/gallium/drivers/i965/brw_wm.h9
-rw-r--r--src/gallium/drivers/i965/brw_wm_pass0.c48
3 files changed, 34 insertions, 53 deletions
diff --git a/src/gallium/drivers/i965/brw_curbe.c b/src/gallium/drivers/i965/brw_curbe.c
index 3e821d5afee..3f031577d5a 100644
--- a/src/gallium/drivers/i965/brw_curbe.c
+++ b/src/gallium/drivers/i965/brw_curbe.c
@@ -182,16 +182,32 @@ static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
/* fragment shader constants */
if (brw->curbe.wm_size) {
+ const struct brw_fragment_shader *fs = brw->curr.fragment_shader;
GLuint offset = brw->curbe.wm_start * 16;
- unsigned nr = brw->wm.prog_data->nr_params;
+ GLuint nr_immediate, nr_const;
+
+ nr_immediate = fs->immediates.nr;
+ if (nr_immediate) {
+ memcpy(&buf[offset],
+ fs->immediates.data,
+ nr_immediate * 4 * sizeof(float));
- const GLfloat *value = screen->buffer_map( screen,
- brw->curr.fragment_constants,
- PIPE_BUFFER_USAGE_CPU_READ);
+ offset += nr_immediate * 4;
+ }
- memcpy(&buf[offset], value, nr * 4 * sizeof(float));
+ nr_const = fs->info.file_max[TGSI_FILE_CONSTANT] + 1;
+/* nr_const = brw->wm.prog_data->nr_params; */
+ if (nr_const) {
+ const GLfloat *value = screen->buffer_map( screen,
+ brw->curr.fragment_constants,
+ PIPE_BUFFER_USAGE_CPU_READ);
- screen->buffer_unmap( screen, brw->curr.fragment_constants );
+ memcpy(&buf[offset], value,
+ nr_const * 4 * sizeof(float));
+
+ screen->buffer_unmap( screen,
+ brw->curr.fragment_constants );
+ }
}
@@ -226,7 +242,7 @@ static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
/* vertex shader constants */
if (brw->curbe.vs_size) {
GLuint offset = brw->curbe.vs_start * 16;
- struct brw_vertex_shader *vs = brw->curr.vertex_shader;
+ const struct brw_vertex_shader *vs = brw->curr.vertex_shader;
GLuint nr_immediate, nr_const;
nr_immediate = vs->immediates.nr;
diff --git a/src/gallium/drivers/i965/brw_wm.h b/src/gallium/drivers/i965/brw_wm.h
index f85a8af878d..b7d807dcb35 100644
--- a/src/gallium/drivers/i965/brw_wm.h
+++ b/src/gallium/drivers/i965/brw_wm.h
@@ -129,12 +129,6 @@ struct brw_wm_ref {
GLuint insn:24;
};
-struct brw_wm_imm_ref {
- const struct brw_wm_ref *ref;
- GLfloat imm1f;
-};
-
-
struct brw_wm_instruction {
struct brw_wm_value *dst[4];
struct brw_wm_ref *src[3][4];
@@ -272,9 +266,6 @@ struct brw_wm_compile {
struct brw_wm_instruction instruction[BRW_WM_MAX_INSN];
GLuint nr_insns;
- struct brw_wm_imm_ref imm_ref[BRW_WM_MAX_CONST];
- GLuint nr_imm_refs;
-
struct brw_wm_grf pass2_grf[BRW_WM_MAX_GRF/2];
GLuint grf_limit;
diff --git a/src/gallium/drivers/i965/brw_wm_pass0.c b/src/gallium/drivers/i965/brw_wm_pass0.c
index 7bb341e2c2c..0bacad2b0f0 100644
--- a/src/gallium/drivers/i965/brw_wm_pass0.c
+++ b/src/gallium/drivers/i965/brw_wm_pass0.c
@@ -30,6 +30,7 @@
*/
#include "util/u_memory.h"
+#include "util/u_math.h"
#include "brw_debug.h"
#include "brw_wm.h"
@@ -97,9 +98,10 @@ static void pass0_set_fpreg_ref( struct brw_wm_compile *c,
}
static const struct brw_wm_ref *get_param_ref( struct brw_wm_compile *c,
- const GLfloat *param_ptr )
+ unsigned idx,
+ unsigned component)
{
- GLuint i = c->prog_data.nr_params++;
+ GLuint i = idx * 4 + component;
if (i >= BRW_WM_MAX_PARAM) {
debug_printf("%s: out of params\n", __FUNCTION__);
@@ -109,8 +111,7 @@ static const struct brw_wm_ref *get_param_ref( struct brw_wm_compile *c,
else {
struct brw_wm_ref *ref = get_ref(c);
- c->prog_data.param[i] = param_ptr;
- c->nr_creg = (i+16)/16;
+ c->nr_creg = MAX2(c->nr_creg, (i+16)/16);
/* Push the offsets into hw_reg. These will be added to the
* real register numbers once one is allocated in pass2.
@@ -125,37 +126,6 @@ static const struct brw_wm_ref *get_param_ref( struct brw_wm_compile *c,
}
-/** Return a ref to an immediate value */
-static const struct brw_wm_ref *get_imm_ref( struct brw_wm_compile *c,
- const GLfloat *imm1f )
-{
- GLuint i;
-
- /* Search for an existing const value matching the request:
- */
- for (i = 0; i < c->nr_imm_refs; i++) {
- if (c->imm_ref[i].imm1f == *imm1f)
- return c->imm_ref[i].ref;
- }
-
- /* Else try to add a new one:
- */
- if (c->nr_imm_refs < Elements(c->imm_ref)) {
- GLuint i = c->nr_imm_refs++;
-
- /* An immediate is a special type of parameter:
- */
- c->imm_ref[i].imm1f = *imm1f;
- c->imm_ref[i].ref = get_param_ref(c, imm1f);
-
- return c->imm_ref[i].ref;
- }
- else {
- debug_printf("%s: out of imm_refs\n", __FUNCTION__);
- c->prog_data.error = 1;
- return NULL;
- }
-}
/* Lookup our internal registers
@@ -177,11 +147,15 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
break;
case TGSI_FILE_CONSTANT:
- ref = get_param_ref(c, &c->env_param[idx][component]);
+ ref = get_param_ref(c,
+ c->fp->info.immediate_count + idx,
+ component);
break;
case TGSI_FILE_IMMEDIATE:
- ref = get_imm_ref(c, &c->immediate[idx].v[component]);
+ ref = get_param_ref(c,
+ idx,
+ component);
break;
default: