/* 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 );
+ }
}
/* 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;
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];
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;
*/
#include "util/u_memory.h"
+#include "util/u_math.h"
#include "brw_debug.h"
#include "brw_wm.h"
}
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__);
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.
}
-/** 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
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: