summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c45
-rw-r--r--src/mesa/shader/arbprogram.c4
-rw-r--r--src/mesa/shader/grammar/grammar_crt.c10
-rw-r--r--src/mesa/shader/nvfragparse.c2
-rw-r--r--src/mesa/shader/nvprogram.c2
-rw-r--r--src/mesa/shader/prog_execute.c3
-rw-r--r--src/mesa/shader/program.c2
-rw-r--r--src/mesa/shader/shader_api.c81
-rw-r--r--src/mesa/shader/slang/slang_codegen.c6
-rw-r--r--src/mesa/shader/slang/slang_link.c197
-rw-r--r--src/mesa/shader/slang/slang_link.h8
11 files changed, 223 insertions, 137 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 26ccdc7395..f499499eb3 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -30,17 +30,38 @@
* \author Karl Rasche
*/
+/**
+Notes on program parameters, etc.
+
+The instructions we emit will use six kinds of source registers:
+
+ PROGRAM_INPUT - input registers
+ PROGRAM_TEMPORARY - temp registers
+ PROGRAM_ADDRESS - address/indirect register
+ PROGRAM_SAMPLER - texture sampler
+ PROGRAM_CONSTANT - indexes into program->Parameters, a known constant/literal
+ PROGRAM_STATE_VAR - indexes into program->Parameters, and may actually be:
+ + a state variable, like "state.fog.color", or
+ + a pointer to a "program.local[k]" parameter, or
+ + a pointer to a "program.env[k]" parameter
+
+Basically, all the program.local[] and program.env[] values will get mapped
+into the unified gl_program->Parameters array. This solves the problem of
+having three separate program parameter arrays.
+*/
+
+
#include "main/glheader.h"
#include "main/imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
#include "shader/grammar/grammar_mesa.h"
#include "arbprogparse.h"
#include "program.h"
#include "programopt.h"
#include "prog_parameter.h"
#include "prog_statevars.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
#include "prog_instruction.h"
@@ -1871,7 +1892,11 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
const_values, 4);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
- param_var->param_binding_type = PROGRAM_CONSTANT;
+ param_var->param_binding_type = PROGRAM_STATE_VAR;
+ /* Note: when we reference this parameter in an instruction later,
+ * we'll check if it's really a constant/immediate and set the
+ * instruction register type appropriately.
+ */
param_var->param_binding_length++;
Program->Base.NumParameters++;
break;
@@ -2578,6 +2603,18 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
return 1;
}
+ if (*File == PROGRAM_STATE_VAR) {
+ enum register_file file;
+
+ /* If we're referencing the Program->Parameters[] array, check if the
+ * parameter is really a constant/literal. If so, set File to CONSTANT.
+ */
+ assert(*Index < Program->Base.Parameters->NumParameters);
+ file = Program->Base.Parameters->Parameters[*Index].Type;
+ if (file == PROGRAM_CONSTANT)
+ *File = PROGRAM_CONSTANT;
+ }
+
/* Add attributes to InputsRead only if they are used the program.
* This avoids the handling of unused ATTRIB declarations in the drivers. */
if (*File == PROGRAM_INPUT)
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index beb5deea50..760dac2399 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -30,13 +30,13 @@
#include "main/glheader.h"
-#include "arbprogram.h"
-#include "arbprogparse.h"
#include "main/context.h"
#include "main/hash.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
+#include "arbprogram.h"
+#include "arbprogparse.h"
#include "program.h"
diff --git a/src/mesa/shader/grammar/grammar_crt.c b/src/mesa/shader/grammar/grammar_crt.c
index bdf2da9b2e..d2c95d1c8e 100644
--- a/src/mesa/shader/grammar/grammar_crt.c
+++ b/src/mesa/shader/grammar/grammar_crt.c
@@ -10,17 +10,17 @@ void grammar_alloc_free (void *ptr)
free (ptr);
}
-void *grammar_alloc_malloc (unsigned int size)
+void *grammar_alloc_malloc (size_t size)
{
return malloc (size);
}
-void *grammar_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
+void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
{
return realloc (ptr, size);
}
-void *grammar_memory_copy (void *dst, const void * src, unsigned int size)
+void *grammar_memory_copy (void *dst, const void * src, size_t size)
{
return memcpy (dst, src, size);
}
@@ -30,7 +30,7 @@ int grammar_string_compare (const byte *str1, const byte *str2)
return strcmp ((const char *) str1, (const char *) str2);
}
-int grammar_string_compare_n (const byte *str1, const byte *str2, unsigned int n)
+int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
{
return strncmp ((const char *) str1, (const char *) str2, n);
}
@@ -40,7 +40,7 @@ byte *grammar_string_copy (byte *dst, const byte *src)
return (byte *) strcpy ((char *) dst, (const char *) src);
}
-byte *grammar_string_copy_n (byte *dst, const byte *src, unsigned int n)
+byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
{
return (byte *) strncpy ((char *) dst, (const char *) src, n);
}
diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c
index a2a7a5f3f4..20e4781372 100644
--- a/src/mesa/shader/nvfragparse.c
+++ b/src/mesa/shader/nvfragparse.c
@@ -41,10 +41,10 @@
#include "main/context.h"
#include "main/imports.h"
#include "main/macros.h"
+#include "program.h"
#include "prog_parameter.h"
#include "prog_instruction.h"
#include "nvfragparse.h"
-#include "program.h"
#define INPUT_1V 1
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index d656d4b28b..88272fff3f 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -42,12 +42,12 @@
#include "main/hash.h"
#include "main/imports.h"
#include "main/macros.h"
+#include "program.h"
#include "prog_parameter.h"
#include "prog_instruction.h"
#include "nvfragparse.h"
#include "nvvertparse.h"
#include "nvprogram.h"
-#include "program.h"
diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c
index 32b6ff4fd4..23648f3f4c 100644
--- a/src/mesa/shader/prog_execute.c
+++ b/src/mesa/shader/prog_execute.c
@@ -81,11 +81,12 @@ get_register_pointer(const struct prog_src_register *source,
{
if (source->RelAddr) {
const GLint reg = source->Index + machine->AddressReg[0][0];
- if (source->File == PROGRAM_ENV_PARAM)
+ if (source->File == PROGRAM_ENV_PARAM) {
if (reg < 0 || reg >= MAX_PROGRAM_ENV_PARAMS)
return ZeroVec;
else
return machine->EnvParams[reg];
+ }
else {
const struct gl_program_parameter_list *params;
ASSERT(source->File == PROGRAM_LOCAL_PARAM ||
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 6263fd277f..f120c20bdf 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -517,7 +517,7 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count)
for (i = 0; i < prog->NumInstructions; i++) {
struct prog_instruction *inst = prog->Instructions + i;
if (inst->BranchTarget > 0) {
- if (inst->BranchTarget >= start) {
+ if ((GLuint)inst->BranchTarget >= start) {
inst->BranchTarget += count;
}
}
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index d8b210be53..854f8bfdaa 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 2004-2008 Brian Paul All Rights Reserved.
*
@@ -39,11 +39,11 @@
#include "main/context.h"
#include "main/hash.h"
#include "main/macros.h"
-#include "program.h"
-#include "prog_parameter.h"
-#include "prog_print.h"
-#include "prog_statevars.h"
-#include "prog_uniform.h"
+#include "shader/program.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/prog_statevars.h"
+#include "shader/prog_uniform.h"
#include "shader/shader_api.h"
#include "shader/slang/slang_compile.h"
#include "shader/slang/slang_link.h"
@@ -497,10 +497,14 @@ _mesa_get_attrib_location(GLcontext *ctx, GLuint program,
if (!name)
return -1;
- if (shProg->Attributes) {
- GLint i = _mesa_lookup_parameter_index(shProg->Attributes, -1, name);
- if (i >= 0) {
- return shProg->Attributes->Parameters[i].StateIndexes[0];
+ if (shProg->VertexProgram) {
+ const struct gl_program_parameter_list *attribs =
+ shProg->VertexProgram->Base.Attributes;
+ if (attribs) {
+ GLint i = _mesa_lookup_parameter_index(attribs, -1, name);
+ if (i >= 0) {
+ return attribs->Parameters[i].StateIndexes[0];
+ }
}
}
return -1;
@@ -551,12 +555,10 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
return;
}
- if (shProg->VertexProgram && oldIndex >= 0 && oldIndex != index) {
- /* If the index changed, need to search/replace references to that attribute
- * in the vertex program.
- */
- _slang_remap_attribute(&shProg->VertexProgram->Base, oldIndex, index);
- }
+ /*
+ * Note that this attribute binding won't go into effect until
+ * glLinkProgram is called again.
+ */
}
@@ -798,24 +800,29 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index,
GLsizei maxLength, GLsizei *length, GLint *size,
GLenum *type, GLchar *nameOut)
{
+ const struct gl_program_parameter_list *attribs = NULL;
struct gl_shader_program *shProg;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib");
if (!shProg)
return;
- if (!shProg->Attributes || index >= shProg->Attributes->NumParameters) {
+ if (shProg->VertexProgram)
+ attribs = shProg->VertexProgram->Base.Attributes;
+
+ if (!attribs || index >= attribs->NumParameters) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)");
return;
}
- copy_string(nameOut, maxLength, length,
- shProg->Attributes->Parameters[index].Name);
+ copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name);
+
if (size)
- *size = shProg->Attributes->Parameters[index].Size
- / sizeof_glsl_type(shProg->Attributes->Parameters[index].DataType);
+ *size = attribs->Parameters[index].Size
+ / sizeof_glsl_type(attribs->Parameters[index].DataType);
+
if (type)
- *type = shProg->Attributes->Parameters[index].DataType;
+ *type = attribs->Parameters[index].DataType;
}
@@ -937,6 +944,7 @@ static void
_mesa_get_programiv(GLcontext *ctx, GLuint program,
GLenum pname, GLint *params)
{
+ const struct gl_program_parameter_list *attribs;
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
@@ -945,6 +953,11 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program,
return;
}
+ if (shProg->VertexProgram)
+ attribs = shProg->VertexProgram->Base.Attributes;
+ else
+ attribs = NULL;
+
switch (pname) {
case GL_DELETE_STATUS:
*params = shProg->DeletePending;
@@ -962,11 +975,10 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program,
*params = shProg->NumShaders;
break;
case GL_ACTIVE_ATTRIBUTES:
- *params = shProg->Attributes ? shProg->Attributes->NumParameters : 0;
+ *params = attribs ? attribs->NumParameters : 0;
break;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
- *params = _mesa_longest_parameter_name(shProg->Attributes,
- PROGRAM_INPUT) + 1;
+ *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1;
break;
case GL_ACTIVE_UNIFORMS:
*params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0;
@@ -1108,7 +1120,8 @@ get_matrix_dims(GLenum type, GLint *rows, GLint *cols)
/**
* Determine the number of rows and columns occupied by a uniform
- * according to its datatype.
+ * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4),
+ * the number of rows = 1 and cols = number of elements in the vector.
*/
static void
get_uniform_rows_cols(const struct gl_program_parameter *p,
@@ -1117,11 +1130,17 @@ get_uniform_rows_cols(const struct gl_program_parameter *p,
get_matrix_dims(p->DataType, rows, cols);
if (*rows == 0 && *cols == 0) {
/* not a matrix type, probably a float or vector */
- *rows = p->Size / 4 + 1;
- if (p->Size % 4 == 0)
- *cols = 4;
- else
- *cols = p->Size % 4;
+ if (p->Size <= 4) {
+ *rows = 1;
+ *cols = p->Size;
+ }
+ else {
+ *rows = p->Size / 4 + 1;
+ if (p->Size % 4 == 0)
+ *cols = 4;
+ else
+ *cols = p->Size % 4;
+ }
}
}
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 7006e86958..72a3c0ef9e 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2439,7 +2439,11 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var)
/*assert(!var->declared);*/
var->declared = GL_TRUE;
- assert(!is_sampler_type(&var->type));
+ if(is_sampler_type(&var->type)) {
+ slang_info_log_error(A->log, "redeclaration of sampler '%s'",
+ (char*) var->a_name);
+ return NULL;
+ }
n = new_node0(IR_VAR_DECL);
if (n) {
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 57dbfc2388..d884be2a75 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.2
*
- * Copyright (C) 2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -42,6 +42,24 @@
#include "slang_link.h"
+/** cast wrapper */
+static struct gl_vertex_program *
+vertex_program(struct gl_program *prog)
+{
+ assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
+ return (struct gl_vertex_program *) prog;
+}
+
+
+/** cast wrapper */
+static struct gl_fragment_program *
+fragment_program(struct gl_program *prog)
+{
+ assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
+ return (struct gl_fragment_program *) prog;
+}
+
+
/**
* Record a linking error.
*/
@@ -215,74 +233,112 @@ link_uniform_vars(struct gl_shader_program *shProg,
* For example, if the vertex shader declared "attribute vec4 foobar" we'll
* allocate a generic vertex attribute for "foobar" and plug that value into
* the vertex program instructions.
+ * But if the user called glBindAttributeLocation(), those bindings will
+ * have priority.
*/
static GLboolean
_slang_resolve_attributes(struct gl_shader_program *shProg,
- struct gl_program *prog)
+ const struct gl_program *origProg,
+ struct gl_program *linkedProg)
{
+ GLint attribMap[MAX_VERTEX_ATTRIBS];
GLuint i, j;
GLbitfield usedAttributes;
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
+ assert(origProg != linkedProg);
+ assert(origProg->Target == GL_VERTEX_PROGRAM_ARB);
+ assert(linkedProg->Target == GL_VERTEX_PROGRAM_ARB);
if (!shProg->Attributes)
shProg->Attributes = _mesa_new_parameter_list();
+ if (linkedProg->Attributes) {
+ _mesa_free_parameter_list(linkedProg->Attributes);
+ }
+ linkedProg->Attributes = _mesa_new_parameter_list();
+
+
/* Build a bitmask indicating which attribute indexes have been
* explicitly bound by the user with glBindAttributeLocation().
*/
usedAttributes = 0x0;
for (i = 0; i < shProg->Attributes->NumParameters; i++) {
GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0];
- usedAttributes |= attr;
+ usedAttributes |= (1 << attr);
+ }
+
+ /* initialize the generic attribute map entries to -1 */
+ for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+ attribMap[i] = -1;
}
/*
* Scan program for generic attribute references
*/
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < linkedProg->NumInstructions; i++) {
+ struct prog_instruction *inst = linkedProg->Instructions + i;
for (j = 0; j < 3; j++) {
if (inst->SrcReg[j].File == PROGRAM_INPUT &&
inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) {
- /* this is a generic attrib */
- const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0;
- const char *name = prog->Attributes->Parameters[k].Name;
- /* See if this attrib name is in the program's attribute list
- * (i.e. was bound by the user).
+ /*
+ * OK, we've found a generic vertex attribute reference.
*/
- GLint index = _mesa_lookup_parameter_index(shProg->Attributes,
- -1, name);
- GLint attr;
- if (index >= 0) {
- /* found, user must have specified a binding */
- attr = shProg->Attributes->Parameters[index].StateIndexes[0];
- }
- else {
- /* Not found, choose our own attribute number.
- * Start at 1 since generic attribute 0 always aliases
- * glVertex/position.
+ const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0;
+
+ GLint attr = attribMap[k];
+
+ if (attr < 0) {
+ /* Need to figure out attribute mapping now.
+ */
+ const char *name = origProg->Attributes->Parameters[k].Name;
+ const GLint size = origProg->Attributes->Parameters[k].Size;
+ const GLenum type =origProg->Attributes->Parameters[k].DataType;
+ GLint index;
+
+ /* See if there's a user-defined attribute binding for
+ * this name.
*/
- GLint size = prog->Attributes->Parameters[k].Size;
- GLenum datatype = prog->Attributes->Parameters[k].DataType;
- for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
- if (((1 << attr) & usedAttributes) == 0)
- break;
+ index = _mesa_lookup_parameter_index(shProg->Attributes,
+ -1, name);
+ if (index >= 0) {
+ /* Found a user-defined binding */
+ attr = shProg->Attributes->Parameters[index].StateIndexes[0];
}
- if (attr == MAX_VERTEX_ATTRIBS) {
- /* too many! XXX record error log */
- return GL_FALSE;
+ else {
+ /* No user-defined binding, choose our own attribute number.
+ * Start at 1 since generic attribute 0 always aliases
+ * glVertex/position.
+ */
+ for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
+ if (((1 << attr) & usedAttributes) == 0)
+ break;
+ }
+ if (attr == MAX_VERTEX_ATTRIBS) {
+ link_error(shProg, "Too many vertex attributes");
+ return GL_FALSE;
+ }
+
+ /* mark this attribute as used */
+ usedAttributes |= (1 << attr);
}
- _mesa_add_attribute(shProg->Attributes, name, size, datatype,attr);
- /* set the attribute as used */
- usedAttributes |= 1<<attr;
+ attribMap[k] = attr;
+
+ /* Save the final name->attrib binding so it can be queried
+ * with glGetAttributeLocation().
+ */
+ _mesa_add_attribute(linkedProg->Attributes, name,
+ size, type, attr);
}
+ assert(attr >= 0);
+
+ /* update the instruction's src reg */
inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr;
}
}
}
+
return GL_TRUE;
}
@@ -325,6 +381,7 @@ static void
_slang_update_inputs_outputs(struct gl_program *prog)
{
GLuint i, j;
+ GLuint maxAddrReg = 0;
prog->InputsRead = 0x0;
prog->OutputsWritten = 0x0;
@@ -335,60 +392,33 @@ _slang_update_inputs_outputs(struct gl_program *prog)
for (j = 0; j < numSrc; j++) {
if (inst->SrcReg[j].File == PROGRAM_INPUT) {
prog->InputsRead |= 1 << inst->SrcReg[j].Index;
+ if (prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
+ inst->SrcReg[j].Index == FRAG_ATTRIB_FOGC) {
+ /* The fragment shader FOGC input is used for fog,
+ * front-facing and sprite/point coord.
+ */
+ struct gl_fragment_program *fp = fragment_program(prog);
+ const GLint swz = GET_SWZ(inst->SrcReg[j].Swizzle, 0);
+ if (swz == SWIZZLE_X)
+ fp->UsesFogFragCoord = GL_TRUE;
+ else if (swz == SWIZZLE_Y)
+ fp->UsesFrontFacing = GL_TRUE;
+ else if (swz == SWIZZLE_Z || swz == SWIZZLE_W)
+ fp->UsesPointCoord = GL_TRUE;
+ }
+ }
+ else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) {
+ maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1);
}
}
if (inst->DstReg.File == PROGRAM_OUTPUT) {
prog->OutputsWritten |= 1 << inst->DstReg.Index;
}
- }
-}
-
-
-/**
- * Scan a vertex program looking for instances of
- * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + oldAttrib) and replace with
- * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + newAttrib).
- * This is used when the user calls glBindAttribLocation on an already linked
- * shader program.
- */
-void
-_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, GLuint newAttrib)
-{
- GLuint i, j;
-
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
-
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
- for (j = 0; j < 3; j++) {
- if (inst->SrcReg[j].File == PROGRAM_INPUT) {
- if (inst->SrcReg[j].Index == VERT_ATTRIB_GENERIC0 + oldAttrib) {
- inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + newAttrib;
- }
- }
+ else if (inst->DstReg.File == PROGRAM_ADDRESS) {
+ maxAddrReg = MAX2(maxAddrReg, inst->DstReg.Index + 1);
}
}
-
- _slang_update_inputs_outputs(prog);
-}
-
-
-
-/** cast wrapper */
-static struct gl_vertex_program *
-vertex_program(struct gl_program *prog)
-{
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
- return (struct gl_vertex_program *) prog;
-}
-
-
-/** cast wrapper */
-static struct gl_fragment_program *
-fragment_program(struct gl_program *prog)
-{
- assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
- return (struct gl_fragment_program *) prog;
+ prog->NumAddressRegs = maxAddrReg;
}
@@ -492,9 +522,8 @@ _slang_link(GLcontext *ctx,
/*_mesa_print_uniforms(shProg->Uniforms);*/
if (shProg->VertexProgram) {
- if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) {
- /*goto cleanup;*/
- _mesa_problem(ctx, "_slang_resolve_attributes() failed");
+ if (!_slang_resolve_attributes(shProg, &vertProg->Base,
+ &shProg->VertexProgram->Base)) {
return;
}
}
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 8ef8a6b4b3..2b44d20787 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.2
*
- * Copyright (C) 2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,10 +32,6 @@ extern void
_slang_link(GLcontext *ctx, GLhandleARB h,
struct gl_shader_program *shProg);
-extern void
-_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib,
- GLuint newAttrib);
-
#endif