summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/tgsi/core/tgsi_exec.h
blob: fb11eec777686f23f1237eb0d38e4800598f45ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#if !defined TGSI_EXEC_H
#define TGSI_EXEC_H

#if 0
#include "x86/rtasm/x86sse.h"
#endif

#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus

union tgsi_exec_channel
{
   GLfloat  f[4];
   GLint    i[4];
   GLuint   u[4];
};

struct tgsi_exec_vector
{
   union tgsi_exec_channel xyzw[4];
};

#define SAMPLER_CACHE_SIZE 8

struct tgsi_sampler
{
   const struct pipe_sampler_state *state;
   struct pipe_mipmap_tree *texture;
   void (*get_sample)(struct tgsi_sampler *sampler,
                      const GLfloat strq[4], GLfloat lambda, GLfloat rgba[4]);
   void *pipe; /*XXX temporary*/

   GLint cache_x, cache_y;
   GLfloat cache[SAMPLER_CACHE_SIZE][SAMPLER_CACHE_SIZE][4];
};

struct tgsi_exec_labels
{
   GLuint   labels[128][2];
   GLuint   count;
};

#define TGSI_EXEC_TEMP_00000000_I   32
#define TGSI_EXEC_TEMP_00000000_C   0

#define TGSI_EXEC_TEMP_7FFFFFFF_I   32
#define TGSI_EXEC_TEMP_7FFFFFFF_C   1

#define TGSI_EXEC_TEMP_80000000_I   32
#define TGSI_EXEC_TEMP_80000000_C   2

#define TGSI_EXEC_TEMP_FFFFFFFF_I   32
#define TGSI_EXEC_TEMP_FFFFFFFF_C   3

#define TGSI_EXEC_TEMP_ONE_I        33
#define TGSI_EXEC_TEMP_ONE_C        0

#define TGSI_EXEC_TEMP_TWO_I        33
#define TGSI_EXEC_TEMP_TWO_C        1

#define TGSI_EXEC_TEMP_128_I        33
#define TGSI_EXEC_TEMP_128_C        2

#define TGSI_EXEC_TEMP_MINUS_128_I  33
#define TGSI_EXEC_TEMP_MINUS_128_C  3

#define TGSI_EXEC_TEMP_KILMASK_I    34
#define TGSI_EXEC_TEMP_KILMASK_C    0

#define TGSI_EXEC_TEMP_OUTPUT_I     34
#define TGSI_EXEC_TEMP_OUTPUT_C     1

#define TGSI_EXEC_TEMP_PRIMITIVE_I  34
#define TGSI_EXEC_TEMP_PRIMITIVE_C  2

#define TGSI_EXEC_TEMP_R0           35

#define TGSI_EXEC_NUM_TEMPS   (32 + 4)
#define TGSI_EXEC_NUM_ADDRS   1

/* XXX: This is temporary */
struct tgsi_exec_cond_regs
{
   struct tgsi_exec_vector    TempsAddrs[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_ADDRS];
   struct tgsi_exec_vector    Outputs[2];    /* XXX: That's just enough for fragment shader only! */
};

/* XXX: This is temporary */
struct tgsi_exec_cond_state
{
   struct tgsi_exec_cond_regs IfPortion;
   struct tgsi_exec_cond_regs ElsePortion;
   GLuint                     Condition;
   GLboolean                  WasElse;
};

/* XXX: This is temporary */
struct tgsi_exec_cond_stack
{
   struct tgsi_exec_cond_state   States[8];
   GLuint                        Index;      /* into States[] */
};

struct tgsi_exec_machine
{
   /*
    * 32 program temporaries
    * 4  internal temporaries
    * 1  address
    * 1  temporary of padding to align to 16 bytes
    */
   struct tgsi_exec_vector       _Temps[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_ADDRS + 1];

   /*
    * This will point to _Temps after aligning to 16B boundary.
    */
   struct tgsi_exec_vector       *Temps;
   struct tgsi_exec_vector       *Addrs;

   struct tgsi_sampler           *Samplers;

   GLfloat                       Imms[256][4];
   GLuint                        ImmLimit;
   GLfloat                       (*Consts)[4];
   const struct tgsi_exec_vector *Inputs;
   struct tgsi_exec_vector       *Outputs;
   struct tgsi_token             *Tokens;
   GLuint                        Processor;

   GLuint                        *Primitives;

   struct tgsi_exec_cond_stack   CondStack;
#if XXX_SSE
   struct x86_function           Function;
#endif
};

void
tgsi_exec_machine_init(
   struct tgsi_exec_machine *mach,
   struct tgsi_token *tokens,
   GLuint numSamplers,
   struct tgsi_sampler *samplers);

void
tgsi_exec_prepare(
   struct tgsi_exec_machine *mach,
   struct tgsi_exec_labels *labels );

void
tgsi_exec_machine_run(
   struct tgsi_exec_machine *mach );

void
tgsi_exec_machine_run2(
   struct tgsi_exec_machine *mach,
   struct tgsi_exec_labels *labels );

#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus

#endif // !defined TGSI_EXEC_H