Debian Codegraph @

gcc/testsuite/gcc.c-torture/compile/pr34091.c

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