1#!/usr/bin/python
2
3import sys
4import StringIO
5
6# Bitfield constants for the 'variant' argument to generate_sigs
7Proj = 1
8Offset = 2
9Single = 4
10
11def vec_type(g, size):
12    if size == 1:
13        if g == "i":
14            return "int"
15        elif g == "u":
16            return "uint"
17        return "float"
18    return g + "vec" + str(size)
19
20# Get the sampler dimension - i.e. sampler3D gives 3
21def get_sampler_dim(sampler_type):
22    if sampler_type[0].isdigit():
23        sampler_dim = int(sampler_type[0])
24    elif sampler_type.startswith("Cube"):
25        sampler_dim = 3
26    elif sampler_type == "ExternalOES":
27        sampler_dim = 2
28    elif sampler_type == "Buffer":
29        sampler_dim = 1
30    else:
31        assert False ("coord_dim: invalid sampler_type: " + sampler_type)
32    return sampler_dim
33
34# Get the coordinate dimension for a given sampler type.
35# Array samplers also get +1 here since the layer is really an extra coordinate
36def get_coord_dim(sampler_type):
37    coord_dim = get_sampler_dim(sampler_type)
38    if sampler_type.find("Array") != -1:
39        coord_dim += 1
40    return coord_dim
41
42# Get the number of extra vector components (i.e. shadow comparitor)
43def get_extra_dim(sampler_type, use_proj, unused_fields):
44    extra_dim = unused_fields
45    if sampler_type.find("Shadow") != -1:
46        extra_dim += 1
47    if use_proj:
48        extra_dim += 1
49    return extra_dim
50
51def get_txs_dim(sampler_type):
52    if sampler_type.startswith("Cube"):
53        return 2
54    return get_coord_dim(sampler_type)
55
56def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
57    coord_dim = get_coord_dim(sampler_type)
58    extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields)
59    sampler_dim = get_sampler_dim(sampler_type)
60
61    if variant & Single:
62        return_type = "float"
63    elif tex_inst == "txs":
64        return_type = vec_type("i", get_txs_dim(sampler_type))
65    else:
66        return_type = g + "vec4"
67
68    # Print parameters
69    print "   (signature", return_type
70    print "     (parameters"
71    print "       (declare (in) " + g + "sampler" + sampler_type + " sampler)",
72    if tex_inst != "txs":
73        print "\n       (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
74    if tex_inst == "txl":
75        print "\n       (declare (in) float lod)",
76    elif ((tex_inst == "txf" or tex_inst == "txs") and "Buffer" not in sampler_type and "Rect" not in sampler_type):
77        print "\n       (declare (in) int lod)",
78    elif tex_inst == "txd":
79        grad_type = vec_type("", sampler_dim)
80        print "\n       (declare (in) " + grad_type + " dPdx)",
81        print "\n       (declare (in) " + grad_type + " dPdy)",
82
83    if variant & Offset:
84        print "\n       (declare (const_in) " + vec_type("i", sampler_dim) + " offset)",
85    if tex_inst == "txb":
86        print "\n       (declare (in) float bias)",
87
88    print ")\n     ((return (" + tex_inst, return_type, "(var_ref sampler)",
89
90    if tex_inst != "txs":
91        # Coordinate
92        if extra_dim > 0:
93            print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))",
94        else:
95            print "(var_ref P)",
96
97        if variant & Offset:
98            print "(var_ref offset)",
99        else:
100            print "0",
101
102    if tex_inst != "txf" and tex_inst != "txs":
103        # Projective divisor
104        if variant & Proj:
105            print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))",
106        else:
107            print "1",
108
109        # Shadow comparitor
110        if sampler_type == "2DArrayShadow" or sampler_type == "CubeShadow": # a special case:
111            print "(swiz w (var_ref P))",   # ...array layer is z; shadow is w
112        elif sampler_type.endswith("Shadow"):
113            print "(swiz z (var_ref P))",
114        else:
115            print "()",
116
117    # Bias/explicit LOD/gradient:
118    if tex_inst == "txb":
119        print "(var_ref bias)",
120    elif tex_inst == "txs" or tex_inst == "txf":
121        if "Rect" not in sampler_type and "Buffer" not in sampler_type:
122            print "(var_ref lod)",
123        else:
124            print "(constant int (0))"
125    elif tex_inst == "txl":
126        print "(var_ref lod)",
127    elif tex_inst == "txd":
128        print "((var_ref dPdx) (var_ref dPdy))",
129    print "))))\n"
130
131def generate_fiu_sigs(tex_inst, sampler_type, variant = 0, unused_fields = 0):
132    generate_sigs("",  tex_inst, sampler_type, variant, unused_fields)
133    generate_sigs("i", tex_inst, sampler_type, variant, unused_fields)
134    generate_sigs("u", tex_inst, sampler_type, variant, unused_fields)
135
136def start_function(name):
137    sys.stdout = StringIO.StringIO()
138    print "((function " + name
139
140def end_function(fs, name):
141    print "))"
142    fs[name] = sys.stdout.getvalue();
143    sys.stdout.close()
144
145# Generate all the functions and store them in the supplied dictionary.
146# This is better than writing them to actual files since they should never be
147# edited; it'd also be easy to confuse them with the many hand-generated files.
148#
149# Takes a dictionary as an argument.
150def generate_texture_functions(fs):
151    start_function("textureSize")
152    generate_fiu_sigs("txs", "1D")
153    generate_fiu_sigs("txs", "2D")
154    generate_fiu_sigs("txs", "3D")
155    generate_fiu_sigs("txs", "Cube")
156    generate_fiu_sigs("txs", "1DArray")
157    generate_fiu_sigs("txs", "2DArray")
158    generate_sigs("", "txs", "1DShadow")
159    generate_sigs("", "txs", "2DShadow")
160    generate_sigs("", "txs", "CubeShadow")
161    generate_sigs("", "txs", "1DArrayShadow")
162    generate_sigs("", "txs", "2DArrayShadow")
163    generate_fiu_sigs("txs", "2DRect")
164    generate_sigs("", "txs", "2DRectShadow")
165    generate_fiu_sigs("txs", "Buffer")
166    end_function(fs, "textureSize")
167
168    start_function("texture")
169    generate_fiu_sigs("tex", "1D")
170    generate_fiu_sigs("tex", "2D")
171    generate_fiu_sigs("tex", "3D")
172    generate_fiu_sigs("tex", "Cube")
173    generate_fiu_sigs("tex", "1DArray")
174    generate_fiu_sigs("tex", "2DArray")
175    generate_sigs("", "tex", "1DShadow", Single, 1);
176    generate_sigs("", "tex", "2DShadow", Single);
177    generate_sigs("", "tex", "CubeShadow", Single);
178    generate_sigs("", "tex", "1DArrayShadow", Single);
179    generate_sigs("", "tex", "2DArrayShadow", Single);
180    generate_fiu_sigs("tex", "2DRect")
181    generate_sigs("", "tex", "2DRectShadow", Single);
182
183    generate_fiu_sigs("txb", "1D")
184    generate_fiu_sigs("txb", "2D")
185    generate_fiu_sigs("txb", "3D")
186    generate_fiu_sigs("txb", "Cube")
187    generate_fiu_sigs("txb", "1DArray")
188    generate_fiu_sigs("txb", "2DArray")
189    generate_sigs("", "txb", "1DShadow", Single, 1);
190    generate_sigs("", "txb", "2DShadow", Single);
191    generate_sigs("", "txb", "CubeShadow", Single);
192    generate_sigs("", "txb", "1DArrayShadow", Single);
193    generate_sigs("", "txb", "2DArrayShadow", Single);
194    end_function(fs, "texture")
195
196    start_function("textureProj")
197    generate_fiu_sigs("tex", "1D", Proj)
198    generate_fiu_sigs("tex", "1D", Proj, 2)
199    generate_fiu_sigs("tex", "2D", Proj)
200    generate_fiu_sigs("tex", "2D", Proj, 1)
201    generate_fiu_sigs("tex", "3D", Proj)
202    generate_sigs("", "tex", "1DShadow", Proj | Single, 1);
203    generate_sigs("", "tex", "2DShadow", Proj | Single);
204    generate_fiu_sigs("tex", "2DRect", Proj)
205    generate_fiu_sigs("tex", "2DRect", Proj, 1)
206    generate_sigs("", "tex", "2DRectShadow", Proj | Single);
207
208    generate_fiu_sigs("txb", "1D", Proj)
209    generate_fiu_sigs("txb", "1D", Proj, 2)
210    generate_fiu_sigs("txb", "2D", Proj)
211    generate_fiu_sigs("txb", "2D", Proj, 1)
212    generate_fiu_sigs("txb", "3D", Proj)
213    generate_sigs("", "txb", "1DShadow", Proj | Single, 1);
214    generate_sigs("", "txb", "2DShadow", Proj | Single);
215    end_function(fs, "textureProj")
216
217    start_function("textureLod")
218    generate_fiu_sigs("txl", "1D")
219    generate_fiu_sigs("txl", "2D")
220    generate_fiu_sigs("txl", "3D")
221    generate_fiu_sigs("txl", "Cube")
222    generate_fiu_sigs("txl", "1DArray")
223    generate_fiu_sigs("txl", "2DArray")
224    generate_sigs("", "txl", "1DShadow", Single, 1);
225    generate_sigs("", "txl", "2DShadow", Single);
226    generate_sigs("", "txl", "1DArrayShadow", Single);
227    end_function(fs, "textureLod")
228
229    start_function("textureLodOffset")
230    generate_fiu_sigs("txl", "1D", Offset)
231    generate_fiu_sigs("txl", "2D", Offset)
232    generate_fiu_sigs("txl", "3D", Offset)
233    generate_fiu_sigs("txl", "1DArray", Offset)
234    generate_fiu_sigs("txl", "2DArray", Offset)
235    generate_sigs("", "txl", "1DShadow", Offset | Single, 1);
236    generate_sigs("", "txl", "2DShadow", Offset | Single);
237    generate_sigs("", "txl", "1DArrayShadow", Offset | Single);
238    end_function(fs, "textureLodOffset")
239
240    start_function("textureOffset")
241    generate_fiu_sigs("tex", "1D", Offset)
242    generate_fiu_sigs("tex", "2D", Offset)
243    generate_fiu_sigs("tex", "3D", Offset)
244    generate_fiu_sigs("tex", "2DRect", Offset)
245    generate_sigs("", "tex", "2DRectShadow", Offset | Single);
246    generate_fiu_sigs("tex", "1DArray", Offset)
247    generate_fiu_sigs("tex", "2DArray", Offset)
248    generate_sigs("", "tex", "1DShadow", Offset | Single, 1);
249    generate_sigs("", "tex", "2DShadow", Offset | Single);
250    generate_sigs("", "tex", "1DArrayShadow", Offset | Single);
251
252    generate_fiu_sigs("txb", "1D", Offset)
253    generate_fiu_sigs("txb", "2D", Offset)
254    generate_fiu_sigs("txb", "3D", Offset)
255    generate_fiu_sigs("txb", "1DArray", Offset)
256    generate_fiu_sigs("txb", "2DArray", Offset)
257    generate_sigs("", "txb", "1DShadow", Offset | Single, 1);
258    generate_sigs("", "txb", "2DShadow", Offset | Single);
259    generate_sigs("", "txb", "1DArrayShadow", Offset | Single);
260    end_function(fs, "textureOffset")
261
262    start_function("texelFetch")
263    generate_fiu_sigs("txf", "1D")
264    generate_fiu_sigs("txf", "2D")
265    generate_fiu_sigs("txf", "3D")
266    generate_fiu_sigs("txf", "2DRect")
267    generate_fiu_sigs("txf", "1DArray")
268    generate_fiu_sigs("txf", "2DArray")
269    generate_fiu_sigs("txf", "Buffer")
270    end_function(fs, "texelFetch")
271
272    start_function("texelFetchOffset")
273    generate_fiu_sigs("txf", "1D", Offset)
274    generate_fiu_sigs("txf", "2D", Offset)
275    generate_fiu_sigs("txf", "3D", Offset)
276    generate_fiu_sigs("txf", "2DRect", Offset)
277    generate_fiu_sigs("txf", "1DArray", Offset)
278    generate_fiu_sigs("txf", "2DArray", Offset)
279    end_function(fs, "texelFetchOffset")
280
281    start_function("textureProjOffset")
282    generate_fiu_sigs("tex", "1D", Proj | Offset)
283    generate_fiu_sigs("tex", "1D", Proj | Offset, 2)
284    generate_fiu_sigs("tex", "2D", Proj | Offset)
285    generate_fiu_sigs("tex", "2D", Proj | Offset, 1)
286    generate_fiu_sigs("tex", "3D", Proj | Offset)
287    generate_fiu_sigs("tex", "2DRect", Proj | Offset)
288    generate_fiu_sigs("tex", "2DRect", Proj | Offset, 1)
289    generate_sigs("", "tex", "2DRectShadow", Proj | Offset | Single);
290    generate_sigs("", "tex", "1DShadow", Proj | Offset | Single, 1);
291    generate_sigs("", "tex", "2DShadow", Proj | Offset | Single);
292
293    generate_fiu_sigs("txb", "1D", Proj | Offset)
294    generate_fiu_sigs("txb", "1D", Proj | Offset, 2)
295    generate_fiu_sigs("txb", "2D", Proj | Offset)
296    generate_fiu_sigs("txb", "2D", Proj | Offset, 1)
297    generate_fiu_sigs("txb", "3D", Proj | Offset)
298    generate_sigs("", "txb", "1DShadow", Proj | Offset | Single, 1);
299    generate_sigs("", "txb", "2DShadow", Proj | Offset | Single);
300    end_function(fs, "textureProjOffset")
301
302    start_function("textureProjLod")
303    generate_fiu_sigs("txl", "1D", Proj)
304    generate_fiu_sigs("txl", "1D", Proj, 2)
305    generate_fiu_sigs("txl", "2D", Proj)
306    generate_fiu_sigs("txl", "2D", Proj, 1)
307    generate_fiu_sigs("txl", "3D", Proj)
308    generate_sigs("", "txl", "1DShadow", Proj | Single, 1);
309    generate_sigs("", "txl", "2DShadow", Proj | Single);
310    end_function(fs, "textureProjLod")
311
312    start_function("textureProjLodOffset")
313    generate_fiu_sigs("txl", "1D", Proj | Offset)
314    generate_fiu_sigs("txl", "1D", Proj | Offset, 2)
315    generate_fiu_sigs("txl", "2D", Proj | Offset)
316    generate_fiu_sigs("txl", "2D", Proj | Offset, 1)
317    generate_fiu_sigs("txl", "3D", Proj | Offset)
318    generate_sigs("", "txl", "1DShadow", Proj | Offset | Single, 1);
319    generate_sigs("", "txl", "2DShadow", Proj | Offset | Single);
320    end_function(fs, "textureProjLodOffset")
321
322    start_function("textureGrad")
323    generate_fiu_sigs("txd", "1D")
324    generate_fiu_sigs("txd", "2D")
325    generate_fiu_sigs("txd", "3D")
326    generate_fiu_sigs("txd", "Cube")
327    generate_fiu_sigs("txd", "1DArray")
328    generate_fiu_sigs("txd", "2DArray")
329    generate_fiu_sigs("txd", "2DRect")
330    generate_sigs("", "txd", "2DRectShadow", Single);
331    generate_sigs("", "txd", "1DShadow", Single, 1);
332    generate_sigs("", "txd", "2DShadow", Single);
333    generate_sigs("", "txd", "CubeShadow", Single);
334    generate_sigs("", "txd", "1DArrayShadow", Single);
335    generate_sigs("", "txd", "2DArrayShadow", Single);
336    end_function(fs, "textureGrad")
337
338    start_function("textureGradOffset")
339    generate_fiu_sigs("txd", "1D", Offset)
340    generate_fiu_sigs("txd", "2D", Offset)
341    generate_fiu_sigs("txd", "3D", Offset)
342    generate_fiu_sigs("txd", "2DRect", Offset)
343    generate_sigs("", "txd", "2DRectShadow", Offset | Single);
344    generate_fiu_sigs("txd", "1DArray", Offset)
345    generate_fiu_sigs("txd", "2DArray", Offset)
346    generate_sigs("", "txd", "1DShadow", Offset | Single, 1);
347    generate_sigs("", "txd", "2DShadow", Offset | Single);
348    generate_sigs("", "txd", "1DArrayShadow", Offset | Single);
349    generate_sigs("", "txd", "2DArrayShadow", Offset | Single);
350    end_function(fs, "textureGradOffset")
351
352    start_function("textureProjGrad")
353    generate_fiu_sigs("txd", "1D", Proj)
354    generate_fiu_sigs("txd", "1D", Proj, 2)
355    generate_fiu_sigs("txd", "2D", Proj)
356    generate_fiu_sigs("txd", "2D", Proj, 1)
357    generate_fiu_sigs("txd", "3D", Proj)
358    generate_fiu_sigs("txd", "2DRect", Proj)
359    generate_fiu_sigs("txd", "2DRect", Proj, 1)
360    generate_sigs("", "txd", "2DRectShadow", Proj | Single);
361    generate_sigs("", "txd", "1DShadow", Proj | Single, 1);
362    generate_sigs("", "txd", "2DShadow", Proj | Single);
363    end_function(fs, "textureProjGrad")
364
365    start_function("textureProjGradOffset")
366    generate_fiu_sigs("txd", "1D", Proj | Offset)
367    generate_fiu_sigs("txd", "1D", Proj | Offset, 2)
368    generate_fiu_sigs("txd", "2D", Proj | Offset)
369    generate_fiu_sigs("txd", "2D", Proj | Offset, 1)
370    generate_fiu_sigs("txd", "3D", Proj | Offset)
371    generate_fiu_sigs("txd", "2DRect", Proj | Offset)
372    generate_fiu_sigs("txd", "2DRect", Proj | Offset, 1)
373    generate_sigs("", "txd", "2DRectShadow", Proj | Offset | Single);
374    generate_sigs("", "txd", "1DShadow", Proj | Offset | Single, 1);
375    generate_sigs("", "txd", "2DShadow", Proj | Offset | Single);
376    end_function(fs, "textureProjGradOffset")
377
378
379    # ARB_texture_rectangle extension
380    start_function("texture2DRect")
381    generate_sigs("", "tex", "2DRect")
382    end_function(fs, "texture2DRect")
383
384    start_function("texture2DRectProj")
385    generate_sigs("", "tex", "2DRect", Proj)
386    generate_sigs("", "tex", "2DRect", Proj, 1)
387    end_function(fs, "texture2DRectProj")
388
389    start_function("shadow2DRect")
390    generate_sigs("", "tex", "2DRectShadow")
391    end_function(fs, "shadow2DRect")
392
393    start_function("shadow2DRectProj")
394    generate_sigs("", "tex", "2DRectShadow", Proj)
395    end_function(fs, "shadow2DRectProj")
396
397    # EXT_texture_array extension
398    start_function("texture1DArray")
399    generate_sigs("", "tex", "1DArray")
400    generate_sigs("", "txb", "1DArray")
401    end_function(fs, "texture1DArray")
402
403    start_function("texture1DArrayLod")
404    generate_sigs("", "txl", "1DArray")
405    end_function(fs, "texture1DArrayLod")
406
407    start_function("texture2DArray")
408    generate_sigs("", "tex", "2DArray")
409    generate_sigs("", "txb", "2DArray")
410    end_function(fs, "texture2DArray")
411
412    start_function("texture2DArrayLod")
413    generate_sigs("", "txl", "2DArray")
414    end_function(fs, "texture2DArrayLod")
415
416    start_function("shadow1DArray")
417    generate_sigs("", "tex", "1DArrayShadow")
418    generate_sigs("", "txb", "1DArrayShadow")
419    end_function(fs, "shadow1DArray")
420
421    start_function("shadow1DArrayLod")
422    generate_sigs("", "txl", "1DArrayShadow")
423    end_function(fs, "shadow1DArrayLod")
424
425    start_function("shadow2DArray")
426    generate_sigs("", "tex", "2DArrayShadow")
427    end_function(fs, "shadow2DArray")
428
429    # ARB_shader_texture_lod extension
430    start_function("texture1DGradARB")
431    generate_fiu_sigs("txd", "1D")
432    end_function(fs, "texture1DGradARB")
433
434    start_function("texture2DGradARB")
435    generate_fiu_sigs("txd", "2D")
436    end_function(fs, "texture2DGradARB")
437
438    start_function("texture3DGradARB")
439    generate_fiu_sigs("txd", "3D")
440    end_function(fs, "texture3DGradARB")
441
442    start_function("textureCubeGradARB")
443    generate_fiu_sigs("txd", "Cube")
444    end_function(fs, "textureCubeGradARB")
445
446    start_function("texture1DProjGradARB")
447    generate_fiu_sigs("txd", "1D", True)
448    generate_fiu_sigs("txd", "1D", True, 2)
449    end_function(fs, "texture1DProjGradARB")
450
451    start_function("texture2DProjGradARB")
452    generate_fiu_sigs("txd", "2D", True)
453    generate_fiu_sigs("txd", "2D", True, 1)
454    end_function(fs, "texture2DProjGradARB")
455
456    start_function("texture3DProjGradARB")
457    generate_fiu_sigs("txd", "3D", True)
458    end_function(fs, "texture3DProjGradARB")
459
460    start_function("shadow1DGradARB")
461    generate_sigs("", "txd", "1DShadow", False, 1)
462    end_function(fs, "shadow1DGradARB")
463
464    start_function("shadow1DProjGradARB")
465    generate_sigs("", "txd", "1DShadow", True, 1)
466    end_function(fs, "shadow1DProjGradARB")
467
468    start_function("shadow2DGradARB")
469    generate_sigs("", "txd", "2DShadow", False)
470    end_function(fs, "shadow2DGradARB")
471
472    start_function("shadow2DProjGradARB")
473    generate_sigs("", "txd", "2DShadow", True)
474    end_function(fs, "shadow2DProjGradARB")
475
476    start_function("texture2DRectGradARB")
477    generate_sigs("", "txd", "2DRect")
478    end_function(fs, "texture2DRectGradARB")
479
480    start_function("texture2DRectProjGradARB")
481    generate_sigs("", "txd", "2DRect", True)
482    generate_sigs("", "txd", "2DRect", True, 1)
483    end_function(fs, "texture2DRectProjGradARB")
484
485    start_function("shadow2DRectGradARB")
486    generate_sigs("", "txd", "2DRectShadow", False)
487    end_function(fs, "shadow2DRectGradARB")
488
489    start_function("shadow2DRectProjGradARB")
490    generate_sigs("", "txd", "2DRectShadow", True)
491    end_function(fs, "shadow2DRectProjGradARB")
492
493    # Deprecated (110/120 style) functions with silly names:
494    start_function("texture1D")
495    generate_sigs("", "tex", "1D")
496    generate_sigs("", "txb", "1D")
497    end_function(fs, "texture1D")
498
499    start_function("texture1DLod")
500    generate_sigs("", "txl", "1D")
501    end_function(fs, "texture1DLod")
502
503    start_function("texture1DProj")
504    generate_sigs("", "tex", "1D", Proj)
505    generate_sigs("", "tex", "1D", Proj, 2)
506    generate_sigs("", "txb", "1D", Proj)
507    generate_sigs("", "txb", "1D", Proj, 2)
508    end_function(fs, "texture1DProj")
509
510    start_function("texture1DProjLod")
511    generate_sigs("", "txl", "1D", Proj)
512    generate_sigs("", "txl", "1D", Proj, 2)
513    end_function(fs, "texture1DProjLod")
514
515    start_function("texture2D")
516    generate_sigs("", "tex", "2D")
517    generate_sigs("", "txb", "2D")
518    # OES_EGL_image_external
519    generate_sigs("", "tex", "ExternalOES")
520    end_function(fs, "texture2D")
521
522    start_function("texture2DLod")
523    generate_sigs("", "txl", "2D")
524    end_function(fs, "texture2DLod")
525
526    start_function("texture2DProj")
527    generate_sigs("", "tex", "2D", Proj)
528    generate_sigs("", "tex", "2D", Proj, 1)
529    generate_sigs("", "txb", "2D", Proj)
530    generate_sigs("", "txb", "2D", Proj, 1)
531    # OES_EGL_image_external
532    generate_sigs("", "tex", "ExternalOES", Proj)
533    generate_sigs("", "tex", "ExternalOES", Proj, 1)
534    end_function(fs, "texture2DProj")
535
536    start_function("texture2DProjLod")
537    generate_sigs("", "txl", "2D", Proj)
538    generate_sigs("", "txl", "2D", Proj, 1)
539    end_function(fs, "texture2DProjLod")
540
541    start_function("texture3D")
542    generate_sigs("", "tex", "3D")
543    generate_sigs("", "txb", "3D")
544    end_function(fs, "texture3D")
545
546    start_function("texture3DLod")
547    generate_sigs("", "txl", "3D")
548    end_function(fs, "texture3DLod")
549
550    start_function("texture3DProj")
551    generate_sigs("", "tex", "3D", Proj)
552    generate_sigs("", "txb", "3D", Proj)
553    end_function(fs, "texture3DProj")
554
555    start_function("texture3DProjLod")
556    generate_sigs("", "txl", "3D", Proj)
557    end_function(fs, "texture3DProjLod")
558
559    start_function("textureCube")
560    generate_sigs("", "tex", "Cube")
561    generate_sigs("", "txb", "Cube")
562    end_function(fs, "textureCube")
563
564    start_function("textureCubeLod")
565    generate_sigs("", "txl", "Cube")
566    end_function(fs, "textureCubeLod")
567
568    start_function("shadow1D")
569    generate_sigs("", "tex", "1DShadow", False, 1)
570    generate_sigs("", "txb", "1DShadow", False, 1)
571    end_function(fs, "shadow1D")
572
573    start_function("shadow1DLod")
574    generate_sigs("", "txl", "1DShadow", False, 1)
575    end_function(fs, "shadow1DLod")
576
577    start_function("shadow1DProj")
578    generate_sigs("", "tex", "1DShadow", Proj, 1)
579    generate_sigs("", "txb", "1DShadow", Proj, 1)
580    end_function(fs, "shadow1DProj")
581
582    start_function("shadow1DProjLod")
583    generate_sigs("", "txl", "1DShadow", Proj, 1)
584    end_function(fs, "shadow1DProjLod")
585
586    start_function("shadow2D")
587    generate_sigs("", "tex", "2DShadow")
588    generate_sigs("", "txb", "2DShadow")
589    end_function(fs, "shadow2D")
590
591    start_function("shadow2DLod")
592    generate_sigs("", "txl", "2DShadow")
593    end_function(fs, "shadow2DLod")
594
595    start_function("shadow2DProj")
596    generate_sigs("", "tex", "2DShadow", Proj)
597    generate_sigs("", "txb", "2DShadow", Proj)
598    end_function(fs, "shadow2DProj")
599
600    start_function("shadow2DProjLod")
601    generate_sigs("", "txl", "2DShadow", Proj)
602    end_function(fs, "shadow2DProjLod")
603
604    sys.stdout = sys.__stdout__
605    return fs
606
607# If you actually run this script, it'll print out all the functions.
608if __name__ == "__main__":
609    fs = {}
610    generate_texture_functions(fs);
611    for k, v in fs.iteritems():
612        print v
613