#ifndef R300_TEXTURE_H
#define R300_TEXTURE_H
-#include "pipe/p_video_state.h"
-
-#include "r300_reg.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+struct pipe_screen;
+struct pipe_context;
+struct pipe_resource;
+struct winsys_handle;
+struct r300_texture_format_state;
+struct r300_texture_desc;
struct r300_texture;
+struct r300_screen;
-void r300_init_screen_texture_functions(struct pipe_screen* screen);
+unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
+ const unsigned char *swizzle_view,
+ boolean dxtc_swizzle);
-unsigned r300_texture_get_stride(struct r300_screen* screen,
- struct r300_texture* tex, unsigned level);
+uint32_t r300_translate_texformat(enum pipe_format format,
+ const unsigned char *swizzle_view,
+ boolean is_r500,
+ boolean dxtc_swizzle);
-unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
- unsigned zslice, unsigned face);
+uint32_t r500_tx_format_msb_bit(enum pipe_format format);
-/* Translate a pipe_format into a useful texture format for sampling.
- *
- * R300_EASY_TX_FORMAT swizzles the texture.
- * Note the signature of R300_EASY_TX_FORMAT:
- * R300_EASY_TX_FORMAT(B, G, R, A, FORMAT);
- *
- * The FORMAT specifies how the texture sampler will treat the texture, and
- * makes available X, Y, Z, W, ZERO, and ONE for swizzling. */
-static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
-{
- switch (format) {
- /* X8 */
- case PIPE_FORMAT_A8_UNORM:
- return R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8);
- case PIPE_FORMAT_I8_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, X, X8);
- case PIPE_FORMAT_L8_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, ONE, X8);
- case PIPE_FORMAT_L8_SRGB:
- return R300_EASY_TX_FORMAT(X, X, X, ONE, X8) |
- R300_TX_FORMAT_GAMMA;
- /* X16 */
- case PIPE_FORMAT_R16_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, X, X16);
- case PIPE_FORMAT_R16_SNORM:
- return R300_EASY_TX_FORMAT(X, X, X, X, X16) |
- R300_TX_FORMAT_SIGNED;
- /* Y8X8 */
- case PIPE_FORMAT_A8L8_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8);
- case PIPE_FORMAT_A8L8_SRGB:
- return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8) |
- R300_TX_FORMAT_GAMMA;
- /* W8Z8Y8X8 */
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8);
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- return R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
- case PIPE_FORMAT_R8G8B8X8_UNORM:
- return R300_EASY_TX_FORMAT(Y, Z, ONE, X, W8Z8Y8X8);
- case PIPE_FORMAT_A8R8G8B8_SRGB:
- return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8) |
- R300_TX_FORMAT_GAMMA;
- case PIPE_FORMAT_R8G8B8A8_SRGB:
- return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8) |
- R300_TX_FORMAT_GAMMA;
- /* DXT1 */
- case PIPE_FORMAT_DXT1_RGB:
- return R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1);
- case PIPE_FORMAT_DXT1_RGBA:
- return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1);
- /* DXT3 */
- case PIPE_FORMAT_DXT3_RGBA:
- return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3);
- /* DXT5 */
- case PIPE_FORMAT_DXT5_RGBA:
- return R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5);
- /* YVYU422 */
- case PIPE_FORMAT_YCBCR:
- return R300_EASY_TX_FORMAT(X, Y, Z, ONE, YVYU422) |
- R300_TX_FORMAT_YUV_TO_RGB;
- /* W24_FP */
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
-
- default:
- debug_printf("r300: Implementation error: "
- "Got unsupported texture format %s in %s\n",
- pf_name(format), __FUNCTION__);
- assert(0);
- break;
- }
- return 0;
-}
-
-struct r300_video_surface
-{
- struct pipe_video_surface base;
- struct pipe_texture *tex;
-};
-
-static INLINE struct r300_video_surface *
-r300_video_surface(struct pipe_video_surface *pvs)
-{
- return (struct r300_video_surface *)pvs;
-}
-
-#ifndef R300_WINSYS_H
-
-boolean r300_get_texture_buffer(struct pipe_screen* screen,
- struct pipe_texture* texture,
- struct pipe_buffer** buffer,
- unsigned* stride);
-
-#endif /* R300_WINSYS_H */
+void r300_texture_reinterpret_format(struct pipe_screen *screen,
+ struct pipe_resource *tex,
+ enum pipe_format new_format);
+
+boolean r300_is_colorbuffer_format_supported(enum pipe_format format);
+
+boolean r300_is_zs_format_supported(enum pipe_format format);
+
+boolean r300_is_sampler_format_supported(enum pipe_format format);
+
+void r300_texture_setup_format_state(struct r300_screen *screen,
+ struct r300_texture_desc *desc,
+ unsigned level,
+ struct r300_texture_format_state *out);
+
+struct pipe_resource*
+r300_texture_from_handle(struct pipe_screen* screen,
+ const struct pipe_resource* base,
+ struct winsys_handle *whandle);
+
+struct pipe_resource*
+r300_texture_create(struct pipe_screen* screen,
+ const struct pipe_resource* templ);
+
+
+struct pipe_surface* r300_create_surface(struct pipe_context *ctx,
+ struct pipe_resource* texture,
+ const struct pipe_surface *surf_tmpl);
+
+void r300_surface_destroy(struct pipe_context *ctx, struct pipe_surface* s);
#endif /* R300_TEXTURE_H */