program: remove _mesa_init_*_program wrappers
authorMarek Olšák <marek.olsak@amd.com>
Mon, 5 Oct 2015 20:13:34 +0000 (22:13 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 9 Oct 2015 20:02:19 +0000 (22:02 +0200)
They didn't do anything useful.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/i915/i915_fragprog.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
src/mesa/drivers/dri/r200/r200_vertprog.c
src/mesa/program/program.c
src/mesa/program/program.h
src/mesa/state_tracker/st_cb_program.c

index 1a5943c87fba4dc5ae64f62db266934d3638b944..237d219289b8a5584a3be23c924001425265eea7 100644 (file)
@@ -1316,8 +1316,8 @@ i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id)
 {
    switch (target) {
    case GL_VERTEX_PROGRAM_ARB:
-      return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program),
-                                       target, id);
+      return _mesa_init_gl_program(CALLOC_STRUCT(gl_vertex_program),
+                                   target, id);
 
    case GL_FRAGMENT_PROGRAM_ARB:{
          struct i915_fragment_program *prog =
@@ -1325,8 +1325,7 @@ i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id)
          if (prog) {
             i915_init_program(I915_CONTEXT(ctx), prog);
 
-            return _mesa_init_fragment_program(ctx, &prog->FragProg,
-                                               target, id);
+            return _mesa_init_gl_program(prog, target, id);
          }
          else
             return NULL;
index 69ecc36f2e78e501527ad8a05c740c073d4c8895..164c3d76c998a2fe63330e47f438484379f2d7e4 100644 (file)
@@ -69,8 +69,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
         prog->id = get_new_program_id(brw->intelScreen);
 
-        return _mesa_init_vertex_program( ctx, &prog->program,
-                                            target, id );
+        return _mesa_init_gl_program(&prog->program, target, id);
       }
       else
         return NULL;
@@ -81,8 +80,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
         prog->id = get_new_program_id(brw->intelScreen);
 
-        return _mesa_init_fragment_program( ctx, &prog->program,
-                                            target, id );
+        return _mesa_init_gl_program(&prog->program, target, id);
       }
       else
         return NULL;
@@ -93,7 +91,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
          prog->id = get_new_program_id(brw->intelScreen);
 
-         return _mesa_init_geometry_program(ctx, &prog->program, target, id);
+         return _mesa_init_gl_program(&prog->program, target, id);
       } else {
          return NULL;
       }
@@ -104,7 +102,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
          prog->id = get_new_program_id(brw->intelScreen);
 
-         return _mesa_init_compute_program(ctx, &prog->program, target, id);
+         return _mesa_init_gl_program(&prog->program, target, id);
       } else {
          return NULL;
       }
index 8adb626d420ce7f29094d1f8338211512bd2ed23..7eee42630a6aecf428549446dd988c0c6d03dcf4 100644 (file)
@@ -66,7 +66,7 @@ void cmod_propagation_test::SetUp()
 
    v = new cmod_propagation_fs_visitor(compiler, prog_data, shader);
 
-   _mesa_init_fragment_program(ctx, &fp->program, GL_FRAGMENT_SHADER, 0);
+   _mesa_init_gl_program(&fp->program, GL_FRAGMENT_SHADER, 0);
 
    devinfo->gen = 4;
 }
index f77b18e7db8711ffc01977665da79fd034ab04c8..fefde4bb7bf7b9edfc43868f0e5a4c3c4051a1e1 100644 (file)
@@ -66,7 +66,7 @@ void saturate_propagation_test::SetUp()
 
    v = new saturate_propagation_fs_visitor(compiler, prog_data, shader);
 
-   _mesa_init_fragment_program(ctx, &fp->program, GL_FRAGMENT_SHADER, 0);
+   _mesa_init_gl_program(&fp->program, GL_FRAGMENT_SHADER, 0);
 
    devinfo->gen = 4;
 }
index 40253961a6553463bfaead5b2c6f690d903f2517..4a87e6eff96f7dce2e595f8d0a22e1aa0386914d 100644 (file)
@@ -98,7 +98,7 @@ void copy_propagation_test::SetUp()
 
    v = new copy_propagation_vec4_visitor(compiler, shader);
 
-   _mesa_init_vertex_program(ctx, &vp->program, GL_VERTEX_SHADER, 0);
+   _mesa_init_gl_program(&vp->program, GL_VERTEX_SHADER, 0);
 
    devinfo->gen = 4;
 }
index 76028d3631105f51664c8221189746ce779d03aa..92d75e798378aaa89aa682b81d0b7c97d9f9570e 100644 (file)
@@ -101,7 +101,7 @@ void register_coalesce_test::SetUp()
 
    v = new register_coalesce_vec4_visitor(compiler, shader);
 
-   _mesa_init_vertex_program(ctx, &vp->program, GL_VERTEX_SHADER, 0);
+   _mesa_init_gl_program(&vp->program, GL_VERTEX_SHADER, 0);
 
    devinfo->gen = 4;
 }
index d43eaf977fc6a8d085dd7c3631f2f7cc0aadddca..d173605d1103c8ed5029d9094591607c69db67fd 100644 (file)
@@ -1205,9 +1205,9 @@ r200NewProgram(struct gl_context *ctx, GLenum target, GLuint id)
    switch(target){
    case GL_VERTEX_PROGRAM_ARB:
       vp = CALLOC_STRUCT(r200_vertex_program);
-      return _mesa_init_vertex_program(ctx, &vp->mesa_program, target, id);
+      return _mesa_init_gl_program(&vp->mesa_program, target, id);
    case GL_FRAGMENT_PROGRAM_ARB:
-      return _mesa_init_fragment_program( ctx, CALLOC_STRUCT(gl_fragment_program), target, id );
+      return _mesa_init_gl_program(CALLOC_STRUCT(gl_fragment_program), target, id);
    default:
       _mesa_problem(ctx, "Bad target in r200NewProgram");
    }
index 1fcb8e06ea3d1215e7a44327dddaa922df208913..c35a89b5983ad5fe9e7824c1be4385a09d377c99 100644 (file)
@@ -175,12 +175,14 @@ _mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string)
 /**
  * Initialize a new gl_program object.
  */
-static void
-init_program_struct(struct gl_program *prog, GLenum target, GLuint id)
+struct gl_program *
+_mesa_init_gl_program(void *_prog, GLenum target, GLuint id)
 {
+   struct gl_program *prog = (struct gl_program*)_prog;
    GLuint i;
 
-   assert(prog);
+   if (!prog)
+      return NULL;
 
    memset(prog, 0, sizeof(*prog));
    mtx_init(&prog->Mutex, mtx_plain);
@@ -192,102 +194,8 @@ init_program_struct(struct gl_program *prog, GLenum target, GLuint id)
    /* default mapping from samplers to texture units */
    for (i = 0; i < MAX_SAMPLERS; i++)
       prog->SamplerUnits[i] = i;
-}
-
-
-/**
- * Initialize a new fragment program object.
- */
-struct gl_program *
-_mesa_init_fragment_program(struct gl_context *ctx,
-                            struct gl_fragment_program *prog,
-                            GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
-}
-
-
-/**
- * Initialize a new vertex program object.
- */
-struct gl_program *
-_mesa_init_vertex_program(struct gl_context *ctx,
-                          struct gl_vertex_program *prog,
-                          GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
-}
-
-
-/**
- * Initialize a new compute program object.
- */
-struct gl_program *
-_mesa_init_compute_program(struct gl_context *ctx,
-                           struct gl_compute_program *prog,
-                           GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
-}
-
 
-/**
- * Initialize a new tessellation control program object.
- */
-struct gl_program *
-_mesa_init_tess_ctrl_program(struct gl_context *ctx,
-                             struct gl_tess_ctrl_program *prog,
-                             GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
-}
-
-
-/**
- * Initialize a new tessellation evaluation program object.
- */
-struct gl_program *
-_mesa_init_tess_eval_program(struct gl_context *ctx,
-                             struct gl_tess_eval_program *prog,
-                             GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
-}
-
-
-/**
- * Initialize a new geometry program object.
- */
-struct gl_program *
-_mesa_init_geometry_program(struct gl_context *ctx,
-                            struct gl_geometry_program *prog,
-                            GLenum target, GLuint id)
-{
-   if (prog) {
-      init_program_struct(&prog->Base, target, id);
-      return &prog->Base;
-   }
-   return NULL;
+   return prog;
 }
 
 
@@ -309,34 +217,29 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
    struct gl_program *prog;
    switch (target) {
    case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
-      prog = _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program),
-                                       target, id );
+      prog = _mesa_init_gl_program(CALLOC_STRUCT(gl_vertex_program),
+                                   target, id);
       break;
    case GL_FRAGMENT_PROGRAM_NV:
    case GL_FRAGMENT_PROGRAM_ARB:
-      prog =_mesa_init_fragment_program(ctx,
-                                         CALLOC_STRUCT(gl_fragment_program),
-                                         target, id );
+      prog =_mesa_init_gl_program(CALLOC_STRUCT(gl_fragment_program),
+                                  target, id);
       break;
    case GL_GEOMETRY_PROGRAM_NV:
-      prog = _mesa_init_geometry_program(ctx,
-                                         CALLOC_STRUCT(gl_geometry_program),
-                                         target, id);
+      prog = _mesa_init_gl_program(CALLOC_STRUCT(gl_geometry_program),
+                                   target, id);
       break;
    case GL_TESS_CONTROL_PROGRAM_NV:
-      prog = _mesa_init_tess_ctrl_program(ctx,
-                                          CALLOC_STRUCT(gl_tess_ctrl_program),
-                                          target, id);
+      prog = _mesa_init_gl_program(CALLOC_STRUCT(gl_tess_ctrl_program),
+                                   target, id);
       break;
    case GL_TESS_EVALUATION_PROGRAM_NV:
-      prog = _mesa_init_tess_eval_program(ctx,
-                                         CALLOC_STRUCT(gl_tess_eval_program),
-                                         target, id);
+      prog = _mesa_init_gl_program(CALLOC_STRUCT(gl_tess_eval_program),
+                                   target, id);
       break;
    case GL_COMPUTE_PROGRAM_NV:
-      prog = _mesa_init_compute_program(ctx,
-                                        CALLOC_STRUCT(gl_compute_program),
-                                        target, id);
+      prog = _mesa_init_gl_program(CALLOC_STRUCT(gl_compute_program),
+                                   target, id);
       break;
    default:
       _mesa_problem(ctx, "bad target in _mesa_new_program");
index 6f54fac4f32b2cc93243b204d80b0c9ecb3b5956..51e10a1708b61c455ee7d8bec9f120ceab00b1ac 100644 (file)
@@ -64,34 +64,7 @@ extern void
 _mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string);
 
 extern struct gl_program *
-_mesa_init_vertex_program(struct gl_context *ctx,
-                          struct gl_vertex_program *prog,
-                          GLenum target, GLuint id);
-
-extern struct gl_program *
-_mesa_init_fragment_program(struct gl_context *ctx,
-                            struct gl_fragment_program *prog,
-                            GLenum target, GLuint id);
-
-extern struct gl_program *
-_mesa_init_tess_ctrl_program(struct gl_context *ctx,
-                            struct gl_tess_ctrl_program *prog,
-                            GLenum target, GLuint id);
-
-extern struct gl_program *
-_mesa_init_tess_eval_program(struct gl_context *ctx,
-                            struct gl_tess_eval_program *prog,
-                            GLenum target, GLuint id);
-
-extern struct gl_program *
-_mesa_init_geometry_program(struct gl_context *ctx,
-                            struct gl_geometry_program *prog,
-                            GLenum target, GLuint id);
-
-extern struct gl_program *
-_mesa_init_compute_program(struct gl_context *ctx,
-                           struct gl_compute_program *prog,
-                           GLenum target, GLuint id);
+_mesa_init_gl_program(void *prog, GLenum target, GLuint id);
 
 extern struct gl_program *
 _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id);
index 003ce336fd4bb2ad42e7e1f4e22388e4b93b9de6..40f2af0e550a088b0c22ea2bb999409efc629f4f 100644 (file)
@@ -102,36 +102,29 @@ st_use_program(struct gl_context *ctx, struct gl_shader_program *shProg)
 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_vertex_program(ctx, &prog->Base, target, id);
-   }
-
-   case GL_FRAGMENT_PROGRAM_ARB: {
-      struct st_fragment_program *prog = ST_CALLOC_STRUCT(st_fragment_program);
-      return _mesa_init_fragment_program(ctx, &prog->Base, target, id);
-   }
-
-   case GL_GEOMETRY_PROGRAM_NV: {
-      struct st_geometry_program *prog = ST_CALLOC_STRUCT(st_geometry_program);
-      return _mesa_init_geometry_program(ctx, &prog->Base, target, id);
-   }
-
-   case GL_TESS_CONTROL_PROGRAM_NV: {
-      struct st_tessctrl_program *prog = ST_CALLOC_STRUCT(st_tessctrl_program);
-      return _mesa_init_tess_ctrl_program(ctx, &prog->Base, target, id);
-   }
-
-   case GL_TESS_EVALUATION_PROGRAM_NV: {
-      struct st_tesseval_program *prog = ST_CALLOC_STRUCT(st_tesseval_program);
-      return _mesa_init_tess_eval_program(ctx, &prog->Base, target, id);
-   }
+   struct gl_program *prog;
 
+   switch (target) {
+   case GL_VERTEX_PROGRAM_ARB:
+      prog = (struct gl_program*)ST_CALLOC_STRUCT(st_vertex_program);
+      break;
+   case GL_FRAGMENT_PROGRAM_ARB:
+      prog = (struct gl_program*)ST_CALLOC_STRUCT(st_fragment_program);
+      break;
+   case GL_GEOMETRY_PROGRAM_NV:
+      prog = (struct gl_program*)ST_CALLOC_STRUCT(st_geometry_program);
+      break;
+   case GL_TESS_CONTROL_PROGRAM_NV:
+      prog = (struct gl_program*)ST_CALLOC_STRUCT(st_tessctrl_program);
+      break;
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+      prog = (struct gl_program*)ST_CALLOC_STRUCT(st_tesseval_program);
+      break;
    default:
       assert(0);
       return NULL;
    }
+   return _mesa_init_gl_program(prog, target, id);
 }