/* Create program and attach it to the linked shader */
struct gl_program *gl_prog =
- ctx->Driver.NewProgram(ctx,
- _mesa_shader_stage_to_program(shader_list[0]->Stage),
- prog->Name, false);
+ ctx->Driver.NewProgram(ctx, shader_list[0]->Stage, prog->Name, false);
if (!gl_prog) {
prog->data->LinkStatus = LINKING_FAILURE;
_mesa_delete_linked_shader(ctx, linked);
struct gl_linked_shader *linked = rzalloc(NULL, struct gl_linked_shader);
linked->Stage = stage;
- glprog = ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage),
- prog->Name, false);
+ glprog = ctx->Driver.NewProgram(ctx, stage, prog->Name, false);
glprog->info.stage = stage;
linked->Program = glprog;
};
static void
-init_gl_program(struct gl_program *prog, bool is_arb_asm, GLenum target)
+init_gl_program(struct gl_program *prog, bool is_arb_asm, gl_shader_stage stage)
{
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
prog->is_arb_asm = is_arb_asm;
- prog->info.stage = (gl_shader_stage)_mesa_program_enum_to_shader_stage(target);
+ prog->info.stage = stage;
}
static struct gl_program *
-new_program(UNUSED struct gl_context *ctx, GLenum target,
+new_program(UNUSED struct gl_context *ctx, gl_shader_stage stage,
UNUSED GLuint id, bool is_arb_asm)
{
- 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 = rzalloc(NULL, struct gl_program);
- init_gl_program(prog, is_arb_asm, target);
- return prog;
- }
- default:
- printf("bad target in new_program\n");
- return NULL;
- }
+ struct gl_program *prog = rzalloc(NULL, struct gl_program);
+ init_gl_program(prog, is_arb_asm, stage);
+ return prog;
}
static const struct standalone_options *options;
}
static struct gl_program *
-i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id,
+i915NewProgram(struct gl_context * ctx, gl_shader_stage stage, GLuint id,
bool is_arb_asm)
{
- switch (target) {
- case GL_VERTEX_PROGRAM_ARB: {
+ switch (stage) {
+ case MESA_SHADER_VERTEX: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id, is_arb_asm);
+ return _mesa_init_gl_program(prog, stage, id, is_arb_asm);
}
- case GL_FRAGMENT_PROGRAM_ARB:{
+ case MESA_SHADER_FRAGMENT:{
struct i915_fragment_program *prog =
rzalloc(NULL, struct i915_fragment_program);
if (prog) {
i915_init_program(I915_CONTEXT(ctx), prog);
- return _mesa_init_gl_program(&prog->FragProg, target, id,
+ return _mesa_init_gl_program(&prog->FragProg, stage, id,
is_arb_asm);
}
else
default:
/* Just fallback:
*/
- return _mesa_new_program(ctx, target, id, is_arb_asm);
+ return _mesa_new_program(ctx, stage, id, is_arb_asm);
}
}
}
}
-static struct gl_program *brwNewProgram(struct gl_context *ctx, GLenum target,
+static struct gl_program *brwNewProgram(struct gl_context *ctx,
+ gl_shader_stage stage,
GLuint id, bool is_arb_asm);
nir_shader *
return p_atomic_inc_return(&screen->program_id);
}
-static struct gl_program *brwNewProgram(struct gl_context *ctx, GLenum target,
+static struct gl_program *brwNewProgram(struct gl_context *ctx,
+ gl_shader_stage stage,
GLuint id, bool is_arb_asm)
{
struct brw_context *brw = brw_context(ctx);
if (prog) {
prog->id = get_new_program_id(brw->screen);
- return _mesa_init_gl_program(&prog->program, target, id, is_arb_asm);
+ return _mesa_init_gl_program(&prog->program, stage, id, is_arb_asm);
}
return NULL;
static struct gl_program *
-r200NewProgram(struct gl_context *ctx, GLenum target, GLuint id,
+r200NewProgram(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
bool is_arb_asm)
{
- switch(target){
- case GL_VERTEX_PROGRAM_ARB: {
+ switch(stage){
+ case MESA_SHADER_VERTEX: {
struct r200_vertex_program *vp = rzalloc(NULL,
struct r200_vertex_program);
- return _mesa_init_gl_program(&vp->mesa_program, target, id, is_arb_asm);
+ return _mesa_init_gl_program(&vp->mesa_program, stage, id, is_arb_asm);
}
- case GL_FRAGMENT_PROGRAM_ARB: {
+ case MESA_SHADER_FRAGMENT: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id, is_arb_asm);
+ return _mesa_init_gl_program(prog, stage, id, is_arb_asm);
}
default:
_mesa_problem(ctx, "Bad target in r200NewProgram");
newProg = _mesa_lookup_program(ctx, id);
if (!newProg || newProg == &_mesa_DummyProgram) {
/* allocate a new program now */
- newProg = ctx->Driver.NewProgram(ctx, target, id, true);
+ newProg = ctx->Driver.NewProgram(ctx, _mesa_program_enum_to_shader_stage(target),
+ id, true);
if (!newProg) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
return NULL;
#include "glheader.h"
#include "formats.h"
#include "menums.h"
+#include "compiler/shader_enums.h"
struct gl_bitmap_atlas;
struct gl_buffer_object;
*/
/*@{*/
/** Allocate a new program */
- struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target,
+ struct gl_program * (*NewProgram)(struct gl_context *ctx,
+ gl_shader_stage stage,
GLuint id, bool is_arb_asm);
/** Delete a program */
void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
if (0)
printf("Build new TNL program\n");
- prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true);
+ prog = ctx->Driver.NewProgram(ctx, MESA_SHADER_VERTEX, 0, true);
if (!prog)
return NULL;
/* Create program and attach it to the linked shader */
struct gl_program *gl_prog =
- ctx->Driver.NewProgram(ctx,
- _mesa_shader_stage_to_program(shader_type),
- prog->Name, false);
+ ctx->Driver.NewProgram(ctx, shader_type, prog->Name, false);
if (!gl_prog) {
prog->data->LinkStatus = LINKING_FAILURE;
_mesa_delete_linked_shader(ctx, linked);
shared->Programs = _mesa_NewHashTable();
shared->DefaultVertexProgram =
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true);
+ ctx->Driver.NewProgram(ctx, MESA_SHADER_VERTEX, 0, true);
shared->DefaultFragmentProgram =
- ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0, true);
+ ctx->Driver.NewProgram(ctx, MESA_SHADER_FRAGMENT, 0, true);
shared->ATIShaders = _mesa_NewHashTable();
shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0);
* Initialize a new gl_program object.
*/
struct gl_program *
-_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
- bool is_arb_asm)
+_mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
+ GLuint id, bool is_arb_asm)
{
if (!prog)
return NULL;
memset(prog, 0, sizeof(*prog));
prog->Id = id;
- prog->Target = target;
+ prog->Target = _mesa_shader_stage_to_program(stage);
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- prog->info.stage = _mesa_program_enum_to_shader_stage(target);
+ prog->info.stage = stage;
prog->is_arb_asm = is_arb_asm;
/* Uniforms that lack an initializer in the shader code have an initial
*
* \param ctx context
* \param id program id/number
- * \param target program target/type
+ * \param stage shader stage
* \return pointer to new program object
*/
struct gl_program *
-_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
bool is_arb_asm)
{
- 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 = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id, is_arb_asm);
- }
- default:
- _mesa_problem(ctx, "bad target in _mesa_new_program");
- return NULL;
- }
+ struct gl_program *prog = rzalloc(NULL, struct gl_program);
+
+ return _mesa_init_gl_program(prog, stage, id, is_arb_asm);
}
_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string);
extern struct gl_program *
-_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
- bool is_arb_asm);
+_mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
+ GLuint id, bool is_arb_asm);
extern struct gl_program *
-_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
bool is_arb_asm);
extern void
* fragment program.
*/
static struct gl_program *
-st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+st_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
bool is_arb_asm)
{
- switch (target) {
- case GL_VERTEX_PROGRAM_ARB: {
- struct st_vertex_program *prog = rzalloc(NULL, struct st_vertex_program);
- return _mesa_init_gl_program(&prog->Base.Base, target, id, is_arb_asm);
- }
- case GL_TESS_CONTROL_PROGRAM_NV:
- case GL_TESS_EVALUATION_PROGRAM_NV:
- case GL_GEOMETRY_PROGRAM_NV:
- case GL_FRAGMENT_PROGRAM_ARB:
- case GL_COMPUTE_PROGRAM_NV: {
- struct st_program *prog = rzalloc(NULL, struct st_program);
- return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
- }
+ struct st_program *prog;
+
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ prog = (struct st_program*)rzalloc(NULL, struct st_vertex_program);
+ break;
default:
- assert(0);
- return NULL;
+ prog = rzalloc(NULL, struct st_program);
+ break;
}
+
+ return _mesa_init_gl_program(&prog->Base, stage, id, is_arb_asm);
}
static struct gl_program *
st_new_ati_fs(struct gl_context *ctx, struct ati_fragment_shader *curProg)
{
- struct gl_program *prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
+ struct gl_program *prog = ctx->Driver.NewProgram(ctx, MESA_SHADER_FRAGMENT,
curProg->Id, true);
struct st_program *stfp = (struct st_program *)prog;
stfp->ati_fs = curProg;