Minor r200 vertex program cleanups. Remove disabled leftovers from r300 vertex progra...
[mesa.git] / src / mesa / drivers / dri / i965 / brw_tex.c
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **********************************************************************/
27 /*
28 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32
33 #include "glheader.h"
34 #include "mtypes.h"
35 #include "imports.h"
36 #include "simple_list.h"
37 #include "enums.h"
38 #include "image.h"
39 #include "texstore.h"
40 #include "texformat.h"
41 #include "texmem.h"
42
43 #include "intel_ioctl.h"
44 #include "brw_context.h"
45 #include "brw_defines.h"
46
47
48
49
50 static const struct gl_texture_format *
51 brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
52 GLenum format, GLenum type )
53 {
54 switch ( internalFormat ) {
55 case 4:
56 case GL_RGBA:
57 case GL_COMPRESSED_RGBA:
58 case GL_RGBA8:
59 case GL_RGB10_A2:
60 case GL_RGBA12:
61 case GL_RGBA16:
62 case GL_RGBA4:
63 case GL_RGBA2:
64 case GL_RGB5_A1:
65 return &_mesa_texformat_argb8888;
66 /* return &_mesa_texformat_rgba8888_rev; */
67
68 case 3:
69 case GL_RGB:
70 case GL_COMPRESSED_RGB:
71 case GL_RGB8:
72 case GL_RGB10:
73 case GL_RGB12:
74 case GL_RGB16:
75 case GL_RGB5:
76 case GL_RGB4:
77 case GL_R3_G3_B2:
78 /* return &_mesa_texformat_rgb888; */
79 return &_mesa_texformat_argb8888;
80
81 case GL_ALPHA:
82 case GL_ALPHA4:
83 case GL_ALPHA8:
84 case GL_ALPHA12:
85 case GL_ALPHA16:
86 case GL_COMPRESSED_ALPHA:
87 return &_mesa_texformat_a8;
88
89 case 1:
90 case GL_LUMINANCE:
91 case GL_LUMINANCE4:
92 case GL_LUMINANCE8:
93 case GL_LUMINANCE12:
94 case GL_LUMINANCE16:
95 case GL_COMPRESSED_LUMINANCE:
96 return &_mesa_texformat_l8;
97
98 case 2:
99 case GL_LUMINANCE_ALPHA:
100 case GL_LUMINANCE4_ALPHA4:
101 case GL_LUMINANCE6_ALPHA2:
102 case GL_LUMINANCE8_ALPHA8:
103 case GL_LUMINANCE12_ALPHA4:
104 case GL_LUMINANCE12_ALPHA12:
105 case GL_LUMINANCE16_ALPHA16:
106 case GL_COMPRESSED_LUMINANCE_ALPHA:
107 return &_mesa_texformat_al88;
108
109 case GL_INTENSITY:
110 case GL_INTENSITY4:
111 case GL_INTENSITY8:
112 case GL_INTENSITY12:
113 case GL_INTENSITY16:
114 case GL_COMPRESSED_INTENSITY:
115 return &_mesa_texformat_i8;
116
117 case GL_YCBCR_MESA:
118 if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
119 type == GL_UNSIGNED_BYTE)
120 return &_mesa_texformat_ycbcr;
121 else
122 return &_mesa_texformat_ycbcr_rev;
123
124 case GL_COMPRESSED_RGB_FXT1_3DFX:
125 case GL_COMPRESSED_RGBA_FXT1_3DFX:
126 return &_mesa_texformat_rgb_fxt1;
127
128 case GL_RGB_S3TC:
129 case GL_RGB4_S3TC:
130 case GL_RGBA_S3TC:
131 case GL_RGBA4_S3TC:
132 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
133 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
134 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
135 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
136 return &_mesa_texformat_rgb_dxt1; /* there is no rgba support? */
137
138 case GL_DEPTH_COMPONENT:
139 case GL_DEPTH_COMPONENT16:
140 case GL_DEPTH_COMPONENT24:
141 case GL_DEPTH_COMPONENT32:
142 return &_mesa_texformat_z16;
143
144 default:
145 fprintf(stderr, "unexpected texture format %s in %s\n",
146 _mesa_lookup_enum_by_nr(internalFormat),
147 __FUNCTION__);
148 return NULL;
149 }
150
151 return NULL; /* never get here */
152 }
153
154
155 void brwInitTextureFuncs( struct dd_function_table *functions )
156 {
157 functions->ChooseTextureFormat = brwChooseTextureFormat;
158 }