summaryrefslogtreecommitdiff
path: root/src/mesa/shader/nvprogram.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/nvprogram.c')
-rw-r--r--src/mesa/shader/nvprogram.c103
1 files changed, 92 insertions, 11 deletions
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index 5142c2a4a5..471a7358a2 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -354,6 +354,7 @@ _mesa_GetTrackMatrixivNV(GLenum target, GLuint address,
void GLAPIENTRY
_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
{
+ const struct gl_client_array *array;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -362,15 +363,17 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
return;
}
+ array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Size;
+ params[0] = array->Size;
break;
case GL_ATTRIB_ARRAY_STRIDE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+ params[0] = array->Stride;
break;
case GL_ATTRIB_ARRAY_TYPE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Type;
+ params[0] = array->Type;
break;
case GL_CURRENT_ATTRIB_NV:
if (index == 0) {
@@ -395,6 +398,7 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
void GLAPIENTRY
_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
{
+ const struct gl_client_array *array;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -403,15 +407,17 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
return;
}
+ array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
- params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Size;
+ params[0] = (GLfloat) array->Size;
break;
case GL_ATTRIB_ARRAY_STRIDE_NV:
- params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+ params[0] = (GLfloat) array->Stride;
break;
case GL_ATTRIB_ARRAY_TYPE_NV:
- params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Type;
+ params[0] = (GLfloat) array->Type;
break;
case GL_CURRENT_ATTRIB_NV:
if (index == 0) {
@@ -436,6 +442,7 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
void GLAPIENTRY
_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
{
+ const struct gl_client_array *array;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -444,15 +451,17 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
return;
}
+ array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Size;
+ params[0] = array->Size;
break;
case GL_ATTRIB_ARRAY_STRIDE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+ params[0] = array->Stride;
break;
case GL_ATTRIB_ARRAY_TYPE_NV:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Type;
+ params[0] = array->Type;
break;
case GL_CURRENT_ATTRIB_NV:
if (index == 0) {
@@ -467,7 +476,7 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
params[3] = (GLint) ctx->Current.Attrib[index][3];
break;
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
- params[0] = ctx->Array.ArrayObj->VertexAttrib[index].BufferObj->Name;
+ params[0] = array->BufferObj->Name;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
@@ -500,7 +509,79 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer)
*pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
}
+void
+_mesa_emit_nv_temp_initialization(GLcontext *ctx,
+ struct gl_program *program)
+{
+ struct prog_instruction *inst;
+ int i;
+ if (!ctx->Shader.EmitNVTempInitialization)
+ return;
+
+ /* We'll swizzle up a zero temporary so we can use it for the
+ * ARL.
+ */
+ if (program->NumTemporaries == 0)
+ program->NumTemporaries = 1;
+
+ _mesa_insert_instructions(program, 0, program->NumTemporaries + 1);
+
+ for (i = 0; i < program->NumTemporaries; i++) {
+ struct prog_instruction *inst = &program->Instructions[i];
+
+ inst->Opcode = OPCODE_SWZ;
+ inst->DstReg.File = PROGRAM_TEMPORARY;
+ inst->DstReg.Index = i;
+ inst->DstReg.WriteMask = WRITEMASK_XYZW;
+ inst->SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst->SrcReg[0].Index = 0;
+ inst->SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO,
+ SWIZZLE_ZERO,
+ SWIZZLE_ZERO,
+ SWIZZLE_ZERO);
+ }
+
+ inst = &program->Instructions[i];
+ inst->Opcode = OPCODE_ARL;
+ inst->DstReg.File = PROGRAM_ADDRESS;
+ inst->DstReg.Index = 0;
+ inst->DstReg.WriteMask = WRITEMASK_XYZW;
+ inst->SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst->SrcReg[0].Index = 0;
+ inst->SrcReg[0].Swizzle = SWIZZLE_XXXX;
+
+ if (program->NumAddressRegs == 0)
+ program->NumAddressRegs = 1;
+}
+
+void
+_mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program)
+{
+ int i;
+
+ program->NumTemporaries = 0;
+ for (i = 0; i < program->NumInstructions; i++) {
+ struct prog_instruction *inst = &program->Instructions[i];
+
+ if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+ program->NumTemporaries = MAX2(program->NumTemporaries,
+ inst->DstReg.Index + 1);
+ }
+ if (inst->SrcReg[0].File == PROGRAM_TEMPORARY) {
+ program->NumTemporaries = MAX2(program->NumTemporaries,
+ inst->SrcReg[0].Index + 1);
+ }
+ if (inst->SrcReg[1].File == PROGRAM_TEMPORARY) {
+ program->NumTemporaries = MAX2(program->NumTemporaries,
+ inst->SrcReg[1].Index + 1);
+ }
+ if (inst->SrcReg[2].File == PROGRAM_TEMPORARY) {
+ program->NumTemporaries = MAX2(program->NumTemporaries,
+ inst->SrcReg[2].Index + 1);
+ }
+ }
+}
/**
* Load/parse/compile a program.
@@ -706,7 +787,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
prog = _mesa_lookup_program(ctx, id);
if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {