OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [compile/] [pr34091.c] - Blame information for rev 688

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
typedef unsigned int GLenum;
2
typedef unsigned char GLboolean;
3
typedef int GLint;
4
typedef unsigned short GLushort;
5
typedef unsigned int GLuint;
6
typedef float GLfloat;
7
typedef GLushort GLchan;
8
struct gl_texture_image;
9
typedef struct __GLcontextRec GLcontext;
10
typedef void (*FetchTexelFuncC) (const struct gl_texture_image * texImage,
11
                                 GLint col, GLint row, GLint img,
12
                                 GLchan * texelOut);
13
struct gl_texture_format
14
{
15
};
16
struct gl_texture_image
17
{
18
  GLenum _BaseFormat;
19
  GLboolean _IsPowerOfTwo;
20
  FetchTexelFuncC FetchTexelc;
21
};
22
struct gl_texture_object
23
{
24
  GLenum Target;
25
  GLenum WrapS;
26
  GLenum MinFilter;
27
  GLenum MagFilter;
28
  GLint BaseLevel;
29
  GLint _MaxLevel;
30
  struct gl_texture_image *Image[6][12];
31
};
32
enum _format
33
{
34
    MESA_FORMAT_RGBA_DXT3, MESA_FORMAT_RGBA_DXT5, MESA_FORMAT_RGBA,
35
    MESA_FORMAT_RGB, MESA_FORMAT_ALPHA, MESA_FORMAT_LUMINANCE,
36
};
37
typedef void (*texture_sample_func) (GLcontext * ctx,
38
                                     const struct gl_texture_object * tObj,
39
                                     GLuint n, const GLfloat texcoords[][4],
40
                                     const GLfloat lambda[],
41
                                     GLchan rgba[][4]);
42
lerp_2d (GLfloat a, GLfloat b, GLfloat v00, GLfloat v10, GLfloat v01,
43
         GLfloat v11)
44
{
45
  const GLfloat temp0 = ((v00) + (a) * ((v10) - (v00)));
46
  const GLfloat temp1 = ((v01) + (a) * ((v11) - (v01)));
47
  return ((temp0) + (b) * ((temp1) - (temp0)));
48
}
49
static __inline__ void
50
lerp_rgba (GLchan result[4], GLfloat t, const GLchan a[4], const GLchan b[4])
51
{
52
  result[0] = (GLchan) (((a[0]) + (t) * ((b[0]) - (a[0]))) + 0.5);
53
  result[1] = (GLchan) (((a[1]) + (t) * ((b[1]) - (a[1]))) + 0.5);
54
  result[2] = (GLchan) (((a[2]) + (t) * ((b[2]) - (a[2]))) + 0.5);
55
}
56
static __inline__ void
57
lerp_rgba_2d (GLchan result[4], GLfloat a, GLfloat b, const GLchan t00[4],
58
              const GLchan t10[4], const GLchan t01[4], const GLchan t11[4])
59
{
60
  result[0] = (GLchan) (lerp_2d (a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5);
61
  result[1] = (GLchan) (lerp_2d (a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5);
62
  result[2] = (GLchan) (lerp_2d (a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5);
63
}
64
static __inline__ void
65
sample_2d_linear_repeat (GLcontext * ctx,
66
                         const struct gl_texture_object *tObj,
67
                         const struct gl_texture_image *img,
68
                         const GLfloat texcoord[4], GLchan rgba[])
69
{
70
  GLint i0, j0, i1, j1;
71
  GLfloat a, b;
72
  GLchan t00[4], t10[4], t01[4], t11[4];
73
  {
74
  };
75
  img->FetchTexelc (img, i1, j1, 0, t11);
76
  lerp_rgba_2d (rgba, a, b, t00, t10, t01, t11);
77
}
78
sample_2d_nearest_mipmap_linear (GLcontext * ctx,
79
                                 const struct gl_texture_object *tObj,
80
                                 GLuint n, const GLfloat texcoord[][4],
81
                                 const GLfloat lambda[], GLchan rgba[][4])
82
{
83
  GLuint i;
84
  GLint level = linear_mipmap_level (tObj, lambda[i]);
85
  sample_2d_nearest (ctx, tObj, tObj->Image[0][tObj->_MaxLevel], texcoord[i], rgba[i]);
86
  GLchan t0[4], t1[4];
87
  sample_2d_nearest (ctx, tObj, tObj->Image[0][level], texcoord[i], t0);
88
  sample_2d_nearest (ctx, tObj, tObj->Image[0][level + 1], texcoord[i], t1);
89
}
90
static void
91
sample_2d_linear_mipmap_linear_repeat (GLcontext * ctx,
92
                                       const struct gl_texture_object *tObj,
93
                                       GLuint n, const GLfloat texcoord[][4],
94
                                       const GLfloat lambda[],
95
                                       GLchan rgba[][4])
96
{
97
  GLuint i;
98
  for (i = 0; i < n; i++)
99
    {
100
      GLint level = linear_mipmap_level (tObj, lambda[i]);
101
      if (level >= tObj->_MaxLevel)
102
        {
103
          GLchan t0[4], t1[4];
104
          const GLfloat f = ((lambda[i]) - ifloor (lambda[i]));
105
          sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level],
106
                                   texcoord[i], t0);
107
          sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level + 1],
108
                                   texcoord[i], t1);
109
          lerp_rgba (rgba[i], f, t0, t1);
110
        }
111
    }
112
}
113
static void
114
sample_lambda_2d (GLcontext * ctx, const struct gl_texture_object *tObj,
115
                  GLuint n, const GLfloat texcoords[][4],
116
                  const GLfloat lambda[], GLchan rgba[][4])
117
{
118
  const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
119
  GLuint minStart, minEnd;
120
  GLuint magStart, magEnd;
121
  const GLboolean repeatNoBorderPOT = (tObj->WrapS == 0x2901)
122
    && (tImg->_BaseFormat != 0x1900) && tImg->_IsPowerOfTwo;
123
  compute_min_mag_ranges (tObj, n, lambda, &minStart, &minEnd, &magStart,
124
                          &magEnd);
125
  if (minStart < minEnd)
126
    {
127
      const GLuint m = minEnd - minStart;
128
      switch (tObj->MinFilter)
129
        {
130
        case 0x2600:
131
          if (repeatNoBorderPOT)
132
            {
133
                case MESA_FORMAT_RGB:
134
                  opt_sample_rgb_2d (ctx, tObj, m, texcoords + minStart,
135
                                     ((void *) 0), rgba + minStart);
136
                case MESA_FORMAT_RGBA:
137
                  opt_sample_rgba_2d (ctx, tObj, m, texcoords + minStart,
138
                                      ((void *) 0), rgba + minStart);
139
            }
140
            {
141
              sample_nearest_2d (ctx, tObj, m, texcoords + minStart,
142
                                 ((void *) 0), rgba + minStart);
143
            }
144
          break;
145
          sample_2d_nearest_mipmap_linear (ctx, tObj, m, texcoords + minStart,
146
                                           lambda + minStart,
147
                                           rgba + minStart);
148
        case 0x2703:
149
          if (repeatNoBorderPOT)
150
            sample_2d_linear_mipmap_linear_repeat (ctx, tObj, m,
151
                                                   texcoords + minStart,
152
                                                   lambda + minStart,
153
                                                   rgba + minStart);
154
        }
155
      switch (tObj->MagFilter)
156
        {
157
                case MESA_FORMAT_RGB:
158
                  opt_sample_rgb_2d (ctx, tObj, m, texcoords + magStart,
159
                                     ((void *) 0), rgba + magStart);
160
                  opt_sample_rgba_2d (ctx, tObj, m, texcoords + magStart,
161
                                      ((void *) 0), rgba + magStart);
162
                  sample_nearest_2d (ctx, tObj, m, texcoords + magStart,
163
                                     ((void *) 0), rgba + magStart);
164
        }
165
    }
166
}
167
texture_sample_func
168
_swrast_choose_texture_sample_func (const struct gl_texture_object *t)
169
{
170
      switch (t->Target)
171
        {
172
        case 0x0DE0:
173
              return &sample_lambda_2d;
174
        }
175
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.