diff options
Diffstat (limited to 'src/mesa/shader')
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 6 | ||||
-rw-r--r-- | src/mesa/shader/arbprogram.c | 4 | ||||
-rw-r--r-- | src/mesa/shader/descrip.mms | 93 | ||||
-rw-r--r-- | src/mesa/shader/grammar/sources | 8 | ||||
-rw-r--r-- | src/mesa/shader/nvfragparse.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/nvprogram.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/prog_execute.c | 3 | ||||
-rw-r--r-- | src/mesa/shader/prog_statevars.c | 120 | ||||
-rw-r--r-- | src/mesa/shader/prog_statevars.h | 13 | ||||
-rw-r--r-- | src/mesa/shader/prog_uniform.c | 4 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 118 | ||||
-rw-r--r-- | src/mesa/shader/program.h | 16 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 10 | ||||
-rw-r--r-- | src/mesa/shader/slang/descrip.mms | 68 | ||||
-rw-r--r--[-rwxr-xr-x] | src/mesa/shader/slang/library/slang_pp_directives.syn | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/mesa/shader/slang/library/slang_pp_expression.syn | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/mesa/shader/slang/library/slang_version.syn | 0 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_link.c | 1 | ||||
-rw-r--r-- | src/mesa/shader/slang/sources | 44 | ||||
-rw-r--r-- | src/mesa/shader/sources | 28 |
20 files changed, 416 insertions, 124 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 466ae48bef3..f499499eb3a 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -53,15 +53,15 @@ having three separate program parameter arrays. #include "main/glheader.h" #include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mtypes.h" #include "shader/grammar/grammar_mesa.h" #include "arbprogparse.h" #include "program.h" #include "programopt.h" #include "prog_parameter.h" #include "prog_statevars.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/mtypes.h" #include "prog_instruction.h" diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index beb5deea505..760dac23993 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -30,13 +30,13 @@ #include "main/glheader.h" -#include "arbprogram.h" -#include "arbprogparse.h" #include "main/context.h" #include "main/hash.h" #include "main/imports.h" #include "main/macros.h" #include "main/mtypes.h" +#include "arbprogram.h" +#include "arbprogparse.h" #include "program.h" diff --git a/src/mesa/shader/descrip.mms b/src/mesa/shader/descrip.mms new file mode 100644 index 00000000000..bdac946efe2 --- /dev/null +++ b/src/mesa/shader/descrip.mms @@ -0,0 +1,93 @@ +# Makefile for core library for VMS +# contributed by Jouk Jansen [email protected] +# Last revision : 27 May 2008 +.first + define gl [---.include.gl] + define math [-.math] + define swrast [-.swrast] + define array_cache [-.array_cache] + define glapi [-.glapi] + define main [-.main] + define shader [-.shader] + +.include [---]mms-config. + +##### MACROS ##### + +VPATH = RCS + +INCDIR = [---.include],[.grammar],[-.main],[-.glapi],[.slang] +LIBDIR = [---.lib] +CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1,"__extension__=")/name=(as_is,short)/float=ieee/ieee=denorm + +SOURCES = \ + atifragshader.c \ + arbprogparse.c \ + arbprogram.c \ + nvfragparse.c \ + nvprogram.c \ + nvvertparse.c \ + program.c \ + programopt.c \ + prog_debug.c \ + prog_execute.c \ + prog_instruction.c \ + prog_parameter.c \ + prog_print.c \ + prog_statevars.c \ + shader_api.c prog_uniform.c + +OBJECTS = \ + atifragshader.obj,\ + arbprogparse.obj,\ + arbprogram.obj,\ + nvfragparse.obj,\ + nvprogram.obj,\ + nvvertparse.obj,\ + program.obj,\ + programopt.obj,\ + prog_debug.obj,\ + prog_execute.obj,\ + prog_instruction.obj,\ + prog_parameter.obj,\ + prog_print.obj,\ + prog_statevars.obj,\ + shader_api.obj,prog_uniform.obj + +##### RULES ##### + +VERSION=Mesa V3.4 + +##### TARGETS ##### +all : + $(MMS)$(MMSQUALIFIERS) $(LIBDIR)$(GL_LIB) + set def [.slang] + $(MMS)$(MMSQUALIFIERS) + set def [-.grammar] + $(MMS)$(MMSQUALIFIERS) + set def [-] + +# Make the library +$(LIBDIR)$(GL_LIB) : $(OBJECTS) + @ library $(LIBDIR)$(GL_LIB) $(OBJECTS) + +clean : + purge + delete *.obj;* + +atifragshader.obj : atifragshader.c +arbprogparse.obj : arbprogparse.c +arbprogram.obj : arbprogram.c +nvfragparse.obj : nvfragparse.c +nvprogram.obj : nvprogram.c +nvvertparse.obj : nvvertparse.c +program.obj : program.c +programopt. obj : programopt.c +prog_debug.obj : prog_debug.c +prog_execute.obj : prog_execute.c +prog_instruction.obj : prog_instruction.c +prog_parameter.obj : prog_parameter.c +prog_print.obj : prog_print.c +prog_statevars.obj : prog_statevars.c +shader_api.obj : shader_api.c +prog_uniform.obj : prog_uniform.c diff --git a/src/mesa/shader/grammar/sources b/src/mesa/shader/grammar/sources deleted file mode 100644 index a6bbfd3ffd3..00000000000 --- a/src/mesa/shader/grammar/sources +++ /dev/null @@ -1,8 +0,0 @@ -MESA_SHADER_GRAMMAR_SOURCES = \ -grammar_mesa.c - -MESA_SHADER_GRAMMAR_HEADERS = \ -grammar.c \ -grammar.h \ -grammar_mesa.h \ -grammar_syn.h diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index a2a7a5f3f49..20e47813729 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -41,10 +41,10 @@ #include "main/context.h" #include "main/imports.h" #include "main/macros.h" +#include "program.h" #include "prog_parameter.h" #include "prog_instruction.h" #include "nvfragparse.h" -#include "program.h" #define INPUT_1V 1 diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c index d656d4b28b6..88272fff3ff 100644 --- a/src/mesa/shader/nvprogram.c +++ b/src/mesa/shader/nvprogram.c @@ -42,12 +42,12 @@ #include "main/hash.h" #include "main/imports.h" #include "main/macros.h" +#include "program.h" #include "prog_parameter.h" #include "prog_instruction.h" #include "nvfragparse.h" #include "nvvertparse.h" #include "nvprogram.h" -#include "program.h" diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 5afd9eb1534..32b6ff4fd42 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -90,7 +90,8 @@ get_register_pointer(const struct prog_src_register *source, const struct gl_program_parameter_list *params; ASSERT(source->File == PROGRAM_LOCAL_PARAM || source->File == PROGRAM_CONSTANT || - source->File == PROGRAM_STATE_VAR); + source->File == PROGRAM_STATE_VAR || + source->File == PROGRAM_UNIFORM); params = machine->CurProgram->Parameters; if (reg < 0 || reg >= (GLint)params->NumParameters) return ZeroVec; diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 8acf37c3c08..d4e31207e84 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -131,7 +131,7 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], ADD_3V(value, p, eye_z); NORMALIZE_3FV(value); value[3] = 1.0; - } + } return; default: _mesa_problem(ctx, "Invalid light state in fetch_state"); @@ -235,11 +235,11 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], } } case STATE_TEXENV_COLOR: - { + { /* state[1] is the texture unit */ const GLuint unit = (GLuint) state[1]; COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); - } + } return; case STATE_FOG_COLOR: COPY_4V(value, ctx->Fog.Color); @@ -369,7 +369,7 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], } } return; - + case STATE_VERTEX_PROGRAM: { /* state[1] = {STATE_ENV, STATE_LOCAL} */ @@ -469,7 +469,6 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], } - case STATE_PT_SCALE: value[0] = ctx->Pixel.RedScale; value[1] = ctx->Pixel.GreenScale; @@ -488,6 +487,20 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], case STATE_PCM_BIAS: COPY_4V(value, ctx->Pixel.PostColorMatrixBias); break; + case STATE_SHADOW_AMBIENT: + { + const int unit = (int) state[2]; + const struct gl_texture_object *texObj + = ctx->Texture.Unit[unit]._Current; + if (texObj) { + value[0] = texObj->ShadowAmbient; + value[1] = texObj->ShadowAmbient; + value[2] = texObj->ShadowAmbient; + value[3] = texObj->ShadowAmbient; + } + } + return; + default: /* unknown state indexes are silently ignored * should be handled by the driver. @@ -562,6 +575,7 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_INTERNAL: switch (state[1]) { case STATE_TEXRECT_SCALE: + case STATE_SHADOW_AMBIENT: return _NEW_TEXTURE; case STATE_FOG_PARAMS_OPTIMIZED: return _NEW_FOG; @@ -740,6 +754,9 @@ append_token(char *dst, gl_state_index k) case STATE_PCM_BIAS: append(dst, "PCMbias"); break; + case STATE_SHADOW_AMBIENT: + append(dst, "ShadowAmbient"); + break; default: ; } @@ -890,10 +907,101 @@ _mesa_load_state_parameters(GLcontext *ctx, for (i = 0; i < paramList->NumParameters; i++) { if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) { - _mesa_fetch_state(ctx, + _mesa_fetch_state(ctx, (gl_state_index *) paramList->Parameters[i].StateIndexes, paramList->ParameterValues[i]); } } } + +/** + * Copy the 16 elements of a matrix into four consecutive program + * registers starting at 'pos'. + */ +static void +load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16]) +{ + GLuint i; + for (i = 0; i < 4; i++) { + registers[pos + i][0] = mat[0 + i]; + registers[pos + i][1] = mat[4 + i]; + registers[pos + i][2] = mat[8 + i]; + registers[pos + i][3] = mat[12 + i]; + } +} + + +/** + * As above, but transpose the matrix. + */ +static void +load_transpose_matrix(GLfloat registers[][4], GLuint pos, + const GLfloat mat[16]) +{ + MEMCPY(registers[pos], mat, 16 * sizeof(GLfloat)); +} + + +/** + * Load current vertex program's parameter registers with tracked + * matrices (if NV program). This only needs to be done per + * glBegin/glEnd, not per-vertex. + */ +void +_mesa_load_tracked_matrices(GLcontext *ctx) +{ + GLuint i; + + for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) { + /* point 'mat' at source matrix */ + GLmatrix *mat; + if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) { + mat = ctx->ModelviewMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) { + mat = ctx->ProjectionMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) { + mat = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_COLOR) { + mat = ctx->ColorMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) { + /* XXX verify the combined matrix is up to date */ + mat = &ctx->_ModelProjectMatrix; + } + else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV && + ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) { + GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV; + ASSERT(n < MAX_PROGRAM_MATRICES); + mat = ctx->ProgramMatrixStack[n].Top; + } + else { + /* no matrix is tracked, but we leave the register values as-is */ + assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE); + continue; + } + + /* load the matrix values into sequential registers */ + if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) { + load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); + } + else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) { + _math_matrix_analyse(mat); /* update the inverse */ + ASSERT(!_math_matrix_is_dirty(mat)); + load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); + } + else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) { + load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); + } + else { + assert(ctx->VertexProgram.TrackMatrixTransform[i] + == GL_INVERSE_TRANSPOSE_NV); + _math_matrix_analyse(mat); /* update the inverse */ + ASSERT(!_math_matrix_is_dirty(mat)); + load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); + } + } +} diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 7b490e3d630..20643ca7947 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 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"), @@ -77,7 +77,7 @@ typedef enum gl_state_index_ { STATE_SPECULAR, STATE_EMISSION, STATE_SHININESS, - STATE_HALF_VECTOR, + STATE_HALF_VECTOR, STATE_POSITION, STATE_ATTENUATION, @@ -94,7 +94,7 @@ typedef enum gl_state_index_ { STATE_TEXGEN_OBJECT_Q, STATE_TEXENV_COLOR, - + STATE_DEPTH_RANGE, STATE_VERTEX_PROGRAM, @@ -115,6 +115,7 @@ typedef enum gl_state_index_ { STATE_PT_BIAS, /**< Pixel transfer RGBA bias */ STATE_PCM_SCALE, /**< Post color matrix RGBA scale */ STATE_PCM_BIAS, /**< Post color matrix RGBA bias */ + STATE_SHADOW_AMBIENT, /**< ARB_shadow_ambient fail value; token[2] is texture unit index */ STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */ } gl_state_index; @@ -133,4 +134,8 @@ extern char * _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]); +extern void +_mesa_load_tracked_matrices(GLcontext *ctx); + + #endif /* PROG_STATEVARS_H */ diff --git a/src/mesa/shader/prog_uniform.c b/src/mesa/shader/prog_uniform.c index f57df3d86dc..25d7c0997bc 100644 --- a/src/mesa/shader/prog_uniform.c +++ b/src/mesa/shader/prog_uniform.c @@ -134,8 +134,8 @@ _mesa_longest_uniform_name(const struct gl_uniform_list *list) GLint max = 0; GLuint i; for (i = 0; list && i < list->NumUniforms; i++) { - GLuint len = _mesa_strlen(list->Uniforms[i].Name); - if (len > (GLuint)max) + GLint len = (GLint)_mesa_strlen(list->Uniforms[i].Name); + if (len > max) max = len; } return max; diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index b03dd24d112..6263fd277f8 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -121,6 +121,43 @@ _mesa_free_program_data(GLcontext *ctx) /** + * Update the default program objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_program(GLcontext *ctx) +{ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, + (struct gl_vertex_program *) + ctx->Shared->DefaultVertexProgram); + assert(ctx->VertexProgram.Current); +#endif + +#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, + (struct gl_fragment_program *) + ctx->Shared->DefaultFragmentProgram); + assert(ctx->FragmentProgram.Current); +#endif + + /* XXX probably move this stuff */ +#if FEATURE_ATI_fragment_shader + if (ctx->ATIFragmentShader.Current) { + ctx->ATIFragmentShader.Current->RefCount--; + if (ctx->ATIFragmentShader.Current->RefCount <= 0) { + _mesa_free(ctx->ATIFragmentShader.Current); + } + } + ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader; + assert(ctx->ATIFragmentShader.Current); + ctx->ATIFragmentShader.Current->RefCount++; +#endif +} + + +/** * Set the vertex/fragment program error state (position and error string). * This is generally called from within the parsers. */ @@ -211,7 +248,7 @@ struct gl_program * _mesa_init_fragment_program( GLcontext *ctx, struct gl_fragment_program *prog, GLenum target, GLuint id) { - if (prog) + if (prog) return _mesa_init_program_struct( ctx, &prog->Base, target, id ); else return NULL; @@ -225,7 +262,7 @@ struct gl_program * _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog, GLenum target, GLuint id) { - if (prog) + if (prog) return _mesa_init_program_struct( ctx, &prog->Base, target, id ); else return NULL; @@ -238,7 +275,7 @@ _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog, * 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 @@ -247,19 +284,23 @@ _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog, struct gl_program * _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id) { + struct gl_program *prog; switch (target) { case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ - return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), + prog = _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), target, id ); + break; case GL_FRAGMENT_PROGRAM_NV: case GL_FRAGMENT_PROGRAM_ARB: - return _mesa_init_fragment_program(ctx, + prog =_mesa_init_fragment_program(ctx, CALLOC_STRUCT(gl_fragment_program), target, id ); + break; default: _mesa_problem(ctx, "bad target in _mesa_new_program"); - return NULL; + prog = NULL; } + return prog; } @@ -278,7 +319,7 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) if (prog == &_mesa_DummyProgram) return; - + if (prog->String) _mesa_free(prog->String); @@ -341,15 +382,17 @@ _mesa_reference_program(GLcontext *ctx, /*_glthread_LOCK_MUTEX((*ptr)->Mutex);*/ #if 0 - printf("Program %p %u 0x%x Refcount-- to %d\n", - *ptr, (*ptr)->Id, (*ptr)->Target, (*ptr)->RefCount - 1); + printf("Program %p ID=%u Target=%s Refcount-- to %d\n", + *ptr, (*ptr)->Id, + ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP"), + (*ptr)->RefCount - 1); #endif ASSERT((*ptr)->RefCount > 0); (*ptr)->RefCount--; deleteFlag = ((*ptr)->RefCount == 0); /*_glthread_UNLOCK_MUTEX((*ptr)->Mutex);*/ - + if (deleteFlag) { ASSERT(ctx); ctx->Driver.DeleteProgram(ctx, *ptr); @@ -363,8 +406,10 @@ _mesa_reference_program(GLcontext *ctx, /*_glthread_LOCK_MUTEX(prog->Mutex);*/ prog->RefCount++; #if 0 - printf("Program %p %u 0x%x Refcount++ to %d\n", - prog, prog->Id, prog->Target, prog->RefCount); + printf("Program %p ID=%u Target=%s Refcount++ to %d\n", + prog, prog->Id, + (prog->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP"), + prog->RefCount); #endif /*_glthread_UNLOCK_MUTEX(prog->Mutex);*/ } @@ -402,6 +447,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog) clone->InputsRead = prog->InputsRead; clone->OutputsWritten = prog->OutputsWritten; clone->SamplersUsed = prog->SamplersUsed; + clone->ShadowSamplers = prog->ShadowSamplers; memcpy(clone->TexturesUsed, prog->TexturesUsed, sizeof(prog->TexturesUsed)); if (prog->Parameters) @@ -471,7 +517,7 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count) for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = prog->Instructions + i; if (inst->BranchTarget > 0) { - if ((GLuint)inst->BranchTarget >= start) { + if (inst->BranchTarget >= start) { inst->BranchTarget += count; } } @@ -504,6 +550,52 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count) return GL_TRUE; } +/** + * Delete 'count' instructions at 'start' in the given program. + * Adjust branch targets accordingly. + */ +GLboolean +_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count) +{ + const GLuint origLen = prog->NumInstructions; + const GLuint newLen = origLen - count; + struct prog_instruction *newInst; + GLuint i; + + /* adjust branches */ + for (i = 0; i < prog->NumInstructions; i++) { + struct prog_instruction *inst = prog->Instructions + i; + if (inst->BranchTarget > 0) { + if (inst->BranchTarget >= start) { + inst->BranchTarget -= count; + } + } + } + + /* Alloc storage for new instructions */ + newInst = _mesa_alloc_instructions(newLen); + if (!newInst) { + return GL_FALSE; + } + + /* Copy 'start' instructions into new instruction buffer */ + _mesa_copy_instructions(newInst, prog->Instructions, start); + + /* Copy the remaining/tail instructions to new inst buffer */ + _mesa_copy_instructions(newInst + start, + prog->Instructions + start + count, + newLen - start); + + /* free old instructions */ + _mesa_free_instructions(prog->Instructions, origLen); + + /* install new instructions */ + prog->Instructions = newInst; + prog->NumInstructions = newLen; + + return GL_TRUE; +} + /** * Search instructions for registers that match (oldFile, oldIndex), diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index f8bd63233ed..48176162c35 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -53,6 +53,9 @@ extern void _mesa_free_program_data(GLcontext *ctx); extern void +_mesa_update_default_objects_program(GLcontext *ctx); + +extern void _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string); extern const GLubyte * @@ -60,13 +63,13 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos, GLint *line, GLint *col); -extern struct gl_program * -_mesa_init_vertex_program(GLcontext *ctx, - struct gl_vertex_program *prog, +extern struct gl_program * +_mesa_init_vertex_program(GLcontext *ctx, + struct gl_vertex_program *prog, GLenum target, GLuint id); -extern struct gl_program * -_mesa_init_fragment_program(GLcontext *ctx, +extern struct gl_program * +_mesa_init_fragment_program(GLcontext *ctx, struct gl_fragment_program *prog, GLenum target, GLuint id); @@ -108,6 +111,9 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog); extern GLboolean _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count); +extern GLboolean +_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count); + extern struct gl_program * _mesa_combine_programs(GLcontext *ctx, const struct gl_program *progA, diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index decdec53ed2..eb7b71341f5 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -39,11 +39,11 @@ #include "main/context.h" #include "main/hash.h" #include "main/macros.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_statevars.h" -#include "prog_uniform.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" +#include "shader/prog_statevars.h" +#include "shader/prog_uniform.h" #include "shader/shader_api.h" #include "shader/slang/slang_compile.h" #include "shader/slang/slang_link.h" diff --git a/src/mesa/shader/slang/descrip.mms b/src/mesa/shader/slang/descrip.mms new file mode 100644 index 00000000000..6eefbcf5bdd --- /dev/null +++ b/src/mesa/shader/slang/descrip.mms @@ -0,0 +1,68 @@ +# Makefile for core library for VMS +# contributed by Jouk Jansen [email protected] +# Last revision : 3 October 2007 + +.first + define gl [----.include.gl] + define math [--.math] + define swrast [--.swrast] + define array_cache [--.array_cache] + define main [--.main] + define glapi [--.glapi] + define shader [--.shader] + +.include [----]mms-config. + +##### MACROS ##### + +VPATH = RCS + +INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-.grammar],[-] +LIBDIR = [----.lib] +CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm + +SOURCES = \ + slang_compile.c,slang_preprocess.c + +OBJECTS = slang_builtin.obj,slang_codegen.obj,slang_compile.obj,\ + slang_compile_function.obj,slang_compile_operation.obj,\ + slang_compile_struct.obj,slang_compile_variable.obj,slang_emit.obj,\ + slang_ir.obj,slang_label.obj,slang_library_noise.obj,slang_link.obj,\ + slang_log.obj,slang_mem.obj,slang_preprocess.obj,slang_print.obj,\ + slang_simplify.obj,slang_storage.obj,slang_typeinfo.obj,\ + slang_utility.obj,slang_vartable.obj + +##### RULES ##### + +VERSION=Mesa V3.4 + +##### TARGETS ##### +# Make the library +$(LIBDIR)$(GL_LIB) : $(OBJECTS) + @ library $(LIBDIR)$(GL_LIB) $(OBJECTS) + +clean : + purge + delete *.obj;* + +slang_builtin.obj : slang_builtin.c +slang_codegen.obj : slang_codegen.c +slang_compile.obj : slang_compile.c +slang_compile_function.obj : slang_compile_function.c +slang_compile_operation.obj : slang_compile_operation.c +slang_compile_struct.obj : slang_compile_struct.c +slang_compile_variable.obj : slang_compile_variable.c +slang_emit.obj : slang_emit.c +slang_ir.obj : slang_ir.c +slang_label.obj : slang_label.c +slang_library_noise.obj : slang_library_noise.c +slang_link.obj : slang_link.c +slang_log.obj : slang_log.c +slang_mem.obj : slang_mem.c +slang_preprocess.obj : slang_preprocess.c +slang_print.obj : slang_print.c +slang_simplify.obj : slang_simplify.c +slang_storage.obj : slang_storage.c +slang_typeinfo.obj : slang_typeinfo.c +slang_utility.obj : slang_utility.c +slang_vartable.obj : slang_vartable.c diff --git a/src/mesa/shader/slang/library/slang_pp_directives.syn b/src/mesa/shader/slang/library/slang_pp_directives.syn index d4a321034d1..d4a321034d1 100755..100644 --- a/src/mesa/shader/slang/library/slang_pp_directives.syn +++ b/src/mesa/shader/slang/library/slang_pp_directives.syn diff --git a/src/mesa/shader/slang/library/slang_pp_expression.syn b/src/mesa/shader/slang/library/slang_pp_expression.syn index bfdb220bf5c..bfdb220bf5c 100755..100644 --- a/src/mesa/shader/slang/library/slang_pp_expression.syn +++ b/src/mesa/shader/slang/library/slang_pp_expression.syn diff --git a/src/mesa/shader/slang/library/slang_version.syn b/src/mesa/shader/slang/library/slang_version.syn index aaf8bef342f..aaf8bef342f 100755..100644 --- a/src/mesa/shader/slang/library/slang_version.syn +++ b/src/mesa/shader/slang/library/slang_version.syn diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index dd7d5be6d8b..d884be2a75d 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -418,7 +418,6 @@ _slang_update_inputs_outputs(struct gl_program *prog) maxAddrReg = MAX2(maxAddrReg, inst->DstReg.Index + 1); } } - prog->NumAddressRegs = maxAddrReg; } diff --git a/src/mesa/shader/slang/sources b/src/mesa/shader/slang/sources deleted file mode 100644 index 00d617fa8af..00000000000 --- a/src/mesa/shader/slang/sources +++ /dev/null @@ -1,44 +0,0 @@ -MESA_SHADER_SLANG_SOURCES = \ -slang_analyse.c \ -slang_assemble_assignment.c \ -slang_assemble.c \ -slang_assemble_conditional.c \ -slang_assemble_constructor.c \ -slang_assemble_typeinfo.c \ -slang_compile.c \ -slang_compile_function.c \ -slang_compile_operation.c \ -slang_compile_struct.c \ -slang_compile_variable.c \ -slang_execute.c \ -slang_execute_x86.c \ -slang_export.c \ -slang_library_texsample.c \ -slang_library_noise.c \ -slang_link.c \ -slang_preprocess.c \ -slang_storage.c \ -slang_utility.c - -MESA_SHADER_SLANG_HEADERS = \ -slang_analyse.h \ -slang_assemble.h \ -slang_assemble_assignment.h \ -slang_assemble_conditional.h \ -slang_assemble_constructor.h \ -slang_assemble_typeinfo.h \ -slang_compile.h \ -slang_compile_function.h \ -slang_compile_operation.h \ -slang_compile_struct.h \ -slang_compile_variable.h \ -slang_execute.h \ -slang_export.h \ -slang_library_noise.h \ -slang_library_texsample.h \ -slang_link.h \ -slang_mesa.h \ -slang_preprocess.h \ -slang_storage.h \ -slang_utility.h \ -traverse_wrap.h diff --git a/src/mesa/shader/sources b/src/mesa/shader/sources deleted file mode 100644 index 27871872766..00000000000 --- a/src/mesa/shader/sources +++ /dev/null @@ -1,28 +0,0 @@ -# List of source files in this directory used for X.org xserver build -MESA_SHADER_SOURCES = \ -arbprogparse.c \ -arbprogram.c \ -atifragshader.c \ -nvfragparse.c \ -nvprogram.c \ -nvvertexec.c \ -nvvertparse.c \ -program.c \ -programopt.c \ -shaderobjects.c \ -shaderobjects_3dlabs.c - -MESA_SHADER_HEADERS = \ -arbprogparse.h \ -arbprogram.h \ -arbprogram_syn.h \ -atifragshader.h \ -nvfragparse.h \ -nvprogram.h \ -nvvertexec.h \ -nvvertparse.h \ -programopt.h \ -program.h \ -program_instruction.h \ -shaderobjects.h \ -shaderobjects_3dlabs.h |