static struct gl_program *brwNewProgram( struct gl_context *ctx,
				      GLenum target,
				      GLuint id )
{
   struct brw_context *brw = brw_context(ctx);

   switch (target) {
   case GL_VERTEX_PROGRAM_ARB: {
      struct brw_vertex_program *prog = CALLOC_STRUCT(brw_vertex_program);
      if (prog) {
	 prog->id = get_new_program_id(brw->intelScreen);

	 return _mesa_init_gl_program(&prog->program.Base, target, id);
      }
      else
	 return NULL;
   }

   case GL_FRAGMENT_PROGRAM_ARB: {
      struct brw_fragment_program *prog = CALLOC_STRUCT(brw_fragment_program);
      if (prog) {
	 prog->id = get_new_program_id(brw->intelScreen);

	 return _mesa_init_gl_program(&prog->program.Base, target, id);
      }
      else
	 return NULL;
   }

   case GL_GEOMETRY_PROGRAM_NV: {
      struct brw_geometry_program *prog = CALLOC_STRUCT(brw_geometry_program);
      if (prog) {
         prog->id = get_new_program_id(brw->intelScreen);

         return _mesa_init_gl_program(&prog->program.Base, target, id);
      } else {
         return NULL;
      }
   }

   case GL_COMPUTE_PROGRAM_NV: {
      struct brw_compute_program *prog = CALLOC_STRUCT(brw_compute_program);
      if (prog) {
         prog->id = get_new_program_id(brw->intelScreen);

         return _mesa_init_gl_program(&prog->program.Base, target, id);
      } else {
         return NULL;
      }
   }

   default:
      unreachable("Unsupported target in brwNewProgram()");
   }
}
Ejemplo n.º 2
0
static struct gl_program *brwNewProgram( struct gl_context *ctx,
				      GLenum target,
				      GLuint id )
{
   struct brw_context *brw = brw_context(ctx);

   switch (target) {
   case GL_VERTEX_PROGRAM_ARB:
   case GL_TESS_CONTROL_PROGRAM_NV:
   case GL_TESS_EVALUATION_PROGRAM_NV:
   case GL_GEOMETRY_PROGRAM_NV:
   case GL_COMPUTE_PROGRAM_NV: {
      struct brw_program *prog = rzalloc(NULL, struct brw_program);
      if (prog) {
	 prog->id = get_new_program_id(brw->screen);

	 return _mesa_init_gl_program(&prog->program, target, id);
      }
      else
	 return NULL;
   }

   case GL_FRAGMENT_PROGRAM_ARB: {
      struct brw_program *prog;
      if (brw->gen < 6) {
         struct gen4_fragment_program *g4_prog =
            rzalloc(NULL, struct gen4_fragment_program);
         prog = &g4_prog->base;
      } else {
         prog = rzalloc(NULL, struct brw_program);
      }

      if (prog) {
	 prog->id = get_new_program_id(brw->screen);

	 return _mesa_init_gl_program(&prog->program, target, id);
      }
      else
	 return NULL;
   }

   default:
      unreachable("Unsupported target in brwNewProgram()");
   }
Ejemplo n.º 3
0
static struct gl_program *
r200NewProgram(struct gl_context *ctx, GLenum target, GLuint id,
               bool is_arb_asm)
{
   switch(target){
   case GL_VERTEX_PROGRAM_ARB: {
      struct r200_vertex_program *vp = rzalloc(NULL,
                                               struct r200_vertex_program);
      return _mesa_init_gl_program(&vp->mesa_program, target, id, is_arb_asm);
   }
   case GL_FRAGMENT_PROGRAM_ARB: {
      struct gl_program *prog = rzalloc(NULL, struct gl_program);
      return _mesa_init_gl_program(prog, target, id, is_arb_asm);
   }
   default:
      _mesa_problem(ctx, "Bad target in r200NewProgram");
      return NULL;
   }
}
Ejemplo n.º 4
0
/**
 * Called via ctx->Driver.NewProgram() to allocate a new vertex or
 * fragment program.
 */
static struct gl_program *
st_new_program(struct gl_context *ctx, GLenum target, GLuint id)
{
   switch (target) {
   case GL_VERTEX_PROGRAM_ARB: {
      struct st_vertex_program *prog = ST_CALLOC_STRUCT(st_vertex_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   case GL_FRAGMENT_PROGRAM_ARB: {
      struct st_fragment_program *prog = ST_CALLOC_STRUCT(st_fragment_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   case GL_GEOMETRY_PROGRAM_NV: {
      struct st_geometry_program *prog = ST_CALLOC_STRUCT(st_geometry_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   case GL_TESS_CONTROL_PROGRAM_NV: {
      struct st_tessctrl_program *prog = ST_CALLOC_STRUCT(st_tessctrl_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   case GL_TESS_EVALUATION_PROGRAM_NV: {
      struct st_tesseval_program *prog = ST_CALLOC_STRUCT(st_tesseval_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   case GL_COMPUTE_PROGRAM_NV: {
      struct st_compute_program *prog = ST_CALLOC_STRUCT(st_compute_program);
      return _mesa_init_gl_program(&prog->Base.Base, target, id);
   }
   default:
      assert(0);
      return NULL;
   }
}
Ejemplo n.º 5
0
/**
 * Allocate and initialize a new fragment/vertex program object but
 * don't put it into the program hash table.  Called via
 * ctx->Driver.NewProgram.  May be overridden (ie. replaced) by a
 * device driver function to implement OO deriviation with additional
 * types not understood by this function.
 *
 * \param ctx  context
 * \param id   program id/number
 * \param target  program target/type
 * \return  pointer to new program object
 */
struct gl_program *
_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
{
   switch (target) {
   case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
   case GL_GEOMETRY_PROGRAM_NV:
   case GL_TESS_CONTROL_PROGRAM_NV:
   case GL_TESS_EVALUATION_PROGRAM_NV:
   case GL_FRAGMENT_PROGRAM_ARB:
   case GL_COMPUTE_PROGRAM_NV: {
      struct gl_program *prog = CALLOC_STRUCT(gl_program);
      return _mesa_init_gl_program(prog, target, id);
   }
   default:
      _mesa_problem(ctx, "bad target in _mesa_new_program");
      return NULL;
   }
}