diff options
author | Zou Nan hai <nanhai.zou@intel.com> | 2007-07-04 10:52:35 +0800 |
---|---|---|
committer | Zou Nan hai <nanhai.zou@intel.com> | 2007-07-04 10:52:35 +0800 |
commit | fb9ee9b323bff93973a39560b2bc007aace4bddd (patch) | |
tree | 05e1e72e8f4d321cde2c48b8518e6d9736c680dd /src/mesa/shader/arbprogparse.c | |
parent | 285b326c606e9b2f90e4fe177b15b3fa23239b86 (diff) | |
parent | 7ff4359a3be1278b26950f96ab23014a667af838 (diff) |
Merge branch 'master' of git+ssh://znh@git.freedesktop.org/git/mesa/mesa into 965-glsl
Diffstat (limited to 'src/mesa/shader/arbprogparse.c')
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 5027264f03..5d8f763741 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -71,6 +71,7 @@ struct arb_program /* ARB_fragment_program specifics */ GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; + GLbitfield ShadowSamplers; GLuint NumAluInstructions; GLuint NumTexInstructions; GLuint NumTexIndirections; @@ -181,7 +182,7 @@ LONGSTRING static char arb_grammar_text[] = - changed and merged V_* and F_* opcode values to OP_*. - added GL_ARB_fragment_program_shadow specific tokens (michal) */ -#define REVISION 0x09 +#define REVISION 0x0a /* program type */ #define FRAGMENT_PROGRAM 0x01 @@ -209,6 +210,9 @@ LONGSTRING static char arb_grammar_text[] = /* GL_ARB_draw_buffers option */ #define ARB_DRAW_BUFFERS 0x07 +/* GL_MESA_texture_array option */ +#define MESA_TEXTURE_ARRAY 0x08 + /* GL_ARB_fragment_program instruction class */ #define OP_ALU_INST 0x00 #define OP_TEX_INST 0x01 @@ -368,6 +372,11 @@ LONGSTRING static char arb_grammar_text[] = #define TEXTARGET_SHADOW1D 0x06 #define TEXTARGET_SHADOW2D 0x07 #define TEXTARGET_SHADOWRECT 0x08 +/* GL_MESA_texture_array */ +#define TEXTARGET_1D_ARRAY 0x09 +#define TEXTARGET_2D_ARRAY 0x0a +#define TEXTARGET_SHADOW1D_ARRAY 0x0b +#define TEXTARGET_SHADOW2D_ARRAY 0x0c /* face type */ #define FACE_FRONT 0x00 @@ -2653,6 +2662,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst, GLuint texcoord; GLubyte instClass, type, code; GLboolean rel; + GLuint shadow_tex = 0; _mesa_init_instructions(fp, 1); @@ -2970,27 +2980,54 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst, /* texTarget */ switch (*(*inst)++) { + case TEXTARGET_SHADOW1D: + shadow_tex = 1 << texcoord; + /* FALLTHROUGH */ case TEXTARGET_1D: fp->TexSrcTarget = TEXTURE_1D_INDEX; break; + case TEXTARGET_SHADOW2D: + shadow_tex = 1 << texcoord; + /* FALLTHROUGH */ case TEXTARGET_2D: fp->TexSrcTarget = TEXTURE_2D_INDEX; break; case TEXTARGET_3D: fp->TexSrcTarget = TEXTURE_3D_INDEX; break; + case TEXTARGET_SHADOWRECT: + shadow_tex = 1 << texcoord; + /* FALLTHROUGH */ case TEXTARGET_RECT: fp->TexSrcTarget = TEXTURE_RECT_INDEX; break; case TEXTARGET_CUBE: fp->TexSrcTarget = TEXTURE_CUBE_INDEX; break; - case TEXTARGET_SHADOW1D: - case TEXTARGET_SHADOW2D: - case TEXTARGET_SHADOWRECT: - /* TODO ARB_fragment_program_shadow code */ - break; + case TEXTARGET_SHADOW1D_ARRAY: + shadow_tex = 1 << texcoord; + /* FALLTHROUGH */ + case TEXTARGET_1D_ARRAY: + fp->TexSrcTarget = TEXTURE_1D_ARRAY_INDEX; + break; + case TEXTARGET_SHADOW2D_ARRAY: + shadow_tex = 1 << texcoord; + /* FALLTHROUGH */ + case TEXTARGET_2D_ARRAY: + fp->TexSrcTarget = TEXTURE_2D_ARRAY_INDEX; + break; + } + + /* Don't test the first time a particular sampler is seen. Each time + * after that, make sure the shadow state is the same. + */ + if ((_mesa_bitcount(Program->TexturesUsed[texcoord]) > 0) + && ((Program->ShadowSamplers & (1 << texcoord)) != shadow_tex)) { + program_error(ctx, Program->Position, + "texture image unit used for shadow sampling and non-shadow sampling"); + return 1; } + Program->TexturesUsed[texcoord] |= (1 << fp->TexSrcTarget); /* Check that both "2D" and "CUBE" (for example) aren't both used */ if (_mesa_bitcount(Program->TexturesUsed[texcoord]) > 1) { @@ -2998,6 +3035,9 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst, "multiple targets used on one texture image unit"); return 1; } + + + Program->ShadowSamplers |= shadow_tex; break; case OP_TEX_KIL: @@ -3464,6 +3504,10 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst, /* do nothing for now */ } break; + + case MESA_TEXTURE_ARRAY: + /* do nothing for now */ + break; } break; @@ -3584,10 +3628,10 @@ enable_parser_extensions(GLcontext *ctx, grammar id) if (ctx->Extensions.ARB_matrix_palette && !enable_ext(ctx, id, "matrix_palette")) return GL_FALSE; +#endif if (ctx->Extensions.ARB_fragment_program_shadow && !enable_ext(ctx, id, "fragment_program_shadow")) return GL_FALSE; -#endif if (ctx->Extensions.EXT_point_parameters && !enable_ext(ctx, id, "point_parameters")) return GL_FALSE; @@ -3603,7 +3647,9 @@ enable_parser_extensions(GLcontext *ctx, grammar id) if (ctx->Extensions.ARB_draw_buffers && !enable_ext(ctx, id, "draw_buffers")) return GL_FALSE; - + if (ctx->Extensions.MESA_texture_array + && !enable_ext(ctx, id, "texture_array")) + return GL_FALSE; #if 1 /* hack for Warcraft (see bug 8060) */ enable_ext(ctx, id, "vertex_blend"); @@ -3782,6 +3828,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, program->HintPositionInvariant = GL_FALSE; for (a = 0; a < MAX_TEXTURE_IMAGE_UNITS; a++) program->TexturesUsed[a] = 0x0; + program->ShadowSamplers = 0x0; program->NumAluInstructions = program->NumTexInstructions = program->NumTexIndirections = 0; @@ -3862,6 +3909,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, program->Base.OutputsWritten = ap.Base.OutputsWritten; for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) program->Base.TexturesUsed[i] = ap.TexturesUsed[i]; + program->Base.ShadowSamplers = ap.ShadowSamplers; program->FogOption = ap.FogOption; program->UsesKill = ap.UsesKill; |