initial import
[ICEs.git] / 225977 / texenvprogram.i.2
1 struct gl_fragment_program_state {
2 unsigned char _Enabled;
3 struct gl_fragment_program *_TexEnvProgram;
4 };
5 struct gl_shader_state {
6 struct gl_shader_program *CurrentProgram;
7 };
8 struct gl_constants {
9 unsigned int MaxTextureUnits;
10 } GLvertexformat;
11 typedef struct {
12 struct gl_constants Const;
13 struct gl_fragment_program_state FragmentProgram;
14 struct gl_shader_state Shader;
15 } GLcontext;
16 struct mode_opt {
17 unsigned int Source:4;
18 unsigned int Operand:3;
19 };
20 struct state_key {
21 unsigned int enabled_units;
22 struct {
23 unsigned int NumArgsRGB:2;
24 unsigned int ModeRGB:4;
25 struct mode_opt OptRGB[3];
26 unsigned int ModeA:4;
27 } unit[8];
28 };
29 struct ureg {
30 unsigned int file:4;
31 unsigned int idx:8;
32 };
33 static const struct ureg undef = {
34 0, ~0, 0, 0, 0, 0, 0
35 };
36 struct texenv_fragment_program {
37 struct state_key *state;
38 struct ureg src_texture[8];
39 struct ureg src_previous;
40 unsigned int last_tex_stage;
41 };
42 static struct ureg get_temp(struct texenv_fragment_program *p)
43 {
44 }
45 static struct ureg register_const4f(struct texenv_fragment_program *p,
46 float s0, float s1, float s2,
47 float s3)
48 {
49 }
50 static struct ureg emit_combine_source(struct texenv_fragment_program *p,
51 unsigned int mask, unsigned int unit, unsigned int source,
52 unsigned int operand)
53 {
54 }
55 static struct ureg emit_combine(struct texenv_fragment_program *p,
56 struct ureg dest, unsigned int mask,
57 unsigned char saturate, unsigned int unit, unsigned int nr,
58 unsigned int mode, const struct mode_opt *opt)
59 {
60 struct ureg src[3];
61 unsigned int i;
62 for (i = 0; i < nr; i++)
63 src[i] =
64 emit_combine_source(p, mask, unit, opt[i].Source,
65 opt[i].Operand);
66 switch (mode) {
67 case 6:{
68 struct ureg tmp0;
69 struct ureg neg1;
70 struct ureg two;
71 neg1 = register_const4f(p, -1, -1, -1, -1);
72 two = register_const4f(p, 2, 2, 2, 2);
73 emit_arith(p, 0, tmp0, 0xf, 0, two, src[0],
74 neg1);
75 }
76 }
77 }
78 static struct ureg emit_texenv(struct texenv_fragment_program *p, unsigned int unit)
79 {
80 struct state_key *key;
81 unsigned char saturate;
82 struct ureg out;
83 struct ureg shift;
84 struct ureg dest;
85 key = p->state;
86 saturate = (unit < p->last_tex_stage);
87 if (key->unit[unit].ModeRGB == key->unit[unit].ModeA
88 && args_match(key, unit))
89 out =
90 emit_combine(p, dest, 0xf, saturate, unit,
91 key->unit[unit].NumArgsRGB,
92 key->unit[unit].ModeRGB,
93 key->unit[unit].OptRGB);
94 }
95 static void create_new_program(GLcontext * ctx, struct state_key *key,
96 struct gl_fragment_program *program)
97 {
98 struct texenv_fragment_program p;
99 unsigned int unit;
100 for (unit = 0; unit < 8; unit++)
101 p.src_texture[unit] = undef;
102 if (key->enabled_units)
103 for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++)
104 if (key->enabled_units & (1 << unit))
105 p.src_previous = emit_texenv(&p, unit);
106 }
107 void _mesa_UpdateTexEnvProgram(GLcontext * ctx)
108 {
109 struct state_key key;
110 if (!ctx->FragmentProgram._Enabled && !ctx->Shader.CurrentProgram)
111 if (!ctx->FragmentProgram._TexEnvProgram)
112 create_new_program(ctx, &key,
113 ctx->FragmentProgram._TexEnvProgram);
114 }