summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-03-26 10:13:02 -0600
committerBrian <[email protected]>2007-03-26 10:13:02 -0600
commitd619cceea47dc3070ebb7f7ea4f8b6b31a672d38 (patch)
treef8b8a9f3fdc3f17a43436af270b22754b1749d31 /src/mesa/drivers
parent76f3b66e0489526694d6a39b4a6ac3b1c2bee100 (diff)
parente71c34aaa173ca451fa02e526ead77758f7eeb74 (diff)
merge of glsl-compiler-1 branch
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/common/driverfuncs.c49
-rw-r--r--src/mesa/drivers/common/driverfuncs.h8
-rw-r--r--src/mesa/drivers/dri/i915/i915_context.c3
-rw-r--r--src/mesa/drivers/dri/i915/i915_fragprog.c6
-rw-r--r--src/mesa/drivers/dri/i915/i915_program.c12
-rw-r--r--src/mesa/drivers/dri/i915/i915_state.c2
-rw-r--r--src/mesa/drivers/dri/i915/i915_vtbl.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_context.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_fragprog.c6
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_program.c12
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_curbe.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_metaops.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_util.c32
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_constval.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_emit.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_tnl.c77
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_debug.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_emit.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_fp.c34
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_pass0.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_pass1.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_pass2.c4
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_native_vb.c20
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader.c5
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_0.c16
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_2.c3
-rw-r--r--src/mesa/drivers/dri/r200/r200_vertprog.c10
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c5
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.h5
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c8
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c10
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tritmp.h46
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tris.c16
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.h2
-rw-r--r--src/mesa/drivers/glslcompiler/Makefile44
-rw-r--r--src/mesa/drivers/glslcompiler/glslcompiler.c358
44 files changed, 641 insertions, 207 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 1e44904b930..f543de183a1 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 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"),
@@ -30,6 +30,7 @@
#include "framebuffer.h"
#include "occlude.h"
#include "program.h"
+#include "prog_execute.h"
#include "renderbuffer.h"
#include "texcompress.h"
#include "texformat.h"
@@ -43,6 +44,7 @@
#include "fbobject.h"
#include "texrender.h"
#endif
+#include "shader_api.h"
#include "arrayobj.h"
#include "driverfuncs.h"
@@ -127,7 +129,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->NewProgram = _mesa_new_program;
driver->DeleteProgram = _mesa_delete_program;
#if FEATURE_MESA_program_debug
- driver->GetFragmentProgramRegister = _swrast_get_program_register;
+ driver->GetProgramRegister = _mesa_get_program_register;
#endif /* FEATURE_MESA_program_debug */
/* simple state commands */
@@ -248,4 +250,45 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->EndList = NULL;
driver->BeginCallList = NULL;
driver->EndCallList = NULL;
+
+
+ /* XXX temporary here */
+ _mesa_init_glsl_driver_functions(driver);
+}
+
+
+/**
+ * Plug in Mesa's GLSL functions.
+ */
+void
+_mesa_init_glsl_driver_functions(struct dd_function_table *driver)
+{
+ driver->AttachShader = _mesa_attach_shader;
+ driver->BindAttribLocation = _mesa_bind_attrib_location;
+ driver->CompileShader = _mesa_compile_shader;
+ driver->CreateProgram = _mesa_create_program;
+ driver->CreateShader = _mesa_create_shader;
+ driver->DeleteProgram2 = _mesa_delete_program2;
+ driver->DeleteShader = _mesa_delete_shader;
+ driver->DetachShader = _mesa_detach_shader;
+ driver->GetActiveAttrib = _mesa_get_active_attrib;
+ driver->GetActiveUniform = _mesa_get_active_uniform;
+ driver->GetAttachedShaders = _mesa_get_attached_shaders;
+ driver->GetAttribLocation = _mesa_get_attrib_location;
+ driver->GetHandle = _mesa_get_handle;
+ driver->GetProgramiv = _mesa_get_programiv;
+ driver->GetProgramInfoLog = _mesa_get_program_info_log;
+ driver->GetShaderiv = _mesa_get_shaderiv;
+ driver->GetShaderInfoLog = _mesa_get_shader_info_log;
+ driver->GetShaderSource = _mesa_get_shader_source;
+ driver->GetUniformfv = _mesa_get_uniformfv;
+ driver->GetUniformLocation = _mesa_get_uniform_location;
+ driver->IsProgram = _mesa_is_program;
+ driver->IsShader = _mesa_is_shader;
+ driver->LinkProgram = _mesa_link_program;
+ driver->ShaderSource = _mesa_shader_source;
+ driver->Uniform = _mesa_uniform;
+ driver->UniformMatrix = _mesa_uniform_matrix;
+ driver->UseProgram = _mesa_use_program;
+ driver->ValidateProgram = _mesa_validate_program;
}
diff --git a/src/mesa/drivers/common/driverfuncs.h b/src/mesa/drivers/common/driverfuncs.h
index 64f56d91f95..50f2b4271dc 100644
--- a/src/mesa/drivers/common/driverfuncs.h
+++ b/src/mesa/drivers/common/driverfuncs.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 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"),
@@ -29,4 +29,8 @@
extern void
_mesa_init_driver_functions(struct dd_function_table *driver);
+
+extern void
+_mesa_init_glsl_driver_functions(struct dd_function_table *driver);
+
#endif
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 6ec34e5bdef..4ab9d2686cb 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -167,8 +167,7 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
I915_MAX_TEX_INSN);
ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
- ctx->_MaintainTexEnvProgram = 1;
- ctx->_UseTexEnvProgram = 1;
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
driInitExtensions( ctx, i915_extensions, GL_FALSE );
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c
index ef14f3eef7c..a28c8bb6fc2 100644
--- a/src/mesa/drivers/dri/i915/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -37,7 +37,8 @@
#include "i915_context.h"
#include "i915_program.h"
-#include "program_instruction.h"
+#include "prog_instruction.h"
+#include "prog_parameter.h"
#include "program.h"
#include "programopt.h"
@@ -782,9 +783,6 @@ static void fixup_depth_write( struct i915_fragment_program *p )
}
-#define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n))
-
-
static void check_wpos( struct i915_fragment_program *p )
{
GLuint inputs = p->FragProg.Base.InputsRead;
diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c
index 9c13290d118..68491124449 100644
--- a/src/mesa/drivers/dri/i915/i915_program.c
+++ b/src/mesa/drivers/dri/i915/i915_program.c
@@ -430,17 +430,17 @@ void i915_fini_program( struct i915_fragment_program *p )
if (p->error) {
p->FragProg.Base.NumNativeInstructions = 0;
- p->FragProg.NumNativeAluInstructions = 0;
- p->FragProg.NumNativeTexInstructions = 0;
- p->FragProg.NumNativeTexIndirections = 0;
+ p->FragProg.Base.NumNativeAluInstructions = 0;
+ p->FragProg.Base.NumNativeTexInstructions = 0;
+ p->FragProg.Base.NumNativeTexIndirections = 0;
}
else {
p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +
p->nr_tex_insn +
p->nr_decl_insn);
- p->FragProg.NumNativeAluInstructions = p->nr_alu_insn;
- p->FragProg.NumNativeTexInstructions = p->nr_tex_insn;
- p->FragProg.NumNativeTexIndirections = p->nr_tex_indirect;
+ p->FragProg.Base.NumNativeAluInstructions = p->nr_alu_insn;
+ p->FragProg.Base.NumNativeTexInstructions = p->nr_tex_insn;
+ p->FragProg.Base.NumNativeTexIndirections = p->nr_tex_indirect;
}
p->declarations[0] |= program_size + decl_size - 2;
diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index 5e00e6597b0..d126208ce05 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -531,7 +531,7 @@ void i915_update_fog( GLcontext *ctx )
GLboolean enabled;
GLboolean try_pixel_fog;
- if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Enabled) {
/* Pull in static fog state from program */
mode = ctx->FragmentProgram._Current->FogOption;
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index b533e153beb..c920fc47ea0 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -46,10 +46,10 @@ static void i915_render_start( intelContextPtr intel )
GLcontext *ctx = &intel->ctx;
i915ContextPtr i915 = I915_CONTEXT(intel);
- if (ctx->FragmentProgram._Active)
+ if (ctx->FragmentProgram._Current)
i915ValidateFragmentProgram( i915 );
else {
- assert(!ctx->_MaintainTexEnvProgram);
+ assert(!ctx->FragmentProgram._MaintainTexEnvProgram);
i915ValidateTextureProgram( i915 );
}
}
diff --git a/src/mesa/drivers/dri/i915tex/i915_context.c b/src/mesa/drivers/dri/i915tex/i915_context.c
index 9b4d72eab3e..d4187238f3c 100644
--- a/src/mesa/drivers/dri/i915tex/i915_context.c
+++ b/src/mesa/drivers/dri/i915tex/i915_context.c
@@ -157,8 +157,8 @@ i915CreateContext(const __GLcontextModes * mesaVis,
I915_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
- ctx->_MaintainTexEnvProgram = 1;
- ctx->_UseTexEnvProgram = 1;
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+ /*ctx->_UseTexEnvProgram = 1;*/
driInitExtensions(ctx, i915_extensions, GL_FALSE);
diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c
index 8772e702307..cbea6092a81 100644
--- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c
@@ -37,7 +37,8 @@
#include "i915_context.h"
#include "i915_program.h"
-#include "program_instruction.h"
+#include "prog_instruction.h"
+#include "prog_parameter.h"
#include "program.h"
#include "programopt.h"
@@ -772,9 +773,6 @@ fixup_depth_write(struct i915_fragment_program *p)
}
-#define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n))
-
-
static void
check_wpos(struct i915_fragment_program *p)
{
diff --git a/src/mesa/drivers/dri/i915tex/i915_program.c b/src/mesa/drivers/dri/i915tex/i915_program.c
index 0be89d33206..ed45e4f8069 100644
--- a/src/mesa/drivers/dri/i915tex/i915_program.c
+++ b/src/mesa/drivers/dri/i915tex/i915_program.c
@@ -446,17 +446,17 @@ i915_fini_program(struct i915_fragment_program *p)
if (p->error) {
p->FragProg.Base.NumNativeInstructions = 0;
- p->FragProg.NumNativeAluInstructions = 0;
- p->FragProg.NumNativeTexInstructions = 0;
- p->FragProg.NumNativeTexIndirections = 0;
+ p->FragProg.Base.NumNativeAluInstructions = 0;
+ p->FragProg.Base.NumNativeTexInstructions = 0;
+ p->FragProg.Base.NumNativeTexIndirections = 0;
}
else {
p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +
p->nr_tex_insn +
p->nr_decl_insn);
- p->FragProg.NumNativeAluInstructions = p->nr_alu_insn;
- p->FragProg.NumNativeTexInstructions = p->nr_tex_insn;
- p->FragProg.NumNativeTexIndirections = p->nr_tex_indirect;
+ p->FragProg.Base.NumNativeAluInstructions = p->nr_alu_insn;
+ p->FragProg.Base.NumNativeTexInstructions = p->nr_tex_insn;
+ p->FragProg.Base.NumNativeTexIndirections = p->nr_tex_indirect;
}
p->declarations[0] |= program_size + decl_size - 2;
diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c
index 1fafadced02..c2c2ff366f1 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state.c
@@ -561,7 +561,7 @@ i915_update_fog(GLcontext * ctx)
GLboolean enabled;
GLboolean try_pixel_fog;
- if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Enabled) {
/* Pull in static fog state from program */
mode = ctx->FragmentProgram._Current->FogOption;
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 6faee65542b..397a9bd3f5c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -148,7 +148,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
brw->emit_state_always = 0;
- ctx->_MaintainTexEnvProgram = 1;
+ ctx->FragmentProgram._MaintainTexEnvProgram = 1;
brw_draw_init( brw );
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index 4352c3bcb0f..3f0aaa1f86d 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -35,7 +35,8 @@
#include "context.h"
#include "macros.h"
#include "enums.h"
-#include "shader/program.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
#include "intel_batchbuffer.h"
#include "brw_context.h"
#include "brw_defines.h"
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index d4dbcf38a7a..52f89d577ca 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -35,7 +35,7 @@
#include "brw_structs.h"
#include "brw_defines.h"
-#include "shader/program.h"
+#include "shader/prog_instruction.h"
#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
diff --git a/src/mesa/drivers/dri/i965/brw_metaops.c b/src/mesa/drivers/dri/i965/brw_metaops.c
index 1579762b6d1..6e030f191ef 100644
--- a/src/mesa/drivers/dri/i965/brw_metaops.c
+++ b/src/mesa/drivers/dri/i965/brw_metaops.c
@@ -35,8 +35,6 @@
#include "glheader.h"
#include "context.h"
#include "macros.h"
-#include "enums.h"
-#include "dd.h"
#include "shader/arbprogparse.h"
diff --git a/src/mesa/drivers/dri/i965/brw_util.c b/src/mesa/drivers/dri/i965/brw_util.c
index 9d12c26486d..b6deee23769 100644
--- a/src/mesa/drivers/dri/i965/brw_util.c
+++ b/src/mesa/drivers/dri/i965/brw_util.c
@@ -30,9 +30,9 @@
*/
-#include "brw_util.h"
#include "mtypes.h"
-#include "shader/program.h"
+#include "shader/prog_parameter.h"
+#include "brw_util.h"
#include "brw_defines.h"
GLuint brw_count_bits( GLuint val )
@@ -45,7 +45,7 @@ GLuint brw_count_bits( GLuint val )
}
-static GLuint brw_parameter_state_flags(const enum state_index state[])
+static GLuint brw_parameter_state_flags(const gl_state_index state[])
{
switch (state[0]) {
case STATE_MATERIAL:
@@ -70,22 +70,16 @@ static GLuint brw_parameter_state_flags(const enum state_index state[])
case STATE_POINT_ATTENUATION:
return _NEW_POINT;
- case STATE_MATRIX:
- switch (state[1]) {
- case STATE_MODELVIEW:
- return _NEW_MODELVIEW;
- case STATE_PROJECTION:
- return _NEW_PROJECTION;
- case STATE_MVP:
- return _NEW_MODELVIEW | _NEW_PROJECTION;
- case STATE_TEXTURE:
- return _NEW_TEXTURE_MATRIX;
- case STATE_PROGRAM:
- return _NEW_TRACK_MATRIX;
- default:
- assert(0);
- return 0;
- }
+ case STATE_MODELVIEW_MATRIX:
+ return _NEW_MODELVIEW;
+ case STATE_PROJECTION_MATRIX:
+ return _NEW_PROJECTION;
+ case STATE_MVP_MATRIX:
+ return _NEW_MODELVIEW | _NEW_PROJECTION;
+ case STATE_TEXTURE_MATRIX:
+ return _NEW_TEXTURE_MATRIX;
+ case STATE_PROGRAM_MATRIX:
+ return _NEW_TRACK_MATRIX;
case STATE_DEPTH_RANGE:
return _NEW_VIEWPORT;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 74c9d88e464..e173f6fce3e 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -34,8 +34,7 @@
#include "brw_vs.h"
#include "brw_util.h"
#include "brw_state.h"
-#include "program.h"
-#include "shader/arbprogparse.h"
+#include "shader/prog_print.h"
diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c
index 528e164db8c..caef042f1cd 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_constval.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c
@@ -30,10 +30,8 @@
*/
-#include "brw_context.h"
-#include "program.h"
-#include "program_instruction.h"
#include "macros.h"
+#include "brw_context.h"
#include "brw_vs.h"
/* Component is active if it may diverge from [0,0,0,1]. Undef values
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index ffdb843e85f..6eb11b19ad2 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -30,10 +30,11 @@
*/
-#include "brw_context.h"
#include "program.h"
-#include "program_instruction.h"
#include "macros.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "brw_context.h"
#include "brw_vs.h"
diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
index dd1664bf33a..35adc4846a0 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
@@ -33,12 +33,11 @@
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
#include "brw_vs.h"
#include "brw_state.h"
-#include "shader/program.h"
-#include "shader/program_instruction.h"
-#include "shader/arbprogparse.h"
struct state_key {
unsigned light_global_enabled:1;
@@ -398,11 +397,14 @@ static struct ureg register_const4f( struct tnl_program *p,
{
GLfloat values[4];
GLint idx;
+ GLuint swizzle;
values[0] = s0;
values[1] = s1;
values[2] = s2;
values[3] = s3;
- idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
+ idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
+ &swizzle);
+ /* XXX what about swizzle? */
return make_ureg(PROGRAM_STATE_VAR, idx);
}
@@ -424,40 +426,37 @@ static struct ureg get_identity_param( struct tnl_program *p )
return p->identity;
}
-static struct ureg register_param6( struct tnl_program *p,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4,
- GLint s5)
+static struct ureg register_param5( struct tnl_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4)
{
- GLint tokens[6];
+ gl_state_index tokens[STATE_LENGTH];
GLint idx;
tokens[0] = s0;
tokens[1] = s1;
tokens[2] = s2;
tokens[3] = s3;
tokens[4] = s4;
- tokens[5] = s5;
idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
return make_ureg(PROGRAM_STATE_VAR, idx);
}
-#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0)
-#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0)
-#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0)
-#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0)
+#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
-static void register_matrix_param6( struct tnl_program *p,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4,
- GLint s5,
+static void register_matrix_param5( struct tnl_program *p,
+ GLint s0, /* matrix name */
+ GLint s1, /* texture matrix number */
+ GLint s2, /* first row */
+ GLint s3, /* last row */
+ GLint s4, /* modifier */
struct ureg *matrix )
{
GLint i;
@@ -465,8 +464,8 @@ static void register_matrix_param6( struct tnl_program *p,
/* This is a bit sad as the support is there to pull the whole
* matrix out in one go:
*/
- for (i = 0; i <= s4 - s3; i++)
- matrix[i] = register_param6( p, s0, s1, s2, i, i, s5 );
+ for (i = 0; i <= s3 - s2; i++)
+ matrix[i] = register_param5( p, s0, s1, i, i, s4 );
}
@@ -650,13 +649,13 @@ static struct ureg get_eye_position( struct tnl_program *p )
p->eye_position = reserve_temp(p);
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX, modelview );
+ register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
+ 0, modelview );
emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
+ register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
STATE_MATRIX_TRANSPOSE, modelview );
emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
@@ -710,7 +709,7 @@ static struct ureg get_eye_normal( struct tnl_program *p )
struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
struct ureg mvinv[3];
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
+ register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2,
STATE_MATRIX_INVTRANS, mvinv );
p->eye_normal = reserve_temp(p);
@@ -745,12 +744,12 @@ static void build_hpos( struct tnl_program *p )
struct ureg mvp[4];
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX, mvp );
+ register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
+ 0, mvp );
emit_matrix_transform_vec4( p, hpos, mvp, pos );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
+ register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
STATE_MATRIX_TRANSPOSE, mvp );
emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
}
@@ -894,7 +893,7 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
/* Need to add some addtional parameters to allow lighting in object
- * space - STATE_SPOT_DIRECTION and STATE_HALF implicitly assume eye
+ * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye
* space lighting.
*/
static void build_lighting( struct tnl_program *p )
@@ -993,7 +992,7 @@ static void build_lighting( struct tnl_program *p )
emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat);
emit_normalize_vec3(p, half, half);
} else {
- half = register_param3(p, STATE_LIGHT, i, STATE_HALF);
+ half = register_param3(p, STATE_LIGHT, i, STATE_HALF_VECTOR);
}
}
else {
@@ -1360,13 +1359,13 @@ static void build_texture_transform( struct tnl_program *p )
out_texgen :
register_input(p, VERT_ATTRIB_TEX0+i));
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX, texmat );
+ register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ 0, texmat );
emit_matrix_transform_vec4( p, out, texmat, in );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX_TRANSPOSE, texmat );
+ register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ STATE_MATRIX_TRANSPOSE, texmat );
emit_transpose_matrix_transform_vec4( p, out, texmat, in );
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 0f842d289d7..1497dc79687 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -36,10 +36,6 @@
#include "brw_state.h"
#include "brw_hal.h"
-#include "program.h"
-#include "program_instruction.h"
-#include "arbprogparse.h"
-
GLuint brw_wm_nr_args( GLuint opcode )
{
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index ec6ad6105ca..f5fddfdb68a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -36,7 +36,7 @@
#include "brw_context.h"
#include "brw_eu.h"
-#include "program_instruction.h"
+#include "prog_instruction.h"
/* A big lookup table is used to figure out which and how many
* additional regs will inserted before the main payload in the WM
diff --git a/src/mesa/drivers/dri/i965/brw_wm_debug.c b/src/mesa/drivers/dri/i965/brw_wm_debug.c
index 9a6154b3336..f31d0974ecf 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_debug.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_debug.c
@@ -32,9 +32,6 @@
#include "brw_context.h"
#include "brw_wm.h"
-#include "program.h"
-#include "shader/arbprogparse.h"
-#include "shader/program_instruction.h"
void brw_wm_print_value( struct brw_wm_compile *c,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index d96a9b717c0..fd605159727 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -30,10 +30,8 @@
*/
-#include "brw_context.h"
-#include "program.h"
-#include "program_instruction.h"
#include "macros.h"
+#include "brw_context.h"
#include "brw_wm.h"
#define SATURATE (1<<5)
diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c
index ba2dbeccde2..ff97d87dc45 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_fp.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c
@@ -37,9 +37,10 @@
#include "brw_wm.h"
#include "brw_util.h"
-#include "shader/program.h"
-#include "shader/program_instruction.h"
-#include "shader/arbprogparse.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/prog_statevars.h"
+
#define FIRST_INTERNAL_TEMP MAX_NV_FRAGMENT_PROGRAM_TEMPS
@@ -370,23 +371,21 @@ static void emit_interp( struct brw_wm_compile *c,
* harm and it's not as if the parameter handling isn't a big hack
* anyway.
*/
-static struct prog_src_register search_or_add_param6( struct brw_wm_compile *c,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4,
- GLint s5)
+static struct prog_src_register search_or_add_param5(struct brw_wm_compile *c,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4)
{
struct gl_program_parameter_list *paramList = c->fp->program.Base.Parameters;
- GLint tokens[6];
+ gl_state_index tokens[STATE_LENGTH];
GLuint idx;
tokens[0] = s0;
tokens[1] = s1;
tokens[2] = s2;
tokens[3] = s3;
tokens[4] = s4;
- tokens[5] = s5;
for (idx = 0; idx < paramList->NumParameters; idx++) {
if (paramList->Parameters[idx].Type == PROGRAM_STATE_VAR &&
@@ -413,6 +412,7 @@ static struct prog_src_register search_or_add_const4f( struct brw_wm_compile *c,
struct gl_program_parameter_list *paramList = c->fp->program.Base.Parameters;
GLfloat values[4];
GLuint idx;
+ GLuint swizzle;
values[0] = s0;
values[1] = s1;
@@ -432,8 +432,8 @@ static struct prog_src_register search_or_add_const4f( struct brw_wm_compile *c,
return src_reg(PROGRAM_STATE_VAR, idx);
}
- idx = _mesa_add_unnamed_constant( paramList, values, 4 );
-
+ idx = _mesa_add_unnamed_constant( paramList, values, 4, &swizzle );
+ /* XXX what about swizzle? */
return src_reg(PROGRAM_STATE_VAR, idx);
}
@@ -527,11 +527,11 @@ static void precalc_tex( struct brw_wm_compile *c,
if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
struct prog_src_register scale =
- search_or_add_param6( c,
+ search_or_add_param5( c,
STATE_INTERNAL,
STATE_TEXRECT_SCALE,
inst->TexSrcUnit,
- 0,0,0 );
+ 0,0 );
tmpcoord = get_temp(c);
@@ -724,7 +724,7 @@ static void fog_blend( struct brw_wm_compile *c,
struct prog_src_register fog_factor )
{
struct prog_dst_register outcolor = dst_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
- struct prog_src_register fogcolor = search_or_add_param6( c, STATE_FOG_COLOR, 0,0,0,0,0 );
+ struct prog_src_register fogcolor = search_or_add_param5( c, STATE_FOG_COLOR, 0,0,0,0 );
/* color.xyz = LRP fog_factor.xxxx, output_color, fog_color */
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass0.c b/src/mesa/drivers/dri/i965/brw_wm_pass0.c
index 36b69b70681..00f6f6b9a4f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass0.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass0.c
@@ -32,9 +32,7 @@
#include "brw_context.h"
#include "brw_wm.h"
-#include "program.h"
-#include "arbprogparse.h"
-#include "program_instruction.h"
+#include "shader/prog_parameter.h"
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass1.c b/src/mesa/drivers/dri/i965/brw_wm_pass1.c
index 21d0881d57e..d668def7007 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass1.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass1.c
@@ -32,9 +32,6 @@
#include "brw_context.h"
#include "brw_wm.h"
-#include "program.h"
-#include "arbprogparse.h"
-#include "program_instruction.h"
static GLuint get_tracked_mask(struct brw_wm_compile *c,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
index cb8d51fb5cf..a1edbd6168d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
@@ -32,9 +32,7 @@
#include "brw_context.h"
#include "brw_wm.h"
-#include "program.h"
-#include "arbprogparse.h"
-#include "program_instruction.h"
+
/* Use these to force spilling so that that functionality can be
* tested with known-good examples rather than having to construct new
diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/src/mesa/drivers/dri/mach64/mach64_native_vb.c
index 7872c206f58..519ec81e548 100644
--- a/src/mesa/drivers/dri/mach64/mach64_native_vb.c
+++ b/src/mesa/drivers/dri/mach64/mach64_native_vb.c
@@ -52,14 +52,14 @@ void TAG(translate_vertex)(GLcontext *ctx,
{
float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
- dst->texcoord[1][0] = rhw*LE32_IN_FLOAT( p++ );
- dst->texcoord[1][1] = rhw*LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX1][0] = rhw*LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX1][1] = rhw*LE32_IN_FLOAT( p++ );
}
#else
- dst->texcoord[1][0] = LE32_IN_FLOAT( p++ );
- dst->texcoord[1][1] = LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX1][0] = LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX1][1] = LE32_IN_FLOAT( p++ );
#endif
- dst->texcoord[1][3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0;
p++;
case TEX0_VERTEX_FORMAT:
@@ -67,14 +67,14 @@ void TAG(translate_vertex)(GLcontext *ctx,
{
float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
- dst->texcoord[0][0] = rhw*LE32_IN_FLOAT( p++ );
- dst->texcoord[0][1] = rhw*LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX0][0] = rhw*LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX0][1] = rhw*LE32_IN_FLOAT( p++ );
}
#else
- dst->texcoord[0][0] = LE32_IN_FLOAT( p++ );
- dst->texcoord[0][1] = LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX0][0] = LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ );
#endif
- dst->texcoord[0][3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
dst->win[3] = LE32_IN_FLOAT( p++ );
case NOTEX_VERTEX_FORMAT:
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index f217c4404e9..8e11eb61342 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -201,7 +201,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual,
nouveauShaderInitFuncs(ctx);
/* Install Mesa's fixed-function texenv shader support */
if (nmesa->screen->card->type >= NV_40)
- ctx->_MaintainTexEnvProgram = GL_TRUE;
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
/* Initialize the swrast */
_swrast_CreateContext( ctx );
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
index 3d5b6843a15..b6837c5de14 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
@@ -35,9 +35,10 @@
#include "enums.h"
#include "extensions.h"
-#include "program.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+/*#include "shader/arbprogparse.h"*/
#include "tnl/tnl.h"
-#include "shader/arbprogparse.h"
#include "nouveau_context.h"
#include "nouveau_shader.h"
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
index 7c2e2b9443b..8c203cc664b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
@@ -34,9 +34,10 @@
#include "macros.h"
#include "enums.h"
-#include "program.h"
-#include "programopt.h"
-#include "program_instruction.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
+#include "shader/programopt.h"
#include "nouveau_context.h"
#include "nouveau_shader.h"
@@ -428,8 +429,10 @@ pass0_fixup_swizzle(nvsPtr nvs, nvsFragmentHeader *parent, int fpos,
if (!rec->swzconst_done) {
struct gl_program *prog = &nvs->mesa.vp.Base;
+ GLuint swizzle;
rec->swzconst_id = _mesa_add_unnamed_constant(prog->Parameters,
- sc, 4);
+ sc, 4, &swizzle);
+ /* XXX what about swizzle? */
rec->swzconst_done = 1;
COPY_4V(nvs->params[rec->swzconst_id].val, sc);
}
@@ -839,7 +842,8 @@ pass0_vp_insert_ff_clip_planes(GLcontext *ctx, nouveauShader *nvs)
nvsInstruction *nvsinst;
GLuint fpos = 0;
nvsRegister opos, epos, eqn, mv[4];
- GLint tokens[6] = { STATE_MATRIX, STATE_MODELVIEW, 0, 0, 0, 0 };
+ gl_state_index tokens[STATE_LENGTH]
+ = { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0 };
GLint id;
int i;
@@ -847,7 +851,7 @@ pass0_vp_insert_ff_clip_planes(GLcontext *ctx, nouveauShader *nvs)
pass0_make_reg(nvs, &opos, NVS_FILE_ATTRIB, NVS_FR_POSITION);
pass0_make_reg(nvs, &epos, NVS_FILE_TEMP , -1);
for (i=0; i<4; i++) {
- tokens[3] = tokens[4] = i;
+ tokens[2] = tokens[3] = i;
id = _mesa_add_state_reference(prog->Parameters, tokens);
pass0_make_reg(nvs, &mv[i], NVS_FILE_CONST, id);
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
index 130ef35e57b..cd27daca88b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
@@ -34,7 +34,8 @@
#include "macros.h"
#include "enums.h"
-#include "program.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
#include "nouveau_context.h"
#include "nouveau_shader.h"
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c
index 4960d481d5d..6089d617c6b 100644
--- a/src/mesa/drivers/dri/r200/r200_vertprog.c
+++ b/src/mesa/drivers/dri/r200/r200_vertprog.c
@@ -34,14 +34,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "macros.h"
#include "enums.h"
#include "program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
+#include "shader/programopt.h"
+#include "tnl/tnl.h"
#include "r200_context.h"
#include "r200_vertprog.h"
#include "r200_ioctl.h"
#include "r200_tcl.h"
-#include "program_instruction.h"
-#include "programopt.h"
-#include "tnl/tnl.h"
#if SWIZZLE_X != VSF_IN_COMPONENT_X || \
SWIZZLE_Y != VSF_IN_COMPONENT_Y || \
@@ -462,7 +464,7 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
base e isn't directly available neither. */
if ((mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) && !vp->fogpidx) {
struct gl_program_parameter_list *paramList;
- GLint tokens[6] = { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 };
+ gl_state_index tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
paramList = mesa_vp->Base.Parameters;
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
}
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 68c8f5b87d0..1f8d95078fb 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -331,7 +331,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
ctx->Const.FragmentProgram.MaxNativeTexIndirections = PFS_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* and these are?? */
_tnl_ProgramCacheInit(ctx);
- ctx->_MaintainTexEnvProgram = GL_TRUE;
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
driInitExtensions(ctx, card_extensions, GL_TRUE);
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index e01f56d99df..77f95605e4d 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -43,9 +43,10 @@
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
-#include "program.h"
-#include "program_instruction.h"
#include "r300_context.h"
#include "r300_fragprog.h"
#include "r300_reg.h"
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.h b/src/mesa/drivers/dri/r300/r300_fragprog.h
index 73986abc3cc..d883aee2d72 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.h
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.h
@@ -36,10 +36,11 @@
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
-#include "program.h"
#include "r300_context.h"
-#include "program_instruction.h"
+
#if 0
/* representation of a register for emit_arith/swizzle */
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 17658efdb2f..ff3c51c5edf 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -46,6 +46,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "api_arrayelt.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "texformat.h"
@@ -1055,8 +1057,10 @@ r300UpdateDrawBuffer(GLcontext *ctx)
#endif
}
-static void r300FetchStateParameter(GLcontext *ctx, const enum state_index state[],
- GLfloat *value)
+static void
+r300FetchStateParameter(GLcontext *ctx,
+ const gl_state_index state[STATE_LENGTH],
+ GLfloat *value)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 092ebb1140e..aa2f20127ba 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -33,11 +33,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "macros.h"
#include "enums.h"
#include "program.h"
-#include "nvvertexec.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
+#include "tnl/tnl.h"
#include "r300_context.h"
#include "r300_program.h"
-#include "program_instruction.h"
#if SWIZZLE_X != VSF_IN_COMPONENT_X || \
SWIZZLE_Y != VSF_IN_COMPONENT_Y || \
@@ -103,7 +105,7 @@ int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont *
struct gl_program_parameter_list *paramList;
if (mesa_vp->IsNVProgram) {
- _mesa_init_vp_per_primitive_registers(ctx);
+ _mesa_load_tracked_matrices(ctx);
for (pi=0; pi < MAX_NV_VERTEX_PROGRAM_PARAMS; pi++) {
*dst++=ctx->VertexProgram.Parameters[pi][0];
@@ -880,7 +882,7 @@ static void position_invariant(struct gl_program *prog)
struct gl_program_parameter_list *paramList;
int i;
- GLint tokens[6] = { STATE_MATRIX, STATE_MVP, 0, 0, 0, STATE_MATRIX };
+ gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 };
#ifdef PREFER_DP4
tokens[5] = STATE_MATRIX;
diff --git a/src/mesa/drivers/dri/s3v/s3v_tritmp.h b/src/mesa/drivers/dri/s3v/s3v_tritmp.h
index 16318f4c402..696fc02250f 100644
--- a/src/mesa/drivers/dri/s3v/s3v_tritmp.h
+++ b/src/mesa/drivers/dri/s3v/s3v_tritmp.h
@@ -407,17 +407,17 @@ do { \
ctx->Texture.Unit[0]._Current->DriverData); \
deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \
\
- u0 = (v[idx[0]].texcoord[0][0] \
+ u0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] \
* (GLfloat)(t->image[0].image->Width) * 256.0); \
- u1 = (v[idx[1]].texcoord[0][0] \
+ u1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] \
* (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
- u2 = (v[idx[2]].texcoord[0][0] \
+ u2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0] \
* (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
- v0 = (v[idx[0]].texcoord[0][1] \
+ v0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] \
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
- v1 = (v[idx[1]].texcoord[0][1] \
+ v1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] \
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
- v2 = (v[idx[2]].texcoord[0][1] \
+ v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
\
w0 = (v[idx[0]].win[3]); \
@@ -485,23 +485,23 @@ do { \
GLfloat sxy, suv; \
int lev; \
\
- suv = (v[idx[0]].texcoord[0][0] - \
- v[idx[2]].texcoord[0][0]) * \
- (v[idx[1]].texcoord[0][1] - \
- v[idx[2]].texcoord[0][1]) - \
- (v[idx[1]].texcoord[0][0] - \
- v[idx[2]].texcoord[0][0]) * \
- (v[idx[0]].texcoord[0][1] - \
- v[idx[2]].texcoord[0][2]); \
-\
- sxy = (v[idx[0]].texcoord[0][0] - \
- v[idx[2]].texcoord[0][0]) * \
- (v[idx[1]].texcoord[0][1] - \
- v[idx[2]].texcoord[0][1]) - \
- (v[idx[1]].texcoord[0][0] - \
- v[idx[2]].texcoord[0][0]) * \
- (v[idx[0]].texcoord[0][1] - \
- v[idx[2]].texcoord[0][2]); \
+ suv = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
+ (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \
+ (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
+ (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \
+\
+ sxy = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
+ (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \
+ (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \
+ (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \
+ v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \
\
if (sxy < 0) sxy *= -1.0; \
if (suv < 0) suv *= -1.0; \
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c
index ac8daf47497..4ba2f40b9e8 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tris.c
@@ -165,21 +165,21 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
dst->color[2] = src->color[0];
dst->color[3] = src->color[3];
- dst->texcoord[0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0;
- dst->texcoord[0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0;
+ dst->attrib[FRAG_ATTRIB_TEX0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0;
+ dst->attrib[FRAG_ATTRIB_TEX0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0;
if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ1 || fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
- dst->texcoord[0][3] = w * src->tq0;
+ dst->attrib[FRAG_ATTRIB_TEX0][3] = w * src->tq0;
} else {
- dst->texcoord[0][3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
}
if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
- dst->texcoord[1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1;
- dst->texcoord[1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1;
+ dst->attrib[FRAG_ATTRIB_TEX1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1;
+ dst->attrib[FRAG_ATTRIB_TEX1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1;
if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
- dst->texcoord[1][3] = w * src->tq1;
+ dst->attrib[FRAG_ATTRIB_TEX1][3] = w * src->tq1;
} else {
- dst->texcoord[1][3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0;
}
}
}
diff --git a/src/mesa/drivers/dri/trident/trident_context.h b/src/mesa/drivers/dri/trident/trident_context.h
index b1e68b01663..1d3ca84400d 100644
--- a/src/mesa/drivers/dri/trident/trident_context.h
+++ b/src/mesa/drivers/dri/trident/trident_context.h
@@ -179,7 +179,7 @@ struct trident_context {
GLuint vertex_format;
GLuint vertex_size;
GLuint vertex_stride_shift;
- char *verts;
+ GLubyte *verts;
GLint tmu_source[2];
diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile
new file mode 100644
index 00000000000..858457ddd40
--- /dev/null
+++ b/src/mesa/drivers/glslcompiler/Makefile
@@ -0,0 +1,44 @@
+# Makefile for stand-alone GL-SL compiler
+
+TOP = ../../../..
+
+include $(TOP)/configs/current
+
+
+PROGRAM = glslcompiler
+
+OBJECTS = \
+ glslcompiler.o \
+ ../../glapi/glapi.o \
+ ../../glapi/glthread.o \
+ ../../main/dispatch.o \
+ ../common/driverfuncs.o \
+ ../../libmesa.a
+
+INCLUDES = \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL/internal \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/transform \
+ -I$(TOP)/src/mesa/shader \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup \
+
+
+default: $(PROGRAM)
+ $(INSTALL) $(PROGRAM) $(TOP)/bin
+
+
+glslcompiler: $(OBJECTS)
+ $(CC) $(OBJECTS) -lm -lpthread -o $@
+
+
+glslcompiler.o: glslcompiler.c
+ $(CC) -c $(CFLAGS) $(INCLUDES) glslcompiler.c -o $@
+
+
+clean:
+ rm -f *.o *~ $(PROGRAM)
diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c
new file mode 100644
index 00000000000..016b53d57aa
--- /dev/null
+++ b/src/mesa/drivers/glslcompiler/glslcompiler.c
@@ -0,0 +1,358 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5.3
+ *
+ * Copyright (C) 1999-2007 Brian Paul, Tungsten Graphics, Inc.
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \mainpage
+ *
+ * Stand-alone Shading Language compiler.
+ * Basically, a command-line program which accepts GLSL shaders and emits
+ * vertex/fragment programs (GPU instructions).
+ *
+ * This file is basically just a Mesa device driver but instead of building
+ * a shared library we build an executable.
+ *
+ * We can emit programs in three different formats:
+ * 1. ARB-style (GL_ARB_vertex/fragment_program)
+ * 2. NV-style (GL_NV_vertex/fragment_program)
+ * 3. debug-style (a slightly more sophisticated, internal format)
+ *
+ * Note that the ARB and NV program languages can't express all the
+ * features that might be used by a fragment program (examples being
+ * uniform and varying vars). So, the ARB/NV programs that are
+ * emitted aren't always legal programs in those languages.
+ */
+
+
+#include "imports.h"
+#include "context.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "shaders.h"
+#include "shader/shader_api.h"
+#include "shader/prog_print.h"
+#include "drivers/common/driverfuncs.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "swrast/swrast.h"
+#include "swrast/s_context.h"
+#include "swrast/s_triangle.h"
+#include "swrast_setup/swrast_setup.h"
+#include "vbo/vbo.h"
+
+
+static const char *Prog = "glslcompiler";
+
+
+struct options {
+ GLboolean LineNumbers;
+ gl_prog_print_mode Mode;
+ const char *VertFile;
+ const char *FragFile;
+ const char *OutputFile;
+};
+
+static struct options Options;
+
+
+/**
+ * GLSL compiler driver context. (kind of an artificial thing for now)
+ */
+struct compiler_context
+{
+ GLcontext MesaContext;
+ int foo;
+};
+
+typedef struct compiler_context CompilerContext;
+
+
+
+static void
+UpdateState(GLcontext *ctx, GLuint new_state)
+{
+ /* easy - just propogate */
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _vbo_InvalidateState( ctx, new_state );
+}
+
+
+
+static GLboolean
+CreateContext(void)
+{
+ struct dd_function_table ddFuncs;
+ GLvisual *vis;
+ GLframebuffer *buf;
+ GLcontext *ctx;
+ CompilerContext *cc;
+
+ vis = _mesa_create_visual(GL_TRUE, GL_FALSE, GL_FALSE, /* RGB */
+ 8, 8, 8, 8, /* color */
+ 0, 0, 0, /* z, stencil */
+ 0, 0, 0, 0, 1); /* accum */
+ buf = _mesa_create_framebuffer(vis);
+
+ cc = _mesa_calloc(sizeof(*cc));
+ if (!vis || !buf || !cc) {
+ if (vis)
+ _mesa_destroy_visual(vis);
+ if (buf)
+ _mesa_destroy_framebuffer(buf);
+ return GL_FALSE;
+ }
+
+ _mesa_init_driver_functions(&ddFuncs);
+ ddFuncs.GetString = NULL;/*get_string;*/
+ ddFuncs.UpdateState = UpdateState;
+ ddFuncs.GetBufferSize = NULL;
+
+ ctx = &cc->MesaContext;
+ _mesa_initialize_context(ctx, vis, NULL, &ddFuncs, cc);
+ _mesa_enable_sw_extensions(ctx);
+
+ if (!_swrast_CreateContext( ctx ) ||
+ !_vbo_CreateContext( ctx ) ||
+ !_tnl_CreateContext( ctx ) ||
+ !_swsetup_CreateContext( ctx )) {
+ _mesa_destroy_visual(vis);
+ _mesa_free_context_data(ctx);
+ _mesa_free(cc);
+ return GL_FALSE;
+ }
+ TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+ _swsetup_Wakeup( ctx );
+
+ _mesa_make_current(ctx, buf, buf);
+
+ return GL_TRUE;
+}
+
+
+static void
+LoadAndCompileShader(GLuint shader, const char *text)
+{
+ GLint stat;
+ _mesa_ShaderSourceARB(shader, 1, (const GLchar **) &text, NULL);
+ _mesa_CompileShaderARB(shader);
+ _mesa_GetShaderiv(shader, GL_COMPILE_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ _mesa_GetShaderInfoLog(shader, 1000, &len, log);
+ fprintf(stderr, "%s: problem compiling shader: %s\n", Prog, log);
+ exit(1);
+ }
+ else {
+ printf("Shader compiled OK\n");
+ }
+}
+
+
+/**
+ * Read a shader from a file.
+ */
+static void
+ReadShader(GLuint shader, const char *filename)
+{
+ const int max = 100*1000;
+ int n;
+ char *buffer = (char*) malloc(max);
+ FILE *f = fopen(filename, "r");
+ if (!f) {
+ fprintf(stderr, "%s: Unable to open shader file %s\n", Prog, filename);
+ exit(1);
+ }
+
+ n = fread(buffer, 1, max, f);
+ /*
+ printf("%s: read %d bytes from shader file %s\n", Prog, n, filename);
+ */
+ if (n > 0) {
+ buffer[n] = 0;
+ LoadAndCompileShader(shader, buffer);
+ }
+
+ fclose(f);
+ free(buffer);
+}
+
+
+#if 0
+static void
+CheckLink(GLuint prog)
+{
+ GLint stat;
+ _mesa_GetProgramiv(prog, GL_LINK_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ _mesa_GetProgramInfoLog(prog, 1000, &len, log);
+ fprintf(stderr, "%s: Linker error:\n%s\n", Prog, log);
+ }
+ else {
+ fprintf(stderr, "%s: Link success!\n", Prog);
+ }
+}
+#endif
+
+
+static void
+PrintShaderInstructions(GLuint shader, FILE *f)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
+ GLuint i;
+
+ for (i = 0; i < sh->NumPrograms; i++) {
+ struct gl_program *prog = sh->Programs[i];
+ _mesa_print_program_opt(prog, Options.Mode, Options.LineNumbers);
+ }
+}
+
+
+static GLuint
+CompileShader(const char *filename, GLenum type)
+{
+ GLuint shader;
+
+ assert(type == GL_FRAGMENT_SHADER ||
+ type == GL_VERTEX_SHADER);
+
+ shader = _mesa_CreateShader(type);
+ ReadShader(shader, filename);
+
+ return shader;
+}
+
+
+static void
+Usage(void)
+{
+ printf("Mesa GLSL stand-alone compiler\n");
+ printf("Usage:\n");
+ printf(" --vs FILE vertex shader input filename\n");
+ printf(" --fs FILE fragment shader input filename\n");
+ printf(" --arb emit ARB-style instructions (the default)\n");
+ printf(" --nv emit NV-style instructions\n");
+ printf(" --debug emit debug-style instructions\n");
+ printf(" --number, -n emit line numbers\n");
+ printf(" --output, -o FILE output filename\n");
+ printf(" --help display this information\n");
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+ int i;
+
+ Options.LineNumbers = GL_FALSE;
+ Options.Mode = PROG_PRINT_ARB;
+ Options.VertFile = NULL;
+ Options.FragFile = NULL;
+ Options.OutputFile = NULL;
+
+ if (argc == 1) {
+ Usage();
+ exit(0);
+ }
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--vs") == 0) {
+ Options.VertFile = argv[i + 1];
+ i++;
+ }
+ else if (strcmp(argv[i], "--fs") == 0) {
+ Options.FragFile = argv[i + 1];
+ i++;
+ }
+ else if (strcmp(argv[i], "--arb") == 0) {
+ Options.Mode = PROG_PRINT_ARB;
+ }
+ else if (strcmp(argv[i], "--nv") == 0) {
+ Options.Mode = PROG_PRINT_NV;
+ }
+ else if (strcmp(argv[i], "--debug") == 0) {
+ Options.Mode = PROG_PRINT_DEBUG;
+ }
+ else if (strcmp(argv[i], "--number") == 0 ||
+ strcmp(argv[i], "-n") == 0) {
+ Options.LineNumbers = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "--output") == 0 ||
+ strcmp(argv[i], "-o") == 0) {
+ Options.OutputFile = argv[i + 1];
+ i++;
+ }
+ else if (strcmp(argv[i], "--help") == 0) {
+ Usage();
+ exit(0);
+ }
+ else {
+ printf("Unknown option: %s\n", argv[i]);
+ Usage();
+ exit(1);
+ }
+ }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ GLuint shader = 0;
+
+ if (!CreateContext()) {
+ fprintf(stderr, "%s: Failed to create compiler context\n", Prog);
+ exit(1);
+ }
+
+ ParseOptions(argc, argv);
+
+ if (Options.VertFile) {
+ shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER);
+ }
+ else if (Options.FragFile) {
+ shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER);
+ }
+
+ if (shader) {
+ if (Options.OutputFile) {
+ fclose(stdout);
+ /*stdout =*/ freopen(Options.OutputFile, "w", stdout);
+ }
+ if (stdout) {
+ PrintShaderInstructions(shader, stdout);
+ }
+ if (Options.OutputFile) {
+ fclose(stdout);
+ }
+ }
+
+ return 0;
+}