r300g: Fix EXT_packed_depth_stencil functionality.
[mesa.git] / src / gallium / drivers / r300 / r300_texture.h
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef R300_TEXTURE_H
24 #define R300_TEXTURE_H
25
26 #include "pipe/p_screen.h"
27
28 #include "util/u_math.h"
29
30 #include "r300_context.h"
31 #include "r300_reg.h"
32
33 void r300_init_screen_texture_functions(struct pipe_screen* screen);
34
35 /* Note the signature of R300_EASY_TX_FORMAT(A, R, G, B, FORMAT)... */
36 static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
37 {
38 switch (format) {
39 /* X8 */
40 case PIPE_FORMAT_I8_UNORM:
41 return R300_EASY_TX_FORMAT(X, X, X, X, X8);
42 /* W8Z8Y8X8 */
43 case PIPE_FORMAT_A8R8G8B8_UNORM:
44 return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
45 case PIPE_FORMAT_R8G8B8A8_UNORM:
46 return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8);
47 /* DXT1 */
48 case PIPE_FORMAT_DXT1_RGB:
49 return R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1);
50 case PIPE_FORMAT_DXT1_RGBA:
51 return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1);
52 /* DXT3 */
53 case PIPE_FORMAT_DXT3_RGBA:
54 return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3);
55 /* DXT5 */
56 case PIPE_FORMAT_DXT5_RGBA:
57 return R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5);
58 /* W24_FP */
59 case PIPE_FORMAT_Z24S8_UNORM:
60 return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
61 default:
62 debug_printf("r300: Implementation error: "
63 "Got unsupported texture format %s in %s\n",
64 pf_name(format), __FUNCTION__);
65 assert(0);
66 break;
67 }
68 return 0;
69 }
70
71 #ifndef R300_WINSYS_H
72
73 boolean r300_get_texture_buffer(struct pipe_texture* texture,
74 struct pipe_buffer** buffer,
75 unsigned* stride);
76
77 #endif /* R300_WINSYS_H */
78
79 #endif /* R300_TEXTURE_H */