diff options
author | Ian Romanick <[email protected]> | 2009-07-20 17:44:36 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2009-07-20 17:44:36 -0700 |
commit | 770cebbc29863ae944a31463ee4bdeb789105aba (patch) | |
tree | 9792859ab2c18f730cb0646812d75063f2c02076 /src/mesa/shader/arbprogparse.c | |
parent | 480567d5c451511a72744b0c849960c2b712e093 (diff) |
ARB_fp/vp: Initial import of new ARB vp/fp assembler
This still needs quite a bit of work, but a bunch of the programs in progs/vp
produce correct results.
Diffstat (limited to 'src/mesa/shader/arbprogparse.c')
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 121 |
1 files changed, 72 insertions, 49 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index bc65aba39a1..36470b669c5 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -63,6 +63,7 @@ having three separate program parameter arrays. #include "prog_parameter.h" #include "prog_statevars.h" #include "prog_instruction.h" +#include "program_parser.h" /** * This is basically a union of the vertex_program and fragment_program @@ -96,7 +97,7 @@ struct arb_program }; - +#if 0 /* TODO: * Fragment Program Stuff: * ----------------------------------------------------- @@ -3923,7 +3924,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, return !err; } - +#endif void @@ -3931,11 +3932,18 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, const GLvoid *str, GLsizei len, struct gl_fragment_program *program) { - struct arb_program ap; + struct gl_program prog; + struct asm_parser_state state; GLuint i; ASSERT(target == GL_FRAGMENT_PROGRAM_ARB); - if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, &ap)) { + + memset(&prog, 0, sizeof(prog)); + memset(&state, 0, sizeof(state)); + state.prog = &prog; + + if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, + &state)) { /* Error in the program. Just return. */ return; } @@ -3943,33 +3951,39 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, /* Copy the relevant contents of the arb_program struct into the * fragment_program struct. */ - program->Base.String = ap.Base.String; - program->Base.NumInstructions = ap.Base.NumInstructions; - program->Base.NumTemporaries = ap.Base.NumTemporaries; - program->Base.NumParameters = ap.Base.NumParameters; - program->Base.NumAttributes = ap.Base.NumAttributes; - program->Base.NumAddressRegs = ap.Base.NumAddressRegs; - program->Base.NumNativeInstructions = ap.Base.NumNativeInstructions; - program->Base.NumNativeTemporaries = ap.Base.NumNativeTemporaries; - program->Base.NumNativeParameters = ap.Base.NumNativeParameters; - program->Base.NumNativeAttributes = ap.Base.NumNativeAttributes; - program->Base.NumNativeAddressRegs = ap.Base.NumNativeAddressRegs; - program->Base.NumAluInstructions = ap.Base.NumAluInstructions; - program->Base.NumTexInstructions = ap.Base.NumTexInstructions; - program->Base.NumTexIndirections = ap.Base.NumTexIndirections; - program->Base.NumNativeAluInstructions = ap.Base.NumAluInstructions; - program->Base.NumNativeTexInstructions = ap.Base.NumTexInstructions; - program->Base.NumNativeTexIndirections = ap.Base.NumTexIndirections; - program->Base.InputsRead = ap.Base.InputsRead; - program->Base.OutputsWritten = ap.Base.OutputsWritten; + program->Base.String = prog.String; + program->Base.NumInstructions = prog.NumInstructions; + program->Base.NumTemporaries = prog.NumTemporaries; + program->Base.NumParameters = prog.NumParameters; + program->Base.NumAttributes = prog.NumAttributes; + program->Base.NumAddressRegs = prog.NumAddressRegs; + program->Base.NumNativeInstructions = prog.NumNativeInstructions; + program->Base.NumNativeTemporaries = prog.NumNativeTemporaries; + program->Base.NumNativeParameters = prog.NumNativeParameters; + program->Base.NumNativeAttributes = prog.NumNativeAttributes; + program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs; + program->Base.NumAluInstructions = prog.NumAluInstructions; + program->Base.NumTexInstructions = prog.NumTexInstructions; + program->Base.NumTexIndirections = prog.NumTexIndirections; + program->Base.NumNativeAluInstructions = prog.NumAluInstructions; + program->Base.NumNativeTexInstructions = prog.NumTexInstructions; + program->Base.NumNativeTexIndirections = prog.NumTexIndirections; + program->Base.InputsRead = prog.InputsRead; + program->Base.OutputsWritten = prog.OutputsWritten; for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) { - program->Base.TexturesUsed[i] = ap.TexturesUsed[i]; - if (ap.TexturesUsed[i]) + program->Base.TexturesUsed[i] = state.fragment.TexturesUsed[i]; + if (state.fragment.TexturesUsed[i]) program->Base.SamplersUsed |= (1 << i); } - program->Base.ShadowSamplers = ap.ShadowSamplers; - program->FogOption = ap.FogOption; - program->UsesKill = ap.UsesKill; + program->Base.ShadowSamplers = state.fragment.ShadowSamplers; + switch (state.option.Fog) { + case OPTION_FOG_EXP: program->FogOption = GL_EXP; break; + case OPTION_FOG_EXP2: program->FogOption = GL_EXP2; break; + case OPTION_FOG_LINEAR: program->FogOption = GL_LINEAR; break; + default: program->FogOption = GL_NONE; break; + } + + program->UsesKill = state.fragment.UsesKill; if (program->FogOption) program->Base.InputsRead |= FRAG_BIT_FOGC; @@ -3983,11 +3997,11 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, if (program->Base.Instructions) _mesa_free(program->Base.Instructions); - program->Base.Instructions = ap.Base.Instructions; + program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) _mesa_free_parameter_list(program->Base.Parameters); - program->Base.Parameters = ap.Base.Parameters; + program->Base.Parameters = prog.Parameters; /* Append fog instructions now if the program has "OPTION ARB_fog_exp" * or similar. We used to leave this up to drivers, but it appears @@ -4017,11 +4031,17 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, const GLvoid *str, GLsizei len, struct gl_vertex_program *program) { - struct arb_program ap; + struct gl_program prog; + struct asm_parser_state state; ASSERT(target == GL_VERTEX_PROGRAM_ARB); - if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, &ap)) { + memset(&prog, 0, sizeof(prog)); + memset(&state, 0, sizeof(state)); + state.prog = &prog; + + if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, + &state)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)"); return; } @@ -4029,31 +4049,34 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, /* Copy the relevant contents of the arb_program struct into the * vertex_program struct. */ - program->Base.String = ap.Base.String; - program->Base.NumInstructions = ap.Base.NumInstructions; - program->Base.NumTemporaries = ap.Base.NumTemporaries; - program->Base.NumParameters = ap.Base.NumParameters; - program->Base.NumAttributes = ap.Base.NumAttributes; - program->Base.NumAddressRegs = ap.Base.NumAddressRegs; - program->Base.NumNativeInstructions = ap.Base.NumNativeInstructions; - program->Base.NumNativeTemporaries = ap.Base.NumNativeTemporaries; - program->Base.NumNativeParameters = ap.Base.NumNativeParameters; - program->Base.NumNativeAttributes = ap.Base.NumNativeAttributes; - program->Base.NumNativeAddressRegs = ap.Base.NumNativeAddressRegs; - program->Base.InputsRead = ap.Base.InputsRead; - program->Base.OutputsWritten = ap.Base.OutputsWritten; - program->IsPositionInvariant = ap.HintPositionInvariant; + program->Base.String = prog.String; + program->Base.NumInstructions = prog.NumInstructions; + program->Base.NumTemporaries = prog.NumTemporaries; + program->Base.NumParameters = prog.NumParameters; + program->Base.NumAttributes = prog.NumAttributes; + program->Base.NumAddressRegs = prog.NumAddressRegs; + program->Base.NumNativeInstructions = prog.NumNativeInstructions; + program->Base.NumNativeTemporaries = prog.NumNativeTemporaries; + program->Base.NumNativeParameters = prog.NumNativeParameters; + program->Base.NumNativeAttributes = prog.NumNativeAttributes; + program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs; + program->Base.InputsRead = prog.InputsRead; + program->Base.OutputsWritten = prog.OutputsWritten; + program->IsPositionInvariant = (state.option.PositionInvariant) + ? GL_TRUE : GL_FALSE; if (program->Base.Instructions) _mesa_free(program->Base.Instructions); - program->Base.Instructions = ap.Base.Instructions; + program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) _mesa_free_parameter_list(program->Base.Parameters); - program->Base.Parameters = ap.Base.Parameters; + program->Base.Parameters = prog.Parameters; -#if DEBUG_VP +#if 1 || DEBUG_VP _mesa_printf("____________Vertex program %u __________\n", program->Base.Id); _mesa_print_program(&program->Base); + _mesa_printf("inputs = 0x%04x, outputs = 0x%04x\n", program->Base.InputsRead, + program->Base.OutputsWritten); #endif } |