i965/vs: Fix NULL pointer dereference in pre-Gen6 push constant loading.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_vertprog.c
index a1fe3780294e5c6c04d113057531f80aceb397f6..1daa305e3c4657e72f0097a0d852255c9718fcae 100644 (file)
@@ -31,12 +31,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/glheader.h"
 #include "main/macros.h"
 #include "main/enums.h"
-#include "shader/program.h"
-#include "shader/programopt.h"
-#include "shader/prog_instruction.h"
-#include "shader/prog_parameter.h"
-#include "shader/prog_print.h"
-#include "shader/prog_statevars.h"
+#include "program/program.h"
+#include "program/programopt.h"
+#include "program/prog_instruction.h"
+#include "program/prog_parameter.h"
+#include "program/prog_print.h"
+#include "program/prog_statevars.h"
 #include "tnl/tnl.h"
 
 #include "compiler/radeon_compiler.h"
@@ -49,7 +49,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Write parameter array for the given vertex program into dst.
  * Return the total number of components written.
  */
-static int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program *vp, float *dst)
+static int r300VertexProgUpdateParams(struct gl_context * ctx, struct r300_vertex_program *vp, float *dst)
 {
        int i;
 
@@ -227,7 +227,7 @@ static void initialize_NV_registers(struct radeon_compiler * compiler)
        inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000;
 }
 
-static struct r300_vertex_program *build_program(GLcontext *ctx,
+static struct r300_vertex_program *build_program(struct gl_context *ctx,
                                                 struct r300_vertex_program_key *wanted_key,
                                                 const struct gl_vertex_program *mesa_vp)
 {
@@ -238,12 +238,19 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
        vp->Base = _mesa_clone_vertex_program(ctx, mesa_vp);
        memcpy(&vp->key, wanted_key, sizeof(vp->key));
 
+        memset(&compiler, 0, sizeof(compiler));
        rc_init(&compiler.Base);
        compiler.Base.Debug = (RADEON_DEBUG & RADEON_VERTS) ? GL_TRUE : GL_FALSE;
 
        compiler.code = &vp->code;
        compiler.RequiredOutputs = compute_required_outputs(vp->Base, vp->key.FpReads);
        compiler.SetHwInputOutput = &t_inputs_outputs;
+       compiler.Base.is_r500 = R300_CONTEXT(ctx)->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515;
+       compiler.Base.disable_optimizations = 0;
+       compiler.Base.has_half_swizzles = 0;
+       compiler.Base.max_temp_regs = 32;
+       compiler.Base.max_constants = 256;
+       compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 1024 : 256;
 
        if (compiler.Base.Debug) {
                fprintf(stderr, "Initial vertex program:\n");
@@ -300,7 +307,7 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
        return vp;
 }
 
-struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx)
+struct r300_vertex_program * r300SelectAndTranslateVertexShader(struct gl_context *ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        struct r300_vertex_program_key wanted_key = { 0 };
@@ -379,7 +386,7 @@ static void r300EmitVertexProgram(r300ContextPtr r300, int dest, struct r300_ver
 
 void r300SetupVertexProgram(r300ContextPtr rmesa)
 {
-       GLcontext *ctx = rmesa->radeon.glCtx;
+       struct gl_context *ctx = rmesa->radeon.glCtx;
        struct r300_vertex_program *prog = rmesa->selected_vp;
        int inst_count = 0;
        int param_count = 0;